48 #define LICENSE_PREFIX "libavfilter license: "
58 idx =
FFMIN(idx, *count);
62 memmove(*pads +idx+1, *pads +idx,
sizeof(
AVFilterPad) * (*count-idx));
63 memmove(*links+idx+1, *links+idx,
sizeof(
AVFilterLink*) * (*count-idx));
68 for (i = idx+1; i < *count; i++)
70 (*(
unsigned *)((
uint8_t *) *links[i] + padidx_off))++;
84 "Media type mismatch between the '%s' filter output pad %d and the '%s' filter input pad %d\n",
85 src->
name, srcpad, dst->
name, dstpad);
104 unsigned filt_srcpad_idx,
unsigned filt_dstpad_idx)
110 "between the filter '%s' and the filter '%s'\n",
114 if ((ret =
avfilter_link(filt, filt_dstpad_idx, link->
dst, dstpad_idx)) < 0) {
123 filt->
inputs[filt_srcpad_idx] = link;
146 for (i = 0; i < filter->
nb_inputs; i ++) {
154 case AVLINK_STARTINIT:
166 "with more than one input "
167 "must set config_props() "
168 "callbacks on all outputs\n");
171 }
else if ((ret = config_link(link)) < 0) {
173 "Failed to configure output pad on %s\n",
192 }
else if (!link->
w || !link->
h) {
194 "Video source filters must set their output link's "
195 "width and height\n");
201 if ((ret = config_link(link)) < 0) {
203 "Failed to configure input pad on %s\n",
219 "link[%p s:%dx%d fmt:%-16s %-16s->%-16s]%s",
220 link, link->
w, link->
h,
230 "link[%p r:%d cl:%s fmt:%-16s %-16s->%-16s]%s",
252 int i,
min = INT_MAX;
262 min =
FFMIN(min, val);
268 #define MAX_REGISTERED_AVFILTERS_NB 64
278 for (i = 0; registered_avfilters[i]; i++)
279 if (!strcmp(registered_avfilters[i]->name, name))
280 return registered_avfilters[i];
296 return filter ? ++filter : ®istered_avfilters[0];
301 memset(registered_avfilters, 0,
sizeof(registered_avfilters));
312 for(count = 0; pads->
name; count ++) pads ++;
399 for (i = 0; i < filter->
nb_inputs; i++) {
400 if ((link = filter->
inputs[i])) {
413 if ((link = filter->
outputs[i])) {
446 return pads[pad_idx].
name;
451 return pads[pad_idx].
type;
464 int perms = frame->
perms;
478 "Copying data in avfilter (have perms %x, need %x, reject %x)\n",
481 switch (link->
type) {
490 default:
return AVERROR(EINVAL);
498 switch (link->
type) {
509 default:
return AVERROR(EINVAL);
uint8_t ** extended_data
pointers to the data planes/channels.
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 ...
AVFilterBufferRef * ff_get_audio_buffer(AVFilterLink *link, int perms, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
static int default_filter_frame(AVFilterLink *link, AVFilterBufferRef *frame)
int nb_samples
number of audio samples
AVFilterBufferRefAudioProps * audio
audio buffer specific properties
AVFilterBufferRefVideoProps * video
video buffer specific properties
const char * avfilter_pad_get_name(AVFilterPad *pads, int pad_idx)
Get the name of an AVFilterPad.
static const char * filter_name(void *p)
static int next_registered_avfilter_idx
int linesize[8]
number of bytes per line
static int pad_count(const AVFilterPad *pads)
void avfilter_free(AVFilterContext *filter)
Free a filter context.
int h
agreed upon image height
int ff_filter_frame(AVFilterLink *link, AVFilterBufferRef *frame)
Send a frame of data to the next filter.
int(* init)(AVFilterContext *ctx, const char *args)
Filter initialization function.
int(* filter_frame)(AVFilterLink *link, AVFilterBufferRef *frame)
Filtering callback.
static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *buf)
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.
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)
AVFilterPad * dstpad
input pad on the dest filter
const char * avfilter_license(void)
Return the libavfilter license.
struct AVFilterChannelLayouts * in_channel_layouts
static AVFilter * registered_avfilters[MAX_REGISTERED_AVFILTERS_NB+1]
void avfilter_unref_buffer(AVFilterBufferRef *ref)
Remove a reference to a buffer.
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
const char * name
Pad name.
int priv_size
size of private data to allocate for the filter
AVFilterLink ** inputs
array of pointers to input links
char * name
name of this filter instance
#define MAX_REGISTERED_AVFILTERS_NB
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)
int avfilter_register(AVFilter *filter)
Register a filter.
int(* request_frame)(AVFilterLink *link)
Frame request callback.
int avfilter_config_links(AVFilterContext *filter)
Negotiate the media format, dimensions, etc of all inputs to a filter.
void(* uninit)(AVFilterContext *ctx)
Filter uninitialization function.
A filter pad used for either input or output.
A link between two filters.
static const AVClass avfilter_class
const char * avfilter_configuration(void)
Return the libavfilter build-time configuration.
AVFilterPad * input_pads
array of input pads
AVFilterBufferRef * ff_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
Request a picture buffer with a specific set of permissions.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque)
Initialize a filter.
AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
int sample_rate
samples per second
enum AVFilterLink::@70 init_state
stage of the initialization of the link properties (dimensions, etc)
unsigned nb_outputs
number of output pads
void * priv
private data for use by the filter
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...
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.
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.
void avfilter_uninit(void)
Uninitialize the filter system.
int w
agreed upon image width
static void filter(MpegAudioContext *s, int ch, const short *samples, int incr)
struct AVRational AVRational
rational number numerator/denominator
audio channel layout utility functions
unsigned nb_inputs
number of input pads
int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name)
Create a filter instance.
AVFilterContext * src
source filter
AVFilter ** av_filter_next(AVFilter **filter)
If filter is NULL, returns a pointer to the first registered filter pointer, if filter is non-NULL...
AVFilterFormats * out_samplerates
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.
int format
agreed upon media format
const AVFilterPad * inputs
NULL terminated list of inputs. NULL if none.
A reference to an AVFilterBuffer.
AVFilterFormats * in_samplerates
Lists of channel layouts and sample rates used for automatic negotiation.
char * av_strdup(const char *s)
Duplicate the string s.
int perms
permissions, see the AV_PERM_* flags
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.
Describe the class of an AVClass context structure.
unsigned avfilter_version(void)
Return the LIBAVFILTER_VERSION_INT constant.
static const AVFilterPad inputs[]
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
enum AVMediaType avfilter_pad_get_type(AVFilterPad *pads, int pad_idx)
Get the type of an AVFilterPad.
int rej_perms
Permissions which are not accepted on incoming buffers.
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)
void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src)
Copy properties of src to dst, without copying the actual data.
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
AVFilterContext * dst
dest filter
AVFilter * filter
the AVFilter of which this is an instance
const AVClass * av_class
needed for av_log()
uint8_t * data[8]
picture/audio data for each plane
#define FF_DPRINTF_START(ctx, func)
AVFilterPad * srcpad
output pad on the source filter
const AVFilterPad * outputs
NULL terminated list of outputs. NULL if none.
int(* config_props)(AVFilterLink *link)
Link configuration callback.
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.
int ff_poll_frame(AVFilterLink *link)
Poll a frame from the filter chain.
int min_perms
Minimum required permissions on incoming buffers.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
AVFilterFormats * out_formats
#define AV_PERM_NEG_LINESIZES
the buffer requested can have negative linesizes
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.