64 #define NB_ITEMS(list) (list ## _size / sizeof(*list))
65 #define FIFO_INIT_SIZE 8
66 #define FIFO_INIT_ELEMENT_SIZE sizeof(void *)
93 "Cannot buffer more frames. Consume some available frames "
94 "before adding new ones.\n");
115 "%d buffers queued in %s, something may be wrong.\n",
209 }
else if (ret < 0) {
274 || !strcmp(ctx->
filter->
name,
"ffbuffersink"));
293 #define CHECK_LIST_SIZE(field) \
294 if (buf->field ## _size % sizeof(*buf->field)) { \
295 av_log(ctx, AV_LOG_ERROR, "Invalid size for " #field ": %d, " \
296 "should be multiple of %d\n", \
297 buf->field ## _size, (int)sizeof(*buf->field)); \
298 return AVERROR(EINVAL); \
371 "Conflicting all_channel_counts and list in options\n");
391 #define OFFSET(x) offsetof(BufferSinkContext, x)
392 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
398 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
422 .
name =
"buffersink",
423 .description =
NULL_IF_CONFIG_SMALL(
"Buffer video frames, and make them available to the end of the filter graph."),
425 .priv_class = &buffersink_class,
430 .
inputs = avfilter_vsink_buffer_inputs,
444 .
name =
"abuffersink",
445 .description =
NULL_IF_CONFIG_SMALL(
"Buffer audio frames, and make them available to the end of the filter graph."),
446 .priv_class = &abuffersink_class,
452 .
inputs = avfilter_asink_abuffer_inputs,
int frame_wanted_out
True if a frame is currently wanted on the output of this filter.
AVAudioFifo * av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels, int nb_samples)
Allocate an AVAudioFifo.
int av_audio_fifo_read(AVAudioFifo *af, void **data, int nb_samples)
Read data from an AVAudioFifo.
enum AVSampleFormat * sample_fmts
list of accepted sample formats, terminated by AV_SAMPLE_FMT_NONE
This structure describes decoded (raw) audio or video data.
AVBufferSinkParams * av_buffersink_params_alloc(void)
Create an AVBufferSinkParams structure.
#define AV_LOG_WARNING
Something somehow does not look correct.
static av_cold void uninit(AVFilterContext *ctx)
Main libavfilter public API header.
static int read_from_fifo(AVFilterContext *ctx, AVFrame *frame, int nb_samples)
const int * channel_counts
list of allowed channel counts, terminated by -1
AVABufferSinkParams * av_abuffersink_params_alloc(void)
Create an AVABufferSinkParams structure.
int max_samples
Maximum number of samples to filter at once.
#define av_opt_set_int_list(obj, name, val, term, flags)
Set a binary option to an integer list.
void av_audio_fifo_free(AVAudioFifo *af)
Free an AVAudioFifo.
int * sample_rates
list of accepted sample rates, terminated by -1
static const AVOption abuffersink_options[]
int * channel_counts
list of accepted channel counts, terminated by -1
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
static enum AVSampleFormat formats[]
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.
struct AVFilterGraph * graph
filtergraph this filter belongs to
memory buffer sink API for audio and video
enum AVSampleFormat * sample_fmts
list of allowed sample formats, terminated by AV_SAMPLE_FMT_NONE
const char * name
Pad name.
int ff_filter_graph_run_once(AVFilterGraph *graph)
Run one round of processing on a filter graph.
AVFilterLink ** inputs
array of pointers to input links
char * name
name of this filter instance
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static av_cold int vsink_init(AVFilterContext *ctx, void *opaque)
AVAudioFifo * audio_fifo
FIFO for audio samples.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
int av_fifo_space(const AVFifoBuffer *f)
Return the amount of space in bytes in the AVFifoBuffer, that is the amount of data you can write int...
#define FIFO_INIT_ELEMENT_SIZE
static av_cold int asink_init(AVFilterContext *ctx, void *opaque)
static const AVOption buffersink_options[]
#define AVERROR_EOF
End of file.
#define CHECK_LIST_SIZE(field)
#define AV_BUFFERSINK_FLAG_NO_REQUEST
Tell av_buffersink_get_buffer_ref() not to request a frame from its input.
A filter pad used for either input or output.
static void * av_x_if_null(const void *p, const void *x)
Return x default pointer in case p is NULL.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
AVFILTER_DEFINE_CLASS(buffersink)
A link between two filters.
static int vsink_query_formats(AVFilterContext *ctx)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static uint8_t * av_fifo_peek2(const AVFifoBuffer *f, int offs)
Return a pointer to the data stored in a FIFO buffer at a certain offset.
int min_samples
Minimum number of samples to filter at once.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0, will be automatically copied from the first input of the source filter if it exists.
int sample_rate
samples per second
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int * sample_rates
list of allowed sample rates, terminated by -1
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_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
simple assert() macros that are a bit more flexible than ISO C assert().
static const AVFilterPad avfilter_asink_abuffer_inputs[]
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.
static const int sample_rates[]
Context for an Audio FIFO Buffer.
common internal API header
int64_t * channel_layouts
list of accepted channel layouts, terminated by -1
int av_audio_fifo_size(AVAudioFifo *af)
Get the current number of samples in the AVAudioFifo available for reading.
audio channel layout utility functions
Struct to use for initializing an abuffersink context.
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...
Struct to use for initializing a buffersink context.
int partial_buf_size
Size of the partial buffer to allocate.
enum AVPixelFormat * pixel_fmts
list of accepted pixel formats, must be terminated with -1
static const AVFilterPad outputs[]
int format
agreed upon media format
offset must point to a pointer immediately followed by an int for the length
AVFilter ff_asink_abuffer
A list of supported channel layouts.
static const AVFilterPad inputs[]
AVSampleFormat
Audio sample formats.
int av_fifo_size(const AVFifoBuffer *f)
Return the amount of data in bytes in the AVFifoBuffer, that is the amount of data you can read from ...
int av_fifo_realloc2(AVFifoBuffer *f, unsigned int new_size)
Resize an AVFifoBuffer.
int all_channel_counts
if not 0, accept any channel count or layout
Describe the class of an AVClass context structure.
rational number numerator/denominator
const char * name
Filter name.
enum MovChannelLayoutTag * layouts
AVRational av_buffersink_get_frame_rate(AVFilterContext *ctx)
Get the frame rate of the input.
AVFifoBuffer * fifo
FIFO buffer of video frame references.
AVFifoBuffer * av_fifo_alloc_array(size_t nmemb, size_t size)
Initialize an AVFifoBuffer.
int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples)
Write data to an AVAudioFifo.
int64_t next_pts
interpolating audio pts
static int query_formats(AVFilterContext *ctx)
common internal and external API header
static int add_buffer_ref(AVFilterContext *ctx, AVFrame *ref)
enum AVPixelFormat * pixel_fmts
list of allowed pixel formats, terminated by AV_PIX_FMT_NONE
void av_buffersink_set_frame_size(AVFilterContext *ctx, unsigned frame_size)
Set the frame size for an audio buffer sink.
int channels
Number of channels.
static av_cold int common_init(AVFilterContext *ctx)
#define AV_BUFFERSINK_FLAG_PEEK
Tell av_buffersink_get_buffer_ref() to read video/samples buffer reference, but not remove it from th...
static int asink_query_formats(AVFilterContext *ctx)
static int filter_frame(AVFilterLink *link, AVFrame *frame)
AVFilterContext * dst
dest filter
static enum AVSampleFormat sample_fmts[]
static const AVFilterPad avfilter_vsink_buffer_inputs[]
void av_fifo_freep(AVFifoBuffer **f)
Free an AVFifoBuffer and reset pointer to NULL.
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
uint8_t ** extended_data
pointers to the data planes/channels.
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.
const int64_t * channel_layouts
list of allowed channel layouts, terminated by -1
AVPixelFormat
Pixel format.
int nb_samples
number of audio samples (per channel) described by this frame
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
const AVFilter * filter
the AVFilter of which this is an instance
#define AV_NOPTS_VALUE
Undefined timestamp value.