avfilter.h File Reference
#include "libavutil/avutil.h"
#include "libavutil/log.h"
#include "libavutil/samplefmt.h"
#include "libavutil/pixfmt.h"
#include "libavutil/rational.h"
#include "libavcodec/avcodec.h"
#include <stddef.h>
#include "libavfilter/version.h"

Go to the source code of this file.

Data Structures

struct  AVFilterBuffer
 A reference-counted buffer data type used by the filter system. More...
 
struct  AVFilterBufferRefAudioProps
 Audio specific properties in a reference to an AVFilterBuffer. More...
 
struct  AVFilterBufferRefVideoProps
 Video specific properties in a reference to an AVFilterBuffer. More...
 
struct  AVFilterBufferRef
 A reference to an AVFilterBuffer. More...
 
struct  AVFilter
 Filter definition. More...
 
struct  AVFilterContext
 An instance of a filter. More...
 
struct  AVFilterLink
 A link between two filters. More...
 

Macros

#define AV_PERM_READ   0x01
 can read from the buffer More...
 
#define AV_PERM_WRITE   0x02
 can write to the buffer More...
 
#define AV_PERM_PRESERVE   0x04
 nobody else can overwrite the buffer More...
 
#define AV_PERM_REUSE   0x08
 can output the buffer multiple times, with the same contents each time More...
 
#define AV_PERM_REUSE2   0x10
 can output the buffer multiple times, modified each time More...
 
#define AV_PERM_NEG_LINESIZES   0x20
 the buffer requested can have negative linesizes More...
 

Typedefs

typedef struct AVFilterContext AVFilterContext
 
typedef struct AVFilterLink AVFilterLink
 
typedef struct AVFilterPad AVFilterPad
 
typedef struct AVFilterFormats AVFilterFormats
 
typedef struct AVFilterBuffer AVFilterBuffer
 A reference-counted buffer data type used by the filter system. More...
 
typedef struct
AVFilterBufferRefAudioProps 
AVFilterBufferRefAudioProps
 Audio specific properties in a reference to an AVFilterBuffer. More...
 
typedef struct
AVFilterBufferRefVideoProps 
AVFilterBufferRefVideoProps
 Video specific properties in a reference to an AVFilterBuffer. More...
 
typedef struct AVFilterBufferRef AVFilterBufferRef
 A reference to an AVFilterBuffer. More...
 
typedef struct AVFilter AVFilter
 Filter definition. More...
 

Functions

unsigned avfilter_version (void)
 Return the LIBAVFILTER_VERSION_INT constant. More...
 
const char * avfilter_configuration (void)
 Return the libavfilter build-time configuration. More...
 
const char * avfilter_license (void)
 Return the libavfilter license. More...
 
void avfilter_copy_buffer_ref_props (AVFilterBufferRef *dst, AVFilterBufferRef *src)
 Copy properties of src to dst, without copying the actual data. More...
 
AVFilterBufferRefavfilter_ref_buffer (AVFilterBufferRef *ref, int pmask)
 Add a new reference to a buffer. More...
 
void avfilter_unref_buffer (AVFilterBufferRef *ref)
 Remove a reference to a buffer. More...
 
void avfilter_unref_bufferp (AVFilterBufferRef **ref)
 Remove a reference to a buffer and set the pointer to NULL. More...
 
const char * avfilter_pad_get_name (AVFilterPad *pads, int pad_idx)
 Get the name of an AVFilterPad. More...
 
enum AVMediaType avfilter_pad_get_type (AVFilterPad *pads, int pad_idx)
 Get the type of an AVFilterPad. More...
 
