libavfilter/avfilter.h File Reference

#include <stddef.h>
#include "libavcodec/avcodec.h"

Go to the source code of this file.

Data Structures

struct  AVFilterPic
 A reference-counted picture data type used by the filter system. More...
struct  AVFilterPicRef
 A reference to an AVFilterPic. More...
struct  AVFilterFormats
struct  AVFilterPad
 A filter pad used for either input or output. More...
struct  AVFilter
 Filter definition. More...
struct  AVFilterContext
 An instance of a filter. More...
struct  AVFilterLink
 A link between two filters. More...

Defines

#define LIBAVFILTER_VERSION_MAJOR   0
#define LIBAVFILTER_VERSION_MINOR   4
#define LIBAVFILTER_VERSION_MICRO   0
#define LIBAVFILTER_VERSION_INT
#define LIBAVFILTER_VERSION
#define LIBAVFILTER_BUILD   LIBAVFILTER_VERSION_INT
#define AV_PERM_READ   0x01
 can read from the buffer
#define AV_PERM_WRITE   0x02
 can write to the buffer
#define AV_PERM_PRESERVE   0x04
 nobody else can overwrite the buffer
#define AV_PERM_REUSE   0x08
 can output the buffer multiple times, with the same contents each time
#define AV_PERM_REUSE2   0x10
 can output the buffer multiple times, modified each time

Typedefs

typedef struct AVFilterContext AVFilterContext
typedef struct AVFilterLink AVFilterLink
typedef struct AVFilterPad AVFilterPad
typedef struct AVFilterFormats AVFilterFormats
 A list of supported formats for one end of a filter link.

Functions

unsigned avfilter_version (void)
 Returns the LIBAVFILTER_VERSION_INT constant.
AVFilterPicRefavfilter_ref_pic (AVFilterPicRef *ref, int pmask)
 Add a new reference to a picture.
void avfilter_unref_pic (AVFilterPicRef *ref)
 Remove a reference to a picture.
AVFilterFormatsavfilter_make_format_list (int len,...)
 Helper function to create a list of supported formats.
AVFilterFormatsavfilter_all_colorspaces (void)
 Returns a list of all colorspaces supported by FFmpeg.
AVFilterFormatsavfilter_merge_formats (AVFilterFormats *a, AVFilterFormats *b)
 Returns a format list which contains the intersection of the formats of a and b.
void avfilter_formats_ref (AVFilterFormats *formats, AVFilterFormats **ref)
 Adds *ref as a new reference to formats.
void avfilter_formats_unref (AVFilterFormats **ref)
 Remove *ref as a reference to the format list it currently points to, deallocate that list if this was the last reference, and set *ref to NULL.
void avfilter_formats_changeref (AVFilterFormats **oldref, AVFilterFormats **newref)
 Before After ________ ________ |formats |<---------.
void avfilter_default_start_frame (AVFilterLink *link, AVFilterPicRef *picref)
 default handler for start_frame() for video inputs
void avfilter_default_draw_slice (AVFilterLink *link, int y, int h)
 default handler for draw_slice() for video inputs
void avfilter_default_end_frame (AVFilterLink *link)
 default handler for end_frame() for video inputs
int avfilter_default_config_output_link (AVFilterLink *link)
 default handler for config_props() for video outputs
int avfilter_default_config_input_link (AVFilterLink *link)
 default handler for config_props() for video inputs
AVFilterPicRefavfilter_default_get_video_buffer (AVFilterLink *link, int perms)
 default handler for get_video_buffer() for video inputs
void avfilter_set_common_formats (AVFilterContext *ctx, AVFilterFormats *formats)
 A helper for query_formats() which sets all links to the same list of formats.
int avfilter_default_query_formats (AVFilterContext *ctx)
 Default handler for query_formats().
int avfilter_link (AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
 Link two filters together.
int avfilter_config_links (AVFilterContext *filter)
 Negotiate the colorspace, dimensions, etc of all inputs to a filter.
AVFilterPicRefavfilter_get_video_buffer (AVFilterLink *link, int perms)
 Request a picture 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, AVFilterPicRef *picref)
 Notify the next filter of the start of a frame.
void avfilter_end_frame (AVFilterLink *link)
 Notify the next filter that the current frame has finished.
