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  */
214 {
216  unsigned a_all = a->all_layouts + a->all_counts;
217  unsigned b_all = b->all_layouts + b->all_counts;
218  int ret_max, ret_nb = 0, i, j, round;
219 
220  av_assert2(a->refcount && b->refcount);
221 
222  if (a == b) return 1;
223 
224  /* Put the most generic set in a, to avoid doing everything twice */
225  if (a_all < b_all) {
227  FFSWAP(unsigned, a_all, b_all);
228  }
229  if (a_all) {
230  if (a_all == 1 && !b_all) {
231  /* keep only known layouts in b; works also for b_all = 1 */
232  for (i = j = 0; i < b->nb_channel_layouts; i++)
233  if (KNOWN(&b->channel_layouts[i]) && i != j++) {
234  if (check)
235  return 1;
236  av_channel_layout_copy(&b->channel_layouts[j], &b->channel_layouts[i]);
237  }
238  /* Not optimal: the unknown layouts of b may become known after
239  another merge. */
240  if (!j)
241  return 0;
242  b->nb_channel_layouts = j;
243  }
245  return 1;
246  }
247 
248  ret_max = a->nb_channel_layouts + b->nb_channel_layouts;
249  if (!check && !(channel_layouts = av_calloc(ret_max, sizeof(*channel_layouts))))
250  return AVERROR(ENOMEM);
251 
252  /* a[known] intersect b[known] */
253  for (i = 0; i < a->nb_channel_layouts; i++) {
254  if (!KNOWN(&a->channel_layouts[i]))
255  continue;
256  for (j = 0; j < b->nb_channel_layouts; j++) {
257  if (!av_channel_layout_compare(&a->channel_layouts[i], &b->channel_layouts[j])) {
258  if (check)
259  return 1;
260  av_channel_layout_copy(&channel_layouts[ret_nb++], &a->channel_layouts[i]);
261  av_channel_layout_uninit(&a->channel_layouts[i]);
262  av_channel_layout_uninit(&b->channel_layouts[j]);
263  break;
264  }
265  }
266  }
267  /* 1st round: a[known] intersect b[generic]
268  2nd round: a[generic] intersect b[known] */
269  for (round = 0; round < 2; round++) {
270  for (i = 0; i < a->nb_channel_layouts; i++) {
271  AVChannelLayout *fmt = &a->channel_layouts[i], bfmt = { 0 };
272  if (!av_channel_layout_check(fmt) || !KNOWN(fmt))
273  continue;
274  bfmt = FF_COUNT2LAYOUT(fmt->nb_channels);
275  for (j = 0; j < b->nb_channel_layouts; j++)
276  if (!av_channel_layout_compare(&b->channel_layouts[j], &bfmt)) {
277  if (check)
278  return 1;
279  av_channel_layout_copy(&channel_layouts[ret_nb++], fmt);
280  }
281  }
282  /* 1st round: swap to prepare 2nd round; 2nd round: put it back */
284  }
285  /* a[generic] intersect b[generic] */
286  for (i = 0; i < a->nb_channel_layouts; i++) {
287  if (KNOWN(&a->channel_layouts[i]))
288  continue;
289  for (j = 0; j < b->nb_channel_layouts; j++)
290  if (!av_channel_layout_compare(&a->channel_layouts[i], &b->channel_layouts[j])) {
291  if (check)
292  return 1;
293  av_channel_layout_copy(&channel_layouts[ret_nb++], &a->channel_layouts[i]);
294  }
295  }
296 
297  if (!ret_nb) {
299  return 0;
300  }
301 
302  if (a->refcount > b->refcount)
304 
306  { av_free(channel_layouts); return AVERROR(ENOMEM); });
307  av_freep(&b->channel_layouts);
308  b->channel_layouts = channel_layouts;
309  b->nb_channel_layouts = ret_nb;
310  return 1;
311 }
312 
313 static int can_merge_channel_layouts(const void *a, const void *b)
314 {
316  (AVFilterChannelLayouts *)b, 1);
317 }
318 
319 static int merge_channel_layouts(void *a, void *b)
320 {
321  return merge_channel_layouts_internal(a, b, 0);
322 }
323 
324 static const AVFilterFormatsMerger mergers_video[] = {
325  {
326  .offset = offsetof(AVFilterFormatsConfig, formats),
327  .merge = merge_pix_fmts,
328  .can_merge = can_merge_pix_fmts,
329  },
330 };
331 
332 static const AVFilterFormatsMerger mergers_audio[] = {
333  {
334  .offset = offsetof(AVFilterFormatsConfig, channel_layouts),
335  .merge = merge_channel_layouts,
336  .can_merge = can_merge_channel_layouts,
337  },
338  {
339  .offset = offsetof(AVFilterFormatsConfig, samplerates),
340  .merge = merge_samplerates,
341  .can_merge = can_merge_samplerates,
342  },
343  {
344  .offset = offsetof(AVFilterFormatsConfig, formats),
345  .merge = merge_sample_fmts,
346  .can_merge = can_merge_sample_fmts,
347  },
348 };
349 
350 static const AVFilterNegotiation negotiate_video = {
352  .mergers = mergers_video,
353  .conversion_filter = "scale",
354  .conversion_opts_offset = offsetof(AVFilterGraph, scale_sws_opts),
355 };
356 
357 static const AVFilterNegotiation negotiate_audio = {
359  .mergers = mergers_audio,
360  .conversion_filter = "aresample",
361  .conversion_opts_offset = offsetof(AVFilterGraph, aresample_swr_opts),
362 };
363 
365 {
366  switch (link->type) {
367  case AVMEDIA_TYPE_VIDEO: return &negotiate_video;
368  case AVMEDIA_TYPE_AUDIO: return &negotiate_audio;
369  default: return NULL;
370  }
371 }
372 
373 int ff_fmt_is_in(int fmt, const int *fmts)
374 {
375  const int *p;
376 
377  for (p = fmts; *p != -1; p++) {
378  if (fmt == *p)
379  return 1;
380  }
381  return 0;
382 }
383 
384 #define MAKE_FORMAT_LIST(type, field, count_field) \
385  type *formats; \
386  int count = 0; \
387  if (fmts) \
388  for (count = 0; fmts[count] != -1; count++) \
389  ; \
390  formats = av_mallocz(sizeof(*formats)); \
391  if (!formats) \
392  return NULL; \
393  formats->count_field = count; \
394  if (count) { \
395  formats->field = av_malloc_array(count, sizeof(*formats->field)); \
396  if (!formats->field) { \
397  av_freep(&formats); \
398  return NULL; \
399  } \
400  }
401 
402 AVFilterFormats *ff_make_format_list(const int *fmts)
403 {
405  while (count--)
406  formats->formats[count] = fmts[count];
407 
408  return formats;
409 }
410 
412 {
414  int count = 0;
415  if (fmts)
416  for (count = 0; fmts[count].nb_channels; count++)
417  ;
418  ch_layouts = av_mallocz(sizeof(*ch_layouts));
419  if (!ch_layouts)
420  return NULL;
421  ch_layouts->nb_channel_layouts = count;
422  if (count) {
423  ch_layouts->channel_layouts =
424  av_calloc(count, sizeof(*ch_layouts->channel_layouts));
425  if (!ch_layouts->channel_layouts) {
427  return NULL;
428  }
429  for (int i = 0; i < count; i++) {
430  int ret = av_channel_layout_copy(&ch_layouts->channel_layouts[i], &fmts[i]);
431  if (ret < 0)
432  goto fail;
433  }
434  }
435 
436  return ch_layouts;
437 
438 fail:
439  for (int i = 0; i < count; i++)
440  av_channel_layout_uninit(&ch_layouts->channel_layouts[i]);
441  av_free(ch_layouts->channel_layouts);
443 
444  return NULL;
445 }
446 
447 #define ADD_FORMAT(f, fmt, unref_fn, type, list, nb) \
448 do { \
449  type *fmts; \
450  \
451  if (!(*f) && !(*f = av_mallocz(sizeof(**f)))) { \
452  return AVERROR(ENOMEM); \
453  } \
454  \
455  fmts = av_realloc_array((*f)->list, (*f)->nb + 1, \
456  sizeof(*(*f)->list)); \
457  if (!fmts) { \
458  unref_fn(f); \
459  return AVERROR(ENOMEM); \
460  } \
461  \
462  (*f)->list = fmts; \
463  ASSIGN_FMT(f, fmt, list, nb); \
464 } while (0)
465 
466 #define ASSIGN_FMT(f, fmt, list, nb) \
467 do { \
468  (*f)->list[(*f)->nb++] = fmt; \
469 } while (0)
470 
471 int ff_add_format(AVFilterFormats **avff, int64_t fmt)
472 {
473  ADD_FORMAT(avff, fmt, ff_formats_unref, int, formats, nb_formats);
474  return 0;
475 }
476 
477 #undef ASSIGN_FMT
478 #define ASSIGN_FMT(f, fmt, list, nb) \
479 do { \
480  int ret; \
481  memset((*f)->list + (*f)->nb, 0, sizeof(*(*f)->list)); \
482  ret = av_channel_layout_copy(&(*f)->list[(*f)->nb], fmt); \
483  if (ret < 0) \
484  return ret; \
485  (*f)->nb++; \
486 } while (0)
487 
489  const AVChannelLayout *channel_layout)
490 {
491  av_assert1(!(*l && (*l)->all_layouts));
492  ADD_FORMAT(l, channel_layout, ff_channel_layouts_unref, AVChannelLayout, channel_layouts, nb_channel_layouts);
493  return 0;
494 }
495 
497 {
498  int fmts[2] = { fmt, -1 };
499  return ff_make_format_list(fmts);
500 }
501 
503 {
505 
506  if (type == AVMEDIA_TYPE_VIDEO) {
507  return ff_formats_pixdesc_filter(0, 0);
508  } else if (type == AVMEDIA_TYPE_AUDIO) {
509  enum AVSampleFormat fmt = 0;
510  while (av_get_sample_fmt_name(fmt)) {
511  if (ff_add_format(&ret, fmt) < 0)
512  return NULL;
513  fmt++;
514  }
515  }
516 
517  return ret;
518 }
519 
520 AVFilterFormats *ff_formats_pixdesc_filter(unsigned want, unsigned rej)
521 {
522  unsigned nb_formats, fmt, flags;
524 
525  while (1) {
526  nb_formats = 0;
527  for (fmt = 0;; fmt++) {
529  if (!desc)
530  break;
531  flags = desc->flags;
532  if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL) &&
533  !(desc->flags & AV_PIX_FMT_FLAG_PLANAR) &&
534  (desc->log2_chroma_w || desc->log2_chroma_h))
536  if ((flags & (want | rej)) != want)
537  continue;
538  if (formats)
539  formats->formats[nb_formats] = fmt;
540  nb_formats++;
541  }
542  if (formats) {
543  av_assert0(formats->nb_formats == nb_formats);
544  return formats;
545  }
546  formats = av_mallocz(sizeof(*formats));
547  if (!formats)
548  return NULL;
549  formats->nb_formats = nb_formats;
550  if (nb_formats) {
551  formats->formats = av_malloc_array(nb_formats, sizeof(*formats->formats));
552  if (!formats->formats) {
553  av_freep(&formats);
554  return NULL;
555  }
556  }
557  }
558 }
559 
561 {
563  int fmt;
564 
565  for (fmt = 0; av_get_bytes_per_sample(fmt)>0; fmt++)
566  if (av_sample_fmt_is_planar(fmt))
567  if (ff_add_format(&ret, fmt) < 0)
568  return NULL;
569 
570  return ret;
571 }
572 
574 {
575  AVFilterFormats *ret = av_mallocz(sizeof(*ret));
576  return ret;
577 }
578 
580 {
582  if (!ret)
583  return NULL;
584  ret->all_layouts = 1;
585  return ret;
586 }
587 
589 {
591  if (!ret)
592  return NULL;
593  ret->all_layouts = ret->all_counts = 1;
594  return ret;
595 }
596 
597 #define FORMATS_REF(f, ref, unref_fn) \
598  void *tmp; \
599  \
600  if (!f) \
601  return AVERROR(ENOMEM); \
602  \
603  tmp = av_realloc_array(f->refs, sizeof(*f->refs), f->refcount + 1); \
604  if (!tmp) { \
605  unref_fn(&f); \
606  return AVERROR(ENOMEM); \
607  } \
608  f->refs = tmp; \
609  f->refs[f->refcount++] = ref; \
610  *ref = f; \
611  return 0
612 
614 {
616 }
617 
619 {
621 }
622 
623 #define FIND_REF_INDEX(ref, idx) \
624 do { \
625  int i; \
626  for (i = 0; i < (*ref)->refcount; i ++) \
627  if((*ref)->refs[i] == ref) { \
628  idx = i; \
629  break; \
630  } \
631 } while (0)
632 
633 #define FORMATS_UNREF(ref, list) \
634 do { \
635  int idx = -1; \
636  \
637  if (!*ref) \
638  return; \
639  \
640  FIND_REF_INDEX(ref, idx); \
641  \
642  if (idx >= 0) { \
643  memmove((*ref)->refs + idx, (*ref)->refs + idx + 1, \
644  sizeof(*(*ref)->refs) * ((*ref)->refcount - idx - 1)); \
645  --(*ref)->refcount; \
646  } \
647  if (!(*ref)->refcount) { \
648  FREE_LIST(ref, list); \
649  av_free((*ref)->list); \
650  av_free((*ref)->refs); \
651  av_free(*ref); \
652  } \
653  *ref = NULL; \
654 } while (0)
655 
656 #define FREE_LIST(ref, list) do { } while(0)
658 {
660 }
661 
662 #undef FREE_LIST
663 #define FREE_LIST(ref, list) \
664  do { \
665  for (int i = 0; i < (*ref)->nb_channel_layouts; i++) \
666  av_channel_layout_uninit(&(*ref)->list[i]); \
667  } while(0)
668 
670 {
672 }
673 
674 #define FORMATS_CHANGEREF(oldref, newref) \
675 do { \
676  int idx = -1; \
677  \
678  FIND_REF_INDEX(oldref, idx); \
679  \
680  if (idx >= 0) { \
681  (*oldref)->refs[idx] = newref; \
682  *newref = *oldref; \
683  *oldref = NULL; \
684  } \
685 } while (0)
686 
688  AVFilterChannelLayouts **newref)
689 {
690  FORMATS_CHANGEREF(oldref, newref);
691 }
692 
694 {
695  FORMATS_CHANGEREF(oldref, newref);
696 }
697 
698 #define SET_COMMON_FORMATS(ctx, fmts, media_type, ref_fn, unref_fn) \
699  int i; \
700  \
701  if (!fmts) \
702  return AVERROR(ENOMEM); \
703  \
704  for (i = 0; i < ctx->nb_inputs; i++) { \
705  AVFilterLink *const link = ctx->inputs[i]; \
706  if (link && !link->outcfg.fmts && \
707  (media_type == AVMEDIA_TYPE_UNKNOWN || link->type == media_type)) { \
708  int ret = ref_fn(fmts, &ctx->inputs[i]->outcfg.fmts); \
709  if (ret < 0) { \
710  return ret; \
711  } \
712  } \
713  } \
714  for (i = 0; i < ctx->nb_outputs; i++) { \
715  AVFilterLink *const link = ctx->outputs[i]; \
716  if (link && !link->incfg.fmts && \
717  (media_type == AVMEDIA_TYPE_UNKNOWN || link->type == media_type)) { \
718  int ret = ref_fn(fmts, &ctx->outputs[i]->incfg.fmts); \
719  if (ret < 0) { \
720  return ret; \
721  } \
722  } \
723  } \
724  \
725  if (!fmts->refcount) \
726  unref_fn(&fmts); \
727  \
728  return 0;
729 
732 {
735 }
736 
738  const AVChannelLayout *fmts)
739 {
741 }
742 
744 {
746 }
747 
749  AVFilterFormats *samplerates)
750 {
753 }
754 
756  const int *samplerates)
757 {
758  return ff_set_common_samplerates(ctx, ff_make_format_list(samplerates));
759 }
760 
762 {
764 }
765 
766 /**
767  * A helper for query_formats() which sets all links to the same list of
768  * formats. If there are no links hooked to this filter, the list of formats is
769  * freed.
770  */
772 {
775 }
776 
778 {
780 }
781 
783 {
784  const AVFilter *const f = ctx->filter;
786  enum AVMediaType type;
787  int ret;
788 
789  switch (f->formats_state) {
792  formats = ff_make_format_list(f->formats.pixels_list);
793  break;
796  formats = ff_make_format_list(f->formats.samples_list);
797  break;
800  formats = ff_make_formats_list_singleton(f->formats.pix_fmt);
801  break;
804  formats = ff_make_formats_list_singleton(f->formats.sample_fmt);
805  break;
806  default:
807  av_assert2(!"Unreachable");
808  /* Intended fallthrough */
811  type = ctx->nb_inputs ? ctx->inputs [0]->type :
812  ctx->nb_outputs ? ctx->outputs[0]->type : AVMEDIA_TYPE_VIDEO;
814  break;
815  }
816 
818  if (ret < 0)
819  return ret;
820  if (type == AVMEDIA_TYPE_AUDIO) {
822  if (ret < 0)
823  return ret;
825  if (ret < 0)
826  return ret;
827  }
828 
829  return 0;
830 }
831 
832 /* internal functions for parsing audio format arguments */
833 
834 int ff_parse_pixel_format(enum AVPixelFormat *ret, const char *arg, void *log_ctx)
835 {
836  char *tail;
837  int pix_fmt = av_get_pix_fmt(arg);
838  if (pix_fmt == AV_PIX_FMT_NONE) {
839  pix_fmt = strtol(arg, &tail, 0);
840  if (*tail || !av_pix_fmt_desc_get(pix_fmt)) {
841  av_log(log_ctx, AV_LOG_ERROR, "Invalid pixel format '%s'\n", arg);
842  return AVERROR(EINVAL);
843  }
844  }
845  *ret = pix_fmt;
846  return 0;
847 }
848 
849 int ff_parse_sample_rate(int *ret, const char *arg, void *log_ctx)
850 {
851  char *tail;
852  double srate = av_strtod(arg, &tail);
853  if (*tail || srate < 1 || (int)srate != srate || srate > INT_MAX) {
854  av_log(log_ctx, AV_LOG_ERROR, "Invalid sample rate '%s'\n", arg);
855  return AVERROR(EINVAL);
856  }
857  *ret = srate;
858  return 0;
859 }
860 
861 int ff_parse_channel_layout(AVChannelLayout *ret, int *nret, const char *arg,
862  void *log_ctx)
863 {
864  AVChannelLayout chlayout = { 0 };
865  int res;
866 
867  res = av_channel_layout_from_string(&chlayout, arg);
868  if (res < 0) {
869 #if FF_API_OLD_CHANNEL_LAYOUT
870  int64_t mask;
871  int nb_channels;
873  if (av_get_extended_channel_layout(arg, &mask, &nb_channels) < 0) {
874 #endif
875  av_log(log_ctx, AV_LOG_ERROR, "Invalid channel layout '%s'\n", arg);
876  return AVERROR(EINVAL);
877 #if FF_API_OLD_CHANNEL_LAYOUT
878  }
880  av_log(log_ctx, AV_LOG_WARNING, "Channel layout '%s' uses a deprecated syntax.\n",
881  arg);
882  if (mask)
883  av_channel_layout_from_mask(&chlayout, mask);
884  else
885  chlayout = (AVChannelLayout) { .order = AV_CHANNEL_ORDER_UNSPEC, .nb_channels = nb_channels };
886 #endif
887  }
888 
889  if (chlayout.order == AV_CHANNEL_ORDER_UNSPEC && !nret) {
890  av_log(log_ctx, AV_LOG_ERROR, "Unknown channel layout '%s' is not supported.\n", arg);
891  return AVERROR(EINVAL);
892  }
893  *ret = chlayout;
894  if (nret)
895  *nret = chlayout.nb_channels;
896 
897  return 0;
898 }
899 
900 static int check_list(void *log, const char *name, const AVFilterFormats *fmts)
901 {
902  unsigned i, j;
903 
904  if (!fmts)
905  return 0;
906  if (!fmts->nb_formats) {
907  av_log(log, AV_LOG_ERROR, "Empty %s list\n", name);
908  return AVERROR(EINVAL);
909  }
910  for (i = 0; i < fmts->nb_formats; i++) {
911  for (j = i + 1; j < fmts->nb_formats; j++) {
912  if (fmts->formats[i] == fmts->formats[j]) {
913  av_log(log, AV_LOG_ERROR, "Duplicated %s\n", name);
914  return AVERROR(EINVAL);
915  }
916  }
917  }
918  return 0;
919 }
920 
921 int ff_formats_check_pixel_formats(void *log, const AVFilterFormats *fmts)
922 {
923  return check_list(log, "pixel format", fmts);
924 }
925 
927 {
928  return check_list(log, "sample format", fmts);
929 }
930 
931 int ff_formats_check_sample_rates(void *log, const AVFilterFormats *fmts)
932 {
933  if (!fmts || !fmts->nb_formats)
934  return 0;
935  return check_list(log, "sample rate", fmts);
936 }
937 
938 static int layouts_compatible(const AVChannelLayout *a, const AVChannelLayout *b)
939 {
940  return !av_channel_layout_compare(a, b) ||
941  (KNOWN(a) && !KNOWN(b) && a->nb_channels == b->nb_channels) ||
942  (KNOWN(b) && !KNOWN(a) && b->nb_channels == a->nb_channels);
943 }
944 
946 {
947  unsigned i, j;
948 
949  if (!fmts)
950  return 0;
951  if (fmts->all_layouts < fmts->all_counts) {
952  av_log(log, AV_LOG_ERROR, "Inconsistent generic list\n");
953  return AVERROR(EINVAL);
954  }
955  if (!fmts->all_layouts && !fmts->nb_channel_layouts) {
956  av_log(log, AV_LOG_ERROR, "Empty channel layout list\n");
957  return AVERROR(EINVAL);
958  }
959  for (i = 0; i < fmts->nb_channel_layouts; i++) {
960  for (j = i + 1; j < fmts->nb_channel_layouts; j++) {
961  if (layouts_compatible(&fmts->channel_layouts[i], &fmts->channel_layouts[j])) {
962  av_log(log, AV_LOG_ERROR, "Duplicated or redundant channel layout\n");
963  return AVERROR(EINVAL);
964  }
965  }
966  }
967  return 0;
968 }
formats
formats
Definition: signature.h:48
FF_ENABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:73
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:401
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
ff_channel_layouts_ref
int ff_channel_layouts_ref(AVFilterChannelLayouts *f, AVFilterChannelLayouts **ref)
Add *ref as a new reference to f.
Definition: formats.c:612
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2964
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
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:754
normalize.log
log
Definition: normalize.py:21
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:587
can_merge_channel_layouts
static int can_merge_channel_layouts(const void *a, const void *b)
Definition: formats.c:312
pixdesc.h
b
#define b
Definition: input.c:41
mergers_video
static const AVFilterFormatsMerger mergers_video[]
Definition: formats.c:323
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:760
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:164
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:495
FORMATS_UNREF
#define FORMATS_UNREF(ref, list)
Definition: formats.c:632
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:937
SET_COMMON_FORMATS
#define SET_COMMON_FORMATS(ctx, fmts, media_type, ref_fn, unref_fn)
Definition: formats.c:697
fail
#define fail()
Definition: checkasm.h:138
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:501
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:770
FF_FILTER_FORMATS_SINGLE_SAMPLEFMT
@ FF_FILTER_FORMATS_SINGLE_SAMPLEFMT
formats.sample_fmt active.
Definition: internal.h:166
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:617
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:395
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:776
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
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:736
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:692
NULL
#define NULL
Definition: coverity.c:32
ff_filter_get_negotiation
const AVFilterNegotiation * ff_filter_get_negotiation(AVFilterLink *link)
Definition: formats.c:363
MAKE_FORMAT_LIST
#define MAKE_FORMAT_LIST(type, field, count_field)
Definition: formats.c:383
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:470
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:372
negotiate_audio
static const AVFilterNegotiation negotiate_audio
Definition: formats.c:356
AVFilterGraph
Definition: avfilter.h:864
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:742
ff_add_channel_layout
int ff_add_channel_layout(AVFilterChannelLayouts **l, const AVChannelLayout *channel_layout)
Definition: formats.c:487
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:668
AVFilterFormatsConfig
Lists of formats / etc.
Definition: avfilter.h:500
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
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:121
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:781
AVChannelLayout
An AVChannelLayout holds information about the channel layout of audio data.
Definition: channel_layout.h:301
merge_channel_layouts_internal
static int merge_channel_layouts_internal(AVFilterChannelLayouts *a, AVFilterChannelLayouts *b, int check)
See merge_pix_fmts().
Definition: formats.c:211
check_list
static int check_list(void *log, const char *name, const AVFilterFormats *fmts)
Definition: formats.c:899
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:860
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:944
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:578
ADD_FORMAT
#define ADD_FORMAT(f, fmt, unref_fn, type, list, nb)
Definition: formats.c:446
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:938
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:656
av_assert2
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
Definition: avassert.h:67
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:408
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:519
FORMATS_REF
#define FORMATS_REF(f, ref, unref_fn)
Definition: formats.c:596
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:244
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:161
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:673
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
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:559
mergers_audio
static const AVFilterFormatsMerger mergers_audio[]
Definition: formats.c:331
merge_channel_layouts
static int merge_channel_layouts(void *a, void *b)
Definition: formats.c:318
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:262
AVFilter
Filter definition.
Definition: avfilter.h:166
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:912
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:2896
ff_all_samplerates
AVFilterFormats * ff_all_samplerates(void)
Definition: formats.c:572
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:636
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: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:643
FF_DISABLE_DEPRECATION_WARNINGS
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:72
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:163
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:349
ff_make_channel_layout_list
AVFilterChannelLayouts * ff_make_channel_layout_list(const AVChannelLayout *fmts)
Definition: formats.c:410
FF_FILTER_FORMATS_QUERY_FUNC
@ FF_FILTER_FORMATS_QUERY_FUNC
formats.query active.
Definition: internal.h:162
ff_parse_sample_rate
int ff_parse_sample_rate(int *ret, const char *arg, void *log_ctx)
Parse a sample rate.
Definition: formats.c:848
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:833
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:467
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:747
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:259
ff_channel_layouts_changeref
void ff_channel_layouts_changeref(AVFilterChannelLayouts **oldref, AVFilterChannelLayouts **newref)
Definition: formats.c:686
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:165
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