int avfilter_link (AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
 Link two filters together. More...
 
int avfilter_config_links (AVFilterContext *filter)
 Negotiate the media format, dimensions, etc of all inputs to a filter. More...
 
AVFilterBufferRefavfilter_get_video_buffer_ref_from_arrays (uint8_t *data[4], int linesize[4], int perms, int w, int h, enum AVPixelFormat format)
 Create a buffer reference wrapped around an already allocated image buffer. More...
 
AVFilterBufferRefavfilter_get_audio_buffer_ref_from_arrays (uint8_t **data, int linesize, int perms, int nb_samples, enum AVSampleFormat sample_fmt, uint64_t channel_layout)
 Create an audio buffer reference wrapped around an already allocated samples buffer. More...
 
void avfilter_register_all (void)
 Initialize the filter system. More...
 
void avfilter_uninit (void)
 Uninitialize the filter system. More...
 
int avfilter_register (AVFilter *filter)
 Register a filter. More...
 
AVFilteravfilter_get_by_name (const char *name)
 Get a filter definition matching the given name. More...
 
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. More...
 
int avfilter_open (AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name)
 Create a filter instance. More...
 
int avfilter_init_filter (AVFilterContext *filter, const char *args, void *opaque)
 Initialize a filter. More...
 
void avfilter_free (AVFilterContext *filter)
 Free a filter context. More...
 
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. More...
 
int avfilter_copy_frame_props (AVFilterBufferRef *dst, const AVFrame *src)
 Copy the frame properties of src to dst, without copying the actual image data. More...
 
int avfilter_copy_buf_props (AVFrame *dst, const AVFilterBufferRef *src)
 Copy the frame properties and data pointers of src to dst, without copying the actual data. More...
 

Macro Definition Documentation

#define AV_PERM_NEG_LINESIZES   0x20

the buffer requested can have negative linesizes

Definition at line 102 of file avfilter.h.

Referenced by ff_filter_frame(), filter_frame(), and get_video_buffer().

#define AV_PERM_PRESERVE   0x04

nobody else can overwrite the buffer

Definition at line 99 of file avfilter.h.

Referenced by decode_video(), filter_frame(), movie_get_frame(), and video_thread().

#define AV_PERM_READ   0x01
#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.

Referenced by movie_get_frame().

#define AV_PERM_WRITE   0x02

Typedef Documentation

typedef struct AVFilter AVFilter

Filter definition.

This defines the pads a filter contains, and all the callback functions used to interact with the filter.

A reference-counted buffer data type used by the filter system.

Filters should not store pointers to this structure directly, but instead use the AVFilterBufferRef structure below.

A reference to an AVFilterBuffer.

Since filters can manipulate the origin of a buffer to, for example, crop image without any memcpy, the buffer origin and dimensions are per-reference properties. Linesize is also useful for image flipping, frame to field filters, etc, and so is also per-reference.

TODO: add anything necessary for frame reordering

Audio specific properties in a reference to an AVFilterBuffer.

Since AVFilterBufferRef is common to different media formats, audio specific per reference properties must be separated out.

Video specific properties in a reference to an AVFilterBuffer.

Since AVFilterBufferRef is common to different media formats, video specific per reference properties must be separated out.

Definition at line 52 of file avfilter.h.

Definition at line 55 of file avfilter.h.

typedef struct AVFilterLink AVFilterLink

Definition at line 53 of file avfilter.h.

typedef struct AVFilterPad AVFilterPad

Definition at line 54 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 294 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
filterthe filter to negotiate the properties for its inputs
Returns
zero on successful negotiation

Definition at line 140 of file avfilter.c.

Referenced by avfilter_config_links(), and graph_config_links().

const char* avfilter_configuration ( void  )

Return the libavfilter build-time configuration.

Definition at line 41 of file avfilter.c.

int avfilter_copy_buf_props ( AVFrame dst,
const AVFilterBufferRef src 
)

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

Returns
0 on success, a negative number on error.

Definition at line 120 of file buffer.c.

Referenced by poll_filter(), and video_thread().

void avfilter_copy_buffer_ref_props ( AVFilterBufferRef dst,
AVFilterBufferRef src 
)

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

Definition at line 164 of file buffer.c.

Referenced by ff_filter_frame(), filter_frame(), and return_frame().

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 94 of file buffer.c.

Referenced by av_buffersrc_write_frame(), decode_video(), movie_get_frame(), and video_thread().

void avfilter_free ( AVFilterContext filter)

Free a filter context.

Parameters
filterthe filter to free

Definition at line 391 of file avfilter.c.

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

AVFilterBufferRef* avfilter_get_audio_buffer_ref_from_arrays ( uint8_t **  data,
int  linesize,
int  perms,
int  nb_samples,
enum AVSampleFormat  sample_fmt,
uint64_t  channel_layout 
)

Create an audio buffer reference wrapped around an already allocated samples buffer.

Parameters
datapointers to the samples plane buffers
linesizelinesize for the samples plane buffers
permsthe required access permissions
nb_samplesnumber of samples per channel
sample_fmtthe format of each sample in the buffer to allocate
channel_layoutthe channel layout of the buffer

Definition at line 80 of file audio.c.

Referenced by ff_default_get_audio_buffer(), and join_request_frame().

AVFilter* avfilter_get_by_name ( const char *  name)

Get a filter definition matching the given name.

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

Definition at line 274 of file avfilter.c.

Referenced by configure_input_audio_filter(), configure_input_video_filter(), configure_output_audio_filter(), configure_output_video_filter(), create_filter(), graph_insert_fifos(), main(), and query_formats().

AVFilterBufferRef* avfilter_get_video_buffer_ref_from_arrays ( uint8_t data[4],
int  linesize[4],
int  perms,
int  w,
int  h,
enum AVPixelFormat  format 
)

Create a buffer reference wrapped around an already allocated image buffer.

Parameters
datapointers to the planes of the image to reference
linesizelinesizes for the planes of the image to reference
permsthe required access permissions
wthe width of the image specified by the data and linesize arrays
hthe height of the image specified by the data and linesize arrays
formatthe pixel format of the image specified by the data and linesize arrays

Definition at line 101 of file video.c.

Referenced by decode_video(), ff_default_get_video_buffer(), and video_thread().

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

Initialize a filter.

Parameters
filterthe filter to initialize
argsA string of parameters to use when initializing the filter. The format and meaning of this string varies by filter.
opaqueAny extra non-string data needed by the filter. The meaning of this parameter varies by filter.
Returns
zero on success

Definition at line 435 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
linkthe link into which the filter should be inserted
filtthe filter to be inserted
filt_srcpad_idxthe input pad on the filter to connect
filt_dstpad_idxthe output pad on the filter to connect
Returns
zero on success

Definition at line 103 of file avfilter.c.

Referenced by graph_insert_fifos(), and query_formats().

const char* avfilter_license ( void  )

Return the libavfilter license.

Definition at line 46 of file avfilter.c.

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

Link two filters together.

Parameters
srcthe source filter
srcpadindex of the output pad on the source filter
dstthe destination filter
dstpadindex of the input pad on the destination filter
Returns
zero on success

Definition at line 73 of file avfilter.c.

Referenced by avfilter_graph_parse(), avfilter_insert_filter(), configure_input_audio_filter(), configure_input_video_filter(), configure_output_audio_filter(), configure_output_video_filter(), and link_filter().

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

Create a filter instance.

Parameters
filter_ctxput here a pointer to the created filter context on success, NULL on failure
filterthe filter to create an instance of
inst_nameName 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 329 of file avfilter.c.

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

const char* avfilter_pad_get_name ( AVFilterPad pads,
int  pad_idx 
)

Get the name of an AVFilterPad.

Parameters
padsan array of AVFilterPads
pad_idxindex of the pad in the array it; is the caller's responsibility to ensure the index is valid
Returns
name of the pad_idx'th pad in pads

Definition at line 444 of file avfilter.c.

enum AVMediaType avfilter_pad_get_type ( AVFilterPad pads,
int  pad_idx 
)

Get the type of an AVFilterPad.

Parameters
padsan array of AVFilterPads
pad_idxindex of the pad in the array; it is the caller's responsibility to ensure the index is valid
Returns
type of the pad_idx'th pad in pads

Definition at line 449 of file avfilter.c.

Referenced by configure_input_filter(), configure_output_filter(), init_input_filter(), init_output_filter(), and open_output_file().

AVFilterBufferRef* avfilter_ref_buffer ( AVFilterBufferRef ref,
int  pmask 
)

Add a new reference to a buffer.

Parameters
refan existing reference to the buffer
pmaska 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 35 of file buffer.c.

Referenced by filter_frame(), request_frame(), and return_audio_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
filterthe filter to register
Returns
0 if the registration was succesfull, a negative value otherwise

Definition at line 285 of file avfilter.c.

void avfilter_register_all ( void  )

Initialize the filter system.

Register all builtin filters.

Definition at line 39 of file allfilters.c.

Referenced by main().

void avfilter_uninit ( void  )

Uninitialize the filter system.

Unregister all filters.

Definition at line 299 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
refreference to the buffer, may be NULL
Note
it is recommended to use avfilter_unref_bufferp() instead of this function

Definition at line 75 of file buffer.c.

Referenced by add_to_queue(), av_buffersink_read_samples(), av_buffersrc_write_frame(), avfilter_unref_bufferp(), channelmap_filter_frame(), ff_filter_frame(), filter_frame(), flush_fifo(), join_request_frame(), output_frame(), poll_filter(), request_frame(), return_audio_frame(), uninit(), and write_to_fifo().

void avfilter_unref_bufferp ( AVFilterBufferRef **  ref)

Remove a reference to a buffer and set the pointer to NULL.

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

Parameters
refpointer to the buffer reference

Definition at line 88 of file buffer.c.

Referenced by alloc_picture(), filter_frame(), join_free_buffer(), join_uninit(), null_filter_frame(), queue_picture(), request_frame(), stream_close(), uninit(), and write_to_fifo().

unsigned avfilter_version ( void  )

Return the LIBAVFILTER_VERSION_INT constant.

Definition at line 37 of file avfilter.c.