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

memory buffer source filter More...

#include <float.h>
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
#include "libavutil/fifo.h"
#include "libavutil/frame.h"
#include "libavutil/imgutils.h"
#include "libavutil/internal.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"

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, ch_count, format)
 
#define OFFSET(x)   offsetof(BufferSourceContext, 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. More...
 
int av_buffersrc_parameters_set (AVFilterContext *ctx, AVBufferSrcParameters *param)
 Initialize the buffersrc or abuffersrc filter with the provided parameters. More...
 
int attribute_align_arg av_buffersrc_write_frame (AVFilterContext *ctx, const AVFrame *frame)
 Add a frame to the buffer source. More...
 
int attribute_align_arg av_buffersrc_add_frame (AVFilterContext *ctx, AVFrame *frame)
 Add a frame to the buffer source. More...
 
static int av_buffersrc_add_frame_internal (AVFilterContext *ctx, AVFrame *frame, int flags)
 
int attribute_align_arg av_buffersrc_add_frame_flags (AVFilterContext *ctx, AVFrame *frame, int flags)
 Add a frame to the buffer source. More...
 
static int push_frame (AVFilterGraph *graph)
 
int av_buffersrc_close (AVFilterContext *ctx, int64_t pts, unsigned flags)
 Close the buffer source after EOF. More...
 
static av_cold int init_video (AVFilterContext *ctx)
 
unsigned av_buffersrc_get_nb_failed_requests (AVFilterContext *buffer_src)
 Get the number of failed requests. More...
 
 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 (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 ff_vsrc_buffer
 
static const AVFilterPad avfilter_asrc_abuffer_outputs []
 
AVFilter ff_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");\
}
const char * s
Definition: avisynth_c.h:768
#define height
#define av_log(a,...)
uint16_t width
Definition: gdv.c:47
#define AV_LOG_INFO
Standard information.
Definition: log.h:187
static const char * format
Definition: movenc.c:47
static double c[64]

Definition at line 70 of file buffersrc.c.

Referenced by av_buffersrc_add_frame_internal().

#define CHECK_AUDIO_PARAM_CHANGE (   s,
  c,
  srate,
  ch_layout,
  ch_count,
  format 
)
Value:
if (c->sample_fmt != format || c->sample_rate != srate ||\
c->channel_layout != ch_layout || c->channels != ch_count) {\
av_log(s, AV_LOG_ERROR, "Changing frame properties on the fly is not supported.\n");\
return AVERROR(EINVAL);\
}
const char * s
Definition: avisynth_c.h:768
#define av_log(a,...)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
#define AVERROR(e)
Definition: error.h:43
return
static const char * format
Definition: movenc.c:47
static double c[64]

Definition at line 75 of file buffersrc.c.

Referenced by av_buffersrc_add_frame_internal().

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

Definition at line 298 of file buffersrc.c.

Definition at line 299 of file buffersrc.c.

Definition at line 300 of file buffersrc.c.

Function Documentation

static int av_buffersrc_add_frame_internal ( AVFilterContext ctx,
AVFrame frame,
int  flags 
)
static

Definition at line 190 of file buffersrc.c.

Referenced by av_buffersrc_add_frame_flags().

static int push_frame ( AVFilterGraph graph)
static

Definition at line 176 of file buffersrc.c.

Referenced by av_buffersrc_add_frame_internal(), and av_buffersrc_close().

static av_cold int init_video ( AVFilterContext ctx)
static

Definition at line 272 of file buffersrc.c.

AVFILTER_DEFINE_CLASS ( buffer  )
AVFILTER_DEFINE_CLASS ( abuffer  )
static av_cold int init_audio ( AVFilterContext ctx)
static

Definition at line 336 of file buffersrc.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 389 of file buffersrc.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 401 of file buffersrc.c.

static int config_props ( AVFilterLink link)
static

Definition at line 436 of file buffersrc.c.

static int request_frame ( AVFilterLink link)
static

Definition at line 465 of file buffersrc.c.

static int poll_frame ( AVFilterLink link)
static

Definition at line 484 of file buffersrc.c.

Variable Documentation

const AVOption buffer_options[]
static
Initial value:
= {
{ "width", NULL, OFFSET(w), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, V },
{ "video_size", NULL, OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, .flags = V },
{ "height", NULL, OFFSET(h), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, V },
{ "pix_fmt", NULL, OFFSET(pix_fmt), AV_OPT_TYPE_PIXEL_FMT, { .i64 = AV_PIX_FMT_NONE }, .min = AV_PIX_FMT_NONE, .max = INT_MAX, .flags = V },
{ "sar", "sample aspect ratio", OFFSET(pixel_aspect), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
{ "pixel_aspect", "sample aspect ratio", OFFSET(pixel_aspect), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
{ "time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
{ "frame_rate", NULL, OFFSET(frame_rate), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
{ "sws_param", NULL, OFFSET(sws_param), AV_OPT_TYPE_STRING, .flags = V },
{ NULL },
}
#define NULL
Definition: coverity.c:32
static enum AVPixelFormat pix_fmt
#define OFFSET(x)
Definition: buffersrc.c:298
#define V
Definition: buffersrc.c:300
offset must point to two consecutive integers
Definition: opt.h:233

Definition at line 302 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, 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(channel_layout_str), AV_OPT_TYPE_STRING, .flags = A },
{ "channels", NULL, OFFSET(channels), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, A },
{ NULL },
}
#define NULL
Definition: coverity.c:32
#define OFFSET(x)
Definition: buffersrc.c:298
#define A
Definition: buffersrc.c:299
sample_rate

Definition at line 325 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 }
}
#define NULL
Definition: coverity.c:32
static int poll_frame(AVFilterLink *link)
Definition: buffersrc.c:484
static int request_frame(AVFilterLink *link)
Definition: buffersrc.c:465
static int config_props(AVFilterLink *link)
Definition: buffersrc.c:436

Definition at line 493 of file buffersrc.c.

AVFilter ff_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,
}
#define NULL
Definition: coverity.c:32
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static av_cold int init_video(AVFilterContext *ctx)
Definition: buffersrc.c:272
static const AVFilterPad avfilter_vsrc_buffer_outputs[]
Definition: buffersrc.c:493
static av_cold void uninit(AVFilterContext *ctx)
Definition: buffersrc.c:389
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:179
static const AVFilterPad outputs[]
Definition: af_afftfilt.c:389
static const AVFilterPad inputs[]
Definition: af_afftfilt.c:379
static int query_formats(AVFilterContext *ctx)
Definition: buffersrc.c:401

Definition at line 504 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 }
}
#define NULL
Definition: coverity.c:32
static int poll_frame(AVFilterLink *link)
Definition: buffersrc.c:484
static int request_frame(AVFilterLink *link)
Definition: buffersrc.c:465
static int config_props(AVFilterLink *link)
Definition: buffersrc.c:436

Definition at line 518 of file buffersrc.c.

AVFilter ff_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,
}
#define NULL
Definition: coverity.c:32
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static av_cold void uninit(AVFilterContext *ctx)
Definition: buffersrc.c:389
static const AVFilterPad avfilter_asrc_abuffer_outputs[]
Definition: buffersrc.c:518
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:179
static const AVFilterPad outputs[]
Definition: af_afftfilt.c:389
static av_cold int init_audio(AVFilterContext *ctx)
Definition: buffersrc.c:336
static const AVFilterPad inputs[]
Definition: af_afftfilt.c:379
static int query_formats(AVFilterContext *ctx)
Definition: buffersrc.c:401

Definition at line 529 of file buffersrc.c.