FFmpeg
Modules | Data Structures | Macros | Functions
Bitstream filter graph

Experimental graph-based API for bitstream filters. More...

Modules

 Packet source API
 The source filter is there to connect filter graphs to applications They have a single output, connected to the graph, and no input. Packets must be fed to it using av_bsf_source_add_packet().
 
 Packet sink API
 The sink filter is there to connect filter graphs to applications They have a single input, connected to the graph, and no output. Packets must be extracted using av_bsf_sink_get_packet().
 

Data Structures

struct  AVBitStreamFilterContext
 An instance of a filter. More...
 
struct  AVBitStreamFilterGraph
 

Macros

#define AV_BSF_FLAG_DYNAMIC_INPUTS   (1 << 0)
 The number of the filter inputs is not determined just by the filter's static inputs. More...
 
#define AV_BSF_FLAG_DYNAMIC_OUTPUTS   (1 << 1)
 The number of the filter outputs is not determined just by the filter's static outputs. More...
 
#define AV_BSF_FLAG_METADATA_ONLY   (1 << 2)
 The filter is a "metadata" filter - it does not modify the packet data in any way. More...
 

Functions

const char * av_bsf_pad_get_name (const AVBitStreamFilterPad *pads, int pad_idx)
 Get the name of an AVBitStreamFilterPad. More...
 
enum AVCodecIDav_bsf_pad_get_codec_ids (const AVBitStreamFilterPad *pads, int pad_idx)
 Get the codec ids supported by an AVBitStreamFilterPad. More...
 
int av_bsf_link (AVBitStreamFilterContext *src, unsigned srcpad, AVBitStreamFilterContext *dst, unsigned dstpad)
 Link two filters together. More...
 
int av_bsf_init_str (AVBitStreamFilterContext *ctx, const char *args)
 Initialize a filter with the supplied parameters. More...
 
int av_bsf_init_dict (AVBitStreamFilterContext *ctx, AVDictionary **options)
 Initialize a filter with the supplied dictionary of options. More...
 
AVBitStreamFilterGraphav_bsf_graph_alloc (void)
 Allocate a filter graph. More...
 
int av_bsf_graph_alloc_filter (AVBitStreamFilterContext **filt_ctx, const AVBitStreamFilter *filter, const char *name, AVBitStreamFilterGraph *graph)
 Create a new filter instance in a filter graph. More...
 
int av_bsf_graph_create_filter (AVBitStreamFilterContext **filt_ctx, const AVBitStreamFilter *filt, const char *name, AVDictionary **options, AVBitStreamFilterGraph *graph_ctx)
 A convenience wrapper that allocates and initializes a filter in a single step. More...
 
AVBitStreamFilterContextav_bsf_graph_get_filter (AVBitStreamFilterGraph *graph, const char *name)
 Get a filter instance identified by instance name from graph. More...
 
int av_bsf_graph_config (AVBitStreamFilterGraph *graphctx, void *log_ctx)
 Check validity and configure all the links and formats in the graph. More...
 
int av_bsf_graph_source_needs_input (const AVBitStreamFilterGraph *graph)
 Get the index of the source filter in the filtergraph that reported needing input more urgently. More...
 
void av_bsf_graph_free (AVBitStreamFilterGraph **graph)
 Free a graph, destroy its links, and set *graph to NULL. More...
 

Detailed Description

Experimental graph-based API for bitstream filters.

Macro Definition Documentation

◆ AV_BSF_FLAG_DYNAMIC_INPUTS

#define AV_BSF_FLAG_DYNAMIC_INPUTS   (1 << 0)

The number of the filter inputs is not determined just by the filter's static inputs.

The filter might add additional inputs during initialization depending on the options supplied to it.

Definition at line 388 of file bsf.h.

◆ AV_BSF_FLAG_DYNAMIC_OUTPUTS

#define AV_BSF_FLAG_DYNAMIC_OUTPUTS   (1 << 1)

The number of the filter outputs is not determined just by the filter's static outputs.

The filter might add additional outputs during initialization depending on the options supplied to it.

Definition at line 394 of file bsf.h.

◆ AV_BSF_FLAG_METADATA_ONLY

#define AV_BSF_FLAG_METADATA_ONLY   (1 << 2)

The filter is a "metadata" filter - it does not modify the packet data in any way.

It may only affect the metadata (i.e. those fields copied by av_packet_copy_props()).

More precisely, this means that the data of any packet output by the filter must be exactly equal to some packet that is received on one of its inputs. Furthermore, all packets produced on a given output must correspond to packet received on the same input and their order must be unchanged. Note that the filter may still drop or duplicate the frames.

Definition at line 406 of file bsf.h.

Function Documentation

◆ av_bsf_pad_get_name()

const char* av_bsf_pad_get_name ( const AVBitStreamFilterPad pads,
int  pad_idx 
)

Get the name of an AVBitStreamFilterPad.

Parameters
padsan array of AVBitStreamFilterPads
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 380 of file bitstreamfilter.c.

◆ av_bsf_pad_get_codec_ids()

enum AVCodecID* av_bsf_pad_get_codec_ids ( const AVBitStreamFilterPad pads,
int  pad_idx 
)

Get the codec ids supported by an AVBitStreamFilterPad.

Parameters
padsan array of AVBitStreamFilterPads
pad_idxindex of the pad in the array; it is the caller's responsibility to ensure the index is valid
Returns
an array of AVCodecID terminated by AV_CODEC_ID_NONE, or NULL if the pad has no codec id constrains.

Definition at line 385 of file bitstreamfilter.c.

◆ av_bsf_link()

