libavfilter/avfilter.c File Reference

#include "libavutil/pixdesc.h"
#include "libavutil/rational.h"
#include "libavutil/audioconvert.h"
#include "libavutil/imgutils.h"
#include "libavcodec/avcodec.h"
#include "avfilter.h"
#include "internal.h"

Go to the source code of this file.

Defines

#define LICENSE_PREFIX   "libavfilter license: "
#define FF_DPRINTF_START(ctx, func)   av_dlog(NULL, "%-16s: ", #func)
#define MAX_REGISTERED_AVFILTERS_NB   64

Functions

unsigned avfilter_version (void)
 Return the LIBAVFILTER_VERSION_INT constant.
const char * avfilter_configuration (void)
 Return the libavfilter build-time configuration.
const char * avfilter_license (void)
 Return the libavfilter license.
AVFilterBufferRefavfilter_ref_buffer (AVFilterBufferRef *ref, int pmask)
 Add a new reference to a buffer.
void avfilter_unref_buffer (AVFilterBufferRef *ref)
 Remove a reference to a buffer.
void avfilter_insert_pad (unsigned idx, unsigned *count, size_t padidx_off, AVFilterPad **pads, AVFilterLink ***links, AVFilterPad *newpad)
 Insert a new pad.
int avfilter_link (AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
 Link two filters together.
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 avfilter_config_links (AVFilterContext *filter)
 Negotiate the media format, dimensions, etc of all inputs to a filter.
static void ff_dlog_ref (void *ctx, AVFilterBufferRef *ref, int end)
static void ff_dlog_link (void *ctx, AVFilterLink *link, int end)
AVFilterBufferRefavfilter_get_video_buffer (AVFilterLink *link, int perms, int w, int h)
 Request a picture buffer with a specific set of permissions.
AVFilterBufferRefavfilter_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.
AVFilterBufferRefavfilter_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.
int avfilter_request_frame (AVFilterLink *link)
 Request an input frame from the filter at the other end of the link.
int avfilter_poll_frame (AVFilterLink *link)
 Poll a frame from the filter chain.
void avfilter_start_frame (AVFilterLink *link, AVFilterBufferRef *picref)
 Notify the next filter of the start of a frame.
void avfilter_end_frame (AVFilterLink *link)
 Notifie the next filter that the current frame has finished.
void avfilter_draw_slice (AVFilterLink *link, int y, int h, int slice_dir)
 Send a slice to the next filter.
void avfilter_filter_samples (AVFilterLink *link, AVFilterBufferRef *samplesref)
 Send a buffer of audio samples to the next filter.
AVFilteravfilter_get_by_name (const char *name)
 Get a filter definition matching the given name.
int avfilter_register (AVFilter *filter)
 Register a 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, returns the next pointer after filter.
void avfilter_uninit (void)
 Uninitialize the filter system.
static int pad_count (const AVFilterPad *pads)
static const char * filter_name (void *p)
int avfilter_open (AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name)
 Create a filter instance.
void avfilter_free (AVFilterContext *filter)
 Free a filter context.
int avfilter_init_filter (AVFilterContext *filter, const char *args, void *opaque)
 Initialize a filter.
int avfilter_copy_frame_props (AVFilterBufferRef *dst, const AVFrame *src)
 Copy the frame properties of src to dst, without copying the actual image data.

Variables

static AVFilterregistered_avfilters [MAX_REGISTERED_AVFILTERS_NB+1]
static int next_registered_avfilter_idx = 0
static const AVClass avfilter_class

Define Documentation

#define FF_DPRINTF_START (   ctx,
  func 
)    av_dlog(NULL, "%-16s: ", #func)
#define LICENSE_PREFIX   "libavfilter license: "
#define MAX_REGISTERED_AVFILTERS_NB   64

Definition at line 524 of file avfilter.c.

Referenced by avfilter_register().


Function Documentation

AVFilter** av_filter_next ( AVFilter **  filter  ) 

If filter is NULL, returns a pointer to the first registered filter pointer, if filter is non-NULL, returns the next pointer after filter.

If the returned pointer points to NULL, the last registered filter was already reached.

Definition at line 550 of file avfilter.c.

Referenced by show_filters().

int avfilter_config_links ( AVFilterContext filter  ) 

Negotiate the media format, dimensions, etc of all inputs to a filter.

Parameters:
filter the filter to negotiate the properties for its inputs
Returns:
zero on successful negotiation

Definition at line 166 of file avfilter.c.

Referenced by avfilter_config_links(), and ff_avfilter_graph_config_links().

const char* avfilter_configuration ( void   ) 

Return the libavfilter build-time configuration.

Definition at line 36 of file avfilter.c.

int avfilter_copy_frame_props ( AVFilterBufferRef dst,
const AVFrame src 
)

Copy the frame properties of src to dst, without copying the actual image data.

Returns:
0 on success, a negative number on error.

Definition at line 685 of file avfilter.c.

Referenced by av_vsrc_buffer_add_frame(), movie_get_frame(), and transcode_video().

void avfilter_draw_slice ( AVFilterLink link,
int  y,
int  h,
int  slice_dir 
)

Send a slice to the next filter.

Slices have to be provided in sequential order, either in top-bottom or bottom-top order. If slices are provided in non-sequential order the behavior of the function is undefined.

Parameters:
link the output link over which the frame is being sent
y offset in pixels from the top of the image for this slice
h height of this slice in pixels
slice_dir the assumed direction for sending slices, from the top slice to the bottom slice if the value is 1, from the bottom slice to the top slice if the value is -1, for other values the behavior of the function is undefined.

Definition at line 447 of file avfilter.c.

Referenced by avfilter_default_draw_slice(), avfilter_null_draw_slice(), color_request_frame(), draw_send_bar_slice(), draw_slice(), end_frame(), request_frame(), and return_frame().

void avfilter_end_frame ( AVFilterLink link  ) 

Notifie the next filter that the current frame has finished.

Parameters:
link the output link the frame was sent over

Definition at line 430 of file avfilter.c.

Referenced by avfilter_default_end_frame(), avfilter_null_end_frame(), color_request_frame(), end_frame(), request_frame(), and return_frame().

void avfilter_filter_samples ( AVFilterLink link,
AVFilterBufferRef samplesref 
)

Send a buffer of audio samples to the next filter.

Parameters:
link the output link over which the audio samples are being sent
samplesref a reference to the buffer of audio samples being sent. The receiving filter will free this reference when it no longer needs it or pass it on to the next filter.

Definition at line 488 of file avfilter.c.

Referenced by avfilter_default_filter_samples(), and avfilter_null_filter_samples().

void avfilter_free ( AVFilterContext filter  ) 

Free a filter context.

Parameters:
filter the filter to free

Definition at line 640 of file avfilter.c.

Referenced by avfilter_graph_create_filter(), avfilter_graph_free(), avfilter_graph_parse(), create_filter(), and main().

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.

Parameters:
link the output link to the filter from which the buffer will be requested
perms the required access permissions
sample_fmt the format of each sample in the buffer to allocate
size the buffer size in bytes
channel_layout the number and type of channels per sample in the buffer to allocate
planar audio data layout - planar or packed
Returns:
A reference to the samples. This must be unreferenced with avfilter_unref_buffer when you are finished with it.

Definition at line 351 of file avfilter.c.

Referenced by avfilter_null_get_audio_buffer().

AVFilter* avfilter_get_by_name ( const char *  name  ) 

Get a filter definition matching the given name.

Parameters:
name the filter name to find
Returns:
the filter definition, if any matching one is registered. NULL if none found.

Definition at line 530 of file avfilter.c.

Referenced by create_filter(), main(), and query_formats().

AVFilterBufferRef* avfilter_get_video_buffer ( AVFilterLink link,
int  perms,
int  w,
int  h 
)

Request a picture buffer with a specific set of permissions.

Parameters:
link the output link to the filter from which the buffer will be requested
perms the required access permissions
w the minimum width of the buffer to allocate
h the minimum height of the buffer to allocate
Returns:
A reference to the buffer. This must be unreferenced with avfilter_unref_buffer when you are finished with it.

Definition at line 289 of file avfilter.c.

Referenced by av_vsrc_buffer_add_frame(), avfilter_default_start_frame(), avfilter_null_get_video_buffer(), avfilter_start_frame(), color_request_frame(), get_video_buffer(), movie_get_frame(), request_frame(), return_frame(), source_request_frame(), and start_frame().

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.

Parameters:
data pointers to the planes of the image to reference
linesize linesizes for the planes of the image to reference
perms the required access permissions
w the width of the image specified by the data and linesize arrays
h the height of the image specified by the data and linesize arrays
format the pixel format of the image specified by the data and linesize arrays

Definition at line 312 of file avfilter.c.

Referenced by avfilter_default_get_video_buffer(), and transcode_video().

int avfilter_init_filter ( AVFilterContext filter,
const char *  args,
void *  opaque 
)

Initialize a filter.

Parameters:
filter the filter to initialize
args A string of parameters to use when initializing the filter. The format and meaning of this string varies by filter.
opaque Any extra non-string data needed by the filter. The meaning of this parameter varies by filter.
Returns:
zero on success

Definition at line 676 of file avfilter.c.

Referenced by avfilter_graph_create_filter(), create_filter(), and main().

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.

Parameters:
link the link into which the filter should be inserted
filt the filter to be inserted
filt_srcpad_idx the input pad on the filter to connect
filt_dstpad_idx the output pad on the filter to connect
Returns:
zero on success

Definition at line 135 of file avfilter.c.

Referenced by query_formats().

void avfilter_insert_pad ( unsigned  idx,
unsigned *  count,
size_t  padidx_off,
AVFilterPad **  pads,
AVFilterLink ***  links,
AVFilterPad newpad 
)

Insert a new pad.

Parameters:
idx Insertion point. Pad is inserted at the end if this point is beyond the end of the list of pads.
count Pointer to the number of pads in the list
padidx_off Offset within an AVFilterLink structure to the element to increment when inserting a new pad causes link numbering to change
pads Pointer to the pointer to the beginning of the list of pads
links Pointer to the pointer to the beginning of the list of links
newpad The new pad to add. A copy is made when adding.

Definition at line 84 of file avfilter.c.

Referenced by avfilter_insert_inpad(), and avfilter_insert_outpad().

const char* avfilter_license ( void   ) 

Return the libavfilter license.

Definition at line 41 of file avfilter.c.

int avfilter_link ( AVFilterContext src,
unsigned  srcpad,
AVFilterContext dst,
unsigned  dstpad 
)

Link two filters together.

Parameters:
src the source filter
srcpad index of the output pad on the source filter
dst the destination filter
dstpad index of the input pad on the destination filter
Returns:
zero on success

Definition at line 105 of file avfilter.c.

Referenced by avfilter_insert_filter(), and link_filter().

int avfilter_open ( AVFilterContext **  filter_ctx,
AVFilter filter,
const char *  inst_name 
)

Create a filter instance.

Parameters:
filter_ctx put here a pointer to the created filter context on success, NULL on failure
filter the filter to create an instance of
inst_name Name to give to the new instance. Can be NULL for none.
Returns:
>= 0 in case of success, a negative error code otherwise

Definition at line 582 of file avfilter.c.

Referenced by avfilter_graph_create_filter(), create_filter(), and main().

int avfilter_poll_frame ( AVFilterLink link  ) 

Poll a frame from the filter chain.

Parameters:
link the input link
Returns:
the number of immediately available frames, a negative number in case of error

Definition at line 380 of file avfilter.c.

Referenced by avfilter_poll_frame(), output_packet(), poll_frame(), and transcode_video().

AVFilterBufferRef* avfilter_ref_buffer ( AVFilterBufferRef ref,
int  pmask 
)

Add a new reference to a buffer.

Parameters:
ref an existing reference to the buffer
pmask a bitmask containing the allowable permissions in the new reference
Returns:
a new reference to the buffer with the same properties as the old, excluding any permissions denied by pmask

Definition at line 47 of file avfilter.c.

Referenced by avfilter_default_filter_samples(), avfilter_default_start_frame(), color_request_frame(), request_frame(), source_request_frame(), and start_frame().

int avfilter_register ( AVFilter filter  ) 

Register a filter.

This is only needed if you plan to use avfilter_get_by_name later to lookup the AVFilter structure by name. A filter can still by instantiated with avfilter_open even if it is not registered.

Parameters:
filter the filter to register
Returns:
0 if the registration was succesfull, a negative value otherwise

Definition at line 541 of file avfilter.c.

Referenced by avfilter_register_all().

int avfilter_request_frame ( AVFilterLink link  ) 

Request an input frame from the filter at the other end of the link.

Parameters:
link the input link
Returns:
zero on success

Definition at line 369 of file avfilter.c.

Referenced by avfilter_request_frame(), poll_frame(), request_frame(), and start_frame().

void avfilter_start_frame ( AVFilterLink link,
AVFilterBufferRef picref 
)

Notify the next filter of the start of a frame.

Parameters:
link the output link the frame will be sent over
picref A reference to the frame about to be sent. The data for this frame need only be valid once draw_slice() is called for that portion. The receiving filter will free this reference when it no longer needs it.

Definition at line 400 of file avfilter.c.

Referenced by avfilter_default_start_frame(), avfilter_null_start_frame(), color_request_frame(), request_frame(), return_frame(), source_request_frame(), and start_frame().

void avfilter_uninit ( void   ) 

Uninitialize the filter system.

Unregister all filters.

Definition at line 555 of file avfilter.c.

Referenced by do_exit(), and exit_program().

void avfilter_unref_buffer ( AVFilterBufferRef ref  ) 

Remove a reference to a buffer.

If this is the last reference to the buffer, the buffer itself is also automatically freed.

Parameters:
ref reference to the buffer, may be NULL

Definition at line 73 of file avfilter.c.

Referenced by alloc_picture(), avfilter_default_end_frame(), avfilter_default_filter_samples(), avfilter_end_frame(), avfilter_filter_samples(), color_request_frame(), end_frame(), output_packet(), queue_picture(), request_frame(), start_frame(), stream_close(), transcode_video(), and uninit().

unsigned avfilter_version ( void   ) 

Return the LIBAVFILTER_VERSION_INT constant.

Definition at line 32 of file avfilter.c.

static void ff_dlog_link ( void *  ctx,
AVFilterLink link,
int  end 
) [static]
static void ff_dlog_ref ( void *  ctx,
AVFilterBufferRef ref,
int  end 
) [static]

Definition at line 233 of file avfilter.c.

Referenced by avfilter_get_video_buffer(), and avfilter_start_frame().

static const char* filter_name ( void *  p  )  [static]

Definition at line 569 of file avfilter.c.

static int pad_count ( const AVFilterPad pads  )  [static]

Definition at line 561 of file avfilter.c.

Referenced by avfilter_open().


Variable Documentation

const AVClass avfilter_class [static]
Initial value:
 {
    "AVFilter",
    filter_name,
    NULL,
    LIBAVUTIL_VERSION_INT,
}

Definition at line 575 of file avfilter.c.

int next_registered_avfilter_idx = 0 [static]

Definition at line 528 of file avfilter.c.

Referenced by avfilter_register(), and avfilter_uninit().

AVFilter* registered_avfilters[MAX_REGISTERED_AVFILTERS_NB+1] [static]

Definition at line 526 of file avfilter.c.