43 #define LICENSE_PREFIX "libavfilter license: "
90 idx =
FFMIN(idx, *count);
94 memmove(*pads +idx+1, *pads +idx,
sizeof(
AVFilterPad) * (*count-idx));
95 memmove(*links+idx+1, *links+idx,
sizeof(
AVFilterLink*) * (*count-idx));
100 for (i = idx+1; i < *count; i++)
102 (*(
unsigned *)((uint8_t *) *links[i] + padidx_off))++;
116 "Media type mismatch between the '%s' filter output pad %d and the '%s' filter input pad %d\n",
117 src->
name, srcpad, dst->
name, dstpad);
136 unsigned filt_srcpad_idx,
unsigned filt_dstpad_idx)
142 "between the filter '%s' and the filter '%s'\n",
146 if ((ret =
avfilter_link(filt, filt_dstpad_idx, link->
dst, dstpad_idx)) < 0) {
155 filt->
inputs[filt_srcpad_idx] = link;
180 case AVLINK_STARTINIT:
191 if ((ret = config_link(link)) < 0)
209 if ((ret = config_link(link)) < 0)
220 static char *ff_get_ref_perms_string(
char *buf,
size_t buf_size,
int perms)
222 snprintf(buf, buf_size,
"%s%s%s%s%s%s",
237 "ref[%p buf:%p refcount:%d perms:%s data:%p linesize[%d, %d, %d, %d] pts:%"PRId64
" pos:%"PRId64,
243 av_dlog(ctx,
" a:%d/%d s:%dx%d i:%c iskey:%d type:%c",
252 av_dlog(ctx,
" cl:%"PRId64
"d sn:%d s:%d sr:%d p:%d",
260 av_dlog(ctx,
"]%s", end ?
"\n" :
"");
267 "link[%p s:%dx%d fmt:%-16s %-16s->%-16s]%s",
268 link, link->
w, link->
h,
278 "link[%p r:%"PRId64
" cl:%s fmt:%-16s %-16s->%-16s]%s",
287 #define FF_DPRINTF_START(ctx, func) av_dlog(NULL, "%-16s: ", #func)
295 av_dlog(
NULL,
" perms:%s w:%d h:%d\n", ff_get_ref_perms_string(buf,
sizeof(buf), perms), w, h);
336 memcpy(pic->
data, data, 4*
sizeof(data[0]));
337 memcpy(pic->
linesize, linesize, 4*
sizeof(linesize[0]));
344 if (picref && picref->
video)
353 uint64_t channel_layout,
int planar)
382 int i,
min = INT_MAX;
392 min =
FFMIN(min, val);
404 int perms = picref->
perms;
416 "frame copy needed (have perms %x, need %x, reject %x)\n",
449 uint8_t *src[4], *dst[4];
459 for (i = 0; i < 4; i++) {
462 (y >> (i==1 || i==2 ? vsub : 0)) * link->
src_buf-> linesize[i];
466 src[i] = dst[i] =
NULL;
469 for (i = 0; i < 4; i++) {
473 if (!src[i])
continue;
475 for (j = 0; j < h >> (i==1 || i==2 ? vsub : 0); j++) {
476 memcpy(dst[i], src[i], planew);
503 "Copying audio data in avfilter (have perms %x, need %x, reject %x)\n",
524 #define MAX_REGISTERED_AVFILTERS_NB 64
534 for (i = 0; registered_avfilters[i]; i++)
535 if (!strcmp(registered_avfilters[i]->name, name))
536 return registered_avfilters[i];
552 return filter ? ++filter : ®istered_avfilters[0];
557 memset(registered_avfilters, 0,
sizeof(registered_avfilters));
565 for(count = 0; pads->
name; count ++) pads ++;
649 if ((link = filter->
inputs[i])) {
658 if ((link = filter->
outputs[i])) {
681 ret = filter->
filter->
init(filter, args, opaque);
uint8_t * data[8]
buffer data for each plane/channel
int(* poll_frame)(AVFilterLink *link)
Frame poll callback.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
AVFilterBufferRef * avfilter_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
Request a picture buffer with a specific set of permissions.
int size
audio buffer size
int nb_samples
number of audio samples
AVFilterBufferRefAudioProps * audio
audio buffer specific properties
AVFilterBufferRefVideoProps * video
video buffer specific properties
static const char * filter_name(void *p)
static int next_registered_avfilter_idx
int linesize[8]
number of bytes per line
static void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src)
Copy properties of src to dst, without copying the actual data.
static int pad_count(const AVFilterPad *pads)
void avfilter_free(AVFilterContext *filter)
Free a filter context.
int h
agreed upon image height
int(* init)(AVFilterContext *ctx, const char *args, void *opaque)
Filter initialization function.
#define AV_PERM_REUSE
can output the buffer multiple times, with the same contents each time
enum AVMediaType type
media type of buffer data
static void ff_dlog_ref(void *ctx, AVFilterBufferRef *ref, int end)
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.
Audio specific properties in a reference to an AVFilterBuffer.
A reference-counted buffer data type used by the filter system.
enum AVMediaType type
AVFilterPad type.
#define LIBAVFILTER_VERSION_INT
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
AVFilterBufferRef * avfilter_default_get_audio_buffer(AVFilterLink *link, int perms, enum AVSampleFormat sample_fmt, int size, uint64_t channel_layout, int planar)
default handler for get_audio_buffer() for audio inputs
static void filter_samples(G722Context *c, const int16_t *samples, int *xlow, int *xhigh)
void(* start_frame)(AVFilterLink *link, AVFilterBufferRef *picref)
Callback called before passing the first slice of a new frame.
AVFilterPad * dstpad
input pad on the dest filter
const char * avfilter_license(void)
Return the libavfilter license.
void ff_avfilter_default_free_buffer(AVFilterBuffer *ptr)
default handler for freeing audio/video buffer when there are no references left
void(* end_frame)(AVFilterLink *link)
Callback called after the slices of a frame are completely sent.
#define FF_DPRINTF_START(ctx, func)
int h
width and height of the allocated buffer
void avfilter_default_start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
default handler for start_frame() for video inputs
static AVFilter * registered_avfilters[MAX_REGISTERED_AVFILTERS_NB+1]
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
static int request_frame(AVFilterLink *link)
enum AVFilterLink::@62 init_state
stage of the initialization of the link properties (dimensions, etc)
#define AV_PERM_READ
can read from the buffer
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
int avfilter_register(AVFilter *filter)
Register a filter.
int linesize[8]
number of bytes per line
int(* request_frame)(AVFilterLink *link)
Frame request callback.
int top_field_first
field order
void avfilter_default_end_frame(AVFilterLink *link)
default handler for end_frame() for video inputs
void avfilter_insert_pad(unsigned idx, unsigned *count, size_t padidx_off, AVFilterPad **pads, AVFilterLink ***links, AVFilterPad *newpad)
Insert a new pad.
void avfilter_end_frame(AVFilterLink *link)
Notifie the next filter that the current frame has finished.
int avfilter_config_links(AVFilterContext *filter)
Negotiate the media format, dimensions, etc of all inputs to a filter.
int64_t pts
presentation timestamp in time_base units (time when frame should be shown to user) If AV_NOPTS_VALUE...
unsigned input_count
number of input pads
int key_frame
1 -> keyframe, 0-> not
char av_get_picture_type_char(enum AVPictureType pict_type)
Return a single letter to describe the given picture type pict_type.
void(* filter_samples)(AVFilterLink *link, AVFilterBufferRef *samplesref)
Samples filtering callback.
int interlaced_frame
The content of the picture is interlaced.
void(* uninit)(AVFilterContext *ctx)
Filter uninitialization function.
static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
AVRational pixel_aspect
pixel aspect ratio
int64_t pts
presentation timestamp.
audio conversion routines
A filter pad used for either input or output.
int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src)
Copy the frame properties of src to dst, without copying the actual image data.
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
int width
width and height of the video frame
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.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
AVFilterBuffer * buf
the buffer that this is a reference to
AVFilterBufferRef *(* get_audio_buffer)(AVFilterLink *link, int perms, enum AVSampleFormat sample_fmt, int size, uint64_t channel_layout, int planar)
Callback function to get an audio buffer.
void * priv
private data for use by the filter
AVFilterBufferRef * avfilter_default_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
default handler for get_video_buffer() for video inputs
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
Video specific properties in a reference to an AVFilterBuffer.
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 AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB]
The array of all the pixel format descriptors.
int av_image_get_linesize(enum PixelFormat pix_fmt, int width, int plane)
Compute the size of an image line with format pix_fmt and width width for the plane plane...
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
unsigned output_count
number of output pads
int avfilter_poll_frame(AVFilterLink *link)
Poll a frame from the filter chain.
void avfilter_default_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
default handler for filter_samples() for audio inputs
static void ff_dlog_link(void *ctx, AVFilterLink *link, int end)
enum AVPictureType pict_type
Picture type of the frame, see ?_TYPE below.
void(* draw_slice)(AVFilterLink *link, int y, int height, int slice_dir)
Slice drawing callback.
AVFilterBufferRef * avfilter_get_audio_buffer(AVFilterLink *link, int perms, enum AVSampleFormat sample_fmt, int size, uint64_t channel_layout, int planar)
Request an audio samples buffer with a specific set of permissions.
unsigned refcount
number of references to this buffer
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...
void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
Send a slice to the next filter.
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 av_dlog(pctx,...)
av_dlog macros Useful to print debug messages that shouldn't get compiled in normally.
int format
agreed upon media format
const AVFilterPad * inputs
NULL terminated list of inputs. NULL if none.
void(* free)(struct AVFilterBuffer *buf)
A pointer to the function to deallocate this buffer if the default function is not sufficient...
int64_t sample_rate
samples per second
void avfilter_unref_buffer(AVFilterBufferRef *ref)
Remove a reference to a buffer.
int format
format of the frame, -1 if unknown or unset Values correspond to enum PixelFormat for video frames...
A reference to an AVFilterBuffer.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
char * av_strdup(const char *s)
Duplicate the string s.
int perms
permissions, see the AV_PERM_* flags
uint32_t sample_rate
audio buffer sample rate
static void(WINAPI *cond_broadcast)(pthread_cond_t *cond)
AVRational sample_aspect_ratio
sample aspect ratio for the video frame, 0/1 if unknown
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int avfilter_default_config_output_link(AVFilterLink *link)
default handler for config_props() for audio/video outputs
static int start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
enum AVPictureType pict_type
picture type of the frame
Describe the class of an AVClass context structure.
AVFilterBufferRef * src_buf
The buffer reference currently being sent across the link by the source filter.
unsigned avfilter_version(void)
Return the LIBAVFILTER_VERSION_INT constant.
AVFilterBufferRef * avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask)
Add a new reference to a buffer.
void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
Notify the next filter of the start of a frame.
int avfilter_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
const char * name
filter name
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
AVFilterBufferRef * avfilter_get_video_buffer_ref_from_arrays(uint8_t *data[4], int linesize[4], int perms, int w, int h, enum PixelFormat format)
Create a buffer reference wrapped around an already allocated image buffer.
uint64_t channel_layout
channel layout of audio buffer
AVFilterLink ** outputs
array of pointers to output links
AVFilterBufferRef *(* get_video_buffer)(AVFilterLink *link, int perms, int w, int h)
Callback function to get a video buffer.
int planar
audio buffer - planar or packed
#define AV_PERM_PRESERVE
nobody else can overwrite the buffer
enum AVMediaType type
filter media type
int rej_perms
Permissions which are not accepted on incoming buffers.
static AVFilterBufferRef * get_video_buffer(AVFilterLink *inlink, int perms, int w, int h)
int interlaced
is frame interlaced
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
void avfilter_formats_changeref(AVFilterFormats **oldref, AVFilterFormats **newref)
Before After |formats |<------—.
AVSampleFormat
all in native-endian format
uint64_t channel_layout
channel layout of current buffer (see libavutil/audioconvert.h)
#define AV_PERM_REUSE2
can output the buffer multiple times, modified each time
void avfilter_default_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
default handler for draw_slice() for video inputs
#define AV_PERM_WRITE
can write to the buffer
int64_t pos
byte position in stream, -1 if unknown
int top_field_first
If the content is interlaced, is top field displayed first.
void avfilter_formats_unref(AVFilterFormats **ref)
If *ref is non-NULL, remove *ref as a reference to the format list it currently points to...
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
int key_frame
1 -> keyframe, 0-> not
AVFilterBufferRef * cur_buf
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.
int min_perms
Minimum required permissions on incoming buffers.
void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
Send a buffer of audio samples to the next filter.
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.
static int end_frame(AVCodecContext *avctx)