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

Go to the source code of this file.

Data Structures

struct  BufferSinkContext
 

Macros

#define TERMINATE_ARRAY(arr, val)
 
#define MAKE_AVFILTERLINK_ACCESSOR(type, 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

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...
 
static av_cold int common_init (AVFilterContext *ctx)
 
static int init_video (AVFilterContext *ctx)
 
static int init_audio (AVFilterContext *ctx)
 
static void uninit (AVFilterContext *ctx)
 
static int activate (AVFilterContext *ctx)
 
static int config_input_audio (AVFilterLink *inlink)
 
void av_buffersink_set_frame_size (AVFilterContext *ctx, unsigned frame_size)
 Set the frame size for an audio buffer sink. More...
 
AVRational av_buffersink_get_frame_rate (const AVFilterContext *ctx)
 
AVBufferRefav_buffersink_get_hw_frames_ctx (const AVFilterContext *ctx)
 
int av_buffersink_get_channels (const AVFilterContext *ctx)
 
int av_buffersink_get_ch_layout (const AVFilterContext *ctx, AVChannelLayout *out)
 
static int vsink_query_formats (const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
 
static int asink_query_formats (const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
 
 AVFILTER_DEFINE_CLASS (buffersink)
 
 AVFILTER_DEFINE_CLASS (abuffersink)
 

Variables

static const AVOption buffersink_options []
 
static const AVOption abuffersink_options []
 
const AVFilter ff_vsink_buffer
 
static const AVFilterPad inputs_audio []
 
const AVFilter ff_asink_abuffer
 

Detailed Description

buffer sink

Definition in file buffersink.c.

Macro Definition Documentation

◆ TERMINATE_ARRAY

#define TERMINATE_ARRAY (   arr,
  val 
)
Value:
if (s->arr) { \
void *tmp = av_realloc_array(s->arr, s->nb_ ## arr + 1, sizeof(*s->arr)); \
if (!tmp) \
return AVERROR(ENOMEM); \
s->arr = tmp; \
s->arr[s->nb_ ## arr] = val; \
}

Definition at line 236 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 315 of file buffersink.c.

◆ OFFSET

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

Definition at line 488 of file buffersink.c.

◆ FLAGS [1/2]

Definition at line 507 of file buffersink.c.

◆ FLAGS [2/2]

Definition at line 507 of file buffersink.c.

Function Documentation

◆ return_or_keep_frame()

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

Definition at line 94 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 108 of file buffersink.c.

Referenced by av_buffersink_get_frame_flags(), and av_buffersink_get_samples().

◆ common_init()

static av_cold int common_init ( AVFilterContext ctx)
static

Definition at line 154 of file buffersink.c.

Referenced by init_audio(), and init_video().

◆ init_video()

static int init_video ( AVFilterContext ctx)
static

Definition at line 245 of file buffersink.c.

◆ init_audio()

static int init_audio ( AVFilterContext ctx)
static

Definition at line 256 of file buffersink.c.

◆ uninit()

static void uninit ( AVFilterContext ctx)
static

Definition at line 269 of file buffersink.c.

◆ activate()

static int activate ( AVFilterContext ctx)
static

◆ config_input_audio()

static int config_input_audio ( AVFilterLink inlink)
static

Definition at line 294 of file buffersink.c.

◆ vsink_query_formats()

static int vsink_query_formats ( const AVFilterContext ctx,
AVFilterFormatsConfig **  cfg_in,
AVFilterFormatsConfig **  cfg_out 
)
static

Definition at line 370 of file buffersink.c.

◆ asink_query_formats()

static int asink_query_formats ( const AVFilterContext ctx,
AVFilterFormatsConfig **  cfg_in,
AVFilterFormatsConfig **  cfg_out 
)
static

Definition at line 430 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:
= {
{ "pixel_formats", "array of supported pixel formats", OFFSET(pixel_formats),
AV_OPT_TYPE_PIXEL_FMT | AV_OPT_TYPE_FLAG_ARRAY, .max = INT_MAX, .flags = FLAGS },
{ "colorspaces", "array of supported color spaces", OFFSET(colorspaces),
AV_OPT_TYPE_INT | AV_OPT_TYPE_FLAG_ARRAY, .max = INT_MAX, .flags = FLAGS },
{ "colorranges", "array of supported color ranges", OFFSET(colorranges),
AV_OPT_TYPE_INT | AV_OPT_TYPE_FLAG_ARRAY, .max = INT_MAX, .flags = FLAGS },
{ NULL },
}

Definition at line 490 of file buffersink.c.

◆ abuffersink_options

const AVOption abuffersink_options[]
static
Initial value:
= {
{ "sample_formats", "array of supported sample formats", OFFSET(sample_formats),
AV_OPT_TYPE_SAMPLE_FMT | AV_OPT_TYPE_FLAG_ARRAY, .max = INT_MAX, .flags = FLAGS },
{ "samplerates", "array of supported sample formats", OFFSET(samplerates),
AV_OPT_TYPE_INT | AV_OPT_TYPE_FLAG_ARRAY, .max = INT_MAX, .flags = FLAGS },
{ "channel_layouts", "array of supported channel layouts", OFFSET(channel_layouts),
{ NULL },
}

Definition at line 508 of file buffersink.c.

◆ ff_vsink_buffer

const 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,
.outputs = NULL,
}

Definition at line 530 of file buffersink.c.

◆ inputs_audio

const AVFilterPad inputs_audio[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_input_audio,
},
}

Definition at line 543 of file buffersink.c.

◆ ff_asink_abuffer

const 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),
.outputs = NULL,
}

