Go to the documentation of this file.
34 #define WHITESPACES " \n\t\r"
44 const char *start = *buf;
54 "Bad (empty?) label found in the following: \"%s\".\n", start);
60 "Mismatched '[' found in the following: \"%s\".\n", start);
89 while (*
links && (!(*links)->name || strcmp((*links)->name, label)))
90 links = &((*links)->next);
104 while (*inouts && (*inouts)->
next)
105 inouts = &((*inouts)->next);
110 (*inouts)->
next = *element;
116 char *p = strchr(*buf,
';');
118 if (strncmp(*buf,
"sws_flags=", 10))
179 "Not enough inputs specified for the \"%s\" filter.\n",
199 "Invalid filterchain containing an unlabelled output pad: \"%s\"\n",
298 while (**linklabels ==
'[') {
331 for (
unsigned i = 0;
i < nb;
i++)
397 "Error parsing a filter description around: %s\n", *
filter);
405 const char *chain = *pchain;
407 int ret, nb_filters = 0;
432 if (chr && chr !=
',' && chr !=
';') {
434 "Trailing garbage after a filter: %s\n", chain);
454 "Error parsing filterchain '%s' around: %s\n", *pchain, chain);
463 int ret, nb_chains = 0;
580 "A creation-pending filter '%s' present in the segment. All filters "
581 "must be created or disabled before calling %s().\n",
fn,
func);
587 int ret, leftover_opts = 0;
643 int output,
size_t idx_chain,
size_t idx_filter,
646 for (; idx_chain < seg->
nb_chains; idx_chain++) {
649 for (; idx_filter < ch->
nb_filters; idx_filter++) {
662 for (
unsigned i = 0;
i <
FFMIN(nb_io, nb_l);
i++)
663 if (!l[
i] && io[
i]->label && !strcmp(io[
i]->label, label)) {
711 "More input link labels specified for filter '%s' than "
712 "it has inputs: %u > %d\n",
f->filter->name,
717 for (
unsigned in = 0; in <
f->nb_inputs; in++) {
726 unsigned idx =
find_linklabel(seg, label, 1, idx_chain, idx_filter, &po);
756 "More output link labels specified for filter '%s' than "
757 "it has outputs: %u > %d\n",
f->filter->name,
761 for (
unsigned out = 0;
out <
f->nb_outputs;
out++) {
770 unsigned idx =
find_linklabel(seg, label, 0, idx_chain, idx_filter, &po);
783 for (
size_t i = idx_filter + 1;
i < ch->
nb_filters && !label;
i++) {
824 for (
size_t idx_chain = 0; idx_chain < seg->
nb_chains; idx_chain++) {
827 for (
size_t idx_filter = 0; idx_filter < ch->
nb_filters; idx_filter++) {
871 "Could not set non-existent option '%s' to value '%s'\n",
953 const char *
tmp =
"[in]";
964 const char *
tmp =
"[out]";
1031 if (open_inputs_ptr) *open_inputs_ptr = user_inputs;
1033 if (open_outputs_ptr) *open_outputs_ptr = user_outputs;
static int link_inputs(AVFilterGraphSegment *seg, size_t idx_chain, size_t idx_filter, AVFilterInOut **inputs)
int(* func)(AVBPrint *dst, const char *in, const char *arg)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static int inout_add(AVFilterInOut **inouts, AVFilterContext *f, unsigned pad_idx, const char *label)
char * instance_name
Name to be used for this filter instance.
int avfilter_graph_segment_create_filters(AVFilterGraphSegment *seg, int flags)
Create filters specified in a graph segment.
int ff_filter_opt_parse(void *logctx, const AVClass *priv_class, AVDictionary **options, const char *args)
Parse filter options into a dictionary.
int av_dict_count(const AVDictionary *m)
Get number of entries in dictionary.
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
static int parse_sws_flags(const char **buf, char **dst, void *log_ctx)
struct AVFilterInOut * next
next input/input in the list, NULL if this is the last
static int fail_creation_pending(AVFilterGraphSegment *seg, const char *fn, const char *func)
unsigned nb_outputs
number of output pads
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce then the filter should push the output frames on the output link immediately As an exception to the previous rule if the input frame is enough to produce several output frames then the filter needs output only at least one per link The additional frames can be left buffered in the filter
const char * name
Filter name.
AVFilterPadParams ** inputs
A link between two filters.
static int chain_parse(void *logctx, const char **pchain, AVFilterChain **pch)
AVFilterPadParams ** outputs
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.
static void append_inout(AVFilterInOut **inouts, AVFilterInOut **element)
AVFilterContext * avfilter_graph_alloc_filter(AVFilterGraph *graph, const AVFilter *filter, const char *name)
Create a new filter instance in a filter graph.
static void pad_params_free(AVFilterPadParams **pfpp)
int avfilter_graph_segment_link(AVFilterGraphSegment *seg, int flags, AVFilterInOut **inputs, AVFilterInOut **outputs)
Link filters in a graph segment.
#define AVERROR_OPTION_NOT_FOUND
Option not found.
void avfilter_graph_segment_free(AVFilterGraphSegment **pseg)
Free the provided AVFilterGraphSegment and everything associated with it.
int avfilter_graph_segment_parse(AVFilterGraph *graph, const char *graph_str, int flags, AVFilterGraphSegment **pseg)
Parse a textual filtergraph description into an intermediate form.
void avfilter_inout_free(AVFilterInOut **inout)
Free the supplied list of AVFilterInOut and set *inout to NULL.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static unsigned find_linklabel(AVFilterGraphSegment *seg, const char *label, int output, size_t idx_chain, size_t idx_filter, AVFilterParams **pp)
AVFilterParams ** filters
static void chain_free(AVFilterChain **pch)
#define filters(fmt, type, inverse, clp, inverset, clip, one, clip_fn, packed)
int avfilter_graph_segment_init(AVFilterGraphSegment *seg, int flags)
Initialize all filter instances in a graph segment.
char * label
An av_malloc()'ed string containing the pad label.
const AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
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.
Parameters describing a filter to be created in a filtergraph.
AVFilterContext * filter
The filter context.
char * filter_name
Name of the AVFilter to be used.
AVFilterContext ** filters
AVFilterLink ** inputs
array of pointers to input links
AVFilterInOut * avfilter_inout_alloc(void)
Allocate a single AVFilterInOut entry.
AVFilterChain ** chains
A list of filter chain contained in this segment.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
int avfilter_graph_parse2(AVFilterGraph *graph, const char *filters, AVFilterInOut **inputs, AVFilterInOut **outputs)
Add a graph described by a string to a graph.
A parsed representation of a filtergraph segment.
int pad_idx
index of the filt_ctx pad to use for linking
char * scale_sws_opts
sws options to use for the auto-inserted scale filters
unsigned nb_inputs
number of input pads
AVFilterContext * filter_ctx
filter context associated to this input/output
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
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]".
char * scale_sws_opts
A string containing a colon-separated list of key=value options applied to all scale filters in this ...
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
static int link_outputs(AVFilterGraphSegment *seg, size_t idx_chain, size_t idx_filter, AVFilterInOut **outputs)
int av_opt_set_dict2(void *obj, AVDictionary **options, int search_flags)
Set all the options from a given dictionary on an object.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
AVFilterGraph * graph
The filtergraph this segment is associated with.
#define i(width, name, range_min, range_max)
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.
static AVFilterInOut * extract_inout(const char *label, AVFilterInOut **links)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
const char * name
Pad name.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output links
AVDictionary * opts
Options to be apllied to the filter.
int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem)
Add an element to a dynamic array.
static int linklabels_parse(void *logctx, const char **linklabels, AVFilterPadParams ***res, unsigned *nb_res)
static const AVFilterPad outputs[]
int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options)
Initialize a filter with the supplied dictionary of options.
A filterchain is a list of filter specifications.
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 log_unknown_opt(const AVFilterGraphSegment *seg)
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
#define AVERROR_FILTER_NOT_FOUND
Filter not found.
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 * av_strdup(const char *s)
Duplicate a string.
void avfilter_free(AVFilterContext *filter)
Free a filter context.
static void filter_params_free(AVFilterParams **pp)
char * name
unique name for this input/output in the list
#define flags(name, subs,...)
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.
int avfilter_graph_segment_apply_opts(AVFilterGraphSegment *seg, int flags)
Apply parsed options to filter instances in a graph segment.
const AVFilter * filter
the AVFilter of which this is an instance
A linked-list of the inputs/outputs of the filter chain.
static int filter_parse(void *logctx, const char **filter, AVFilterParams **pp)
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
Parameters of a filter's input or output pad.
AVFilterLink ** outputs
array of pointers to output links