FFmpeg
Loading...
Searching...
No Matches
buffersrc.c File Reference

memory buffer source filter More...

#include <float.h>
#include "libavutil/channel_layout.h"
#include "libavutil/frame.h"
#include "libavutil/hwcontext.h"
#include "libavutil/internal.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/samplefmt.h"
#include "libavutil/timestamp.h"
#include "avfilter.h"
#include "avfilter_internal.h"
#include "buffersrc.h"
#include "filters.h"
#include "formats.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  BufferSourceContext
 

Macros

#define CHECK_VIDEO_PARAM_CHANGE(s, c, width, height, format, csp, range, alpha, pts)
 
#define CHECK_AUDIO_PARAM_CHANGE(s, c, srate, layout, format, pts)
 
#define OFFSET(x)
 
#define A   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_AUDIO_PARAM
 
#define V   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 

Functions

AVBufferSrcParametersav_buffersrc_parameters_alloc (void)
 Allocate a new AVBufferSrcParameters instance.
 
int av_buffersrc_parameters_set (AVFilterContext *ctx, AVBufferSrcParameters *param)
 Initialize the buffersrc or abuffersrc filter with the provided parameters.
 
int attribute_align_arg av_buffersrc_write_frame (AVFilterContext *ctx, const AVFrame *frame)
 Add a frame to the buffer source.
 
int attribute_align_arg av_buffersrc_add_frame (AVFilterContext *ctx, AVFrame *frame)
 Add a frame to the buffer source.
 
static int push_frame (AVFilterGraph *graph)
 
int attribute_align_arg av_buffersrc_add_frame_flags (AVFilterContext *ctx, AVFrame *frame, int flags)
 Add a frame to the buffer source.
 
int av_buffersrc_close (AVFilterContext *ctx, int64_t pts, unsigned flags)
 Close the buffer source after EOF.
 
int av_buffersrc_get_status (AVFilterContext *ctx)
 Returns 0 or a negative AVERROR code.
 
static av_cold int common_init (AVFilterContext *ctx)
 
static av_cold int init_video (AVFilterContext *ctx)
 
unsigned av_buffersrc_get_nb_failed_requests (AVFilterContext *buffer_src)
 Get the number of failed requests.
 
 AVFILTER_DEFINE_CLASS (buffer)
 
 AVFILTER_DEFINE_CLASS (abuffer)
 
