50 #define LICENSE_PREFIX "libavfilter license: "
60 idx =
FFMIN(idx, *count);
64 memmove(*pads + idx + 1, *pads + idx,
sizeof(
AVFilterPad) * (*count - idx));
65 memmove(*links + idx + 1, *links + idx,
sizeof(
AVFilterLink*) * (*count - idx));
70 for (i = idx + 1; i < *count; i++)
72 (*(
unsigned *)((
uint8_t *) *links[i] + padidx_off))++;
86 "Media type mismatch between the '%s' filter output pad %d and the '%s' filter input pad %d\n",
87 src->
name, srcpad, dst->
name, dstpad);
109 unsigned filt_srcpad_idx,
unsigned filt_dstpad_idx)
115 "between the filter '%s' and the filter '%s'\n",
119 if ((ret =
avfilter_link(filt, filt_dstpad_idx, link->
dst, dstpad_idx)) < 0) {
128 filt->
inputs[filt_srcpad_idx] = link;
151 for (i = 0; i < filter->
nb_inputs; i ++) {
159 case AVLINK_STARTINIT:
171 "with more than one input "
172 "must set config_props() "
173 "callbacks on all outputs\n");
176 }
else if ((ret = config_link(link)) < 0) {
178 "Failed to configure output pad on %s\n",
197 }
else if (!link->
w || !link->
h) {
199 "Video source filters must set their output link's "
200 "width and height\n");
206 if ((ret = config_link(link)) < 0) {
208 "Failed to configure input pad on %s\n",
224 "link[%p s:%dx%d fmt:%-16s %-16s->%-16s]%s",
225 link, link->
w, link->
h,
235 "link[%p r:%d cl:%s fmt:%-16s %-16s->%-16s]%s",
257 int i,
min = INT_MAX;
267 min =
FFMIN(min, val);
275 #if !FF_API_NOCONST_GET_NAME
286 if (!strcmp(f->
name, name))
307 #if FF_API_OLD_FILTER_REGISTER
313 void avfilter_uninit(
void)
325 for (count = 0; pads->
name; count++)
359 #define OFFSET(x) offsetof(AVFilterContext, x)
360 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM
378 int *ret,
int nb_jobs)
382 for (i = 0; i < nb_jobs; i++) {
383 int r = func(ctx, arg, i, nb_jobs);
464 #if FF_API_AVFILTER_OPEN
468 return *filter_ctx ? 0 :
AVERROR(ENOMEM);
501 for (i = 0; i < filter->
nb_inputs; i++) {
527 const char *p = args;
534 "this filter supports.\n");
554 #if FF_API_AVFILTER_INIT_FILTER
605 "options, but options were provided: %s.\n", args);
609 #if FF_API_OLD_FILTER_OPTS
611 strchr(args,
':') && strchr(args,
':') < strchr(args,
'=')) {
617 "syntax is deprecated. Use either <w>:<h>:<flags> or "
618 "w=<w>:h=<h>:flags=<flags>.\n");
625 p = strrchr(copy,
':');
639 if (strchr(args,
'=')) {
644 #if FF_API_OLD_FILTER_OPTS
645 }
else if (!strcmp(filter->
filter->
name,
"format") ||
648 !strcmp(filter->
filter->
name,
"frei0r_src") ||
661 if (!strcmp(filter->
filter->
name,
"frei0r") ||
664 else if (!strcmp(filter->
filter->
name,
"frei0r_src"))
667 while (nb_leading--) {
670 p = copy + strlen(copy);
676 if (strchr(p,
':')) {
678 "'|' to separate the list items.\n");
681 while ((p = strchr(p,
':')))
715 return pads[pad_idx].
name;
720 return pads[pad_idx].
type;
745 switch (link->
type) {
765 switch (link->
type) {
int(* poll_frame)(AVFilterLink *link)
Frame poll callback.
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
AVFilterContext * ff_filter_alloc(const AVFilter *filter, const char *inst_name)
Allocate a new filter context and return it.
This structure describes decoded (raw) audio or video data.
int thread_type
Type of multithreading allowed for filters in this graph.
static int default_filter_frame(AVFilterLink *link, AVFrame *frame)
void avfilter_free(AVFilterContext *filter)
Free a filter context.
static const char * filter_name(void *p)
#define AV_LOG_WARNING
Something somehow does not look correct.
Main libavfilter public API header.
int(* init)(AVFilterContext *ctx)
Filter initialization function.
int h
agreed upon image height
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx)
Get the type of an AVFilterPad.
enum AVMediaType type
AVFilterPad type.
#define LIBAVFILTER_VERSION_INT
av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (%s)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic?ac->func_descr_generic:ac->func_descr)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
AVFilterPad * dstpad
input pad on the dest filter
struct AVFilterChannelLayouts * in_channel_layouts
int thread_type
Type of multithreading being allowed/used.
#define AVFILTER_THREAD_SLICE
Process multiple parts of the frame concurrently.
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
struct AVFilterGraph * graph
filtergraph this filter belongs to
const char * name
Pad name.
int priv_size
size of private data to allocate for the filter
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
AVFilterLink ** inputs
array of pointers to input links
char * name
name of this filter instance
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
Link two filters together.
AVFilterPad * output_pads
array of output pads
void ff_dlog_link(void *ctx, AVFilterLink *link, int end)
const char * avfilter_license(void)
Return the libavfilter license.
int(* request_frame)(AVFilterLink *link)
Frame request callback.
const struct AVOption * option
a pointer to the first option specified in the class if any or NULL
int flags
A combination of AVFILTER_FLAG_*.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
int avfilter_config_links(AVFilterContext *filter)
Negotiate the media format, dimensions, etc of all inputs to a filter.
const AVFilter * avfilter_next(const AVFilter *prev)
Iterate over all registered filters.
#define AV_LOG_VERBOSE
Detailed information.
void(* uninit)(AVFilterContext *ctx)
Filter uninitialization function.
static void copy(LZOContext *c, int cnt)
Copies bytes from input to output buffer with checking.
static void free_link(AVFilterLink *link)
const OptionDef options[]
A filter pad used for either input or output.
A link between two filters.
static const AVClass avfilter_class
AVFilterPad * input_pads
array of input pads
int width
width and height of the video frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
int( avfilter_action_func)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
A function pointer passed to the AVFilterGraph::execute callback to be executed multiple times...
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.
unsigned nb_outputs
number of output pads
unsigned avfilter_version(void)
Return the LIBAVFILTER_VERSION_INT constant.
void * priv
private data for use by the filter
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int(* filter_frame)(AVFilterLink *link, AVFrame *frame)
Filtering callback.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
const AVOption * av_opt_next(void *obj, const AVOption *last)
Iterate over all AVOptions belonging to obj.
int(* init_dict)(AVFilterContext *ctx, AVDictionary **options)
Should be set instead of init by the filters that want to pass a dictionary of AVOptions to nested co...
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
struct AVFilterChannelLayouts * out_channel_layouts
void av_log(void *avcl, int level, const char *fmt,...)
AVFilterFormats * in_formats
Lists of formats supported by the input and output filters respectively.
const char * av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
#define LIBAV_CONFIGURATION
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.
char * av_get_token(const char **buf, const char *term)
Unescape the given string until a non escaped terminating char, and return the token corresponding to...
uint64_t channel_layout
Channel layout of the audio data.
int w
agreed upon image width
const AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
common internal API header
static void filter(MpegAudioContext *s, int ch, const short *samples, int incr)
static void * filter_child_next(void *obj, void *prev)
audio channel layout utility functions
unsigned nb_inputs
number of input pads
static AVFilter * first_filter
static const AVOption avfilter_options[]
int needs_writable
The filter expects writable frames from its input link, duplicating data buffers if needed...
AVFilterContext * src
source filter
AVFilterFormats * out_samplerates
static int process_unnamed_options(AVFilterContext *ctx, AVDictionary **options, const char *args)
int format
agreed upon media format
int avfilter_init_str(AVFilterContext *filter, const char *args)
Initialize a filter with the supplied parameters.
const AVFilterPad * inputs
List of inputs, terminated by a zeroed element.
const AVClass * avfilter_get_class(void)
int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt, unsigned filt_srcpad_idx, unsigned filt_dstpad_idx)
Insert a filter in the middle of an existing link.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
int av_dict_parse_string(AVDictionary **pm, const char *str, const char *key_val_sep, const char *pairs_sep, int flags)
Parse the key/value pairs list and add to a dictionary.
const AVClass * priv_class
A class for the private data, used to declare filter private AVOptions.
#define AV_LOG_INFO
Standard information.
AVFilterFormats * in_samplerates
Lists of channel layouts and sample rates used for automatic negotiation.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
AVFilterGraphInternal * internal
Opaque object for libavfilter internal use.
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
int av_opt_set_dict(void *obj, AVDictionary **options)
char * av_strdup(const char *s)
Duplicate the string s.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
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.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Describe the class of an AVClass context structure.
rational number numerator/denominator
struct AVFilter * next
Used by the filter registration system.
const char * name
Filter name.
const char * avfilter_configuration(void)
Return the libavfilter build-time configuration.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
const char * avfilter_pad_get_name(const AVFilterPad *pads, int pad_idx)
Get the name of an AVFilterPad.
AVFilterLink ** outputs
array of pointers to output links
static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
static int default_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
enum AVMediaType type
filter media type
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options)
Initialize a filter with the supplied dictionary of options.
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_dlog(ac->avr,"%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-> out
void av_opt_free(void *obj)
Free all allocated objects in obj.
#define FF_DISABLE_DEPRECATION_WARNINGS
common internal and external API header
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
static int request_frame(AVFilterLink *outlink)
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
avfilter_execute_func * execute
void ff_filter_graph_remove_filter(AVFilterGraph *graph, AVFilterContext *filter)
Remove a filter from a graph;.
avfilter_execute_func * thread_execute
#define AVERROR_OPTION_NOT_FOUND
Option not found.
#define FF_ENABLE_DEPRECATION_WARNINGS
int avfilter_register(AVFilter *filter)
Register a filter.
AVFilterContext * dst
dest filter
const AVClass * av_class
needed for av_log()
int avfilter_pad_count(const AVFilterPad *pads)
Get the number of elements in a NULL-terminated array of AVFilterPads (e.g.
#define FF_DPRINTF_START(ctx, func)
AVFilterPad * srcpad
output pad on the source filter
const AVFilterPad * outputs
List of outputs, terminated by a zeroed element.
int(* config_props)(AVFilterLink *link)
Link configuration callback.
#define AV_DICT_IGNORE_SUFFIX
void ff_insert_pad(unsigned idx, unsigned *count, size_t padidx_off, AVFilterPad **pads, AVFilterLink ***links, AVFilterPad *newpad)
Insert a new pad.
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
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.
static const AVClass * filter_child_class_next(const AVClass *prev)
uint8_t ** extended_data
pointers to the data planes/channels.
int ff_poll_frame(AVFilterLink *link)
Poll a frame from the filter chain.
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
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
AVFilterFormats * out_formats
void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout)
Return a description of a channel layout.
enum AVFilterLink::@85 init_state
stage of the initialization of the link properties (dimensions, etc)