32 #define FF_INTERNAL_FIELDS 1
63 #define NB_ITEMS(list) (list ## _size / sizeof(*list))
64 #define FIFO_INIT_SIZE 8
65 #define FIFO_INIT_ELEMENT_SIZE sizeof(void *)
165 "%d buffers queued in %s, something may be wrong.\n",
183 #define MAKE_AVFILTERLINK_ACCESSOR(type, field) \
184 type av_buffersink_get_##field(const AVFilterContext *ctx) { \
185 av_assert0(ctx->filter->activate == activate); \
186 return ctx->inputs[0]->field; \
218 #define CHECK_LIST_SIZE(field) \
219 if (buf->field ## _size % sizeof(*buf->field)) { \
220 av_log(ctx, AV_LOG_ERROR, "Invalid size for " #field ": %d, " \
221 "should be multiple of %d\n", \
222 buf->field ## _size, (int)sizeof(*buf->field)); \
223 return AVERROR(EINVAL); \
296 "Conflicting all_channel_counts and list in options\n");
316 #define OFFSET(x) offsetof(BufferSinkContext, x)
317 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
323 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
346 .
name =
"buffersink",
347 .description =
NULL_IF_CONFIG_SMALL(
"Buffer video frames, and make them available to the end of the filter graph."),
349 .priv_class = &buffersink_class,
354 .
inputs = avfilter_vsink_buffer_inputs,
367 .
name =
"abuffersink",
368 .description =
NULL_IF_CONFIG_SMALL(
"Buffer audio frames, and make them available to the end of the filter graph."),
369 .priv_class = &abuffersink_class,
375 .
inputs = avfilter_asink_abuffer_inputs,
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
int frame_wanted_out
True if a frame is currently wanted on the output of this filter.
enum AVSampleFormat * sample_fmts
list of accepted sample formats, terminated by AV_SAMPLE_FMT_NONE
static const char * format[]
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.
Main libavfilter public API header.
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.
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
static int return_or_keep_frame(BufferSinkContext *buf, AVFrame *out, AVFrame *in, int flags)
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
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
static av_cold int vsink_init(AVFilterContext *ctx, void *opaque)
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
static av_cold int asink_init(AVFilterContext *ctx, void *opaque)
static const AVOption buffersink_options[]
#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.
AVFILTER_DEFINE_CLASS(buffersink)
A link between two filters.
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
static int vsink_query_formats(AVFilterContext *ctx)
int min_samples
Minimum number of samples to filter at once.
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
static int activate(AVFilterContext *ctx)
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
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.
common internal API header
int64_t * channel_layouts
list of accepted channel layouts, terminated by -1
audio channel layout utility functions
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
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 inputs[]
static const uint8_t channel_counts[7]
static const AVFilterPad outputs[]
offset must point to a pointer immediately followed by an int for the length
AVFilter ff_asink_abuffer
A list of supported channel layouts.
AVSampleFormat
Audio sample formats.
int ff_inlink_consume_samples(AVFilterLink *link, unsigned min, unsigned max, AVFrame **rframe)
Take samples from the link's FIFO and update the link's stats.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
static const uint16_t channel_layouts[7]
int all_channel_counts
if not 0, accept any channel count or layout
Describe the class of an AVClass context structure.
Rational number (pair of numerator and denominator).
const char * name
Filter name.
enum MovChannelLayoutTag * layouts
#define flags(name, subs,...)
static int get_frame_internal(AVFilterContext *ctx, AVFrame *frame, int flags, int samples)
A reference to a data buffer.
static int query_formats(AVFilterContext *ctx)
static size_t ff_framequeue_queued_frames(const FFFrameQueue *fq)
Get the number of queued frames.
common internal and external API header
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.
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 enum AVSampleFormat sample_fmts[]
static const AVFilterPad avfilter_vsink_buffer_inputs[]
#define MAKE_AVFILTERLINK_ACCESSOR(type, field)
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.
const AVFilter * filter
the AVFilter of which this is an instance