30 #define WHITESPACES " \n\t\r"
44 "Cannot create the link %s:%d -> %s:%d\n",
70 "Bad (empty?) label found in the following: \"%s\".\n", start);
74 if (*(*buf)++ !=
']') {
76 "Mismatched '[' found in the following: \"%s\".\n", start);
97 const char *filt_name,
const char *
args,
void *log_ctx)
101 char *tmp_args =
NULL;
104 snprintf(inst_name,
sizeof(inst_name),
"Parsed_%s_%d", filt_name, index);
110 "No such filter: '%s'\n", filt_name);
117 "Error creating filter '%s'\n", filt_name);
121 if (!strcmp(filt_name,
"scale") && (!args || !strstr(args,
"flags")) &&
136 "Error initializing filter '%s'", filt_name);
165 int index,
void *log_ctx)
176 ret =
create_filter(filt_ctx, graph, index, name, opts, log_ctx);
201 while (*links && (!(*links)->name || strcmp((*links)->name, label)))
202 links = &((*links)->next);
216 element->
next = *inouts;
222 while (*inouts && (*inouts)->
next)
223 inouts = &((*inouts)->next);
228 (*inouts)->
next = *element;
238 for (pad = 0; pad < filt_ctx->
nb_inputs; pad++) {
242 *curr_inputs = (*curr_inputs)->
next;
262 "Too many inputs specified for the \"%s\" filter.\n",
286 while (**buf ==
'[') {
315 *curr_inputs = parsed_inputs;
326 while (**buf ==
'[') {
337 "No output pad can be associated to link label '%s'.\n", name);
341 *curr_inputs = (*curr_inputs)->
next;
370 char *p = strchr(*buf,
';');
372 if (strncmp(*buf,
"sws_flags=", 10))
395 int index = 0, ret = 0;
409 if ((ret =
parse_inputs(&filters, &curr_inputs, &open_outputs, graph)) < 0)
411 if ((ret =
parse_filter(&filter, &filters, graph, index, graph)) < 0)
418 if ((ret =
parse_outputs(&filters, &curr_inputs, &open_inputs, &open_outputs,
425 if (chr ==
';' && curr_inputs)
428 }
while (chr ==
',' || chr ==
';');
432 "Unable to parse graph description substring: \"%s\"\n",
441 *inputs = open_inputs;
442 *outputs = open_outputs;
470 if (inputs && !inputs->
name)
472 for (cur = inputs; cur; cur = cur->
next) {
475 "Not enough inputs specified for the \"%s\" filter.\n",
490 if (outputs && !outputs->name)
492 for (cur = outputs; cur; cur = cur->
next) {
495 "Invalid filterchain containing an unlabelled output pad: \"%s\"\n",
526 int index = 0, ret = 0;
538 const char *filterchain =
filters;
541 if ((ret =
parse_inputs(&filters, &curr_inputs, &open_outputs, log_ctx)) < 0)
544 if ((ret =
parse_filter(&filter, &filters, graph, index, log_ctx)) < 0)
547 if (filter->
nb_inputs == 1 && !curr_inputs && !index) {
549 const char *
tmp =
"[in]";
550 if ((ret =
parse_inputs(&tmp, &curr_inputs, &open_outputs, log_ctx)) < 0)
557 if ((ret =
parse_outputs(&filters, &curr_inputs, &open_inputs, &open_outputs,
564 if (chr ==
';' && curr_inputs) {
566 "Invalid filterchain containing an unlabelled output pad: \"%s\"\n",
572 }
while (chr ==
',' || chr ==
';');
576 "Unable to parse graph description substring: \"%s\"\n",
584 const char *
tmp =
"[out]";
585 if ((ret =
parse_outputs(&tmp, &curr_inputs, &open_inputs, &open_outputs,
592 if (open_inputs_ptr) *open_inputs_ptr = open_inputs;
594 if (open_outputs_ptr) *open_outputs_ptr = open_outputs;
AVFilterContext ** filters
void avfilter_free(AVFilterContext *filter)
Free a filter context.
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
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
char * scale_sws_opts
sws options to use for the auto-inserted scale filters
int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
Link two filters together.
static av_cold int end(AVCodecContext *avctx)
static void filter(int16_t *output, ptrdiff_t out_stride, int16_t *low, ptrdiff_t low_stride, int16_t *high, ptrdiff_t high_stride, int len, uint8_t clip)
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.
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...
const AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
char * av_asprintf(const char *fmt,...)
unsigned nb_inputs
number of input pads
static const AVFilterPad outputs[]
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.
static const AVFilterPad inputs[]
char * av_strdup(const char *s)
Duplicate a string.
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.
int pad_idx
index of the filt_ctx pad to use for linking
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 const int8_t filt[NUMTAPS]
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 const struct PPFilter filters[]
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_parse_ptr(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.
const AVFilter * filter
the AVFilter of which this is an instance