FFmpeg
graphparser.c
Go to the documentation of this file.
1 /*
2  * filter graph parser
3  * Copyright (c) 2008 Vitor Sessak
4  * Copyright (c) 2007 Bobby Bingham
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #include <string.h>
24 #include <stdio.h>
25 
26 #include "libavutil/avstring.h"
27 #include "libavutil/mem.h"
28 #include "libavutil/opt.h"
29 
30 #include "avfilter.h"
31 
32 #define WHITESPACES " \n\t\r"
33 
34 /**
35  * Link two filters together.
36  *
37  * @see avfilter_link()
38  */
39 static int link_filter(AVFilterContext *src, int srcpad,
40  AVFilterContext *dst, int dstpad,
41  void *log_ctx)
42 {
43  int ret;
44  if ((ret = avfilter_link(src, srcpad, dst, dstpad))) {
45  av_log(log_ctx, AV_LOG_ERROR,
46  "Cannot create the link %s:%d -> %s:%d\n",
47  src->filter->name, srcpad, dst->filter->name, dstpad);
48  return ret;
49  }
50 
51  return 0;
52 }
53 
54 /**
55  * Parse the name of a link, which has the format "[linkname]".
56  *
57  * @return a pointer (that need to be freed after use) to the name
58  * between parenthesis
59  */
60 static char *parse_link_name(const char **buf, void *log_ctx)
61 {
62  const char *start = *buf;
63  char *name;
64  (*buf)++;
65 
66  name = av_get_token(buf, "]");
67  if (!name)
68  return NULL;
69 
70  if (!name[0]) {
71  av_log(log_ctx, AV_LOG_ERROR,
72  "Bad (empty?) label found in the following: \"%s\".\n", start);
73  goto fail;
74  }
75 
76  if (**buf != ']') {
77  av_log(log_ctx, AV_LOG_ERROR,
78  "Mismatched '[' found in the following: \"%s\".\n", start);
79  fail:
80  av_freep(&name);
81  return NULL;
82  }
83  (*buf)++;
84 
85  return name;
86 }
87 
88 /**
89  * Create an instance of a filter, initialize and insert it in the
90  * filtergraph in *ctx.
91  *
92  * @param filt_ctx put here a filter context in case of successful creation and configuration, NULL otherwise.
93  * @param ctx the filtergraph context
94  * @param index an index which is supposed to be unique for each filter instance added to the filtergraph
95  * @param name the name of the filter to create, can be filter name or filter_name\@id as instance name
96  * @param args the arguments provided to the filter during its initialization
97  * @param log_ctx the log context to use
98  * @return >= 0 in case of success, a negative AVERROR code otherwise
99  */
100 static int create_filter(AVFilterContext **filt_ctx, AVFilterGraph *ctx, int index,
101  const char *name, const char *args, void *log_ctx)
102 {
103  const AVFilter *filt;
104  char name2[30];
105  const char *inst_name = NULL, *filt_name = NULL;
106  int ret, k;
107 
108  av_strlcpy(name2, name, sizeof(name2));
109 
110  for (k = 0; name2[k]; k++) {
111  if (name2[k] == '@' && name[k+1]) {
112  name2[k] = 0;
113  inst_name = name;
114  filt_name = name2;
115  break;
116  }
117  }
118 
119  if (!inst_name) {
120  snprintf(name2, sizeof(name2), "Parsed_%s_%d", name, index);
121  inst_name = name2;
122  filt_name = name;
123  }
124 
125  filt = avfilter_get_by_name(filt_name);
126 
127  if (!filt) {
128  av_log(log_ctx, AV_LOG_ERROR,
129  "No such filter: '%s'\n", filt_name);
130  return AVERROR(EINVAL);
131  }
132 
133  *filt_ctx = avfilter_graph_alloc_filter(ctx, filt, inst_name);
134  if (!*filt_ctx) {
135  av_log(log_ctx, AV_LOG_ERROR,
136  "Error creating filter '%s'\n", filt_name);
137  return AVERROR(ENOMEM);
138  }
139 
140  if (!strcmp(filt_name, "scale") && ctx->scale_sws_opts) {
141  ret = av_set_options_string(*filt_ctx, ctx->scale_sws_opts, "=", ":");
142  if (ret < 0)
143  return ret;
144  }
145 
146  ret = avfilter_init_str(*filt_ctx, args);
147  if (ret < 0) {
148  av_log(log_ctx, AV_LOG_ERROR,
149  "Error initializing filter '%s'", filt_name);
150  if (args)
151  av_log(log_ctx, AV_LOG_ERROR, " with args '%s'", args);
152  av_log(log_ctx, AV_LOG_ERROR, "\n");
153  avfilter_free(*filt_ctx);
154  *filt_ctx = NULL;
155  }
156 
157  return ret;
158 }
159 
160 /**
161  * Parse a string of the form FILTER_NAME[=PARAMS], and create a
162  * corresponding filter instance which is added to graph with
163  * create_filter().
164  *
165  * @param filt_ctx Pointer that is set to the created and configured filter
166  * context on success, set to NULL on failure.
167  * @param filt_ctx put here a pointer to the created filter context on
168  * success, NULL otherwise
169  * @param buf pointer to the buffer to parse, *buf will be updated to
170  * point to the char next after the parsed string
171  * @param index an index which is assigned to the created filter
172  * instance, and which is supposed to be unique for each filter
173  * instance added to the filtergraph
174  * @return >= 0 in case of success, a negative AVERROR code otherwise
175  */
176 static int parse_filter(AVFilterContext **filt_ctx, const char **buf, AVFilterGraph *graph,
177  int index, void *log_ctx)
178 {
179  char *opts = NULL;
180  char *name = av_get_token(buf, "=,;[");
181  int ret;
182 
183  if (!name)
184  return AVERROR(ENOMEM);
185 
186  if (**buf == '=') {
187  (*buf)++;
188  opts = av_get_token(buf, "[],;");
189  if (!opts) {
190  av_free(name);
191  return AVERROR(ENOMEM);
192  }
193  }
194 
195  ret = create_filter(filt_ctx, graph, index, name, opts, log_ctx);
196  av_free(name);
197  av_free(opts);
198  return ret;
199 }
200 
202 {
203  return av_mallocz(sizeof(AVFilterInOut));
204 }
205 
207 {
208  while (*inout) {
209  AVFilterInOut *next = (*inout)->next;
210  av_freep(&(*inout)->name);
211  av_freep(inout);
212  *inout = next;
213  }
214 }
215 
216 static AVFilterInOut *extract_inout(const char *label, AVFilterInOut **links)
217 {
219 
220  while (*links && (!(*links)->name || strcmp((*links)->name, label)))
221  links = &((*links)->next);
222 
223  ret = *links;
224 
225  if (ret) {
226  *links = ret->next;
227  ret->next = NULL;
228  }
229 
230  return ret;
231 }
232 
233 static void insert_inout(AVFilterInOut **inouts, AVFilterInOut *element)
234 {
235  element->next = *inouts;
236  *inouts = element;
237 }
238 
239 static void append_inout(AVFilterInOut **inouts, AVFilterInOut **element)
240 {
241  while (*inouts && (*inouts)->next)
242  inouts = &((*inouts)->next);
243 
244  if (!*inouts)
245  *inouts = *element;
246  else
247  (*inouts)->next = *element;
248  *element = NULL;
249 }
250 
251 static int link_filter_inouts(AVFilterContext *filt_ctx,
252  AVFilterInOut **curr_inputs,
253  AVFilterInOut **open_inputs, void *log_ctx)
254 {
255  int pad, ret;
256 
257  for (pad = 0; pad < filt_ctx->nb_inputs; pad++) {
258  AVFilterInOut *p = *curr_inputs;
259 
260  if (p) {
261  *curr_inputs = (*curr_inputs)->next;
262  p->next = NULL;
263  } else if (!(p = av_mallocz(sizeof(*p))))
264  return AVERROR(ENOMEM);
265 
266  if (p->filter_ctx) {
267  ret = link_filter(p->filter_ctx, p->pad_idx, filt_ctx, pad, log_ctx);
268  av_freep(&p->name);
269  av_freep(&p);
270  if (ret < 0)
271  return ret;
272  } else {
273  p->filter_ctx = filt_ctx;
274  p->pad_idx = pad;
275  append_inout(open_inputs, &p);
276  }
277  }
278 
279  if (*curr_inputs) {
280  av_log(log_ctx, AV_LOG_ERROR,
281  "Too many inputs specified for the \"%s\" filter.\n",
282  filt_ctx->filter->name);
283  return AVERROR(EINVAL);
284  }
285 
286  pad = filt_ctx->nb_outputs;
287  while (pad--) {
288  AVFilterInOut *currlinkn = av_mallocz(sizeof(AVFilterInOut));
289  if (!currlinkn)
290  return AVERROR(ENOMEM);
291  currlinkn->filter_ctx = filt_ctx;
292  currlinkn->pad_idx = pad;
293  insert_inout(curr_inputs, currlinkn);
294  }
295 
296  return 0;
297 }
298 
299 static int parse_inputs(const char **buf, AVFilterInOut **curr_inputs,
300  AVFilterInOut **open_outputs, void *log_ctx)
301 {
302  AVFilterInOut *parsed_inputs = NULL;
303  int pad = 0;
304 
305  while (**buf == '[') {
306  char *name = parse_link_name(buf, log_ctx);
307  AVFilterInOut *match;
308 
309  if (!name) {
310  avfilter_inout_free(&parsed_inputs);
311  return AVERROR(EINVAL);
312  }
313 
314  /* First check if the label is not in the open_outputs list */
315  match = extract_inout(name, open_outputs);
316 
317  if (match) {
318  av_free(name);
319  } else {
320  /* Not in the list, so add it as an input */
321  if (!(match = av_mallocz(sizeof(AVFilterInOut)))) {
322  avfilter_inout_free(&parsed_inputs);
323  av_free(name);
324  return AVERROR(ENOMEM);
325  }
326  match->name = name;
327  match->pad_idx = pad;
328  }
329 
330  append_inout(&parsed_inputs, &match);
331 
332  *buf += strspn(*buf, WHITESPACES);
333  pad++;
334  }
335 
336  append_inout(&parsed_inputs, curr_inputs);
337  *curr_inputs = parsed_inputs;
338 
339  return pad;
340 }
341 
342 static int parse_outputs(const char **buf, AVFilterInOut **curr_inputs,
343  AVFilterInOut **open_inputs,
344  AVFilterInOut **open_outputs, void *log_ctx)
345 {
346  int ret, pad = 0;
347 
348  while (**buf == '[') {
349  char *name = parse_link_name(buf, log_ctx);
350  AVFilterInOut *match;
351 
352  AVFilterInOut *input = *curr_inputs;
353 
354  if (!name)
355  return AVERROR(EINVAL);
356 
357  if (!input) {
358  av_log(log_ctx, AV_LOG_ERROR,
359  "No output pad can be associated to link label '%s'.\n", name);
360  av_free(name);
361  return AVERROR(EINVAL);
362  }
363  *curr_inputs = (*curr_inputs)->next;
364 
365  /* First check if the label is not in the open_inputs list */
366  match = extract_inout(name, open_inputs);
367 
368  if (match) {
369  ret = link_filter(input->filter_ctx, input->pad_idx,
370  match->filter_ctx, match->pad_idx, log_ctx);
371  av_freep(&match->name);
372  av_freep(&name);
373  av_freep(&match);
374  av_freep(&input);
375  if (ret < 0)
376  return ret;
377  } else {
378  /* Not in the list, so add the first input as an open_output */
379  input->name = name;
380  insert_inout(open_outputs, input);
381  }
382  *buf += strspn(*buf, WHITESPACES);
383  pad++;
384  }
385 
386  return pad;
387 }
388 
389 static int parse_sws_flags(const char **buf, AVFilterGraph *graph)
390 {
391  char *p = strchr(*buf, ';');
392 
393  if (strncmp(*buf, "sws_flags=", 10))
394  return 0;
395 
396  if (!p) {
397  av_log(graph, AV_LOG_ERROR, "sws_flags not terminated with ';'.\n");
398  return AVERROR(EINVAL);
399  }
400 
401  *buf += 4; // keep the 'flags=' part
402 
403  av_freep(&graph->scale_sws_opts);
404  if (!(graph->scale_sws_opts = av_mallocz(p - *buf + 1)))
405  return AVERROR(ENOMEM);
406  av_strlcpy(graph->scale_sws_opts, *buf, p - *buf + 1);
407 
408  *buf = p + 1;
409  return 0;
410 }
411 
415 {
416  int index = 0, ret = 0;
417  char chr = 0;
418 
419  AVFilterInOut *curr_inputs = NULL, *open_inputs = NULL, *open_outputs = NULL;
420 
421  filters += strspn(filters, WHITESPACES);
422 
423  if ((ret = parse_sws_flags(&filters, graph)) < 0)
424  goto end;
425 
426  do {
428  filters += strspn(filters, WHITESPACES);
429 
430  if ((ret = parse_inputs(&filters, &curr_inputs, &open_outputs, graph)) < 0)
431  goto end;
432  if ((ret = parse_filter(&filter, &filters, graph, index, graph)) < 0)
433  goto end;
434 
435 
436  if ((ret = link_filter_inouts(filter, &curr_inputs, &open_inputs, graph)) < 0)
437  goto end;
438 
439  if ((ret = parse_outputs(&filters, &curr_inputs, &open_inputs, &open_outputs,
440  graph)) < 0)
441  goto end;
442 
443  filters += strspn(filters, WHITESPACES);
444  chr = *filters++;
445 
446  if (chr == ';' && curr_inputs)
447  append_inout(&open_outputs, &curr_inputs);
448  index++;
449  } while (chr == ',' || chr == ';');
450 
451  if (chr) {
452  av_log(graph, AV_LOG_ERROR,
453  "Unable to parse graph description substring: \"%s\"\n",
454  filters - 1);
455  ret = AVERROR(EINVAL);
456  goto end;
457  }
458 
459  append_inout(&open_outputs, &curr_inputs);
460 
461 
462  *inputs = open_inputs;
463  *outputs = open_outputs;
464  return 0;
465 
466 end:
467  while (graph->nb_filters)
468  avfilter_free(graph->filters[0]);
469  av_freep(&graph->filters);
470  avfilter_inout_free(&open_inputs);
471  avfilter_inout_free(&open_outputs);
472  avfilter_inout_free(&curr_inputs);
473 
474  *inputs = NULL;
475  *outputs = NULL;
476 
477  return ret;
478 }
479 
481  AVFilterInOut *open_inputs,
482  AVFilterInOut *open_outputs, void *log_ctx)
483 {
484  int ret;
485  AVFilterInOut *cur, *match, *inputs = NULL, *outputs = NULL;
486 
487  if ((ret = avfilter_graph_parse2(graph, filters, &inputs, &outputs)) < 0)
488  goto fail;
489 
490  /* First input can be omitted if it is "[in]" */
491  if (inputs && !inputs->name)
492  inputs->name = av_strdup("in");
493  for (cur = inputs; cur; cur = cur->next) {
494  if (!cur->name) {
495  av_log(log_ctx, AV_LOG_ERROR,
496  "Not enough inputs specified for the \"%s\" filter.\n",
497  cur->filter_ctx->filter->name);
498  ret = AVERROR(EINVAL);
499  goto fail;
500  }
501  if (!(match = extract_inout(cur->name, &open_outputs)))
502  continue;
503  ret = avfilter_link(match->filter_ctx, match->pad_idx,
504  cur->filter_ctx, cur->pad_idx);
505  avfilter_inout_free(&match);
506  if (ret < 0)
507  goto fail;
508  }
509 
510  /* Last output can be omitted if it is "[out]" */
511  if (outputs && !outputs->name)
512  outputs->name = av_strdup("out");
513  for (cur = outputs; cur; cur = cur->next) {
514  if (!cur->name) {
515  av_log(log_ctx, AV_LOG_ERROR,
516  "Invalid filterchain containing an unlabelled output pad: \"%s\"\n",
517  filters);
518  ret = AVERROR(EINVAL);
519  goto fail;
520  }
521  if (!(match = extract_inout(cur->name, &open_inputs)))
522  continue;
523  ret = avfilter_link(cur->filter_ctx, cur->pad_idx,
524  match->filter_ctx, match->pad_idx);
525  avfilter_inout_free(&match);
526  if (ret < 0)
527  goto fail;
528  }
529 
530  fail:
531  if (ret < 0) {
532  while (graph->nb_filters)
533  avfilter_free(graph->filters[0]);
534  av_freep(&graph->filters);
535  }
538  avfilter_inout_free(&open_inputs);
539  avfilter_inout_free(&open_outputs);
540  return ret;
541 }
542 
544  AVFilterInOut **open_inputs_ptr, AVFilterInOut **open_outputs_ptr,
545  void *log_ctx)
546 {
547  int index = 0, ret = 0;
548  char chr = 0;
549 
550  AVFilterInOut *curr_inputs = NULL;
551  AVFilterInOut *open_inputs = open_inputs_ptr ? *open_inputs_ptr : NULL;
552  AVFilterInOut *open_outputs = open_outputs_ptr ? *open_outputs_ptr : NULL;
553 
554  if ((ret = parse_sws_flags(&filters, graph)) < 0)
555  goto end;
556 
557  do {
559  const char *filterchain = filters;
560  filters += strspn(filters, WHITESPACES);
561 
562  if ((ret = parse_inputs(&filters, &curr_inputs, &open_outputs, log_ctx)) < 0)
563  goto end;
564 
565  if ((ret = parse_filter(&filter, &filters, graph, index, log_ctx)) < 0)
566  goto end;
567 
568  if (filter->nb_inputs == 1 && !curr_inputs && !index) {
569  /* First input pad, assume it is "[in]" if not specified */
570  const char *tmp = "[in]";
571  if ((ret = parse_inputs(&tmp, &curr_inputs, &open_outputs, log_ctx)) < 0)
572  goto end;
573  }
574 
575  if ((ret = link_filter_inouts(filter, &curr_inputs, &open_inputs, log_ctx)) < 0)
576  goto end;
577 
578  if ((ret = parse_outputs(&filters, &curr_inputs, &open_inputs, &open_outputs,
579  log_ctx)) < 0)
580  goto end;
581 
582  filters += strspn(filters, WHITESPACES);
583  chr = *filters++;
584 
585  if (chr == ';' && curr_inputs) {
586  av_log(log_ctx, AV_LOG_ERROR,
587  "Invalid filterchain containing an unlabelled output pad: \"%s\"\n",
588  filterchain);
589  ret = AVERROR(EINVAL);
590  goto end;
591  }
592  index++;
593  } while (chr == ',' || chr == ';');
594 
595  if (chr) {
596  av_log(log_ctx, AV_LOG_ERROR,
597  "Unable to parse graph description substring: \"%s\"\n",
598  filters - 1);
599  ret = AVERROR(EINVAL);
600  goto end;
601  }
602 
603  if (curr_inputs) {
604  /* Last output pad, assume it is "[out]" if not specified */
605  const char *tmp = "[out]";
606  if ((ret = parse_outputs(&tmp, &curr_inputs, &open_inputs, &open_outputs,
607  log_ctx)) < 0)
608  goto end;
609  }
610 
611 end:
612  /* clear open_in/outputs only if not passed as parameters */
613  if (open_inputs_ptr) *open_inputs_ptr = open_inputs;
614  else avfilter_inout_free(&open_inputs);
615  if (open_outputs_ptr) *open_outputs_ptr = open_outputs;
616  else avfilter_inout_free(&open_outputs);
617  avfilter_inout_free(&curr_inputs);
618 
619  if (ret < 0) {
620  while (graph->nb_filters)
621  avfilter_free(graph->filters[0]);
622  av_freep(&graph->filters);
623  }
624  return ret;
625 }
name
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
Definition: writing_filters.txt:88
AVERROR
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
opt.h
av_get_token
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...
Definition: avstring.c:154
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:28
AVFilterInOut::next
struct AVFilterInOut * next
next input/input in the list, NULL if this is the last
Definition: avfilter.h:1036
AVFilterContext::nb_outputs
unsigned nb_outputs
number of output pads
Definition: avfilter.h:415
link_filter_inouts
static int link_filter_inouts(AVFilterContext *filt_ctx, AVFilterInOut **curr_inputs, AVFilterInOut **open_inputs, void *log_ctx)
Definition: graphparser.c:251
filter
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
Definition: filter_design.txt:228
link_filter
static int link_filter(AVFilterContext *src, int srcpad, AVFilterContext *dst, int dstpad, void *log_ctx)
Link two filters together.
Definition: graphparser.c:39
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:175
av_set_options_string
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.
Definition: opt.c:1587
append_inout
static void append_inout(AVFilterInOut **inouts, AVFilterInOut **element)
Definition: graphparser.c:239
avfilter_graph_alloc_filter
AVFilterContext * avfilter_graph_alloc_filter(AVFilterGraph *graph, const AVFilter *filter, const char *name)
Create a new filter instance in a filter graph.
Definition: avfiltergraph.c:165
fail
#define fail()
Definition: checkasm.h:134
avfilter_inout_free
void avfilter_inout_free(AVFilterInOut **inout)
Free the supplied list of AVFilterInOut and set *inout to NULL.
Definition: graphparser.c:206
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
filters
#define filters(fmt, type, inverse, clp, inverset, clip, one, clip_fn, packed)
Definition: af_crystalizer.c:55
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:172
ctx
AVFormatContext * ctx
Definition: movenc.c:48
avfilter_get_by_name
const AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
Definition: allfilters.c:604
opts
AVDictionary * opts
Definition: movenc.c:50
NULL
#define NULL
Definition: coverity.c:32
AVFilterGraph::filters
AVFilterContext ** filters
Definition: avfilter.h:867
avfilter_inout_alloc
AVFilterInOut * avfilter_inout_alloc(void)
Allocate a single AVFilterInOut entry.
Definition: graphparser.c:201
AVFilterGraph
Definition: avfilter.h:865
inputs
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
Definition: filter_design.txt:243
avfilter_graph_parse2
int avfilter_graph_parse2(AVFilterGraph *graph, const char *filters, AVFilterInOut **inputs, AVFilterInOut **outputs)
Add a graph described by a string to a graph.
Definition: graphparser.c:412
test::name
const char * name
Definition: idctdsp.c:35
index
int index
Definition: gxfenc.c:89
AVFilterInOut::pad_idx
int pad_idx
index of the filt_ctx pad to use for linking
Definition: avfilter.h:1033
AVFilterGraph::scale_sws_opts
char * scale_sws_opts
sws options to use for the auto-inserted scale filters
Definition: avfilter.h:870
AVFilterContext::nb_inputs
unsigned nb_inputs
number of input pads
Definition: avfilter.h:411
AVFilterInOut::filter_ctx
AVFilterContext * filter_ctx
filter context associated to this input/output
Definition: avfilter.h:1030
avfilter_link
int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
Link two filters together.
Definition: avfilter.c:148
create_filter
static int create_filter(AVFilterContext **filt_ctx, AVFilterGraph *ctx, int index, const char *name, const char *args, void *log_ctx)
Create an instance of a filter, initialize and insert it in the filtergraph in *ctx.
Definition: graphparser.c:100
parse_link_name
static char * parse_link_name(const char **buf, void *log_ctx)
Parse the name of a link, which has the format "[linkname]".
Definition: graphparser.c:60
insert_inout
static void insert_inout(AVFilterInOut **inouts, AVFilterInOut *element)
Definition: graphparser.c:233
WHITESPACES
#define WHITESPACES
Definition: graphparser.c:32
parse_filter
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 ...
Definition: graphparser.c:176
input
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some input
Definition: filter_design.txt:172
avfilter_init_str
int avfilter_init_str(AVFilterContext *filter, const char *args)
Initialize a filter with the supplied parameters.
Definition: avfilter.c:904
parse_outputs
static int parse_outputs(const char **buf, AVFilterInOut **curr_inputs, AVFilterInOut **open_inputs, AVFilterInOut **open_outputs, void *log_ctx)
Definition: graphparser.c:342
avfilter_graph_parse_ptr
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.
Definition: graphparser.c:543
extract_inout
static AVFilterInOut * extract_inout(const char *label, AVFilterInOut **links)
Definition: graphparser.c:216
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:264
filt
static const int8_t filt[NUMTAPS *2]
Definition: af_earwax.c:39
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:55
AVFilter
Filter definition.
Definition: avfilter.h:171
ret
ret
Definition: filter_design.txt:187
links
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
Definition: filter_design.txt:14
parse_inputs
static int parse_inputs(const char **buf, AVFilterInOut **curr_inputs, AVFilterInOut **open_outputs, void *log_ctx)
Definition: graphparser.c:299
avfilter.h
AVFilterContext
An instance of a filter.
Definition: avfilter.h:402
avfilter_graph_parse
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.
Definition: graphparser.c:480
av_strdup
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:280
mem.h
avfilter_free
void avfilter_free(AVFilterContext *filter)
Free a filter context.
Definition: avfilter.c:747
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
parse_sws_flags
static int parse_sws_flags(const char **buf, AVFilterGraph *graph)
Definition: graphparser.c:389
AVFilterInOut::name
char * name
unique name for this input/output in the list
Definition: avfilter.h:1027
av_strlcpy
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.
Definition: avstring.c:86
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVFilterGraph::nb_filters
unsigned nb_filters
Definition: avfilter.h:868
avstring.h
AVFilterContext::filter
const AVFilter * filter
the AVFilter of which this is an instance
Definition: avfilter.h:405
AVFilterInOut
A linked-list of the inputs/outputs of the filter chain.
Definition: avfilter.h:1025
snprintf
#define snprintf
Definition: snprintf.h:34