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