FFmpeg
buffersink.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011 Stefano Sabatini
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  * buffer sink
24  */
25 
26 #include "libavutil/avassert.h"
27 #include "libavutil/avstring.h"
29 #include "libavutil/common.h"
30 #include "libavutil/internal.h"
31 #include "libavutil/opt.h"
32 
33 #define FF_INTERNAL_FIELDS 1
34 #include "framequeue.h"
35 
36 #include "audio.h"
37 #include "avfilter.h"
38 #include "buffersink.h"
39 #include "filters.h"
40 #include "internal.h"
41 
42 typedef struct BufferSinkContext {
43  const AVClass *class;
44  unsigned warning_limit;
45 
46  /* only used for video */
47  enum AVPixelFormat *pixel_fmts; ///< list of accepted pixel formats
49 
50  /* only used for audio */
51  enum AVSampleFormat *sample_fmts; ///< list of accepted sample formats
53 #if FF_API_OLD_CHANNEL_LAYOUT
54  int64_t *channel_layouts; ///< list of accepted channel layouts
55  int channel_layouts_size;
56  int *channel_counts; ///< list of accepted channel counts
57  int channel_counts_size;
58 #endif
59  char *channel_layouts_str; ///< list of accepted channel layouts
61  int *sample_rates; ///< list of accepted sample rates
63 
66 
67 #define NB_ITEMS(list) (list ## _size / sizeof(*list))
68 
69 #if FF_API_OLD_CHANNEL_LAYOUT
70 static void cleanup_redundant_layouts(AVFilterContext *ctx)
71 {
72  BufferSinkContext *buf = ctx->priv;
73  int nb_layouts = NB_ITEMS(buf->channel_layouts);
74  int nb_counts = NB_ITEMS(buf->channel_counts);
75  uint64_t counts = 0;
76  int i, lc, n;
77 
78  for (i = 0; i < nb_counts; i++)
79  if (buf->channel_counts[i] < 64)
80  counts |= (uint64_t)1 << buf->channel_counts[i];
81  for (i = lc = 0; i < nb_layouts; i++) {
82  n = av_popcount64(buf->channel_layouts[i]);
83  if (n < 64 && (counts & ((uint64_t)1 << n)))
85  "Removing channel layout 0x%"PRIx64", redundant with %d channels\n",
86  buf->channel_layouts[i], n);
87  else
88  buf->channel_layouts[lc++] = buf->channel_layouts[i];
89  }
90  buf->channel_layouts_size = lc * sizeof(*buf->channel_layouts);
91 }
92 #endif
93 
95 {
97 }
98 
100 {
101  if ((flags & AV_BUFFERSINK_FLAG_PEEK)) {
102  buf->peeked_frame = in;
103  return out ? av_frame_ref(out, in) : 0;
104  } else {
105  av_assert1(out);
106  buf->peeked_frame = NULL;
107  av_frame_move_ref(out, in);
108  av_frame_free(&in);
109  return 0;
110  }
111 }
112 
114 {
115  BufferSinkContext *buf = ctx->priv;
116  AVFilterLink *inlink = ctx->inputs[0];
117  int status, ret;
118  AVFrame *cur_frame;
119  int64_t pts;
120 
121  if (buf->peeked_frame)
122  return return_or_keep_frame(buf, frame, buf->peeked_frame, flags);
123 
124  while (1) {
126  ff_inlink_consume_frame(inlink, &cur_frame);
127  if (ret < 0) {
128  return ret;
129  } else if (ret) {
130  /* TODO return the frame instead of copying it */
131  return return_or_keep_frame(buf, frame, cur_frame, flags);
132  } else if (ff_inlink_acknowledge_status(inlink, &status, &pts)) {
133  return status;
134  } else if ((flags & AV_BUFFERSINK_FLAG_NO_REQUEST)) {
135  return AVERROR(EAGAIN);
136  } else if (inlink->frame_wanted_out) {
137  ret = ff_filter_graph_run_once(ctx->graph);
138  if (ret < 0)
139  return ret;
140  } else {
142  }
143  }
144 }
145 
147 {
148  return get_frame_internal(ctx, frame, flags, ctx->inputs[0]->min_samples);
149 }
150 
152  AVFrame *frame, int nb_samples)
153 {
154  return get_frame_internal(ctx, frame, 0, nb_samples);
155 }
156 
157 #if FF_API_BUFFERSINK_ALLOC
158 AVBufferSinkParams *av_buffersink_params_alloc(void)
159 {
160  static const int pixel_fmts[] = { AV_PIX_FMT_NONE };
161  AVBufferSinkParams *params = av_malloc(sizeof(AVBufferSinkParams));
162  if (!params)
163  return NULL;
164 
165  params->pixel_fmts = pixel_fmts;
166  return params;
167 }
168 
169 AVABufferSinkParams *av_abuffersink_params_alloc(void)
170 {
171  AVABufferSinkParams *params = av_mallocz(sizeof(AVABufferSinkParams));
172 
173  if (!params)
174  return NULL;
175  return params;
176 }
177 #endif
178 
180 {
181  BufferSinkContext *buf = ctx->priv;
182 
183  buf->warning_limit = 100;
184  return 0;
185 }
186 
188 {
189  BufferSinkContext *buf = ctx->priv;
190 
191  if (buf->warning_limit &&
192  ff_framequeue_queued_frames(&ctx->inputs[0]->fifo) >= buf->warning_limit) {
194  "%d buffers queued in %s, something may be wrong.\n",
195  buf->warning_limit,
196  (char *)av_x_if_null(ctx->name, ctx->filter->name));
197  buf->warning_limit *= 10;
198  }
199 
200  /* The frame is queued, the rest is up to get_frame_internal */
201  return 0;
202 }
203 
205 {
206  AVFilterLink *inlink = ctx->inputs[0];
207 
208  inlink->min_samples = inlink->max_samples = frame_size;
209 }
210 
211 #define MAKE_AVFILTERLINK_ACCESSOR(type, field) \
212 type av_buffersink_get_##field(const AVFilterContext *ctx) { \
213  av_assert0(ctx->filter->activate == activate); \
214  return ctx->inputs[0]->field; \
215 }
216 
220 
224 MAKE_AVFILTERLINK_ACCESSOR(AVRational , sample_aspect_ratio)
225 
226 #if FF_API_OLD_CHANNEL_LAYOUT
228 MAKE_AVFILTERLINK_ACCESSOR(uint64_t , channel_layout )
230 #endif
232 
233 MAKE_AVFILTERLINK_ACCESSOR(AVBufferRef * , hw_frames_ctx )
234 
236 {
237  av_assert0(ctx->filter->activate == activate);
238  return ctx->inputs[0]->ch_layout.nb_channels;
239 }
240 
242 {
243  AVChannelLayout ch_layout = { 0 };
244  int ret;
245 
246  av_assert0(ctx->filter->activate == activate);
247  ret = av_channel_layout_copy(&ch_layout, &ctx->inputs[0]->ch_layout);
248  if (ret < 0)
249  return ret;
250  *out = ch_layout;
251  return 0;
252 }
253 
254 #define CHECK_LIST_SIZE(field) \
255  if (buf->field ## _size % sizeof(*buf->field)) { \
256  av_log(ctx, AV_LOG_ERROR, "Invalid size for " #field ": %d, " \
257  "should be multiple of %d\n", \
258  buf->field ## _size, (int)sizeof(*buf->field)); \
259  return AVERROR(EINVAL); \
260  }
262 {
263  BufferSinkContext *buf = ctx->priv;
265  unsigned i;
266  int ret;
267 
269  if (buf->pixel_fmts_size) {
270  for (i = 0; i < NB_ITEMS(buf->pixel_fmts); i++)
271  if ((ret = ff_add_format(&formats, buf->pixel_fmts[i])) < 0)
272  return ret;
273  if ((ret = ff_set_common_formats(ctx, formats)) < 0)
274  return ret;
275  } else {
276  if ((ret = ff_default_query_formats(ctx)) < 0)
277  return ret;
278  }
279 
280  return 0;
281 }
282 
284 {
285  BufferSinkContext *buf = ctx->priv;
287  AVChannelLayout layout = { 0 };
289  unsigned i;
290  int ret;
291 
294 #if FF_API_OLD_CHANNEL_LAYOUT
296  CHECK_LIST_SIZE(channel_counts)
297 #endif
298 
299  if (buf->sample_fmts_size) {
300  for (i = 0; i < NB_ITEMS(buf->sample_fmts); i++)
301  if ((ret = ff_add_format(&formats, buf->sample_fmts[i])) < 0)
302  return ret;
303  if ((ret = ff_set_common_formats(ctx, formats)) < 0)
304  return ret;
305  }
306 
307  if (
309  buf->channel_layouts_size || buf->channel_counts_size ||
310 #endif
312 #if FF_API_OLD_CHANNEL_LAYOUT
313  cleanup_redundant_layouts(ctx);
314  for (i = 0; i < NB_ITEMS(buf->channel_layouts); i++)
315  if ((ret = av_channel_layout_from_mask(&layout, buf->channel_layouts[i])) < 0 ||
317  return ret;
318  for (i = 0; i < NB_ITEMS(buf->channel_counts); i++) {
319  layout = FF_COUNT2LAYOUT(buf->channel_counts[i]);
320  if ((ret = ff_add_channel_layout(&layouts, &layout)) < 0)
321  return ret;
322  }
323 #endif
324  if (buf->channel_layouts_str) {
325  const char *cur = buf->channel_layouts_str;
326 
327 #if FF_API_OLD_CHANNEL_LAYOUT
328  if (layouts)
330  "Conflicting ch_layouts and list of channel_counts/channel_layouts. Ignoring the former\n");
331  else
332 #endif
333  while (cur) {
334  char *next = strchr(cur, '|');
335  if (next)
336  *next++ = 0;
337 
339  if (ret < 0) {
340  av_log(ctx, AV_LOG_ERROR, "Error parsing channel layout: %s.\n", cur);
341  return ret;
342  }
345  if (ret < 0)
346  return ret;
347 
348  cur = next;
349  }
350  }
351 
352  if (buf->all_channel_counts) {
353  if (layouts)
355  "Conflicting all_channel_counts and list in options\n");
356  else if (!(layouts = ff_all_channel_counts()))
357  return AVERROR(ENOMEM);
358  }
360  return ret;
361  }
362 
363  if (buf->sample_rates_size) {
364  formats = NULL;
365  for (i = 0; i < NB_ITEMS(buf->sample_rates); i++)
366  if ((ret = ff_add_format(&formats, buf->sample_rates[i])) < 0)
367  return ret;
369  return ret;
370  }
371 
372  return 0;
373 }
374 
375 #define OFFSET(x) offsetof(BufferSinkContext, x)
376 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
377 static const AVOption buffersink_options[] = {
378  { "pix_fmts", "set the supported pixel formats", OFFSET(pixel_fmts), AV_OPT_TYPE_BINARY, .flags = FLAGS },
379  { NULL },
380 };
381 #undef FLAGS
382 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_AUDIO_PARAM
383 static const AVOption abuffersink_options[] = {
384  { "sample_fmts", "set the supported sample formats", OFFSET(sample_fmts), AV_OPT_TYPE_BINARY, .flags = FLAGS },
385  { "sample_rates", "set the supported sample rates", OFFSET(sample_rates), AV_OPT_TYPE_BINARY, .flags = FLAGS },
386 #if FF_API_OLD_CHANNEL_LAYOUT
387  { "channel_layouts", "set the supported channel layouts (deprecated, use ch_layouts)",
389  { "channel_counts", "set the supported channel counts (deprecated, use ch_layouts)",
390  OFFSET(channel_counts), AV_OPT_TYPE_BINARY, .flags = FLAGS | AV_OPT_FLAG_DEPRECATED },
391 #endif
392  { "ch_layouts", "set a '|'-separated list of supported channel layouts",
393  OFFSET(channel_layouts_str), AV_OPT_TYPE_STRING, .flags = FLAGS },
394  { "all_channel_counts", "accept all channel counts", OFFSET(all_channel_counts), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS },
395  { NULL },
396 };
397 #undef FLAGS
398 
399 AVFILTER_DEFINE_CLASS(buffersink);
400 AVFILTER_DEFINE_CLASS(abuffersink);
401 
403  {
404  .name = "default",
405  .type = AVMEDIA_TYPE_VIDEO,
406  },
407 };
408 
410  .name = "buffersink",
411  .description = NULL_IF_CONFIG_SMALL("Buffer video frames, and make them available to the end of the filter graph."),
412  .priv_size = sizeof(BufferSinkContext),
413  .priv_class = &buffersink_class,
414  .init = common_init,
415  .activate = activate,
417  .outputs = NULL,
419 };
420 
422  {
423  .name = "default",
424  .type = AVMEDIA_TYPE_AUDIO,
425  },
426 };
427 
429  .name = "abuffersink",
430  .description = NULL_IF_CONFIG_SMALL("Buffer audio frames, and make them available to the end of the filter graph."),
431  .priv_class = &abuffersink_class,
432  .priv_size = sizeof(BufferSinkContext),
433  .init = common_init,
434  .activate = activate,
436  .outputs = NULL,
438 };
formats
formats
Definition: signature.h:48
avfilter_vsink_buffer_inputs
static const AVFilterPad avfilter_vsink_buffer_inputs[]
Definition: buffersink.c:402
FF_ENABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:83
AVFilterChannelLayouts
A list of supported channel layouts.
Definition: formats.h:85
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
av_buffersink_get_ch_layout
int av_buffersink_get_ch_layout(const AVFilterContext *ctx, AVChannelLayout *out)
Definition: buffersink.c:241
av_buffersink_get_samples
int attribute_align_arg av_buffersink_get_samples(AVFilterContext *ctx, AVFrame *frame, int nb_samples)
Same as av_buffersink_get_frame(), but with the ability to specify the number of samples read.
Definition: buffersink.c:151
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
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
abuffersink_options
static const AVOption abuffersink_options[]
Definition: buffersink.c:383
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
BufferSinkContext::sample_fmts
enum AVSampleFormat * sample_fmts
list of accepted sample formats
Definition: buffersink.c:51
out
FILE * out
Definition: movenc.c:54
av_popcount64
#define av_popcount64
Definition: common.h:152
sample_fmts
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:947
layouts
enum MovChannelLayoutTag * layouts
Definition: mov_chan.c:330
av_buffersink_get_frame_flags
int attribute_align_arg av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)
Get a frame with filtered data from sink and put it in frame.
Definition: buffersink.c:146
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:111
ff_all_channel_counts
AVFilterChannelLayouts * ff_all_channel_counts(void)
Construct an AVFilterChannelLayouts coding for any channel layout, with known or unknown disposition.
Definition: formats.c:566
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:325
w
uint8_t w
Definition: llviddspenc.c:38
AVOption
AVOption.
Definition: opt.h:251
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:167
pixel_fmts
static enum AVPixelFormat pixel_fmts[]
Definition: vf_amplify.c:53
ff_filter_graph_run_once
int ff_filter_graph_run_once(AVFilterGraph *graph)
Run one round of processing on a filter graph.
Definition: avfiltergraph.c:1339
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:175
BufferSinkContext::sample_fmts_size
int sample_fmts_size
Definition: buffersink.c:52
sample_rate
sample_rate
Definition: ffmpeg_filter.c:153
CHECK_LIST_SIZE
#define CHECK_LIST_SIZE(field)
Definition: buffersink.c:254
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:30
av_channel_layout_copy
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
Definition: channel_layout.c:637
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:64
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:1394
ff_asink_abuffer
const AVFilter ff_asink_abuffer
Definition: buffersink.c:428
av_buffersink_set_frame_size
void av_buffersink_set_frame_size(AVFilterContext *ctx, unsigned frame_size)
Set the frame size for an audio buffer sink.
Definition: buffersink.c:204
AV_OPT_TYPE_BINARY
@ AV_OPT_TYPE_BINARY
offset must point to a pointer immediately followed by an int for the length
Definition: opt.h:231
BufferSinkContext::channel_layouts_str
char * channel_layouts_str
list of accepted channel layouts
Definition: buffersink.c:59
type
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 type
Definition: writing_filters.txt:86
pts
static int64_t pts
Definition: transcode_aac.c:654
BufferSinkContext::pixel_fmts
enum AVPixelFormat * pixel_fmts
list of accepted pixel formats
Definition: buffersink.c:47
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:49
avassert.h
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
av_cold
#define av_cold
Definition: attributes.h:90
ff_set_common_formats
int 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:749
AV_BUFFERSINK_FLAG_PEEK
#define AV_BUFFERSINK_FLAG_PEEK
Tell av_buffersink_get_buffer_ref() to read video/samples buffer reference, but not remove it from th...
Definition: buffersink.h:88
ff_inlink_request_frame
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
Definition: avfilter.c:1511
format
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 format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
return_or_keep_frame
static int return_or_keep_frame(BufferSinkContext *buf, AVFrame *out, AVFrame *in, int flags)
Definition: buffersink.c:99
frame_size
int frame_size
Definition: mxfenc.c:2201
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
av_buffersink_get_frame
int attribute_align_arg av_buffersink_get_frame(AVFilterContext *ctx, AVFrame *frame)
Get a frame with filtered data from sink and put it in frame.
Definition: buffersink.c:94
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(buffersink)
filters.h
ctx
AVFormatContext * ctx
Definition: movenc.c:48
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:190
FLAGS
#define FLAGS
Definition: buffersink.c:382
activate
static int activate(AVFilterContext *ctx)
Definition: buffersink.c:187
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
ff_inlink_consume_samples
int ff_inlink_consume_samples(AVFilterLink *link, unsigned min, unsigned max, AVFrame **rframe)
Take samples from the link's FIFO and update the link's stats.
Definition: avfilter.c:1413
NULL
#define NULL
Definition: coverity.c:32
framequeue.h
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
vsink_query_formats
static int vsink_query_formats(AVFilterContext *ctx)
Definition: buffersink.c:261
ff_add_format
int ff_add_format(AVFilterFormats **avff, int64_t fmt)
Add fmt to the list of media formats contained in *avff.
Definition: formats.c:449
ff_add_channel_layout
int ff_add_channel_layout(AVFilterChannelLayouts **l, const AVChannelLayout *channel_layout)
Definition: formats.c:466
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:1348
buffersink_options
static const AVOption buffersink_options[]
Definition: buffersink.c:377
av_channel_layout_uninit
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
Definition: channel_layout.c:630
BufferSinkContext::sample_rates_size
int sample_rates_size
Definition: buffersink.c:62
avfilter_asink_abuffer_inputs
static const AVFilterPad avfilter_asink_abuffer_inputs[]
Definition: buffersink.c:421
AVMediaType
AVMediaType
Definition: avutil.h:199
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
av_frame_ref
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:343
ff_default_query_formats
int ff_default_query_formats(AVFilterContext *ctx)
Definition: formats.c:760
AVChannelLayout
An AVChannelLayout holds information about the channel layout of audio data.
Definition: channel_layout.h:290
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
FF_API_OLD_CHANNEL_LAYOUT
#define FF_API_OLD_CHANNEL_LAYOUT
Definition: version.h:115
NB_ITEMS
#define NB_ITEMS(list)
Definition: buffersink.c:67
common_init
static av_cold int common_init(AVFilterContext *ctx)
Definition: buffersink.c:179
sample_rates
sample_rates
Definition: ffmpeg_filter.c:153
internal.h
buffersink.h
layout
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 layout
Definition: filter_design.txt:18
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
internal.h
common.h
av_assert1
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:53
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
av_frame_move_ref
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
Definition: frame.c:506
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:264
BufferSinkContext
Definition: buffersink.c:42
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:55
ff_vsink_buffer
const AVFilter ff_vsink_buffer
Definition: buffersink.c:409
AVFilter
Filter definition.
Definition: avfilter.h:171
OFFSET
#define OFFSET(x)
Definition: buffersink.c:375
av_channel_layout_from_mask
FF_ENABLE_DEPRECATION_WARNINGS int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask)
Initialize a native channel layout from a bitmask indicating which channels are present.
Definition: channel_layout.c:389
AV_BUFFERSINK_FLAG_NO_REQUEST
#define AV_BUFFERSINK_FLAG_NO_REQUEST
Tell av_buffersink_get_buffer_ref() not to request a frame from its input.
Definition: buffersink.h:95
ret
ret
Definition: filter_design.txt:187
BufferSinkContext::warning_limit
unsigned warning_limit
Definition: buffersink.c:44
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_COUNT2LAYOUT
#define FF_COUNT2LAYOUT(c)
Encode a channel count as a channel layout.
Definition: formats.h:102
ff_framequeue_queued_frames
static size_t ff_framequeue_queued_frames(const FFFrameQueue *fq)
Get the number of queued frames.
Definition: framequeue.h:146
channel_layout.h
av_channel_layout_from_string
int av_channel_layout_from_string(AVChannelLayout *channel_layout, const char *str)
Initialize a channel layout from a given string description.
Definition: channel_layout.c:402
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
avfilter.h
av_buffersink_get_channels
int av_buffersink_get_channels(const AVFilterContext *ctx)
Definition: buffersink.c:235
samples
Filter the word “frame” indicates either a video frame or a group of audio samples
Definition: filter_design.txt:8
AVFilterContext
An instance of a filter.
Definition: avfilter.h:408
FF_DISABLE_DEPRECATION_WARNINGS
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:82
get_frame_internal
static int get_frame_internal(AVFilterContext *ctx, AVFrame *frame, int flags, int samples)
Definition: buffersink.c:113
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
audio.h
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
MAKE_AVFILTERLINK_ACCESSOR
#define MAKE_AVFILTERLINK_ACCESSOR(type, field)
Definition: buffersink.c:211
asink_query_formats
static int asink_query_formats(AVFilterContext *ctx)
Definition: buffersink.c:283
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:244
channel_layouts
static const uint16_t channel_layouts[7]
Definition: dca_lbr.c:111
BufferSinkContext::all_channel_counts
int all_channel_counts
Definition: buffersink.c:60
BufferSinkContext::peeked_frame
AVFrame * peeked_frame
Definition: buffersink.c:64
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
ff_set_common_samplerates
int ff_set_common_samplerates(AVFilterContext *ctx, AVFilterFormats *samplerates)
Definition: formats.c:726
h
h
Definition: vp9dsp_template.c:2038
avstring.h
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:229
int
int
Definition: ffmpeg_filter.c:153
BufferSinkContext::sample_rates
int * sample_rates
list of accepted sample rates
Definition: buffersink.c:61
av_x_if_null
static void * av_x_if_null(const void *p, const void *x)
Return x default pointer in case p is NULL.
Definition: avutil.h:308
ff_set_common_channel_layouts
int ff_set_common_channel_layouts(AVFilterContext *ctx, AVFilterChannelLayouts *channel_layouts)
Helpers for query_formats() which set all free audio links to the same list of channel layouts/sample...
Definition: formats.c:708
BufferSinkContext::pixel_fmts_size
int pixel_fmts_size
Definition: buffersink.c:48
AV_OPT_FLAG_DEPRECATED
#define AV_OPT_FLAG_DEPRECATED
set if option is deprecated, users should refer to AVOption.help text for more information
Definition: opt.h:298