FFmpeg
f_loop.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Paul B Mahol
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
8  * License 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 GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "libavutil/audio_fifo.h"
22 #include "libavutil/fifo.h"
23 #include "libavutil/internal.h"
24 #include "libavutil/opt.h"
25 #include "avfilter.h"
26 #include "audio.h"
27 #include "filters.h"
28 #include "formats.h"
29 #include "internal.h"
30 #include "video.h"
31 
32 typedef struct LoopContext {
33  const AVClass *class;
34 
38  int nb_frames;
40  int64_t start_pts;
41  int64_t duration;
42  int64_t current_sample;
43  int64_t nb_samples;
44  int64_t ignored_samples;
45 
46  int loop;
47  int eof;
48  int64_t size;
49  int64_t start;
50  int64_t pts;
51 } LoopContext;
52 
53 #define AFLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
54 #define VFLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
55 #define OFFSET(x) offsetof(LoopContext, x)
56 
58 {
59  LoopContext *s = ctx->priv;
60 
61  if (!s->size)
62  av_log(ctx, AV_LOG_WARNING, "Number of %s to loop is not set!\n",
63  ctx->input_pads[0].type == AVMEDIA_TYPE_VIDEO ? "frames" : "samples");
64 }
65 
66 #if CONFIG_ALOOP_FILTER
67 
68 static int aconfig_input(AVFilterLink *inlink)
69 {
70  AVFilterContext *ctx = inlink->dst;
71  LoopContext *s = ctx->priv;
72 
73  s->fifo = av_audio_fifo_alloc(inlink->format, inlink->channels, 8192);
74  s->left = av_audio_fifo_alloc(inlink->format, inlink->channels, 8192);
75  if (!s->fifo || !s->left)
76  return AVERROR(ENOMEM);
77 
78  check_size(ctx);
79 
80  return 0;
81 }
82 
83 static av_cold void auninit(AVFilterContext *ctx)
84 {
85  LoopContext *s = ctx->priv;
86 
87  av_audio_fifo_free(s->fifo);
88  av_audio_fifo_free(s->left);
89 }
90 
91 static int push_samples(AVFilterContext *ctx, int nb_samples)
92 {
93  AVFilterLink *outlink = ctx->outputs[0];
94  LoopContext *s = ctx->priv;
95  AVFrame *out;
96  int ret = 0, i = 0;
97 
98  while (s->loop != 0 && i < nb_samples) {
99  out = ff_get_audio_buffer(outlink, FFMIN(nb_samples, s->nb_samples - s->current_sample));
100  if (!out)
101  return AVERROR(ENOMEM);
102  ret = av_audio_fifo_peek_at(s->fifo, (void **)out->extended_data, out->nb_samples, s->current_sample);
103  if (ret < 0) {
104  av_frame_free(&out);
105  return ret;
106  }
107  out->pts = s->pts;
108  out->nb_samples = ret;
109  s->pts += av_rescale_q(out->nb_samples, (AVRational){1, outlink->sample_rate}, outlink->time_base);
110  i += out->nb_samples;
111  s->current_sample += out->nb_samples;
112 
113  ret = ff_filter_frame(outlink, out);
114  if (ret < 0)
115  return ret;
116 
117  if (s->current_sample >= s->nb_samples) {
118  s->duration = s->pts;
119  s->current_sample = 0;
120 
121  if (s->loop > 0)
122  s->loop--;
123  }
124  }
125 
126  return ret;
127 }
128 
129 static int afilter_frame(AVFilterLink *inlink, AVFrame *frame)
130 {
131  AVFilterContext *ctx = inlink->dst;
132  AVFilterLink *outlink = ctx->outputs[0];
133  LoopContext *s = ctx->priv;
134  int ret = 0;
135 
136  if (s->ignored_samples + frame->nb_samples > s->start && s->size > 0 && s->loop != 0) {
137  if (s->nb_samples < s->size) {
138  int written = FFMIN(frame->nb_samples, s->size - s->nb_samples);
139  int drain = 0;
140 
141  ret = av_audio_fifo_write(s->fifo, (void **)frame->extended_data, written);
142  if (ret < 0)
143  return ret;
144  if (!s->nb_samples) {
145  drain = FFMAX(0, s->start - s->ignored_samples);
146  s->pts = frame->pts;
147  av_audio_fifo_drain(s->fifo, drain);
148  s->pts += av_rescale_q(s->start - s->ignored_samples, (AVRational){1, outlink->sample_rate}, outlink->time_base);
149  }
150  s->nb_samples += ret - drain;
151  drain = frame->nb_samples - written;
152  if (s->nb_samples == s->size && drain > 0) {
153  int ret2;
154 
155  ret2 = av_audio_fifo_write(s->left, (void **)frame->extended_data, frame->nb_samples);
156  if (ret2 < 0)
157  return ret2;
158  av_audio_fifo_drain(s->left, drain);
159  }
160  frame->nb_samples = ret;
161  s->pts += av_rescale_q(ret, (AVRational){1, outlink->sample_rate}, outlink->time_base);
162  ret = ff_filter_frame(outlink, frame);
163  } else {
164  int nb_samples = frame->nb_samples;
165 
167  ret = push_samples(ctx, nb_samples);
168  }
169  } else {
170  s->ignored_samples += frame->nb_samples;
171  frame->pts = s->pts;
172  s->pts += av_rescale_q(frame->nb_samples, (AVRational){1, outlink->sample_rate}, outlink->time_base);
173  ret = ff_filter_frame(outlink, frame);
174  }
175 
176  return ret;
177 }
178 
179 static int arequest_frame(AVFilterLink *outlink)
180 {
181  AVFilterContext *ctx = outlink->src;
182  LoopContext *s = ctx->priv;
183  int ret = 0;
184 
185  if ((!s->size) ||
186  (s->nb_samples < s->size) ||
187  (s->nb_samples >= s->size && s->loop == 0)) {
188  int nb_samples = av_audio_fifo_size(s->left);
189 
190  if (s->loop == 0 && nb_samples > 0) {
191  AVFrame *out;
192 
193  out = ff_get_audio_buffer(outlink, nb_samples);
194  if (!out)
195  return AVERROR(ENOMEM);
196  av_audio_fifo_read(s->left, (void **)out->extended_data, nb_samples);
197  out->pts = s->pts;
198  s->pts += av_rescale_q(nb_samples, (AVRational){1, outlink->sample_rate}, outlink->time_base);
199  ret = ff_filter_frame(outlink, out);
200  if (ret < 0)
201  return ret;
202  }
203  ret = ff_request_frame(ctx->inputs[0]);
204  } else {
205  ret = push_samples(ctx, 1024);
206  }
207 
208  if (s->eof && s->nb_samples > 0 && s->loop != 0) {
209  ret = push_samples(ctx, 1024);
210  }
211 
212  return ret;
213 }
214 
215 static int aactivate(AVFilterContext *ctx)
216 {
217  AVFilterLink *inlink = ctx->inputs[0];
218  AVFilterLink *outlink = ctx->outputs[0];
219  LoopContext *s = ctx->priv;
220  AVFrame *frame = NULL;
221  int ret, status;
222  int64_t pts;
223 
225 
226  if (!s->eof && (s->nb_samples < s->size || !s->loop || !s->size)) {
228  if (ret < 0)
229  return ret;
230  if (ret > 0)
231  return afilter_frame(inlink, frame);
232  }
233 
234  if (!s->eof && ff_inlink_acknowledge_status(inlink, &status, &pts)) {
235  if (status == AVERROR_EOF) {
236  s->size = s->nb_samples;
237  s->eof = 1;
238  }
239  }
240 
241  if (s->eof && (!s->loop || !s->size)) {
242  ff_outlink_set_status(outlink, AVERROR_EOF, s->duration);
243  return 0;
244  }
245 
246  if (!s->eof && (!s->size ||
247  (s->nb_samples < s->size) ||
248  (s->nb_samples >= s->size && s->loop == 0))) {
250  } else if (s->loop && s->nb_samples == s->size) {
251  return arequest_frame(outlink);
252  }
253 
254  return FFERROR_NOT_READY;
255 }
256 
257 static const AVOption aloop_options[] = {
258  { "loop", "number of loops", OFFSET(loop), AV_OPT_TYPE_INT, {.i64 = 0 }, -1, INT_MAX, AFLAGS },
259  { "size", "max number of samples to loop", OFFSET(size), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, INT32_MAX, AFLAGS },
260  { "start", "set the loop start sample", OFFSET(start), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, INT64_MAX, AFLAGS },
261  { NULL }
262 };
263 
264 AVFILTER_DEFINE_CLASS(aloop);
265 
266 static const AVFilterPad ainputs[] = {
267  {
268  .name = "default",
269  .type = AVMEDIA_TYPE_AUDIO,
270  .config_props = aconfig_input,
271  },
272 };
273 
274 static const AVFilterPad aoutputs[] = {
275  {
276  .name = "default",
277  .type = AVMEDIA_TYPE_AUDIO,
278  },
279 };
280 
281 const AVFilter ff_af_aloop = {
282  .name = "aloop",
283  .description = NULL_IF_CONFIG_SMALL("Loop audio samples."),
284  .priv_size = sizeof(LoopContext),
285  .priv_class = &aloop_class,
286  .activate = aactivate,
287  .uninit = auninit,
288  FILTER_INPUTS(ainputs),
289  FILTER_OUTPUTS(aoutputs),
290 };
291 #endif /* CONFIG_ALOOP_FILTER */
292 
293 #if CONFIG_LOOP_FILTER
294 
295 static av_cold int init(AVFilterContext *ctx)
296 {
297  LoopContext *s = ctx->priv;
298 
299  s->frames = av_calloc(s->size, sizeof(*s->frames));
300  if (!s->frames)
301  return AVERROR(ENOMEM);
302 
303  check_size(ctx);
304 
305  return 0;
306 }
307 
308 static av_cold void uninit(AVFilterContext *ctx)
309 {
310  LoopContext *s = ctx->priv;
311  int i;
312 
313  for (i = 0; i < s->nb_frames; i++)
314  av_frame_free(&s->frames[i]);
315 
316  av_freep(&s->frames);
317  s->nb_frames = 0;
318 }
319 
320 static int push_frame(AVFilterContext *ctx)
321 {
322  AVFilterLink *outlink = ctx->outputs[0];
323  LoopContext *s = ctx->priv;
324  int64_t pts, duration;
325  int ret;
326 
327  AVFrame *out = av_frame_clone(s->frames[s->current_frame]);
328 
329  if (!out)
330  return AVERROR(ENOMEM);
331  out->pts += s->duration - s->start_pts;
332  if (out->pkt_duration)
333  duration = out->pkt_duration;
334  else
335  duration = av_rescale_q(1, av_inv_q(outlink->frame_rate), outlink->time_base);
336  pts = out->pts + duration;
337  ret = ff_filter_frame(outlink, out);
338  s->current_frame++;
339 
340  if (s->current_frame >= s->nb_frames) {
341  s->duration = pts;
342  s->current_frame = 0;
343 
344  if (s->loop > 0)
345  s->loop--;
346  }
347 
348  return ret;
349 }
350 
352 {
353  AVFilterContext *ctx = inlink->dst;
354  AVFilterLink *outlink = ctx->outputs[0];
355  LoopContext *s = ctx->priv;
356  int64_t duration;
357  int ret = 0;
358 
359  if (inlink->frame_count_out >= s->start && s->size > 0 && s->loop != 0) {
360  if (s->nb_frames < s->size) {
361  if (!s->nb_frames)
362  s->start_pts = frame->pts;
363  s->frames[s->nb_frames] = av_frame_clone(frame);
364  if (!s->frames[s->nb_frames]) {
366  return AVERROR(ENOMEM);
367  }
368  s->nb_frames++;
369  if (frame->pkt_duration)
370  duration = frame->pkt_duration;
371  else
372  duration = av_rescale_q(1, av_inv_q(outlink->frame_rate), outlink->time_base);
373  s->duration = frame->pts + duration;
374  ret = ff_filter_frame(outlink, frame);
375  } else {
377  ret = push_frame(ctx);
378  }
379  } else {
380  frame->pts += s->duration;
381  ret = ff_filter_frame(outlink, frame);
382  }
383 
384  return ret;
385 }
386 
387 static int activate(AVFilterContext *ctx)
388 {
389  AVFilterLink *inlink = ctx->inputs[0];
390  AVFilterLink *outlink = ctx->outputs[0];
391  LoopContext *s = ctx->priv;
392  AVFrame *frame = NULL;
393  int ret, status;
394  int64_t pts;
395 
397 
398  if (!s->eof && (s->nb_frames < s->size || !s->loop || !s->size)) {
400  if (ret < 0)
401  return ret;
402  if (ret > 0)
403  return filter_frame(inlink, frame);
404  }
405 
406  if (!s->eof && ff_inlink_acknowledge_status(inlink, &status, &pts)) {
407  if (status == AVERROR_EOF) {
408  s->size = s->nb_frames;
409  s->eof = 1;
410  }
411  }
412 
413  if (s->eof && (!s->loop || !s->size)) {
414  ff_outlink_set_status(outlink, AVERROR_EOF, s->duration);
415  return 0;
416  }
417 
418  if (!s->eof && (!s->size ||
419  (s->nb_frames < s->size) ||
420  (s->nb_frames >= s->size && s->loop == 0))) {
422  } else if (s->loop && s->nb_frames == s->size) {
423  return push_frame(ctx);
424  }
425 
426  return FFERROR_NOT_READY;
427 }
428 
429 static const AVOption loop_options[] = {
430  { "loop", "number of loops", OFFSET(loop), AV_OPT_TYPE_INT, {.i64 = 0 }, -1, INT_MAX, VFLAGS },
431  { "size", "max number of frames to loop", OFFSET(size), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, INT16_MAX, VFLAGS },
432  { "start", "set the loop start frame", OFFSET(start), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, INT64_MAX, VFLAGS },
433  { NULL }
434 };
435 
437 
438 static const AVFilterPad inputs[] = {
439  {
440  .name = "default",
441  .type = AVMEDIA_TYPE_VIDEO,
442  },
443 };
444 
445 static const AVFilterPad outputs[] = {
446  {
447  .name = "default",
448  .type = AVMEDIA_TYPE_VIDEO,
449  },
450 };
451 
452 const AVFilter ff_vf_loop = {
453  .name = "loop",
454  .description = NULL_IF_CONFIG_SMALL("Loop video frames."),
455  .priv_size = sizeof(LoopContext),
456  .priv_class = &loop_class,
457  .init = init,
458  .uninit = uninit,
459  .activate = activate,
462 };
463 #endif /* CONFIG_LOOP_FILTER */
av_audio_fifo_free
void av_audio_fifo_free(AVAudioFifo *af)
Free an AVAudioFifo.
Definition: audio_fifo.c:45
ff_get_audio_buffer
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
Definition: audio.c:88
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
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
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
out
FILE * out
Definition: movenc.c:54
push_samples
static int push_samples(ATempoContext *atempo, AVFilterLink *outlink, int n_out)
Definition: af_atempo.c:1022
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1018
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
check_size
static void check_size(AVFilterContext *ctx)
Definition: f_loop.c:57
FFERROR_NOT_READY
return FFERROR_NOT_READY
Definition: filter_design.txt:204
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
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:109
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:317
AVOption
AVOption.
Definition: opt.h:247
ff_request_frame
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
Definition: avfilter.c:420
LoopContext::start_pts
int64_t start_pts
Definition: f_loop.c:40
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:169
video.h
LoopContext::nb_frames
int nb_frames
Definition: f_loop.c:38
LoopContext
Definition: f_loop.c:32
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
formats.h
init
static int init
Definition: av_tx.c:47
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:1417
fifo.h
AVAudioFifo
Context for an Audio FIFO Buffer.
Definition: audio_fifo.c:34
LoopContext::nb_samples
int64_t nb_samples
Definition: f_loop.c:43
av_audio_fifo_drain
int av_audio_fifo_drain(AVAudioFifo *af, int nb_samples)
Drain data from an AVAudioFifo.
Definition: audio_fifo.c:201
LoopContext::pts
int64_t pts
Definition: f_loop.c:50
pts
static int64_t pts
Definition: transcode_aac.c:653
loop
static int loop
Definition: ffplay.c:339
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:50
av_cold
#define av_cold
Definition: attributes.h:90
duration
int64_t duration
Definition: movenc.c:64
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
LoopContext::size
int64_t size
Definition: f_loop.c:48
s
#define s(width, name)
Definition: cbs_vp9.c:257
av_audio_fifo_write
int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples)
Write data to an AVAudioFifo.
Definition: audio_fifo.c:112
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
LoopContext::duration
int64_t duration
Definition: f_loop.c:41
AV_OPT_TYPE_INT64
@ AV_OPT_TYPE_INT64
Definition: opt.h:225
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:172
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:422
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:141
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:191
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
av_audio_fifo_alloc
AVAudioFifo * av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels, int nb_samples)
Allocate an AVAudioFifo.
Definition: audio_fifo.c:59
activate
filter_frame For filters that do not use the activate() callback
LoopContext::loop
int loop
Definition: f_loop.c:46
AFLAGS
#define AFLAGS
Definition: f_loop.c:53
filter_frame
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
Definition: dolby_e.c:1050
inputs
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 inputs
Definition: filter_design.txt:243
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:1371
av_audio_fifo_peek_at
int av_audio_fifo_peek_at(AVAudioFifo *af, void **data, int nb_samples, int offset)
Peek data from an AVAudioFifo.
Definition: audio_fifo.c:157
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:117
size
int size
Definition: twinvq_data.h:10344
LoopContext::current_frame
int current_frame
Definition: f_loop.c:39
FF_FILTER_FORWARD_WANTED
FF_FILTER_FORWARD_WANTED(outlink, inlink)
av_audio_fifo_size
int av_audio_fifo_size(AVAudioFifo *af)
Get the current number of samples in the AVAudioFifo available for reading.
Definition: audio_fifo.c:228
internal.h
AVFILTER_DEFINE_CLASS
#define AVFILTER_DEFINE_CLASS(fname)
Definition: internal.h:326
ff_af_aloop
const AVFilter ff_af_aloop
av_audio_fifo_read
int av_audio_fifo_read(AVAudioFifo *af, void **data, int nb_samples)
Read data from an AVAudioFifo.
Definition: audio_fifo.c:181
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
internal.h
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
audio_fifo.h
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:56
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:271
LoopContext::ignored_samples
int64_t ignored_samples
Definition: f_loop.c:44
AVFilter
Filter definition.
Definition: avfilter.h:165
LoopContext::frames
AVFrame ** frames
Definition: f_loop.c:37
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
LoopContext::current_sample
int64_t current_sample
Definition: f_loop.c:42
LoopContext::eof
int eof
Definition: f_loop.c:47
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
avfilter.h
OFFSET
#define OFFSET(x)
Definition: f_loop.c:55
LoopContext::left
AVAudioFifo * left
Definition: f_loop.c:36
LoopContext::fifo
AVAudioFifo * fifo
Definition: f_loop.c:35
AVFilterContext
An instance of a filter.
Definition: avfilter.h:402
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
audio.h
ff_vf_loop
const AVFilter ff_vf_loop
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:192
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
LoopContext::start
int64_t start
Definition: f_loop.c:49
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
uninit
static av_cold int uninit(AVCodecContext *avctx)
Definition: crystalhd.c:282
VFLAGS
#define VFLAGS
Definition: f_loop.c:54
push_frame
static int push_frame(AVFilterContext *ctx, unsigned in_no, AVFrame *buf)
Definition: avf_concat.c:173