Definition at line 551 of file buffersink.c.

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
AV_OPT_TYPE_SAMPLE_FMT
@ AV_OPT_TYPE_SAMPLE_FMT
Underlying C type is enum AVSampleFormat.
Definition: opt.h:311
uninit
static void uninit(AVFilterContext *ctx)
Definition: buffersink.c:269
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:28
inputs_audio
static const AVFilterPad inputs_audio[]
Definition: buffersink.c:543
init_video
static int init_video(AVFilterContext *ctx)
Definition: buffersink.c:245
val
static double val(void *priv, double ch)
Definition: aeval.c:77
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
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
s
#define s(width, name)
Definition: cbs_vp9.c:198
av_realloc_array
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Definition: mem.c:217
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
ctx
AVFormatContext * ctx
Definition: movenc.c:49
pixel_formats
static enum AVPixelFormat pixel_formats[]
Definition: vf_sr.c:64
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:507
activate
static int activate(AVFilterContext *ctx)
Definition: buffersink.c:276
NULL
#define NULL
Definition: coverity.c:32
AV_OPT_TYPE_CHLAYOUT
@ AV_OPT_TYPE_CHLAYOUT
Underlying C type is AVChannelLayout.
Definition: opt.h:331
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
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:94
sample_formats
static const struct @173 sample_formats[]
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:346
config_input_audio
static int config_input_audio(AVFilterLink *inlink)
Definition: buffersink.c:294
FILTER_QUERY_FUNC2
#define FILTER_QUERY_FUNC2(func)
Definition: filters.h:239
BufferSinkContext
Definition: buffersink.c:43
init_audio
static int init_audio(AVFilterContext *ctx)
Definition: buffersink.c:256
OFFSET
#define OFFSET(x)
Definition: buffersink.c:488
asink_query_formats
static int asink_query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition: buffersink.c:430
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
AV_OPT_TYPE_PIXEL_FMT
@ AV_OPT_TYPE_PIXEL_FMT
Underlying C type is enum AVPixelFormat.
Definition: opt.h:307
AVFilterContext
An instance of a filter.
Definition: avfilter.h:457
channel_layouts
static const uint16_t channel_layouts[7]
Definition: dca_lbr.c:112
vsink_query_formats
static int vsink_query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition: buffersink.c:370