1 /*
2 * Copyright 2007 Bobby Bingham
3 * Copyright 2012 Robert Nagy <ronag89 gmail com>
4 * Copyright 2012 Anton Khirnov <anton khirnov net>
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 /**
24 * @file
25 * a filter enforcing given constant framerate
26 */
27
29 #include <stdint.h>
30
36
40
43
45
46 /* timestamps in input timebase */
47 int64_t
first_pts;
///< pts of the first frame that arrived on this filter
48
49 double start_time;
///< pts, in seconds, of the expected first frame
50
52 int rounding;
///< AVRounding method for timestamps
53
54 /* statistics */
57 int dup;
///< number of frames duplicated
58 int drop;
///< number of framed dropped
60
61 #define OFFSET(x) offsetof(FPSContext, x)
62 #define V AV_OPT_FLAG_VIDEO_PARAM
63 #define F AV_OPT_FLAG_FILTERING_PARAM
74 };
75
77
79 {
81
84
86
88 return 0;
89 }
90
92 {
97 }
98 }
99
101 {
107 }
108
111 }
112
114 {
116
121
122 return 0;
123 }
124
126 {
131
132 while (ret >= 0 && s->
frames_out == frames_out)
134
135 /* flush the fifo */
137 int i;
140
144
147
149 }
150 return 0;
151 }
152
154 }
155
157 {
159
164 }
165
167 return 0;
168 }
169
171 {
177
179 /* discard frames until we get the first timestamp */
183 if (ret < 0)
185
188 first_pts =
FFMIN(
FFMAX(first_pts, INT64_MIN), INT64_MAX);
194 } else {
196 }
197 } else {
199 "timestamp.\n");
202 }
203 return 0;
204 }
205
206 /* now wait for the next timestamp */
209 }
210
211 /* number of output frames */
214
215 if (delta < 1) {
216 /* drop everything buffered except the last */
218
221
224
226 }
227
228 /* can output >= 1 frames */
229 for (i = 0; i <
delta; i++) {
232
233 /* duplicate the frame if needed */
236
238 if (dup)
240 else
242
243 if (ret < 0) {
247 }
248
250 }
251
254
258 }
259
261 }
263
265
267 }
268
270 {
274 },
276 };
277
279 {
284 },
286 };
287
294 .priv_class = &fps_class,
295 .
inputs = avfilter_vf_fps_inputs,
296 .
outputs = avfilter_vf_fps_outputs,
297 };