void avfilter_draw_slice (AVFilterLink *link, int y, int h)
 Send a slice to the next filter.
void avfilter_register_all (void)
 Initialize the filter system.
void avfilter_uninit (void)
 Uninitialize the filter system.
void avfilter_register (AVFilter *filter)
 Register a filter.
AVFilteravfilter_get_by_name (const char *name)
 Gets a filter definition matching the given name.
AVFilterContextavfilter_open (AVFilter *filter, const char *inst_name)
 Create a filter instance.
int avfilter_init_filter (AVFilterContext *filter, const char *args, void *opaque)
 Initialize a filter.
void avfilter_destroy (AVFilterContext *filter)
 Destroy a filter.
int avfilter_insert_filter (AVFilterLink *link, AVFilterContext *filt, unsigned in, unsigned out)
 Insert a filter in the middle of an existing link.
void avfilter_insert_pad (unsigned idx, unsigned *count, size_t padidx_off, AVFilterPad **pads, AVFilterLink ***links, AVFilterPad *newpad)
 Insert a new pad.
static void avfilter_insert_inpad (AVFilterContext *f, unsigned index, AVFilterPad *p)
 Insert a new input pad for the filter.
static void avfilter_insert_outpad (AVFilterContext *f, unsigned index, AVFilterPad *p)
 Insert a new output pad for the filter.


Define Documentation

#define AV_PERM_PRESERVE   0x04

nobody else can overwrite the buffer

Definition at line 99 of file avfilter.h.

#define AV_PERM_READ   0x01

can read from the buffer

Definition at line 97 of file avfilter.h.

Referenced by avfilter_default_get_video_buffer().

#define AV_PERM_REUSE   0x08

can output the buffer multiple times, with the same contents each time

Definition at line 100 of file avfilter.h.

#define AV_PERM_REUSE2   0x10

can output the buffer multiple times, modified each time

Definition at line 101 of file avfilter.h.

#define AV_PERM_WRITE   0x02

can write to the buffer

Definition at line 98 of file avfilter.h.

Referenced by avfilter_default_start_frame().

#define LIBAVFILTER_BUILD   LIBAVFILTER_VERSION_INT

Definition at line 35 of file avfilter.h.

#define LIBAVFILTER_VERSION

#define LIBAVFILTER_VERSION_INT

#define LIBAVFILTER_VERSION_MAJOR   0

Definition at line 25 of file avfilter.h.

#define LIBAVFILTER_VERSION_MICRO   0

Definition at line 27 of file avfilter.h.

#define LIBAVFILTER_VERSION_MINOR   4

Definition at line 26 of file avfilter.h.


Typedef Documentation

Definition at line 45 of file avfilter.h.

A list of supported formats for one end of a filter link.

This is used during the format negotiation process to try to pick the best format to use to minimize the number of necessary conversions. Each filter gives a list of the formats supported by each input and output pad. The list given for each pad need not be distinct - they may be references to the same list of formats, as is often the case when a filter supports multiple formats, but will always output the same format as it is given in input.

In this way, a list of possible input formats and a list of possible output formats are associated with each link. When a set of formats is negotiated over a link, the input and output lists are merged to form a new list containing only the common elements of each list. In the case that there were no common elements, a format conversion is necessary. Otherwise, the lists are merged, and all other links which reference either of the format lists involved in the merge are also affected.

For example, consider the filter chain: filter (a) --> (b) filter (b) --> (c) filter

where the letters in parenthesis indicate a list of formats supported on the input or output of the link. Suppose the lists are as follows: (a) = {A, B} (b) = {A, B, C} (c) = {B, C}

First, the first link's lists are merged, yielding: filter (a) --> (a) filter (a) --> (c) filter

Notice that format list (b) now refers to the same list as filter list (a). Next, the lists for the second link are merged, yielding: filter (a) --> (a) filter (a) --> (a) filter

where (a) = {B}.

Unfortunately, when the format lists at the two ends of a link are merged, we must ensure that all links which reference either pre-merge format list get updated as well. Therefore, we have the format list structure store a pointer to each of the pointers to itself.

Definition at line 161 of file avfilter.h.

typedef struct AVFilterLink AVFilterLink

Definition at line 46 of file avfilter.h.

typedef struct AVFilterPad AVFilterPad

