30 #define WHITESPACES " \n\t"
44 "Cannot create the link %s:%d -> %s:%d\n",
60 const char *start = *buf;
68 "Bad (empty?) label found in the following: \"%s\".\n", start);
72 if (*(*buf)++ !=
']') {
74 "Mismatched '[' found in the following: \"%s\".\n", start);
95 const char *filt_name,
const char *args,
void *log_ctx)
102 snprintf(inst_name,
sizeof(inst_name),
"Parsed filter %d %s", index, filt_name);
108 "No such filter: '%s'\n", filt_name);
115 "Error creating filter '%s'\n", filt_name);
124 if (!strcmp(filt_name,
"scale") && args && !strstr(args,
"flags") &&
126 snprintf(tmp_args,
sizeof(tmp_args),
"%s:%s",
133 "Error initializing filter '%s' with args '%s'\n", filt_name, args);
157 int index,
void *log_ctx)
168 ret =
create_filter(filt_ctx, graph, index, name, opts, log_ctx);
188 while (*links && strcmp((*links)->name, label))
189 links = &((*links)->next);
201 element->
next = *inouts;
215 "Not enough inputs specified for the \"%s\" filter.\n",
220 *curr_inputs = (*curr_inputs)->
next;
236 "Too many inputs specified for the \"%s\" filter.\n",
259 while (**buf ==
'[') {
294 while (**buf ==
'[') {
301 "No output pad can be associated to link label '%s'.\n",
305 *curr_inputs = (*curr_inputs)->
next;
344 const char *filterchain =
filters;
347 if ((ret =
parse_inputs(&filters, &curr_inputs, &open_outputs, log_ctx)) < 0)
350 if ((ret =
parse_filter(&filter, &filters, graph, index, log_ctx)) < 0)
353 if (filter->
input_count == 1 && !curr_inputs && !index) {
355 const char *tmp =
"[in]";
356 if ((ret =
parse_inputs(&tmp, &curr_inputs, &open_outputs, log_ctx)) < 0)
363 if ((ret =
parse_outputs(&filters, &curr_inputs, &open_inputs, &open_outputs,
370 if (chr ==
';' && curr_inputs) {
372 "Invalid filterchain containing an unlabelled output pad: \"%s\"\n",
378 }
while (chr ==
',' || chr ==
';');
382 "Unable to parse graph description substring: \"%s\"\n",
388 if (open_inputs && !strcmp(open_inputs->
name,
"out") && curr_inputs) {
390 const char *tmp =
"[out]";
391 if ((ret =
parse_outputs(&tmp, &curr_inputs, &open_inputs, &open_outputs,
AVFilterContext ** filters
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
void avfilter_free(AVFilterContext *filter)
Free a filter context.
struct AVFilterInOut * next
next input/input in the list, NULL if this is the last
int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, AVFilterInOut *open_inputs, AVFilterInOut *open_outputs, void *log_ctx)
Add a graph described by a string to a graph.
char * scale_sws_opts
sws options to use for the auto-inserted scale filters
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
Link two filters together.
unsigned input_count
number of input pads
static void insert_inout(AVFilterInOut **inouts, AVFilterInOut *element)
static int parse_inputs(const char **buf, AVFilterInOut **curr_inputs, AVFilterInOut **open_outputs, void *log_ctx)
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque)
Initialize a filter.
AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
static AVFilterInOut * extract_inout(const char *label, AVFilterInOut **links)
void av_log(void *avcl, int level, const char *fmt,...)
char * av_get_token(const char **buf, const char *term)
Unescape the given string until a non escaped terminating char, and return the token corresponding to...
static void filter(MpegAudioContext *s, int ch, const short *samples, int incr)
unsigned output_count
number of output pads
int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name)
Create a filter instance.
AVFilterContext * filter_ctx
filter context associated to this input/output
A linked-list of the inputs/outputs of the filter chain.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int pad_idx
index of the filt_ctx pad to use for linking
static struct PPFilter filters[]
const char * name
filter name
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 ...
char * name
unique name for this input/output in the list
static int parse_outputs(const char **buf, AVFilterInOut **curr_inputs, AVFilterInOut **open_inputs, AVFilterInOut **open_outputs, void *log_ctx)
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 link_filter(AVFilterContext *src, int srcpad, AVFilterContext *dst, int dstpad, void *log_ctx)
Link two filters together.
AVFilter * filter
the AVFilter of which this is an instance
static char * parse_link_name(const char **buf, void *log_ctx)
Parse the name of a link, which has the format "[linkname]".
static int link_filter_inouts(AVFilterContext *filt_ctx, AVFilterInOut **curr_inputs, AVFilterInOut **open_inputs, void *log_ctx)
int avfilter_graph_add_filter(AVFilterGraph *graph, AVFilterContext *filter)
Add an existing filter instance to a filter graph.
static void free_inout(AVFilterInOut *head)