FFmpeg
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
graphparser.c File Reference
#include <string.h>
#include <stdio.h>
#include "libavutil/avstring.h"
#include "libavutil/mem.h"
#include "avfilter.h"
#include "avfiltergraph.h"

Go to the source code of this file.

Macros

#define WHITESPACES   " \n\t"
 

Functions

static int link_filter (AVFilterContext *src, int srcpad, AVFilterContext *dst, int dstpad, void *log_ctx)
 Link two filters together.
 
static char * parse_link_name (const char **buf, void *log_ctx)
 Parse the name of a link, which has the format "[linkname]".
 
static int create_filter (AVFilterContext **filt_ctx, AVFilterGraph *ctx, int index, const char *filt_name, const char *args, void *log_ctx)
 Create an instance of a filter, initialize and insert it in the filtergraph in *ctx.
 
static int parse_filter (AVFilterContext **filt_ctx, const char **buf, AVFilterGraph *graph, int index, void *log_ctx)
 Parse a string of the form FILTER_NAME[=PARAMS], and create a corresponding filter instance which is added to graph with create_filter().
 
AVFilterInOutavfilter_inout_alloc (void)
 Allocate a single AVFilterInOut entry.
 
void avfilter_inout_free (AVFilterInOut **inout)
 Free the supplied list of AVFilterInOut and set *inout to NULL.
 
static AVFilterInOutextract_inout (const char *label, AVFilterInOut **links)
 
static void insert_inout (AVFilterInOut **inouts, AVFilterInOut *element)
 
static void append_inout (AVFilterInOut **inouts, AVFilterInOut **element)
 
static int link_filter_inouts (AVFilterContext *filt_ctx, AVFilterInOut **curr_inputs, AVFilterInOut **open_inputs, void *log_ctx)
 
static int parse_inputs (const char **buf, AVFilterInOut **curr_inputs, AVFilterInOut **open_outputs, void *log_ctx)
 
static int parse_outputs (const char **buf, AVFilterInOut **curr_inputs, AVFilterInOut **open_inputs, AVFilterInOut **open_outputs, void *log_ctx)
 
static int parse_sws_flags (const char **buf, AVFilterGraph *graph)
 
int avfilter_graph_parse2 (AVFilterGraph *graph, const char *filters, AVFilterInOut **inputs, AVFilterInOut **outputs)
 Add a graph described by a string to a graph.
 
int avfilter_graph_parse (AVFilterGraph *graph, const char *filters, AVFilterInOut **open_inputs_ptr, AVFilterInOut **open_outputs_ptr, void *log_ctx)
 Add a graph described by a string to a graph.
 

Macro Definition Documentation

#define WHITESPACES   " \n\t"

Definition at line 31 of file graphparser.c.

Referenced by avfilter_graph_parse2(), parse_inputs(), and parse_outputs().

Function Documentation

static int link_filter ( AVFilterContext src,
int  srcpad,
AVFilterContext dst,
int  dstpad,
void log_ctx 
)
static

Link two filters together.

See Also
avfilter_link()

Definition at line 38 of file graphparser.c.

Referenced by link_filter_inouts(), and parse_outputs().

static char* parse_link_name ( const char **  buf,
void log_ctx 
)
static

Parse the name of a link, which has the format "[linkname]".

Returns
a pointer (that need to be freed after use) to the name between parenthesis

Definition at line 59 of file graphparser.c.

Referenced by parse_inputs(), and parse_outputs().

static int create_filter ( AVFilterContext **  filt_ctx,
AVFilterGraph ctx,
int  index,
const char *  filt_name,
const char *  args,
void log_ctx 
)
static

Create an instance of a filter, initialize and insert it in the filtergraph in *ctx.

Parameters
filt_ctxput here a filter context in case of successful creation and configuration, NULL otherwise.
ctxthe filtergraph context
indexan index which is supposed to be unique for each filter instance added to the filtergraph
filt_namethe name of the filter to create
argsthe arguments provided to the filter during its initialization
log_ctxthe log context to use
Returns
0 in case of success, a negative AVERROR code otherwise

Definition at line 95 of file graphparser.c.

Referenced by parse_filter().

static int parse_filter ( AVFilterContext **  filt_ctx,
const char **  buf,
AVFilterGraph graph,
int  index,
void log_ctx 
)
static

Parse a string of the form FILTER_NAME[=PARAMS], and create a corresponding filter instance which is added to graph with create_filter().

Parameters
filt_ctxPointer that is set to the created and configured filter context on success, set to NULL on failure.
filt_ctxput here a pointer to the created filter context on success, NULL otherwise
bufpointer to the buffer to parse, *buf will be updated to point to the char next after the parsed string
indexan index which is assigned to the created filter instance, and which is supposed to be unique for each filter instance added to the filtergraph
Returns
0 in case of success, a negative AVERROR code otherwise

