FFmpeg
Data Structures | Macros | Functions | Variables
buffersink.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
#include "libavutil/internal.h"
#include "libavutil/opt.h"
#include "framequeue.h"
#include "audio.h"
#include "avfilter.h"
#include "buffersink.h"
#include "filters.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  BufferSinkContext
 

Macros

#define FF_INTERNAL_FIELDS   1
 
#define NB_ITEMS(list)   (list ## _size / sizeof(*list))
 
#define MAKE_AVFILTERLINK_ACCESSOR(type, field)
 
#define CHECK_LIST_SIZE(field)
 
#define OFFSET(x)   offsetof(BufferSinkContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_AUDIO_PARAM
 

Functions

static void cleanup_redundant_layouts (AVFilterContext *ctx)
 
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. More...
 
static int return_or_keep_frame (BufferSinkContext *buf, AVFrame *out, AVFrame *in, int flags)
 
static int get_frame_internal (AVFilterContext *ctx, AVFrame *frame, int flags, int samples)
 
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. More...
 
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. More...
 
AVBufferSinkParams * av_buffersink_params_alloc (void)
 
AVABufferSinkParams * av_abuffersink_params_alloc (void)
 
static av_cold int common_init (AVFilterContext *ctx)
 
static int activate (AVFilterContext *ctx)
 
void av_buffersink_set_frame_size (AVFilterContext *ctx, unsigned frame_size)
 Set the frame size for an audio buffer sink. More...
 
static int vsink_query_formats (AVFilterContext *ctx)
 
static int asink_query_formats (AVFilterContext *ctx)
 
 AVFILTER_DEFINE_CLASS (buffersink)
 
 AVFILTER_DEFINE_CLASS (abuffersink)
 

Variables

static const AVOption buffersink_options []
 
static const AVOption abuffersink_options []
 
static const AVFilterPad avfilter_vsink_buffer_inputs []
 
AVFilter ff_vsink_buffer
 
static const AVFilterPad avfilter_asink_abuffer_inputs []
 
AVFilter ff_asink_abuffer
 

Detailed Description

buffer sink

Definition in file buffersink.c.

Macro Definition Documentation

◆ FF_INTERNAL_FIELDS

#define FF_INTERNAL_FIELDS   1

Definition at line 32 of file buffersink.c.

◆ NB_ITEMS

#define NB_ITEMS (   list)    (list ## _size / sizeof(*list))

Definition at line 63 of file buffersink.c.

◆ MAKE_AVFILTERLINK_ACCESSOR

#define MAKE_AVFILTERLINK_ACCESSOR (   type,
  field 
)
Value:
type av_buffersink_get_##field(const AVFilterContext *ctx) { \
av_assert0(ctx->filter->activate == activate); \
return ctx->inputs[0]->field; \
}

Definition at line 206 of file buffersink.c.

◆ CHECK_LIST_SIZE

