101 int buffersrc_empty = 0;
122 }
else if (ret ==
AVERROR(EAGAIN)) {
126 }
else if (ret < 0) {
155#define TERMINATE_ARRAY(arr, val) \
157 void *tmp = av_realloc_array(s->arr, s->nb_ ## arr + 1, sizeof(*s->arr)); \
159 return AVERROR(ENOMEM); \
161 s->arr[s->nb_ ## arr] = val; \
187#undef TERMINATE_ARRAY
204 "%d buffers queued in %s, something may be wrong.\n",
229 if (
ctx->inputs &&
ctx->inputs[0]) {
235#define MAKE_AVFILTERLINK_ACCESSOR(type, field) \
236type av_buffersink_get_##field(const AVFilterContext *ctx) { \
237 av_assert0(fffilter(ctx->filter)->activate == activate); \
238 return ctx->inputs[0]->field; \
271 return ctx->inputs[0]->ch_layout.nb_channels;
291 *nb_side_data =
ctx->inputs[0]->nb_side_data;
352#define OFFSET(x) offsetof(BufferSinkContext, x)
353#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
357 {
"colorspaces",
"array of supported color spaces",
OFFSET(colorspaces),
359 {
"colorranges",
"array of supported color ranges",
OFFSET(colorranges),
361 {
"alphamodes",
"array of supported color ranges",
OFFSET(alphamodes),
367#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_AUDIO_PARAM
371 {
"samplerates",
"array of supported sample formats",
OFFSET(samplerates),
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,
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,
static const char *const format[]
const FFFilter ff_vsink_buffer
const FFFilter ff_asink_abuffer
static AVFormatContext * ctx
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
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.
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
Main libavfilter public API header.
int ff_filter_graph_run_once(AVFilterGraph *graph)
Run one round of processing on a filter graph.
static BitStreamFilterLinkInternal * ff_link_internal(AVBitStreamFilterLink *link)
static const AVOption abuffersink_options[]
static const AVOption buffersink_options[]
static const AVFilterPad inputs_audio[]
#define TERMINATE_ARRAY(arr, val)
#define MAKE_AVFILTERLINK_ACCESSOR(type, field)
static av_cold int common_init(AVFilterContext *ctx)
static int get_frame_internal(AVFilterContext *ctx, AVFrame *frame, int flags, int samples)
static int asink_query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static int return_or_keep_frame(BufferSinkContext *buf, AVFrame *out, AVFrame *in, int flags)
static void uninit(AVFilterContext *ctx)
static int vsink_query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static int config_input_audio(AVFilterLink *inlink)
static int init_audio(AVFilterContext *ctx)
static int activate(AVFilterContext *ctx)
static int init_video(AVFilterContext *ctx)
memory buffer sink API for audio and video
#define flags(name, subs,...)
Public libavutil channel layout APIs header.
common internal and external API header
static const uint16_t channel_layouts[7]
int(* init)(AVBSFContext *ctx)
static size_t ff_framequeue_queued_frames(const FFFrameQueue *fq)
Get the number of queued frames.
static const uint8_t frame_size[4]
@ AV_OPT_TYPE_PIXEL_FMT
Underlying C type is enum AVPixelFormat.
@ AV_OPT_TYPE_FLAG_ARRAY
May be combined with another regular option type to declare an array option.
@ AV_OPT_TYPE_SAMPLE_FMT
Underlying C type is enum AVSampleFormat.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_CHLAYOUT
Underlying C type is AVChannelLayout.
AVBufferRef * av_buffersink_get_hw_frames_ctx(const AVFilterContext *ctx)
AVRational av_buffersink_get_frame_rate(const AVFilterContext *ctx)
const AVFrameSideData *const * av_buffersink_get_side_data(const AVFilterContext *ctx, int *nb_side_data)
int av_buffersink_get_ch_layout(const AVFilterContext *ctx, AVChannelLayout *out)
int av_buffersink_get_channels(const AVFilterContext *ctx)
void av_buffersink_set_frame_size(AVFilterContext *ctx, unsigned frame_size)
Set the frame size for an audio buffer sink.
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.
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.
#define AV_BUFFERSINK_FLAG_PEEK
Tell av_buffersink_get_buffer_ref() to read video/samples buffer reference, but not remove it from th...
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.
#define AV_BUFFERSINK_FLAG_NO_REQUEST
Tell av_buffersink_get_buffer_ref() not to request a frame from its input.
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define AV_LOG_WARNING
Something somehow does not look correct.
static void * av_x_if_null(const void *p, const void *x)
Return x default pointer in case p is NULL.
AVSampleFormat
Audio sample formats.
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
#define FFERROR_BUFFERSRC_EMPTY
static FilterLink * ff_filter_link(AVFilterLink *link)
#define AVFILTER_DEFINE_CLASS(fname)
#define FILTER_QUERY_FUNC2(func)
static const FFFilter * fffilter(const AVFilter *f)
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define attribute_align_arg
Memory handling functions.
AVColorRange
Visual content value range.
AVAlphaMode
Correlation between the alpha channel and color values.
AVPixelFormat
Pixel format.
AVColorSpace
YUV colorspace type.
A reference to a data buffer.
An AVChannelLayout holds information about the channel layout of audio data.
void * priv
private data for use by the filter
A link between two filters.
AVFilterContext * dst
dest filter
A filter pad used for either input or output.
Structure to hold side data for an AVFrame.
This structure describes decoded (raw) audio or video data.
Rational number (pair of numerator and denominator).
unsigned nb_sample_formats
AVChannelLayout * channel_layouts
unsigned nb_pixel_formats
unsigned nb_channel_layouts
enum AVSampleFormat * sample_formats
enum AVPixelFormat * pixel_formats
int(* activate)(AVFilterContext *ctx)
Filter activation function.
int frame_wanted_out
True if a frame is currently wanted on the output of this filter.
FFFrameQueue fifo
Queue of frames waiting to be filtered.
Link properties exposed to filter code, but not external callers.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable.
AVBufferRef * hw_frames_ctx
For hwaccel pixel formats, this should be a reference to the AVHWFramesContext describing the frames.
int min_samples
Minimum number of samples to filter at once.
int max_samples
Maximum number of samples to filter at once.
static enum AVPixelFormat pixel_formats[]
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.