Definition at line 157 of file graphparser.c.

Referenced by avfilter_graph_parse2().

AVFilterInOut* avfilter_inout_alloc ( void  )

Allocate a single AVFilterInOut entry.

Must be freed with avfilter_inout_free().

Returns
allocated AVFilterInOut on success, NULL on failure.

Definition at line 175 of file graphparser.c.

Referenced by init_filters().

void avfilter_inout_free ( AVFilterInOut **  inout)

Free the supplied list of AVFilterInOut and set *inout to NULL.

If *inout is NULL, do nothing.

Definition at line 180 of file graphparser.c.

Referenced by avfilter_graph_parse(), avfilter_graph_parse2(), configure_filtergraph(), init_output_filter(), and lavfi_read_header().

static AVFilterInOut* extract_inout ( const char *  label,
AVFilterInOut **  links 
)
static

Definition at line 190 of file graphparser.c.

Referenced by avfilter_graph_parse(), parse_inputs(), and parse_outputs().

static void insert_inout ( AVFilterInOut **  inouts,
AVFilterInOut element 
)
static

Definition at line 207 of file graphparser.c.

Referenced by link_filter_inouts(), and parse_outputs().

static void append_inout ( AVFilterInOut **  inouts,
AVFilterInOut **  element 
)
static

Definition at line 213 of file graphparser.c.

Referenced by avfilter_graph_parse2(), link_filter_inouts(), and parse_inputs().

static int link_filter_inouts ( AVFilterContext filt_ctx,
AVFilterInOut **  curr_inputs,
AVFilterInOut **  open_inputs,
void log_ctx 
)
static

Definition at line 225 of file graphparser.c.

Referenced by avfilter_graph_parse2().

static int parse_inputs ( const char **  buf,
AVFilterInOut **  curr_inputs,
AVFilterInOut **  open_outputs,
void log_ctx 
)
static

Definition at line 273 of file graphparser.c.

Referenced by avfilter_graph_parse2().

static int parse_outputs ( const char **  buf,
AVFilterInOut **  curr_inputs,
AVFilterInOut **  open_inputs,
AVFilterInOut **  open_outputs,
void log_ctx 
)
static

Definition at line 313 of file graphparser.c.

Referenced by avfilter_graph_parse2().

static int parse_sws_flags ( const char **  buf,
AVFilterGraph graph 
)
static

Definition at line 361 of file graphparser.c.

Referenced by avfilter_graph_parse2().

int avfilter_graph_parse2 ( AVFilterGraph graph,
const char *  filters,
AVFilterInOut **  inputs,
AVFilterInOut **  outputs 
)

Add a graph described by a string to a graph.

Parameters
[in]graphthe filter graph where to link the parsed graph context
[in]filtersstring to be parsed
[out]inputsa linked list of all free (unlinked) inputs of the parsed graph will be returned here. It is to be freed by the caller using avfilter_inout_free().
[out]outputsa linked list of all free (unlinked) outputs of the parsed graph will be returned here. It is to be freed by the caller using avfilter_inout_free().
Returns
zero on success, a negative AVERROR code on error
Note
the difference between avfilter_graph_parse2() and avfilter_graph_parse() is that in avfilter_graph_parse(), the caller provides the lists of inputs and outputs, which therefore must be known before calling the function. On the other hand, avfilter_graph_parse2() returns the inputs and outputs that are left unlinked after parsing the graph and the caller then deals with them. Another difference is that in avfilter_graph_parse(), the inputs parameter describes inputs of the already existing part of the graph; i.e. from the point of view of the newly created part, they are outputs. Similarly the outputs parameter describes outputs of the already existing filters, which are provided as inputs to the parsed filters. avfilter_graph_parse2() takes the opposite approach – it makes no reference whatsoever to already existing parts of the graph and the inputs parameter will on return contain inputs of the newly parsed part of the graph. Analogously the outputs parameter will contain outputs of the newly created filters.

Definition at line 384 of file graphparser.c.

Referenced by avfilter_graph_parse(), and configure_filtergraph().

int avfilter_graph_parse ( AVFilterGraph graph,
const char *  filters,
AVFilterInOut **  inputs,
AVFilterInOut **  outputs,
void log_ctx 
)

Add a graph described by a string to a graph.

Parameters
graphthe filter graph where to link the parsed graph context
filtersstring to be parsed
inputspointer to a linked list to the inputs of the graph, may be NULL. If non-NULL, *inputs is updated to contain the list of open inputs after the parsing, should be freed with avfilter_inout_free().
outputspointer to a linked list to the outputs of the graph, may be NULL. If non-NULL, *outputs is updated to contain the list of open outputs after the parsing, should be freed with avfilter_inout_free().
Returns
non negative on success, a negative AVERROR code on error

Definition at line 452 of file graphparser.c.

Referenced by init_filters(), lavfi_read_header(), and main().