libavfilter/avfilter.h File Reference

#include "libavutil/avutil.h"
#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   1
#define LIBAVFILTER_VERSION_MINOR   19
#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.
const char * avfilter_configuration (void)
 Returns the libavfilter build-time configuration.
const char * avfilter_license (void)
 Returns the libavfilter license.
AVFilterPicRefavfilter_ref_pic (AVFilterPicRef *ref, int pmask)
 Adds a new reference to a picture.
void avfilter_unref_pic (AVFilterPicRef *ref)
 Removes a reference to a picture.
AVFilterFormatsavfilter_make_format_list (const enum PixelFormat *pix_fmts)
 Creates a list of supported formats.
int avfilter_add_colorspace (AVFilterFormats **avff, enum PixelFormat pix_fmt)
 Adds pix_fmt to the list of pixel formats contained in *avff.
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)
 If *ref is non-NULL, removes *ref as a reference to the format list it currently points to, deallocates that list if this was the last reference, and sets *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, int slice_dir)
 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, int w, int h)
 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().
void avfilter_null_start_frame (AVFilterLink *link, AVFilterPicRef *picref)
 start_frame() handler for filters which simply pass video along
void avfilter_null_draw_slice (AVFilterLink *link, int y, int h, int slice_dir)
 draw_slice() handler for filters which simply pass video along
void avfilter_null_end_frame (AVFilterLink *link)
 end_frame() handler for filters which simply pass video along
AVFilterPicRefavfilter_null_get_video_buffer (AVFilterLink *link, int perms, int w, int h)
 get_video_buffer() handler for filters which simply pass video along
int avfilter_link (AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
 Links two filters together.
int avfilter_config_links (AVFilterContext *filter)
 Negotiates the colorspace, dimensions, etc of all inputs to a filter.
AVFilterPicRefavfilter_get_video_buffer (AVFilterLink *link, int perms, int w, int h)
 Requests a picture buffer with a specific set of permissions.
int avfilter_request_frame (AVFilterLink *link)
 Requests an input frame from the filter at the other end of the link.
int avfilter_poll_frame (AVFilterLink *link)
 Polls a frame from the filter chain.
void avfilter_start_frame (AVFilterLink *link, AVFilterPicRef *picref)
 Notifies the next filter of the start of a frame.
void avfilter_end_frame (AVFilterLink *link)
 Notifies the next filter that the current frame has finished.
void avfilter_draw_slice (AVFilterLink *link, int y, int h, int slice_dir)
 Sends a slice to the next filter.
void avfilter_register_all (void)
 Initializes the filter system.
void avfilter_uninit (void)
 Uninitializes the filter system.
int avfilter_register (AVFilter *filter)
 Registers a filter.
AVFilteravfilter_get_by_name (const char *name)
 Gets a filter definition matching the given name.
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.
AVFilterContextavfilter_open (AVFilter *filter, const char *inst_name)
 Creates a filter instance.
int avfilter_init_filter (AVFilterContext *filter, const char *args, void *opaque)
 Initializes a filter.
void avfilter_destroy (AVFilterContext *filter)
 Destroys a filter.
int avfilter_insert_filter (AVFilterLink *link, AVFilterContext *filt, unsigned in, unsigned out)
 Inserts 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)
 Inserts a new pad.
static void avfilter_insert_inpad (AVFilterContext *f, unsigned index, AVFilterPad *p)
 Inserts a new input pad for the filter.
static void avfilter_insert_outpad (AVFilterContext *f, unsigned index, AVFilterPad *p)
 Inserts a new output pad for the filter.


Define Documentation

#define AV_PERM_PRESERVE   0x04

nobody else can overwrite the buffer

Definition at line 115 of file avfilter.h.

#define AV_PERM_READ   0x01

can read from the buffer

Definition at line 113 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 116 of file avfilter.h.

#define AV_PERM_REUSE2   0x10

can output the buffer multiple times, modified each time

Definition at line 117 of file avfilter.h.

#define AV_PERM_WRITE   0x02

can write to the buffer

Definition at line 114 of file avfilter.h.

Referenced by avfilter_default_start_frame(), and start_frame().

#define LIBAVFILTER_BUILD   LIBAVFILTER_VERSION_INT

Definition at line 37 of file avfilter.h.

#define LIBAVFILTER_VERSION

#define LIBAVFILTER_VERSION_INT

#define LIBAVFILTER_VERSION_MAJOR   1

Definition at line 27 of file avfilter.h.

#define LIBAVFILTER_VERSION_MICRO   0

Definition at line 29 of file avfilter.h.

#define LIBAVFILTER_VERSION_MINOR   19

Definition at line 28 of file avfilter.h.


Typedef Documentation

Definition at line 58 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 177 of file avfilter.h.

typedef struct AVFilterLink AVFilterLink

Definition at line 59 of file avfilter.h.

typedef struct AVFilterPad AVFilterPad

Definition at line 60 of file avfilter.h.


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

Referenced by show_filters().

int avfilter_add_colorspace ( AVFilterFormats **  avff,
enum PixelFormat  pix_fmt 
)

Adds pix_fmt to the list of pixel formats contained in *avff.

If *avff is NULL the function allocates the filter formats struct and puts its pointer in *avff.

Returns:
a non negative value in case of success, or a negative value corresponding to an AVERROR code in case of error

Definition at line 92 of file formats.c.

Referenced by avfilter_all_colorspaces(), and query_formats().

AVFilterFormats* avfilter_all_colorspaces ( void   ) 

Returns a list of all colorspaces supported by FFmpeg.