#define CHECK_LIST_SIZE (   field)
Value:
if (buf->field ## _size % sizeof(*buf->field)) { \
av_log(ctx, AV_LOG_ERROR, "Invalid size for " #field ": %d, " \
"should be multiple of %d\n", \
buf->field ## _size, (int)sizeof(*buf->field)); \
return AVERROR(EINVAL); \
}

Definition at line 227 of file buffersink.c.

◆ OFFSET

#define OFFSET (   x)    offsetof(BufferSinkContext, x)

Definition at line 309 of file buffersink.c.

◆ FLAGS [1/2]

Definition at line 316 of file buffersink.c.

◆ FLAGS [2/2]

Definition at line 316 of file buffersink.c.

Function Documentation

◆ cleanup_redundant_layouts()

static void cleanup_redundant_layouts ( AVFilterContext ctx)
static

Definition at line 65 of file buffersink.c.

Referenced by asink_query_formats().

◆ return_or_keep_frame()

static int return_or_keep_frame ( BufferSinkContext buf,
AVFrame out,
AVFrame in,
int  flags 
)
static

Definition at line 93 of file buffersink.c.

Referenced by get_frame_internal().

◆ get_frame_internal()

static int get_frame_internal ( AVFilterContext ctx,
AVFrame frame,
int  flags,
int  samples 
)
static

Definition at line 107 of file buffersink.c.

Referenced by av_buffersink_get_frame_flags(), and av_buffersink_get_samples().

◆ av_buffersink_params_alloc()

AVBufferSinkParams* av_buffersink_params_alloc ( void  )

Definition at line 152 of file buffersink.c.

◆ av_abuffersink_params_alloc()

AVABufferSinkParams* av_abuffersink_params_alloc ( void  )

Definition at line 163 of file buffersink.c.

◆ common_init()

static av_cold int common_init ( AVFilterContext ctx)
static

Definition at line 173 of file buffersink.c.

◆ activate()

static int activate ( AVFilterContext ctx)
static

Definition at line 181 of file buffersink.c.

◆ vsink_query_formats()

static int vsink_query_formats ( AVFilterContext ctx)
static

Definition at line 234 of file buffersink.c.

◆ asink_query_formats()

static int asink_query_formats ( AVFilterContext ctx)
static

Definition at line 256 of file buffersink.c.

◆ AVFILTER_DEFINE_CLASS() [1/2]

AVFILTER_DEFINE_CLASS ( buffersink  )

◆ AVFILTER_DEFINE_CLASS() [2/2]

AVFILTER_DEFINE_CLASS ( abuffersink  )

Variable Documentation

◆ buffersink_options

const AVOption buffersink_options[]
static
Initial value:
= {
{ "pix_fmts", "set the supported pixel formats", OFFSET(pixel_fmts), AV_OPT_TYPE_BINARY, .flags = FLAGS },
{ NULL },
}

Definition at line 311 of file buffersink.c.

◆ abuffersink_options

const AVOption abuffersink_options[]
static
Initial value:
= {
{ "sample_fmts", "set the supported sample formats", OFFSET(sample_fmts), AV_OPT_TYPE_BINARY, .flags = FLAGS },
{ "sample_rates", "set the supported sample rates", OFFSET(sample_rates), AV_OPT_TYPE_BINARY, .flags = FLAGS },
{ "channel_layouts", "set the supported channel layouts", OFFSET(channel_layouts), AV_OPT_TYPE_BINARY, .flags = FLAGS },
{ "channel_counts", "set the supported channel counts", OFFSET(channel_counts), AV_OPT_TYPE_BINARY, .flags = FLAGS },
{ "all_channel_counts", "accept all channel counts", OFFSET(all_channel_counts), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS },
{ NULL },
}

Definition at line 317 of file buffersink.c.

◆ avfilter_vsink_buffer_inputs

const AVFilterPad avfilter_vsink_buffer_inputs[]
static
Initial value:
= {
{
.name = "default",
},
{ NULL }
}

Definition at line 330 of file buffersink.c.

◆ ff_vsink_buffer

AVFilter ff_vsink_buffer
Initial value:
= {
.name = "buffersink",
.description = NULL_IF_CONFIG_SMALL("Buffer video frames, and make them available to the end of the filter graph."),
.priv_size = sizeof(BufferSinkContext),
.priv_class = &buffersink_class,
}

Definition at line 338 of file buffersink.c.

◆ avfilter_asink_abuffer_inputs

const AVFilterPad avfilter_asink_abuffer_inputs[]
static
Initial value:
= {
{
.name = "default",
},
{ NULL }
}

Definition at line 350 of file buffersink.c.

◆ ff_asink_abuffer

AVFilter ff_asink_abuffer
Initial value:
= {
.name = "abuffersink",
.description = NULL_IF_CONFIG_SMALL("Buffer audio frames, and make them available to the end of the filter graph."),
.priv_class = &abuffersink_class,
.priv_size = sizeof(BufferSinkContext),
}

Definition at line 358 of file buffersink.c.

avfilter_vsink_buffer_inputs
static const AVFilterPad avfilter_vsink_buffer_inputs[]
Definition: buffersink.c:330
init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:31
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
sample_fmts
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:925
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
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
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:194
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
ctx
AVFormatContext * ctx
Definition: movenc.c:48
field
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 field
Definition: writing_filters.txt:78
FLAGS
#define FLAGS
Definition: buffersink.c:316
activate
static int activate(AVFilterContext *ctx)
Definition: buffersink.c:181
NULL
#define NULL
Definition: coverity.c:32
vsink_query_formats
static int vsink_query_formats(AVFilterContext *ctx)
Definition: buffersink.c:234
inputs
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 inputs
Definition: filter_design.txt:243
avfilter_asink_abuffer_inputs
static const AVFilterPad avfilter_asink_abuffer_inputs[]
Definition: buffersink.c:350
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
common_init
static av_cold int common_init(AVFilterContext *ctx)
Definition: buffersink.c:173
sample_rates
sample_rates
Definition: ffmpeg_filter.c:170
BufferSinkContext
Definition: buffersink.c:41
OFFSET
#define OFFSET(x)
Definition: buffersink.c:309
channel_counts
static const uint8_t channel_counts[7]
Definition: dca_lbr.c:110
AVFilterContext
An instance of a filter.
Definition: avfilter.h:341
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
asink_query_formats
static int asink_query_formats(AVFilterContext *ctx)
Definition: buffersink.c:256
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:242
channel_layouts
static const uint16_t channel_layouts[7]
Definition: dca_lbr.c:114
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: aeval.c:243