Definition at line 47 of file avfilter.h.


Function Documentation

AVFilterFormats* avfilter_all_colorspaces ( void   ) 

Returns a list of all colorspaces supported by FFmpeg.

Definition at line 93 of file formats.c.

Referenced by avfilter_default_query_formats().

int avfilter_config_links ( AVFilterContext filter  ) 

Negotiate the colorspace, 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 125 of file avfilter.c.

Referenced by avfilter_config_links().

int avfilter_default_config_input_link ( AVFilterLink link  ) 

default handler for config_props() for video inputs

int avfilter_default_config_output_link ( AVFilterLink link  ) 

default handler for config_props() for video outputs

Definition at line 118 of file defaults.c.

Referenced by avfilter_config_links().

void avfilter_default_draw_slice ( AVFilterLink link,
int  y,
int  h 
)

default handler for draw_slice() for video inputs

Definition at line 85 of file defaults.c.

Referenced by avfilter_draw_slice().

void avfilter_default_end_frame ( AVFilterLink link  ) 

default handler for end_frame() for video inputs

Definition at line 96 of file defaults.c.

Referenced by avfilter_end_frame().

AVFilterPicRef* avfilter_default_get_video_buffer ( AVFilterLink link,
int  perms 
)

default handler for get_video_buffer() for video inputs

Definition at line 39 of file defaults.c.

Referenced by avfilter_get_video_buffer(), and avfilter_start_frame().

int avfilter_default_query_formats ( AVFilterContext ctx  ) 

Default handler for query_formats().

Definition at line 164 of file defaults.c.

Referenced by query_formats().

void avfilter_default_start_frame ( AVFilterLink link,
AVFilterPicRef picref 
)

default handler for start_frame() for video inputs

Definition at line 71 of file defaults.c.

Referenced by avfilter_start_frame().

void avfilter_destroy ( AVFilterContext filter  ) 

Destroy a filter.

Parameters:
filter the filter to destroy

Definition at line 368 of file avfilter.c.

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

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

Send a slice to the next filter.

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

Definition at line 249 of file avfilter.c.

Referenced by avfilter_default_draw_slice().

void avfilter_end_frame ( AVFilterLink link  ) 

Notify the next filter that the current frame has finished.

Parameters:
link the output link the frame was sent over

Definition at line 231 of file avfilter.c.

Referenced by avfilter_default_end_frame().

void avfilter_formats_changeref ( AVFilterFormats **  oldref,
AVFilterFormats **  newref 
)

Before After ________ ________ |formats |<---------.

|formats |<---------. | ____ | ___|___ | ____ | ___|___ | |refs| | | | | | |refs| | | | | NULL | |* *--------->|*oldref| | |* *--------->|*newref| ^ | |* * | | |_______| | |* * | | |_______| ___|___ | |____| | | |____| | | | | |________| |________| |*oldref| |_______|

Definition at line 140 of file formats.c.

Referenced by avfilter_insert_filter().

void avfilter_formats_ref ( AVFilterFormats formats,
AVFilterFormats **  ref 
)

Adds *ref as a new reference to formats.

That is the pointers will point like in the ascii art below: ________ |formats |<--------. | ____ | ____|___________________ | |refs| | | __|_ | |* * | | | | | | AVFilterLink | |* *--------->|*ref| | |____| | | |____| |________| |________________________

Definition at line 108 of file formats.c.

Referenced by avfilter_set_common_formats().

void avfilter_formats_unref ( AVFilterFormats **  ref  ) 

Remove *ref as a reference to the format list it currently points to, deallocate that list if this was the last reference, and set *ref to NULL.

Before After ________ ________ NULL |formats |<--------. |formats | ^ | ____ | ____|________________ | ____ | ____|________________ | |refs| | | __|_ | |refs| | | __|_ | |* * | | | | | | AVFilterLink | |* * | | | | | | AVFilterLink | |* *--------->|*ref| | |* | | | |*ref| | |____| | | |____| | |____| | | |____| |________| |_____________________ |________| |_____________________

Definition at line 124 of file formats.c.

Referenced by pick_format().

AVFilter* avfilter_get_by_name ( const char *  name  ) 

Gets 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 288 of file avfilter.c.

Referenced by create_filter(), and query_formats().

