FFmpeg
formats.c
Go to the documentation of this file.
1 /*
2  * Filter layer - format negotiation
3  * Copyright (c) 2007 Bobby Bingham
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include "libavutil/avassert.h"
24 #include "libavutil/common.h"
25 #include "libavutil/eval.h"
26 #include "libavutil/pixdesc.h"
27 #include "avfilter.h"
28 #include "internal.h"
29 #include "formats.h"
30 
31 /**
32  * Add all refs from a to ret and destroy a.
33  */
34 #define MERGE_REF(ret, a, fmts, type, fail_statement) \
35 do { \
36  type ***tmp; \
37  int i; \
38  \
39  if (!(tmp = av_realloc_array(ret->refs, ret->refcount + a->refcount, \
40  sizeof(*tmp)))) \
41  { fail_statement } \
42  ret->refs = tmp; \
43  \
44  for (i = 0; i < a->refcount; i ++) { \
45  ret->refs[ret->refcount] = a->refs[i]; \
46  *ret->refs[ret->refcount++] = ret; \
47  } \
48  \
49  av_freep(&a->refs); \
50  av_freep(&a->fmts); \
51  av_freep(&a); \
52 } while (0)
53 
54 /**
55  * Add all formats common to a and b to a, add b's refs to a and destroy b.
56  * If check is set, nothing is modified and it is only checked whether
57  * the formats are compatible.
58  * If empty_allowed is set and one of a,b->nb is zero, the lists are
59  * merged; otherwise, 0 (for nonmergeability) is returned.
60  */
61 #define MERGE_FORMATS(a, b, fmts, nb, type, check, empty_allowed) \
62 do { \
63  int i, j, k = 0, skip = 0; \
64  \
65  if (empty_allowed) { \
66  if (!a->nb || !b->nb) { \
67  if (check) \
68  return 1; \
69  if (!a->nb) \
70  FFSWAP(type *, a, b); \
71  skip = 1; \
72  } \
73  } \
74  if (!skip) { \
75  for (i = 0; i < a->nb; i++) \
76  for (j = 0; j < b->nb; j++) \
77  if (a->fmts[i] == b->fmts[j]) { \
78  if (check) \
79  return 1; \
80  a->fmts[k++] = a->fmts[i]; \
81  break; \
82  } \
83  /* Check that there was at least one common format. \
84  * Notice that both a and b are unchanged if not. */ \
85  if (!k) \
86  return 0; \
87  av_assert2(!check); \
88  a->nb = k; \
89  } \
90  \
91  MERGE_REF(a, b, fmts, type, return AVERROR(ENOMEM);); \
92 } while (0)
93 
95  enum AVMediaType type, int check)
96 {
97  int i, j;
98  int alpha1=0, alpha2=0;
99  int chroma1=0, chroma2=0;
100 
101  av_assert2(check || (a->refcount && b->refcount));
102 
103  if (a == b)
104  return 1;
105 
106  /* Do not lose chroma or alpha in merging.
107  It happens if both lists have formats with chroma (resp. alpha), but
108  the only formats in common do not have it (e.g. YUV+gray vs.
109  RGB+gray): in that case, the merging would select the gray format,
110  possibly causing a lossy conversion elsewhere in the graph.
111  To avoid that, pretend that there are no common formats to force the
112  insertion of a conversion filter. */
113  if (type == AVMEDIA_TYPE_VIDEO)
114  for (i = 0; i < a->nb_formats; i++) {
115  const AVPixFmtDescriptor *const adesc = av_pix_fmt_desc_get(a->formats[i]);
116  for (j = 0; j < b->nb_formats; j++) {
117  const AVPixFmtDescriptor *bdesc = av_pix_fmt_desc_get(b->formats[j]);
118  alpha2 |= adesc->flags & bdesc->flags & AV_PIX_FMT_FLAG_ALPHA;
119  chroma2|= adesc->nb_components > 1 && bdesc->nb_components > 1;
120  if (a->formats[i] == b->formats[j]) {
121  alpha1 |= adesc->flags & AV_PIX_FMT_FLAG_ALPHA;
122  chroma1|= adesc->nb_components > 1;
123  }
124  }
125  }
126 
127  // If chroma or alpha can be lost through merging then do not merge
128  if (alpha2 > alpha1 || chroma2 > chroma1)
129  return 0;
130 
131  MERGE_FORMATS(a, b, formats, nb_formats, AVFilterFormats, check, 0);
132 
133  return 1;
134 }
135 
136 
137 /**
138  * Check the formats lists for compatibility for merging without actually
139  * merging.
140  *
141  * @return 1 if they are compatible, 0 if not.
142  */
143 static int can_merge_pix_fmts(const void *a, const void *b)
144 {
147 }
148 
149 /**
150  * Merge the formats lists if they are compatible and update all the
151  * references of a and b to point to the combined list and free the old
152  * lists as needed. The combined list usually contains the intersection of
153  * the lists of a and b.
154  *
155  * Both a and b must have owners (i.e. refcount > 0) for these functions.
156  *
157  * @return 1 if merging succeeded, 0 if a and b are incompatible
158  * and negative AVERROR code on failure.
159  * a and b are unmodified if 0 is returned.
160  */
161 static int merge_pix_fmts(void *a, void *b)
162 {
164 }
165 
166 /**
167  * See can_merge_pix_fmts().
168  */
169 static int can_merge_sample_fmts(const void *a, const void *b)
170 {
173 }
174 
175 /**
176  * See merge_pix_fmts().
177  */
178 static int merge_sample_fmts(void *a, void *b)
179 {
181 }
182 
184  AVFilterFormats *b, int check)
185 {
186  av_assert2(check || (a->refcount && b->refcount));
187  if (a == b) return 1;
188 
189  MERGE_FORMATS(a, b, formats, nb_formats, AVFilterFormats, check, 1);
190  return 1;
191 }
192 
193 /**
194  * See can_merge_pix_fmts().
195  */
196 static int can_merge_samplerates(const void *a, const void *b)
197 {
199 }
200 
201 /**
202  * See merge_pix_fmts().
203  */
204 static int merge_samplerates(void *a, void *b)
205 {
206  return merge_samplerates_internal(a, b, 0);
207 }
208 
209 /**
210  * See merge_pix_fmts().
211  */
212 static int merge_channel_layouts(void *va, void *vb)
213 {
217  unsigned a_all = a->all_layouts + a->all_counts;
218  unsigned b_all = b->all_layouts + b->all_counts;
219  int ret_max, ret_nb = 0, i, j, round;
220 
221  av_assert2(a->refcount && b->refcount);
222 
223  if (a == b) return 1;
224 
225  /* Put the most generic set in a, to avoid doing everything twice */
226  if (a_all < b_all) {
228  FFSWAP(unsigned, a_all, b_all);
229  }
230  if (a_all) {
231  if (a_all == 1 && !b_all) {
232  /* keep only known layouts in b; works also for b_all = 1 */
233  for (i = j = 0; i < b->nb_channel_layouts; i++)
234  if (KNOWN(&b->channel_layouts[i]) && i != j++)
235  av_channel_layout_copy(&b->channel_layouts[j], &b->channel_layouts[i]);
236  /* Not optimal: the unknown layouts of b may become known after
237  another merge. */
238  if (!j)
239  return 0;
240  b->nb_channel_layouts = j;
241  }
243  return 1;
244  }
245 
246  ret_max = a->nb_channel_layouts + b->nb_channel_layouts;
247  if (!(channel_layouts = av_calloc(ret_max, sizeof(*channel_layouts))))
248  return AVERROR(ENOMEM);
249 
250  /* a[known] intersect b[known] */
251  for (i = 0; i < a->nb_channel_layouts; i++) {
252  if (!KNOWN(&a->channel_layouts[i]))
253  continue;
254  for (j = 0; j < b->nb_channel_layouts; j++) {
255  if (!av_channel_layout_compare(&a->channel_layouts[i], &b->channel_layouts[j])) {
256  av_channel_layout_copy(&channel_layouts[ret_nb++], &a->channel_layouts[i]);
257  av_channel_layout_uninit(&a->channel_layouts[i]);
258  av_channel_layout_uninit(&b->channel_layouts[j]);
259  break;
260  }
261  }
262  }
263  /* 1st round: a[known] intersect b[generic]
264  2nd round: a[generic] intersect b[known] */
265  for (round = 0; round < 2; round++) {
266  for (i = 0; i < a->nb_channel_layouts; i++) {
267  AVChannelLayout *fmt = &a->channel_layouts[i], bfmt = { 0 };
268  if (!av_channel_layout_check(fmt) || !KNOWN(fmt))
269  continue;
270  bfmt = FF_COUNT2LAYOUT(fmt->nb_channels);
271  for (j = 0; j < b->nb_channel_layouts; j++)
272  if (!av_channel_layout_compare(&b->channel_layouts[j], &bfmt))
273  av_channel_layout_copy(&channel_layouts[ret_nb++], fmt);
274  }
275  /* 1st round: swap to prepare 2nd round; 2nd round: put it back */
277  }
278  /* a[generic] intersect b[generic] */
279  for (i = 0; i < a->nb_channel_layouts; i++) {
280  if (KNOWN(&a->channel_layouts[i]))
281  continue;
282  for (j = 0; j < b->nb_channel_layouts; j++)
283  if (!av_channel_layout_compare(&a->channel_layouts[i], &b->channel_layouts[j]))
284  av_channel_layout_copy(&channel_layouts[ret_nb++], &a->channel_layouts[i]);
285  }
286 
287  if (!ret_nb) {
289  return 0;
290  }
291 
292  if (a->refcount > b->refcount)
294 
296  { av_free(channel_layouts); return AVERROR(ENOMEM); });
297  av_freep(&b->channel_layouts);
298  b->channel_layouts = channel_layouts;
299  b->nb_channel_layouts = ret_nb;
300  return 1;
301 }
302 
303 static const AVFilterFormatsMerger mergers_video[] = {
304  {
305  .offset = offsetof(AVFilterFormatsConfig, formats),
306  .merge = merge_pix_fmts,
307  .can_merge = can_merge_pix_fmts,
308  },
309 };
310 
311 static const AVFilterFormatsMerger mergers_audio[] = {
312  {
313  .offset = offsetof(AVFilterFormatsConfig, channel_layouts),
314  .merge = merge_channel_layouts,
315  .can_merge = NULL,
316  },
317  {
318  .offset = offsetof(AVFilterFormatsConfig, samplerates),
319  .merge = merge_samplerates,
320  .can_merge = can_merge_samplerates,
321  },
322  {
323  .offset = offsetof(AVFilterFormatsConfig, formats),
324  .merge = merge_sample_fmts,
325  .can_merge = can_merge_sample_fmts,
326  },
327 };
328 
329 static const AVFilterNegotiation negotiate_video = {
331  .mergers = mergers_video,
332  .conversion_filter = "scale",
333  .conversion_opts_offset = offsetof(AVFilterGraph, scale_sws_opts),
334 };
335 
336 static const AVFilterNegotiation negotiate_audio = {
338  .mergers = mergers_audio,
339  .conversion_filter = "aresample",
340  .conversion_opts_offset = offsetof(AVFilterGraph, aresample_swr_opts),
341 };
342 
344 {
345  switch (link->type) {
346  case AVMEDIA_TYPE_VIDEO: return &negotiate_video;
347  case AVMEDIA_TYPE_AUDIO: return &negotiate_audio;
348  default: return NULL;
349  }
350 }
351 
352 int ff_fmt_is_in(int fmt, const int *fmts)
353 {
354  const int *p;
355 
356  for (p = fmts; *p != -1; p++) {
357  if (fmt == *p)
358  return 1;
359  }
360  return 0;
361 }
362 
363 #define MAKE_FORMAT_LIST(type, field, count_field) \
364  type *formats; \
365  int count = 0; \
366  if (fmts) \
367  for (count = 0; fmts[count] != -1; count++) \
368  ; \
369  formats = av_mallocz(sizeof(*formats)); \
370  if (!formats) \
371  return NULL; \
372  formats->count_field = count; \
373  if (count) { \
374  formats->field = av_malloc_array(count, sizeof(*formats->field)); \
375  if (!formats->field) { \
376  av_freep(&formats); \
377  return NULL; \
378  } \
379  }
380 
381 AVFilterFormats *ff_make_format_list(const int *fmts)
382 {
384  while (count--)
385  formats->formats[count] = fmts[count];
386 
387  return formats;
388 }
389 
391 {
393  int count = 0;
394  if (fmts)
395  for (count = 0; fmts[count].nb_channels; count++)
396  ;
397  ch_layouts = av_mallocz(sizeof(*ch_layouts));
398  if (!ch_layouts)
399  return NULL;
400  ch_layouts->nb_channel_layouts = count;
401  if (count) {
402  ch_layouts->channel_layouts =
403  av_calloc(count, sizeof(*ch_layouts->channel_layouts));
404  if (!ch_layouts->channel_layouts) {
406  return NULL;
407  }
408  for (int i = 0; i < count; i++) {
409  int ret = av_channel_layout_copy(&ch_layouts->channel_layouts[i], &fmts[i]);
410  if (ret < 0)
411  goto fail;
412  }
413  }
414 
415  return ch_layouts;
416 
417 fail:
418  for (int i = 0; i < count; i++)
419  av_channel_layout_uninit(&ch_layouts->channel_layouts[i]);
420  av_free(ch_layouts->channel_layouts);
422 
423  return NULL;
424 }
425 
426 #define ADD_FORMAT(f, fmt, unref_fn, type, list, nb) \
427 do { \
428  type *fmts; \
429  \
430  if (!(*f) && !(*f = av_mallocz(sizeof(**f)))) { \
431  return AVERROR(ENOMEM); \
432  } \
433  \
434  fmts = av_realloc_array((*f)->list, (*f)->nb + 1, \
435  sizeof(*(*f)->list)); \
436  if (!fmts) { \
437  unref_fn(f); \
438  return AVERROR(ENOMEM); \
439  } \
440  \
441  (*f)->list = fmts; \
442  ASSIGN_FMT(f, fmt, list, nb); \
443 } while (0)
444 
445 #define ASSIGN_FMT(f, fmt, list, nb) \
446 do { \
447  (*f)->list[(*f)->nb++] = fmt; \
448 } while (0)
449 
450 int ff_add_format(AVFilterFormats **avff, int64_t fmt)
451 {
452  ADD_FORMAT(avff, fmt, ff_formats_unref, int, formats, nb_formats);
453  return 0;
454 }
455 
456 #undef ASSIGN_FMT
457 #define ASSIGN_FMT(f, fmt, list, nb) \
458 do { \
459  int ret; \
460  memset((*f)->list + (*f)->nb, 0, sizeof(*(*f)->list)); \
461  ret = av_channel_layout_copy(&(*f)->list[(*f)->nb], fmt); \
462  if (ret < 0) \
463  return ret; \
464  (*f)->nb++; \
465 } while (0)
466 
468  const AVChannelLayout *channel_layout)
469 {
470  av_assert1(!(*l && (*l)->all_layouts));
471  ADD_FORMAT(l, channel_layout, ff_channel_layouts_unref, AVChannelLayout, channel_layouts, nb_channel_layouts);
472  return 0;
473 }
474 
476 {
477  int fmts[2] = { fmt, -1 };
478  return ff_make_format_list(fmts);
479 }
480 
482 {
484 
485  if (type == AVMEDIA_TYPE_VIDEO) {
486  return ff_formats_pixdesc_filter(0, 0);
487  } else if (type == AVMEDIA_TYPE_AUDIO) {
488  enum AVSampleFormat fmt = 0;
489  while (av_get_sample_fmt_name(fmt)) {
490  if (ff_add_format(&ret, fmt) < 0)
491  return NULL;
492  fmt++;
493  }
494  }
495 
496  return ret;
497 }
498 
499 AVFilterFormats *ff_formats_pixdesc_filter(unsigned want, unsigned rej)
500 {
501  unsigned nb_formats, fmt, flags;
503 
504  while (1) {
505  nb_formats = 0;
506  for (fmt = 0;; fmt++) {
508  if (!desc)
509  break;
510  flags = desc->flags;
511  if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL) &&
512  !(desc->flags & AV_PIX_FMT_FLAG_PLANAR) &&
513  (desc->log2_chroma_w || desc->log2_chroma_h))
515  if ((flags & (want | rej)) != want)
516  continue;
517  if (formats)
518  formats->formats[nb_formats] = fmt;
519  nb_formats++;
520  }
521  if (formats) {
522  av_assert0(formats->nb_formats == nb_formats);
523  return formats;
524  }
525  formats = av_mallocz(sizeof(*formats));
526  if (!formats)
527  return NULL;
528  formats->nb_formats = nb_formats;
529  if (nb_formats) {
530  formats->formats = av_malloc_array(nb_formats, sizeof(*formats->formats));
531  if (!formats->formats) {
532  av_freep(&formats);
533  return NULL;
534  }
535  }
536  }
537 }
538 
540 {
542  int fmt;
543 
544  for (fmt = 0; av_get_bytes_per_sample(fmt)>0; fmt++)
545  if (av_sample_fmt_is_planar(fmt))
546  if (ff_add_format(&ret, fmt) < 0)
547  return NULL;
548 
549  return ret;
550 }
551 
553 {
554  AVFilterFormats *ret = av_mallocz(sizeof(*ret));
555  return ret;
556 }
557 
559 {
561  if (!ret)
562  return NULL;
563  ret->all_layouts = 1;
564  return ret;
565 }
566 
568 {
570  if (!ret)
571  return NULL;
572  ret->all_layouts = ret->all_counts = 1;
573  return ret;
574 }
575 
576 #define FORMATS_REF(f, ref, unref_fn) \
577  void *tmp; \
578  \
579  if (!f) \
580  return AVERROR(ENOMEM); \
581  \
582  tmp = av_realloc_array(f->refs, sizeof(*f->refs), f->refcount + 1); \
583  if (!tmp) { \
584  unref_fn(&f); \
585  return AVERROR(ENOMEM); \
586  } \
587  f->refs = tmp; \
588  f->refs[f->refcount++] = ref; \
589  *ref = f; \
590  return 0
591 
593 {
595 }
596 
598 {
600 }
601 
602 #define FIND_REF_INDEX(ref, idx) \
603 do { \
604  int i; \
605  for (i = 0; i < (*ref)->refcount; i ++) \
606  if((*ref)->refs[i] == ref) { \
607  idx = i; \
608  break; \
609  } \
610 } while (0)
611 
612 #define FORMATS_UNREF(ref, list) \
613 do { \
614  int idx = -1; \
615  \
616  if (!*ref) \
617  return; \
618  \
619  FIND_REF_INDEX(ref, idx); \
620  \
621  if (idx >= 0) { \
622  memmove((*ref)->refs + idx, (*ref)->refs + idx + 1, \
623  sizeof(*(*ref)->refs) * ((*ref)->refcount - idx - 1)); \
624  --(*ref)->refcount; \
625  } \
626  if (!(*ref)->refcount) { \
627  FREE_LIST(ref, list); \
628  av_free((*ref)->list); \
629  av_free((*ref)->refs); \
630  av_free(*ref); \
631  } \
632  *ref = NULL; \
633 } while (0)
634 
635 #define FREE_LIST(ref, list) do { } while(0)
637 {
639 }
640 
641 #undef FREE_LIST
642 #define FREE_LIST(ref, list) \
643  do { \
644  for (int i = 0; i < (*ref)->nb_channel_layouts; i++) \
645  av_channel_layout_uninit(&(*ref)->list[i]); \
646  } while(0)
647 
649 {
651 }
652 
653 #define FORMATS_CHANGEREF(oldref, newref) \
654 do { \
655  int idx = -1; \
656  \
657  FIND_REF_INDEX(oldref, idx); \
658  \
659  if (idx >= 0) { \
660  (*oldref)->refs[idx] = newref; \
661  *newref = *oldref; \
662  *oldref = NULL; \
663  } \
664 } while (0)
665 
667  AVFilterChannelLayouts **newref)
668 {
669  FORMATS_CHANGEREF(oldref, newref);
670 }
671 
673 {
674  FORMATS_CHANGEREF(oldref, newref);
675 }
676 
677 #define SET_COMMON_FORMATS(ctx, fmts, media_type, ref_fn, unref_fn) \
678  int i; \
679  \
680  if (!fmts) \
681  return AVERROR(ENOMEM); \
682  \
683  for (i = 0; i < ctx->nb_inputs; i++) { \
684  AVFilterLink *const link = ctx->inputs[i]; \
685  if (link && !link->outcfg.fmts && \
686  (media_type == AVMEDIA_TYPE_UNKNOWN || link->type == media_type)) { \
687  int ret = ref_fn(fmts, &ctx->inputs[i]->outcfg.fmts); \
688  if (ret < 0) { \
689  return ret; \
690  } \
691  } \
692  } \
693  for (i = 0; i < ctx->nb_outputs; i++) { \
694  AVFilterLink *const link = ctx->outputs[i]; \
695  if (link && !link->incfg.fmts && \
696  (media_type == AVMEDIA_TYPE_UNKNOWN || link->type == media_type)) { \
697  int ret = ref_fn(fmts, &ctx->outputs[i]->incfg.fmts); \
698  if (ret < 0) { \
699  return ret; \
700  } \
701  } \
702  } \
703  \
704  if (!fmts->refcount) \
705  unref_fn(&fmts); \
706  \
707  return 0;
708 
711 {
714 }
715 
717  const AVChannelLayout *fmts)
718 {
720 }
721 
723 {
725 }
726 
728  AVFilterFormats *samplerates)
729 {
732 }
733 
735  const int *samplerates)
736 {
737  return ff_set_common_samplerates(ctx, ff_make_format_list(samplerates));
738 }
739 
741 {
743 }
744 
745 /**
746  * A helper for query_formats() which sets all links to the same list of
747  * formats. If there are no links hooked to this filter, the list of formats is
748  * freed.
749  */
751 {
754 }
755 
757 {
759 }
760 
762 {
763  const AVFilter *const f = ctx->filter;
765  enum AVMediaType type;
766  int ret;
767 
768  switch (f->formats_state) {
771  formats = ff_make_format_list(f->formats.pixels_list);
772  break;
775  formats = ff_make_format_list(f->formats.samples_list);
776  break;
779  formats = ff_make_formats_list_singleton(f->formats.pix_fmt);
780  break;
783  formats = ff_make_formats_list_singleton(f->formats.sample_fmt);
784  break;
785  default:
786  av_assert2(!"Unreachable");
787  /* Intended fallthrough */
790  type = ctx->nb_inputs ? ctx->inputs [0]->type :
791  ctx->nb_outputs ? ctx->outputs[0]->type : AVMEDIA_TYPE_VIDEO;
793  break;
794  }
795 
797  if (ret < 0)
798  return ret;
799  if (type == AVMEDIA_TYPE_AUDIO) {
801  if (ret < 0)
802  return ret;
804  if (ret < 0)
805  return ret;
806  }
807 
808  return 0;
809 }
810 
811 /* internal functions for parsing audio format arguments */
812 
813 int ff_parse_pixel_format(enum AVPixelFormat *ret, const char *arg, void *log_ctx)
814 {
815  char *tail;
816  int pix_fmt = av_get_pix_fmt(arg);
817  if (pix_fmt == AV_PIX_FMT_NONE) {
818  pix_fmt = strtol(arg, &tail, 0);
819  if (*tail || !av_pix_fmt_desc_get(pix_fmt)) {
820  av_log(log_ctx, AV_LOG_ERROR, "Invalid pixel format '%s'\n", arg);
821  return AVERROR(EINVAL);
822  }
823  }
824  *ret = pix_fmt;
825  return 0;
826 }
827 
828 int ff_parse_sample_rate(int *ret, const char *arg, void *log_ctx)
829 {
830  char *tail;
831  double srate = av_strtod(arg, &tail);
832  if (*tail || srate < 1 || (int)srate != srate || srate > INT_MAX) {
833  av_log(log_ctx, AV_LOG_ERROR, "Invalid sample rate '%s'\n", arg);
834  return AVERROR(EINVAL);
835  }
836  *ret = srate;
837  return 0;
838 }
839 
840 int ff_parse_channel_layout(AVChannelLayout *ret, int *nret, const char *arg,
841  void *log_ctx)
842 {
843  AVChannelLayout chlayout = { 0 };
844  int res;
845 
846  res = av_channel_layout_from_string(&chlayout, arg);
847  if (res < 0) {
848 #if FF_API_OLD_CHANNEL_LAYOUT
849  int64_t mask;
850  int nb_channels;
852  if (av_get_extended_channel_layout(arg, &mask, &nb_channels) < 0) {
853 #endif
854  av_log(log_ctx, AV_LOG_ERROR, "Invalid channel layout '%s'\n", arg);
855  return AVERROR(EINVAL);
856 #if FF_API_OLD_CHANNEL_LAYOUT
857  }
859  av_log(log_ctx, AV_LOG_WARNING, "Channel layout '%s' uses a deprecated syntax.\n",
860  arg);
861  if (mask)
862  av_channel_layout_from_mask(&chlayout, mask);
863  else
864  chlayout = (AVChannelLayout) { .order = AV_CHANNEL_ORDER_UNSPEC, .nb_channels = nb_channels };
865 #endif
866  }
867 
868  if (chlayout.order == AV_CHANNEL_ORDER_UNSPEC && !nret) {
869  av_log(log_ctx, AV_LOG_ERROR, "Unknown channel layout '%s' is not supported.\n", arg);
870  return AVERROR(EINVAL);
871  }
872  *ret = chlayout;
873  if (nret)
874  *nret = chlayout.nb_channels;
875 
876  return 0;
877 }
878 
879 static int check_list(void *log, const char *name, const AVFilterFormats *fmts)
880 {
881  unsigned i, j;
882 
883  if (!fmts)
884  return 0;
885  if (!fmts->nb_formats) {
886  av_log(log, AV_LOG_ERROR, "Empty %s list\n", name);
887  return AVERROR(EINVAL);
888  }
889  for (i = 0; i < fmts->nb_formats; i++) {
890  for (j = i + 1; j < fmts->nb_formats; j++) {
891  if (fmts->formats[i] == fmts->formats[j]) {
892  av_log(log, AV_LOG_ERROR, "Duplicated %s\n", name);
893  return AVERROR(EINVAL);
894  }
895  }
896  }
897  return 0;
898 }
899 
900 int ff_formats_check_pixel_formats(void *log, const AVFilterFormats *fmts)
901 {
902  return check_list(log, "pixel format", fmts);
903 }
904 
905 int ff_formats_check_sample_formats(void *log, const AVFilterFormats *fmts)
906 {
907  return check_list(log, "sample format", fmts);
908 }
909 
910 int ff_formats_check_sample_rates(void *log, const AVFilterFormats *fmts)
911 {
912  if (!fmts || !fmts->nb_formats)
913  return 0;
914  return check_list(log, "sample rate", fmts);
915 }
916 
917 static int layouts_compatible(const AVChannelLayout *a, const AVChannelLayout *b)
918 {
919  return !av_channel_layout_compare(a, b) ||
920  (KNOWN(a) && !KNOWN(b) && a->nb_channels == b->nb_channels) ||
921  (KNOWN(b) && !KNOWN(a) && b->nb_channels == a->nb_channels);
922 }
923 
925 {
926  unsigned i, j;
927 
928  if (!fmts)
929  return 0;
930  if (fmts->all_layouts < fmts->all_counts) {
931  av_log(log, AV_LOG_ERROR, "Inconsistent generic list\n");
932  return AVERROR(EINVAL);
933  }
934  if (!fmts->all_layouts && !fmts->nb_channel_layouts) {
935  av_log(log, AV_LOG_ERROR, "Empty channel layout list\n");
936  return AVERROR(EINVAL);
937  }
938  for (i = 0; i < fmts->nb_channel_layouts; i++) {
939  for (j = i + 1; j < fmts->nb_channel_layouts; j++) {
940  if (layouts_compatible(&fmts->channel_layouts[i], &fmts->channel_layouts[j])) {
941  av_log(log, AV_LOG_ERROR, "Duplicated or redundant channel layout\n");
942  return AVERROR(EINVAL);
943  }
944  }
945  }
946  return 0;
947 }
formats
formats
Definition: signature.h:48
FF_ENABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:82
AVFilterChannelLayouts
A list of supported channel layouts.
Definition: formats.h:85
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
can_merge_sample_fmts
static int can_merge_sample_fmts(const void *a, const void *b)
See can_merge_pix_fmts().
Definition: formats.c:168
merge_formats_internal
static int merge_formats_internal(AVFilterFormats *a, AVFilterFormats *b, enum AVMediaType type, int check)
Definition: formats.c:93
ff_make_format_list
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:380
can_merge_pix_fmts
static int can_merge_pix_fmts(const void *a, const void *b)
Check the formats lists for compatibility for merging without actually merging.
Definition: formats.c:142
merge_channel_layouts
static int merge_channel_layouts(void *va, void *vb)
See merge_pix_fmts().
Definition: formats.c:211
ff_channel_layouts_ref
int ff_channel_layouts_ref(AVFilterChannelLayouts *f, AVFilterChannelLayouts **ref)
Add *ref as a new reference to f.
Definition: formats.c:591
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2888
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:899
ff_set_common_samplerates_from_list
int ff_set_common_samplerates_from_list(AVFilterContext *ctx, const int *samplerates)
Equivalent to ff_set_common_samplerates(ctx, ff_make_format_list(samplerates))
Definition: formats.c:733
ff_all_channel_counts
AVFilterChannelLayouts * ff_all_channel_counts(void)
Construct an AVFilterChannelLayouts coding for any channel layout, with known or unknown disposition.
Definition: formats.c:566
pixdesc.h
b
#define b
Definition: input.c:41
mergers_video
static const AVFilterFormatsMerger mergers_video[]
Definition: formats.c:302
MERGE_FORMATS
#define MERGE_FORMATS(a, b, fmts, nb, type, check, empty_allowed)
Add all formats common to a and b to a, add b's refs to a and destroy b.
Definition: formats.c:61
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:739
AVChannelLayout::order
enum AVChannelOrder order
Channel order used in this layout.
Definition: channel_layout.h:306
AVFilterFormats::formats
int * formats
list of media formats
Definition: formats.h:66
merge_samplerates_internal
static int merge_samplerates_internal(AVFilterFormats *a, AVFilterFormats *b, int check)
Definition: formats.c:182
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:311
FF_FILTER_FORMATS_SAMPLEFMTS_LIST
@ FF_FILTER_FORMATS_SAMPLEFMTS_LIST
formats.samples_list active.
Definition: internal.h:166
ff_make_formats_list_singleton
AVFilterFormats * ff_make_formats_list_singleton(int fmt)
Equivalent to ff_make_format_list({const int[]}{ fmt, -1 })
Definition: formats.c:474
FORMATS_UNREF
#define FORMATS_UNREF(ref, list)
Definition: formats.c:611
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:64
formats.h
layouts_compatible
static int layouts_compatible(const AVChannelLayout *a, const AVChannelLayout *b)
Definition: formats.c:916
SET_COMMON_FORMATS
#define SET_COMMON_FORMATS(ctx, fmts, media_type, ref_fn, unref_fn)
Definition: formats.c:676
fail
#define fail()
Definition: checkasm.h:134
AV_PIX_FMT_FLAG_HWACCEL
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
Definition: pixdesc.h:128
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
AVFilterNegotiation
Callbacks and properties to describe the steps of a format negotiation.
Definition: formats.h:418
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:480
AVFilterNegotiation::nb_mergers
unsigned nb_mergers
Definition: formats.h:419
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
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:749
FF_FILTER_FORMATS_SINGLE_SAMPLEFMT
@ FF_FILTER_FORMATS_SINGLE_SAMPLEFMT
formats.sample_fmt active.
Definition: internal.h:168
check
#define check(x, y, S, v)
Definition: motion_est_template.c:405
mask
static const uint16_t mask[17]
Definition: lzw.c:38
pix_fmt
static enum AVPixelFormat pix_fmt
Definition: demux_decode.c:41
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AV_CHANNEL_ORDER_UNSPEC
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
Definition: channel_layout.h:112
ff_formats_ref
int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
Add *ref as a new reference to formats.
Definition: formats.c:596
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:391
ff_set_common_formats_from_list
int ff_set_common_formats_from_list(AVFilterContext *ctx, const int *fmts)
Equivalent to ff_set_common_formats(ctx, ff_make_format_list(fmts))
Definition: formats.c:755
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:114
AV_PIX_FMT_FLAG_ALPHA
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
Definition: pixdesc.h:147
ctx
AVFormatContext * ctx
Definition: movenc.c:48
ff_set_common_channel_layouts_from_list
int ff_set_common_channel_layouts_from_list(AVFilterContext *ctx, const AVChannelLayout *fmts)
Equivalent to ff_set_common_channel_layouts(ctx, ff_make_channel_layout_list(fmts))
Definition: formats.c:715
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
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
ff_formats_changeref
void ff_formats_changeref(AVFilterFormats **oldref, AVFilterFormats **newref)
Definition: formats.c:671
NULL
#define NULL
Definition: coverity.c:32
ff_filter_get_negotiation
const AVFilterNegotiation * ff_filter_get_negotiation(AVFilterLink *link)
Definition: formats.c:342
MAKE_FORMAT_LIST
#define MAKE_FORMAT_LIST(type, field, count_field)
Definition: formats.c:362
merge_pix_fmts
static int merge_pix_fmts(void *a, void *b)
Merge the formats lists if they are compatible and update all the references of a and b to point to t...
Definition: formats.c:160
AVPixFmtDescriptor::nb_components
uint8_t nb_components
The number of components each pixel has, (1-4)
Definition: pixdesc.h:71
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:449
AVFilterFormats::nb_formats
unsigned nb_formats
number of formats
Definition: formats.h:65
ff_fmt_is_in
int ff_fmt_is_in(int fmt, const int *fmts)
Tell if an integer is contained in the provided -1-terminated list of integers.
Definition: formats.c:351
negotiate_audio
static const AVFilterNegotiation negotiate_audio
Definition: formats.c:335
AVFilterGraph
Definition: avfilter.h:855
merge_samplerates
static int merge_samplerates(void *a, void *b)
See merge_pix_fmts().
Definition: formats.c:203
ff_set_common_all_channel_counts
int ff_set_common_all_channel_counts(AVFilterContext *ctx)
Equivalent to ff_set_common_channel_layouts(ctx, ff_all_channel_counts())
Definition: formats.c:721
ff_add_channel_layout
int ff_add_channel_layout(AVFilterChannelLayouts **l, const AVChannelLayout *channel_layout)
Definition: formats.c:466
AVPixFmtDescriptor::flags
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Definition: pixdesc.h:94
ff_channel_layouts_unref
void ff_channel_layouts_unref(AVFilterChannelLayouts **ref)
Remove a reference to a channel layouts list.
Definition: formats.c:647
AVFilterFormatsConfig
Lists of formats / etc.
Definition: avfilter.h:491
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:904
eval.h
MERGE_REF
#define MERGE_REF(ret, a, fmts, type, fail_statement)
Add all refs from a to ret and destroy a.
Definition: formats.c:34
f
f
Definition: af_crystalizer.c:122
AVMediaType
AVMediaType
Definition: avutil.h:199
FF_PIX_FMT_FLAG_SW_FLAT_SUB
#define FF_PIX_FMT_FLAG_SW_FLAT_SUB
Definition: formats.h:245
ff_default_query_formats
int ff_default_query_formats(AVFilterContext *ctx)
Definition: formats.c:760
AVChannelLayout
An AVChannelLayout holds information about the channel layout of audio data.
Definition: channel_layout.h:301
check_list
static int check_list(void *log, const char *name, const AVFilterFormats *fmts)
Definition: formats.c:878
ff_parse_channel_layout
int ff_parse_channel_layout(AVChannelLayout *ret, int *nret, const char *arg, void *log_ctx)
Parse a channel layout or a corresponding integer representation.
Definition: formats.c:839
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
AVMEDIA_TYPE_UNKNOWN
@ AVMEDIA_TYPE_UNKNOWN
Usually treated as AVMEDIA_TYPE_DATA.
Definition: avutil.h:200
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:923
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
ff_all_channel_layouts
AVFilterChannelLayouts * ff_all_channel_layouts(void)
Construct an empty AVFilterChannelLayouts/AVFilterFormats struct – representing any channel layout (w...
Definition: formats.c:557
ADD_FORMAT
#define ADD_FORMAT(f, fmt, unref_fn, type, list, nb)
Definition: formats.c:425
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:932
internal.h
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:635
av_assert2
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
Definition: avassert.h:64
av_channel_layout_from_string
int av_channel_layout_from_string(AVChannelLayout *channel_layout, const char *str)
Initialize a channel layout from a given string description.
Definition: channel_layout.c:404
ff_formats_pixdesc_filter
AVFilterFormats * ff_formats_pixdesc_filter(unsigned want, unsigned rej)
Construct a formats list containing all pixel formats with certain properties.
Definition: formats.c:498
FORMATS_REF
#define FORMATS_REF(f, ref, unref_fn)
Definition: formats.c:575
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:909
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
round
static av_always_inline av_const double round(double x)
Definition: libm.h:444
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
FF_FILTER_FORMATS_PASSTHROUGH
@ FF_FILTER_FORMATS_PASSTHROUGH
The default value meaning that this filter supports all formats and (for audio) sample rates and chan...
Definition: internal.h:163
av_malloc_array
#define av_malloc_array(a, b)
Definition: tableprint_vlc.h:31
common.h
FORMATS_CHANGEREF
#define FORMATS_CHANGEREF(oldref, newref)
Definition: formats.c:652
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:55
ch_layouts
static const AVChannelLayout ch_layouts[]
Definition: adpcmenc.c:955
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
ff_planar_sample_fmts
AVFilterFormats * ff_planar_sample_fmts(void)
Construct a formats list containing all planar sample formats.
Definition: formats.c:538
mergers_audio
static const AVFilterFormatsMerger mergers_audio[]
Definition: formats.c:310
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:262
AVFilter
Filter definition.
Definition: avfilter.h:161
ret
ret
Definition: filter_design.txt:187
FFSWAP
#define FFSWAP(type, a, b)
Definition: macros.h:52
av_strtod
double av_strtod(const char *numstr, char **tail)
Parse the string in numstr and return its value as a double.
Definition: eval.c:106
av_channel_layout_check
int av_channel_layout_check(const AVChannelLayout *channel_layout)
Check whether a channel layout is valid, i.e.
Definition: channel_layout.c:906
FF_COUNT2LAYOUT
#define FF_COUNT2LAYOUT(c)
Encode a channel count as a channel layout.
Definition: formats.h:102
av_get_pix_fmt
enum AVPixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
Definition: pixdesc.c:2820
ff_all_samplerates
AVFilterFormats * ff_all_samplerates(void)
Definition: formats.c:551
channel_layout.h
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
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:632
ref
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:112
KNOWN
#define KNOWN(l)
Definition: formats.h:111
AV_PIX_FMT_FLAG_PLANAR
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
Definition: pixdesc.h:132
can_merge_samplerates
static int can_merge_samplerates(const void *a, const void *b)
See can_merge_pix_fmts().
Definition: formats.c:195
AVFilterContext
An instance of a filter.
Definition: avfilter.h:392
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:639
FF_DISABLE_DEPRECATION_WARNINGS
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:81
desc
const char * desc
Definition: libsvtav1.c:83
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
FF_FILTER_FORMATS_PIXFMT_LIST
@ FF_FILTER_FORMATS_PIXFMT_LIST
formats.pixels_list active.
Definition: internal.h:165
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
channel_layouts
static const uint16_t channel_layouts[7]
Definition: dca_lbr.c:111
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
negotiate_video
static const AVFilterNegotiation negotiate_video
Definition: formats.c:328
ff_make_channel_layout_list
AVFilterChannelLayouts * ff_make_channel_layout_list(const AVChannelLayout *fmts)
Definition: formats.c:389
FF_FILTER_FORMATS_QUERY_FUNC
@ FF_FILTER_FORMATS_QUERY_FUNC
formats.query active.
Definition: internal.h:164
ff_parse_sample_rate
int ff_parse_sample_rate(int *ret, const char *arg, void *log_ctx)
Parse a sample rate.
Definition: formats.c:827
ff_parse_pixel_format
int ff_parse_pixel_format(enum AVPixelFormat *ret, const char *arg, void *log_ctx)
Parse a pixel format.
Definition: formats.c:812
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
ff_set_common_samplerates
int ff_set_common_samplerates(AVFilterContext *ctx, AVFilterFormats *samplerates)
Definition: formats.c:726
av_get_extended_channel_layout
int av_get_extended_channel_layout(const char *name, uint64_t *channel_layout, int *nb_channels)
Return a channel layout and the number of channels based on the specified name.
Definition: channel_layout.c:255
ff_channel_layouts_changeref
void ff_channel_layouts_changeref(AVFilterChannelLayouts **oldref, AVFilterChannelLayouts **newref)
Definition: formats.c:665
merge_sample_fmts
static int merge_sample_fmts(void *a, void *b)
See merge_pix_fmts().
Definition: formats.c:177
FF_FILTER_FORMATS_SINGLE_PIXFMT
@ FF_FILTER_FORMATS_SINGLE_PIXFMT
formats.pix_fmt active
Definition: internal.h:167
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:708