static av_cold int init_audio (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int query_formats (const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
 
static int config_props (AVFilterLink *link)
 
static int activate (AVFilterContext *ctx)
 

Variables

static const AVOption buffer_options []
 
static const AVOption abuffer_options []
 
static const AVFilterPad avfilter_vsrc_buffer_outputs []
 
const FFFilter ff_vsrc_buffer
 
static const AVFilterPad avfilter_asrc_abuffer_outputs []
 
const FFFilter ff_asrc_abuffer
 

Detailed Description

memory buffer source filter

Definition in file buffersrc.c.

Macro Definition Documentation

◆ CHECK_VIDEO_PARAM_CHANGE

#define CHECK_VIDEO_PARAM_CHANGE ( s,
c,
width,
height,
format,
csp,
range,
alpha,
pts )
Value:
c->link_delta = c->w != width || c->h != height || c->pix_fmt != format ||\
c->color_space != csp || c->color_range != range || c->alpha_mode != alpha;\
c->prev_delta = c->prev_w != width || c->prev_h != height || c->prev_pix_fmt != format ||\
c->prev_color_space != csp || c->prev_color_range != range || c->prev_alpha_mode != alpha;\
if (c->link_delta) {\
int loglevel = c->prev_delta ? AV_LOG_WARNING : AV_LOG_DEBUG;\
av_log(s, loglevel, "Changing video frame properties on the fly is not supported by all filters.\n");\
av_log(s, loglevel, "filter context - w: %d h: %d fmt: %d csp: %s range: %s alpha: %s, incoming frame - w: %d h: %d fmt: %d csp: %s range: %s alpha: %s pts_time: %s\n",\
c->w, c->h, c->pix_fmt, av_color_space_name(c->color_space), av_color_range_name(c->color_range), av_alpha_mode_name(c->alpha_mode),\
av_ts2timestr(pts, &s->outputs[0]->time_base));\
}\
if (c->prev_delta) {\
if (!c->link_delta)\
av_log(s, AV_LOG_VERBOSE, "video frame properties congruent with link at pts_time: %s\n", av_ts2timestr(pts, &s->outputs[0]->time_base));\
c->prev_w = width;\
c->prev_h = height;\
c->prev_pix_fmt = format;\
c->prev_color_space = csp;\
c->prev_color_range = range;\
c->prev_alpha_mode = alpha;\
}
static const char *const format[]
Definition af_aiir.c:444
#define s(width, name)
Definition cbs_vp9.c:198
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition log.h:231
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216
#define AV_LOG_VERBOSE
Detailed information.
Definition log.h:226
static const int16_t alpha[]
Definition ilbcdata.h:55
enum AVColorRange range
const char * av_color_space_name(enum AVColorSpace space)
Definition pixdesc.c:3860
const char * av_color_range_name(enum AVColorRange range)
Definition pixdesc.c:3776
const char * av_alpha_mode_name(enum AVAlphaMode mode)
Definition pixdesc.c:3925
#define height
Definition dsp.h:89
#define width
Definition dsp.h:89
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition timestamp.h:83
static int64_t pts
static double c[64]

Definition at line 74 of file buffersrc.c.

Referenced by av_buffersrc_add_frame_flags().

◆ CHECK_AUDIO_PARAM_CHANGE

#define CHECK_AUDIO_PARAM_CHANGE ( s,
c,
srate,
layout,
format,
pts )
Value:
if (c->sample_fmt != format || c->sample_rate != srate ||\
av_channel_layout_compare(&c->ch_layout, &layout) || c->channels != layout.nb_channels) {\
av_log(s, AV_LOG_INFO, "filter context - fmt: %s r: %d layout: %"PRIX64" ch: %d, incoming frame - fmt: %s r: %d layout: %"PRIX64" ch: %d pts_time: %s\n",\
av_get_sample_fmt_name(c->sample_fmt), c->sample_rate, c->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ? c->ch_layout.u.mask : 0, c->channels,\
av_get_sample_fmt_name(format), srate, layout.order == AV_CHANNEL_ORDER_NATIVE ? layout.u.mask : 0, layout.nb_channels, av_ts2timestr(pts, &s->outputs[0]->time_base));\
av_log(s, AV_LOG_ERROR, "Changing audio frame properties on the fly is not supported.\n");\
return AVERROR(EINVAL);\
}
int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1)
Check whether two channel layouts are semantically the same, i.e.
@ AV_CHANNEL_ORDER_NATIVE
The native channel order, i.e.
#define AVERROR(e)
Definition error.h:45
#define AV_LOG_INFO
Standard information.
Definition log.h:221
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
const char * av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
Definition samplefmt.c:51
uint64_t layout

Definition at line 98 of file buffersrc.c.

Referenced by av_buffersrc_add_frame_flags().

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 357 of file buffersrc.c.

◆ A

Definition at line 358 of file buffersrc.c.

◆ V

Definition at line 359 of file buffersrc.c.

Function Documentation

◆ push_frame()

static int push_frame ( AVFilterGraph * graph)
static

Definition at line 196 of file buffersrc.c.

Referenced by av_buffersrc_add_frame_flags(), and av_buffersrc_close().

◆ common_init()

static av_cold int common_init ( AVFilterContext * ctx)
static

Definition at line 310 of file buffersrc.c.

Referenced by init_audio(), and init_video().

◆ init_video()

static av_cold int init_video ( AVFilterContext * ctx)
static

Definition at line 318 of file buffersrc.c.

◆ AVFILTER_DEFINE_CLASS() [1/2]

