FFmpeg
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
buffersrc.c File Reference

memory buffer source filter More...

#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
#include "libavutil/fifo.h"
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
#include "libavutil/samplefmt.h"
#include "audio.h"
#include "avfilter.h"
#include "buffersrc.h"
#include "formats.h"
#include "internal.h"
#include "video.h"
#include "avcodec.h"

Go to the source code of this file.

Data Structures

struct  BufferSourceContext
 

Macros

#define CHECK_VIDEO_PARAM_CHANGE(s, c, width, height, format)
 
#define CHECK_AUDIO_PARAM_CHANGE(s, c, srate, ch_layout, format)
 
#define OFFSET(x)   offsetof(BufferSourceContext, 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 av_buffersrc_add_frame (AVFilterContext *buffer_src, const AVFrame *frame, int flags)
 Add frame data to buffer_src.
 
int av_buffersrc_write_frame (AVFilterContext *buffer_filter, const AVFrame *frame)
 Add a frame to the buffer source.
 
int av_buffersrc_add_ref (AVFilterContext *s, AVFilterBufferRef *buf, int flags)
 Add buffer data in picref to buffer_src.
 
unsigned av_buffersrc_get_nb_failed_requests (AVFilterContext *buffer_src)
 Get the number of failed requests.
 
 AVFILTER_DEFINE_CLASS (buffer)
 
static av_cold int init_video (AVFilterContext *ctx, const char *args)
 
 AVFILTER_DEFINE_CLASS (abuffer)
 
static av_cold int init_audio (AVFilterContext *ctx, const char *args)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int query_formats (AVFilterContext *ctx)
 
static int config_props (AVFilterLink *link)
 
static int request_frame (AVFilterLink *link)
 
static int poll_frame (AVFilterLink *link)
 

Variables

static const AVOption buffer_options []
 
static const AVOption abuffer_options []
 
static const AVFilterPad avfilter_vsrc_buffer_outputs []
 
AVFilter avfilter_vsrc_buffer
 
static const AVFilterPad avfilter_asrc_abuffer_outputs []
 
AVFilter avfilter_asrc_abuffer
 

Detailed Description

memory buffer source filter

Definition in file buffersrc.c.

Macro Definition Documentation

#define CHECK_VIDEO_PARAM_CHANGE (   s,
  c,
  width,
  height,
  format 
)
Value:
if (c->w != width || c->h != height || c->pix_fmt != format) {\
av_log(s, AV_LOG_INFO, "Changing frame properties on the fly is not supported by all filters.\n");\
}

Definition at line 65 of file buffersrc.c.

Referenced by av_buffersrc_add_ref().

#define CHECK_AUDIO_PARAM_CHANGE (   s,
  c,
  srate,
  ch_layout,
  format 
)
Value:
if (c->sample_fmt != format || c->sample_rate != srate ||\
c->channel_layout != ch_layout) {\
av_log(s, AV_LOG_ERROR, "Changing frame properties on the fly is not supported.\n");\
return AVERROR(EINVAL);\
}

Definition at line 70 of file buffersrc.c.

Referenced by av_buffersrc_add_ref().

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

Definition at line 171 of file buffersrc.c.

Definition at line 241 of file buffersrc.c.

Definition at line 241 of file buffersrc.c.

Function Documentation

int av_buffersrc_add_frame ( AVFilterContext buffer_src,
const AVFrame frame,
int  flags 
)

Add frame data to buffer_src.

Parameters
buffer_srcpointer to a buffer source context
framea frame, or NULL to mark EOF
flagsa combination of AV_BUFFERSRC_FLAG_*
Returns
>= 0 in case of success, a negative AVERROR code in case of failure

Definition at line 77 of file buffersrc.c.

Referenced by av_buffersrc_write_frame(), decode_video(), and main().

int av_buffersrc_write_frame ( AVFilterContext s,
const AVFrame frame 
)

Add a frame to the buffer source.

Parameters
san instance of the buffersrc filter.
frameframe to be added.
Warning
frame data will be memcpy()ed, which may be a big performance hit. Use av_buffersrc_buffer() to avoid copying the data.

Definition at line 96 of file buffersrc.c.

Referenced by video_thread().

int av_buffersrc_add_ref ( AVFilterContext buffer_src,
AVFilterBufferRef picref,
int  flags 
)

