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