AVFILTER_DEFINE_CLASS ( buffer )

◆ AVFILTER_DEFINE_CLASS() [2/2]

AVFILTER_DEFINE_CLASS ( abuffer )

◆ init_audio()

static av_cold int init_audio ( AVFilterContext * ctx)
static

Definition at line 418 of file buffersrc.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext * ctx)
static

Definition at line 468 of file buffersrc.c.

◆ query_formats()

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

Definition at line 476 of file buffersrc.c.

◆ config_props()

static int config_props ( AVFilterLink * link)
static

Definition at line 549 of file buffersrc.c.

◆ activate()

static int activate ( AVFilterContext * ctx)
static

Definition at line 593 of file buffersrc.c.

Variable Documentation

◆ buffer_options

const AVOption buffer_options[]
static

Definition at line 361 of file buffersrc.c.

◆ abuffer_options

const AVOption abuffer_options[]
static
Initial value:
= {
{ "time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, INT_MAX, A },
{ "sample_rate", NULL, OFFSET(sample_rate), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, A },
{ "sample_fmt", NULL, OFFSET(sample_fmt), AV_OPT_TYPE_SAMPLE_FMT, { .i64 = AV_SAMPLE_FMT_NONE }, .min = AV_SAMPLE_FMT_NONE, .max = INT_MAX, .flags = A },
{ "channel_layout", NULL, OFFSET(ch_layout), AV_OPT_TYPE_CHLAYOUT, .flags = A },
{ "channels", NULL, OFFSET(channels), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, A },
{ NULL },
}
channels
Definition aptx.h:31
#define A(x)
Definition vpx_arith.h:28
#define NULL
Definition coverity.c:32
#define OFFSET(x)
@ AV_OPT_TYPE_SAMPLE_FMT
Underlying C type is enum AVSampleFormat.
Definition opt.h:310
@ AV_OPT_TYPE_RATIONAL
Underlying C type is AVRational.
Definition opt.h:279
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_CHLAYOUT
Underlying C type is AVChannelLayout.
Definition opt.h:330
@ AV_SAMPLE_FMT_NONE
Definition samplefmt.h:56

Definition at line 407 of file buffersrc.c.

◆ avfilter_vsrc_buffer_outputs

const AVFilterPad avfilter_vsrc_buffer_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_props,
},
}
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
static int config_props(AVBitStreamFilterLink *link)
Definition source.c:181

Definition at line 611 of file buffersrc.c.

◆ ff_vsrc_buffer

const FFFilter ff_vsrc_buffer
Initial value:
= {
.p.name = "buffer",
.p.description = NULL_IF_CONFIG_SMALL("Buffer video frames, and make them accessible to the filterchain."),
.p.priv_class = &buffer_class,
.priv_size = sizeof(BufferSourceContext),
}
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition aeval.c:246
static int init_video(AVFilterContext *ctx)
Definition buffersink.c:164
static const AVFilterPad avfilter_vsrc_buffer_outputs[]
Definition buffersrc.c:611
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#define FILTER_QUERY_FUNC2(func)
Definition filters.h:241
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88

Definition at line 619 of file buffersrc.c.

◆ avfilter_asrc_abuffer_outputs

const AVFilterPad avfilter_asrc_abuffer_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_props,
},
}
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201

Definition at line 632 of file buffersrc.c.

◆ ff_asrc_abuffer

const FFFilter ff_asrc_abuffer
Initial value:
= {
.p.name = "abuffer",
.p.description = NULL_IF_CONFIG_SMALL("Buffer audio frames, and make them accessible to the filterchain."),
.p.priv_class = &abuffer_class,
.priv_size = sizeof(BufferSourceContext),
}
static int init_audio(AVFilterContext *ctx)
Definition buffersink.c:176
static const AVFilterPad avfilter_asrc_abuffer_outputs[]
Definition buffersrc.c:632

Definition at line 640 of file buffersrc.c.