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",
207 }
else if (ret < 0) {
269 #if FF_API_AVFILTERBUFFER
279 AVFilterBufferRef **pbuf,
int nb_samples,
int flags)
281 AVFilterBufferRef *
buf;
307 buf = avfilter_get_audio_buffer_ref_from_arrays(frame->
extended_data,
318 avfilter_copy_frame_props(buf, frame);
321 buf->buf->priv = frame;
332 int attribute_align_arg av_buffersink_read(
AVFilterContext *ctx, AVFilterBufferRef **buf)
334 return compat_read(ctx, buf, 0, 0);
337 int attribute_align_arg av_buffersink_read_samples(
AVFilterContext *ctx, AVFilterBufferRef **buf,
340 return compat_read(ctx, buf, nb_samples, 0);
343 int attribute_align_arg av_buffersink_get_buffer_ref(
AVFilterContext *ctx,
344 AVFilterBufferRef **bufref,
int flags)
351 || !strcmp(ctx->
filter->
name,
"ffabuffersink"));
353 return compat_read(ctx, bufref, 0, flags);
361 || !strcmp(ctx->
filter->
name,
"ffbuffersink"));
366 #if FF_API_AVFILTERBUFFER
376 || !strcmp(ctx->
filter->
name,
"ffabuffersink"));
397 #define CHECK_LIST_SIZE(field) \
398 if (buf->field ## _size % sizeof(*buf->field)) { \
399 av_log(ctx, AV_LOG_ERROR, "Invalid size for " #field ": %d, " \
400 "should be multiple of %d\n", \
401 buf->field ## _size, (int)sizeof(*buf->field)); \
402 return AVERROR(EINVAL); \
480 "Conflicting all_channel_counts and list in options\n");
500 #define OFFSET(x) offsetof(BufferSinkContext, x)
501 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
507 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
521 #if FF_API_AVFILTERBUFFER
523 #define ffbuffersink_options buffersink_options
524 #define ffabuffersink_options abuffersink_options
538 .
name =
"ffbuffersink",
539 .description =
NULL_IF_CONFIG_SMALL(
"Buffer video frames, and make them available to the end of the filter graph."),
541 .priv_class = &ffbuffersink_class,
546 .
inputs = ffbuffersink_inputs,
550 static const AVFilterPad ffabuffersink_inputs[] = {
560 .
name =
"ffabuffersink",
561 .description =
NULL_IF_CONFIG_SMALL(
"Buffer audio frames, and make them available to the end of the filter graph."),
565 .priv_class = &ffabuffersink_class,
567 .
inputs = ffabuffersink_inputs,
582 .
name =
"buffersink",
583 .description =
NULL_IF_CONFIG_SMALL(
"Buffer video frames, and make them available to the end of the filter graph."),
585 .priv_class = &buffersink_class,
590 .
inputs = avfilter_vsink_buffer_inputs,
604 .
name =
"abuffersink",
605 .description =
NULL_IF_CONFIG_SMALL(
"Buffer audio frames, and make them available to the end of the filter graph."),
606 .priv_class = &abuffersink_class,
612 .
inputs = avfilter_asink_abuffer_inputs,
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 const AVFilterPad outputs[]
#define AV_NOWARN_DEPRECATED(code)
Disable warnings about deprecated features This is useful for sections of code kept for backward comp...
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
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
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.
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.
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)
int width
width and height of the video frame
#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 closed
True if the link is closed.
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; if left to 0/0, will be automatically be cop...
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.
uint64_t channel_layout
Channel layout of the audio data.
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
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.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
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 linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
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.
static const AVFilterPad inputs[]
rational number numerator/denominator
AVFilterBufferRef * avfilter_get_video_buffer_ref_from_arrays(uint8_t *const data[4], const int linesize[4], int perms, int w, int h, enum AVPixelFormat format)
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.
enum AVMediaType type
filter media type
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples)
Write data to an AVAudioFifo.
int64_t next_pts
interpolating audio pts
#define FF_DISABLE_DEPRECATION_WARNINGS
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...
#define FF_ENABLE_DEPRECATION_WARNINGS
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 ff_poll_frame(AVFilterLink *link)
Poll a frame from the filter chain.
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.
static void compat_free_buffer(void *opaque, uint8_t *data)