Definition at line 109 of file formats.c.

Referenced by avfilter_default_query_formats().

int avfilter_config_links ( AVFilterContext filter  ) 

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

Referenced by avfilter_config_links(), and avfilter_graph_config_links().

const char* avfilter_configuration ( void   ) 

Returns the libavfilter build-time configuration.

Definition at line 32 of file avfilter.c.

Referenced by show_banner().

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 116 of file defaults.c.

Referenced by avfilter_config_links().

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

default handler for draw_slice() for video inputs

Definition at line 83 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 94 of file defaults.c.

Referenced by avfilter_end_frame().

AVFilterPicRef* avfilter_default_get_video_buffer ( AVFilterLink link,
int  perms,
int  w,
int  h 
)

default handler for get_video_buffer() for video inputs

Definition at line 35 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 162 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 67 of file defaults.c.

Referenced by avfilter_start_frame().

void avfilter_destroy ( AVFilterContext filter  ) 

Destroys a filter.

Parameters:
filter the filter to destroy

Definition at line 424 of file avfilter.c.

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

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

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

Referenced by avfilter_default_draw_slice(), avfilter_null_draw_slice(), draw_slice(), and end_frame().

void avfilter_end_frame ( AVFilterLink link  ) 

Notifies the next filter that the current frame has finished.

Parameters:
link the output link the frame was sent over

Definition at line 276 of file avfilter.c.

Referenced by avfilter_default_end_frame(), avfilter_null_end_frame(), and end_frame().

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

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

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

Definition at line 158 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 121 of file formats.c.

Referenced by avfilter_set_common_formats(), and query_formats().

void avfilter_formats_unref ( AVFilterFormats **  ref  ) 

If *ref is non-NULL, removes *ref as a reference to the format list it currently points to, deallocates that list if this was the last reference, and sets *ref to NULL.

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

Definition at line 137 of file formats.c.

Referenced by pick_format(), and query_formats().

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

Referenced by create_filter(), and query_formats().

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

Requests 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
w the minimum width of the buffer to allocate
h the minimum height of the buffer to allocate
Returns:
A reference to the picture. This must be unreferenced with avfilter_unref_pic when you are finished with it.

Definition at line 196 of file avfilter.c.

Referenced by avfilter_default_start_frame(), avfilter_null_get_video_buffer(), get_video_buffer(), and start_frame().

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

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

Referenced by create_filter(), and video_thread().

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

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

Referenced by query_formats().

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

Inserts a new input pad for the filter.

Definition at line 688 of file avfilter.h.

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

Inserts a new output pad for the filter.

Definition at line 696 of file avfilter.h.

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

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

Referenced by avfilter_insert_inpad(), and avfilter_insert_outpad().

const char* avfilter_license ( void   ) 

Returns the libavfilter license.

Definition at line 37 of file avfilter.c.

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

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

Referenced by avfilter_insert_filter(), link_filter(), and video_thread().

AVFilterFormats* avfilter_make_format_list ( const enum PixelFormat pix_fmts  ) 

Creates a list of supported formats.

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

Parameters:
pix_fmt list of pixel formats, terminated by PIX_FMT_NONE
Returns:
the format list, with no existing references

Definition at line 76 of file formats.c.

Referenced by query_formats().

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 42 of file formats.c.

Referenced by query_formats().

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

draw_slice() handler for filters which simply pass video along

Definition at line 173 of file defaults.c.

void avfilter_null_end_frame ( AVFilterLink link  ) 

end_frame() handler for filters which simply pass video along

Definition at line 178 of file defaults.c.

AVFilterPicRef* avfilter_null_get_video_buffer ( AVFilterLink link,
int  perms,
int  w,
int  h 
)

get_video_buffer() handler for filters which simply pass video along

Definition at line 183 of file defaults.c.

void avfilter_null_start_frame ( AVFilterLink link,
AVFilterPicRef picref 
)

start_frame() handler for filters which simply pass video along

Definition at line 168 of file defaults.c.

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

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

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

int avfilter_poll_frame ( AVFilterLink link  ) 

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

Referenced by avfilter_poll_frame().

AVFilterPicRef* avfilter_ref_pic ( AVFilterPicRef ref,
int  pmask 
)

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

Referenced by avfilter_default_start_frame(), and start_frame().

int avfilter_register ( AVFilter filter  ) 

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

void avfilter_register_all ( void   ) 

Initializes the filter system.

Registers all builtin filters.

Definition at line 29 of file allfilters.c.

Referenced by main().

int avfilter_request_frame ( AVFilterLink link  ) 

Requests 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 213 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 138 of file defaults.c.

Referenced by avfilter_default_query_formats(), and query_formats().

void avfilter_start_frame ( AVFilterLink link,
AVFilterPicRef picref 
)

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

Referenced by avfilter_default_start_frame(), avfilter_null_start_frame(), and start_frame().

void avfilter_uninit ( void   ) 

Uninitializes the filter system.

Unregisters all filters.

Definition at line 366 of file avfilter.c.

Referenced by do_exit().

void avfilter_unref_pic ( AVFilterPicRef ref  ) 

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

Referenced by alloc_picture(), avfilter_default_end_frame(), avfilter_end_frame(), end_frame(), queue_picture(), and stream_close().

unsigned avfilter_version ( void   ) 

Returns the LIBAVFILTER_VERSION_INT constant.

Definition at line 28 of file avfilter.c.


Generated on Fri Oct 26 02:36:54 2012 for FFmpeg by  doxygen 1.5.8