Add buffer data in picref to buffer_src.

Parameters
buffer_srcpointer to a buffer source context
picrefa buffer reference, or NULL to mark EOF
flagsa combination of AV_BUFFERSRC_FLAG_*
Returns
>= 0 in case of success, a negative AVERROR code in case of failure

Definition at line 101 of file buffersrc.c.

Referenced by av_asrc_buffer_add_audio_buffer_ref(), av_buffersrc_add_frame(), decode_audio(), decode_video(), sub2video_flush(), sub2video_push_ref(), and video_thread().

unsigned av_buffersrc_get_nb_failed_requests ( AVFilterContext buffer_src)

Get the number of failed requests.

A failed request is when the request_frame method is called while no frame is present in the buffer. The number is reset when a frame is added.

Definition at line 166 of file buffersrc.c.

Referenced by sub2video_heartbeat(), and transcode_from_filter().

AVFILTER_DEFINE_CLASS ( buffer  )
static av_cold int init_video ( AVFilterContext ctx,
const char *  args 
)
static

Definition at line 186 of file buffersrc.c.

AVFILTER_DEFINE_CLASS ( abuffer  )
static av_cold int init_audio ( AVFilterContext ctx,
const char *  args 
)
static

Definition at line 253 of file buffersrc.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 320 of file buffersrc.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 333 of file buffersrc.c.

static int config_props ( AVFilterLink link)
static

Definition at line 364 of file buffersrc.c.

static int request_frame ( AVFilterLink link)
static

Definition at line 387 of file buffersrc.c.

static int poll_frame ( AVFilterLink link)
static

Definition at line 403 of file buffersrc.c.

Variable Documentation

const AVOption buffer_options[]
static
Initial value:
= {
{ "time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, INT_MAX, FLAGS },
{ "frame_rate", NULL, OFFSET(frame_rate), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, INT_MAX, FLAGS },
{ "video_size", NULL, OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, .flags = FLAGS },
{ "pix_fmt", NULL, OFFSET(pix_fmt), AV_OPT_TYPE_PIXEL_FMT, .flags = FLAGS },
{ "pixel_aspect", NULL, OFFSET(pixel_aspect), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, INT_MAX, FLAGS },
{ "sws_param", NULL, OFFSET(sws_param), AV_OPT_TYPE_STRING, .flags = FLAGS },
{ NULL },
}

Definition at line 173 of file buffersrc.c.

const AVOption abuffer_options[]
static
Initial value:
= {
{ "time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, INT_MAX, FLAGS },
{ "sample_rate", NULL, OFFSET(sample_rate), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS },
{ "sample_fmt", NULL, OFFSET(sample_fmt_str), AV_OPT_TYPE_STRING, .flags = FLAGS },
{ "channels", NULL, OFFSET(channels), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS },
{ "channel_layout", NULL, OFFSET(channel_layout_str), AV_OPT_TYPE_STRING, .flags = FLAGS },
{ NULL },
}

Definition at line 242 of file buffersrc.c.

const AVFilterPad avfilter_vsrc_buffer_outputs[]
static
Initial value:
= {
{
.name = "default",
.request_frame = request_frame,
.poll_frame = poll_frame,
.config_props = config_props,
},
{ NULL }
}

Definition at line 412 of file buffersrc.c.

AVFilter avfilter_vsrc_buffer
Initial value:
= {
.name = "buffer",
.description = NULL_IF_CONFIG_SMALL("Buffer video frames, and make them accessible to the filterchain."),
.priv_size = sizeof(BufferSourceContext),
.priv_class = &buffer_class,
}

Definition at line 423 of file buffersrc.c.

const AVFilterPad avfilter_asrc_abuffer_outputs[]
static
Initial value:
= {
{
.name = "default",
.request_frame = request_frame,
.poll_frame = poll_frame,
.config_props = config_props,
},
{ NULL }
}

Definition at line 437 of file buffersrc.c.

AVFilter avfilter_asrc_abuffer
Initial value:
= {
.name = "abuffer",
.description = NULL_IF_CONFIG_SMALL("Buffer audio frames, and make them accessible to the filterchain."),
.priv_size = sizeof(BufferSourceContext),
.priv_class = &abuffer_class,
}

Definition at line 448 of file buffersrc.c.