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/avstring.h"
29 #include "libavutil/bprint.h"
31 #include "libavutil/imgutils.h"
32 #include "libavutil/internal.h"
33 #include "libavutil/opt.h"
34 #include "libavutil/pixdesc.h"
35 
36 #define FF_INTERNAL_FIELDS 1
37 #include "framequeue.h"
38 
39 #include "avfilter.h"
40 #include "buffersink.h"
41 #include "formats.h"
42 #include "internal.h"
43 #include "thread.h"
44 
45 #define OFFSET(x) offsetof(AVFilterGraph, x)
46 #define F AV_OPT_FLAG_FILTERING_PARAM
47 #define V AV_OPT_FLAG_VIDEO_PARAM
48 #define A AV_OPT_FLAG_AUDIO_PARAM
49 static const AVOption filtergraph_options[] = {
50  { "thread_type", "Allowed thread types", OFFSET(thread_type), AV_OPT_TYPE_FLAGS,
51  { .i64 = AVFILTER_THREAD_SLICE }, 0, INT_MAX, F|V|A, "thread_type" },
52  { "slice", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AVFILTER_THREAD_SLICE }, .flags = F|V|A, .unit = "thread_type" },
53  { "threads", "Maximum number of threads", OFFSET(nb_threads), AV_OPT_TYPE_INT,
54  { .i64 = 0 }, 0, INT_MAX, F|V|A, "threads"},
55  {"auto", "autodetect a suitable number of threads to use", 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, .flags = F|V|A, .unit = "threads"},
56  {"scale_sws_opts" , "default scale filter options" , OFFSET(scale_sws_opts) ,
57  AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, F|V },
58  {"aresample_swr_opts" , "default aresample filter options" , OFFSET(aresample_swr_opts) ,
59  AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, F|A },
60  { NULL },
61 };
62 
63 static const AVClass filtergraph_class = {
64  .class_name = "AVFilterGraph",
65  .item_name = av_default_item_name,
66  .version = LIBAVUTIL_VERSION_INT,
67  .option = filtergraph_options,
68  .category = AV_CLASS_CATEGORY_FILTER,
69 };
70 
71 #if !HAVE_THREADS
73 {
74 }
75 
77 {
78  graph->thread_type = 0;
79  graph->nb_threads = 1;
80  return 0;
81 }
82 #endif
83 
85 {
86  AVFilterGraph *ret = av_mallocz(sizeof(*ret));
87  if (!ret)
88  return NULL;
89 
90  ret->internal = av_mallocz(sizeof(*ret->internal));
91  if (!ret->internal) {
92  av_freep(&ret);
93  return NULL;
94  }
95 
96  ret->av_class = &filtergraph_class;
98  ff_framequeue_global_init(&ret->internal->frame_queues);
99 
100  return ret;
101 }
102 
104 {
105  int i, j;
106  for (i = 0; i < graph->nb_filters; i++) {
107  if (graph->filters[i] == filter) {
108  FFSWAP(AVFilterContext*, graph->filters[i],
109  graph->filters[graph->nb_filters - 1]);
110  graph->nb_filters--;
111  filter->graph = NULL;
112  for (j = 0; j<filter->nb_outputs; j++)
113  if (filter->outputs[j])
114  filter->outputs[j]->graph = NULL;
115 
116  return;
117  }
118  }
119 }
120 
122 {
123  if (!*graph)
124  return;
125 
126  while ((*graph)->nb_filters)
127  avfilter_free((*graph)->filters[0]);
128 
130 
131  av_freep(&(*graph)->sink_links);
132 
133  av_opt_free(*graph);
134 
135  av_freep(&(*graph)->filters);
136  av_freep(&(*graph)->internal);
137  av_freep(graph);
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 {
164  graph->disable_auto_convert = flags;
165 }
166 
168  const AVFilter *filter,
169  const char *name)
170 {
172 
173  if (graph->thread_type && !graph->internal->thread_execute) {
174  if (graph->execute) {
175  graph->internal->thread_execute = graph->execute;
176  } else {
178  if (ret < 0) {
179  av_log(graph, AV_LOG_ERROR, "Error initializing threading: %s.\n", av_err2str(ret));
180  return NULL;
181  }
182  }
183  }
184 
185  filters = av_realloc_array(graph->filters, graph->nb_filters + 1, sizeof(*filters));
186  if (!filters)
187  return NULL;
188  graph->filters = filters;
189 
191  if (!s)
192  return NULL;
193 
194  graph->filters[graph->nb_filters++] = s;
195 
196  s->graph = graph;
197 
198  return s;
199 }
200 
201 /**
202  * Check for the validity of graph.
203  *
204  * A graph is considered valid if all its input and output pads are
205  * connected.
206  *
207  * @return >= 0 in case of success, a negative value otherwise
208  */
209 static int graph_check_validity(AVFilterGraph *graph, void *log_ctx)
210 {
212  int i, j;
213 
214  for (i = 0; i < graph->nb_filters; i++) {
215  const AVFilterPad *pad;
216  filt = graph->filters[i];
217 
218  for (j = 0; j < filt->nb_inputs; j++) {
219  if (!filt->inputs[j] || !filt->inputs[j]->src) {
220  pad = &filt->input_pads[j];
221  av_log(log_ctx, AV_LOG_ERROR,
222  "Input pad \"%s\" with type %s of the filter instance \"%s\" of %s not connected to any source\n",
223  pad->name, av_get_media_type_string(pad->type), filt->name, filt->filter->name);
224  return AVERROR(EINVAL);
225  }
226  }
227 
228  for (j = 0; j < filt->nb_outputs; j++) {
229  if (!filt->outputs[j] || !filt->outputs[j]->dst) {
230  pad = &filt->output_pads[j];
231  av_log(log_ctx, AV_LOG_ERROR,
232  "Output pad \"%s\" with type %s of the filter instance \"%s\" of %s not connected to any destination\n",
233  pad->name, av_get_media_type_string(pad->type), filt->name, filt->filter->name);
234  return AVERROR(EINVAL);
235  }
236  }
237  }
238 
239  return 0;
240 }
241 
242 /**
243  * Configure all the links of graphctx.
244  *
245  * @return >= 0 in case of success, a negative value otherwise
246  */
247 static int graph_config_links(AVFilterGraph *graph, void *log_ctx)
248 {
250  int i, ret;
251 
252  for (i = 0; i < graph->nb_filters; i++) {
253  filt = graph->filters[i];
254 
255  if (!filt->nb_outputs) {
256  if ((ret = avfilter_config_links(filt)))
257  return ret;
258  }
259  }
260 
261  return 0;
262 }
263 
264 static int graph_check_links(AVFilterGraph *graph, void *log_ctx)
265 {
267  AVFilterLink *l;
268  unsigned i, j;
269  int ret;
270 
271  for (i = 0; i < graph->nb_filters; i++) {
272  f = graph->filters[i];
273  for (j = 0; j < f->nb_outputs; j++) {
274  l = f->outputs[j];
275  if (l->type == AVMEDIA_TYPE_VIDEO) {
276  ret = av_image_check_size2(l->w, l->h, INT64_MAX, l->format, 0, f);
277  if (ret < 0)
278  return ret;
279  }
280  }
281  }
282  return 0;
283 }
284 
286 {
287  int i;
288 
289  for (i = 0; i < graph->nb_filters; i++)
290  if (graph->filters[i]->name && !strcmp(name, graph->filters[i]->name))
291  return graph->filters[i];
292 
293  return NULL;
294 }
295 
297 {
298  int ret;
299 
300  switch (link->type) {
301 
302  case AVMEDIA_TYPE_VIDEO:
303  if ((ret = ff_formats_check_pixel_formats(log, cfg->formats)) < 0)
304  return ret;
305  break;
306 
307  case AVMEDIA_TYPE_AUDIO:
308  if ((ret = ff_formats_check_sample_formats(log, cfg->formats)) < 0 ||
309  (ret = ff_formats_check_sample_rates(log, cfg->samplerates)) < 0 ||
311  return ret;
312  break;
313 
314  default:
315  av_assert0(!"reached");
316  }
317  return 0;
318 }
319 
320 /**
321  * Check the validity of the formats / etc. lists set by query_formats().
322  *
323  * In particular, check they do not contain any redundant element.
324  */
326 {
327  unsigned i;
328  int ret;
329 
330  for (i = 0; i < ctx->nb_inputs; i++) {
331  ret = filter_link_check_formats(ctx, ctx->inputs[i], &ctx->inputs[i]->outcfg);
332  if (ret < 0)
333  return ret;
334  }
335  for (i = 0; i < ctx->nb_outputs; i++) {
336  ret = filter_link_check_formats(ctx, ctx->outputs[i], &ctx->outputs[i]->incfg);
337  if (ret < 0)
338  return ret;
339  }
340  return 0;
341 }
342 
344 {
345  int ret;
347  AVFilterChannelLayouts *chlayouts;
348  enum AVMediaType type = ctx->inputs && ctx->inputs [0] ? ctx->inputs [0]->type :
349  ctx->outputs && ctx->outputs[0] ? ctx->outputs[0]->type :
351 
352  if ((ret = ctx->filter->formats.query_func(ctx)) < 0) {
353  if (ret != AVERROR(EAGAIN))
354  av_log(ctx, AV_LOG_ERROR, "Query format failed for '%s': %s\n",
355  ctx->name, av_err2str(ret));
356  return ret;
357  }
359  if (ret < 0)
360  return ret;
361 
363  if ((ret = ff_set_common_formats(ctx, formats)) < 0)
364  return ret;
365  if (type == AVMEDIA_TYPE_AUDIO) {
367  return ret;
368  chlayouts = ff_all_channel_layouts();
369  if ((ret = ff_set_common_channel_layouts(ctx, chlayouts)) < 0)
370  return ret;
371  }
372  return 0;
373 }
374 
376 {
377  int i;
378 
379  for (i = 0; i < f->nb_inputs; i++) {
380  if (!f->inputs[i]->outcfg.formats)
381  return 0;
382  if (f->inputs[i]->type == AVMEDIA_TYPE_AUDIO &&
383  !(f->inputs[i]->outcfg.samplerates &&
384  f->inputs[i]->outcfg.channel_layouts))
385  return 0;
386  }
387  for (i = 0; i < f->nb_outputs; i++) {
388  if (!f->outputs[i]->incfg.formats)
389  return 0;
390  if (f->outputs[i]->type == AVMEDIA_TYPE_AUDIO &&
391  !(f->outputs[i]->incfg.samplerates &&
392  f->outputs[i]->incfg.channel_layouts))
393  return 0;
394  }
395  return 1;
396 }
397 
398 /**
399  * Perform one round of query_formats() and merging formats lists on the
400  * filter graph.
401  * @return >=0 if all links formats lists could be queried and merged;
402  * AVERROR(EAGAIN) some progress was made in the queries or merging
403  * and a later call may succeed;
404  * AVERROR(EIO) (may be changed) plus a log message if no progress
405  * was made and the negotiation is stuck;
406  * a negative error code if some other error happened
407  */
408 static int query_formats(AVFilterGraph *graph, void *log_ctx)
409 {
410  int i, j, ret;
411  int converter_count = 0;
412  int count_queried = 0; /* successful calls to query_formats() */
413  int count_merged = 0; /* successful merge of formats lists */
414  int count_already_merged = 0; /* lists already merged */
415  int count_delayed = 0; /* lists that need to be merged later */
416 
417  for (i = 0; i < graph->nb_filters; i++) {
418  AVFilterContext *f = graph->filters[i];
419  if (formats_declared(f))
420  continue;
421  if (f->filter->formats_state == FF_FILTER_FORMATS_QUERY_FUNC)
423  else
425  if (ret < 0 && ret != AVERROR(EAGAIN))
426  return ret;
427  /* note: EAGAIN could indicate a partial success, not counted yet */
428  count_queried += ret >= 0;
429  }
430 
431  /* go through and merge as many format lists as possible */
432  for (i = 0; i < graph->nb_filters; i++) {
433  AVFilterContext *filter = graph->filters[i];
434 
435  for (j = 0; j < filter->nb_inputs; j++) {
436  AVFilterLink *link = filter->inputs[j];
437  const AVFilterNegotiation *neg;
438  unsigned neg_step;
439  int convert_needed = 0;
440 
441  if (!link)
442  continue;
443 
445  av_assert0(neg);
446  for (neg_step = 1; neg_step < neg->nb_mergers; neg_step++) {
447  const AVFilterFormatsMerger *m = &neg->mergers[neg_step];
448  void *a = FF_FIELD_AT(void *, m->offset, link->incfg);
449  void *b = FF_FIELD_AT(void *, m->offset, link->outcfg);
450  if (a && b && a != b && !m->can_merge(a, b)) {
451  convert_needed = 1;
452  break;
453  }
454  }
455  for (neg_step = 0; neg_step < neg->nb_mergers; neg_step++) {
456  const AVFilterFormatsMerger *m = &neg->mergers[neg_step];
457  void *a = FF_FIELD_AT(void *, m->offset, link->incfg);
458  void *b = FF_FIELD_AT(void *, m->offset, link->outcfg);
459  if (!(a && b)) {
460  count_delayed++;
461  } else if (a == b) {
462  count_already_merged++;
463  } else if (!convert_needed) {
464  count_merged++;
465  ret = m->merge(a, b);
466  if (ret < 0)
467  return ret;
468  if (!ret)
469  convert_needed = 1;
470  }
471  }
472 
473  if (convert_needed) {
475  const AVFilter *filter;
476  AVFilterLink *inlink, *outlink;
477  char inst_name[30];
478  const char *opts;
479 
480  if (graph->disable_auto_convert) {
481  av_log(log_ctx, AV_LOG_ERROR,
482  "The filters '%s' and '%s' do not have a common format "
483  "and automatic conversion is disabled.\n",
484  link->src->name, link->dst->name);
485  return AVERROR(EINVAL);
486  }
487 
488  /* couldn't merge format lists. auto-insert conversion filter */
490  av_log(log_ctx, AV_LOG_ERROR,
491  "'%s' filter not present, cannot convert formats.\n",
492  neg->conversion_filter);
493  return AVERROR(EINVAL);
494  }
495  snprintf(inst_name, sizeof(inst_name), "auto_%s_%d",
496  neg->conversion_filter, converter_count++);
497  opts = FF_FIELD_AT(char *, neg->conversion_opts_offset, *graph);
499  if (ret < 0)
500  return ret;
501  if ((ret = avfilter_insert_filter(link, convert, 0, 0)) < 0)
502  return ret;
503 
504  if ((ret = filter_query_formats(convert)) < 0)
505  return ret;
506 
507  inlink = convert->inputs[0];
508  outlink = convert->outputs[0];
509  av_assert0( inlink->incfg.formats->refcount > 0);
510  av_assert0( inlink->outcfg.formats->refcount > 0);
511  av_assert0(outlink->incfg.formats->refcount > 0);
512  av_assert0(outlink->outcfg.formats->refcount > 0);
513  if (outlink->type == AVMEDIA_TYPE_AUDIO) {
514  av_assert0( inlink-> incfg.samplerates->refcount > 0);
515  av_assert0( inlink->outcfg.samplerates->refcount > 0);
516  av_assert0(outlink-> incfg.samplerates->refcount > 0);
517  av_assert0(outlink->outcfg.samplerates->refcount > 0);
518  av_assert0( inlink-> incfg.channel_layouts->refcount > 0);
519  av_assert0( inlink->outcfg.channel_layouts->refcount > 0);
520  av_assert0(outlink-> incfg.channel_layouts->refcount > 0);
521  av_assert0(outlink->outcfg.channel_layouts->refcount > 0);
522  }
523 #define MERGE(merger, link) \
524  ((merger)->merge(FF_FIELD_AT(void *, (merger)->offset, (link)->incfg), \
525  FF_FIELD_AT(void *, (merger)->offset, (link)->outcfg)))
526  for (neg_step = 0; neg_step < neg->nb_mergers; neg_step++) {
527  const AVFilterFormatsMerger *m = &neg->mergers[neg_step];
528  if ((ret = MERGE(m, inlink)) <= 0 ||
529  (ret = MERGE(m, outlink)) <= 0) {
530  if (ret < 0)
531  return ret;
532  av_log(log_ctx, AV_LOG_ERROR,
533  "Impossible to convert between the formats supported by the filter "
534  "'%s' and the filter '%s'\n", link->src->name, link->dst->name);
535  return AVERROR(ENOSYS);
536  }
537  }
538  }
539  }
540  }
541 
542  av_log(graph, AV_LOG_DEBUG, "query_formats: "
543  "%d queried, %d merged, %d already done, %d delayed\n",
544  count_queried, count_merged, count_already_merged, count_delayed);
545  if (count_delayed) {
546  AVBPrint bp;
547 
548  /* if count_queried > 0, one filter at least did set its formats,
549  that will give additional information to its neighbour;
550  if count_merged > 0, one pair of formats lists at least was merged,
551  that will give additional information to all connected filters;
552  in both cases, progress was made and a new round must be done */
553  if (count_queried || count_merged)
554  return AVERROR(EAGAIN);
556  for (i = 0; i < graph->nb_filters; i++)
557  if (!formats_declared(graph->filters[i]))
558  av_bprintf(&bp, "%s%s", bp.len ? ", " : "",
559  graph->filters[i]->name);
561  "The following filters could not choose their formats: %s\n"
562  "Consider inserting the (a)format filter near their input or "
563  "output.\n", bp.str);
564  return AVERROR(EIO);
565  }
566  return 0;
567 }
568 
569 static int get_fmt_score(enum AVSampleFormat dst_fmt, enum AVSampleFormat src_fmt)
570 {
571  int score = 0;
572 
573  if (av_sample_fmt_is_planar(dst_fmt) != av_sample_fmt_is_planar(src_fmt))
574  score ++;
575 
576  if (av_get_bytes_per_sample(dst_fmt) < av_get_bytes_per_sample(src_fmt)) {
577  score += 100 * (av_get_bytes_per_sample(src_fmt) - av_get_bytes_per_sample(dst_fmt));
578  }else
579  score += 10 * (av_get_bytes_per_sample(dst_fmt) - av_get_bytes_per_sample(src_fmt));
580 
583  score += 20;
584 
587  score += 2;
588 
589  return score;
590 }
591 
593  enum AVSampleFormat src_fmt)
594 {
595  int score1, score2;
596 
597  score1 = get_fmt_score(dst_fmt1, src_fmt);
598  score2 = get_fmt_score(dst_fmt2, src_fmt);
599 
600  return score1 < score2 ? dst_fmt1 : dst_fmt2;
601 }
602 
604 {
605  if (!link || !link->incfg.formats)
606  return 0;
607 
608  if (link->type == AVMEDIA_TYPE_VIDEO) {
609  if(ref && ref->type == AVMEDIA_TYPE_VIDEO){
610  //FIXME: This should check for AV_PIX_FMT_FLAG_ALPHA after PAL8 pixel format without alpha is implemented
611  int has_alpha= av_pix_fmt_desc_get(ref->format)->nb_components % 2 == 0;
612  enum AVPixelFormat best= AV_PIX_FMT_NONE;
613  int i;
614  for (i = 0; i < link->incfg.formats->nb_formats; i++) {
615  enum AVPixelFormat p = link->incfg.formats->formats[i];
616  best= av_find_best_pix_fmt_of_2(best, p, ref->format, has_alpha, NULL);
617  }
618  av_log(link->src,AV_LOG_DEBUG, "picking %s out of %d ref:%s alpha:%d\n",
619  av_get_pix_fmt_name(best), link->incfg.formats->nb_formats,
620  av_get_pix_fmt_name(ref->format), has_alpha);
621  link->incfg.formats->formats[0] = best;
622  }
623  } else if (link->type == AVMEDIA_TYPE_AUDIO) {
624  if(ref && ref->type == AVMEDIA_TYPE_AUDIO){
626  int i;
627  for (i = 0; i < link->incfg.formats->nb_formats; i++) {
628  enum AVSampleFormat p = link->incfg.formats->formats[i];
629  best = find_best_sample_fmt_of_2(best, p, ref->format);
630  }
631  av_log(link->src,AV_LOG_DEBUG, "picking %s out of %d ref:%s\n",
632  av_get_sample_fmt_name(best), link->incfg.formats->nb_formats,
633  av_get_sample_fmt_name(ref->format));
634  link->incfg.formats->formats[0] = best;
635  }
636  }
637 
638  link->incfg.formats->nb_formats = 1;
639  link->format = link->incfg.formats->formats[0];
640 
641  if (link->type == AVMEDIA_TYPE_AUDIO) {
642  if (!link->incfg.samplerates->nb_formats) {
643  av_log(link->src, AV_LOG_ERROR, "Cannot select sample rate for"
644  " the link between filters %s and %s.\n", link->src->name,
645  link->dst->name);
646  return AVERROR(EINVAL);
647  }
648  link->incfg.samplerates->nb_formats = 1;
649  link->sample_rate = link->incfg.samplerates->formats[0];
650 
651  if (link->incfg.channel_layouts->all_layouts) {
652  av_log(link->src, AV_LOG_ERROR, "Cannot select channel layout for"
653  " the link between filters %s and %s.\n", link->src->name,
654  link->dst->name);
655  if (!link->incfg.channel_layouts->all_counts)
656  av_log(link->src, AV_LOG_ERROR, "Unknown channel layouts not "
657  "supported, try specifying a channel layout using "
658  "'aformat=channel_layouts=something'.\n");
659  return AVERROR(EINVAL);
660  }
661  link->incfg.channel_layouts->nb_channel_layouts = 1;
662  link->channel_layout = link->incfg.channel_layouts->channel_layouts[0];
664  link->channel_layout = 0;
665  else
667  }
668 
669  ff_formats_unref(&link->incfg.formats);
670  ff_formats_unref(&link->outcfg.formats);
671  ff_formats_unref(&link->incfg.samplerates);
672  ff_formats_unref(&link->outcfg.samplerates);
673  ff_channel_layouts_unref(&link->incfg.channel_layouts);
674  ff_channel_layouts_unref(&link->outcfg.channel_layouts);
675 
676  return 0;
677 }
678 
679 #define REDUCE_FORMATS(fmt_type, list_type, list, var, nb, add_format) \
680 do { \
681  for (i = 0; i < filter->nb_inputs; i++) { \
682  AVFilterLink *link = filter->inputs[i]; \
683  fmt_type fmt; \
684  \
685  if (!link->outcfg.list || link->outcfg.list->nb != 1) \
686  continue; \
687  fmt = link->outcfg.list->var[0]; \
688  \
689  for (j = 0; j < filter->nb_outputs; j++) { \
690  AVFilterLink *out_link = filter->outputs[j]; \
691  list_type *fmts; \
692  \
693  if (link->type != out_link->type || \
694  out_link->incfg.list->nb == 1) \
695  continue; \
696  fmts = out_link->incfg.list; \
697  \
698  if (!out_link->incfg.list->nb) { \
699  if ((ret = add_format(&out_link->incfg.list, fmt)) < 0)\
700  return ret; \
701  ret = 1; \
702  break; \
703  } \
704  \
705  for (k = 0; k < out_link->incfg.list->nb; k++) \
706  if (fmts->var[k] == fmt) { \
707  fmts->var[0] = fmt; \
708  fmts->nb = 1; \
709  ret = 1; \
710  break; \
711  } \
712  } \
713  } \
714 } while (0)
715 
717 {
718  int i, j, k, ret = 0;
719 
721  nb_formats, ff_add_format);
722  REDUCE_FORMATS(int, AVFilterFormats, samplerates, formats,
723  nb_formats, ff_add_format);
724 
725  /* reduce channel layouts */
726  for (i = 0; i < filter->nb_inputs; i++) {
727  AVFilterLink *inlink = filter->inputs[i];
728  uint64_t fmt;
729 
730  if (!inlink->outcfg.channel_layouts ||
731  inlink->outcfg.channel_layouts->nb_channel_layouts != 1)
732  continue;
733  fmt = inlink->outcfg.channel_layouts->channel_layouts[0];
734 
735  for (j = 0; j < filter->nb_outputs; j++) {
736  AVFilterLink *outlink = filter->outputs[j];
738 
739  fmts = outlink->incfg.channel_layouts;
740  if (inlink->type != outlink->type || fmts->nb_channel_layouts == 1)
741  continue;
742 
743  if (fmts->all_layouts &&
744  (!FF_LAYOUT2COUNT(fmt) || fmts->all_counts)) {
745  /* Turn the infinite list into a singleton */
746  fmts->all_layouts = fmts->all_counts = 0;
747  if (ff_add_channel_layout(&outlink->incfg.channel_layouts, fmt) < 0)
748  ret = 1;
749  break;
750  }
751 
752  for (k = 0; k < outlink->incfg.channel_layouts->nb_channel_layouts; k++) {
753  if (fmts->channel_layouts[k] == fmt) {
754  fmts->channel_layouts[0] = fmt;
755  fmts->nb_channel_layouts = 1;
756  ret = 1;
757  break;
758  }
759  }
760  }
761  }
762 
763  return ret;
764 }
765 
767 {
768  int i, reduced, ret;
769 
770  do {
771  reduced = 0;
772 
773  for (i = 0; i < graph->nb_filters; i++) {
774  if ((ret = reduce_formats_on_filter(graph->filters[i])) < 0)
775  return ret;
776  reduced |= ret;
777  }
778  } while (reduced);
779 
780  return 0;
781 }
782 
784 {
786  int sample_rate;
787  int i, j;
788 
789  for (i = 0; i < filter->nb_inputs; i++) {
790  link = filter->inputs[i];
791 
792  if (link->type == AVMEDIA_TYPE_AUDIO &&
793  link->outcfg.samplerates->nb_formats== 1)
794  break;
795  }
796  if (i == filter->nb_inputs)
797  return;
798 
799  sample_rate = link->outcfg.samplerates->formats[0];
800 
801  for (i = 0; i < filter->nb_outputs; i++) {
802  AVFilterLink *outlink = filter->outputs[i];
803  int best_idx, best_diff = INT_MAX;
804 
805  if (outlink->type != AVMEDIA_TYPE_AUDIO ||
806  outlink->incfg.samplerates->nb_formats < 2)
807  continue;
808 
809  for (j = 0; j < outlink->incfg.samplerates->nb_formats; j++) {
810  int diff = abs(sample_rate - outlink->incfg.samplerates->formats[j]);
811 
812  av_assert0(diff < INT_MAX); // This would lead to the use of uninitialized best_diff but is only possible with invalid sample rates
813 
814  if (diff < best_diff) {
815  best_diff = diff;
816  best_idx = j;
817  }
818  }
819  FFSWAP(int, outlink->incfg.samplerates->formats[0],
820  outlink->incfg.samplerates->formats[best_idx]);
821  }
822 }
823 
825 {
826  int i;
827 
828  for (i = 0; i < graph->nb_filters; i++)
830 }
831 
832 #define CH_CENTER_PAIR (AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER)
833 #define CH_FRONT_PAIR (AV_CH_FRONT_LEFT | AV_CH_FRONT_RIGHT)
834 #define CH_STEREO_PAIR (AV_CH_STEREO_LEFT | AV_CH_STEREO_RIGHT)
835 #define CH_WIDE_PAIR (AV_CH_WIDE_LEFT | AV_CH_WIDE_RIGHT)
836 #define CH_SIDE_PAIR (AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT)
837 #define CH_DIRECT_PAIR (AV_CH_SURROUND_DIRECT_LEFT | AV_CH_SURROUND_DIRECT_RIGHT)
838 #define CH_BACK_PAIR (AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT)
839 
840 /* allowable substitutions for channel pairs when comparing layouts,
841  * ordered by priority for both values */
842 static const uint64_t ch_subst[][2] = {
864 };
865 
867 {
869  int i, j, k;
870 
871  for (i = 0; i < filter->nb_inputs; i++) {
872  link = filter->inputs[i];
873 
874  if (link->type == AVMEDIA_TYPE_AUDIO &&
875  link->outcfg.channel_layouts->nb_channel_layouts == 1)
876  break;
877  }
878  if (i == filter->nb_inputs)
879  return;
880 
881  for (i = 0; i < filter->nb_outputs; i++) {
882  AVFilterLink *outlink = filter->outputs[i];
883  int best_idx = -1, best_score = INT_MIN, best_count_diff = INT_MAX;
884 
885  if (outlink->type != AVMEDIA_TYPE_AUDIO ||
887  continue;
888 
889  for (j = 0; j < outlink->incfg.channel_layouts->nb_channel_layouts; j++) {
890  uint64_t in_chlayout = link->outcfg.channel_layouts->channel_layouts[0];
891  uint64_t out_chlayout = outlink->incfg.channel_layouts->channel_layouts[j];
892  int in_channels = av_get_channel_layout_nb_channels(in_chlayout);
893  int out_channels = av_get_channel_layout_nb_channels(out_chlayout);
894  int count_diff = out_channels - in_channels;
895  int matched_channels, extra_channels;
896  int score = 100000;
897 
898  if (FF_LAYOUT2COUNT(in_chlayout) || FF_LAYOUT2COUNT(out_chlayout)) {
899  /* Compute score in case the input or output layout encodes
900  a channel count; in this case the score is not altered by
901  the computation afterwards, as in_chlayout and
902  out_chlayout have both been set to 0 */
903  if (FF_LAYOUT2COUNT(in_chlayout))
904  in_channels = FF_LAYOUT2COUNT(in_chlayout);
905  if (FF_LAYOUT2COUNT(out_chlayout))
906  out_channels = FF_LAYOUT2COUNT(out_chlayout);
907  score -= 10000 + FFABS(out_channels - in_channels) +
908  (in_channels > out_channels ? 10000 : 0);
909  in_chlayout = out_chlayout = 0;
910  /* Let the remaining computation run, even if the score
911  value is not altered */
912  }
913 
914  /* channel substitution */
915  for (k = 0; k < FF_ARRAY_ELEMS(ch_subst); k++) {
916  uint64_t cmp0 = ch_subst[k][0];
917  uint64_t cmp1 = ch_subst[k][1];
918  if (( in_chlayout & cmp0) && (!(out_chlayout & cmp0)) &&
919  (out_chlayout & cmp1) && (!( in_chlayout & cmp1))) {
920  in_chlayout &= ~cmp0;
921  out_chlayout &= ~cmp1;
922  /* add score for channel match, minus a deduction for
923  having to do the substitution */
924  score += 10 * av_get_channel_layout_nb_channels(cmp1) - 2;
925  }
926  }
927 
928  /* no penalty for LFE channel mismatch */
929  if ( (in_chlayout & AV_CH_LOW_FREQUENCY) &&
930  (out_chlayout & AV_CH_LOW_FREQUENCY))
931  score += 10;
932  in_chlayout &= ~AV_CH_LOW_FREQUENCY;
933  out_chlayout &= ~AV_CH_LOW_FREQUENCY;
934 
935  matched_channels = av_get_channel_layout_nb_channels(in_chlayout &
936  out_chlayout);
937  extra_channels = av_get_channel_layout_nb_channels(out_chlayout &
938  (~in_chlayout));
939  score += 10 * matched_channels - 5 * extra_channels;
940 
941  if (score > best_score ||
942  (count_diff < best_count_diff && score == best_score)) {
943  best_score = score;
944  best_idx = j;
945  best_count_diff = count_diff;
946  }
947  }
948  av_assert0(best_idx >= 0);
949  FFSWAP(uint64_t, outlink->incfg.channel_layouts->channel_layouts[0],
950  outlink->incfg.channel_layouts->channel_layouts[best_idx]);
951  }
952 
953 }
954 
956 {
957  int i;
958 
959  for (i = 0; i < graph->nb_filters; i++)
961 }
962 
964 {
966  int format, bps;
967  int i, j;
968 
969  for (i = 0; i < filter->nb_inputs; i++) {
970  link = filter->inputs[i];
971 
972  if (link->type == AVMEDIA_TYPE_AUDIO &&
973  link->outcfg.formats->nb_formats == 1)
974  break;
975  }
976  if (i == filter->nb_inputs)
977  return;
978 
979  format = link->outcfg.formats->formats[0];
981 
982  for (i = 0; i < filter->nb_outputs; i++) {
983  AVFilterLink *outlink = filter->outputs[i];
984  int best_idx = -1, best_score = INT_MIN;
985 
986  if (outlink->type != AVMEDIA_TYPE_AUDIO ||
987  outlink->incfg.formats->nb_formats < 2)
988  continue;
989 
990  for (j = 0; j < outlink->incfg.formats->nb_formats; j++) {
991  int out_format = outlink->incfg.formats->formats[j];
992  int out_bps = av_get_bytes_per_sample(out_format);
993  int score;
994 
995  if (av_get_packed_sample_fmt(out_format) == format ||
996  av_get_planar_sample_fmt(out_format) == format) {
997  best_idx = j;
998  break;
999  }
1000 
1001  /* for s32 and float prefer double to prevent loss of information */
1002  if (bps == 4 && out_bps == 8) {
1003  best_idx = j;
1004  break;
1005  }
1006 
1007  /* prefer closest higher or equal bps */
1008  score = -abs(out_bps - bps);
1009  if (out_bps >= bps)
1010  score += INT_MAX/2;
1011 
1012  if (score > best_score) {
1013  best_score = score;
1014  best_idx = j;
1015  }
1016  }
1017  av_assert0(best_idx >= 0);
1018  FFSWAP(int, outlink->incfg.formats->formats[0],
1019  outlink->incfg.formats->formats[best_idx]);
1020  }
1021 }
1022 
1024 {
1025  int i;
1026 
1027  for (i = 0; i < graph->nb_filters; i++)
1028  swap_sample_fmts_on_filter(graph->filters[i]);
1029 
1030 }
1031 
1033 {
1034  int i, j, ret;
1035  int change;
1036 
1037  do{
1038  change = 0;
1039  for (i = 0; i < graph->nb_filters; i++) {
1040  AVFilterContext *filter = graph->filters[i];
1041  if (filter->nb_inputs){
1042  for (j = 0; j < filter->nb_inputs; j++){
1043  if (filter->inputs[j]->incfg.formats && filter->inputs[j]->incfg.formats->nb_formats == 1) {
1044  if ((ret = pick_format(filter->inputs[j], NULL)) < 0)
1045  return ret;
1046  change = 1;
1047  }
1048  }
1049  }
1050  if (filter->nb_outputs){
1051  for (j = 0; j < filter->nb_outputs; j++){
1052  if (filter->outputs[j]->incfg.formats && filter->outputs[j]->incfg.formats->nb_formats == 1) {
1053  if ((ret = pick_format(filter->outputs[j], NULL)) < 0)
1054  return ret;
1055  change = 1;
1056  }
1057  }
1058  }
1059  if (filter->nb_inputs && filter->nb_outputs && filter->inputs[0]->format>=0) {
1060  for (j = 0; j < filter->nb_outputs; j++) {
1061  if (filter->outputs[j]->format<0) {
1062  if ((ret = pick_format(filter->outputs[j], filter->inputs[0])) < 0)
1063  return ret;
1064  change = 1;
1065  }
1066  }
1067  }
1068  }
1069  }while(change);
1070 
1071  for (i = 0; i < graph->nb_filters; i++) {
1072  AVFilterContext *filter = graph->filters[i];
1073 
1074  for (j = 0; j < filter->nb_inputs; j++)
1075  if ((ret = pick_format(filter->inputs[j], NULL)) < 0)
1076  return ret;
1077  for (j = 0; j < filter->nb_outputs; j++)
1078  if ((ret = pick_format(filter->outputs[j], NULL)) < 0)
1079  return ret;
1080  }
1081  return 0;
1082 }
1083 
1084 /**
1085  * Configure the formats of all the links in the graph.
1086  */
1087 static int graph_config_formats(AVFilterGraph *graph, void *log_ctx)
1088 {
1089  int ret;
1090 
1091  /* find supported formats from sub-filters, and merge along links */
1092  while ((ret = query_formats(graph, log_ctx)) == AVERROR(EAGAIN))
1093  av_log(graph, AV_LOG_DEBUG, "query_formats not finished\n");
1094  if (ret < 0)
1095  return ret;
1096 
1097  /* Once everything is merged, it's possible that we'll still have
1098  * multiple valid media format choices. We try to minimize the amount
1099  * of format conversion inside filters */
1100  if ((ret = reduce_formats(graph)) < 0)
1101  return ret;
1102 
1103  /* for audio filters, ensure the best format, sample rate and channel layout
1104  * is selected */
1108 
1109  if ((ret = pick_formats(graph)) < 0)
1110  return ret;
1111 
1112  return 0;
1113 }
1114 
1115 static int graph_config_pointers(AVFilterGraph *graph, void *log_ctx)
1116 {
1117  unsigned i, j;
1118  int sink_links_count = 0, n = 0;
1119  AVFilterContext *f;
1120  AVFilterLink **sinks;
1121 
1122  for (i = 0; i < graph->nb_filters; i++) {
1123  f = graph->filters[i];
1124  for (j = 0; j < f->nb_inputs; j++) {
1125  f->inputs[j]->graph = graph;
1126  f->inputs[j]->age_index = -1;
1127  }
1128  for (j = 0; j < f->nb_outputs; j++) {
1129  f->outputs[j]->graph = graph;
1130  f->outputs[j]->age_index= -1;
1131  }
1132  if (!f->nb_outputs) {
1133  if (f->nb_inputs > INT_MAX - sink_links_count)
1134  return AVERROR(EINVAL);
1135  sink_links_count += f->nb_inputs;
1136  }
1137  }
1138  sinks = av_calloc(sink_links_count, sizeof(*sinks));
1139  if (!sinks)
1140  return AVERROR(ENOMEM);
1141  for (i = 0; i < graph->nb_filters; i++) {
1142  f = graph->filters[i];
1143  if (!f->nb_outputs) {
1144  for (j = 0; j < f->nb_inputs; j++) {
1145  sinks[n] = f->inputs[j];
1146  f->inputs[j]->age_index = n++;
1147  }
1148  }
1149  }
1150  av_assert0(n == sink_links_count);
1151  graph->sink_links = sinks;
1152  graph->sink_links_count = sink_links_count;
1153  return 0;
1154 }
1155 
1156 int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
1157 {
1158  int ret;
1159 
1160  if ((ret = graph_check_validity(graphctx, log_ctx)))
1161  return ret;
1162  if ((ret = graph_config_formats(graphctx, log_ctx)))
1163  return ret;
1164  if ((ret = graph_config_links(graphctx, log_ctx)))
1165  return ret;
1166  if ((ret = graph_check_links(graphctx, log_ctx)))
1167  return ret;
1168  if ((ret = graph_config_pointers(graphctx, log_ctx)))
1169  return ret;
1170 
1171  return 0;
1172 }
1173 
1174 int avfilter_graph_send_command(AVFilterGraph *graph, const char *target, const char *cmd, const char *arg, char *res, int res_len, int flags)
1175 {
1176  int i, r = AVERROR(ENOSYS);
1177 
1178  if (!graph)
1179  return r;
1180 
1182  r = avfilter_graph_send_command(graph, target, cmd, arg, res, res_len, flags | AVFILTER_CMD_FLAG_FAST);
1183  if (r != AVERROR(ENOSYS))
1184  return r;
1185  }
1186 
1187  if (res_len && res)
1188  res[0] = 0;
1189 
1190  for (i = 0; i < graph->nb_filters; i++) {
1191  AVFilterContext *filter = graph->filters[i];
1192  if (!strcmp(target, "all") || (filter->name && !strcmp(target, filter->name)) || !strcmp(target, filter->filter->name)) {
1193  r = avfilter_process_command(filter, cmd, arg, res, res_len, flags);
1194  if (r != AVERROR(ENOSYS)) {
1195  if ((flags & AVFILTER_CMD_FLAG_ONE) || r < 0)
1196  return r;
1197  }
1198  }
1199  }
1200 
1201  return r;
1202 }
1203 
1204 int avfilter_graph_queue_command(AVFilterGraph *graph, const char *target, const char *command, const char *arg, int flags, double ts)
1205 {
1206  int i;
1207 
1208  if(!graph)
1209  return 0;
1210 
1211  for (i = 0; i < graph->nb_filters; i++) {
1212  AVFilterContext *filter = graph->filters[i];
1213  if(filter && (!strcmp(target, "all") || !strcmp(target, filter->name) || !strcmp(target, filter->filter->name))){
1214  AVFilterCommand **queue = &filter->command_queue, *next;
1215  while (*queue && (*queue)->time <= ts)
1216  queue = &(*queue)->next;
1217  next = *queue;
1218  *queue = av_mallocz(sizeof(AVFilterCommand));
1219  if (!*queue)
1220  return AVERROR(ENOMEM);
1221 
1222  (*queue)->command = av_strdup(command);
1223  (*queue)->arg = av_strdup(arg);
1224  (*queue)->time = ts;
1225  (*queue)->flags = flags;
1226  (*queue)->next = next;
1228  return 0;
1229  }
1230  }
1231 
1232  return 0;
1233 }
1234 
1236  AVFilterLink *link, int index)
1237 {
1238  AVFilterLink **links = graph->sink_links;
1239 
1240  av_assert0(index >= 0);
1241 
1242  while (index) {
1243  int parent = (index - 1) >> 1;
1244  if (links[parent]->current_pts_us >= link->current_pts_us)
1245  break;
1246  links[index] = links[parent];
1247  links[index]->age_index = index;
1248  index = parent;
1249  }
1250  links[index] = link;
1251  link->age_index = index;
1252 }
1253 
1255  AVFilterLink *link, int index)
1256 {
1257  AVFilterLink **links = graph->sink_links;
1258 
1259  av_assert0(index >= 0);
1260 
1261  while (1) {
1262  int child = 2 * index + 1;
1263  if (child >= graph->sink_links_count)
1264  break;
1265  if (child + 1 < graph->sink_links_count &&
1266  links[child + 1]->current_pts_us < links[child]->current_pts_us)
1267  child++;
1268  if (link->current_pts_us < links[child]->current_pts_us)
1269  break;
1270  links[index] = links[child];
1271  links[index]->age_index = index;
1272  index = child;
1273  }
1274  links[index] = link;
1275  link->age_index = index;
1276 }
1277 
1279 {
1280  heap_bubble_up (graph, link, link->age_index);
1281  heap_bubble_down(graph, link, link->age_index);
1282 }
1283 
1285 {
1286  AVFilterLink *oldest = graph->sink_links[0];
1287  int64_t frame_count;
1288  int r;
1289 
1290  while (graph->sink_links_count) {
1291  oldest = graph->sink_links[0];
1292  if (oldest->dst->filter->activate) {
1293  /* For now, buffersink is the only filter implementing activate. */
1296  if (r != AVERROR_EOF)
1297  return r;
1298  } else {
1299  r = ff_request_frame(oldest);
1300  }
1301  if (r != AVERROR_EOF)
1302  break;
1303  av_log(oldest->dst, AV_LOG_DEBUG, "EOF on sink link %s:%s.\n",
1304  oldest->dst->name,
1305  oldest->dstpad->name);
1306  /* EOF: remove the link from the heap */
1307  if (oldest->age_index < --graph->sink_links_count)
1308  heap_bubble_down(graph, graph->sink_links[graph->sink_links_count],
1309  oldest->age_index);
1310  oldest->age_index = -1;
1311  }
1312  if (!graph->sink_links_count)
1313  return AVERROR_EOF;
1314  av_assert1(!oldest->dst->filter->activate);
1315  av_assert1(oldest->age_index >= 0);
1316  frame_count = oldest->frame_count_out;
1317  while (frame_count == oldest->frame_count_out) {
1319  if (r == AVERROR(EAGAIN) &&
1320  !oldest->frame_wanted_out && !oldest->frame_blocked_in &&
1321  !oldest->status_in)
1322  ff_request_frame(oldest);
1323  else if (r < 0)
1324  return r;
1325  }
1326  return 0;
1327 }
1328 
1330 {
1332  unsigned i;
1333 
1334  av_assert0(graph->nb_filters);
1335  filter = graph->filters[0];
1336  for (i = 1; i < graph->nb_filters; i++)
1337  if (graph->filters[i]->ready > filter->ready)
1338  filter = graph->filters[i];
1339  if (!filter->ready)
1340  return AVERROR(EAGAIN);
1341  return ff_filter_activate(filter);
1342 }
formats
formats
Definition: signature.h:48
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:739
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
AVFilterFormatsConfig::samplerates
AVFilterFormats * samplerates
Lists of supported sample rates, only for audio.
Definition: avfilter.h:511
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:46
r
const char * r
Definition: vf_curves.c:116
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_opt_set_defaults
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
Definition: opt.c:1364
AVFilterFormatsConfig::channel_layouts
AVFilterChannelLayouts * channel_layouts
Lists of supported channel layouts, only for audio.
Definition: avfilter.h:516
ch_subst
static const uint64_t ch_subst[][2]
Definition: avfiltergraph.c:842
REDUCE_FORMATS
#define REDUCE_FORMATS(fmt_type, list_type, list, var, nb, add_format)
Definition: avfiltergraph.c:679
av_bprint_init
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
Definition: bprint.c:68
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2660
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:140
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:831
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:343
thread.h
ff_filter_activate
int ff_filter_activate(AVFilterContext *filter)
Definition: avfilter.c:1356
swap_sample_fmts
static void swap_sample_fmts(AVFilterGraph *graph)
Definition: avfiltergraph.c:1023
AVFilterInOut::next
struct AVFilterInOut * next
next input/input in the list, NULL if this is the last
Definition: avfilter.h:1032
pixdesc.h
AVFilterNegotiation::conversion_filter
const char * conversion_filter
Definition: formats.h:418
index
fg index
Definition: ffmpeg_filter.c:167
graph_check_validity
static int graph_check_validity(AVFilterGraph *graph, void *log_ctx)
Check for the validity of graph.
Definition: avfiltergraph.c:209
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:408
AVOption
AVOption.
Definition: opt.h:247
b
#define b
Definition: input.c:40
pick_formats
static int pick_formats(AVFilterGraph *graph)
Definition: avfiltergraph.c:1032
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:420
convert
Definition: convert.py:1
ff_set_common_all_samplerates
int ff_set_common_all_samplerates(AVFilterContext *ctx)
Equivalent to ff_set_common_samplerates(ctx, ff_all_samplerates())
Definition: formats.c:689
pick_format
static int pick_format(AVFilterLink *link, AVFilterLink *ref)
Definition: avfiltergraph.c:603
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
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:1329
AVFilterFormats::formats
int * formats
list of media formats
Definition: formats.h:66
sample_rate
sample_rate
Definition: ffmpeg_filter.c:153
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:662
convert
static void convert(float y, float u, float v, float *b, float *g, float *r)
Definition: exr.c:967
swap_samplerates
static void swap_samplerates(AVFilterGraph *graph)
Definition: avfiltergraph.c:824
FF_LAYOUT2COUNT
#define FF_LAYOUT2COUNT(l)
Decode a channel count encoded as a channel layout.
Definition: formats.h:108
avfilter_graph_free
void avfilter_graph_free(AVFilterGraph **graph)
Free a graph, destroy its links, and set *graph to NULL.
Definition: avfiltergraph.c:121
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:569
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)
Create and add a filter instance into an existing graph.
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
graph
ofilter graph
Definition: ffmpeg_filter.c:171
fail
#define fail()
Definition: checkasm.h:127
avfilter_graph_alloc
AVFilterGraph * avfilter_graph_alloc(void)
Allocate a filter graph.
Definition: avfiltergraph.c:84
reduce_formats
static int reduce_formats(AVFilterGraph *graph)
Definition: avfiltergraph.c:766
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:253
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:1087
OFFSET
#define OFFSET(x)
Definition: avfiltergraph.c:45
avfilter_config_links
int avfilter_config_links(AVFilterContext *filter)
Negotiate the media format, dimensions, etc of all inputs to a filter.
Definition: avfilter.c:290
AV_BPRINT_SIZE_AUTOMATIC
#define AV_BPRINT_SIZE_AUTOMATIC
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
AVFILTER_THREAD_SLICE
#define AVFILTER_THREAD_SLICE
Process multiple parts of the frame concurrently.
Definition: avfilter.h:397
AVFilterNegotiation
Callbacks and properties to describe the steps of a format negotiation.
Definition: formats.h:415
heap_bubble_down
static void heap_bubble_down(AVFilterGraph *graph, AVFilterLink *link, int index)
Definition: avfiltergraph.c:1254
ff_all_formats
AVFilterFormats * ff_all_formats(enum AVMediaType type)
Return a list of all formats supported by FFmpeg for the given media type.
Definition: formats.c:439
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: internal.h:50
AVFilterNegotiation::nb_mergers
unsigned nb_mergers
Definition: formats.h:416
filters
#define filters(fmt, inverse, clip, i, c)
Definition: af_crystalizer.c:221
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:84
reduce_formats_on_filter
static int reduce_formats_on_filter(AVFilterContext *filter)
Definition: avfiltergraph.c:716
avassert.h
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
MERGE
#define MERGE(merger, link)
ff_set_common_formats
int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:699
AV_CH_LOW_FREQUENCY
#define AV_CH_LOW_FREQUENCY
Definition: channel_layout.h:52
ff_add_channel_layout
int ff_add_channel_layout(AVFilterChannelLayouts **l, uint64_t channel_layout)
Definition: formats.c:426
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:89
s
#define s(width, name)
Definition: cbs_vp9.c:257
av_realloc_array
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Definition: mem.c:224
AVFilterChannelLayouts::channel_layouts
uint64_t * channel_layouts
list of channel layouts
Definition: formats.h:86
AVFrame::channels
int channels
number of audio channels, only used for audio.
Definition: frame.h:628
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:552
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
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:112
filtergraph_options
static const AVOption filtergraph_options[]
Definition: avfiltergraph.c:49
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
ctx
AVFormatContext * ctx
Definition: movenc.c:48
CH_DIRECT_PAIR
#define CH_DIRECT_PAIR
Definition: avfiltergraph.c:837
graph_config_pointers
static int graph_config_pointers(AVFilterGraph *graph, void *log_ctx)
Definition: avfiltergraph.c:1115
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:49
f
#define f(width, name)
Definition: cbs_vp9.c:255
AVFilterNegotiation::mergers
const AVFilterFormatsMerger * mergers
Definition: formats.h:417
command
static int command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Definition: vf_drawtext.c:906
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
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:65
AVFilter::activate
int(* activate)(AVFilterContext *ctx)
Filter activation function.
Definition: avfilter.h:386
avfilter_get_by_name
const AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
Definition: allfilters.c:579
opts
AVDictionary * opts
Definition: movenc.c:50
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
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:1156
NULL
#define NULL
Definition: coverity.c:32
ff_filter_get_negotiation
const AVFilterNegotiation * ff_filter_get_negotiation(AVFilterLink *link)
Definition: formats.c:343
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
framequeue.h
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
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:420
AVFilterContext::name
char * name
name of this filter instance
Definition: avfilter.h:407
AVFilterFormats::nb_formats
unsigned nb_formats
number of formats
Definition: formats.h:65
heap_bubble_up
static void heap_bubble_up(AVFilterGraph *graph, AVFilterLink *link, int index)
Definition: avfiltergraph.c:1235
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:285
av_opt_free
void av_opt_free(void *obj)
Free all allocated objects in obj.
Definition: opt.c:1617
avfilter_graph_request_oldest
int avfilter_graph_request_oldest(AVFilterGraph *graph)
Request a frame on the oldest sink link.
Definition: avfiltergraph.c:1284
graph_config_links
static int graph_config_links(AVFilterGraph *graph, void *log_ctx)
Configure all the links of graphctx.
Definition: avfiltergraph.c:247
abs
#define abs(x)
Definition: cuda_runtime.h:35
AVFilterGraph
Definition: avfilter.h:861
AV_CH_FRONT_CENTER
#define AV_CH_FRONT_CENTER
Definition: channel_layout.h:51
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:597
AVFilterFormatsConfig
Lists of formats / etc.
Definition: avfilter.h:501
av_get_channel_layout_nb_channels
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
Definition: channel_layout.c:226
AV_CLASS_CATEGORY_FILTER
@ AV_CLASS_CATEGORY_FILTER
Definition: log.h:36
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:836
CH_BACK_PAIR
#define CH_BACK_PAIR
Definition: avfiltergraph.c:838
AVMediaType
AVMediaType
Definition: avutil.h:199
ff_graph_thread_free
void ff_graph_thread_free(AVFilterGraph *graph)
Definition: avfiltergraph.c:72
ff_default_query_formats
int ff_default_query_formats(AVFilterContext *ctx)
Definition: formats.c:710
AVFilterCommand::next
struct AVFilterCommand * next
Definition: internal.h:39
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:121
AVFrame::sample_rate
int sample_rate
Sample rate of the audio data.
Definition: frame.h:494
bps
unsigned bps
Definition: movenc.c:1597
CH_CENTER_PAIR
#define CH_CENTER_PAIR
Definition: avfiltergraph.c:832
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:59
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:1204
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
format
ofilter format
Definition: ffmpeg_filter.c:172
AVFrame::format
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition: frame.h:404
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:855
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
AVFrame::channel_layout
uint64_t channel_layout
Channel layout of the audio data.
Definition: frame.h:499
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:592
ff_all_channel_layouts
AVFilterChannelLayouts * ff_all_channel_layouts(void)
Construct an empty AVFilterChannelLayouts/AVFilterFormats struct – representing any channel layout (w...
Definition: formats.c:516
internal.h
avfilter_init_str
int avfilter_init_str(AVFilterContext *filter, const char *args)
Initialize a filter with the supplied parameters.
Definition: avfilter.c:938
buffersink.h
filter_link_check_formats
static int filter_link_check_formats(void *log, AVFilterLink *link, AVFilterFormatsConfig *cfg)
Definition: avfiltergraph.c:296
CH_FRONT_PAIR
#define CH_FRONT_PAIR
Definition: avfiltergraph.c:833
swap_sample_fmts_on_filter
static void swap_sample_fmts_on_filter(AVFilterContext *filter)
Definition: avfiltergraph.c:963
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:592
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:841
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
av_get_bytes_per_sample
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
Definition: samplefmt.c:106
internal.h
swap_channel_layouts_on_filter
static void swap_channel_layouts_on_filter(AVFilterContext *filter)
Definition: avfiltergraph.c:866
graph_check_links
static int graph_check_links(AVFilterGraph *graph, void *log_ctx)
Definition: avfiltergraph.c:264
AVFilterCommand
Definition: internal.h:34
av_assert1
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:53
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
AV_CH_BACK_CENTER
#define AV_CH_BACK_CENTER
Definition: channel_layout.h:57
V
#define V
Definition: avfiltergraph.c:47
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:263
filt
static const int8_t filt[NUMTAPS *2]
Definition: af_earwax.c:39
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:56
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:271
ff_graph_thread_init
int ff_graph_thread_init(AVFilterGraph *graph)
Definition: avfiltergraph.c:76
swap_channel_layouts
static void swap_channel_layouts(AVFilterGraph *graph)
Definition: avfiltergraph.c:955
AVFilter
Filter definition.
Definition: avfilter.h:165
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:740
ret
ret
Definition: filter_design.txt:187
AVFilterPad::type
enum AVMediaType type
AVFilterPad type.
Definition: internal.h:61
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
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:71
AVFilterNegotiation::conversion_opts_offset
unsigned conversion_opts_offset
Definition: formats.h:419
CH_SIDE_PAIR
#define CH_SIDE_PAIR
Definition: avfiltergraph.c:836
av_bprintf
void av_bprintf(AVBPrint *buf, const char *fmt,...)
Definition: bprint.c:93
formats_declared
static int formats_declared(AVFilterContext *f)
Definition: avfiltergraph.c:375
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:71
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:2951
channel_layout.h
ff_filter_graph_remove_filter
void ff_filter_graph_remove_filter(AVFilterGraph *graph, AVFilterContext *filter)
Remove a filter from a graph;.
Definition: avfiltergraph.c:103
CH_WIDE_PAIR
#define CH_WIDE_PAIR
Definition: avfiltergraph.c:835
ff_framequeue_global_init
void ff_framequeue_global_init(FFFrameQueueGlobal *fqg)
Init a global structure.
Definition: framequeue.c:30
ff_avfilter_graph_update_heap
void ff_avfilter_graph_update_heap(AVFilterGraph *graph, AVFilterLink *link)
Update the position of a link in the age heap.
Definition: avfiltergraph.c:1278
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
avfilter.h
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:75
ref
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:107
AVFilterContext
An instance of a filter.
Definition: avfilter.h:402
av_strdup
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:279
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AVFilterChannelLayouts::nb_channel_layouts
int nb_channel_layouts
number of channel layouts
Definition: formats.h:87
AVFilterFormatsConfig::formats
AVFilterFormats * formats
List of supported formats (pixel or sample).
Definition: avfilter.h:506
avfilter_free
void avfilter_free(AVFilterContext *filter)
Free a filter context.
Definition: avfilter.c:757
diff
static av_always_inline int diff(const uint32_t a, const uint32_t b)
Definition: vf_palettegen.c:139
A
#define A
Definition: avfiltergraph.c:48
swap_samplerates_on_filter
static void swap_samplerates_on_filter(AVFilterContext *filter)
Definition: avfiltergraph.c:783
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
FF_FILTER_FORMATS_QUERY_FUNC
@ FF_FILTER_FORMATS_QUERY_FUNC
formats.query active.
Definition: internal.h:161
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Definition: opt.h:223
imgutils.h
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
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:1174
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
FF_FIELD_AT
#define FF_FIELD_AT(type, off, obj)
Access a field in a structure by its offset.
Definition: internal.h:105
avstring.h
AVFilterContext::filter
const AVFilter * filter
the AVFilter of which this is an instance
Definition: avfilter.h:405
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:228
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:325
AV_SAMPLE_FMT_S32
@ AV_SAMPLE_FMT_S32
signed 32 bits
Definition: samplefmt.h:62
filtergraph_class
static const AVClass filtergraph_class
Definition: avfiltergraph.c:63
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:233
snprintf
#define snprintf
Definition: snprintf.h:34
AV_SAMPLE_FMT_FLT
@ AV_SAMPLE_FMT_FLT
float
Definition: samplefmt.h:63
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:2580
ff_set_common_channel_layouts
int ff_set_common_channel_layouts(AVFilterContext *ctx, AVFilterChannelLayouts *channel_layouts)
Helpers for query_formats() which set all free audio links to the same list of channel layouts/sample...
Definition: formats.c:658
AVFilterCommand::time
double time
time expressed in seconds
Definition: internal.h:35