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 
158 {
159  BufferSinkContext *buf = ctx->priv;
160 
161  buf->warning_limit = 100;
162  return 0;
163 }
164 
166 {
167  BufferSinkContext *buf = ctx->priv;
168 
169  if (buf->warning_limit &&
170  ff_framequeue_queued_frames(&ctx->inputs[0]->fifo) >= buf->warning_limit) {
172  "%d buffers queued in %s, something may be wrong.\n",
173  buf->warning_limit,
174  (char *)av_x_if_null(ctx->name, ctx->filter->name));
175  buf->warning_limit *= 10;
176  }
177 
178  /* The frame is queued, the rest is up to get_frame_internal */
179  return 0;
180 }
181 
183 {
184  AVFilterLink *inlink = ctx->inputs[0];
185 
186  inlink->min_samples = inlink->max_samples = frame_size;
187 }
188 
189 #define MAKE_AVFILTERLINK_ACCESSOR(type, field) \
190 type av_buffersink_get_##field(const AVFilterContext *ctx) { \
191  av_assert0(ctx->filter->activate == activate); \
192  return ctx->inputs[0]->field; \
193 }
194 
198 
202 MAKE_AVFILTERLINK_ACCESSOR(AVRational , sample_aspect_ratio)
203 
204 #if FF_API_OLD_CHANNEL_LAYOUT
206 MAKE_AVFILTERLINK_ACCESSOR(uint64_t , channel_layout )
208 #endif
210 
211 MAKE_AVFILTERLINK_ACCESSOR(AVBufferRef * , hw_frames_ctx )
212 
214 {
215  av_assert0(ctx->filter->activate == activate);
216  return ctx->inputs[0]->ch_layout.nb_channels;
217 }
218 
220 {
221  AVChannelLayout ch_layout = { 0 };
222  int ret;
223 
224  av_assert0(ctx->filter->activate == activate);
225  ret = av_channel_layout_copy(&ch_layout, &ctx->inputs[0]->ch_layout);
226  if (ret < 0)
227  return ret;
228  *out = ch_layout;
229  return 0;
230 }
231 
232 #define CHECK_LIST_SIZE(field) \
233  if (buf->field ## _size % sizeof(*buf->field)) { \
234  av_log(ctx, AV_LOG_ERROR, "Invalid size for " #field ": %d, " \
235  "should be multiple of %d\n", \
236  buf->field ## _size, (int)sizeof(*buf->field)); \
237  return AVERROR(EINVAL); \
238  }
240 {
241  BufferSinkContext *buf = ctx->priv;
243  unsigned i;
244  int ret;
245 
247  if (buf->pixel_fmts_size) {
248  for (i = 0; i < NB_ITEMS(buf->pixel_fmts); i++)
249  if ((ret = ff_add_format(&formats, buf->pixel_fmts[i])) < 0)
250  return ret;
251  if ((ret = ff_set_common_formats(ctx, formats)) < 0)
252  return ret;
253  } else {
254  if ((ret = ff_default_query_formats(ctx)) < 0)
255  return ret;
256  }
257 
258  return 0;
259 }
260 
262 {
263  BufferSinkContext *buf = ctx->priv;
265  AVChannelLayout layout = { 0 };
267  unsigned i;
268  int ret;
269 
272 #if FF_API_OLD_CHANNEL_LAYOUT
274  CHECK_LIST_SIZE(channel_counts)
275 #endif
276 
277  if (buf->sample_fmts_size) {
278  for (i = 0; i < NB_ITEMS(buf->sample_fmts); i++)
279  if ((ret = ff_add_format(&formats, buf->sample_fmts[i])) < 0)
280  return ret;
281  if ((ret = ff_set_common_formats(ctx, formats)) < 0)
282  return ret;
283  }
284 
285  if (
287  buf->channel_layouts_size || buf->channel_counts_size ||
288 #endif
290 #if FF_API_OLD_CHANNEL_LAYOUT
291  cleanup_redundant_layouts(ctx);
292  for (i = 0; i < NB_ITEMS(buf->channel_layouts); i++)
293  if ((ret = av_channel_layout_from_mask(&layout, buf->channel_layouts[i])) < 0 ||
295  return ret;
296  for (i = 0; i < NB_ITEMS(buf->channel_counts); i++) {
297  layout = FF_COUNT2LAYOUT(buf->channel_counts[i]);
298  if ((ret = ff_add_channel_layout(&layouts, &layout)) < 0)
299  return ret;
300  }
301 #endif
302  if (buf->channel_layouts_str) {
303  const char *cur = buf->channel_layouts_str;
304 
305 #if FF_API_OLD_CHANNEL_LAYOUT
306  if (layouts)
308  "Conflicting ch_layouts and list of channel_counts/channel_layouts. Ignoring the former\n");
309  else
310 #endif
311  while (cur) {
312  char *next = strchr(cur, '|');
313  if (next)
314  *next++ = 0;
315 
317  if (ret < 0) {
318  av_log(ctx, AV_LOG_ERROR, "Error parsing channel layout: %s.\n", cur);
319  return ret;
320  }
323  if (ret < 0)
324  return ret;
325 
326  cur = next;
327  }
328  }
329 
330  if (buf->all_channel_counts) {
331  if (layouts)
333  "Conflicting all_channel_counts and list in options\n");
334  else if (!(layouts = ff_all_channel_counts()))
335  return AVERROR(ENOMEM);
336  }
338  return ret;
339  }
340 
341  if (buf->sample_rates_size) {
342  formats = NULL;
343  for (i = 0; i < NB_ITEMS(buf->sample_rates); i++)
344  if ((ret = ff_add_format(&formats, buf->sample_rates[i])) < 0)
345  return ret;
347  return ret;
348  }
349 
350  return 0;
351 }
352 
353 #define OFFSET(x) offsetof(BufferSinkContext, x)
354 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
355 static const AVOption buffersink_options[] = {
356  { "pix_fmts", "set the supported pixel formats", OFFSET(pixel_fmts), AV_OPT_TYPE_BINARY, .flags = FLAGS },
357  { NULL },
358 };
359 #undef FLAGS
360 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_AUDIO_PARAM
361 static const AVOption abuffersink_options[] = {
362  { "sample_fmts", "set the supported sample formats", OFFSET(sample_fmts), AV_OPT_TYPE_BINARY, .flags = FLAGS },
363  { "sample_rates", "set the supported sample rates", OFFSET(sample_rates), AV_OPT_TYPE_BINARY, .flags = FLAGS },
364 #if FF_API_OLD_CHANNEL_LAYOUT
365  { "channel_layouts", "set the supported channel layouts (deprecated, use ch_layouts)",
367  { "channel_counts", "set the supported channel counts (deprecated, use ch_layouts)",
368  OFFSET(channel_counts), AV_OPT_TYPE_BINARY, .flags = FLAGS | AV_OPT_FLAG_DEPRECATED },
369 #endif
370  { "ch_layouts", "set a '|'-separated list of supported channel layouts",
371  OFFSET(channel_layouts_str), AV_OPT_TYPE_STRING, .flags = FLAGS },
372  { "all_channel_counts", "accept all channel counts", OFFSET(all_channel_counts), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS },
373  { NULL },
374 };
375 #undef FLAGS
376 
377 AVFILTER_DEFINE_CLASS(buffersink);
378 AVFILTER_DEFINE_CLASS(abuffersink);
379 
381  {
382  .name = "default",
383  .type = AVMEDIA_TYPE_VIDEO,
384  },
385 };
386 
388  .name = "buffersink",
389  .description = NULL_IF_CONFIG_SMALL("Buffer video frames, and make them available to the end of the filter graph."),
390  .priv_size = sizeof(BufferSinkContext),
391  .priv_class = &buffersink_class,
392  .init = common_init,
393  .activate = activate,
395  .outputs = NULL,
397 };
398 
400  {
401  .name = "default",
402  .type = AVMEDIA_TYPE_AUDIO,
403  },
404 };
405 
407  .name = "abuffersink",
408  .description = NULL_IF_CONFIG_SMALL("Buffer audio frames, and make them available to the end of the filter graph."),
409  .priv_class = &abuffersink_class,
410  .priv_size = sizeof(BufferSinkContext),
411  .init = common_init,
412  .activate = activate,
414  .outputs = NULL,
416 };
formats
formats
Definition: signature.h:48
avfilter_vsink_buffer_inputs
static const AVFilterPad avfilter_vsink_buffer_inputs[]
Definition: buffersink.c:380
FF_ENABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:82
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:219
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:361
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:326
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:99
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:330
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:171
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:1340
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:165
BufferSinkContext::sample_fmts_size
int sample_fmts_size
Definition: buffersink.c:52
sample_rate
sample_rate
Definition: ffmpeg_filter.c:156
CHECK_LIST_SIZE
#define CHECK_LIST_SIZE(field)
Definition: buffersink.c:232
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:64
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
ff_asink_abuffer
const AVFilter ff_asink_abuffer
Definition: buffersink.c:406
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:182
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:653
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:1481
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:2205
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
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:391
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts_bsf.c:365
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:194
FLAGS
#define FLAGS
Definition: buffersink.c:360
activate
static int activate(AVFilterContext *ctx)
Definition: buffersink.c:165
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:1383
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:239
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:1318
buffersink_options
static const AVOption buffersink_options[]
Definition: buffersink.c:355
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:399
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:115
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:344
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:301
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:111
NB_ITEMS
#define NB_ITEMS(list)
Definition: buffersink.c:67
common_init
static av_cold int common_init(AVFilterContext *ctx)
Definition: buffersink.c:157
sample_rates
sample_rates
Definition: ffmpeg_filter.c:156
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
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:404
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:507
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:387
AVFilter
Filter definition.
Definition: avfilter.h:161
OFFSET
#define OFFSET(x)
Definition: buffersink.c:353
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
avfilter.h
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:632
av_buffersink_get_channels
int av_buffersink_get_channels(const AVFilterContext *ctx)
Definition: buffersink.c:213
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:392
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:639
FF_DISABLE_DEPRECATION_WARNINGS
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:81
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:189
asink_query_formats
static int asink_query_formats(AVFilterContext *ctx)
Definition: buffersink.c:261
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:156
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