59 #define CHECK_VIDEO_PARAM_CHANGE(s, c, width, height, format)\
60 if (c->w != width || c->h != height || c->pix_fmt != format) {\
61 av_log(s, AV_LOG_ERROR, "Changing frame properties on the fly is not supported.\n");\
62 return AVERROR(EINVAL);\
65 #define CHECK_AUDIO_PARAM_CHANGE(s, c, srate, ch_layout, format)\
66 if (c->sample_fmt != format || c->sample_rate != srate ||\
67 c->channel_layout != ch_layout) {\
68 av_log(s, AV_LOG_ERROR, "Changing frame properties on the fly is not supported.\n");\
69 return AVERROR(EINVAL);\
165 char pix_fmt_str[128];
169 (n = sscanf(args,
"%d:%d:%127[^:]:%d:%d:%d:%d", &c->
w, &c->
h, pix_fmt_str,
177 c->
pix_fmt = strtol(pix_fmt_str, &tail, 10);
191 #define OFFSET(x) offsetof(BufferSourceContext, x)
192 #define A AV_OPT_FLAG_AUDIO_PARAM
299 switch (link->
type) {
357 .description =
NULL_IF_CONFIG_SMALL(
"Buffer video frames, and make them accessible to the filterchain."),
365 .
outputs = avfilter_vsrc_buffer_outputs,
381 .description =
NULL_IF_CONFIG_SMALL(
"Buffer audio frames, and make them accessible to the filterchain."),
389 .
outputs = avfilter_asrc_abuffer_outputs,
uint8_t ** extended_data
pointers to the data planes/channels.
static av_cold int init_audio(AVFilterContext *ctx, const char *args)
AVFilterBufferRef * ff_get_audio_buffer(AVFilterLink *link, int perms, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
This structure describes decoded (raw) audio or video data.
int av_buffersrc_write_frame(AVFilterContext *buffer_filter, const AVFrame *frame)
Add a frame to the buffer source.
AVFilterBufferRefAudioProps * audio
audio buffer specific properties
AVFilterBufferRefVideoProps * video
video buffer specific properties
int linesize[8]
number of bytes per line
static const AVFilterPad outputs[]
Memory buffer source API.
int h
agreed upon image height
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
int ff_filter_frame(AVFilterLink *link, AVFilterBufferRef *frame)
Send a frame of data to the next filter.
int av_set_options_string(void *ctx, const char *opts, const char *key_val_sep, const char *pairs_sep)
Parse the key/value pairs list in opts.
static const AVFilterPad avfilter_vsrc_buffer_outputs[]
static enum AVSampleFormat formats[]
enum AVPixelFormat pix_fmt
static av_cold int init_video(AVFilterContext *ctx, const char *args)
static av_cold void uninit(AVFilterContext *ctx)
static const AVClass abuffer_class
int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int(*func)(void *, void *, int))
Feed data from a user-supplied callback to an AVFifoBuffer.
void avfilter_unref_buffer(AVFilterBufferRef *ref)
Remove a reference to a buffer.
const char * name
Pad name.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define CHECK_AUDIO_PARAM_CHANGE(s, c, srate, ch_layout, format)
static int poll_frame(AVFilterLink *link)
AVFilter avfilter_asrc_abuffer
void av_fifo_free(AVFifoBuffer *f)
Free an AVFifoBuffer.
static const AVFilterPad avfilter_asrc_abuffer_outputs[]
static int init(AVCodecParserContext *s)
A filter pad used for either input or output.
A link between two filters.
AVFilterBufferRef * ff_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
Request a picture buffer with a specific set of permissions.
int width
width and height of the video frame
int sample_rate
samples per second
static int request_frame(AVFilterLink *link)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void(*func)(void *, void *, int))
Feed data from an AVFifoBuffer to a user-supplied callback.
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
void av_log(void *avcl, int level, const char *fmt,...)
AVRational time_base
time_base to set in the output link
void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], const uint8_t *src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height)
Copy image in src_data to dst_data.
uint64_t channel_layout
Channel layout of the audio data.
int w
agreed upon image width
struct AVRational AVRational
rational number numerator/denominator
audio channel layout utility functions
AVFilterContext * src
source filter
enum AVPixelFormat pix_fmt
int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src)
Copy the frame properties of src to dst, without copying the actual image data.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
A reference to an AVFilterBuffer.
int av_fifo_space(AVFifoBuffer *f)
Return the amount of space in bytes in the AVFifoBuffer, that is the amount of data you can write int...
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
int av_fifo_realloc2(AVFifoBuffer *f, unsigned int new_size)
Resize an AVFifoBuffer.
int sample_rate
audio buffer sample rate
int av_samples_copy(uint8_t **dst, uint8_t *const *src, int dst_offset, int src_offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt)
Copy samples from src to dst.
a very simple circular buffer FIFO implementation
Describe the class of an AVClass context structure.
int sample_rate
Sample rate of the audio data.
static const AVFilterPad inputs[]
rational number numerator/denominator
static int config_props(AVFilterLink *link)
const char * name
filter name
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
uint64_t channel_layout
channel layout of audio buffer
AVFilterLink ** outputs
array of pointers to output links
enum AVMediaType type
filter media type
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static const AVOption audio_options[]
AVFilter avfilter_vsrc_buffer
int av_fifo_size(AVFifoBuffer *f)
Return the amount of data in bytes in the AVFifoBuffer, that is the amount of data you can read from ...
int av_buffersrc_buffer(AVFilterContext *s, AVFilterBufferRef *buf)
Add a buffer to the filtergraph s.
void av_opt_free(void *obj)
Free all string and binary options in obj.
common internal and external API header
AVSampleFormat
Audio Sample Formats.
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
#define AV_PERM_WRITE
can write to the buffer
AVFifoBuffer * av_fifo_alloc(unsigned int size)
Initialize an AVFifoBuffer.
enum AVSampleFormat sample_fmt
static int query_formats(AVFilterContext *ctx)
uint8_t * data[8]
picture/audio data for each plane
uint64_t av_get_channel_layout(const char *name)
Return a channel layout id that matches name, or 0 if no match is found.
number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of...
enum AVPixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
uint8_t ** extended_data
pointers to the data planes/channels.
AVPixelFormat
Pixel format.
int nb_samples
number of audio samples (per channel) described by this frame
enum AVSampleFormat av_get_sample_fmt(const char *name)
Return a sample format corresponding to name, or AV_SAMPLE_FMT_NONE on error.
#define CHECK_VIDEO_PARAM_CHANGE(s, c, width, height, format)
char * channel_layout_str