FFmpeg
framesync.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Nicolas George
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public License
8  * as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with FFmpeg; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "libavutil/avassert.h"
22 #include "libavutil/opt.h"
23 #include "avfilter.h"
24 #include "filters.h"
25 #include "framesync.h"
26 #include "internal.h"
27 
28 #define OFFSET(member) offsetof(FFFrameSync, member)
29 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
30 
31 static const char *framesync_name(void *ptr)
32 {
33  return "framesync";
34 }
35 
36 static const AVOption framesync_options[] = {
37  { "eof_action", "Action to take when encountering EOF from secondary input ",
38  OFFSET(opt_eof_action), AV_OPT_TYPE_INT, { .i64 = EOF_ACTION_REPEAT },
39  EOF_ACTION_REPEAT, EOF_ACTION_PASS, .flags = FLAGS, "eof_action" },
40  { "repeat", "Repeat the previous frame.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_REPEAT }, .flags = FLAGS, "eof_action" },
41  { "endall", "End both streams.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_ENDALL }, .flags = FLAGS, "eof_action" },
42  { "pass", "Pass through the main input.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_PASS }, .flags = FLAGS, "eof_action" },
43  { "shortest", "force termination when the shortest input terminates", OFFSET(opt_shortest), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
44  { "repeatlast", "extend last frame of secondary streams beyond EOF", OFFSET(opt_repeatlast), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS },
45  { "ts_sync_mode", "How strictly to sync streams based on secondary input timestamps",
46  OFFSET(opt_ts_sync_mode), AV_OPT_TYPE_INT, { .i64 = TS_DEFAULT },
47  TS_DEFAULT, TS_NEAREST, .flags = FLAGS, "ts_sync_mode" },
48  { "default", "Frame from secondary input with the nearest lower or equal timestamp to the primary input frame",
49  0, AV_OPT_TYPE_CONST, { .i64 = TS_DEFAULT }, .flags = FLAGS, "ts_sync_mode" },
50  { "nearest", "Frame from secondary input with the absolute nearest timestamp to the primary input frame",
51  0, AV_OPT_TYPE_CONST, { .i64 = TS_NEAREST }, .flags = FLAGS, "ts_sync_mode" },
52  { NULL }
53 };
54 static const AVClass framesync_class = {
56  .class_name = "framesync",
57  .item_name = framesync_name,
58  .category = AV_CLASS_CATEGORY_FILTER,
59  .option = framesync_options,
60  .parent_log_context_offset = OFFSET(parent),
61 };
62 
64 {
65  const AVClass *c = *iter ? NULL : &framesync_class;
66  *iter = (void *)(uintptr_t)c;
67  return c;
68 }
69 
70 enum {
74 };
75 
76 static int consume_from_fifos(FFFrameSync *fs);
77 
79 {
80  if (fs->class)
81  return;
82  fs->class = &framesync_class;
84 }
85 
86 int ff_framesync_init(FFFrameSync *fs, AVFilterContext *parent, unsigned nb_in)
87 {
88  /* For filters with several outputs, we will not be able to assume which
89  output is relevant for ff_outlink_frame_wanted() and
90  ff_outlink_set_status(). To be designed when needed. */
91  av_assert0(parent->nb_outputs == 1);
92 
94  fs->parent = parent;
95  fs->nb_in = nb_in;
96 
97  fs->in = av_calloc(nb_in, sizeof(*fs->in));
98  if (!fs->in)
99  return AVERROR(ENOMEM);
100  return 0;
101 }
102 
104 {
105  fs->eof = 1;
106  fs->frame_ready = 0;
107  ff_outlink_set_status(fs->parent->outputs[0], AVERROR_EOF, AV_NOPTS_VALUE);
108 }
109 
111 {
112  unsigned i, level = 0;
113 
114  for (i = 0; i < fs->nb_in; i++)
115  if (fs->in[i].state != STATE_EOF)
116  level = FFMAX(level, fs->in[i].sync);
117  av_assert0(level <= fs->sync_level);
118  if (level < fs->sync_level)
119  av_log(fs, AV_LOG_VERBOSE, "Sync level %u\n", level);
120  if (fs->opt_ts_sync_mode > TS_DEFAULT) {
121  for (i = 0; i < fs->nb_in; i++) {
122  if (fs->in[i].sync < level)
123  fs->in[i].ts_mode = fs->opt_ts_sync_mode;
124  else
125  fs->in[i].ts_mode = TS_DEFAULT;
126  }
127  }
128  if (level)
129  fs->sync_level = level;
130  else
131  framesync_eof(fs);
132 }
133 
135 {
136  unsigned i;
137 
138  if (!fs->opt_repeatlast || fs->opt_eof_action == EOF_ACTION_PASS) {
139  fs->opt_repeatlast = 0;
140  fs->opt_eof_action = EOF_ACTION_PASS;
141  }
142  if (fs->opt_shortest || fs->opt_eof_action == EOF_ACTION_ENDALL) {
143  fs->opt_shortest = 1;
144  fs->opt_eof_action = EOF_ACTION_ENDALL;
145  }
146  if (!fs->opt_repeatlast) {
147  for (i = 1; i < fs->nb_in; i++) {
148  fs->in[i].after = EXT_NULL;
149  fs->in[i].sync = 0;
150  }
151  }
152  if (fs->opt_shortest) {
153  for (i = 0; i < fs->nb_in; i++)
154  fs->in[i].after = EXT_STOP;
155  }
156 
157  if (!fs->time_base.num) {
158  for (i = 0; i < fs->nb_in; i++) {
159  if (fs->in[i].sync) {
160  if (fs->time_base.num) {
161  fs->time_base = av_gcd_q(fs->time_base, fs->in[i].time_base,
163  } else {
164  fs->time_base = fs->in[i].time_base;
165  }
166  }
167  }
168  if (!fs->time_base.num) {
169  av_log(fs, AV_LOG_ERROR, "Impossible to set time base\n");
170  return AVERROR(EINVAL);
171  }
172  av_log(fs, AV_LOG_VERBOSE, "Selected %d/%d time base\n",
173  fs->time_base.num, fs->time_base.den);
174  }
175 
176  for (i = 0; i < fs->nb_in; i++)
177  fs->in[i].pts = fs->in[i].pts_next = AV_NOPTS_VALUE;
178  fs->sync_level = UINT_MAX;
180 
181  return 0;
182 }
183 
185 {
186  unsigned i;
187  int64_t pts;
188  int ret;
189 
190  while (!(fs->frame_ready || fs->eof)) {
192  if (ret <= 0)
193  return ret;
194 
195  pts = INT64_MAX;
196  for (i = 0; i < fs->nb_in; i++)
197  if (fs->in[i].have_next && fs->in[i].pts_next < pts)
198  pts = fs->in[i].pts_next;
199  if (pts == INT64_MAX) {
200  framesync_eof(fs);
201  break;
202  }
203  for (i = 0; i < fs->nb_in; i++) {
204  if (fs->in[i].pts_next == pts ||
205  (fs->in[i].ts_mode == TS_NEAREST &&
206  fs->in[i].have_next &&
207  fs->in[i].pts_next != INT64_MAX && fs->in[i].pts != AV_NOPTS_VALUE &&
208  fs->in[i].pts_next - pts < pts - fs->in[i].pts) ||
209  (fs->in[i].before == EXT_INFINITY &&
210  fs->in[i].state == STATE_BOF)) {
211  av_frame_free(&fs->in[i].frame);
212  fs->in[i].frame = fs->in[i].frame_next;
213  fs->in[i].pts = fs->in[i].pts_next;
214  fs->in[i].frame_next = NULL;
215  fs->in[i].pts_next = AV_NOPTS_VALUE;
216  fs->in[i].have_next = 0;
217  fs->in[i].state = fs->in[i].frame ? STATE_RUN : STATE_EOF;
218  if (fs->in[i].sync == fs->sync_level && fs->in[i].frame)
219  fs->frame_ready = 1;
220  if (fs->in[i].state == STATE_EOF &&
221  fs->in[i].after == EXT_STOP)
222  framesync_eof(fs);
223  }
224  }
225  if (fs->frame_ready)
226  for (i = 0; i < fs->nb_in; i++)
227  if ((fs->in[i].state == STATE_BOF &&
228  fs->in[i].before == EXT_STOP))
229  fs->frame_ready = 0;
230  fs->pts = pts;
231  }
232  return 0;
233 }
234 
235 static int64_t framesync_pts_extrapolate(FFFrameSync *fs, unsigned in,
236  int64_t pts)
237 {
238  /* Possible enhancement: use the link's frame rate */
239  return pts + 1;
240 }
241 
242 static void framesync_inject_frame(FFFrameSync *fs, unsigned in, AVFrame *frame)
243 {
244  int64_t pts;
245 
246  av_assert0(!fs->in[in].have_next);
247  av_assert0(frame);
248  pts = av_rescale_q(frame->pts, fs->in[in].time_base, fs->time_base);
249  frame->pts = pts;
250  fs->in[in].frame_next = frame;
251  fs->in[in].pts_next = pts;
252  fs->in[in].have_next = 1;
253 }
254 
255 static void framesync_inject_status(FFFrameSync *fs, unsigned in, int status, int64_t pts)
256 {
257  av_assert0(!fs->in[in].have_next);
258  pts = fs->in[in].state != STATE_RUN || fs->in[in].after == EXT_INFINITY
259  ? INT64_MAX : framesync_pts_extrapolate(fs, in, fs->in[in].pts);
260  fs->in[in].sync = 0;
262  fs->in[in].frame_next = NULL;
263  fs->in[in].pts_next = pts;
264  fs->in[in].have_next = 1;
265 }
266 
267 int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe,
268  unsigned get)
269 {
270  AVFrame *frame;
271  unsigned need_copy = 0, i;
272  int64_t pts_next;
273  int ret;
274 
275  if (!fs->in[in].frame) {
276  *rframe = NULL;
277  return 0;
278  }
279  frame = fs->in[in].frame;
280  if (get) {
281  /* Find out if we need to copy the frame: is there another sync
282  stream, and do we know if its current frame will outlast this one? */
283  pts_next = fs->in[in].have_next ? fs->in[in].pts_next : INT64_MAX;
284  for (i = 0; i < fs->nb_in && !need_copy; i++)
285  if (i != in && fs->in[i].sync &&
286  (!fs->in[i].have_next || fs->in[i].pts_next < pts_next))
287  need_copy = 1;
288  if (need_copy) {
289  if (!(frame = av_frame_clone(frame)))
290  return AVERROR(ENOMEM);
291  if ((ret = av_frame_make_writable(frame)) < 0) {
293  return ret;
294  }
295  } else {
296  fs->in[in].frame = NULL;
297  }
298  fs->frame_ready = 0;
299  }
300  *rframe = frame;
301  return 0;
302 }
303 
305 {
306  unsigned i;
307 
308  for (i = 0; i < fs->nb_in; i++) {
309  av_frame_free(&fs->in[i].frame);
310  av_frame_free(&fs->in[i].frame_next);
311  }
312 
313  av_freep(&fs->in);
314 }
315 
317 {
318  AVFilterContext *ctx = fs->parent;
319  AVFrame *frame = NULL;
320  int64_t pts;
321  unsigned i, nb_active, nb_miss;
322  int ret, status;
323 
324  nb_active = nb_miss = 0;
325  for (i = 0; i < fs->nb_in; i++) {
326  if (fs->in[i].have_next || fs->in[i].state == STATE_EOF)
327  continue;
328  nb_active++;
329  ret = ff_inlink_consume_frame(ctx->inputs[i], &frame);
330  if (ret < 0)
331  return ret;
332  if (ret) {
333  av_assert0(frame);
335  } else {
337  if (ret > 0) {
339  } else if (!ret) {
340  nb_miss++;
341  }
342  }
343  }
344  if (nb_miss) {
345  if (nb_miss == nb_active && !ff_outlink_frame_wanted(ctx->outputs[0]))
346  return FFERROR_NOT_READY;
347  for (i = 0; i < fs->nb_in; i++)
348  if (!fs->in[i].have_next && fs->in[i].state != STATE_EOF)
349  ff_inlink_request_frame(ctx->inputs[i]);
350  return 0;
351  }
352  return 1;
353 }
354 
356 {
357  int ret;
358 
360  if (ret < 0)
361  return ret;
362  if (fs->eof || !fs->frame_ready)
363  return 0;
364  ret = fs->on_event(fs);
365  if (ret < 0)
366  return ret;
367  fs->frame_ready = 0;
368 
369  return 0;
370 }
371 
373 {
374  int ret;
375 
376  ret = ff_framesync_init(fs, parent, 2);
377  if (ret < 0)
378  return ret;
379  fs->in[0].time_base = parent->inputs[0]->time_base;
380  fs->in[1].time_base = parent->inputs[1]->time_base;
381  fs->in[0].sync = 2;
382  fs->in[0].before = EXT_STOP;
383  fs->in[0].after = EXT_INFINITY;
384  fs->in[1].sync = 1;
385  fs->in[1].before = EXT_NULL;
386  fs->in[1].after = EXT_INFINITY;
387  return 0;
388 }
389 
391 {
392  AVFilterContext *ctx = fs->parent;
393  AVFrame *mainpic = NULL, *secondpic = NULL;
394  int ret;
395 
396  if ((ret = ff_framesync_get_frame(fs, 0, &mainpic, 1)) < 0 ||
397  (ret = ff_framesync_get_frame(fs, 1, &secondpic, 0)) < 0) {
398  av_frame_free(&mainpic);
399  return ret;
400  }
401  av_assert0(mainpic);
402  mainpic->pts = av_rescale_q(fs->pts, fs->time_base, ctx->outputs[0]->time_base);
403  if (ctx->is_disabled)
404  secondpic = NULL;
405  *f0 = mainpic;
406  *f1 = secondpic;
407  return 0;
408 }
409 
411 {
412  int ret;
413 
414  ret = ff_framesync_dualinput_get(fs, f0, f1);
415  if (ret < 0)
416  return ret;
417  ret = ff_inlink_make_frame_writable(fs->parent->inputs[0], f0);
418  if (ret < 0) {
419  av_frame_free(f0);
420  *f1 = NULL;
421  return ret;
422  }
423  return 0;
424 }
ff_framesync_configure
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
Definition: framesync.c:134
status
they must not be accessed directly The fifo field contains the frames that are queued in the input for processing by the filter The status_in and status_out fields contains the queued status(EOF or error) of the link
level
uint8_t level
Definition: svq3.c:204
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
av_opt_set_defaults
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
Definition: opt.c:1459
ff_framesync_uninit
void ff_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
Definition: framesync.c:304
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
FFERROR_NOT_READY
return FFERROR_NOT_READY
Definition: filter_design.txt:204
consume_from_fifos
static int consume_from_fifos(FFFrameSync *fs)
Definition: framesync.c:316
ff_framesync_get_frame
int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, unsigned get)
Get the current frame in an input.
Definition: framesync.c:267
AV_TIME_BASE_Q
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Definition: avutil.h:260
AVClass::version
int version
LIBAVUTIL_VERSION with which this structure was created.
Definition: log.h:92
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:116
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:325
av_frame_make_writable
int av_frame_make_writable(AVFrame *frame)
Ensure that the frame data is writable, avoiding data copy if possible.
Definition: frame.c:550
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:432
AVOption
AVOption.
Definition: opt.h:251
EOF_ACTION_ENDALL
@ EOF_ACTION_ENDALL
Definition: framesync.h:28
AVFilterContext::nb_outputs
unsigned nb_outputs
number of output pads
Definition: avfilter.h:428
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
FFFrameSync
Frame sync structure.
Definition: framesync.h:168
EXT_INFINITY
@ EXT_INFINITY
Extend the frame to infinity.
Definition: framesync.h:75
framesync_advance
static int framesync_advance(FFFrameSync *fs)
Definition: framesync.c:184
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:1404
EXT_STOP
@ EXT_STOP
Completely stop all streams with this one.
Definition: framesync.h:65
ff_framesync_child_class_iterate
const AVClass * ff_framesync_child_class_iterate(void **iter)
Definition: framesync.c:63
framesync_inject_frame
static void framesync_inject_frame(FFFrameSync *fs, unsigned in, AVFrame *frame)
Definition: framesync.c:242
EXT_NULL
@ EXT_NULL
Ignore this stream and continue processing the other ones.
Definition: framesync.h:70
framesync_pts_extrapolate
static int64_t framesync_pts_extrapolate(FFFrameSync *fs, unsigned in, int64_t pts)
Definition: framesync.c:235
pts
static int64_t pts
Definition: transcode_aac.c:654
OFFSET
#define OFFSET(member)
Definition: framesync.c:28
STATE_BOF
@ STATE_BOF
Definition: framesync.c:71
avassert.h
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
FLAGS
#define FLAGS
Definition: framesync.c:29
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
ff_inlink_request_frame
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
Definition: avfilter.c:1521
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
filters.h
ctx
AVFormatContext * ctx
Definition: movenc.c:48
av_frame_clone
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:474
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
STATE_EOF
@ STATE_EOF
Definition: framesync.c:73
EOF_ACTION_PASS
@ EOF_ACTION_PASS
Definition: framesync.h:29
ff_inlink_make_frame_writable
int ff_inlink_make_frame_writable(AVFilterLink *link, AVFrame **rframe)
Make sure a frame is writable.
Definition: avfilter.c:1448
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
TS_DEFAULT
@ TS_DEFAULT
Sync to frames from secondary input with the nearest, lower or equal timestamp to the frame event one...
Definition: framesync.h:90
NULL
#define NULL
Definition: coverity.c:32
fs
#define fs(width, name, subs,...)
Definition: cbs_vp9.c:258
AVFilterContext::inputs
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:423
framesync_inject_status
static void framesync_inject_status(FFFrameSync *fs, unsigned in, int status, int64_t pts)
Definition: framesync.c:255
get
static void get(const uint8_t *pixels, int stride, int16_t *block)
Definition: proresenc_anatoliy.c:307
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:1358
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
AV_CLASS_CATEGORY_FILTER
@ AV_CLASS_CATEGORY_FILTER
Definition: log.h:36
framesync_sync_level_update
static void framesync_sync_level_update(FFFrameSync *fs)
Definition: framesync.c:110
STATE_RUN
@ STATE_RUN
Definition: framesync.c:72
ff_framesync_init_dualinput
int ff_framesync_init_dualinput(FFFrameSync *fs, AVFilterContext *parent)
Initialize a frame sync structure for dualinput.
Definition: framesync.c:372
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
framesync_options
static const AVOption framesync_options[]
Definition: framesync.c:36
internal.h
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
av_gcd_q
AVRational av_gcd_q(AVRational a, AVRational b, int max_den, AVRational def)
Return the best rational so that a and b are multiple of it.
Definition: rational.c:186
AV_TIME_BASE
#define AV_TIME_BASE
Internal time base represented as integer.
Definition: avutil.h:254
framesync_eof
static void framesync_eof(FFFrameSync *fs)
Definition: framesync.c:103
framesync_class
static const AVClass framesync_class
Definition: framesync.c:54
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:272
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
ff_framesync_init
int ff_framesync_init(FFFrameSync *fs, AVFilterContext *parent, unsigned nb_in)
Initialize a frame sync structure.
Definition: framesync.c:86
EOF_ACTION_REPEAT
@ EOF_ACTION_REPEAT
Definition: framesync.h:27
framesync.h
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
avfilter.h
TS_NEAREST
@ TS_NEAREST
Sync to frames from secondary input with the absolute nearest timestamp to the frame event one.
Definition: framesync.h:96
framesync_name
static const char * framesync_name(void *ptr)
Definition: framesync.c:31
AVFilterContext
An instance of a filter.
Definition: avfilter.h:415
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:244
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
ff_outlink_frame_wanted
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the ff_outlink_frame_wanted() function. If this function returns true
ff_framesync_activate
int ff_framesync_activate(FFFrameSync *fs)
Examine the frames in the filter's input and try to produce output.
Definition: framesync.c:355
ff_framesync_dualinput_get
int ff_framesync_dualinput_get(FFFrameSync *fs, AVFrame **f0, AVFrame **f1)
Definition: framesync.c:390
ff_framesync_dualinput_get_writable
int ff_framesync_dualinput_get_writable(FFFrameSync *fs, AVFrame **f0, AVFrame **f1)
Same as ff_framesync_dualinput_get(), but make sure that f0 is writable.
Definition: framesync.c:410
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234
ff_framesync_preinit
void ff_framesync_preinit(FFFrameSync *fs)
Pre-initialize a frame sync structure.
Definition: framesync.c:78