FFmpeg
fifo.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2007 Bobby Bingham
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 /**
22  * @file
23  * FIFO buffering filter
24  */
25 
26 #include "libavutil/avassert.h"
28 #include "libavutil/common.h"
29 #include "libavutil/mathematics.h"
30 #include "libavutil/samplefmt.h"
31 
32 #include "audio.h"
33 #include "avfilter.h"
34 #include "internal.h"
35 #include "video.h"
36 
37 typedef struct Buf {
39  struct Buf *next;
40 } Buf;
41 
42 typedef struct FifoContext {
44  Buf *last; ///< last buffered frame
45 
46  /**
47  * When a specific number of output samples is requested, the partial
48  * buffer is stored here
49  */
51  int allocated_samples; ///< number of samples out was allocated for
52 } FifoContext;
53 
55 {
56  FifoContext *fifo = ctx->priv;
57  fifo->last = &fifo->root;
58 
59  return 0;
60 }
61 
63 {
64  FifoContext *fifo = ctx->priv;
65  Buf *buf, *tmp;
66 
67  for (buf = fifo->root.next; buf; buf = tmp) {
68  tmp = buf->next;
69  av_frame_free(&buf->frame);
70  av_free(buf);
71  }
72 
73  av_frame_free(&fifo->out);
74 }
75 
77 {
78  FifoContext *fifo = inlink->dst->priv;
79 
80  fifo->last->next = av_mallocz(sizeof(Buf));
81  if (!fifo->last->next) {
83  return AVERROR(ENOMEM);
84  }
85 
86  fifo->last = fifo->last->next;
87  fifo->last->frame = frame;
88 
89  return 0;
90 }
91 
92 static void queue_pop(FifoContext *s)
93 {
94  Buf *tmp = s->root.next->next;
95  if (s->last == s->root.next)
96  s->last = &s->root;
97  av_freep(&s->root.next);
98  s->root.next = tmp;
99 }
100 
101 /**
102  * Move data pointers and pts offset samples forward.
103  */
105  int offset)
106 {
107  int nb_channels = link->channels;
109  int planes = planar ? nb_channels : 1;
110  int block_align = av_get_bytes_per_sample(link->format) * (planar ? 1 : nb_channels);
111  int i;
112 
113  av_assert0(frame->nb_samples > offset);
114 
115  for (i = 0; i < planes; i++)
116  frame->extended_data[i] += block_align * offset;
117  if (frame->data != frame->extended_data)
118  memcpy(frame->data, frame->extended_data,
119  FFMIN(planes, FF_ARRAY_ELEMS(frame->data)) * sizeof(*frame->data));
120  frame->linesize[0] -= block_align*offset;
121  frame->nb_samples -= offset;
122 
123  if (frame->pts != AV_NOPTS_VALUE) {
125  link->time_base);
126  }
127 }
128 
130 {
131  int planes = av_sample_fmt_is_planar(frame->format) ?
132  frame->channels : 1;
133  int min_align = 128;
134  int p;
135 
136  for (p = 0; p < planes; p++) {
137  int cur_align = 128;
138  while ((intptr_t)frame->extended_data[p] % cur_align)
139  cur_align >>= 1;
140  if (cur_align < min_align)
141  min_align = cur_align;
142  }
143  return min_align;
144 }
145 
147 {
148  AVFilterLink *link = ctx->outputs[0];
149  FifoContext *s = ctx->priv;
150  AVFrame *head = s->root.next ? s->root.next->frame : NULL;
151  AVFrame *out;
152  int ret;
153 
154  /* if head is NULL then we're flushing the remaining samples in out */
155  if (!head && !s->out)
156  return AVERROR_EOF;
157 
158  if (!s->out &&
159  head->nb_samples >= link->request_samples &&
160  calc_ptr_alignment(head) >= 32) {
161  if (head->nb_samples == link->request_samples) {
162  out = head;
163  queue_pop(s);
164  } else {
165  out = av_frame_clone(head);
166  if (!out)
167  return AVERROR(ENOMEM);
168 
169  out->nb_samples = link->request_samples;
170  buffer_offset(link, head, link->request_samples);
171  }
172  } else {
173  int nb_channels = link->channels;
174 
175  if (!s->out) {
176  s->out = ff_get_audio_buffer(link, link->request_samples);
177  if (!s->out)
178  return AVERROR(ENOMEM);
179 
180  s->out->nb_samples = 0;
181  s->out->pts = head->pts;
182  s->allocated_samples = link->request_samples;
183  } else if (link->request_samples != s->allocated_samples) {
184  av_log(ctx, AV_LOG_ERROR, "request_samples changed before the "
185  "buffer was returned.\n");
186  return AVERROR(EINVAL);
187  }
188 
189  while (s->out->nb_samples < s->allocated_samples) {
190  int len;
191 
192  if (!s->root.next) {
193  ret = ff_request_frame(ctx->inputs[0]);
194  if (ret == AVERROR_EOF) {
195  av_samples_set_silence(s->out->extended_data,
196  s->out->nb_samples,
197  s->allocated_samples -
198  s->out->nb_samples,
200  s->out->nb_samples = s->allocated_samples;
201  break;
202  } else if (ret < 0)
203  return ret;
204  if (!s->root.next)
205  return 0;
206  }
207  head = s->root.next->frame;
208 
209  len = FFMIN(s->allocated_samples - s->out->nb_samples,
210  head->nb_samples);
211 
212  av_samples_copy(s->out->extended_data, head->extended_data,
213  s->out->nb_samples, 0, len, nb_channels,
214  link->format);
215  s->out->nb_samples += len;
216 
217  if (len == head->nb_samples) {
218  av_frame_free(&head);
219  queue_pop(s);
220  } else {
221  buffer_offset(link, head, len);
222  }
223  }
224  out = s->out;
225  s->out = NULL;
226  }
227  return ff_filter_frame(link, out);
228 }
229 
230 static int request_frame(AVFilterLink *outlink)
231 {
232  FifoContext *fifo = outlink->src->priv;
233  int ret = 0;
234 
235  if (!fifo->root.next) {
236  if ((ret = ff_request_frame(outlink->src->inputs[0])) < 0) {
237  if (ret == AVERROR_EOF && outlink->request_samples)
238  return return_audio_frame(outlink->src);
239  return ret;
240  }
241  if (!fifo->root.next)
242  return 0;
243  }
244 
245  if (outlink->request_samples) {
246  return return_audio_frame(outlink->src);
247  } else {
248  ret = ff_filter_frame(outlink, fifo->root.next->frame);
249  queue_pop(fifo);
250  }
251 
252  return ret;
253 }
254 
256  {
257  .name = "default",
258  .type = AVMEDIA_TYPE_VIDEO,
259  .filter_frame = add_to_queue,
260  },
261  { NULL }
262 };
263 
265  {
266  .name = "default",
267  .type = AVMEDIA_TYPE_VIDEO,
268  .request_frame = request_frame,
269  },
270  { NULL }
271 };
272 
274  .name = "fifo",
275  .description = NULL_IF_CONFIG_SMALL("Buffer input images and send them when they are requested."),
276 
277  .init = init,
278  .uninit = uninit,
279 
280  .priv_size = sizeof(FifoContext),
281 
284 };
285 
287  {
288  .name = "default",
289  .type = AVMEDIA_TYPE_AUDIO,
290  .filter_frame = add_to_queue,
291  },
292  { NULL }
293 };
294 
296  {
297  .name = "default",
298  .type = AVMEDIA_TYPE_AUDIO,
299  .request_frame = request_frame,
300  },
301  { NULL }
302 };
303 
305  .name = "afifo",
306  .description = NULL_IF_CONFIG_SMALL("Buffer input frames and send them when they are requested."),
307 
308  .init = init,
309  .uninit = uninit,
310 
311  .priv_size = sizeof(FifoContext),
312 
315 };
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:86
avfilter_af_afifo_outputs
static const AVFilterPad avfilter_af_afifo_outputs[]
Definition: fifo.c:295
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: fifo.c:62
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
out
FILE * out
Definition: movenc.c:54
FifoContext::root
Buf root
Definition: fifo.c:43
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1080
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:55
FifoContext
Definition: fifo.c:42
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:202
Buf::frame
AVFrame * frame
Definition: fifo.c:38
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:295
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:26
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:388
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:407
avfilter_vf_fifo_inputs
static const AVFilterPad avfilter_vf_fifo_inputs[]
Definition: fifo.c:255
mathematics.h
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:148
video.h
avfilter_vf_fifo_outputs
static const AVFilterPad avfilter_vf_fifo_outputs[]
Definition: fifo.c:264
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:353
queue_pop
static void queue_pop(FifoContext *s)
Definition: fifo.c:92
samplefmt.h
FifoContext::out
AVFrame * out
When a specific number of output samples is requested, the partial buffer is stored here.
Definition: fifo.c:50
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:54
return_audio_frame
static int return_audio_frame(AVFilterContext *ctx)
Definition: fifo.c:146
avassert.h
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
FifoContext::allocated_samples
int allocated_samples
number of samples out was allocated for
Definition: fifo.c:51
buf
void * buf
Definition: avisynth_c.h:766
av_cold
#define av_cold
Definition: attributes.h:84
planar
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(const uint8_t *) pi - 0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(const int16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(const int16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(const int32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(const int32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(const int64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const float *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const double *) pi *(INT64_C(1)<< 63))) #define FMT_PAIR_FUNC(out, in) static conv_func_type *const fmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={ FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64), };static void cpy1(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, len);} static void cpy2(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 2 *len);} static void cpy4(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 4 *len);} static void cpy8(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 8 *len);} AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) return NULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) return NULL;if(channels==1){ in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);} ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map) { switch(av_get_bytes_per_sample(in_fmt)){ case 1:ctx->simd_f=cpy1;break;case 2:ctx->simd_f=cpy2;break;case 4:ctx->simd_f=cpy4;break;case 8:ctx->simd_f=cpy8;break;} } if(HAVE_X86ASM &&1) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);return ctx;} void swri_audio_convert_free(AudioConvert **ctx) { av_freep(ctx);} int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len) { int ch;int off=0;const int os=(out->planar ? 1 :out->ch_count) *out->bps;unsigned misaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask) { int planes=in->planar ? in->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;} if(ctx->out_simd_align_mask) { int planes=out->planar ? out->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;} if(ctx->simd_f &&!ctx->ch_map &&!misaligned){ off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){ if(out->planar==in->planar){ int planes=out->planar ? out->ch_count :1;for(ch=0;ch< planes;ch++){ ctx->simd_f(out-> ch const uint8_t **in ch off *out planar
Definition: audioconvert.c:226
s
#define s(width, name)
Definition: cbs_vp9.c:257
ff_vf_fifo
AVFilter ff_vf_fifo
Definition: fifo.c:273
AVFrame::channels
int channels
number of audio channels, only used for audio.
Definition: frame.h:601
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
av_sample_fmt_is_planar
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
Definition: samplefmt.c:112
Buf::next
struct Buf * next
Definition: fifo.c:39
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
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:540
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
link
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 link
Definition: filter_design.txt:23
if
if(ret)
Definition: filter_design.txt:179
NULL
#define NULL
Definition: coverity.c:32
avfilter_af_afifo_inputs
static const AVFilterPad avfilter_af_afifo_inputs[]
Definition: fifo.c:286
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AVFilterContext::inputs
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:346
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
Buf
Definition: fifo.c:37
planes
static const struct @314 planes[]
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:188
request_frame
static int request_frame(AVFilterLink *outlink)
Definition: fifo.c:230
ff_af_afifo
AVFilter ff_af_afifo
Definition: fifo.c:304
AVFrame::sample_rate
int sample_rate
Sample rate of the audio data.
Definition: frame.h:467
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
AVFrame::format
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition: frame.h:368
FFMIN
#define FFMIN(a, b)
Definition: common.h:96
offset
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
Definition: writing_filters.txt:86
buffer_offset
static void buffer_offset(AVFilterLink *link, AVFrame *frame, int offset)
Move data pointers and pts offset samples forward.
Definition: fifo.c:104
add_to_queue
static int add_to_queue(AVFilterLink *inlink, AVFrame *frame)
Definition: fifo.c:76
internal.h
av_samples_copy
int av_samples_copy(uint8_t **dst, uint8_t *const *src, int dst_offset, int src_offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt)
Copy samples from src to dst.
Definition: samplefmt.c:213
AVFrame::nb_samples
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:361
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:259
av_get_bytes_per_sample
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
Definition: samplefmt.c:106
AVFrame::extended_data
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:342
common.h
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:236
len
int len
Definition: vorbis_enc_data.h:452
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:60
av_samples_set_silence
int av_samples_set_silence(uint8_t **audio_data, int offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt)
Fill an audio buffer with silence.
Definition: samplefmt.c:237
AVFilter
Filter definition.
Definition: avfilter.h:144
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_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen_template.c:38
channel_layout.h
avfilter.h
AVFilterContext
An instance of a filter.
Definition: avfilter.h:338
FifoContext::last
Buf * last
last buffered frame
Definition: fifo.c:44
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
audio.h
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
calc_ptr_alignment
static int calc_ptr_alignment(AVFrame *frame)
Definition: fifo.c:129
init
static av_cold int init(AVFilterContext *ctx)
Definition: fifo.c:54
nb_channels
int nb_channels
Definition: channel_layout.c:76