30 #define WHITESPACES " \n\t" 44 "Cannot create the link %s:%d -> %s:%d\n",
60 const char *start = *buf;
70 "Bad (empty?) label found in the following: \"%s\".\n", start);
74 if (*(*buf)++ !=
']') {
76 "Mismatched '[' found in the following: \"%s\".\n", start);
84 #define TMP_ARGS_SIZE 256 89 const char *separator =
":";
90 const char *opt = *args;
92 if (strstr(*args,
"flags"))
95 if (strstr(*args,
"="))
96 separator =
":flags=";
98 while ((opt = strstr(opt,
":")) && *opt) {
107 opt = strstr(sws_opts,
"flags=");
108 if (opt && strlen(opt) > 6)
114 *args, separator, opt);
132 const char *filt_name,
const char *args,
void *log_ctx)
139 snprintf(inst_name,
sizeof(inst_name),
"Parsed filter %d %s", index, filt_name);
145 "No such filter: '%s'\n", filt_name);
152 "Error creating filter '%s'\n", filt_name);
156 if (!strcmp(filt_name,
"scale") && args &&
164 "Error initializing filter '%s'", filt_name);
192 int index,
void *log_ctx)
203 ret =
create_filter(filt_ctx, graph, index, name, opts, log_ctx);
228 while (*links && (!(*links)->name || strcmp((*links)->name, label)))
229 links = &((*links)->next);
243 element->
next = *inouts;
249 while (*inouts && (*inouts)->
next)
250 inouts = &((*inouts)->next);
255 (*inouts)->
next = *element;
265 for (pad = 0; pad < filt_ctx->
nb_inputs; pad++) {
269 *curr_inputs = (*curr_inputs)->
next;
289 "Too many inputs specified for the \"%s\" filter.\n",
313 while (**buf ==
'[') {
342 *curr_inputs = parsed_inputs;
353 while (**buf ==
'[') {
364 "No output pad can be associated to link label '%s'.\n", name);
368 *curr_inputs = (*curr_inputs)->
next;
397 char *p = strchr(*buf,
';');
399 if (strncmp(*buf,
"sws_flags=", 10))
436 if ((ret =
parse_inputs(&filters, &curr_inputs, &open_outputs, graph)) < 0)
439 if ((ret =
parse_filter(&filter, &filters, graph, index, graph)) < 0)
446 if ((ret =
parse_outputs(&filters, &curr_inputs, &open_inputs, &open_outputs,
453 if (chr ==
';' && curr_inputs)
456 }
while (chr ==
',' || chr ==
';');
460 "Unable to parse graph description substring: \"%s\"\n",
468 *inputs = open_inputs;
469 *outputs = open_outputs;
497 if (inputs && !inputs->
name)
499 for (cur = inputs; cur; cur = cur->
next) {
502 "Not enough inputs specified for the \"%s\" filter.\n",
517 if (outputs && !outputs->name)
519 for (cur = outputs; cur; cur = cur->
next) {
522 "Invalid filterchain containing an unlabelled output pad: \"%s\"\n",
AVFilterContext ** filters
void avfilter_free(AVFilterContext *filter)
Free a filter context.
static const AVFilterPad outputs[]
Main libavfilter public API header.
memory handling functions
void avfilter_inout_free(AVFilterInOut **inout)
Free the supplied list of AVFilterInOut and set *inout to NULL.
struct AVFilterInOut * next
next input/input in the list, NULL if this is the last
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
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.
static void insert_inout(AVFilterInOut **inouts, AVFilterInOut *element)
int avfilter_graph_parse2(AVFilterGraph *graph, const char *filters, AVFilterInOut **inputs, AVFilterInOut **outputs)
Add a graph described by a string to a graph.
static int parse_inputs(const char **buf, AVFilterInOut **curr_inputs, AVFilterInOut **open_outputs, void *log_ctx)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
static AVFilterInOut * extract_inout(const char *label, AVFilterInOut **links)
unsigned nb_outputs
number of output pads
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
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...
AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
static void filter(MpegAudioContext *s, int ch, const short *samples, int incr)
unsigned nb_inputs
number of input pads
static void append_sws_flags(const char **args, const char *sws_opts, char *tmp)
AVFilterContext * filter_ctx
filter context associated to this input/output
int avfilter_init_str(AVFilterContext *filter, const char *args)
Initialize a filter with the supplied parameters.
A linked-list of the inputs/outputs of the filter chain.
#define AV_LOG_INFO
Standard information.
char * av_strdup(const char *s)
Duplicate the string s.
static int parse_sws_flags(const char **buf, AVFilterGraph *graph)
static void append_inout(AVFilterInOut **inouts, AVFilterInOut **element)
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.
static const AVFilterPad inputs[]
int pad_idx
index of the filt_ctx pad to use for linking
struct SwsContext * sws_opts
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)
AVFilterInOut * avfilter_inout_alloc(void)
Allocate a single AVFilterInOut entry.
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.
AVFilterContext * avfilter_graph_alloc_filter(AVFilterGraph *graph, const AVFilter *filter, const char *name)
Create a new filter instance in a filter graph.
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)
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
const AVFilter * filter
the AVFilter of which this is an instance