AVFilterPicRef* avfilter_get_video_buffer ( AVFilterLink link,
int  perms 
)

Request a picture buffer with a specific set of permissions.

Parameters:
link the output link to the filter from which the picture will be requested
perms the required access permissions
Returns:
A reference to the picture. This must be unreferenced with avfilter_unref_pic when you are finished with it.

Definition at line 163 of file avfilter.c.

Referenced by avfilter_default_start_frame().

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 395 of file avfilter.c.

Referenced by create_filter().

int avfilter_insert_filter ( AVFilterLink link,
AVFilterContext filt,
unsigned  in,
unsigned  out 
)

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
in the input pad on the filter to connect
out the output pad on the filter to connect
Returns:
zero on success

Definition at line 98 of file avfilter.c.

Referenced by query_formats().

static void avfilter_insert_inpad ( AVFilterContext f,
unsigned  index,
AVFilterPad p 
) [inline, static]

Insert a new input pad for the filter.

Definition at line 620 of file avfilter.h.

static void avfilter_insert_outpad ( AVFilterContext f,
unsigned  index,
AVFilterPad p 
) [inline, static]

Insert a new output pad for the filter.

Definition at line 628 of file avfilter.h.

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 56 of file avfilter.c.

Referenced by avfilter_insert_inpad(), and avfilter_insert_outpad().

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 77 of file avfilter.c.

Referenced by avfilter_insert_filter(), and link_filter().

AVFilterFormats* avfilter_make_format_list ( int  len,
  ... 
)

Helper function to create a list of supported formats.

This is intended for use in AVFilter->query_formats().

Parameters:
len the number of formats supported
... a list of the supported formats
Returns:
the format list, with no existing references

Definition at line 75 of file formats.c.

AVFilterFormats* avfilter_merge_formats ( AVFilterFormats a,
AVFilterFormats b 
)

Returns a format list which contains the intersection of the formats of a and b.

Also, all the references of a, all the references of b, and a and b themselves will be deallocated.

If a and b do not share any common formats, neither is modified, and NULL is returned.

Definition at line 41 of file formats.c.

Referenced by query_formats().

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

Create a filter instance.

Parameters:
filter the filter to create an instance of
inst_name Name to give to the new instance. Can be NULL for none.
Returns:
Pointer to the new instance on success. NULL on failure.

Definition at line 337 of file avfilter.c.

Referenced by create_filter(), and query_formats().

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 185 of file avfilter.c.

Referenced by avfilter_poll_frame().

AVFilterPicRef* avfilter_ref_pic ( AVFilterPicRef ref,
int  pmask 
)

Add a new reference to a picture.

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

Definition at line 40 of file avfilter.c.

Referenced by avfilter_default_start_frame().

void 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

Definition at line 299 of file avfilter.c.

void avfilter_register_all ( void   ) 

Initialize the filter system.

Registers all builtin filters

Definition at line 29 of file allfilters.c.

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 176 of file avfilter.c.

Referenced by avfilter_request_frame().

void avfilter_set_common_formats ( AVFilterContext ctx,
AVFilterFormats formats 
)

A helper for query_formats() which sets all links to the same list of formats.

If there are no links hooked to this filter, the list of formats is freed.

If there are no links hooked to this filter, the list of formats is freed.

FIXME: this will need changed for filters with a mix of pad types (video + audio, etc)

Definition at line 140 of file defaults.c.

Referenced by avfilter_default_query_formats().

void avfilter_start_frame ( AVFilterLink link,
AVFilterPicRef 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 203 of file avfilter.c.

Referenced by avfilter_default_start_frame().

void avfilter_uninit ( void   ) 

Uninitialize the filter system.

Unregisters all filters

Definition at line 308 of file avfilter.c.

void avfilter_unref_pic ( AVFilterPicRef ref  ) 

Remove a reference to a picture.

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

Parameters:
ref reference to the picture

Definition at line 49 of file avfilter.c.

Referenced by avfilter_default_end_frame(), and avfilter_end_frame().

unsigned avfilter_version ( void   ) 

Returns the LIBAVFILTER_VERSION_INT constant.

Definition at line 25 of file avfilter.c.


Generated on Fri Oct 26 02:35:45 2012 for FFmpeg by  doxygen 1.5.8