FFmpeg
vf_fps.c
Go to the documentation of this file.
1 /*
2  * Copyright 2007 Bobby Bingham
3  * Copyright 2012 Robert Nagy <ronag89 gmail com>
4  * Copyright 2012 Anton Khirnov <anton khirnov net>
5  * Copyright 2018 Calvin Walton <calvin.walton@kepstin.ca>
6  *
7  * This file is part of FFmpeg.
8  *
9  * FFmpeg is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * FFmpeg is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with FFmpeg; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23 
24 /**
25  * @file
26  * a filter enforcing given constant framerate
27  */
28 
29 #include <float.h>
30 #include <stdint.h>
31 
32 #include "libavutil/avassert.h"
33 #include "libavutil/eval.h"
34 #include "libavutil/mathematics.h"
35 #include "libavutil/opt.h"
36 #include "avfilter.h"
37 #include "ccfifo.h"
38 #include "filters.h"
39 #include "internal.h"
40 #include "video.h"
41 
42 enum EOFAction {
46 };
47 
48 static const char *const var_names[] = {
49  "source_fps",
50  "ntsc",
51  "pal",
52  "film",
53  "ntsc_film",
54  NULL
55 };
56 
57 enum var_name {
64 };
65 
66 static const double ntsc_fps = 30000.0 / 1001.0;
67 static const double pal_fps = 25.0;
68 static const double film_fps = 24.0;
69 static const double ntsc_film_fps = 24000.0 / 1001.0;
70 
71 typedef struct FPSContext {
72  const AVClass *class;
73 
74  double start_time; ///< pts, in seconds, of the expected first frame
75 
76  char *framerate; ///< expression that defines the target framerate
77  int rounding; ///< AVRounding method for timestamps
78  int eof_action; ///< action performed for last frame in FIFO
79 
80  /* Set during outlink configuration */
81  int64_t in_pts_off; ///< input frame pts offset for start_time handling
82  int64_t out_pts_off; ///< output frame pts offset for start_time handling
83 
84  /* Runtime state */
85  int status; ///< buffered input status
86  int64_t status_pts; ///< buffered input status timestamp
87 
88  AVFrame *frames[2]; ///< buffered frames
89  int frames_count; ///< number of buffered frames
90  CCFifo cc_fifo; ///< closed captions
91 
92  int64_t next_pts; ///< pts of the next frame to output
93 
94  /* statistics */
95  int cur_frame_out; ///< number of times current frame has been output
96  int frames_in; ///< number of frames on input
97  int frames_out; ///< number of frames on output
98  int dup; ///< number of frames duplicated
99  int drop; ///< number of framed dropped
100 } FPSContext;
101 
102 #define OFFSET(x) offsetof(FPSContext, x)
103 #define V AV_OPT_FLAG_VIDEO_PARAM
104 #define F AV_OPT_FLAG_FILTERING_PARAM
105 static const AVOption fps_options[] = {
106  { "fps", "A string describing desired output framerate", OFFSET(framerate), AV_OPT_TYPE_STRING, { .str = "25" }, 0, 0, V|F },
107  { "start_time", "Assume the first PTS should be this value.", OFFSET(start_time), AV_OPT_TYPE_DOUBLE, { .dbl = DBL_MAX}, -DBL_MAX, DBL_MAX, V|F },
108  { "round", "set rounding method for timestamps", OFFSET(rounding), AV_OPT_TYPE_INT, { .i64 = AV_ROUND_NEAR_INF }, 0, 5, V|F, .unit = "round" },
109  { "zero", "round towards 0", 0, AV_OPT_TYPE_CONST, { .i64 = AV_ROUND_ZERO }, 0, 0, V|F, .unit = "round" },
110  { "inf", "round away from 0", 0, AV_OPT_TYPE_CONST, { .i64 = AV_ROUND_INF }, 0, 0, V|F, .unit = "round" },
111  { "down", "round towards -infty", 0, AV_OPT_TYPE_CONST, { .i64 = AV_ROUND_DOWN }, 0, 0, V|F, .unit = "round" },
112  { "up", "round towards +infty", 0, AV_OPT_TYPE_CONST, { .i64 = AV_ROUND_UP }, 0, 0, V|F, .unit = "round" },
113  { "near", "round to nearest", 0, AV_OPT_TYPE_CONST, { .i64 = AV_ROUND_NEAR_INF }, 0, 0, V|F, .unit = "round" },
114  { "eof_action", "action performed for last frame", OFFSET(eof_action), AV_OPT_TYPE_INT, { .i64 = EOF_ACTION_ROUND }, 0, EOF_ACTION_NB-1, V|F, .unit = "eof_action" },
115  { "round", "round similar to other frames", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_ROUND }, 0, 0, V|F, .unit = "eof_action" },
116  { "pass", "pass through last frame", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_PASS }, 0, 0, V|F, .unit = "eof_action" },
117  { NULL }
118 };
119 
121 
123 {
124  FPSContext *s = ctx->priv;
125 
126  s->status_pts = AV_NOPTS_VALUE;
127  s->next_pts = AV_NOPTS_VALUE;
128 
129  return 0;
130 }
131 
132 /* Remove the first frame from the buffer, returning it */
134 {
135  AVFrame *frame;
136 
137  /* Must only be called when there are frames in the buffer */
138  av_assert1(s->frames_count > 0);
139 
140  frame = s->frames[0];
141  s->frames[0] = s->frames[1];
142  s->frames[1] = NULL;
143  s->frames_count--;
144 
145  /* Update statistics counters */
146  s->frames_out += s->cur_frame_out;
147  if (s->cur_frame_out > 1) {
148  av_log(ctx, AV_LOG_DEBUG, "Duplicated frame with pts %"PRId64" %d times\n",
149  frame->pts, s->cur_frame_out - 1);
150  s->dup += s->cur_frame_out - 1;
151  } else if (s->cur_frame_out == 0) {
152  av_log(ctx, AV_LOG_DEBUG, "Dropping frame with pts %"PRId64"\n",
153  frame->pts);
154  s->drop++;
155  }
156  s->cur_frame_out = 0;
157 
158  return frame;
159 }
160 
162 {
163  FPSContext *s = ctx->priv;
164 
165  AVFrame *frame;
166 
167  while (s->frames_count > 0) {
168  frame = shift_frame(ctx, s);
170  }
171  ff_ccfifo_uninit(&s->cc_fifo);
172 
173  av_log(ctx, AV_LOG_VERBOSE, "%d frames in, %d frames out; %d frames dropped, "
174  "%d frames duplicated.\n", s->frames_in, s->frames_out, s->drop, s->dup);
175 }
176 
177 static int config_props(AVFilterLink* outlink)
178 {
179  AVFilterContext *ctx = outlink->src;
180  AVFilterLink *inlink = ctx->inputs[0];
181  FPSContext *s = ctx->priv;
182 
183  double var_values[VARS_NB], res;
184  int ret;
185 
186  var_values[VAR_SOURCE_FPS] = av_q2d(inlink->frame_rate);
187  var_values[VAR_FPS_NTSC] = ntsc_fps;
188  var_values[VAR_FPS_PAL] = pal_fps;
189  var_values[VAR_FPS_FILM] = film_fps;
190  var_values[VAR_FPS_NTSC_FILM] = ntsc_film_fps;
191  ret = av_expr_parse_and_eval(&res, s->framerate,
192  var_names, var_values,
193  NULL, NULL, NULL, NULL, NULL, 0, ctx);
194  if (ret < 0)
195  return ret;
196 
197  outlink->frame_rate = av_d2q(res, INT_MAX);
198  outlink->time_base = av_inv_q(outlink->frame_rate);
199 
200  /* Calculate the input and output pts offsets for start_time */
201  if (s->start_time != DBL_MAX && s->start_time != AV_NOPTS_VALUE) {
202  double first_pts = s->start_time * AV_TIME_BASE;
203  if (first_pts < INT64_MIN || first_pts > INT64_MAX) {
204  av_log(ctx, AV_LOG_ERROR, "Start time %f cannot be represented in internal time base\n",
205  s->start_time);
206  return AVERROR(EINVAL);
207  }
208  s->in_pts_off = av_rescale_q_rnd(first_pts, AV_TIME_BASE_Q, inlink->time_base,
209  s->rounding | AV_ROUND_PASS_MINMAX);
210  s->out_pts_off = av_rescale_q_rnd(first_pts, AV_TIME_BASE_Q, outlink->time_base,
211  s->rounding | AV_ROUND_PASS_MINMAX);
212  s->next_pts = s->out_pts_off;
213  av_log(ctx, AV_LOG_VERBOSE, "Set first pts to (in:%"PRId64" out:%"PRId64") from start time %f\n",
214  s->in_pts_off, s->out_pts_off, s->start_time);
215  }
216 
217  ret = ff_ccfifo_init(&s->cc_fifo, outlink->frame_rate, ctx);
218  if (ret < 0) {
219  av_log(ctx, AV_LOG_ERROR, "Failure to setup CC FIFO queue\n");
220  return ret;
221  }
222 
223  av_log(ctx, AV_LOG_VERBOSE, "fps=%d/%d\n", outlink->frame_rate.num, outlink->frame_rate.den);
224 
225  return 0;
226 }
227 
228 /* Read a frame from the input and save it in the buffer */
230 {
231  AVFrame *frame;
232  int ret;
233  int64_t in_pts;
234 
235  /* Must only be called when we have buffer room available */
236  av_assert1(s->frames_count < 2);
237 
239  /* Caller must have run ff_inlink_check_available_frame first */
240  av_assert1(ret);
241  if (ret < 0)
242  return ret;
243 
244  /* Convert frame pts to output timebase.
245  * The dance with offsets is required to match the rounding behaviour of the
246  * previous version of the fps filter when using the start_time option. */
247  in_pts = frame->pts;
248  frame->pts = s->out_pts_off + av_rescale_q_rnd(in_pts - s->in_pts_off,
249  inlink->time_base, outlink->time_base,
250  s->rounding | AV_ROUND_PASS_MINMAX);
251 
252  av_log(ctx, AV_LOG_DEBUG, "Read frame with in pts %"PRId64", out pts %"PRId64"\n",
253  in_pts, frame->pts);
254 
255  ff_ccfifo_extract(&s->cc_fifo, frame);
256  s->frames[s->frames_count++] = frame;
257  s->frames_in++;
258 
259  return 1;
260 }
261 
262 /* Write a frame to the output */
264 {
265  AVFrame *frame;
266 
267  av_assert1(s->frames_count == 2 || (s->status && s->frames_count == 1));
268 
269  /* We haven't yet determined the pts of the first frame */
270  if (s->next_pts == AV_NOPTS_VALUE) {
271  if (s->frames[0]->pts != AV_NOPTS_VALUE) {
272  s->next_pts = s->frames[0]->pts;
273  av_log(ctx, AV_LOG_VERBOSE, "Set first pts to %"PRId64"\n", s->next_pts);
274  } else {
275  av_log(ctx, AV_LOG_WARNING, "Discarding initial frame(s) with no "
276  "timestamp.\n");
277  frame = shift_frame(ctx, s);
279  *again = 1;
280  return 0;
281  }
282  }
283 
284  /* There are two conditions where we want to drop a frame:
285  * - If we have two buffered frames and the second frame is acceptable
286  * as the next output frame, then drop the first buffered frame.
287  * - If we have status (EOF) set, drop frames when we hit the
288  * status timestamp. */
289  if ((s->frames_count == 2 && s->frames[1]->pts <= s->next_pts) ||
290  (s->status && s->status_pts <= s->next_pts)) {
291 
292  frame = shift_frame(ctx, s);
294  *again = 1;
295  return 0;
296 
297  /* Output a copy of the first buffered frame */
298  } else {
299  frame = av_frame_clone(s->frames[0]);
300  if (!frame)
301  return AVERROR(ENOMEM);
302  // Make sure Closed Captions will not be duplicated
303  ff_ccfifo_inject(&s->cc_fifo, frame);
304  frame->pts = s->next_pts++;
305  frame->duration = 1;
306 
307  av_log(ctx, AV_LOG_DEBUG, "Writing frame with pts %"PRId64" to pts %"PRId64"\n",
308  s->frames[0]->pts, frame->pts);
309  s->cur_frame_out++;
310  *again = 1;
311  return ff_filter_frame(outlink, frame);
312  }
313 }
314 
315 /* Convert status_pts to outlink timebase */
317 {
318  int eof_rounding = (s->eof_action == EOF_ACTION_PASS) ? AV_ROUND_UP : s->rounding;
319  s->status_pts = av_rescale_q_rnd(status_pts, inlink->time_base, outlink->time_base,
320  eof_rounding | AV_ROUND_PASS_MINMAX);
321 
322  av_log(ctx, AV_LOG_DEBUG, "EOF is at pts %"PRId64"\n", s->status_pts);
323 }
324 
326 {
327  FPSContext *s = ctx->priv;
328  AVFilterLink *inlink = ctx->inputs[0];
329  AVFilterLink *outlink = ctx->outputs[0];
330 
331  int ret;
332  int again = 0;
333  int64_t status_pts;
334 
336 
337  /* No buffered status: normal operation */
338  if (!s->status) {
339 
340  /* Read available input frames if we have room */
341  while (s->frames_count < 2 && ff_inlink_check_available_frame(inlink)) {
342  ret = read_frame(ctx, s, inlink, outlink);
343  if (ret < 0)
344  return ret;
345  }
346 
347  /* We do not yet have enough frames to produce output */
348  if (s->frames_count < 2) {
349  /* Check if we've hit EOF (or otherwise that an error status is set) */
350  ret = ff_inlink_acknowledge_status(inlink, &s->status, &status_pts);
351  if (ret > 0)
352  update_eof_pts(ctx, s, inlink, outlink, status_pts);
353 
354  if (!ret) {
355  /* If someone wants us to output, we'd better ask for more input */
357  return 0;
358  }
359  }
360  }
361 
362  /* Buffered frames are available, so generate an output frame */
363  if (s->frames_count > 0) {
364  ret = write_frame(ctx, s, outlink, &again);
365  /* Couldn't generate a frame, so schedule us to perform another step */
366  if (again && ff_inoutlink_check_flow(inlink, outlink))
367  ff_filter_set_ready(ctx, 100);
368  return ret;
369  }
370 
371  /* No frames left, so forward the status */
372  if (s->status && s->frames_count == 0) {
373  ff_outlink_set_status(outlink, s->status, s->next_pts);
374  return 0;
375  }
376 
377  return FFERROR_NOT_READY;
378 }
379 
381  {
382  .name = "default",
383  .type = AVMEDIA_TYPE_VIDEO,
384  .config_props = config_props,
385  },
386 };
387 
389  .name = "fps",
390  .description = NULL_IF_CONFIG_SMALL("Force constant framerate."),
391  .init = init,
392  .uninit = uninit,
393  .priv_size = sizeof(FPSContext),
394  .priv_class = &fps_class,
395  .activate = activate,
399 };
AV_ROUND_UP
@ AV_ROUND_UP
Round toward +infinity.
Definition: mathematics.h:134
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
VARS_NB
@ VARS_NB
Definition: vf_fps.c:63
var_name
var_name
Definition: noise.c:47
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1015
FFERROR_NOT_READY
return FFERROR_NOT_READY
Definition: filter_design.txt:204
AV_TIME_BASE_Q
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Definition: avutil.h:264
int64_t
long long int64_t
Definition: coverity.c:34
inlink
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Definition: filter_design.txt:212
EOF_ACTION_PASS
@ EOF_ACTION_PASS
Definition: vf_fps.c:44
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:160
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:374
VAR_FPS_NTSC
@ VAR_FPS_NTSC
Definition: vf_fps.c:59
AVOption
AVOption.
Definition: opt.h:357
AV_ROUND_ZERO
@ AV_ROUND_ZERO
Round toward zero.
Definition: mathematics.h:131
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
float.h
ntsc_fps
static const double ntsc_fps
Definition: vf_fps.c:66
var_names
static const char *const var_names[]
Definition: vf_fps.c:48
mathematics.h
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:170
pal_fps
static const double pal_fps
Definition: vf_fps.c:67
video.h
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_fps.c:122
FF_FILTER_FORWARD_STATUS_BACK
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
Definition: filters.h:199
config_props
static int config_props(AVFilterLink *outlink)
Definition: vf_fps.c:177
ff_inoutlink_check_flow
int ff_inoutlink_check_flow(AVFilterLink *inlink, AVFilterLink *outlink)
Check for flow control between input and output.
Definition: avfilter.c:1599
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_fps.c:161
ff_inlink_consume_frame
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
Definition: avfilter.c:1442
ff_ccfifo_uninit
void ff_ccfifo_uninit(CCFifo *ccf)
Free all memory allocated in a CCFifo and clear the context.
Definition: ccfifo.c:46
EOFAction
EOFAction
Definition: framesync.h:26
AVRational::num
int num
Numerator.
Definition: rational.h:59
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:33
avassert.h
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
update_eof_pts
static void update_eof_pts(AVFilterContext *ctx, FPSContext *s, AVFilterLink *inlink, AVFilterLink *outlink, int64_t status_pts)
Definition: vf_fps.c:316
av_cold
#define av_cold
Definition: attributes.h:90
ff_video_default_filterpad
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
Definition: video.c:37
ff_ccfifo_inject
int ff_ccfifo_inject(CCFifo *ccf, AVFrame *frame)
Insert CC data from the FIFO into an AVFrame (as side data)
Definition: ccfifo.c:133
ff_outlink_set_status
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
Definition: filters.h:189
FPSContext::eof_action
int eof_action
action performed for last frame in FIFO
Definition: vf_fps.c:78
s
#define s(width, name)
Definition: cbs_vp9.c:198
FPSContext::frames_in
int frames_in
number of frames on input
Definition: vf_fps.c:96
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Definition: opt.h:247
V
#define V
Definition: vf_fps.c:103
av_q2d
static double av_q2d(AVRational a)
Convert an AVRational to a double.
Definition: rational.h:104
filters.h
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
ctx
AVFormatContext * ctx
Definition: movenc.c:49
av_frame_clone
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:593
FPSContext::frames_count
int frames_count
number of buffered frames
Definition: vf_fps.c:89
AV_ROUND_NEAR_INF
@ AV_ROUND_NEAR_INF
Round to nearest and halfway cases away from zero.
Definition: mathematics.h:135
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
AV_ROUND_PASS_MINMAX
@ AV_ROUND_PASS_MINMAX
Flag telling rescaling functions to pass INT64_MIN/MAX through unchanged, avoiding special cases for ...
Definition: mathematics.h:159
write_frame
static int write_frame(AVFilterContext *ctx, FPSContext *s, AVFilterLink *outlink, int *again)
Definition: vf_fps.c:263
FPSContext::out_pts_off
int64_t out_pts_off
output frame pts offset for start_time handling
Definition: vf_fps.c:82
ntsc_film_fps
static const double ntsc_film_fps
Definition: vf_fps.c:69
OFFSET
#define OFFSET(x)
Definition: vf_fps.c:102
framerate
float framerate
Definition: av1_levels.c:29
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
avfilter_vf_fps_outputs
static const AVFilterPad avfilter_vf_fps_outputs[]
Definition: vf_fps.c:380
ff_ccfifo_extract
int ff_ccfifo_extract(CCFifo *ccf, AVFrame *frame)
Extract CC data from an AVFrame.
Definition: ccfifo.c:183
FPSContext::status_pts
int64_t status_pts
buffered input status timestamp
Definition: vf_fps.c:86
FPSContext::frames
AVFrame * frames[2]
buffered frames
Definition: vf_fps.c:88
CCFifo
Definition: ccfifo.h:40
ff_inlink_acknowledge_status
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
Definition: avfilter.c:1389
VAR_FPS_FILM
@ VAR_FPS_FILM
Definition: vf_fps.c:61
AV_ROUND_DOWN
@ AV_ROUND_DOWN
Round toward -infinity.
Definition: mathematics.h:133
FPSContext::status
int status
buffered input status
Definition: vf_fps.c:85
read_frame
static int read_frame(AVFilterContext *ctx, FPSContext *s, AVFilterLink *inlink, AVFilterLink *outlink)
Definition: vf_fps.c:229
eval.h
FPSContext
Definition: vf_fps.c:71
ff_inlink_check_available_frame
int ff_inlink_check_available_frame(AVFilterLink *link)
Test if a frame is available on the link.
Definition: avfilter.c:1411
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:94
av_expr_parse_and_eval
int av_expr_parse_and_eval(double *d, const char *s, const char *const *const_names, const double *const_values, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), void *opaque, int log_offset, void *log_ctx)
Parse and evaluate an expression.
Definition: eval.c:803
start_time
static int64_t start_time
Definition: ffplay.c:326
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
ff_vf_fps
const AVFilter ff_vf_fps
Definition: vf_fps.c:388
EOF_ACTION_ROUND
@ EOF_ACTION_ROUND
Definition: vf_fps.c:43
FPSContext::next_pts
int64_t next_pts
pts of the next frame to output
Definition: vf_fps.c:92
FF_FILTER_FORWARD_WANTED
FF_FILTER_FORWARD_WANTED(outlink, inlink)
EOF_ACTION_NB
@ EOF_ACTION_NB
Definition: vf_fps.c:45
FPSContext::drop
int drop
number of framed dropped
Definition: vf_fps.c:99
internal.h
shift_frame
static AVFrame * shift_frame(AVFilterContext *ctx, FPSContext *s)
Definition: vf_fps.c:133
FPSContext::framerate
char * framerate
expression that defines the target framerate
Definition: vf_fps.c:76
AV_TIME_BASE
#define AV_TIME_BASE
Internal time base represented as integer.
Definition: avutil.h:254
AV_ROUND_INF
@ AV_ROUND_INF
Round away from zero.
Definition: mathematics.h:132
FPSContext::cc_fifo
CCFifo cc_fifo
closed captions
Definition: vf_fps.c:90
av_assert1
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:56
av_d2q
AVRational av_d2q(double d, int max)
Convert a double precision floating point number to a rational.
Definition: rational.c:106
av_inv_q
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:159
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:39
AVFilter
Filter definition.
Definition: avfilter.h:166
ff_ccfifo_init
int ff_ccfifo_init(CCFifo *ccf, AVRational framerate, void *log_ctx)
Initialize a CCFifo.
Definition: ccfifo.c:53
ret
ret
Definition: filter_design.txt:187
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
again
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining again
Definition: filter_design.txt:25
AVRational::den
int den
Denominator.
Definition: rational.h:60
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:245
avfilter.h
AVFILTER_FLAG_METADATA_ONLY
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
Definition: avfilter.h:133
FPSContext::in_pts_off
int64_t in_pts_off
input frame pts offset for start_time handling
Definition: vf_fps.c:81
film_fps
static const double film_fps
Definition: vf_fps.c:68
F
#define F
Definition: vf_fps.c:104
FPSContext::dup
int dup
number of frames duplicated
Definition: vf_fps.c:98
AVFilterContext
An instance of a filter.
Definition: avfilter.h:407
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
FPSContext::start_time
double start_time
pts, in seconds, of the expected first frame
Definition: vf_fps.c:74
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(fps)
activate
static int activate(AVFilterContext *ctx)
Definition: vf_fps.c:325
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
fps_options
static const AVOption fps_options[]
Definition: vf_fps.c:105
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:474
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
ccfifo.h
FPSContext::cur_frame_out
int cur_frame_out
number of times current frame has been output
Definition: vf_fps.c:95
VAR_FPS_NTSC_FILM
@ VAR_FPS_NTSC_FILM
Definition: vf_fps.c:62
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:249
VAR_SOURCE_FPS
@ VAR_SOURCE_FPS
Definition: vf_fps.c:58
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:254
av_rescale_q_rnd
int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq, enum AVRounding rnd)
Rescale a 64-bit integer by 2 rational numbers with specified rounding.
Definition: mathematics.c:134
FPSContext::frames_out
int frames_out
number of frames on output
Definition: vf_fps.c:97
FPSContext::rounding
int rounding
AVRounding method for timestamps.
Definition: vf_fps.c:77
ff_filter_set_ready
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.
Definition: avfilter.c:235
VAR_FPS_PAL
@ VAR_FPS_PAL
Definition: vf_fps.c:60