35#define WHITESPACES " \n\t\r"
45 const char *start = *buf;
55 "Bad (empty?) label found in the following: \"%s\".\n", start);
61 "Mismatched '[' found in the following: \"%s\".\n", start);
90 while (*links && (!(*links)->name || strcmp((*links)->name, label)))
91 links = &((*links)->next);
105 while (*inouts && (*inouts)->
next)
106 inouts = &((*inouts)->next);
111 (*inouts)->
next = *element;
117 if (strncmp(*buf,
"sws_flags=", 10))
120 const char *p = strchr(*buf,
';');
180 "Not enough inputs specified for the \"%s\" filter.\n",
200 "Invalid filterchain containing an unlabelled output pad: \"%s\"\n",
246 for (
unsigned i = 0;
i < p->nb_inputs;
i++)
250 for (
unsigned i = 0;
i < p->nb_outputs;
i++)
299 while (**linklabels ==
'[') {
332 for (
unsigned i = 0;
i < nb;
i++)
354 if (!p->filter_name) {
359 inst_name = strchr(p->filter_name,
'@');
363 if (!p->instance_name) {
398 "Error parsing a filter description around: %s\n", *
filter);
406 const char *chain = *pchain;
408 int ret, nb_filters = 0;
433 if (chr && chr !=
',' && chr !=
';') {
435 "Trailing garbage after a filter: %s\n", chain);
455 "Error parsing filterchain '%s' around: %s\n", *pchain, chain);
464 int ret, nb_chains = 0;
539 if (p->filter || !p->filter_name)
544 "No such filter: '%s'\n", p->filter_name);
548 if (!p->instance_name)
581 "A creation-pending filter '%s' present in the segment. All filters "
582 "must be created or disabled before calling %s().\n",
fn,
func);
588 int ret, leftover_opts = 0;
601 if (!p->filter || !p->opts)
645 int output,
size_t idx_chain,
size_t idx_filter,
648 for (; idx_chain < seg->
nb_chains; idx_chain++) {
651 for (; idx_filter < ch->
nb_filters; idx_filter++) {
654 unsigned nb_io = output ? p->nb_outputs : p->nb_inputs;
661 l = output ? p->filter->outputs : p->filter->inputs;
662 nb_l = output ? p->filter->nb_outputs : p->filter->nb_inputs;
664 for (
unsigned i = 0;
i <
FFMIN(nb_io, nb_l);
i++)
665 if (!l[
i] && io[
i]->label && !strcmp(io[
i]->label, label)) {
711 if (
f->nb_inputs < p->nb_inputs) {
713 "More input link labels specified for filter '%s' than "
714 "it has inputs: %u > %d\n",
f->filter->name,
715 p->nb_inputs,
f->nb_inputs);
719 for (
unsigned in = 0; in <
f->nb_inputs; in++) {
720 const char *label = (in < p->nb_inputs) ? p->inputs[in]->label :
NULL;
728 unsigned idx =
find_linklabel(seg, label, 1, idx_chain, idx_filter, &po);
756 if (
f->nb_outputs < p->nb_outputs) {
758 "More output link labels specified for filter '%s' than "
759 "it has outputs: %u > %d\n",
f->filter->name,
760 p->nb_outputs,
f->nb_outputs);
763 for (
unsigned out = 0;
out <
f->nb_outputs;
out++) {
764 char *label = (
out < p->nb_outputs) ? p->outputs[
out]->label :
NULL;
772 unsigned idx =
find_linklabel(seg, label, 0, idx_chain, idx_filter, &po);
785 for (
size_t i = idx_filter + 1;
i < ch->
nb_filters && !label;
i++) {
826 for (
size_t idx_chain = 0; idx_chain < seg->
nb_chains; idx_chain++) {
829 for (
size_t idx_filter = 0; idx_filter < ch->
nb_filters; idx_filter++) {
832 if (p->filter_name) {
873 "Could not set non-existent option '%s' to value '%s'\n",
954 if (p->filter->nb_inputs == 1 && !p->inputs) {
955 const char *
tmp =
"[in]";
965 if (p->filter->nb_outputs == 1 && !p->outputs) {
966 const char *
tmp =
"[out]";
1033 if (open_inputs_ptr) *open_inputs_ptr = user_inputs;
1035 if (open_outputs_ptr) *open_outputs_ptr = user_outputs;
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static const AVFilterPad inputs[]
static const AVFilterPad outputs[]
#define filters(fmt, type, inverse, clp, inverset, clip, one, clip_fn, packed)
static AVDictionary * opts
int ff_filter_opt_parse(void *logctx, const AVClass *priv_class, AVDictionary **options, const char *args)
Parse filter options into a dictionary.
Main libavfilter public API header.
static FFFilterContext * fffilterctx(AVFilterContext *ctx)
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
static unsigned find_linklabel(AVFilterGraphSegment *seg, const char *label, int output, size_t idx_chain, size_t idx_filter, AVFilterParams **pp)
static int link_outputs(AVFilterGraphSegment *seg, size_t idx_chain, size_t idx_filter, AVFilterInOut **outputs)
static int filter_parse(void *logctx, const char **filter, AVFilterParams **pp)
static int linklabels_parse(void *logctx, const char **linklabels, AVFilterPadParams ***res, unsigned *nb_res)
static int parse_sws_flags(const char **buf, char **dst, void *log_ctx)
static int chain_parse(void *logctx, const char **pchain, AVFilterChain **pch)
static int inout_add(AVFilterInOut **inouts, AVFilterContext *f, unsigned pad_idx, const char *label)
static void append_inout(AVFilterInOut **inouts, AVFilterInOut **element)
static AVFilterInOut * extract_inout(const char *label, AVFilterInOut **links)
static void filter_params_free(AVFilterParams **pp)
static void log_unknown_opt(const AVFilterGraphSegment *seg)
static int fail_creation_pending(AVFilterGraphSegment *seg, const char *fn, const char *func)
static void chain_free(AVFilterChain **pch)
static void pad_params_free(AVFilterPadParams **pfpp)
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_inputs(AVFilterGraphSegment *seg, size_t idx_chain, size_t idx_filter, AVFilterInOut **inputs)
void avfilter_free(AVFilterContext *filter)
Free a filter context.
const AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
void avfilter_inout_free(AVFilterInOut **inout)
Free the supplied list of AVFilterInOut and set *inout to NULL.
int avfilter_graph_segment_parse(AVFilterGraph *graph, const char *graph_str, int flags, AVFilterGraphSegment **pseg)
Parse a textual filtergraph description into an intermediate form.
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.
void avfilter_graph_segment_free(AVFilterGraphSegment **pseg)
Free the provided AVFilterGraphSegment and everything associated with it.
AVFilterContext * avfilter_graph_alloc_filter(AVFilterGraph *graph, const AVFilter *filter, const char *name)
Create a new filter instance in a filter 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_init_dict(AVFilterContext *ctx, AVDictionary **options)
Initialize a filter with the supplied dictionary of options.
int avfilter_graph_segment_apply_opts(AVFilterGraphSegment *seg, int flags)
Apply parsed options to filter instances in a graph segment.
int avfilter_graph_segment_init(AVFilterGraphSegment *seg, int flags)
Initialize all filter instances in a graph segment.
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 avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
Link two filters together.
int avfilter_graph_segment_link(AVFilterGraphSegment *seg, int flags, AVFilterInOut **inputs, AVFilterInOut **outputs)
Link filters in a graph segment.
int avfilter_graph_segment_apply(AVFilterGraphSegment *seg, int flags, AVFilterInOut **inputs, AVFilterInOut **outputs)
Apply all filter/link descriptions from a graph segment to the associated filtergraph.
int avfilter_graph_segment_create_filters(AVFilterGraphSegment *seg, int flags)
Create filters specified in a graph segment.
AVFilterInOut * avfilter_inout_alloc(void)
Allocate a single AVFilterInOut entry.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
int av_dict_count(const AVDictionary *m)
Get number of entries in dictionary.
#define AVERROR_FILTER_NOT_FOUND
Filter not found.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define AVERROR_OPTION_NOT_FOUND
Option not found.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem)
Add an element to a dynamic array.
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...
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
int av_opt_set_dict2(void *obj, AVDictionary **options, int search_flags)
Set all the options from a given dictionary on an object.
int av_set_options_string(void *ctx, const char *opts, const char *key_val_sep, const char *pairs_sep)
Parse the key/value pairs list in opts.
int(* func)(AVBPrint *dst, const char *in, const char *arg)
@ AV_CLASS_STATE_INITIALIZED
Object initialization has finished and it is now in the 'runtime' stage.
Memory handling functions.
A filterchain is a list of filter specifications.
AVFilterParams ** filters
unsigned nb_inputs
number of input pads
AVFilterLink ** inputs
array of pointers to input links
const AVFilter * filter
the AVFilter of which this is an instance
A parsed representation of a filtergraph segment.
char * scale_sws_opts
A string containing a colon-separated list of key=value options applied to all scale filters in this ...
AVFilterGraph * graph
The filtergraph this segment is associated with.
AVFilterChain ** chains
A list of filter chain contained in this segment.
char * scale_sws_opts
sws options to use for the auto-inserted scale filters
AVFilterContext ** filters
A linked-list of the inputs/outputs of the filter chain.
AVFilterContext * filter_ctx
filter context associated to this input/output
int pad_idx
index of the filt_ctx pad to use for linking
char * name
unique name for this input/output in the list
struct AVFilterInOut * next
next input/input in the list, NULL if this is the last
A link between two filters.
Parameters of a filter's input or output pad.
char * label
An av_malloc()'ed string containing the pad label.
Parameters describing a filter to be created in a filtergraph.
AVFilterPadParams ** inputs
AVFilterContext * filter
The filter context.
const char * name
Filter name.
void(* filter)(uint8_t *src, ptrdiff_t stride, int qscale)