FFmpeg
avfiltergraph.c
Go to the documentation of this file.
1 /*
2  * filter graphs
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 "config.h"
24 
25 #include <string.h>
26 
27 #include "libavutil/avassert.h"
28 #include "libavutil/bprint.h"
30 #include "libavutil/imgutils.h"
31 #include "libavutil/mem.h"
32 #include "libavutil/opt.h"
33 #include "libavutil/pixdesc.h"
34 
35 
36 #include "avfilter.h"
37 #include "avfilter_internal.h"
38 #include "buffersink.h"
39 #include "filters.h"
40 #include "formats.h"
41 #include "framequeue.h"
42 #include "video.h"
43 
44 #define OFFSET(x) offsetof(AVFilterGraph, x)
45 #define F AV_OPT_FLAG_FILTERING_PARAM
46 #define V AV_OPT_FLAG_VIDEO_PARAM
47 #define A AV_OPT_FLAG_AUDIO_PARAM
48 static const AVOption filtergraph_options[] = {
49  { "thread_type", "Allowed thread types", OFFSET(thread_type), AV_OPT_TYPE_FLAGS,
50  { .i64 = AVFILTER_THREAD_SLICE }, 0, INT_MAX, F|V|A, .unit = "thread_type" },
51  { "slice", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AVFILTER_THREAD_SLICE }, .flags = F|V|A, .unit = "thread_type" },
52  { "threads", "Maximum number of threads", OFFSET(nb_threads), AV_OPT_TYPE_INT,
53  { .i64 = 0 }, 0, INT_MAX, F|V|A, .unit = "threads"},
54  {"auto", "autodetect a suitable number of threads to use", 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, .flags = F|V|A, .unit = "threads"},
55  {"scale_sws_opts" , "default scale filter options" , OFFSET(scale_sws_opts) ,
56  AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, F|V },
57  {"aresample_swr_opts" , "default aresample filter options" , OFFSET(aresample_swr_opts) ,
58  AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, F|A },
59  {"max_buffered_frames" , "maximum number of buffered frames allowed", OFFSET(max_buffered_frames),
60  AV_OPT_TYPE_UINT, {.i64 = 0}, 0, UINT_MAX, F|V|A },
61  { NULL },
62 };
63 
64 static const AVClass filtergraph_class = {
65  .class_name = "AVFilterGraph",
66  .item_name = av_default_item_name,
67  .version = LIBAVUTIL_VERSION_INT,
68  .option = filtergraph_options,
69  .category = AV_CLASS_CATEGORY_FILTER,
70 };
71 
72 #if !HAVE_THREADS
74 {
75 }
76 
78 {
79  graph->p.thread_type = 0;
80  graph->p.nb_threads = 1;
81  return 0;
82 }
83 #endif
84 
86 {
87  FFFilterGraph *graph = av_mallocz(sizeof(*graph));
89 
90  if (!graph)
91  return NULL;
92 
93  ret = &graph->p;
94  ret->av_class = &filtergraph_class;
97 
98  return ret;
99 }
100 
102 {
103  int i, j;
104  for (i = 0; i < graph->nb_filters; i++) {
105  if (graph->filters[i] == filter) {
106  FFSWAP(AVFilterContext*, graph->filters[i],
107  graph->filters[graph->nb_filters - 1]);
108  graph->nb_filters--;
109  filter->graph = NULL;
110  for (j = 0; j<filter->nb_outputs; j++)
111  if (filter->outputs[j])
112  ff_filter_link(filter->outputs[j])->graph = NULL;
113 
114  return;
115  }
116  }
117 }
118 
120 {
121  AVFilterGraph *graph = *graphp;
122  FFFilterGraph *graphi = fffiltergraph(graph);
123 
124  if (!graph)
125  return;
126 
127  while (graph->nb_filters)
128  avfilter_free(graph->filters[0]);
129 
130  ff_graph_thread_free(graphi);
131 
132  av_freep(&graphi->sink_links);
133 
134  av_opt_free(graph);
135 
136  av_freep(&graph->filters);
137  av_freep(graphp);
138 }
139 
141  const char *name, const char *args, void *opaque,
142  AVFilterGraph *graph_ctx)
143 {
144  int ret;
145 
146  *filt_ctx = avfilter_graph_alloc_filter(graph_ctx, filt, name);
147  if (!*filt_ctx)
148  return AVERROR(ENOMEM);
149 
150  ret = avfilter_init_str(*filt_ctx, args);
151  if (ret < 0)
152  goto fail;
153 
154  return 0;
155 
156 fail:
157  avfilter_free(*filt_ctx);
158  *filt_ctx = NULL;
159  return ret;
160 }
161 
163 {
165 }
166 
168  const AVFilter *filter,
169  const char *name)
170 {
172  FFFilterGraph *graphi = fffiltergraph(graph);
173 
174  if (graph->thread_type && !graphi->thread_execute) {
175  if (graph->execute) {
176  graphi->thread_execute = graph->execute;
177  } else {
178  int ret = ff_graph_thread_init(graphi);
179  if (ret < 0) {
180  av_log(graph, AV_LOG_ERROR, "Error initializing threading: %s.\n", av_err2str(ret));
181  return NULL;
182  }
183  }
184  }
185 
186  filters = av_realloc_array(graph->filters, graph->nb_filters + 1, sizeof(*filters));
187  if (!filters)
188  return NULL;
189  graph->filters = filters;
190 
192  if (!s)
193  return NULL;
194 
195  graph->filters[graph->nb_filters++] = s;
196 
197  s->graph = graph;
198 
199  return s;
200 }
201 
202 /**
203  * Check for the validity of graph.
204  *
205  * A graph is considered valid if all its input and output pads are
206  * connected.
207  *
208  * @return >= 0 in case of success, a negative value otherwise
209  */
210 static int graph_check_validity(AVFilterGraph *graph, void *log_ctx)
211 {
213  int i, j;
214 
215  for (i = 0; i < graph->nb_filters; i++) {
216  const AVFilterPad *pad;
217  filt = graph->filters[i];
218 
219  for (j = 0; j < filt->nb_inputs; j++) {
220  if (!filt->inputs[j] || !filt->inputs[j]->src) {
221  pad = &filt->input_pads[j];
222  av_log(log_ctx, AV_LOG_ERROR,
223  "Input pad \"%s\" with type %s of the filter instance \"%s\" of %s not connected to any source\n",
224  pad->name, av_get_media_type_string(pad->type), filt->name, filt->filter->name);
225  return AVERROR(EINVAL);
226  }
227  }
228 
229  for (j = 0; j < filt->nb_outputs; j++) {
230  if (!filt->outputs[j] || !filt->outputs[j]->dst) {
231  pad = &filt->output_pads[j];
232  av_log(log_ctx, AV_LOG_ERROR,
233  "Output pad \"%s\" with type %s of the filter instance \"%s\" of %s not connected to any destination\n",
234  pad->name, av_get_media_type_string(pad->type), filt->name, filt->filter->name);
235  return AVERROR(EINVAL);
236  }
237  }
238  }
239 
240  return 0;
241 }
242 
243 /**
244  * Configure all the links of graphctx.
245  *
246  * @return >= 0 in case of success, a negative value otherwise
247  */
248 static int graph_config_links(AVFilterGraph *graph, void *log_ctx)
249 {
251  int i, ret;
252 
253  for (i = 0; i < graph->nb_filters; i++) {
254  filt = graph->filters[i];
255 
256  if (!filt->nb_outputs) {
258  return ret;
259  }
260  }
261 
262  return 0;
263 }
264 
265 static int graph_check_links(AVFilterGraph *graph, void *log_ctx)
266 {
268  AVFilterLink *l;
269  unsigned i, j;
270  int ret;
271 
272  for (i = 0; i < graph->nb_filters; i++) {
273  f = graph->filters[i];
274  for (j = 0; j < f->nb_outputs; j++) {
275  l = f->outputs[j];
276  if (l->type == AVMEDIA_TYPE_VIDEO) {
277  ret = av_image_check_size2(l->w, l->h, INT64_MAX, l->format, 0, f);
278  if (ret < 0)
279  return ret;
280  }
281  }
282  }
283  return 0;
284 }
285 
287 {
288  int i;
289 
290  for (i = 0; i < graph->nb_filters; i++)
291  if (graph->filters[i]->name && !strcmp(name, graph->filters[i]->name))
292  return graph->filters[i];
293 
294  return NULL;
295 }
296 
298 {
299  int ret;
300 
301  switch (link->type) {
302 
303  case AVMEDIA_TYPE_VIDEO:
304  if ((ret = ff_formats_check_pixel_formats(log, cfg->formats)) < 0 ||
308  return ret;
309  break;
310 
311  case AVMEDIA_TYPE_AUDIO:
312  if ((ret = ff_formats_check_sample_formats(log, cfg->formats)) < 0 ||
315  return ret;
316  break;
317 
318  default:
319  av_assert0(!"reached");
320  }
321  return 0;
322 }
323 
324 /**
325  * Check the validity of the formats / etc. lists set by query_formats().
326  *
327  * In particular, check they do not contain any redundant element.
328  */
330 {
331  unsigned i;
332  int ret;
333 
334  for (i = 0; i < ctx->nb_inputs; i++) {
335  ret = filter_link_check_formats(ctx, ctx->inputs[i], &ctx->inputs[i]->outcfg);
336  if (ret < 0)
337  return ret;
338  }
339  for (i = 0; i < ctx->nb_outputs; i++) {
340  ret = filter_link_check_formats(ctx, ctx->outputs[i], &ctx->outputs[i]->incfg);
341  if (ret < 0)
342  return ret;
343  }
344  return 0;
345 }
346 
348 {
349  const FFFilter *const filter = fffilter(ctx->filter);
350  int ret;
351 
352  if (filter->formats_state == FF_FILTER_FORMATS_QUERY_FUNC) {
353  if ((ret = filter->formats.query_func(ctx)) < 0) {
354  if (ret != AVERROR(EAGAIN))
355  av_log(ctx, AV_LOG_ERROR, "Query format failed for '%s': %s\n",
356  ctx->name, av_err2str(ret));
357  return ret;
358  }
359  } else if (filter->formats_state == FF_FILTER_FORMATS_QUERY_FUNC2) {
360  AVFilterFormatsConfig *cfg_in_stack[64], *cfg_out_stack[64];
361  AVFilterFormatsConfig **cfg_in_dyn = NULL, **cfg_out_dyn = NULL;
362  AVFilterFormatsConfig **cfg_in, **cfg_out;
363 
364  if (ctx->nb_inputs > FF_ARRAY_ELEMS(cfg_in_stack)) {
365  cfg_in_dyn = av_malloc_array(ctx->nb_inputs, sizeof(*cfg_in_dyn));
366  if (!cfg_in_dyn)
367  return AVERROR(ENOMEM);
368  cfg_in = cfg_in_dyn;
369  } else
370  cfg_in = ctx->nb_inputs ? cfg_in_stack : NULL;
371 
372  for (unsigned i = 0; i < ctx->nb_inputs; i++) {
373  AVFilterLink *l = ctx->inputs[i];
374  cfg_in[i] = &l->outcfg;
375  }
376 
377  if (ctx->nb_outputs > FF_ARRAY_ELEMS(cfg_out_stack)) {
378  cfg_out_dyn = av_malloc_array(ctx->nb_outputs, sizeof(*cfg_out_dyn));
379  if (!cfg_out_dyn) {
380  av_freep(&cfg_in_dyn);
381  return AVERROR(ENOMEM);
382  }
383  cfg_out = cfg_out_dyn;
384  } else
385  cfg_out = ctx->nb_outputs ? cfg_out_stack : NULL;
386 
387  for (unsigned i = 0; i < ctx->nb_outputs; i++) {
388  AVFilterLink *l = ctx->outputs[i];
389  cfg_out[i] = &l->incfg;
390  }
391 
392  ret = filter->formats.query_func2(ctx, cfg_in, cfg_out);
393  av_freep(&cfg_in_dyn);
394  av_freep(&cfg_out_dyn);
395  if (ret < 0) {
396  if (ret != AVERROR(EAGAIN))
397  av_log(ctx, AV_LOG_ERROR, "Query format failed for '%s': %s\n",
398  ctx->name, av_err2str(ret));
399  return ret;
400  }
401  }
402 
403  if (filter->formats_state == FF_FILTER_FORMATS_QUERY_FUNC ||
404  filter->formats_state == FF_FILTER_FORMATS_QUERY_FUNC2) {
406  if (ret < 0)
407  return ret;
408  }
409 
411 }
412 
414 {
415  int i;
416 
417  for (i = 0; i < f->nb_inputs; i++) {
418  if (!f->inputs[i]->outcfg.formats)
419  return 0;
420  if (f->inputs[i]->type == AVMEDIA_TYPE_VIDEO &&
421  !(f->inputs[i]->outcfg.color_ranges &&
422  f->inputs[i]->outcfg.color_spaces &&
423  f->inputs[i]->outcfg.alpha_modes))
424  return 0;
425  if (f->inputs[i]->type == AVMEDIA_TYPE_AUDIO &&
426  !(f->inputs[i]->outcfg.samplerates &&
427  f->inputs[i]->outcfg.channel_layouts))
428  return 0;
429  }
430  for (i = 0; i < f->nb_outputs; i++) {
431  if (!f->outputs[i]->incfg.formats)
432  return 0;
433  if (f->outputs[i]->type == AVMEDIA_TYPE_VIDEO &&
434  !(f->outputs[i]->incfg.color_ranges &&
435  f->outputs[i]->incfg.color_spaces &&
436  f->outputs[i]->incfg.alpha_modes))
437  return 0;
438  if (f->outputs[i]->type == AVMEDIA_TYPE_AUDIO &&
439  !(f->outputs[i]->incfg.samplerates &&
440  f->outputs[i]->incfg.channel_layouts))
441  return 0;
442  }
443  return 1;
444 }
445 
446 static void print_formats(void *log_ctx, int level, enum AVMediaType type,
447  const AVFilterFormats *formats)
448 {
449  AVBPrint bp;
451 
452  switch (type) {
453  case AVMEDIA_TYPE_VIDEO:
454  for (unsigned i = 0; i < formats->nb_formats; i++)
455  av_bprintf(&bp, "%s%s", bp.len ? " " : "", av_get_pix_fmt_name(formats->formats[i]));
456  break;
457  case AVMEDIA_TYPE_AUDIO:
458  for (unsigned i = 0; i < formats->nb_formats; i++)
459  av_bprintf(&bp, "%s%s", bp.len ? " " : "", av_get_sample_fmt_name(formats->formats[i]));
460  break;
461  default:
462  av_bprintf(&bp, "(unknown)");
463  break;
464  }
465 
466  if (av_bprint_is_complete(&bp)) {
467  av_log(log_ctx, level, "%s\n", bp.str);
468  } else {
469  av_log(log_ctx, level, "(out of memory)\n");
470  }
471  av_bprint_finalize(&bp, NULL);
472 }
473 
474 static void print_link_formats(void *log_ctx, int level, const AVFilterLink *l)
475 {
476  if (av_log_get_level() < level)
477  return;
478 
479  av_log(log_ctx, level, "Link '%s.%s' -> '%s.%s':\n"
480  " src: ", l->src->name, l->srcpad->name, l->dst->name, l->dstpad->name);
481  print_formats(log_ctx, level, l->type, l->incfg.formats);
482  av_log(log_ctx, level, " dst: ");
483  print_formats(log_ctx, level, l->type, l->outcfg.formats);
484 }
485 
486 static void print_filter_formats(void *log_ctx, int level, const AVFilterContext *f)
487 {
488  if (av_log_get_level() < level)
489  return;
490 
491  av_log(log_ctx, level, "Filter '%s' formats:\n", f->name);
492  for (int i = 0; i < f->nb_inputs; i++) {
493  av_log(log_ctx, level, " in[%d] '%s': ", i, f->input_pads[i].name);
494  print_formats(log_ctx, level, f->inputs[i]->type, f->inputs[i]->outcfg.formats);
495  }
496  for (int i = 0; i < f->nb_outputs; i++) {
497  av_log(log_ctx, level, " out[%d] '%s': ", i, f->output_pads[i].name);
498  print_formats(log_ctx, level, f->outputs[i]->type, f->outputs[i]->incfg.formats);
499  }
500 }
501 
502 /**
503  * Perform one round of query_formats() and merging formats lists on the
504  * filter graph.
505  * @return >=0 if all links formats lists could be queried and merged;
506  * AVERROR(EAGAIN) some progress was made in the queries or merging
507  * and a later call may succeed;
508  * AVERROR(EIO) (may be changed) plus a log message if no progress
509  * was made and the negotiation is stuck;
510  * a negative error code if some other error happened
511  */
512 static int query_formats(AVFilterGraph *graph, void *log_ctx)
513 {
514  int i, j, k, ret;
515  int converter_count = 0;
516  int count_queried = 0; /* successful calls to query_formats() */
517  int count_merged = 0; /* successful merge of formats lists */
518  int count_already_merged = 0; /* lists already merged */
519  int count_delayed = 0; /* lists that need to be merged later */
520 
521  for (i = 0; i < graph->nb_filters; i++) {
522  AVFilterContext *f = graph->filters[i];
523  if (formats_declared(f))
524  continue;
526  if (ret < 0 && ret != AVERROR(EAGAIN))
527  return ret;
528  /* note: EAGAIN could indicate a partial success, not counted yet */
529  if (ret >= 0) {
531  count_queried++;
532  }
533  }
534 
535  /* go through and merge as many format lists as possible */
536 retry:
537  for (i = 0; i < graph->nb_filters; i++) {
538  AVFilterContext *filter = graph->filters[i];
539 
540  for (j = 0; j < filter->nb_inputs; j++) {
541  AVFilterLink *link = filter->inputs[j];
542  const AVFilterNegotiation *neg;
543  AVFilterContext *conv[4];
544  const char *conv_filters[4], *conv_opts[4] = {0};
545  unsigned neg_step, num_conv = 0;
546 
547  if (!link)
548  continue;
549 
551  av_assert0(neg);
552  for (neg_step = 0; neg_step < neg->nb_mergers; neg_step++) {
553  const AVFilterFormatsMerger *m = &neg->mergers[neg_step];
554  void *a = FF_FIELD_AT(void *, m->offset, link->incfg);
555  void *b = FF_FIELD_AT(void *, m->offset, link->outcfg);
556  if (a && b && a != b && !m->can_merge(a, b)) {
557  for (k = 0; k < num_conv; k++) {
558  if (conv_filters[k] == m->conversion_filter)
559  break;
560  }
561  if (k == num_conv) {
562  av_assert1(num_conv < FF_ARRAY_ELEMS(conv_filters));
563  conv_filters[num_conv] = m->conversion_filter;
564  if (m->conversion_opts_offset)
565  conv_opts[num_conv] = FF_FIELD_AT(char *, m->conversion_opts_offset, *graph);
566  num_conv++;
567  }
568  }
569  }
570  for (neg_step = 0; neg_step < neg->nb_mergers; neg_step++) {
571  const AVFilterFormatsMerger *m = &neg->mergers[neg_step];
572  void *a = FF_FIELD_AT(void *, m->offset, link->incfg);
573  void *b = FF_FIELD_AT(void *, m->offset, link->outcfg);
574  if (!(a && b)) {
575  count_delayed++;
576  } else if (a == b) {
577  count_already_merged++;
578  } else if (!num_conv) {
579  count_merged++;
580  ret = m->merge(a, b);
581  if (ret < 0)
582  return ret;
583  if (!ret) {
584  conv_filters[num_conv] = m->conversion_filter;
585  if (m->conversion_opts_offset)
586  conv_opts[num_conv] = FF_FIELD_AT(char *, m->conversion_opts_offset, *graph);
587  num_conv++;
588  }
589  }
590  }
591 
592  /**
593  * Couldn't merge format lists; auto-insert conversion filters
594  * in reverse order to keep the order consistent with the list
595  * of mergers, since they are prepended onto the existing link
596  */
597  for (k = num_conv - 1; k >= 0; k--) {
598  const AVFilter *filter;
599  char inst_name[30];
600 
601  if (fffiltergraph(graph)->disable_auto_convert) {
602  av_log(log_ctx, AV_LOG_ERROR,
603  "The filters '%s' and '%s' do not have a common format "
604  "and automatic conversion is disabled.\n",
605  link->src->name, link->dst->name);
607  return AVERROR(EINVAL);
608  }
609 
610  if (!(filter = avfilter_get_by_name(conv_filters[k]))) {
611  av_log(log_ctx, AV_LOG_ERROR,
612  "'%s' filter not present, cannot convert formats.\n",
613  conv_filters[k]);
615  return AVERROR(EINVAL);
616  }
617  snprintf(inst_name, sizeof(inst_name), "auto_%s_%d",
618  conv_filters[k], converter_count++);
619  ret = avfilter_graph_create_filter(&conv[k], filter, inst_name,
620  conv_opts[k], NULL, graph);
621  if (ret < 0)
622  return ret;
623  if ((ret = avfilter_insert_filter(link, conv[k], 0, 0)) < 0)
624  return ret;
625 
626  if ((ret = filter_query_formats(conv[k])) < 0)
627  return ret;
628  }
629 
630  /* preemptively settle formats of auto filters */
631  for (k = 0; k < num_conv; k++) {
632  AVFilterLink *inlink = conv[k]->inputs[0];
633  AVFilterLink *outlink = conv[k]->outputs[0];
634  av_assert0( inlink->incfg.formats->refcount > 0);
635  av_assert0( inlink->outcfg.formats->refcount > 0);
636  av_assert0(outlink->incfg.formats->refcount > 0);
637  av_assert0(outlink->outcfg.formats->refcount > 0);
638  if (outlink->type == AVMEDIA_TYPE_VIDEO) {
639  av_assert0( inlink-> incfg.color_spaces->refcount > 0);
640  av_assert0( inlink->outcfg.color_spaces->refcount > 0);
641  av_assert0(outlink-> incfg.color_spaces->refcount > 0);
642  av_assert0(outlink->outcfg.color_spaces->refcount > 0);
643  av_assert0( inlink-> incfg.color_ranges->refcount > 0);
644  av_assert0( inlink->outcfg.color_ranges->refcount > 0);
645  av_assert0(outlink-> incfg.color_ranges->refcount > 0);
646  av_assert0(outlink->outcfg.color_ranges->refcount > 0);
647  av_assert0( inlink-> incfg.alpha_modes->refcount > 0);
648  av_assert0( inlink->outcfg.alpha_modes->refcount > 0);
649  av_assert0(outlink-> incfg.alpha_modes->refcount > 0);
650  av_assert0(outlink->outcfg.alpha_modes->refcount > 0);
651  } else if (outlink->type == AVMEDIA_TYPE_AUDIO) {
652  av_assert0( inlink-> incfg.samplerates->refcount > 0);
653  av_assert0( inlink->outcfg.samplerates->refcount > 0);
654  av_assert0(outlink-> incfg.samplerates->refcount > 0);
655  av_assert0(outlink->outcfg.samplerates->refcount > 0);
656  av_assert0( inlink-> incfg.channel_layouts->refcount > 0);
657  av_assert0( inlink->outcfg.channel_layouts->refcount > 0);
658  av_assert0(outlink-> incfg.channel_layouts->refcount > 0);
659  av_assert0(outlink->outcfg.channel_layouts->refcount > 0);
660  }
661 
662 #define MERGE(merger, link) \
663  ((merger)->merge(FF_FIELD_AT(void *, (merger)->offset, (link)->incfg), \
664  FF_FIELD_AT(void *, (merger)->offset, (link)->outcfg)))
665 
666  for (neg_step = 0; neg_step < neg->nb_mergers; neg_step++) {
667  const AVFilterFormatsMerger *m = &neg->mergers[neg_step];
668  if (m->conversion_filter != conv_filters[k])
669  continue;
670  if ((ret = MERGE(m, inlink)) <= 0 ||
671  (ret = MERGE(m, outlink)) <= 0) {
672  if (ret < 0)
673  return ret;
674  av_log(log_ctx, AV_LOG_ERROR,
675  "Impossible to convert between the formats supported by the filter "
676  "'%s' and the filter '%s'\n", link->src->name, link->dst->name);
678  return AVERROR(ENOSYS);
679  } else {
680  count_merged += 2;
681  }
682  }
683  }
684 
685  /* if there is more than one auto filter, we may need another round
686  * to fully settle formats due to possible cross-incompatibilities
687  * between the auto filters themselves */
688  if (num_conv > 1)
689  goto retry;
690  }
691  }
692 
693  av_log(graph, AV_LOG_DEBUG, "query_formats: "
694  "%d queried, %d merged, %d already done, %d delayed\n",
695  count_queried, count_merged, count_already_merged, count_delayed);
696  if (count_delayed) {
697  AVBPrint bp;
698 
699  /* if count_queried > 0, one filter at least did set its formats,
700  that will give additional information to its neighbour;
701  if count_merged > 0, one pair of formats lists at least was merged,
702  that will give additional information to all connected filters;
703  in both cases, progress was made and a new round must be done */
704  if (count_queried || count_merged)
705  return AVERROR(EAGAIN);
707  for (i = 0; i < graph->nb_filters; i++)
708  if (!formats_declared(graph->filters[i]))
709  av_bprintf(&bp, "%s%s", bp.len ? ", " : "",
710  graph->filters[i]->name);
711  av_log(graph, AV_LOG_ERROR,
712  "The following filters could not choose their formats: %s\n"
713  "Consider inserting the (a)format filter near their input or "
714  "output.\n", bp.str);
715  return AVERROR(EIO);
716  }
717  return 0;
718 }
719 
720 static int get_fmt_score(enum AVSampleFormat dst_fmt, enum AVSampleFormat src_fmt)
721 {
722  int score = 0;
723 
724  if (av_sample_fmt_is_planar(dst_fmt) != av_sample_fmt_is_planar(src_fmt))
725  score ++;
726 
727  if (av_get_bytes_per_sample(dst_fmt) < av_get_bytes_per_sample(src_fmt)) {
728  score += 100 * (av_get_bytes_per_sample(src_fmt) - av_get_bytes_per_sample(dst_fmt));
729  }else
730  score += 10 * (av_get_bytes_per_sample(dst_fmt) - av_get_bytes_per_sample(src_fmt));
731 
734  score += 20;
735 
738  score += 2;
739 
740  return score;
741 }
742 
744  enum AVSampleFormat src_fmt)
745 {
746  int score1, score2;
747 
748  score1 = get_fmt_score(dst_fmt1, src_fmt);
749  score2 = get_fmt_score(dst_fmt2, src_fmt);
750 
751  return score1 < score2 ? dst_fmt1 : dst_fmt2;
752 }
753 
755 {
757  if (!desc)
758  return 0;
759  if (desc->nb_components < 3)
760  return 0; /* Grayscale is explicitly full-range in swscale */
762  return !(desc->flags & (AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_PAL |
764 }
765 
766 
768 {
769  switch (fmt) {
770  case AV_PIX_FMT_YUVJ420P:
771  case AV_PIX_FMT_YUVJ422P:
772  case AV_PIX_FMT_YUVJ444P:
773  case AV_PIX_FMT_YUVJ440P:
774  case AV_PIX_FMT_YUVJ411P:
775  return 1;
776  default:
777  return 0;
778  }
779 }
780 
782 {
783  if (!link || !link->incfg.formats)
784  return 0;
785 
786  if (link->type == AVMEDIA_TYPE_VIDEO) {
787  if(ref && ref->type == AVMEDIA_TYPE_VIDEO){
788  //FIXME: This should check for AV_PIX_FMT_FLAG_ALPHA after PAL8 pixel format without alpha is implemented
789  int has_alpha= av_pix_fmt_desc_get(ref->format)->nb_components % 2 == 0;
790  enum AVPixelFormat best= AV_PIX_FMT_NONE;
791  int i;
792  for (i = 0; i < link->incfg.formats->nb_formats; i++) {
793  enum AVPixelFormat p = link->incfg.formats->formats[i];
794  best= av_find_best_pix_fmt_of_2(best, p, ref->format, has_alpha, NULL);
795  }
796  av_log(link->src,AV_LOG_DEBUG, "picking %s out of %d ref:%s alpha:%d\n",
797  av_get_pix_fmt_name(best), link->incfg.formats->nb_formats,
798  av_get_pix_fmt_name(ref->format), has_alpha);
799  link->incfg.formats->formats[0] = best;
800  }
801  } else if (link->type == AVMEDIA_TYPE_AUDIO) {
802  if(ref && ref->type == AVMEDIA_TYPE_AUDIO){
804  int i;
805  for (i = 0; i < link->incfg.formats->nb_formats; i++) {
806  enum AVSampleFormat p = link->incfg.formats->formats[i];
807  best = find_best_sample_fmt_of_2(best, p, ref->format);
808  }
809  av_log(link->src,AV_LOG_DEBUG, "picking %s out of %d ref:%s\n",
810  av_get_sample_fmt_name(best), link->incfg.formats->nb_formats,
811  av_get_sample_fmt_name(ref->format));
812  link->incfg.formats->formats[0] = best;
813  }
814  }
815 
816  link->incfg.formats->nb_formats = 1;
817  link->format = link->incfg.formats->formats[0];
818 
819  if (link->type == AVMEDIA_TYPE_VIDEO) {
820  enum AVPixelFormat swfmt = link->format;
822  // FIXME: this is a hack - we'd like to use the sw_format of
823  // link->hw_frames_ctx here, but it is not yet available.
824  // To make this work properly we will need to either reorder
825  // things so that it is available here or somehow negotiate
826  // sw_format separately.
827  swfmt = AV_PIX_FMT_YUV420P;
828  }
829 
831  if (!ff_fmt_is_regular_yuv(swfmt)) {
832  /* These fields are explicitly documented as affecting YUV only,
833  * so set them to sane values for other formats. */
834  if (desc->flags & AV_PIX_FMT_FLAG_FLOAT)
836  else
838  if (desc->flags & (AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_XYZ)) {
840  } else {
842  }
843  } else {
844  if (!link->incfg.color_spaces->nb_formats) {
845  av_log(link->src, AV_LOG_ERROR, "Cannot select color space for"
846  " the link between filters %s and %s.\n", link->src->name,
847  link->dst->name);
848  return AVERROR(EINVAL);
849  }
850  link->incfg.color_spaces->nb_formats = 1;
851  link->colorspace = link->incfg.color_spaces->formats[0];
852 
853  if (ff_fmt_is_forced_full_range(swfmt)) {
855  } else {
856  if (!link->incfg.color_ranges->nb_formats) {
857  av_log(link->src, AV_LOG_ERROR, "Cannot select color range for"
858  " the link between filters %s and %s.\n", link->src->name,
859  link->dst->name);
860  return AVERROR(EINVAL);
861  }
862  link->incfg.color_ranges->nb_formats = 1;
863  link->color_range = link->incfg.color_ranges->formats[0];
864  }
865  }
866 
867  if (desc->flags & AV_PIX_FMT_FLAG_ALPHA) {
868  if (!link->incfg.alpha_modes->nb_formats) {
869  av_log(link->src, AV_LOG_ERROR, "Cannot select alpha mode for"
870  " the link between filters %s and %s.\n", link->src->name,
871  link->dst->name);
872  return AVERROR(EINVAL);
873  }
874  link->incfg.alpha_modes->nb_formats = 1;
875  link->alpha_mode = link->incfg.alpha_modes->formats[0];
876  } else {
878  }
879  } else if (link->type == AVMEDIA_TYPE_AUDIO) {
880  int ret;
881 
882  if (!link->incfg.samplerates->nb_formats) {
883  av_log(link->src, AV_LOG_ERROR, "Cannot select sample rate for"
884  " the link between filters %s and %s.\n", link->src->name,
885  link->dst->name);
886  return AVERROR(EINVAL);
887  }
888  link->incfg.samplerates->nb_formats = 1;
889  link->sample_rate = link->incfg.samplerates->formats[0];
890 
891  if (link->incfg.channel_layouts->all_layouts) {
892  av_log(link->src, AV_LOG_ERROR, "Cannot select channel layout for"
893  " the link between filters %s and %s.\n", link->src->name,
894  link->dst->name);
895  if (!link->incfg.channel_layouts->all_counts)
896  av_log(link->src, AV_LOG_ERROR, "Unknown channel layouts not "
897  "supported, try specifying a channel layout using "
898  "'aformat=channel_layouts=something'.\n");
899  return AVERROR(EINVAL);
900  }
901  link->incfg.channel_layouts->nb_channel_layouts = 1;
902  ret = av_channel_layout_copy(&link->ch_layout, &link->incfg.channel_layouts->channel_layouts[0]);
903  if (ret < 0)
904  return ret;
905  }
906 
907  ff_formats_unref(&link->incfg.formats);
908  ff_formats_unref(&link->outcfg.formats);
909  ff_formats_unref(&link->incfg.samplerates);
910  ff_formats_unref(&link->outcfg.samplerates);
911  ff_channel_layouts_unref(&link->incfg.channel_layouts);
912  ff_channel_layouts_unref(&link->outcfg.channel_layouts);
913  ff_formats_unref(&link->incfg.color_spaces);
914  ff_formats_unref(&link->outcfg.color_spaces);
915  ff_formats_unref(&link->incfg.color_ranges);
916  ff_formats_unref(&link->outcfg.color_ranges);
917  ff_formats_unref(&link->incfg.alpha_modes);
918  ff_formats_unref(&link->outcfg.alpha_modes);
919 
920  return 0;
921 }
922 
923 #define REDUCE_FORMATS(fmt_type, list_type, list, var, nb, add_format) \
924 do { \
925  for (i = 0; i < filter->nb_inputs; i++) { \
926  AVFilterLink *link = filter->inputs[i]; \
927  fmt_type fmt; \
928  \
929  if (!link->outcfg.list || link->outcfg.list->nb != 1) \
930  continue; \
931  fmt = link->outcfg.list->var[0]; \
932  \
933  for (j = 0; j < filter->nb_outputs; j++) { \
934  AVFilterLink *out_link = filter->outputs[j]; \
935  list_type *fmts; \
936  \
937  if (link->type != out_link->type || \
938  out_link->incfg.list->nb == 1) \
939  continue; \
940  fmts = out_link->incfg.list; \
941  \
942  if (!out_link->incfg.list->nb) { \
943  if ((ret = add_format(&out_link->incfg.list, fmt)) < 0)\
944  return ret; \
945  ret = 1; \
946  break; \
947  } \
948  \
949  for (k = 0; k < out_link->incfg.list->nb; k++) \
950  if (fmts->var[k] == fmt) { \
951  fmts->var[0] = fmt; \
952  fmts->nb = 1; \
953  ret = 1; \
954  break; \
955  } \
956  } \
957  } \
958 } while (0)
959 
961 {
962  int i, j, k, ret = 0;
963 
965  nb_formats, ff_add_format);
966  REDUCE_FORMATS(int, AVFilterFormats, samplerates, formats,
967  nb_formats, ff_add_format);
968  REDUCE_FORMATS(int, AVFilterFormats, color_spaces, formats,
969  nb_formats, ff_add_format);
970  REDUCE_FORMATS(int, AVFilterFormats, color_ranges, formats,
971  nb_formats, ff_add_format);
972  REDUCE_FORMATS(int, AVFilterFormats, alpha_modes, formats,
973  nb_formats, ff_add_format);
974 
975  /* reduce channel layouts */
976  for (i = 0; i < filter->nb_inputs; i++) {
977  AVFilterLink *inlink = filter->inputs[i];
978  const AVChannelLayout *fmt;
979 
980  if (!inlink->outcfg.channel_layouts ||
981  inlink->outcfg.channel_layouts->nb_channel_layouts != 1)
982  continue;
983  fmt = &inlink->outcfg.channel_layouts->channel_layouts[0];
984 
985  for (j = 0; j < filter->nb_outputs; j++) {
986  AVFilterLink *outlink = filter->outputs[j];
988 
989  fmts = outlink->incfg.channel_layouts;
990  if (inlink->type != outlink->type || fmts->nb_channel_layouts == 1)
991  continue;
992 
993  if (fmts->all_layouts &&
994  (KNOWN(fmt) || fmts->all_counts)) {
995  /* Turn the infinite list into a singleton */
996  fmts->all_layouts = fmts->all_counts = 0;
998  if (ret < 0)
999  return ret;
1000  ret = 1;
1001  break;
1002  }
1003 
1004  for (k = 0; k < outlink->incfg.channel_layouts->nb_channel_layouts; k++) {
1005  if (!av_channel_layout_compare(&fmts->channel_layouts[k], fmt)) {
1006  ret = av_channel_layout_copy(&fmts->channel_layouts[0], fmt);
1007  if (ret < 0)
1008  return ret;
1009  fmts->nb_channel_layouts = 1;
1010  ret = 1;
1011  break;
1012  }
1013  }
1014  }
1015  }
1016 
1017  return ret;
1018 }
1019 
1020 static int reduce_formats(AVFilterGraph *graph)
1021 {
1022  int i, reduced, ret;
1023 
1024  do {
1025  reduced = 0;
1026 
1027  for (i = 0; i < graph->nb_filters; i++) {
1028  if ((ret = reduce_formats_on_filter(graph->filters[i])) < 0)
1029  return ret;
1030  reduced |= ret;
1031  }
1032  } while (reduced);
1033 
1034  return 0;
1035 }
1036 
1038 {
1039  AVFilterLink *link = NULL;
1040  int sample_rate;
1041  int i, j;
1042 
1043  for (i = 0; i < filter->nb_inputs; i++) {
1044  link = filter->inputs[i];
1045 
1046  if (link->type == AVMEDIA_TYPE_AUDIO &&
1047  link->outcfg.samplerates->nb_formats== 1)
1048  break;
1049  }
1050  if (i == filter->nb_inputs)
1051  return;
1052 
1053  sample_rate = link->outcfg.samplerates->formats[0];
1054 
1055  for (i = 0; i < filter->nb_outputs; i++) {
1056  AVFilterLink *outlink = filter->outputs[i];
1057  int best_idx, best_diff = INT_MAX;
1058 
1059  if (outlink->type != AVMEDIA_TYPE_AUDIO ||
1060  outlink->incfg.samplerates->nb_formats < 2)
1061  continue;
1062 
1063  for (j = 0; j < outlink->incfg.samplerates->nb_formats; j++) {
1064  int diff = abs(sample_rate - outlink->incfg.samplerates->formats[j]);
1065 
1066  av_assert0(diff < INT_MAX); // This would lead to the use of uninitialized best_diff but is only possible with invalid sample rates
1067 
1068  if (diff < best_diff) {
1069  best_diff = diff;
1070  best_idx = j;
1071  }
1072  }
1073  FFSWAP(int, outlink->incfg.samplerates->formats[0],
1074  outlink->incfg.samplerates->formats[best_idx]);
1075  }
1076 }
1077 
1078 static void swap_samplerates(AVFilterGraph *graph)
1079 {
1080  int i;
1081 
1082  for (i = 0; i < graph->nb_filters; i++)
1084 }
1085 
1086 #define CH_CENTER_PAIR (AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER)
1087 #define CH_FRONT_PAIR (AV_CH_FRONT_LEFT | AV_CH_FRONT_RIGHT)
1088 #define CH_STEREO_PAIR (AV_CH_STEREO_LEFT | AV_CH_STEREO_RIGHT)
1089 #define CH_WIDE_PAIR (AV_CH_WIDE_LEFT | AV_CH_WIDE_RIGHT)
1090 #define CH_SIDE_PAIR (AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT)
1091 #define CH_DIRECT_PAIR (AV_CH_SURROUND_DIRECT_LEFT | AV_CH_SURROUND_DIRECT_RIGHT)
1092 #define CH_BACK_PAIR (AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT)
1093 
1094 /* allowable substitutions for channel pairs when comparing layouts,
1095  * ordered by priority for both values */
1096 static const uint64_t ch_subst[][2] = {
1118 };
1119 
1121 {
1122  AVFilterLink *link = NULL;
1123  int i, j, k;
1124 
1125  for (i = 0; i < filter->nb_inputs; i++) {
1126  link = filter->inputs[i];
1127 
1128  if (link->type == AVMEDIA_TYPE_AUDIO &&
1129  link->outcfg.channel_layouts->nb_channel_layouts == 1)
1130  break;
1131  }
1132  if (i == filter->nb_inputs)
1133  return;
1134 
1135  for (i = 0; i < filter->nb_outputs; i++) {
1136  AVFilterLink *outlink = filter->outputs[i];
1137  int best_idx = -1, best_score = INT_MIN, best_count_diff = INT_MAX;
1138 
1139  if (outlink->type != AVMEDIA_TYPE_AUDIO ||
1141  continue;
1142 
1143  for (j = 0; j < outlink->incfg.channel_layouts->nb_channel_layouts; j++) {
1144  AVChannelLayout in_chlayout = { 0 }, out_chlayout = { 0 };
1145  int in_channels;
1146  int out_channels;
1147  int count_diff;
1148  int matched_channels, extra_channels;
1149  int score = 100000;
1150 
1151  av_channel_layout_copy(&in_chlayout, &link->outcfg.channel_layouts->channel_layouts[0]);
1152  av_channel_layout_copy(&out_chlayout, &outlink->incfg.channel_layouts->channel_layouts[j]);
1153  in_channels = in_chlayout.nb_channels;
1154  out_channels = out_chlayout.nb_channels;
1155  count_diff = out_channels - in_channels;
1156  if (!KNOWN(&in_chlayout) || !KNOWN(&out_chlayout)) {
1157  /* Compute score in case the input or output layout encodes
1158  a channel count; in this case the score is not altered by
1159  the computation afterwards, as in_chlayout and
1160  out_chlayout have both been set to 0 */
1161  if (!KNOWN(&in_chlayout))
1162  in_channels = FF_LAYOUT2COUNT(&in_chlayout);
1163  if (!KNOWN(&out_chlayout))
1164  out_channels = FF_LAYOUT2COUNT(&out_chlayout);
1165  score -= 10000 + FFABS(out_channels - in_channels) +
1166  (in_channels > out_channels ? 10000 : 0);
1167  av_channel_layout_uninit(&in_chlayout);
1168  av_channel_layout_uninit(&out_chlayout);
1169  /* Let the remaining computation run, even if the score
1170  value is not altered */
1171  }
1172 
1173  /* channel substitution */
1174  for (k = 0; k < FF_ARRAY_ELEMS(ch_subst); k++) {
1175  uint64_t cmp0 = ch_subst[k][0];
1176  uint64_t cmp1 = ch_subst[k][1];
1177  if ( av_channel_layout_subset(& in_chlayout, cmp0) &&
1178  !av_channel_layout_subset(&out_chlayout, cmp0) &&
1179  av_channel_layout_subset(&out_chlayout, cmp1) &&
1180  !av_channel_layout_subset(& in_chlayout, cmp1)) {
1181  av_channel_layout_from_mask(&in_chlayout, av_channel_layout_subset(& in_chlayout, ~cmp0));
1182  av_channel_layout_from_mask(&out_chlayout, av_channel_layout_subset(&out_chlayout, ~cmp1));
1183  /* add score for channel match, minus a deduction for
1184  having to do the substitution */
1185  score += 10 * av_popcount64(cmp1) - 2;
1186  }
1187  }
1188 
1189  /* no penalty for LFE channel mismatch */
1192  score += 10;
1195 
1196  matched_channels = av_popcount64(in_chlayout.u.mask & out_chlayout.u.mask);
1197  extra_channels = av_popcount64(out_chlayout.u.mask & (~in_chlayout.u.mask));
1198  score += 10 * matched_channels - 5 * extra_channels;
1199 
1200  if (score > best_score ||
1201  (count_diff < best_count_diff && score == best_score)) {
1202  best_score = score;
1203  best_idx = j;
1204  best_count_diff = count_diff;
1205  }
1206  }
1207  av_assert0(best_idx >= 0);
1209  outlink->incfg.channel_layouts->channel_layouts[best_idx]);
1210  }
1211 
1212 }
1213 
1215 {
1216  int i;
1217 
1218  for (i = 0; i < graph->nb_filters; i++)
1220 }
1221 
1223 {
1224  AVFilterLink *link = NULL;
1225  int format, bps;
1226  int i, j;
1227 
1228  for (i = 0; i < filter->nb_inputs; i++) {
1229  link = filter->inputs[i];
1230 
1231  if (link->type == AVMEDIA_TYPE_AUDIO &&
1232  link->outcfg.formats->nb_formats == 1)
1233  break;
1234  }
1235  if (i == filter->nb_inputs)
1236  return;
1237 
1238  format = link->outcfg.formats->formats[0];
1240 
1241  for (i = 0; i < filter->nb_outputs; i++) {
1242  AVFilterLink *outlink = filter->outputs[i];
1243  int best_idx = -1, best_score = INT_MIN;
1244 
1245  if (outlink->type != AVMEDIA_TYPE_AUDIO ||
1246  outlink->incfg.formats->nb_formats < 2)
1247  continue;
1248 
1249  for (j = 0; j < outlink->incfg.formats->nb_formats; j++) {
1250  int out_format = outlink->incfg.formats->formats[j];
1251  int out_bps = av_get_bytes_per_sample(out_format);
1252  int score;
1253 
1254  if (av_get_packed_sample_fmt(out_format) == format ||
1255  av_get_planar_sample_fmt(out_format) == format) {
1256  best_idx = j;
1257  break;
1258  }
1259 
1260  /* for s32 and float prefer double to prevent loss of information */
1261  if (bps == 4 && out_bps == 8) {
1262  best_idx = j;
1263  break;
1264  }
1265 
1266  /* prefer closest higher or equal bps */
1267  score = -abs(out_bps - bps);
1268  if (out_bps >= bps)
1269  score += INT_MAX/2;
1270 
1271  if (score > best_score) {
1272  best_score = score;
1273  best_idx = j;
1274  }
1275  }
1276  av_assert0(best_idx >= 0);
1277  FFSWAP(int, outlink->incfg.formats->formats[0],
1278  outlink->incfg.formats->formats[best_idx]);
1279  }
1280 }
1281 
1282 static void swap_sample_fmts(AVFilterGraph *graph)
1283 {
1284  int i;
1285 
1286  for (i = 0; i < graph->nb_filters; i++)
1288 
1289 }
1290 
1291 static int pick_formats(AVFilterGraph *graph)
1292 {
1293  int i, j, ret;
1294  int change;
1295 
1296  do{
1297  change = 0;
1298  for (i = 0; i < graph->nb_filters; i++) {
1299  AVFilterContext *filter = graph->filters[i];
1300  if (filter->nb_inputs){
1301  for (j = 0; j < filter->nb_inputs; j++){
1302  if (filter->inputs[j]->incfg.formats && filter->inputs[j]->incfg.formats->nb_formats == 1) {
1303  if ((ret = pick_format(filter->inputs[j], NULL)) < 0)
1304  return ret;
1305  change = 1;
1306  }
1307  }
1308  }
1309  if (filter->nb_outputs){
1310  for (j = 0; j < filter->nb_outputs; j++){
1311  if (filter->outputs[j]->incfg.formats && filter->outputs[j]->incfg.formats->nb_formats == 1) {
1312  if ((ret = pick_format(filter->outputs[j], NULL)) < 0)
1313  return ret;
1314  change = 1;
1315  }
1316  }
1317  }
1318  if (filter->nb_inputs && filter->nb_outputs && filter->inputs[0]->format>=0) {
1319  for (j = 0; j < filter->nb_outputs; j++) {
1320  if (filter->outputs[j]->format<0) {
1321  if ((ret = pick_format(filter->outputs[j], filter->inputs[0])) < 0)
1322  return ret;
1323  change = 1;
1324  }
1325  }
1326  }
1327  }
1328  }while(change);
1329 
1330  for (i = 0; i < graph->nb_filters; i++) {
1331  AVFilterContext *filter = graph->filters[i];
1332 
1333  for (j = 0; j < filter->nb_inputs; j++)
1334  if ((ret = pick_format(filter->inputs[j], NULL)) < 0)
1335  return ret;
1336  for (j = 0; j < filter->nb_outputs; j++)
1337  if ((ret = pick_format(filter->outputs[j], NULL)) < 0)
1338  return ret;
1339  }
1340  return 0;
1341 }
1342 
1343 /**
1344  * Configure the formats of all the links in the graph.
1345  */
1346 static int graph_config_formats(AVFilterGraph *graph, void *log_ctx)
1347 {
1348  int ret;
1349 
1350  /* find supported formats from sub-filters, and merge along links */
1351  while ((ret = query_formats(graph, log_ctx)) == AVERROR(EAGAIN))
1352  av_log(graph, AV_LOG_DEBUG, "query_formats not finished\n");
1353  if (ret < 0)
1354  return ret;
1355 
1356  /* Once everything is merged, it's possible that we'll still have
1357  * multiple valid media format choices. We try to minimize the amount
1358  * of format conversion inside filters */
1359  if ((ret = reduce_formats(graph)) < 0)
1360  return ret;
1361 
1362  /* for audio filters, ensure the best format, sample rate and channel layout
1363  * is selected */
1364  swap_sample_fmts(graph);
1365  swap_samplerates(graph);
1366  swap_channel_layouts(graph);
1367 
1368  if ((ret = pick_formats(graph)) < 0)
1369  return ret;
1370 
1371  return 0;
1372 }
1373 
1374 static int graph_config_pointers(AVFilterGraph *graph, void *log_ctx)
1375 {
1376  unsigned i, j;
1377  int sink_links_count = 0, n = 0;
1378  AVFilterContext *f;
1379  FilterLinkInternal **sinks;
1380 
1381  for (i = 0; i < graph->nb_filters; i++) {
1382  f = graph->filters[i];
1383  for (j = 0; j < f->nb_inputs; j++) {
1384  ff_link_internal(f->inputs[j])->age_index = -1;
1385  }
1386  for (j = 0; j < f->nb_outputs; j++) {
1387  ff_link_internal(f->outputs[j])->age_index = -1;
1388  }
1389  if (!f->nb_outputs) {
1390  if (f->nb_inputs > INT_MAX - sink_links_count)
1391  return AVERROR(EINVAL);
1392  sink_links_count += f->nb_inputs;
1393  }
1394  }
1395  sinks = av_calloc(sink_links_count, sizeof(*sinks));
1396  if (!sinks)
1397  return AVERROR(ENOMEM);
1398  for (i = 0; i < graph->nb_filters; i++) {
1399  f = graph->filters[i];
1400  if (!f->nb_outputs) {
1401  for (j = 0; j < f->nb_inputs; j++) {
1402  sinks[n] = ff_link_internal(f->inputs[j]);
1403  sinks[n]->age_index = n;
1404  n++;
1405  }
1406  }
1407  }
1408  av_assert0(n == sink_links_count);
1409  fffiltergraph(graph)->sink_links = sinks;
1410  fffiltergraph(graph)->sink_links_count = sink_links_count;
1411  return 0;
1412 }
1413 
1414 int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
1415 {
1416  int ret;
1417 
1418  if (graphctx->max_buffered_frames)
1420  if ((ret = graph_check_validity(graphctx, log_ctx)))
1421  return ret;
1422  if ((ret = graph_config_formats(graphctx, log_ctx)))
1423  return ret;
1424  if ((ret = graph_config_links(graphctx, log_ctx)))
1425  return ret;
1426  if ((ret = graph_check_links(graphctx, log_ctx)))
1427  return ret;
1428  if ((ret = graph_config_pointers(graphctx, log_ctx)))
1429  return ret;
1430 
1431  return 0;
1432 }
1433 
1434 int avfilter_graph_send_command(AVFilterGraph *graph, const char *target, const char *cmd, const char *arg, char *res, int res_len, int flags)
1435 {
1436  int i, r = AVERROR(ENOSYS);
1437 
1438  if (!graph)
1439  return r;
1440 
1442  r = avfilter_graph_send_command(graph, target, cmd, arg, res, res_len, flags | AVFILTER_CMD_FLAG_FAST);
1443  if (r != AVERROR(ENOSYS))
1444  return r;
1445  }
1446 
1447  if (res_len && res)
1448  res[0] = 0;
1449 
1450  for (i = 0; i < graph->nb_filters; i++) {
1451  AVFilterContext *filter = graph->filters[i];
1452  if (!strcmp(target, "all") || (filter->name && !strcmp(target, filter->name)) || !strcmp(target, filter->filter->name)) {
1453  r = avfilter_process_command(filter, cmd, arg, res, res_len, flags);
1454  if (r != AVERROR(ENOSYS)) {
1455  if ((flags & AVFILTER_CMD_FLAG_ONE) || r < 0)
1456  return r;
1457  }
1458  }
1459  }
1460 
1461  return r;
1462 }
1463 
1464 int avfilter_graph_queue_command(AVFilterGraph *graph, const char *target, const char *command, const char *arg, int flags, double ts)
1465 {
1466  int i;
1467 
1468  if(!graph)
1469  return 0;
1470 
1471  for (i = 0; i < graph->nb_filters; i++) {
1472  AVFilterContext *filter = graph->filters[i];
1474  if(filter && (!strcmp(target, "all") || !strcmp(target, filter->name) || !strcmp(target, filter->filter->name))){
1475  AVFilterCommand **queue = &ctxi->command_queue, *next;
1476  while (*queue && (*queue)->time <= ts)
1477  queue = &(*queue)->next;
1478  next = *queue;
1479  *queue = av_mallocz(sizeof(AVFilterCommand));
1480  if (!*queue)
1481  return AVERROR(ENOMEM);
1482 
1483  (*queue)->command = av_strdup(command);
1484  (*queue)->arg = av_strdup(arg);
1485  (*queue)->time = ts;
1486  (*queue)->flags = flags;
1487  (*queue)->next = next;
1489  return 0;
1490  }
1491  }
1492 
1493  return 0;
1494 }
1495 
1496 static void heap_bubble_up(FFFilterGraph *graph,
1497  FilterLinkInternal *li, int index)
1498 {
1499  FilterLinkInternal **links = graph->sink_links;
1500 
1501  av_assert0(index >= 0);
1502 
1503  while (index) {
1504  int parent = (index - 1) >> 1;
1505  if (links[parent]->l.current_pts_us >= li->l.current_pts_us)
1506  break;
1507  links[index] = links[parent];
1508  links[index]->age_index = index;
1509  index = parent;
1510  }
1511  links[index] = li;
1512  li->age_index = index;
1513 }
1514 
1515 static void heap_bubble_down(FFFilterGraph *graph,
1516  FilterLinkInternal *li, int index)
1517 {
1518  FilterLinkInternal **links = graph->sink_links;
1519 
1520  av_assert0(index >= 0);
1521 
1522  while (1) {
1523  int child = 2 * index + 1;
1524  if (child >= graph->sink_links_count)
1525  break;
1526  if (child + 1 < graph->sink_links_count &&
1527  links[child + 1]->l.current_pts_us < links[child]->l.current_pts_us)
1528  child++;
1529  if (li->l.current_pts_us < links[child]->l.current_pts_us)
1530  break;
1531  links[index] = links[child];
1532  links[index]->age_index = index;
1533  index = child;
1534  }
1535  links[index] = li;
1536  li->age_index = index;
1537 }
1538 
1540 {
1541  FFFilterGraph *graphi = fffiltergraph(graph);
1542 
1543  heap_bubble_up (graphi, li, li->age_index);
1544  heap_bubble_down(graphi, li, li->age_index);
1545 }
1546 
1548 {
1549  FFFilterGraph *graphi = fffiltergraph(graph);
1550  FilterLinkInternal *oldesti = graphi->sink_links[0];
1551  AVFilterLink *oldest = &oldesti->l.pub;
1552  int64_t frame_count;
1553  int r;
1554 
1555  while (graphi->sink_links_count) {
1556  oldesti = graphi->sink_links[0];
1557  oldest = &oldesti->l.pub;
1558  if (fffilter(oldest->dst->filter)->activate) {
1561  if (r != AVERROR_EOF)
1562  return r;
1563  } else {
1564  r = ff_request_frame(oldest);
1565  }
1566  if (r != AVERROR_EOF)
1567  break;
1568  av_log(oldest->dst, AV_LOG_DEBUG, "EOF on sink link %s:%s.\n",
1569  oldest->dst->name,
1570  oldest->dstpad->name);
1571  /* EOF: remove the link from the heap */
1572  if (oldesti->age_index < --graphi->sink_links_count)
1573  heap_bubble_down(graphi, graphi->sink_links[graphi->sink_links_count],
1574  oldesti->age_index);
1575  oldesti->age_index = -1;
1576  }
1577  if (!graphi->sink_links_count)
1578  return AVERROR_EOF;
1579  av_assert1(!fffilter(oldest->dst->filter)->activate);
1580  av_assert1(oldesti->age_index >= 0);
1581  frame_count = oldesti->l.frame_count_out;
1582  while (frame_count == oldesti->l.frame_count_out) {
1583  r = ff_filter_graph_run_once(graph);
1584  if (r == FFERROR_BUFFERSRC_EMPTY)
1585  r = 0;
1586  if (r == AVERROR(EAGAIN) &&
1587  !oldesti->frame_wanted_out && !oldesti->frame_blocked_in &&
1588  !oldesti->status_in)
1589  (void)ff_request_frame(oldest);
1590  else if (r < 0)
1591  return r;
1592  }
1593  return 0;
1594 }
1595 
1597 {
1598  FFFilterContext *ctxi;
1599  unsigned i;
1600 
1601  av_assert0(graph->nb_filters);
1602  ctxi = fffilterctx(graph->filters[0]);
1603  for (i = 1; i < graph->nb_filters; i++) {
1604  FFFilterContext *ctxi_other = fffilterctx(graph->filters[i]);
1605 
1606  if (ctxi_other->ready > ctxi->ready)
1607  ctxi = ctxi_other;
1608  }
1609 
1610  if (!ctxi->ready)
1611  return AVERROR(EAGAIN);
1612  return ff_filter_activate(&ctxi->p);
1613 }
flags
const SwsFlags flags[]
Definition: swscale.c:61
formats
formats
Definition: signature.h:47
AVFilterGraph::execute
avfilter_execute_func * execute
This callback may be set by the caller immediately after allocating the graph and before adding any f...
Definition: avfilter.h:636
AVFilterChannelLayouts
A list of supported channel layouts.
Definition: formats.h:85
AVFILTER_CMD_FLAG_ONE
#define AVFILTER_CMD_FLAG_ONE
Stop once a filter understood the command (for target=all for example), fast filters are favored auto...
Definition: avfilter.h:469
AVFrame::color_range
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: frame.h:678
AV_BPRINT_SIZE_UNLIMITED
#define AV_BPRINT_SIZE_UNLIMITED
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
AVFilterFormatsConfig::samplerates
AVFilterFormats * samplerates
Lists of supported sample rates, only for audio.
Definition: avfilter.h:131
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
F
#define F
Definition: avfiltergraph.c:45
level
uint8_t level
Definition: svq3.c:208
av_opt_set_defaults
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
Definition: opt.c:1678
ff_link_internal
static FilterLinkInternal * ff_link_internal(AVFilterLink *link)
Definition: avfilter_internal.h:90
av_bprint_is_complete
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
Definition: bprint.h:218
r
const char * r
Definition: vf_curves.c:127
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
FF_FILTER_FORMATS_QUERY_FUNC
@ FF_FILTER_FORMATS_QUERY_FUNC
formats.query active.
Definition: filters.h:229
opt.h
AVFilterGraph::nb_threads
int nb_threads
Maximum number of threads used by filters in this graph.
Definition: avfilter.h:615
AVFilterFormatsConfig::channel_layouts
AVFilterChannelLayouts * channel_layouts
Lists of supported channel layouts, only for audio.
Definition: avfilter.h:136
ch_subst
static const uint64_t ch_subst[][2]
Definition: avfiltergraph.c:1096
REDUCE_FORMATS
#define REDUCE_FORMATS(fmt_type, list_type, list, var, nb, add_format)
Definition: avfiltergraph.c:923
av_bprint_init
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
Definition: bprint.c:69
av_popcount64
#define av_popcount64
Definition: common.h:157
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3447
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
av_buffersink_get_frame_flags
int attribute_align_arg av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)
Get a frame with filtered data from sink and put it in frame.
Definition: buffersink.c:155
ff_formats_check_pixel_formats
int ff_formats_check_pixel_formats(void *log, const AVFilterFormats *fmts)
Check that fmts is a valid pixel formats list.
Definition: formats.c:1178
int64_t
long long int64_t
Definition: coverity.c:34
FFFilterGraph
Definition: avfilter_internal.h:134
inlink
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Definition: filter_design.txt:212
filter_query_formats
static int filter_query_formats(AVFilterContext *ctx)
Definition: avfiltergraph.c:347
AV_PIX_FMT_FLAG_FLOAT
#define AV_PIX_FMT_FLAG_FLOAT
The pixel format contains IEEE-754 floating point values.
Definition: pixdesc.h:158
normalize.log
log
Definition: normalize.py:21
ff_filter_activate
int ff_filter_activate(AVFilterContext *filter)
Definition: avfilter.c:1448
AVFrame::colorspace
enum AVColorSpace colorspace
YUV colorspace type.
Definition: frame.h:689
swap_sample_fmts
static void swap_sample_fmts(AVFilterGraph *graph)
Definition: avfiltergraph.c:1282
pixdesc.h
graph_check_validity
static int graph_check_validity(AVFilterGraph *graph, void *log_ctx)
Check for the validity of graph.
Definition: avfiltergraph.c:210
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:767
query_formats
static int query_formats(AVFilterGraph *graph, void *log_ctx)
Perform one round of query_formats() and merging formats lists on the filter graph.
Definition: avfiltergraph.c:512
AVOption
AVOption.
Definition: opt.h:429
FFFilterGraph::sink_links
struct FilterLinkInternal ** sink_links
Definition: avfilter_internal.h:140
b
#define b
Definition: input.c:42
pick_formats
static int pick_formats(AVFilterGraph *graph)
Definition: avfiltergraph.c:1291
ff_request_frame
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
Definition: avfilter.c:483
FilterLinkInternal::l
FilterLink l
Definition: avfilter_internal.h:35
AVCOL_SPC_RGB
@ AVCOL_SPC_RGB
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB), YZX and ST 428-1
Definition: pixfmt.h:691
filter
void(* filter)(uint8_t *src, int stride, int qscale)
Definition: h263dsp.c:29
pick_format
static int pick_format(AVFilterLink *link, AVFilterLink *ref)
Definition: avfiltergraph.c:781
ff_filter_graph_run_once
int ff_filter_graph_run_once(AVFilterGraph *graph)
Run one round of processing on a filter graph.
Definition: avfiltergraph.c:1596
AVFilterFormats::formats
int * formats
list of media formats
Definition: formats.h:66
AVChannelLayout::mask
uint64_t mask
This member must be used for AV_CHANNEL_ORDER_NATIVE, and may be used for AV_CHANNEL_ORDER_AMBISONIC ...
Definition: channel_layout.h:351
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:329
video.h
ff_fmt_is_regular_yuv
int ff_fmt_is_regular_yuv(enum AVPixelFormat fmt)
Returns true if a pixel format is "regular YUV", which includes all pixel formats that are affected b...
Definition: avfiltergraph.c:754
ff_filter_alloc
AVFilterContext * ff_filter_alloc(const AVFilter *filter, const char *inst_name)
Allocate a new filter context and return it.
Definition: avfilter.c:701
swap_samplerates
static void swap_samplerates(AVFilterGraph *graph)
Definition: avfiltergraph.c:1078
FF_LAYOUT2COUNT
#define FF_LAYOUT2COUNT(l)
Decode a channel count encoded as a channel layout.
Definition: formats.h:108
fffilter
static const FFFilter * fffilter(const AVFilter *f)
Definition: filters.h:463
avfilter_graph_free
void avfilter_graph_free(AVFilterGraph **graphp)
Free a graph, destroy its links, and set *graph to NULL.
Definition: avfiltergraph.c:119
FilterLinkInternal
Definition: avfilter_internal.h:34
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:64
formats.h
get_fmt_score
static int get_fmt_score(enum AVSampleFormat dst_fmt, enum AVSampleFormat src_fmt)
Definition: avfiltergraph.c:720
FFFrameQueueGlobal::max_queued
size_t max_queued
Maximum number of allowed frames in the queues combined.
Definition: framequeue.h:49
ff_fmt_is_forced_full_range
int ff_fmt_is_forced_full_range(enum AVPixelFormat fmt)
Returns true if a YUV pixel format is forced full range (i.e.
Definition: avfiltergraph.c:767
avfilter_graph_create_filter
int avfilter_graph_create_filter(AVFilterContext **filt_ctx, const AVFilter *filt, const char *name, const char *args, void *opaque, AVFilterGraph *graph_ctx)
A convenience wrapper that allocates and initializes a filter in a single step.
Definition: avfiltergraph.c:140
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:167
fail
#define fail()
Definition: checkasm.h:200
avfilter_graph_alloc
AVFilterGraph * avfilter_graph_alloc(void)
Allocate a filter graph.
Definition: avfiltergraph.c:85
AV_PIX_FMT_FLAG_HWACCEL
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
Definition: pixdesc.h:128
ff_graph_thread_init
int ff_graph_thread_init(FFFilterGraph *graph)
Definition: avfiltergraph.c:77
reduce_formats
static int reduce_formats(AVFilterGraph *graph)
Definition: avfiltergraph.c:1020
avfilter_insert_filter
int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt, unsigned filt_srcpad_idx, unsigned filt_dstpad_idx)
Insert a filter in the middle of an existing link.
Definition: avfilter.c:282
graph_config_formats
static int graph_config_formats(AVFilterGraph *graph, void *log_ctx)
Configure the formats of all the links in the graph.
Definition: avfiltergraph.c:1346
OFFSET
#define OFFSET(x)
Definition: avfiltergraph.c:44
av_opt_free
void av_opt_free(void *obj)
Free all allocated objects in obj.
Definition: opt.c:1949
AV_BPRINT_SIZE_AUTOMATIC
#define AV_BPRINT_SIZE_AUTOMATIC
AVFrame::alpha_mode
enum AVAlphaMode alpha_mode
Indicates how the alpha channel of the video is to be handled.
Definition: frame.h:782
AVFrame::ch_layout
AVChannelLayout ch_layout
Channel layout of the audio data.
Definition: frame.h:770
type
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 type
Definition: writing_filters.txt:86
FFFilterContext::p
AVFilterContext p
The public AVFilterContext.
Definition: avfilter_internal.h:99
AVFILTER_THREAD_SLICE
#define AVFILTER_THREAD_SLICE
Process multiple parts of the frame concurrently.
Definition: avfilter.h:271
AVFilterNegotiation
Callbacks and properties to describe the steps of a format negotiation.
Definition: formats.h:609
FFFilterGraph::sink_links_count
int sink_links_count
Definition: avfilter_internal.h:141
heap_bubble_up
static void heap_bubble_up(FFFilterGraph *graph, FilterLinkInternal *li, int index)
Definition: avfiltergraph.c:1496
av_image_check_size2
int av_image_check_size2(unsigned int w, unsigned int h, int64_t max_pixels, enum AVPixelFormat pix_fmt, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of a plane of an image with...
Definition: imgutils.c:289
AVFilterPad
A filter pad used for either input or output.
Definition: filters.h:39
AVFilterNegotiation::nb_mergers
unsigned nb_mergers
Definition: formats.h:610
av_get_planar_sample_fmt
enum AVSampleFormat av_get_planar_sample_fmt(enum AVSampleFormat sample_fmt)
Get the planar alternative form of the given sample format.
Definition: samplefmt.c:86
ff_filter_config_links
int ff_filter_config_links(AVFilterContext *filter)
Negotiate the media format, dimensions, etc of all inputs to a filter.
Definition: avfilter.c:328
AV_PIX_FMT_YUVJ411P
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:283
reduce_formats_on_filter
static int reduce_formats_on_filter(AVFilterContext *filter)
Definition: avfiltergraph.c:960
avassert.h
FFFilterGraph::thread_execute
avfilter_execute_func * thread_execute
Definition: avfilter_internal.h:146
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:210
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
MERGE
#define MERGE(merger, link)
FFFilter
Definition: filters.h:266
AV_CH_LOW_FREQUENCY
#define AV_CH_LOW_FREQUENCY
Definition: channel_layout.h:178
AV_PIX_FMT_YUVJ422P
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:86
AV_BUFFERSINK_FLAG_PEEK
#define AV_BUFFERSINK_FLAG_PEEK
Tell av_buffersink_get_buffer_ref() to read video/samples buffer reference, but not remove it from th...
Definition: buffersink.h:85
s
#define s(width, name)
Definition: cbs_vp9.c:198
av_realloc_array
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Definition: mem.c:217
avfilter_process_command
int avfilter_process_command(AVFilterContext *filter, const char *cmd, const char *arg, char *res, int res_len, int flags)
Make the filter instance process a command.
Definition: avfilter.c:610
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:201
av_channel_layout_from_mask
int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask)
Initialize a native channel layout from a bitmask indicating which channels are present.
Definition: channel_layout.c:252
print_filter_formats
static void print_filter_formats(void *log_ctx, int level, const AVFilterContext *f)
Definition: avfiltergraph.c:486
filters
#define filters(fmt, type, inverse, clp, inverset, clip, one, clip_fn, packed)
Definition: af_crystalizer.c:55
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:41
av_sample_fmt_is_planar
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
Definition: samplefmt.c:114
filters.h
filtergraph_options
static const AVOption filtergraph_options[]
Definition: avfiltergraph.c:48
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:231
AV_PIX_FMT_FLAG_ALPHA
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
Definition: pixdesc.h:147
ctx
AVFormatContext * ctx
Definition: movenc.c:49
AVFilterFormatsConfig::color_spaces
AVFilterFormats * color_spaces
Lists of supported YUV color metadata, only for YUV video.
Definition: avfilter.h:141
CH_DIRECT_PAIR
#define CH_DIRECT_PAIR
Definition: avfiltergraph.c:1091
graph_config_pointers
static int graph_config_pointers(AVFilterGraph *graph, void *log_ctx)
Definition: avfiltergraph.c:1374
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:73
av_get_sample_fmt_name
const char * av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
Definition: samplefmt.c:51
AVFilterNegotiation::mergers
const AVFilterFormatsMerger * mergers
Definition: formats.h:611
command
static int command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Definition: vf_drawtext.c:1187
link
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 link
Definition: filter_design.txt:23
AV_PIX_FMT_YUVJ444P
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:87
conv
static int conv(int samples, float **pcm, char *buf, int channels)
Definition: libvorbisdec.c:141
arg
const char * arg
Definition: jacosubdec.c:67
FFABS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:74
av_log_get_level
int av_log_get_level(void)
Get the current log level.
Definition: log.c:470
avfilter_get_by_name
const AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
Definition: allfilters.c:646
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
FFFilter::activate
int(* activate)(AVFilterContext *ctx)
Filter activation function.
Definition: filters.h:460
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:76
avfilter_graph_config
int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
Check validity and configure all the links and formats in the graph.
Definition: avfiltergraph.c:1414
NULL
#define NULL
Definition: coverity.c:32
ff_filter_get_negotiation
const AVFilterNegotiation * ff_filter_get_negotiation(AVFilterLink *link)
Definition: formats.c:413
format
New swscale design to change SwsGraph is what coordinates multiple passes These can include cascaded scaling error diffusion and so on Or we could have separate passes for the vertical and horizontal scaling In between each SwsPass lies a fully allocated image buffer Graph passes may have different levels of e g we can have a single threaded error diffusion pass following a multi threaded scaling pass SwsGraph is internally recreated whenever the image format
Definition: swscale-v2.txt:14
AVPixFmtDescriptor::nb_components
uint8_t nb_components
The number of components each pixel has, (1-4)
Definition: pixdesc.h:71
avfilter_graph_set_auto_convert
void avfilter_graph_set_auto_convert(AVFilterGraph *graph, unsigned flags)
Enable or disable automatic format conversion inside the graph.
Definition: avfiltergraph.c:162
ff_formats_check_alpha_modes
int ff_formats_check_alpha_modes(void *log, const AVFilterFormats *fmts)
Check that fmts is a valid formats list for alpha modes.
Definition: formats.c:1211
framequeue.h
AV_PIX_FMT_YUVJ420P
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:85
AVFilterGraph::filters
AVFilterContext ** filters
Definition: avfilter.h:591
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:241
ff_add_format
int ff_add_format(AVFilterFormats **avff, int64_t fmt)
Add fmt to the list of media formats contained in *avff.
Definition: formats.c:520
AVFilterContext::name
char * name
name of this filter instance
Definition: avfilter.h:279
fffiltergraph
static FFFilterGraph * fffiltergraph(AVFilterGraph *graph)
Definition: avfilter_internal.h:150
AVFilterFormats::nb_formats
unsigned nb_formats
number of formats
Definition: formats.h:65
avfilter_graph_get_filter
AVFilterContext * avfilter_graph_get_filter(AVFilterGraph *graph, const char *name)
Get a filter instance identified by instance name from graph.
Definition: avfiltergraph.c:286
avfilter_graph_request_oldest
int avfilter_graph_request_oldest(AVFilterGraph *graph)
Request a frame on the oldest sink link.
Definition: avfiltergraph.c:1547
graph_config_links
static int graph_config_links(AVFilterGraph *graph, void *log_ctx)
Configure all the links of graphctx.
Definition: avfiltergraph.c:248
abs
#define abs(x)
Definition: cuda_runtime.h:35
avfilter_internal.h
AVFilterGraph
Definition: avfilter.h:589
AV_OPT_TYPE_UINT
@ AV_OPT_TYPE_UINT
Underlying C type is unsigned int.
Definition: opt.h:335
AV_CH_FRONT_CENTER
#define AV_CH_FRONT_CENTER
Definition: channel_layout.h:177
ff_add_channel_layout
int ff_add_channel_layout(AVFilterChannelLayouts **l, const AVChannelLayout *channel_layout)
Definition: formats.c:537
AVFilterFormats::refcount
unsigned refcount
number of references to this list
Definition: formats.h:68
ff_channel_layouts_unref
void ff_channel_layouts_unref(AVFilterChannelLayouts **ref)
Remove a reference to a channel layouts list.
Definition: formats.c:756
AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_UNSPECIFIED
Definition: pixfmt.h:733
index
int index
Definition: gxfenc.c:90
AVFilterFormatsConfig
Lists of formats / etc.
Definition: avfilter.h:121
ff_filter_link
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition: filters.h:198
AV_CLASS_CATEGORY_FILTER
@ AV_CLASS_CATEGORY_FILTER
Definition: log.h:36
FFFilterContext::command_queue
struct AVFilterCommand * command_queue
Definition: avfilter_internal.h:118
ff_formats_check_sample_formats
int ff_formats_check_sample_formats(void *log, const AVFilterFormats *fmts)
Check that fmts is a valid sample formats list.
Definition: formats.c:1183
ff_graph_thread_free
void ff_graph_thread_free(FFFilterGraph *graph)
Definition: avfiltergraph.c:73
FFERROR_BUFFERSRC_EMPTY
#define FFERROR_BUFFERSRC_EMPTY
Definition: filters.h:34
f
f
Definition: af_crystalizer.c:122
ff_formats_check_color_spaces
int ff_formats_check_color_spaces(void *log, const AVFilterFormats *fmts)
Check that fmts is a valid formats list for YUV colorspace metadata.
Definition: formats.c:1195
CH_BACK_PAIR
#define CH_BACK_PAIR
Definition: avfiltergraph.c:1092
AVMediaType
AVMediaType
Definition: avutil.h:198
av_bprint_finalize
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
Definition: bprint.c:235
ff_default_query_formats
int ff_default_query_formats(AVFilterContext *ctx)
Sets all remaining unset filter lists for all inputs/outputs to their corresponding ff_all_*() lists.
Definition: formats.c:1094
AVChannelLayout
An AVChannelLayout holds information about the channel layout of audio data.
Definition: channel_layout.h:319
FilterLinkInternal::age_index
int age_index
Index in the age array.
Definition: avfilter_internal.h:80
ff_avfilter_graph_update_heap
void ff_avfilter_graph_update_heap(AVFilterGraph *graph, FilterLinkInternal *li)
Update the position of a link in the age heap.
Definition: avfiltergraph.c:1539
AV_PIX_FMT_FLAG_RGB
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
Definition: pixdesc.h:136
AVFilterCommand::next
struct AVFilterCommand * next
Definition: avfilter_internal.h:131
av_err2str
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition: error.h:122
AVFrame::sample_rate
int sample_rate
Sample rate of the audio data.
Definition: frame.h:590
bps
unsigned bps
Definition: movenc.c:1958
CH_CENTER_PAIR
#define CH_CENTER_PAIR
Definition: avfiltergraph.c:1086
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:56
AV_CHAN_LOW_FREQUENCY
@ AV_CHAN_LOW_FREQUENCY
Definition: channel_layout.h:53
avfilter_graph_queue_command
int avfilter_graph_queue_command(AVFilterGraph *graph, const char *target, const char *command, const char *arg, int flags, double ts)
Queue a command for one or more filter instances.
Definition: avfiltergraph.c:1464
AVFilterChannelLayouts::channel_layouts
AVChannelLayout * channel_layouts
list of channel layouts
Definition: formats.h:86
FFFilterGraph::frame_queues
FFFrameQueueGlobal frame_queues
Definition: avfilter_internal.h:147
AVFilterChannelLayouts::all_layouts
char all_layouts
accept any known channel layout
Definition: formats.h:88
AVFilterChannelLayouts::all_counts
char all_counts
accept any channel layout or count
Definition: formats.h:89
AVFrame::format
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition: frame.h:514
ff_formats_check_channel_layouts
int ff_formats_check_channel_layouts(void *log, const AVFilterChannelLayouts *fmts)
Check that fmts is a valid channel layouts list.
Definition: formats.c:1223
diff
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)
Definition: vf_paletteuse.c:166
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
find_best_sample_fmt_of_2
static enum AVSampleFormat find_best_sample_fmt_of_2(enum AVSampleFormat dst_fmt1, enum AVSampleFormat dst_fmt2, enum AVSampleFormat src_fmt)
Definition: avfiltergraph.c:743
AVFilterFormatsConfig::color_ranges
AVFilterFormats * color_ranges
AVColorRange.
Definition: avfilter.h:142
av_channel_layout_compare
int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1)
Check whether two channel layouts are semantically the same, i.e.
Definition: channel_layout.c:809
avfilter_init_str
int avfilter_init_str(AVFilterContext *filter, const char *args)
Initialize a filter with the supplied parameters.
Definition: avfilter.c:959
buffersink.h
FilterLinkInternal::frame_blocked_in
int frame_blocked_in
If set, the source filter can not generate a frame as is.
Definition: avfilter_internal.h:49
filter_link_check_formats
static int filter_link_check_formats(void *log, AVFilterLink *link, AVFilterFormatsConfig *cfg)
Definition: avfiltergraph.c:297
CH_FRONT_PAIR
#define CH_FRONT_PAIR
Definition: avfiltergraph.c:1087
swap_sample_fmts_on_filter
static void swap_sample_fmts_on_filter(AVFilterContext *filter)
Definition: avfiltergraph.c:1222
ff_formats_unref
void ff_formats_unref(AVFilterFormats **ref)
If *ref is non-NULL, remove *ref as a reference to the format list it currently points to,...
Definition: formats.c:744
bprint.h
ff_formats_check_sample_rates
int ff_formats_check_sample_rates(void *log, const AVFilterFormats *fmts)
Check that fmts is a valid sample rates list.
Definition: formats.c:1188
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
av_get_bytes_per_sample
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
Definition: samplefmt.c:108
FFFilterGraph::disable_auto_convert
unsigned disable_auto_convert
Definition: avfilter_internal.h:143
fffilterctx
static FFFilterContext * fffilterctx(AVFilterContext *ctx)
Definition: avfilter_internal.h:121
swap_channel_layouts_on_filter
static void swap_channel_layouts_on_filter(AVFilterContext *filter)
Definition: avfiltergraph.c:1120
graph_check_links
static int graph_check_links(AVFilterGraph *graph, void *log_ctx)
Definition: avfiltergraph.c:265
AVFilterCommand
Definition: avfilter_internal.h:126
av_malloc_array
#define av_malloc_array(a, b)
Definition: tableprint_vlc.h:32
FilterLinkInternal::status_in
int status_in
Link input status.
Definition: avfilter_internal.h:56
av_assert1
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:57
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
AV_CH_BACK_CENTER
#define AV_CH_BACK_CENTER
Definition: channel_layout.h:183
V
#define V
Definition: avfiltergraph.c:46
FilterLinkInternal::frame_wanted_out
int frame_wanted_out
True if a frame is currently wanted on the output of this filter.
Definition: avfilter_internal.h:75
AV_PIX_FMT_YUVJ440P
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
Definition: pixfmt.h:107
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:256
AVFilterGraph::thread_type
int thread_type
Type of multithreading allowed for filters in this graph.
Definition: avfilter.h:608
print_link_formats
static void print_link_formats(void *log_ctx, int level, const AVFilterLink *l)
Definition: avfiltergraph.c:474
filt
static const int8_t filt[NUMTAPS *2]
Definition: af_earwax.c:40
AVFilterPad::name
const char * name
Pad name.
Definition: filters.h:45
AVCOL_SPC_UNSPECIFIED
@ AVCOL_SPC_UNSPECIFIED
Definition: pixfmt.h:693
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:264
swap_channel_layouts
static void swap_channel_layouts(AVFilterGraph *graph)
Definition: avfiltergraph.c:1214
ff_formats_check_color_ranges
int ff_formats_check_color_ranges(void *log, const AVFilterFormats *fmts)
Definition: formats.c:1206
AVFilter
Filter definition.
Definition: avfilter.h:216
AVFILTER_CMD_FLAG_FAST
#define AVFILTER_CMD_FLAG_FAST
Only execute command when its fast (like a video out that supports contrast adjustment in hw)
Definition: avfilter.h:470
FFFilterContext::ready
unsigned ready
Ready status of the filter.
Definition: avfilter_internal.h:111
ret
ret
Definition: filter_design.txt:187
AVFilterPad::type
enum AVMediaType type
AVFilterPad type.
Definition: filters.h:50
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
FFSWAP
#define FFSWAP(type, a, b)
Definition: macros.h:52
AVALPHA_MODE_UNSPECIFIED
@ AVALPHA_MODE_UNSPECIFIED
Unknown alpha handling, or no alpha channel.
Definition: pixfmt.h:801
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:81
CH_SIDE_PAIR
#define CH_SIDE_PAIR
Definition: avfiltergraph.c:1090
heap_bubble_down
static void heap_bubble_down(FFFilterGraph *graph, FilterLinkInternal *li, int index)
Definition: avfiltergraph.c:1515
av_bprintf
void av_bprintf(AVBPrint *buf, const char *fmt,...)
Definition: bprint.c:122
FF_FILTER_FORMATS_QUERY_FUNC2
@ FF_FILTER_FORMATS_QUERY_FUNC2
formats.query_func2 active.
Definition: filters.h:230
formats_declared
static int formats_declared(AVFilterContext *f)
Definition: avfiltergraph.c:413
av_get_media_type_string
const char * av_get_media_type_string(enum AVMediaType media_type)
Return a string describing the media_type enum, NULL if media_type is unknown.
Definition: utils.c:28
av_find_best_pix_fmt_of_2
enum AVPixelFormat av_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2, enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr)
Compute what kind of losses will occur when converting from one specific pixel format to another.
Definition: pixdesc.c:3726
channel_layout.h
print_formats
static void print_formats(void *log_ctx, int level, enum AVMediaType type, const AVFilterFormats *formats)
Definition: avfiltergraph.c:446
av_channel_layout_subset
uint64_t av_channel_layout_subset(const AVChannelLayout *channel_layout, uint64_t mask)
Find out what channels from a given set are present in a channel layout, without regard for their pos...
Definition: channel_layout.c:865
AV_PIX_FMT_FLAG_XYZ
#define AV_PIX_FMT_FLAG_XYZ
The pixel format contains XYZ-like data (as opposed to YUV/RGB/grayscale).
Definition: pixdesc.h:163
ff_filter_graph_remove_filter
void ff_filter_graph_remove_filter(AVFilterGraph *graph, AVFilterContext *filter)
Remove a filter from a graph;.
Definition: avfiltergraph.c:101
av_channel_layout_index_from_channel
int av_channel_layout_index_from_channel(const AVChannelLayout *channel_layout, enum AVChannel channel)
Get the index of a given channel in a channel layout.
Definition: channel_layout.c:713
CH_WIDE_PAIR
#define CH_WIDE_PAIR
Definition: avfiltergraph.c:1089
ff_framequeue_global_init
void ff_framequeue_global_init(FFFrameQueueGlobal *fqg)
Init a global structure.
Definition: framequeue.c:31
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
avfilter.h
av_channel_layout_uninit
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
Definition: channel_layout.c:442
av_get_packed_sample_fmt
enum AVSampleFormat av_get_packed_sample_fmt(enum AVSampleFormat sample_fmt)
Get the packed alternative form of the given sample format.
Definition: samplefmt.c:77
FFFilterContext
Definition: avfilter_internal.h:95
ref
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:117
KNOWN
#define KNOWN(l)
Definition: formats.h:111
FFFilterGraph::p
AVFilterGraph p
The public AVFilterGraph.
Definition: avfilter_internal.h:138
AVFilterContext
An instance of a filter.
Definition: avfilter.h:274
av_channel_layout_copy
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
Definition: channel_layout.c:449
av_strdup
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:272
desc
const char * desc
Definition: libsvtav1.c:79
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:200
AVFilterChannelLayouts::nb_channel_layouts
int nb_channel_layouts
number of channel layouts
Definition: formats.h:87
mem.h
AVFilterFormatsConfig::formats
AVFilterFormats * formats
List of supported formats (pixel or sample).
Definition: avfilter.h:126
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
avfilter_free
void avfilter_free(AVFilterContext *filter)
Free a filter context.
Definition: avfilter.c:799
A
#define A
Definition: avfiltergraph.c:47
swap_samplerates_on_filter
static void swap_samplerates_on_filter(AVFilterContext *filter)
Definition: avfiltergraph.c:1037
AVChannelLayout::u
union AVChannelLayout::@472 u
Details about which channels are present in this layout.
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
AVFilterGraph::max_buffered_frames
unsigned max_buffered_frames
Sets the maximum number of buffered frames in the filtergraph combined.
Definition: avfilter.h:646
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
Definition: opt.h:255
imgutils.h
avfilter_graph_send_command
int avfilter_graph_send_command(AVFilterGraph *graph, const char *target, const char *cmd, const char *arg, char *res, int res_len, int flags)
Send a command to one or more filter instances.
Definition: avfiltergraph.c:1434
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
FF_FIELD_AT
#define FF_FIELD_AT(type, off, obj)
Access a field in a structure by its offset.
Definition: internal.h:85
AVFilterGraph::nb_filters
unsigned nb_filters
Definition: avfilter.h:592
AVFilterContext::filter
const AVFilter * filter
the AVFilter of which this is an instance
Definition: avfilter.h:277
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition: opt.h:276
AVFilterChannelLayouts::refcount
unsigned refcount
number of references to this list
Definition: formats.h:91
filter_check_formats
static int filter_check_formats(AVFilterContext *ctx)
Check the validity of the formats / etc.
Definition: avfiltergraph.c:329
AV_PIX_FMT_FLAG_PAL
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
Definition: pixdesc.h:120
AV_SAMPLE_FMT_S32
@ AV_SAMPLE_FMT_S32
signed 32 bits
Definition: samplefmt.h:59
filtergraph_class
static const AVClass filtergraph_class
Definition: avfiltergraph.c:64
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
snprintf
#define snprintf
Definition: snprintf.h:34
AV_SAMPLE_FMT_FLT
@ AV_SAMPLE_FMT_FLT
float
Definition: samplefmt.h:60
av_get_pix_fmt_name
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
Definition: pixdesc.c:3367
AVFilterFormatsConfig::alpha_modes
AVFilterFormats * alpha_modes
List of supported alpha modes, only for video with an alpha channel.
Definition: avfilter.h:147
AVFilterCommand::time
double time
time expressed in seconds
Definition: avfilter_internal.h:127