int av_bsf_link ( AVBitStreamFilterContext src,
unsigned  srcpad,
AVBitStreamFilterContext 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 126 of file bitstreamfilter.c.

Referenced by ist_use().

◆ av_bsf_init_str()

int av_bsf_init_str ( AVBitStreamFilterContext ctx,
const char *  args 
)

Initialize a filter with the supplied parameters.

Parameters
ctxuninitialized filter context to initialize
argsOptions to initialize the filter with. This must be a ':'-separated list of options in the 'key=value' form. May be NULL if the options have been set directly using the AVOptions API or there are no options that need to be set.
Returns
0 on success, a negative AVERROR on failure

Definition at line 352 of file bitstreamfilter.c.

◆ av_bsf_init_dict()

int av_bsf_init_dict ( AVBitStreamFilterContext ctx,
AVDictionary **  options 
)

Initialize a filter with the supplied dictionary of options.

Parameters
ctxuninitialized filter context to initialize
optionsAn AVDictionary filled with options for this filter. On return this parameter will be destroyed and replaced with a dict containing options that were not found. This dictionary must be freed by the caller. May be NULL, then this function is equivalent to av_bsf_init_str() with the second parameter set to NULL.
Returns
0 on success, a negative AVERROR on failure
Note
This function and av_bsf_init_str() do essentially the same thing, the difference is in manner in which the options are passed. It is up to the calling code to choose whichever is more preferable. The two functions also behave differently when some of the provided options are not declared as supported by the filter. In such a case, av_bsf_init_str() will fail, but this function will leave those extra options in the options AVDictionary and continue as usual.

Definition at line 326 of file bitstreamfilter.c.

Referenced by av_bsf_graph_create_filter(), av_bsf_init_str(), and ist_use().

◆ av_bsf_graph_alloc()

AVBitStreamFilterGraph* av_bsf_graph_alloc ( void  )

Allocate a filter graph.

Returns
the allocated filter graph on success or NULL.

Definition at line 48 of file bsfgraph.c.

Referenced by istg_parse_lcevc().

◆ av_bsf_graph_alloc_filter()

int av_bsf_graph_alloc_filter ( AVBitStreamFilterContext **  filt_ctx,
const AVBitStreamFilter filter,
const char *  name,
AVBitStreamFilterGraph graph 
)

Create a new filter instance in a filter graph.

Parameters
[out]filt_ctxA pointer into which the pointer to the newly-allocated context will be written on success. May be NULL. Note that it is also retrievable directly through AVBitStreamFilterGraph.filters or with av_bsf_graph_get_filter().
[in]filterthe filter to create an instance of
[in]nameName to give to the new instance (will be copied to AVBitStreamFilterContext.name). This may be used by the caller to identify different filters, libavcodec itself assigns no semantics to this parameter. May be NULL.
[in]graphgraph in which the new filter will be used
Note
On failure and if filt_ctx is not NULL, *filt_ctx will be set to NULL.
Returns
a negative AVERROR error code in case of failure, a non negative value otherwise

Definition at line 139 of file bsfgraph.c.

Referenced by av_bsf_graph_create_filter(), and istg_parse_lcevc().

◆ av_bsf_graph_create_filter()

int av_bsf_graph_create_filter ( AVBitStreamFilterContext **  filt_ctx,
const AVBitStreamFilter filt,
const char *  name,
AVDictionary **  options,
AVBitStreamFilterGraph graph_ctx 
)

A convenience wrapper that allocates and initializes a filter in a single step.

The filter instance is created from the filter filt and inited with the parameter args.

Parameters
[out]filt_ctxA pointer into which the pointer to the newly-allocated context will be written on success. May be NULL. Note that it is also retrievable directly through AVBitStreamFilterGraph.filters or with av_bsf_graph_get_filter().
[in]namethe instance name to give to the created filter instance
[in]graph_ctxthe filter graph
Returns
a negative AVERROR error code in case of failure, a non negative value otherwise
Note
On failure and if filt_ctx is not NULL, *filt_ctx will be set to NULL.
Warning
Since the filter is initialized after this function successfully returns, you MUST NOT set any further options on it. If you need to do that, call av_bsf_graph_alloc_filter(), followed by setting the options, followed by av_bsf_init_dict() instead of this function.

Definition at line 113 of file bsfgraph.c.

◆ av_bsf_graph_get_filter()

AVBitStreamFilterContext* av_bsf_graph_get_filter ( AVBitStreamFilterGraph graph,
const char *  name 
)

Get a filter instance identified by instance name from graph.

Parameters
graphfilter graph to search through.
namefilter instance name (should be unique in the graph).
Returns
the pointer to the found filter instance or NULL if it cannot be found.

Definition at line 82 of file bsfgraph.c.

Referenced by ist_use().

◆ av_bsf_graph_config()

int av_bsf_graph_config ( AVBitStreamFilterGraph graphctx,
void *  log_ctx 
)

Check validity and configure all the links and formats in the graph.

Parameters
graphctxthe filter graph
log_ctxcontext used for logging
Returns
>= 0 in case of success, a negative AVERROR code otherwise

Definition at line 294 of file bsfgraph.c.

Referenced by ist_use().

◆ av_bsf_graph_source_needs_input()

int av_bsf_graph_source_needs_input ( const AVBitStreamFilterGraph graph)

Get the index of the source filter in the filtergraph that reported needing input more urgently.

Returns
the index value of a source filter in the filtergraph, or AVERROR(EOF) if no source is accepting more packets.

Definition at line 383 of file bsfgraph.c.

◆ av_bsf_graph_free()

void av_bsf_graph_free ( AVBitStreamFilterGraph **  graph)

Free a graph, destroy its links, and set *graph to NULL.

If *graph is NULL, do nothing.

Definition at line 93 of file bsfgraph.c.

Referenced by istg_free().