Libav
buffersrc.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008 Vitor Sessak
3  *
4  * This file is part of Libav.
5  *
6  * Libav 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  * Libav 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 Libav; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
26 #include <float.h>
27 
29 #include "libavutil/common.h"
30 #include "libavutil/fifo.h"
31 #include "libavutil/frame.h"
32 #include "libavutil/imgutils.h"
33 #include "libavutil/internal.h"
34 #include "libavutil/opt.h"
35 #include "libavutil/samplefmt.h"
36 #include "audio.h"
37 #include "avfilter.h"
38 #include "buffersrc.h"
39 #include "formats.h"
40 #include "internal.h"
41 #include "video.h"
42 
43 typedef struct BufferSourceContext {
44  const AVClass *class;
47 
48  /* video only */
49  int h, w;
51  char *pix_fmt_str;
53 
54  /* audio only */
58  uint64_t channel_layout;
60 
61  int eof;
63 
64 #define CHECK_VIDEO_PARAM_CHANGE(s, c, width, height, format)\
65  if (c->w != width || c->h != height || c->pix_fmt != format) {\
66  av_log(s, AV_LOG_ERROR, "Changing frame properties on the fly is not supported.\n");\
67  return AVERROR(EINVAL);\
68  }
69 
70 #define CHECK_AUDIO_PARAM_CHANGE(s, c, srate, ch_layout, format)\
71  if (c->sample_fmt != format || c->sample_rate != srate ||\
72  c->channel_layout != ch_layout) {\
73  av_log(s, AV_LOG_ERROR, "Changing frame properties on the fly is not supported.\n");\
74  return AVERROR(EINVAL);\
75  }
76 
78 {
79  AVFrame *copy;
80  int ret = 0;
81 
82  if (!(copy = av_frame_alloc()))
83  return AVERROR(ENOMEM);
84  ret = av_frame_ref(copy, frame);
85  if (ret >= 0)
86  ret = av_buffersrc_add_frame(ctx, copy);
87 
88  av_frame_free(&copy);
89  return ret;
90 }
91 
93  AVFrame *frame)
94 {
95  BufferSourceContext *s = ctx->priv;
96  AVFrame *copy;
97  int refcounted, ret;
98 
99  if (!frame) {
100  s->eof = 1;
101  return 0;
102  } else if (s->eof)
103  return AVERROR(EINVAL);
104 
105  refcounted = !!frame->buf[0];
106 
107  switch (ctx->outputs[0]->type) {
108  case AVMEDIA_TYPE_VIDEO:
109  CHECK_VIDEO_PARAM_CHANGE(ctx, s, frame->width, frame->height,
110  frame->format);
111  break;
112  case AVMEDIA_TYPE_AUDIO:
113  CHECK_AUDIO_PARAM_CHANGE(ctx, s, frame->sample_rate, frame->channel_layout,
114  frame->format);
115  break;
116  default:
117  return AVERROR(EINVAL);
118  }
119 
120  if (!av_fifo_space(s->fifo) &&
121  (ret = av_fifo_realloc2(s->fifo, av_fifo_size(s->fifo) +
122  sizeof(copy))) < 0)
123  return ret;
124 
125  if (!(copy = av_frame_alloc()))
126  return AVERROR(ENOMEM);
127 
128  if (refcounted) {
129  av_frame_move_ref(copy, frame);
130  } else {
131  ret = av_frame_ref(copy, frame);
132  if (ret < 0) {
133  av_frame_free(&copy);
134  return ret;
135  }
136  }
137 
138  if ((ret = av_fifo_generic_write(s->fifo, &copy, sizeof(copy), NULL)) < 0) {
139  if (refcounted)
140  av_frame_move_ref(frame, copy);
141  av_frame_free(&copy);
142  return ret;
143  }
144 
145  return 0;
146 }
147 
148 #if FF_API_AVFILTERBUFFER
150 static void compat_free_buffer(void *opaque, uint8_t *data)
151 {
152  AVFilterBufferRef *buf = opaque;
154 }
155 
156 static void compat_unref_buffer(void *opaque, uint8_t *data)
157 {
158  AVBufferRef *buf = opaque;
159  av_buffer_unref(&buf);
160 }
161 
162 int av_buffersrc_buffer(AVFilterContext *ctx, AVFilterBufferRef *buf)
163 {
164  BufferSourceContext *s = ctx->priv;
165  AVFrame *frame = NULL;
166  AVBufferRef *dummy_buf = NULL;
167  int ret = 0, planes, i;
168 
169  if (!buf) {
170  s->eof = 1;
171  return 0;
172  } else if (s->eof)
173  return AVERROR(EINVAL);
174 
175  frame = av_frame_alloc();
176  if (!frame)
177  return AVERROR(ENOMEM);
178 
179  dummy_buf = av_buffer_create(NULL, 0, compat_free_buffer, buf, 0);
180  if (!dummy_buf) {
181  ret = AVERROR(ENOMEM);
182  goto fail;
183  }
184 
185  if ((ret = avfilter_copy_buf_props(frame, buf)) < 0)
186  goto fail;
187 
188 #define WRAP_PLANE(ref_out, data, data_size) \
189 do { \
190  AVBufferRef *dummy_ref = av_buffer_ref(dummy_buf); \
191  if (!dummy_ref) { \
192  ret = AVERROR(ENOMEM); \
193  goto fail; \
194  } \
195  ref_out = av_buffer_create(data, data_size, compat_unref_buffer, \
196  dummy_ref, 0); \
197  if (!ref_out) { \
198  av_frame_unref(frame); \
199  ret = AVERROR(ENOMEM); \
200  goto fail; \
201  } \
202 } while (0)
203 
204  if (ctx->outputs[0]->type == AVMEDIA_TYPE_VIDEO) {
205  const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
206 
207  planes = av_pix_fmt_count_planes(frame->format);
208  if (!desc || planes <= 0) {
209  ret = AVERROR(EINVAL);
210  goto fail;
211  }
212 
213  for (i = 0; i < planes; i++) {
214  int v_shift = (i == 1 || i == 2) ? desc->log2_chroma_h : 0;
215  int plane_size = (frame->height >> v_shift) * frame->linesize[i];
216 
217  WRAP_PLANE(frame->buf[i], frame->data[i], plane_size);
218  }
219  } else {
220  int planar = av_sample_fmt_is_planar(frame->format);
221  int channels = av_get_channel_layout_nb_channels(frame->channel_layout);
222 
223  planes = planar ? channels : 1;
224 
225  if (planes > FF_ARRAY_ELEMS(frame->buf)) {
226  frame->nb_extended_buf = planes - FF_ARRAY_ELEMS(frame->buf);
227  frame->extended_buf = av_mallocz(sizeof(*frame->extended_buf) *
228  frame->nb_extended_buf);
229  if (!frame->extended_buf) {
230  ret = AVERROR(ENOMEM);
231  goto fail;
232  }
233  }
234 
235  for (i = 0; i < FFMIN(planes, FF_ARRAY_ELEMS(frame->buf)); i++)
236  WRAP_PLANE(frame->buf[i], frame->extended_data[i], frame->linesize[0]);
237 
238  for (i = 0; i < planes - FF_ARRAY_ELEMS(frame->buf); i++)
239  WRAP_PLANE(frame->extended_buf[i],
240  frame->extended_data[i + FF_ARRAY_ELEMS(frame->buf)],
241  frame->linesize[0]);
242  }
243 
244  ret = av_buffersrc_add_frame(ctx, frame);
245 
246 fail:
247  av_buffer_unref(&dummy_buf);
248  av_frame_free(&frame);
249 
250  return ret;
251 }
253 #endif
254 
256 {
257  BufferSourceContext *c = ctx->priv;
258 
259  if (!c->pix_fmt_str || !c->w || !c->h || av_q2d(c->time_base) <= 0) {
260  av_log(ctx, AV_LOG_ERROR, "Invalid parameters provided.\n");
261  return AVERROR(EINVAL);
262  }
263 
265  char *tail;
266  c->pix_fmt = strtol(c->pix_fmt_str, &tail, 10);
267  if (*tail || c->pix_fmt < 0 || !av_pix_fmt_desc_get(c->pix_fmt)) {
268  av_log(ctx, AV_LOG_ERROR, "Invalid pixel format string '%s'\n", c->pix_fmt_str);
269  return AVERROR(EINVAL);
270  }
271  }
272 
273  if (!(c->fifo = av_fifo_alloc(sizeof(AVFrame*))))
274  return AVERROR(ENOMEM);
275 
276  av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d pixfmt:%s\n", c->w, c->h, av_get_pix_fmt_name(c->pix_fmt));
277  return 0;
278 }
279 
280 #define OFFSET(x) offsetof(BufferSourceContext, x)
281 #define A AV_OPT_FLAG_AUDIO_PARAM
282 #define V AV_OPT_FLAG_VIDEO_PARAM
283 
284 static const AVOption video_options[] = {
285  { "width", NULL, OFFSET(w), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, V },
286  { "height", NULL, OFFSET(h), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, V },
287  { "pix_fmt", NULL, OFFSET(pix_fmt_str), AV_OPT_TYPE_STRING, .flags = V },
288 #if FF_API_OLD_FILTER_OPTS
289  /* those 4 are for compatibility with the old option passing system where each filter
290  * did its own parsing */
291  { "time_base_num", "deprecated, do not use", OFFSET(time_base.num), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, V },
292  { "time_base_den", "deprecated, do not use", OFFSET(time_base.den), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, V },
293  { "sar_num", "deprecated, do not use", OFFSET(pixel_aspect.num), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, V },
294  { "sar_den", "deprecated, do not use", OFFSET(pixel_aspect.den), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, V },
295 #endif
296  { "sar", "sample aspect ratio", OFFSET(pixel_aspect), AV_OPT_TYPE_RATIONAL, { .dbl = 1 }, 0, DBL_MAX, V },
297  { "time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
298  { NULL },
299 };
300 
301 static const AVClass buffer_class = {
302  .class_name = "buffer source",
303  .item_name = av_default_item_name,
304  .option = video_options,
305  .version = LIBAVUTIL_VERSION_INT,
306 };
307 
308 static const AVOption audio_options[] = {
309  { "time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, INT_MAX, A },
310  { "sample_rate", NULL, OFFSET(sample_rate), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, A },
311  { "sample_fmt", NULL, OFFSET(sample_fmt_str), AV_OPT_TYPE_STRING, .flags = A },
312  { "channel_layout", NULL, OFFSET(channel_layout_str), AV_OPT_TYPE_STRING, .flags = A },
313  { NULL },
314 };
315 
316 static const AVClass abuffer_class = {
317  .class_name = "abuffer source",
318  .item_name = av_default_item_name,
319  .option = audio_options,
320  .version = LIBAVUTIL_VERSION_INT,
321 };
322 
324 {
325  BufferSourceContext *s = ctx->priv;
326  int ret = 0;
327 
329  if (s->sample_fmt == AV_SAMPLE_FMT_NONE) {
330  av_log(ctx, AV_LOG_ERROR, "Invalid sample format %s.\n",
331  s->sample_fmt_str);
332  return AVERROR(EINVAL);
333  }
334 
336  if (!s->channel_layout) {
337  av_log(ctx, AV_LOG_ERROR, "Invalid channel layout %s.\n",
338  s->channel_layout_str);
339  return AVERROR(EINVAL);
340  }
341 
342  if (!(s->fifo = av_fifo_alloc(sizeof(AVFrame*))))
343  return AVERROR(ENOMEM);
344 
345  if (!s->time_base.num)
346  s->time_base = (AVRational){1, s->sample_rate};
347 
348  av_log(ctx, AV_LOG_VERBOSE, "tb:%d/%d samplefmt:%s samplerate: %d "
349  "ch layout:%s\n", s->time_base.num, s->time_base.den, s->sample_fmt_str,
351 
352  return ret;
353 }
354 
355 static av_cold void uninit(AVFilterContext *ctx)
356 {
357  BufferSourceContext *s = ctx->priv;
358  while (s->fifo && av_fifo_size(s->fifo)) {
359  AVFrame *frame;
360  av_fifo_generic_read(s->fifo, &frame, sizeof(frame), NULL);
361  av_frame_free(&frame);
362  }
363  av_fifo_free(s->fifo);
364  s->fifo = NULL;
365 }
366 
368 {
369  BufferSourceContext *c = ctx->priv;
370  AVFilterChannelLayouts *channel_layouts = NULL;
372  AVFilterFormats *samplerates = NULL;
373 
374  switch (ctx->outputs[0]->type) {
375  case AVMEDIA_TYPE_VIDEO:
376  ff_add_format(&formats, c->pix_fmt);
377  ff_set_common_formats(ctx, formats);
378  break;
379  case AVMEDIA_TYPE_AUDIO:
380  ff_add_format(&formats, c->sample_fmt);
381  ff_set_common_formats(ctx, formats);
382 
383  ff_add_format(&samplerates, c->sample_rate);
384  ff_set_common_samplerates(ctx, samplerates);
385 
386  ff_add_channel_layout(&channel_layouts, c->channel_layout);
387  ff_set_common_channel_layouts(ctx, channel_layouts);
388  break;
389  default:
390  return AVERROR(EINVAL);
391  }
392 
393  return 0;
394 }
395 
396 static int config_props(AVFilterLink *link)
397 {
398  BufferSourceContext *c = link->src->priv;
399 
400  switch (link->type) {
401  case AVMEDIA_TYPE_VIDEO:
402  link->w = c->w;
403  link->h = c->h;
405  break;
406  case AVMEDIA_TYPE_AUDIO:
407  link->channel_layout = c->channel_layout;
408  link->sample_rate = c->sample_rate;
409  break;
410  default:
411  return AVERROR(EINVAL);
412  }
413 
414  link->time_base = c->time_base;
415  return 0;
416 }
417 
418 static int request_frame(AVFilterLink *link)
419 {
420  BufferSourceContext *c = link->src->priv;
421  AVFrame *frame;
422  int ret = 0;
423 
424  if (!av_fifo_size(c->fifo)) {
425  if (c->eof)
426  return AVERROR_EOF;
427  return AVERROR(EAGAIN);
428  }
429  av_fifo_generic_read(c->fifo, &frame, sizeof(frame), NULL);
430 
431  ff_filter_frame(link, frame);
432 
433  return ret;
434 }
435 
436 static int poll_frame(AVFilterLink *link)
437 {
438  BufferSourceContext *c = link->src->priv;
439  int size = av_fifo_size(c->fifo);
440  if (!size && c->eof)
441  return AVERROR_EOF;
442  return size/sizeof(AVFrame*);
443 }
444 
446  {
447  .name = "default",
448  .type = AVMEDIA_TYPE_VIDEO,
449  .request_frame = request_frame,
450  .poll_frame = poll_frame,
451  .config_props = config_props,
452  },
453  { NULL }
454 };
455 
457  .name = "buffer",
458  .description = NULL_IF_CONFIG_SMALL("Buffer video frames, and make them accessible to the filterchain."),
459  .priv_size = sizeof(BufferSourceContext),
460  .priv_class = &buffer_class,
462 
463  .init = init_video,
464  .uninit = uninit,
465 
466  .inputs = NULL,
468 };
469 
471  {
472  .name = "default",
473  .type = AVMEDIA_TYPE_AUDIO,
474  .request_frame = request_frame,
475  .poll_frame = poll_frame,
476  .config_props = config_props,
477  },
478  { NULL }
479 };
480 
482  .name = "abuffer",
483  .description = NULL_IF_CONFIG_SMALL("Buffer audio frames, and make them accessible to the filterchain."),
484  .priv_size = sizeof(BufferSourceContext),
485  .priv_class = &abuffer_class,
487 
488  .init = init_audio,
489  .uninit = uninit,
490 
491  .inputs = NULL,
492  .outputs = avfilter_asrc_abuffer_outputs,
493 };
static FF_DISABLE_DEPRECATION_WARNINGS void compat_free_buffer(void *opaque, uint8_t *data)
Definition: buffersrc.c:150
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
Definition: buffer.c:106
int size
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:1599
This structure describes decoded (raw) audio or video data.
Definition: frame.h:135
AVOption.
Definition: opt.h:234
AVRational pixel_aspect
Definition: buffersrc.c:52
misc image utilities
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:232
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:1637
Main libavfilter public API header.
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
Definition: frame.h:393
Memory buffer source API.
int nb_extended_buf
Number of elements in extended_buf.
Definition: frame.h:411
int num
numerator
Definition: rational.h:44
static const AVFilterPad avfilter_vsrc_buffer_outputs[]
Definition: buffersrc.c:445
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everythnig contained in src to dst and reset src.
Definition: frame.c:300
#define FF_ARRAY_ELEMS(a)
static enum AVSampleFormat formats[]
enum AVPixelFormat pix_fmt
Definition: buffersrc.c:50
static const AVRational pixel_aspect[17]
Definition: h264_ps.c:40
static av_cold void uninit(AVFilterContext *ctx)
Definition: buffersrc.c:355
static const AVClass abuffer_class
Definition: buffersrc.c:316
void avfilter_unref_buffer(AVFilterBufferRef *ref)
Definition: buffer.c:78
#define OFFSET(x)
Definition: buffersrc.c:280
int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int(*func)(void *, void *, int))
Feed data from a user-supplied callback to an AVFifoBuffer.
Definition: fifo.c:84
AVFilter ff_asrc_abuffer
Definition: buffersrc.c:481
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:38
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:733
#define WRAP_PLANE(ref_out, data, data_size)
uint8_t
#define av_cold
Definition: attributes.h:66
#define CHECK_AUDIO_PARAM_CHANGE(s, c, srate, ch_layout, format)
Definition: buffersrc.c:70
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:57
AVOptions.
static int poll_frame(AVFilterLink *link)
Definition: buffersrc.c:436
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
Definition: frame.c:188
const char data[16]
Definition: mxf.c:70
static double av_q2d(AVRational a)
Convert rational to double.
Definition: rational.h:69
#define AVERROR_EOF
End of file.
Definition: error.h:51
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:139
void av_fifo_free(AVFifoBuffer *f)
Free an AVFifoBuffer.
Definition: fifo.c:38
static const AVFilterPad avfilter_asrc_abuffer_outputs[]
Definition: buffersrc.c:470
static void copy(LZOContext *c, int cnt)
Copies bytes from input to output buffer with checking.
Definition: lzo.c:79
void ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:379
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
Definition: samplefmt.c:101
int width
width and height of the video frame
Definition: frame.h:174
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:123
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:89
int ff_add_channel_layout(AVFilterChannelLayouts **l, uint64_t channel_layout)
Definition: formats.c:204
#define AVERROR(e)
Definition: error.h:43
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:69
static int request_frame(AVFilterLink *link)
Definition: buffersrc.c:418
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:150
void * priv
private data for use by the filter
Definition: avfilter.h:584
int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void(*func)(void *, void *, int))
Feed data from an AVFifoBuffer to a user-supplied callback.
Definition: fifo.c:107
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
#define A
Definition: buffersrc.c:281
void av_log(void *avcl, int level, const char *fmt,...)
Definition: log.c:169
AVRational time_base
time_base to set in the output link
Definition: buffersrc.c:46
AVBufferRef * av_buffer_create(uint8_t *data, int size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
Definition: buffer.c:28
reference-counted frame API
static const AVOption video_options[]
Definition: buffersrc.c:284
uint64_t channel_layout
Channel layout of the audio data.
Definition: frame.h:381
common internal API header
audio channel layout utility functions
#define FFMIN(a, b)
Definition: common.h:57
AVBufferRef ** extended_buf
For planar audio which requires more than AV_NUM_DATA_POINTERS AVBufferRef pointers, this array will hold all the references which cannot fit into AVFrame.buf.
Definition: frame.h:407
static av_cold int init_audio(AVFilterContext *ctx)
Definition: buffersrc.c:323
LIBAVUTIL_VERSION_INT
Definition: eval.c:55
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
Definition: frame.h:186
#define attribute_align_arg
Definition: internal.h:54
NULL
Definition: eval.c:55
int av_fifo_space(AVFifoBuffer *f)
Return the amount of space in bytes in the AVFifoBuffer, that is the amount of data you can write int...
Definition: fifo.c:57
int attribute_align_arg av_buffersrc_write_frame(AVFilterContext *ctx, const AVFrame *frame)
Add a frame to the buffer source.
Definition: buffersrc.c:77
int av_buffersrc_buffer(AVFilterContext *ctx, AVFilterBufferRef *buf)
Definition: buffersrc.c:162
static FF_ENABLE_DEPRECATION_WARNINGS av_cold int init_video(AVFilterContext *ctx)
Definition: buffersrc.c:255
AVSampleFormat
Audio Sample Formats.
Definition: samplefmt.h:61
AV_SAMPLE_FMT_NONE
Definition: avconv_filter.c:68
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:153
int av_fifo_realloc2(AVFifoBuffer *f, unsigned int new_size)
Resize an AVFifoBuffer.
Definition: fifo.c:62
av_default_item_name
Definition: dnxhdenc.c:52
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
static const AVClass buffer_class
Definition: buffersrc.c:301
a very simple circular buffer FIFO implementation
#define V
Definition: buffersrc.c:282
Describe the class of an AVClass context structure.
Definition: log.h:33
int sample_rate
Sample rate of the audio data.
Definition: frame.h:376
Filter definition.
Definition: avfilter.h:421
static const AVFilterPad inputs[]
Definition: af_ashowinfo.c:221
rational number numerator/denominator
Definition: rational.h:43
static int config_props(AVFilterLink *link)
Definition: buffersrc.c:396
char * sample_fmt_str
Definition: buffersrc.c:57
enum AVSampleFormat av_get_sample_fmt(const char *name)
Return a sample format corresponding to name, or AV_SAMPLE_FMT_NONE on error.
Definition: samplefmt.c:54
const char * name
Filter name.
Definition: avfilter.h:425
AVFifoBuffer * fifo
Definition: buffersrc.c:45
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:578
int attribute_align_arg av_buffersrc_add_frame(AVFilterContext *ctx, AVFrame *frame)
Add a frame to the buffer source.
Definition: buffersrc.c:92
uint64_t channel_layout
Definition: buffersrc.c:58
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:141
static const AVOption audio_options[]
Definition: buffersrc.c:308
AVFilter ff_vsrc_buffer
Definition: buffersrc.c:456
void ff_set_common_samplerates(AVFilterContext *ctx, AVFilterFormats *samplerates)
Definition: formats.c:367
A reference to a data buffer.
Definition: buffer.h:81
int av_fifo_size(AVFifoBuffer *f)
Return the amount of data in bytes in the AVFifoBuffer, that is the amount of data you can read from ...
Definition: fifo.c:52
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:76
common internal and external API header
int den
denominator
Definition: rational.h:45
struct AVFilterPad AVFilterPad
Definition: avfilter.h:67
static av_cold int init(AVCodecParserContext *s)
Definition: h264_parser.c:499
int ff_add_format(AVFilterFormats **avff, int fmt)
Add fmt to the list of media formats contained in *avff.
Definition: formats.c:199
static void compat_unref_buffer(void *opaque, uint8_t *data)
Definition: buffersrc.c:156
AVFifoBuffer * av_fifo_alloc(unsigned int size)
Initialize an AVFifoBuffer.
Definition: fifo.c:25
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:77
enum AVSampleFormat sample_fmt
Definition: buffersrc.c:56
static int query_formats(AVFilterContext *ctx)
Definition: buffersrc.c:367
uint64_t av_get_channel_layout(const char *name)
Return a channel layout id that matches name, or 0 if no match is found.
A list of supported formats for one end of a filter link.
Definition: formats.h:64
int avfilter_copy_buf_props(AVFrame *dst, const AVFilterBufferRef *src)
Definition: buffer.c:125
An instance of a filter.
Definition: avfilter.h:563
int height
Definition: frame.h:174
void ff_set_common_channel_layouts(AVFilterContext *ctx, AVFilterChannelLayouts *layouts)
A helper for query_formats() which sets all links to the same list of channel layouts/sample rates...
Definition: formats.c:360
enum AVPixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
Definition: pixdesc.c:1552
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
Definition: pixdesc.c:1540
internal API functions
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:169
AVPixelFormat
Pixel format.
Definition: pixfmt.h:63
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition: mem.c:205
#define CHECK_VIDEO_PARAM_CHANGE(s, c, width, height, format)
Definition: buffersrc.c:64
char * channel_layout_str
Definition: buffersrc.c:59