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/mem.h"
32 #include "libavutil/opt.h"
33 
34 #include "audio.h"
35 #include "avfilter.h"
36 #include "avfilter_internal.h"
37 #include "buffersink.h"
38 #include "filters.h"
39 #include "formats.h"
40 #include "framequeue.h"
41 #include "video.h"
42 
43 typedef struct BufferSinkContext {
44  const AVClass *class;
45  unsigned warning_limit;
46  unsigned frame_size;
47 
48  /* only used for video */
50  unsigned nb_pixel_formats;
51 
53  unsigned nb_colorspaces;
54 
56  unsigned nb_colorranges;
57 
58  int *alphamodes;
59  unsigned nb_alphamodes;
60 
61  /* only used for audio */
64 
66  unsigned nb_samplerates;
67 
70 
73 
75 {
77 }
78 
80 {
82  buf->peeked_frame = in;
83  return out ? av_frame_ref(out, in) : 0;
84  } else {
85  av_assert1(out);
86  buf->peeked_frame = NULL;
88  av_frame_free(&in);
89  return 0;
90  }
91 }
92 
94 {
95  BufferSinkContext *buf = ctx->priv;
96  AVFilterLink *inlink = ctx->inputs[0];
98  int status, ret;
99  AVFrame *cur_frame;
100  int64_t pts;
101  int buffersrc_empty = 0;
102 
103  if (buf->peeked_frame)
104  return return_or_keep_frame(buf, frame, buf->peeked_frame, flags);
105 
106  while (1) {
108  ff_inlink_consume_frame(inlink, &cur_frame);
109  if (ret < 0) {
110  return ret;
111  } else if (ret) {
112  /* TODO return the frame instead of copying it */
113  return return_or_keep_frame(buf, frame, cur_frame, flags);
114  } else if (ff_inlink_acknowledge_status(inlink, &status, &pts)) {
115  return status;
116  } else if ((flags & AV_BUFFERSINK_FLAG_NO_REQUEST)) {
117  return AVERROR(EAGAIN);
118  } else if (li->frame_wanted_out) {
119  ret = ff_filter_graph_run_once(ctx->graph);
120  if (ret == FFERROR_BUFFERSRC_EMPTY) {
121  buffersrc_empty = 1;
122  } else if (ret == AVERROR(EAGAIN)) {
123  if (buffersrc_empty)
124  return ret;
126  } else if (ret < 0) {
127  return ret;
128  }
129  } else {
131  }
132  }
133 }
134 
136 {
138  ff_filter_link(ctx->inputs[0])->min_samples);
139 }
140 
142  AVFrame *frame, int nb_samples)
143 {
144  return get_frame_internal(ctx, frame, 0, nb_samples);
145 }
146 
148 {
149  BufferSinkContext *buf = ctx->priv;
150 
151  buf->warning_limit = 100;
152  return 0;
153 }
154 
155 #define TERMINATE_ARRAY(arr, val) \
156  if (s->arr) { \
157  void *tmp = av_realloc_array(s->arr, s->nb_ ## arr + 1, sizeof(*s->arr)); \
158  if (!tmp) \
159  return AVERROR(ENOMEM); \
160  s->arr = tmp; \
161  s->arr[s->nb_ ## arr] = val; \
162  }
163 
165 {
166  BufferSinkContext *s = ctx->priv;
167 
169  TERMINATE_ARRAY(colorranges, -1);
170  TERMINATE_ARRAY(colorspaces, -1);
171  TERMINATE_ARRAY(alphamodes, -1);
172 
173  return common_init(ctx);
174 }
175 
177 {
178  BufferSinkContext *s = ctx->priv;
179 
181  TERMINATE_ARRAY(samplerates, -1);
182  TERMINATE_ARRAY(channel_layouts, (AVChannelLayout){ .nb_channels = 0 });
183 
184  return common_init(ctx);
185 }
186 
187 #undef TERMINATE_ARRAY
188 
190 {
191  BufferSinkContext *buf = ctx->priv;
192 
194 }
195 
197 {
198  BufferSinkContext *buf = ctx->priv;
199  FilterLinkInternal * const li = ff_link_internal(ctx->inputs[0]);
200 
201  if (buf->warning_limit &&
204  "%d buffers queued in %s, something may be wrong.\n",
205  buf->warning_limit,
206  (char *)av_x_if_null(ctx->name, ctx->filter->name));
207  buf->warning_limit *= 10;
208  }
209 
210  /* The frame is queued, the rest is up to get_frame_internal */
211  return 0;
212 }
213 
215 {
216  BufferSinkContext *buf = inlink->dst->priv;
218 
219  l->min_samples = l->max_samples = buf->frame_size;
220 
221  return 0;
222 }
223 
225 {
226  BufferSinkContext *buf = ctx->priv;
227  buf->frame_size = frame_size;
228 
229  if (ctx->inputs && ctx->inputs[0]) {
230  FilterLink *l = ff_filter_link(ctx->inputs[0]);
231  l->min_samples = l->max_samples = buf->frame_size;
232  }
233 }
234 
235 #define MAKE_AVFILTERLINK_ACCESSOR(type, field) \
236 type av_buffersink_get_##field(const AVFilterContext *ctx) { \
237  av_assert0(fffilter(ctx->filter)->activate == activate); \
238  return ctx->inputs[0]->field; \
239 }
240 
244 
247 MAKE_AVFILTERLINK_ACCESSOR(AVRational , sample_aspect_ratio)
250 MAKE_AVFILTERLINK_ACCESSOR(enum AVAlphaMode , alpha_mode)
251 
252 MAKE_AVFILTERLINK_ACCESSOR(int , sample_rate )
253 
255 {
256  FilterLink *l = ff_filter_link(ctx->inputs[0]);
257  av_assert0(fffilter(ctx->filter)->activate == activate);
258  return l->frame_rate;
259 }
260 
262 {
263  FilterLink *l = ff_filter_link(ctx->inputs[0]);
264  av_assert0(fffilter(ctx->filter)->activate == activate);
265  return l->hw_frames_ctx;
266 }
267 
269 {
270  av_assert0(fffilter(ctx->filter)->activate == activate);
271  return ctx->inputs[0]->ch_layout.nb_channels;
272 }
273 
275 {
276  AVChannelLayout ch_layout = { 0 };
277  int ret;
278 
279  av_assert0(fffilter(ctx->filter)->activate == activate);
280  ret = av_channel_layout_copy(&ch_layout, &ctx->inputs[0]->ch_layout);
281  if (ret < 0)
282  return ret;
283  *out = ch_layout;
284  return 0;
285 }
286 
288  int *nb_side_data)
289 {
290  av_assert0(fffilter(ctx->filter)->activate == activate);
291  *nb_side_data = ctx->inputs[0]->nb_side_data;
292  return (const AVFrameSideData *const *)ctx->inputs[0]->side_data;
293 }
294 
296  AVFilterFormatsConfig **cfg_in,
297  AVFilterFormatsConfig **cfg_out)
298 {
299  const BufferSinkContext *buf = ctx->priv;
300  int ret;
301 
302  if (buf->nb_pixel_formats) {
303  ret = ff_set_pixel_formats_from_list2(ctx, cfg_in, cfg_out, buf->pixel_formats);
304  if (ret < 0)
305  return ret;
306  }
307  if (buf->nb_colorspaces) {
308  ret = ff_set_common_color_spaces_from_list2(ctx, cfg_in, cfg_out, buf->colorspaces);
309  if (ret < 0)
310  return ret;
311  }
312  if (buf->nb_colorranges) {
313  ret = ff_set_common_color_ranges_from_list2(ctx, cfg_in, cfg_out, buf->colorranges);
314  if (ret < 0)
315  return ret;
316  }
317  if (buf->nb_alphamodes) {
318  ret = ff_set_common_alpha_modes_from_list2(ctx, cfg_in, cfg_out, buf->alphamodes);
319  if (ret < 0)
320  return ret;
321  }
322 
323  return 0;
324 }
325 
327  AVFilterFormatsConfig **cfg_in,
328  AVFilterFormatsConfig **cfg_out)
329 {
330  const BufferSinkContext *buf = ctx->priv;
331  int ret;
332 
333  if (buf->nb_sample_formats) {
334  ret = ff_set_sample_formats_from_list2(ctx, cfg_in, cfg_out, buf->sample_formats);
335  if (ret < 0)
336  return ret;
337  }
338  if (buf->nb_samplerates) {
339  ret = ff_set_common_samplerates_from_list2(ctx, cfg_in, cfg_out, buf->samplerates);
340  if (ret < 0)
341  return ret;
342  }
343  if (buf->nb_channel_layouts) {
345  if (ret < 0)
346  return ret;
347  }
348 
349  return 0;
350 }
351 
352 #define OFFSET(x) offsetof(BufferSinkContext, x)
353 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
354 static const AVOption buffersink_options[] = {
355  { "pixel_formats", "array of supported pixel formats", OFFSET(pixel_formats),
356  AV_OPT_TYPE_PIXEL_FMT | AV_OPT_TYPE_FLAG_ARRAY, .max = INT_MAX, .flags = FLAGS },
357  { "colorspaces", "array of supported color spaces", OFFSET(colorspaces),
358  AV_OPT_TYPE_INT | AV_OPT_TYPE_FLAG_ARRAY, .max = INT_MAX, .flags = FLAGS },
359  { "colorranges", "array of supported color ranges", OFFSET(colorranges),
360  AV_OPT_TYPE_INT | AV_OPT_TYPE_FLAG_ARRAY, .max = INT_MAX, .flags = FLAGS },
361  { "alphamodes", "array of supported color ranges", OFFSET(alphamodes),
362  AV_OPT_TYPE_INT | AV_OPT_TYPE_FLAG_ARRAY, .max = INT_MAX, .flags = FLAGS },
363 
364  { NULL },
365 };
366 #undef FLAGS
367 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_AUDIO_PARAM
368 static const AVOption abuffersink_options[] = {
369  { "sample_formats", "array of supported sample formats", OFFSET(sample_formats),
370  AV_OPT_TYPE_SAMPLE_FMT | AV_OPT_TYPE_FLAG_ARRAY, .max = INT_MAX, .flags = FLAGS },
371  { "samplerates", "array of supported sample formats", OFFSET(samplerates),
372  AV_OPT_TYPE_INT | AV_OPT_TYPE_FLAG_ARRAY, .max = INT_MAX, .flags = FLAGS },
373  { "channel_layouts", "array of supported channel layouts", OFFSET(channel_layouts),
375  { NULL },
376 };
377 #undef FLAGS
378 
379 AVFILTER_DEFINE_CLASS(buffersink);
380 AVFILTER_DEFINE_CLASS(abuffersink);
381 
383  .p.name = "buffersink",
384  .p.description = NULL_IF_CONFIG_SMALL("Buffer video frames, and make them available to the end of the filter graph."),
385  .p.priv_class = &buffersink_class,
386  .p.outputs = NULL,
387  .priv_size = sizeof(BufferSinkContext),
388  .init = init_video,
389  .uninit = uninit,
390  .activate = activate,
393 };
394 
395 static const AVFilterPad inputs_audio[] = {
396  {
397  .name = "default",
398  .type = AVMEDIA_TYPE_AUDIO,
399  .config_props = config_input_audio,
400  },
401 };
402 
404  .p.name = "abuffersink",
405  .p.description = NULL_IF_CONFIG_SMALL("Buffer audio frames, and make them available to the end of the filter graph."),
406  .p.priv_class = &abuffersink_class,
407  .p.outputs = NULL,
408  .priv_size = sizeof(BufferSinkContext),
409  .init = init_audio,
410  .uninit = uninit,
411  .activate = activate,
414 };
flags
const SwsFlags flags[]
Definition: swscale.c:85
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:1616
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:216
av_buffersink_get_ch_layout
int av_buffersink_get_ch_layout(const AVFilterContext *ctx, AVChannelLayout *out)
Definition: buffersink.c:274
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:141
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
ff_link_internal
static FilterLinkInternal * ff_link_internal(AVFilterLink *link)
Definition: avfilter_internal.h:94
abuffersink_options
static const AVOption abuffersink_options[]
Definition: buffersink.c:368
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
AV_OPT_TYPE_SAMPLE_FMT
@ AV_OPT_TYPE_SAMPLE_FMT
Underlying C type is enum AVSampleFormat.
Definition: opt.h:310
out
static FILE * out
Definition: movenc.c:55
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:135
uninit
static void uninit(AVFilterContext *ctx)
Definition: buffersink.c:189
av_cold
#define av_cold
Definition: attributes.h:119
int64_t
long long int64_t
Definition: coverity.c:34
TERMINATE_ARRAY
#define TERMINATE_ARRAY(arr, val)
Definition: buffersink.c:155
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:64
ff_set_pixel_formats_from_list2
int ff_set_pixel_formats_from_list2(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out, const enum AVPixelFormat *fmts)
Definition: formats.c:1162
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:466
AVOption
AVOption.
Definition: opt.h:428
filters.h
ff_asink_abuffer
const FFFilter ff_asink_abuffer
Definition: buffersink.c:403
ff_set_common_channel_layouts_from_list2
int ff_set_common_channel_layouts_from_list2(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out, const AVChannelLayout *fmts)
Definition: formats.c:1026
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:219
av_buffersink_get_hw_frames_ctx
AVBufferRef * av_buffersink_get_hw_frames_ctx(const AVFilterContext *ctx)
Definition: buffersink.c:261
video.h
ff_set_common_color_ranges_from_list2
int ff_set_common_color_ranges_from_list2(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out, const int *color_ranges)
Definition: formats.c:1098
inputs_audio
static const AVFilterPad inputs_audio[]
Definition: buffersink.c:395
FilterLinkInternal
Definition: avfilter_internal.h:35
BufferSinkContext::sample_formats
enum AVSampleFormat * sample_formats
Definition: buffersink.c:62
formats.h
ff_inlink_consume_frame
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
Definition: avfilter.c:1516
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:224
init_video
static int init_video(AVFilterContext *ctx)
Definition: buffersink.c:164
BufferSinkContext::samplerates
int * samplerates
Definition: buffersink.c:65
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:649
FILTER_QUERY_FUNC2
#define FILTER_QUERY_FUNC2(func)
Definition: filters.h:241
AVFilterPad
A filter pad used for either input or output.
Definition: filters.h:40
avassert.h
ff_video_default_filterpad
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
Definition: video.c:37
FFFilter
Definition: filters.h:267
av_buffersink_get_frame_rate
AVRational av_buffersink_get_frame_rate(const AVFilterContext *ctx)
Definition: buffersink.c:254
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:85
ff_inlink_request_frame
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
Definition: avfilter.c:1619
s
#define s(width, name)
Definition: cbs_vp9.c:198
return_or_keep_frame
static int return_or_keep_frame(BufferSinkContext *buf, AVFrame *out, AVFrame *in, int flags)
Definition: buffersink.c:79
ff_filter_link
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition: filters.h:199
frame_size
int frame_size
Definition: mxfenc.c:2489
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:201
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:74
fffilter
static const FFFilter * fffilter(const AVFilter *f)
Definition: filters.h:464
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:42
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(buffersink)
ff_set_common_samplerates_from_list2
int ff_set_common_samplerates_from_list2(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out, const int *samplerates)
Definition: formats.c:1050
ctx
static AVFormatContext * ctx
Definition: movenc.c:49
pixel_formats
static enum AVPixelFormat pixel_formats[]
Definition: vf_sr.c:64
color_range
color_range
Definition: vf_selectivecolor.c:43
BufferSinkContext::alphamodes
int * alphamodes
Definition: buffersink.c:58
FLAGS
#define FLAGS
Definition: buffersink.c:367
ff_vsink_buffer
const FFFilter ff_vsink_buffer
Definition: buffersink.c:382
BufferSinkContext::pixel_formats
enum AVPixelFormat * pixel_formats
Definition: buffersink.c:49
ff_set_common_color_spaces_from_list2
int ff_set_common_color_spaces_from_list2(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out, const int *color_spaces)
Definition: formats.c:1074
activate
static int activate(AVFilterContext *ctx)
Definition: buffersink.c:196
FFFilter::activate
int(* activate)(AVFilterContext *ctx)
Filter activation function.
Definition: filters.h:461
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:76
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:1536
NULL
#define NULL
Definition: coverity.c:32
format
New swscale design to change SwsGraph is what coordinates multiple passes These can include cascaded scaling error diffusion and so on Or we could have separate passes for the vertical and horizontal scaling In between each SwsPass lies a fully allocated image buffer Graph passes may have different levels of e g we can have a single threaded error diffusion pass following a multi threaded scaling pass SwsGraph is internally recreated whenever the image format
Definition: swscale-v2.txt:14
framequeue.h
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
avfilter_internal.h
BufferSinkContext::colorranges
int * colorranges
Definition: buffersink.c:55
AV_OPT_TYPE_CHLAYOUT
@ AV_OPT_TYPE_CHLAYOUT
Underlying C type is AVChannelLayout.
Definition: opt.h:330
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:1463
buffersink_options
static const AVOption buffersink_options[]
Definition: buffersink.c:354
AVFilterFormatsConfig
Lists of formats / etc.
Definition: avfilter.h:120
BufferSinkContext::colorspaces
int * colorspaces
Definition: buffersink.c:52
BufferSinkContext::nb_samplerates
unsigned nb_samplerates
Definition: buffersink.c:66
attribute_align_arg
#define attribute_align_arg
Definition: internal.h:50
AVAlphaMode
AVAlphaMode
Correlation between the alpha channel and color values.
Definition: pixfmt.h:810
BufferSinkContext::nb_sample_formats
unsigned nb_sample_formats
Definition: buffersink.c:63
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:579
AVMediaType
AVMediaType
Definition: avutil.h:198
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:88
BufferSinkContext::frame_size
unsigned frame_size
Definition: buffersink.c:46
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:278
AVChannelLayout
An AVChannelLayout holds information about the channel layout of audio data.
Definition: channel_layout.h:319
AV_OPT_TYPE_FLAG_ARRAY
@ AV_OPT_TYPE_FLAG_ARRAY
May be combined with another regular option type to declare an array option.
Definition: opt.h:345
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:56
BufferSinkContext::nb_channel_layouts
unsigned nb_channel_layouts
Definition: buffersink.c:69
config_input_audio
static int config_input_audio(AVFilterLink *inlink)
Definition: buffersink.c:214
common_init
static av_cold int common_init(AVFilterContext *ctx)
Definition: buffersink.c:147
buffersink.h
av_buffersink_get_side_data
const AVFrameSideData *const * av_buffersink_get_side_data(const AVFilterContext *ctx, int *nb_side_data)
Definition: buffersink.c:287
ff_set_common_alpha_modes_from_list2
int ff_set_common_alpha_modes_from_list2(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out, const int *alpha_modes)
Definition: formats.c:1122
BufferSinkContext::nb_colorspaces
unsigned nb_colorspaces
Definition: buffersink.c:53
internal.h
AVColorSpace
AVColorSpace
YUV colorspace type.
Definition: pixfmt.h:700
common.h
av_assert1
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:58
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
FilterLinkInternal::frame_wanted_out
int frame_wanted_out
True if a frame is currently wanted on the output of this filter.
Definition: avfilter_internal.h:79
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:523
BufferSinkContext::nb_alphamodes
unsigned nb_alphamodes
Definition: buffersink.c:59
BufferSinkContext
Definition: buffersink.c:43
BufferSinkContext::nb_pixel_formats
unsigned nb_pixel_formats
Definition: buffersink.c:50
init_audio
static int init_audio(AVFilterContext *ctx)
Definition: buffersink.c:176
AVFilterPad::name
const char * name
Pad name.
Definition: filters.h:46
OFFSET
#define OFFSET(x)
Definition: buffersink.c:352
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:92
ret
ret
Definition: filter_design.txt:187
BufferSinkContext::warning_limit
unsigned warning_limit
Definition: buffersink.c:45
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:265
ff_set_sample_formats_from_list2
int ff_set_sample_formats_from_list2(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out, const enum AVSampleFormat *fmts)
Definition: formats.c:1154
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:264
ff_framequeue_queued_frames
static size_t ff_framequeue_queued_frames(const FFFrameQueue *fq)
Get the number of queued frames.
Definition: framequeue.h:158
sample_formats
static const struct @212 sample_formats[]
status
ov_status_e status
Definition: dnn_backend_openvino.c:100
channel_layout.h
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
asink_query_formats
static int asink_query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition: buffersink.c:326
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:258
avfilter.h
av_buffersink_get_channels
int av_buffersink_get_channels(const AVFilterContext *ctx)
Definition: buffersink.c:268
samples
Filter the word “frame” indicates either a video frame or a group of audio samples
Definition: filter_design.txt:8
AV_OPT_TYPE_PIXEL_FMT
@ AV_OPT_TYPE_PIXEL_FMT
Underlying C type is enum AVPixelFormat.
Definition: opt.h:306
AVFilterContext
An instance of a filter.
Definition: avfilter.h:273
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:450
get_frame_internal
static int get_frame_internal(AVFilterContext *ctx, AVFrame *frame, int flags, int samples)
Definition: buffersink.c:93
FFFilter::p
AVFilter p
The public AVFilter.
Definition: filters.h:271
mem.h
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:235
AVFrameSideData
Structure to hold side data for an AVFrame.
Definition: frame.h:321
w
uint8_t w
Definition: llvidencdsp.c:39
channel_layouts
static const uint16_t channel_layouts[7]
Definition: dca_lbr.c:112
AVFormatContext::name
char * name
Name of this format context, only used for logging purposes.
Definition: avformat.h:1944
BufferSinkContext::peeked_frame
AVFrame * peeked_frame
Definition: buffersink.c:71
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
BufferSinkContext::nb_colorranges
unsigned nb_colorranges
Definition: buffersink.c:56
h
h
Definition: vp9dsp_template.c:2070
FilterLinkInternal::fifo
FFFrameQueue fifo
Queue of frames waiting to be filtered.
Definition: avfilter_internal.h:46
avstring.h
vsink_query_formats
static int vsink_query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition: buffersink.c:295
AVColorRange
AVColorRange
Visual content value range.
Definition: pixfmt.h:742
BufferSinkContext::channel_layouts
AVChannelLayout * channel_layouts
Definition: buffersink.c:68
FFERROR_BUFFERSRC_EMPTY
#define FFERROR_BUFFERSRC_EMPTY
Definition: filters.h:35
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:311