FFmpeg
mov_chan.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011 Justin Ruggles
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /**
22  * mov 'chan' tag reading/writing.
23  * @author Justin Ruggles
24  */
25 
26 #include <assert.h>
27 #include <stdint.h>
28 
29 #include "libavutil/avassert.h"
31 #include "libavutil/mem.h"
32 #include "libavcodec/codec_id.h"
33 #include "mov_chan.h"
34 
35 enum {
52  // = AV_CHAN_TOP_BACK_CENTER,
61  // = AV_CHAN_TOP_SIDE_LEFT,
62  // = AV_CHAN_TOP_SIDE_RIGHT,
63  // = AV_CHAN_BOTTOM_FRONT_CENTER,
64  // = AV_CHAN_BOTTOM_FRONT_LEFT,
65  // = AV_CHAN_BOTTOM_FRONT_RIGHT,
70  /* The following have no exact counterparts */
76 };
77 
78 enum {
97  // = AV_CHAN_STEREO_LEFT,
98  // = AV_CHAN_STEREO_RIGHT,
111  /* The following have no exact counterparts */
114 };
115 
117  union {
118  uint32_t tag;
119  enum AVChannel id;
120  };
121 };
122 
123 #define TAG(_tag, _cnt) {.tag = _tag}
124 #define ID(_0) {.id = c_##_0}
125 #define CHLIST01(_tag, _1) CHLIST(_tag, 1, ID(_1))
126 #define CHLIST02(_tag, _1, _2) CHLIST(_tag, 2, ID(_1), ID(_2))
127 #define CHLIST03(_tag, _1, _2, _3) CHLIST(_tag, 3, ID(_1), ID(_2), ID(_3))
128 #define CHLIST04(_tag, _1, _2, _3, _4) CHLIST(_tag, 4, ID(_1), ID(_2), ID(_3), ID(_4))
129 #define CHLIST05(_tag, _1, _2, _3, _4, _5) CHLIST(_tag, 5, ID(_1), ID(_2), ID(_3), ID(_4), ID(_5))
130 #define CHLIST06(_tag, _1, _2, _3, _4, _5, _6) CHLIST(_tag, 6, ID(_1), ID(_2), ID(_3), ID(_4), ID(_5), ID(_6))
131 #define CHLIST07(_tag, _1, _2, _3, _4, _5, _6, _7) CHLIST(_tag, 7, ID(_1), ID(_2), ID(_3), ID(_4), ID(_5), ID(_6), ID(_7))
132 #define CHLIST08(_tag, _1, _2, _3, _4, _5, _6, _7, _8) CHLIST(_tag, 8, ID(_1), ID(_2), ID(_3), ID(_4), ID(_5), ID(_6), ID(_7), ID(_8))
133 #define CHLIST09(_tag, _1, _2, _3, _4, _5, _6, _7, _8, _9) CHLIST(_tag, 9, ID(_1), ID(_2), ID(_3), ID(_4), ID(_5), ID(_6), ID(_7), ID(_8), ID(_9))
134 #define CHLIST16(_tag, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16) \
135  CHLIST(_tag, 16, ID(_1), ID(_2), ID(_3), ID(_4), ID(_5), ID(_6), ID(_7), ID(_8), ID(_9), ID(_10), \
136  ID(_11), ID(_12), ID(_13), ID(_14), ID(_15), ID(_16))
137 #define CHLIST21(_tag, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21) \
138  CHLIST(_tag, 21, ID(_1), ID(_2), ID(_3), ID(_4), ID(_5), ID(_6), ID(_7), ID(_8), ID(_9), ID(_10), \
139  ID(_11), ID(_12), ID(_13), ID(_14), ID(_15), ID(_16), ID(_17), ID(_18), ID(_19), ID(_20), ID(_21))
140 #define CHLIST24(_tag, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24) \
141  CHLIST(_tag, 24, ID(_1), ID(_2), ID(_3), ID(_4), ID(_5), ID(_6), ID(_7), ID(_8), ID(_9), ID(_10), \
142  ID(_11), ID(_12), ID(_13), ID(_14), ID(_15), ID(_16), ID(_17), ID(_18), ID(_19), ID(_20), \
143  ID(_21), ID(_22), ID(_23), ID(_24))
144 
145 #define MOV_CH_LAYOUT_MAP \
146  CHLIST01( MOV_CH_LAYOUT_MONO, C )\
147  CHLIST02( MOV_CH_LAYOUT_STEREO, L, R )\
148  CHLIST02( MOV_CH_LAYOUT_STEREOHEADPHONES, L, R )\
149  CHLIST02( MOV_CH_LAYOUT_BINAURAL, L, R )\
150  CHLIST02( MOV_CH_LAYOUT_MIDSIDE, L, R )\
151  CHLIST02( MOV_CH_LAYOUT_XY, L, R )\
152  CHLIST02( MOV_CH_LAYOUT_MATRIXSTEREO, Lt, Rt )\
153  CHLIST02( MOV_CH_LAYOUT_AC3_1_0_1, C, LFE )\
154  CHLIST03( MOV_CH_LAYOUT_MPEG_3_0_A, L, R, C )\
155  CHLIST03( MOV_CH_LAYOUT_MPEG_3_0_B, C, L, R )\
156  CHLIST03( MOV_CH_LAYOUT_AC3_3_0, L, C, R )\
157  CHLIST03( MOV_CH_LAYOUT_ITU_2_1, L, R, Cs )\
158  CHLIST03( MOV_CH_LAYOUT_DVD_4, L, R, LFE )\
159  CHLIST04( MOV_CH_LAYOUT_AMBISONIC_B_FORMAT, W, X, Y, Z )\
160  CHLIST04( MOV_CH_LAYOUT_QUADRAPHONIC, L, R, Rls, Rrs )\
161  CHLIST04( MOV_CH_LAYOUT_MPEG_4_0_A, L, R, C, Cs )\
162  CHLIST04( MOV_CH_LAYOUT_MPEG_4_0_B, C, L, R, Cs )\
163  CHLIST04( MOV_CH_LAYOUT_AC3_3_1, L, C, R, Cs )\
164  CHLIST04( MOV_CH_LAYOUT_ITU_2_2, L, R, Ls, Rs )\
165  CHLIST04( MOV_CH_LAYOUT_DVD_5, L, R, LFE, Cs )\
166  CHLIST04( MOV_CH_LAYOUT_AC3_2_1_1, L, R, Cs, LFE )\
167  CHLIST04( MOV_CH_LAYOUT_DVD_10, L, R, C, LFE )\
168  CHLIST04( MOV_CH_LAYOUT_AC3_3_0_1, L, C, R, LFE )\
169  CHLIST04( MOV_CH_LAYOUT_DTS_3_1, C, L, R, LFE )\
170  CHLIST05( MOV_CH_LAYOUT_PENTAGONAL, L, R, Rls, Rrs, C )\
171  CHLIST05( MOV_CH_LAYOUT_MPEG_5_0_A, L, R, C, Ls, Rs )\
172  CHLIST05( MOV_CH_LAYOUT_MPEG_5_0_B, L, R, Ls, Rs, C )\
173  CHLIST05( MOV_CH_LAYOUT_MPEG_5_0_C, L, C, R, Ls, Rs )\
174  CHLIST05( MOV_CH_LAYOUT_MPEG_5_0_D, C, L, R, Ls, Rs )\
175  CHLIST05( MOV_CH_LAYOUT_DVD_6, L, R, LFE, Ls, Rs )\
176  CHLIST05( MOV_CH_LAYOUT_DVD_18, L, R, Ls, Rs, LFE )\
177  CHLIST05( MOV_CH_LAYOUT_DVD_11, L, R, C, LFE, Cs )\
178  CHLIST05( MOV_CH_LAYOUT_AC3_3_1_1, L, C, R, Cs, LFE )\
179  CHLIST05( MOV_CH_LAYOUT_DTS_4_1, C, L, R, Cs, LFE )\
180  CHLIST06( MOV_CH_LAYOUT_HEXAGONAL, L, R, Rls, Rrs, C, Cs )\
181  CHLIST06( MOV_CH_LAYOUT_DTS_6_0_C, C, Cs, L, R, Rls, Rrs )\
182  CHLIST06( MOV_CH_LAYOUT_MPEG_5_1_A, L, R, C, LFE, Ls, Rs )\
183  CHLIST06( MOV_CH_LAYOUT_MPEG_5_1_B, L, R, Ls, Rs, C, LFE )\
184  CHLIST06( MOV_CH_LAYOUT_MPEG_5_1_C, L, C, R, Ls, Rs, LFE )\
185  CHLIST06( MOV_CH_LAYOUT_MPEG_5_1_D, C, L, R, Ls, Rs, LFE )\
186  CHLIST06( MOV_CH_LAYOUT_AUDIOUNIT_6_0, L, R, Ls, Rs, C, Cs )\
187  CHLIST06( MOV_CH_LAYOUT_AAC_6_0, C, L, R, Ls, Rs, Cs )\
188  CHLIST06( MOV_CH_LAYOUT_EAC3_6_0_A, L, C, R, Ls, Rs, Cs )\
189  CHLIST06( MOV_CH_LAYOUT_DTS_6_0_A, Lc, Rc, L, R, Ls, Rs )\
190  CHLIST06( MOV_CH_LAYOUT_DTS_6_0_B, C, L, R, Rls, Rrs, Ts )\
191  CHLIST07( MOV_CH_LAYOUT_MPEG_6_1_A, L, R, C, LFE, Ls, Rs, Cs )\
192  CHLIST07( MOV_CH_LAYOUT_AAC_6_1, C, L, R, Ls, Rs, Cs, LFE )\
193  CHLIST07( MOV_CH_LAYOUT_EAC3_6_1_A, L, C, R, Ls, Rs, LFE, Cs )\
194  CHLIST07( MOV_CH_LAYOUT_DTS_6_1_D, C, L, R, Ls, Rs, LFE, Cs )\
195  CHLIST07( MOV_CH_LAYOUT_AUDIOUNIT_7_0, L, R, Ls, Rs, C, Rls, Rrs )\
196  CHLIST07( MOV_CH_LAYOUT_AAC_7_0, C, L, R, Ls, Rs, Rls, Rrs )\
197  CHLIST07( MOV_CH_LAYOUT_EAC3_7_0_A, L, C, R, Ls, Rs, Rls, Rrs )\
198  CHLIST07( MOV_CH_LAYOUT_AUDIOUNIT_7_0_FRONT, L, R, Ls, Rs, C, Lc, Rc )\
199  CHLIST07( MOV_CH_LAYOUT_DTS_7_0, Lc, C, Rc, L, R, Ls, Rs )\
200  CHLIST07( MOV_CH_LAYOUT_EAC3_6_1_B, L, C, R, Ls, Rs, LFE, Ts )\
201  CHLIST07( MOV_CH_LAYOUT_EAC3_6_1_C, L, C, R, Ls, Rs, LFE, Vhc )\
202  CHLIST07( MOV_CH_LAYOUT_DTS_6_1_A, Lc, Rc, L, R, Ls, Rs, LFE )\
203  CHLIST07( MOV_CH_LAYOUT_DTS_6_1_B, C, L, R, Rls, Rrs, Ts, LFE )\
204  CHLIST07( MOV_CH_LAYOUT_DTS_6_1_C, C, Cs, L, R, Rls, Rrs, LFE )\
205  CHLIST08( MOV_CH_LAYOUT_OCTAGONAL, L, R, Rls, Rrs, C, Cs, Ls, Rs )\
206  CHLIST08( MOV_CH_LAYOUT_AAC_OCTAGONAL, C, L, R, Ls, Rs, Rls, Rrs, Cs )\
207  CHLIST08( MOV_CH_LAYOUT_CUBE, L, R, Rls, Rrs, Vhl, Vhr, Rlt, Rrt )\
208  CHLIST08( MOV_CH_LAYOUT_MPEG_7_1_A, L, R, C, LFE, Ls, Rs, Lc, Rc )\
209  CHLIST08( MOV_CH_LAYOUT_MPEG_7_1_B, C, Lc, Rc, L, R, Ls, Rs, LFE )\
210  CHLIST08( MOV_CH_LAYOUT_EMAGIC_DEFAULT_7_1, L, R, Ls, Rs, C, LFE, Lc, Rc )\
211  CHLIST08( MOV_CH_LAYOUT_EAC3_7_1_B, L, C, R, Ls, Rs, LFE, Lc, Rc )\
212  CHLIST08( MOV_CH_LAYOUT_DTS_7_1, Lc, C, Rc, L, R, Ls, Rs, LFE )\
213  CHLIST08( MOV_CH_LAYOUT_MPEG_7_1_C, L, R, C, LFE, Ls, Rs, Rls, Rrs )\
214  CHLIST08( MOV_CH_LAYOUT_EAC3_7_1_A, L, C, R, Ls, Rs, LFE, Rls, Rrs )\
215  CHLIST08( MOV_CH_LAYOUT_SMPTE_DTV, L, R, C, LFE, Ls, Rs, Lt, Rt )\
216  CHLIST08( MOV_CH_LAYOUT_EAC3_7_1_C, L, C, R, Ls, Rs, LFE, Lsd, Rsd )\
217  CHLIST08( MOV_CH_LAYOUT_EAC3_7_1_D, L, C, R, Ls, Rs, LFE, Lw, Rw )\
218  CHLIST08( MOV_CH_LAYOUT_EAC3_7_1_E, L, C, R, Ls, Rs, LFE, Vhl, Vhr )\
219  CHLIST08( MOV_CH_LAYOUT_EAC3_7_1_F, L, C, R, Ls, Rs, LFE, Cs, Ts )\
220  CHLIST08( MOV_CH_LAYOUT_EAC3_7_1_G, L, C, R, Ls, Rs, LFE, Cs, Vhc )\
221  CHLIST08( MOV_CH_LAYOUT_EAC3_7_1_H, L, C, R, Ls, Rs, LFE, Ts, Vhc )\
222  CHLIST08( MOV_CH_LAYOUT_DTS_8_0_A, Lc, Rc, L, R, Ls, Rs, Rls, Rrs )\
223  CHLIST08( MOV_CH_LAYOUT_DTS_8_0_B, Lc, C, Rc, L, R, Ls, Cs, Rs )\
224  CHLIST09( MOV_CH_LAYOUT_DTS_8_1_A, Lc, Rc, L, R, Ls, Rs, Rls, Rrs, LFE )\
225  CHLIST09( MOV_CH_LAYOUT_DTS_8_1_B, Lc, C, Rc, L, R, Ls, Cs, Rs, LFE )\
226  CHLIST16( MOV_CH_LAYOUT_TMH_10_2_STD, L, R, C, Vhc, Lsd, Rsd, Ls, Rs, Vhl, Vhr, Lw, Rw, Csd, Cs, LFE1, LFE2 )\
227  CHLIST21( MOV_CH_LAYOUT_TMH_10_2_FULL, L, R, C, Vhc, Lsd, Rsd, Ls, Rs, Vhl, Vhr, Lw, Rw, Csd, Cs, LFE1, LFE2, Lc, Rc, HI, VI, Haptic )\
228 
229 #define CHLIST(_tag, _cnt, ...) static_assert((_tag & 0xffff) == _cnt, "Channel count of " #_tag " is not " #_cnt);
231 #undef CHLIST
232 #define CHLIST(_tag, _cnt, ...) TAG(_tag, _cnt), __VA_ARGS__,
233 static const struct MovChannelLayoutMap mov_ch_layout_map[] = {
235  { {0} },
236 };
237 
238 #undef ID
239 #undef TAG
240 #define ID(_0) {.id = iso_##_0}
241 #define TAG(_tag, _cnt) {.tag = (_tag << 16) | _cnt}
242 
243 /* ISO/IEC 23001-8 */
244 static const struct MovChannelLayoutMap iso_ch_layout_map[] = {
245  CHLIST01( 1, C )
246  CHLIST02( 2, L, R )
247  CHLIST03( 3, C, L, R )
248  CHLIST04( 4, C, L, R, Cs )
249  CHLIST05( 5, C, L, R, Ls, Rs )
250  CHLIST06( 6, C, L, R, Ls, Rs, LFE )
251  CHLIST08( 7, C, Lc, Rc, L, R, Ls, Rs, LFE )
252  CHLIST03( 9, L, R, Cs )
253  CHLIST04( 10, L, R, Ls, Rs )
254  CHLIST07( 11, C, L, R, Ls, Rs, Cs, LFE )
255  CHLIST08( 12, C, L, R, Ls, Rs, Lsr, Rsr, LFE )
256  CHLIST24( 13, C, Lc, Rc, L, R, Lss, Rss, Lsr, Rsr, Cs, LFE, LFE2, Cv, Lv, Rv, Lvss, Rvss, Ts, Lvr, Rvr, Cvr, Cb, Lb, Rb)
257  CHLIST08( 14, C, L, R, Ls, Rs, LFE, Lv, Rv)
258  { {0} },
259 };
260 
285  0,
286 };
287 
303  0,
304 };
305 
315  0,
316 };
317 
330  0,
331 };
332 
333 static const struct {
336 } mov_codec_ch_layouts[] = {
358  { AV_CODEC_ID_NONE, NULL },
359 };
360 
361 static const struct MovChannelLayoutMap* find_layout_map(uint32_t tag, const struct MovChannelLayoutMap *map)
362 {
363  for (int i = 0; map[i].tag & 0xffff; i += 1 + (map[i].tag & 0xffff))
364  if (map[i].tag == tag)
365  return &map[i + 1];
366  return NULL;
367 }
368 
369 /**
370  * Get the channel layout for the specified non-special channel layout tag if
371  * known.
372  *
373  * @param[in,out] ch_layout channel layout
374  * @param[in] tag channel layout tag
375  * @return <0 on error
376  */
377 static int mov_get_channel_layout(AVChannelLayout *ch_layout, uint32_t tag, uint64_t omitted_channel_map, const struct MovChannelLayoutMap *map)
378 {
379  const struct MovChannelLayoutMap *layout_map;
380 
381  /* find the channel layout for the specified layout tag */
382  layout_map = find_layout_map(tag, map);
383  if (layout_map) {
384  AVChannelLayout tmp = { 0 };
385  int ret;
386  int map_layout_nb_channels = tag & 0xFFFF;
387  int nb_channels = ch_layout->nb_channels;
388 
389  /* Omitted channel bits must not exceed number of channels in map */
390  if (omitted_channel_map >> map_layout_nb_channels)
391  return AVERROR_INVALIDDATA;
392 
393  ret = av_channel_layout_custom_init(&tmp, nb_channels);
394  if (ret < 0)
395  return ret;
396 
397  for (int i = 0, idx = 0; i < map_layout_nb_channels && idx < nb_channels; i++, omitted_channel_map >>= 1) {
398  if (!(omitted_channel_map & 1)) {
399  enum AVChannel id = layout_map[i].id;
400  tmp.u.map[idx++].id = (id != AV_CHAN_NONE ? id : AV_CHAN_UNKNOWN);
401  }
402  }
403 
405  if (ret < 0) {
407  return ret;
408  }
409 
410  av_channel_layout_uninit(ch_layout);
411  *ch_layout = tmp;
412  }
413  return 0;
414 }
415 
416 static enum AVChannel mov_get_channel_id(uint32_t label)
417 {
418  if (label == 0)
419  return AV_CHAN_UNUSED;
420  if (label <= 18)
421  return (label - 1);
422  if (label == 35)
423  return AV_CHAN_WIDE_LEFT;
424  if (label == 36)
425  return AV_CHAN_WIDE_RIGHT;
426  if (label == 37)
428  if (label == 38)
429  return AV_CHAN_STEREO_LEFT;
430  if (label == 39)
431  return AV_CHAN_STEREO_RIGHT;
432  return AV_CHAN_UNKNOWN;
433 }
434 
436 {
437  if (channel < 0)
438  return 0;
440  return channel + 1;
441  if (channel == AV_CHAN_WIDE_LEFT)
442  return 35;
444  return 36;
446  return 37;
448  return 38;
450  return 39;
451  return 0;
452 }
453 
454 static int is_layout_valid_for_tag(const AVChannelLayout *ch_layout, uint32_t tag, const struct MovChannelLayoutMap *map)
455 {
456  const struct MovChannelLayoutMap *layout_map;
457  int channels = ch_layout->nb_channels;
458 
459  /* get the layout map based on the channel count */
460  if ((tag & 0xFFFF) != channels)
461  return 0;
462 
463  layout_map = find_layout_map(tag, map);
464  if (layout_map) {
465  int i;
466  for (i = 0; i < channels; i++) {
467  if (av_channel_layout_channel_from_index(ch_layout, i) != layout_map[i].id)
468  break;
469  }
470  if (i == channels)
471  return 1;
472  }
473  return 0;
474 }
475 
477  uint32_t *layout,
478  uint32_t *bitmap,
479  uint32_t **pchannel_desc)
480 {
481  int i;
482  uint32_t tag = 0;
483  const enum MovChannelLayoutTag *layouts = NULL;
484 
485  /* find the layout list for the specified codec */
486  for (i = 0; mov_codec_ch_layouts[i].codec_id != AV_CODEC_ID_NONE; i++) {
488  break;
489  }
491  layouts = mov_codec_ch_layouts[i].layouts;
492 
493  if (layouts) {
494  /* find the layout tag for the specified channel layout */
495  for (i = 0; layouts[i] != 0; i++)
497  break;
498 
499  tag = layouts[i];
500  }
501 
502  *layout = tag;
503  *bitmap = 0;
504  *pchannel_desc = NULL;
505 
506  /* if no tag was found, use channel bitmap or description as a backup if possible */
507  if (tag == 0) {
508  uint32_t *channel_desc;
509 
511  /* Parsers and encoders (e.g. AC3, AAC, ALAC) indicate/propagate the bitstream's
512  * channel configuration using "standard" layouts in AV_CHANNEL_ORDER_NATIVE but
513  * the encoded bitstream's channels are not actually in that order. Don't return
514  * a channel layout bitmap or description using a conflicting channel order, as
515  * some software will incorrectly override the bitstream-provided information
516  * using the chan atom's data instead (e.g. afinfo/afplay for AAC in MOV) */
517  if (layouts != mov_ch_layouts_wav) {
519  return 0;
520  }
521 
522  if (par->ch_layout.u.mask < 0x40000) {
524  *bitmap = (uint32_t)par->ch_layout.u.mask;
525  return 0;
526  }
527  } else if (par->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC)
528  return AVERROR(ENOSYS);
529 
530  channel_desc = av_malloc_array(par->ch_layout.nb_channels, sizeof(*channel_desc));
531  if (!channel_desc)
532  return AVERROR(ENOMEM);
533 
534  for (i = 0; i < par->ch_layout.nb_channels; i++) {
535  channel_desc[i] =
537 
538  if (channel_desc[i] == 0) {
539  av_free(channel_desc);
540  return AVERROR(ENOSYS);
541  }
542  }
543 
544  *pchannel_desc = channel_desc;
545  }
546 
547  return 0;
548 }
549 
551  int64_t size)
552 {
553  uint32_t layout_tag, bitmap, num_descr;
554  int ret;
555  AVChannelLayout *ch_layout = &st->codecpar->ch_layout;
556 
557  if (size < 12)
558  return AVERROR_INVALIDDATA;
559 
560  layout_tag = avio_rb32(pb);
561  bitmap = avio_rb32(pb);
562  num_descr = avio_rb32(pb);
563 
564  av_log(s, AV_LOG_DEBUG, "chan: layout=%"PRIu32" "
565  "bitmap=%"PRIu32" num_descr=%"PRIu32"\n",
566  layout_tag, bitmap, num_descr);
567 
568  if (size < 12ULL + num_descr * 20ULL)
569  return 0;
570 
571  if (layout_tag == MOV_CH_LAYOUT_USE_DESCRIPTIONS) {
572  AVChannelLayout tmp = { 0 };
573  int nb_channels = ch_layout->nb_channels;
574 
575  if (!num_descr || num_descr < nb_channels) {
576  av_log(s, AV_LOG_ERROR, "got %"PRIu32" channel descriptions when at least %d were needed\n",
577  num_descr, nb_channels);
578  return AVERROR_INVALIDDATA;
579  }
580 
581  if (num_descr > nb_channels) {
582  int strict = s->strict_std_compliance >= FF_COMPLIANCE_STRICT;
583  av_log(s, strict ? AV_LOG_ERROR : AV_LOG_WARNING,
584  "got %"PRIu32" channel descriptions when number of channels is %d\n",
585  num_descr, nb_channels);
586  if (strict)
587  return AVERROR_INVALIDDATA;
588  av_log(s, AV_LOG_WARNING, "capping channel descriptions to the number of channels\n");
589  num_descr = nb_channels;
590  }
591 
592  ret = av_channel_layout_custom_init(&tmp, nb_channels);
593  if (ret < 0)
594  goto out;
595 
596  for (int i = 0; i < num_descr; i++) {
597  uint32_t label;
598  if (pb->eof_reached) {
600  "reached EOF while reading channel layout\n");
602  return AVERROR_INVALIDDATA;
603  }
604  label = avio_rb32(pb); // mChannelLabel
605  avio_rb32(pb); // mChannelFlags
606  avio_rl32(pb); // mCoordinates[0]
607  avio_rl32(pb); // mCoordinates[1]
608  avio_rl32(pb); // mCoordinates[2]
609  size -= 20;
610  tmp.u.map[i].id = mov_get_channel_id(label);
611  }
612 
614  if (ret < 0) {
616  goto out;
617  }
618 
619  av_channel_layout_uninit(ch_layout);
620  *ch_layout = tmp;
621  } else if (layout_tag == MOV_CH_LAYOUT_USE_BITMAP) {
622  if (!ch_layout->nb_channels || av_popcount(bitmap) == ch_layout->nb_channels) {
623  if (bitmap < 0x40000) {
624  av_channel_layout_uninit(ch_layout);
625  av_channel_layout_from_mask(ch_layout, bitmap);
626  }
627  } else {
628  av_log(s, AV_LOG_WARNING, "ignoring channel layout bitmap with %d channels because number of channels is %d\n",
629  av_popcount64(bitmap), ch_layout->nb_channels);
630  }
631  } else if (layout_tag & 0xFFFF) {
632  int nb_channels = layout_tag & 0xFFFF;
633  if (!ch_layout->nb_channels)
634  ch_layout->nb_channels = nb_channels;
635  if (nb_channels == ch_layout->nb_channels) {
636  ret = mov_get_channel_layout(ch_layout, layout_tag, 0, mov_ch_layout_map);
637  if (ret < 0)
638  return ret;
639  } else {
640  av_log(s, AV_LOG_WARNING, "ignoring layout tag with %d channels because number of channels is %d\n",
641  nb_channels, ch_layout->nb_channels);
642  }
643  }
644  ret = 0;
645 
646 out:
647  avio_skip(pb, size - 12);
648 
649  return ret;
650 }
651 
652 /* ISO/IEC 23001-8, table 8 */
653 static const enum AVChannel iso_channel_position[] = {
654  [0] = AV_CHAN_FRONT_LEFT, // left front
655  [1] = AV_CHAN_FRONT_RIGHT, // right front
656  [2] = AV_CHAN_FRONT_CENTER, // centre front
657  [3] = AV_CHAN_LOW_FREQUENCY, // low frequency enhancement
658  [4] = AV_CHAN_SIDE_LEFT, // left surround
659  [5] = AV_CHAN_SIDE_RIGHT, // right surround
660  [6] = AV_CHAN_FRONT_LEFT_OF_CENTER, // left front centre
661  [7] = AV_CHAN_FRONT_RIGHT_OF_CENTER, // right front centre
662  [8] = AV_CHAN_BACK_LEFT, // rear surround left
663  [9] = AV_CHAN_BACK_RIGHT, // rear surround right
664  [10] = AV_CHAN_BACK_CENTER, // rear centre
665  [11] = AV_CHAN_SURROUND_DIRECT_LEFT, // left surround direct
666  [12] = AV_CHAN_SURROUND_DIRECT_RIGHT, // right surround direct
667  [13] = AV_CHAN_SIDE_SURROUND_LEFT, // left side surround
668  [14] = AV_CHAN_SIDE_SURROUND_RIGHT, // right side surround
669  [15] = AV_CHAN_WIDE_LEFT, // left wide front
670  [16] = AV_CHAN_WIDE_RIGHT, // right wide front
671  [17] = AV_CHAN_TOP_FRONT_LEFT, // left front vertical height
672  [18] = AV_CHAN_TOP_FRONT_RIGHT, // right front vertical height
673  [19] = AV_CHAN_TOP_FRONT_CENTER, // centre front vertical height
674  [20] = AV_CHAN_TOP_BACK_LEFT, // left surround vertical height rear
675  [21] = AV_CHAN_TOP_BACK_RIGHT, // right surround vertical height rear
676  [22] = AV_CHAN_TOP_BACK_CENTER, // centre vertical height rear
677  [23] = AV_CHAN_TOP_SIDE_LEFT, // left vertical height side surround
678  [24] = AV_CHAN_TOP_SIDE_RIGHT, // right vertical height side surround
679  [25] = AV_CHAN_TOP_CENTER, // top centre surround
680  [26] = AV_CHAN_LOW_FREQUENCY_2, // low frequency enhancement 2
681  [27] = AV_CHAN_BOTTOM_FRONT_LEFT, // left front vertical bottom
682  [28] = AV_CHAN_BOTTOM_FRONT_RIGHT, // right front vertical bottom
683  [29] = AV_CHAN_BOTTOM_FRONT_CENTER, // centre front vertical bottom
684  [30] = AV_CHAN_TOP_SURROUND_LEFT, // left vertical height surround
685  [31] = AV_CHAN_TOP_SURROUND_RIGHT, // right vertical height surround
686 
687  [32] = AV_CHAN_NONE, // reserved
688  [33] = AV_CHAN_NONE, // reserved
689  [34] = AV_CHAN_NONE, // reserved
690  [35] = AV_CHAN_NONE, // reserved
691 
692  [36] = AV_CHAN_NONE, // low frequency enhancement 3
693  [37] = AV_CHAN_NONE, // left edge of screen
694  [38] = AV_CHAN_NONE, // right edge of screen
695  [39] = AV_CHAN_NONE, // half-way between centre of screen and left edge of screen
696  [40] = AV_CHAN_NONE, // half-way between centre of screen and right edge of screen
697  [41] = AV_CHAN_NONE, // left back surround
698  [42] = AV_CHAN_NONE, // right back surround
699 
700  // 43 - 125: reserved
701  // 126: explicit position
702  // 127: unknown /undefined
703 };
704 
706 {
707  // Set default value which means any setup in 23001-8
708  *config = 0;
709  for (int i = 0; iso_ch_layout_map[i].tag & 0xffff; i += 1 + (iso_ch_layout_map[i].tag & 0xffff)) {
711  *config = iso_ch_layout_map[i].tag >> 16;
712  break;
713  }
714  }
715 
716  return 0;
717 }
718 
719 /**
720  * Get AVChannelLayout from ISO/IEC 23001-8 ChannelConfiguration.
721  *
722  * @return 1 if the config was unknown, layout is untouched in this case
723  * 0 if the config was found
724  * <0 on error
725  */
726 static int mov_get_channel_layout_from_config(int config, AVChannelLayout *layout, uint64_t omitted_channel_map)
727 {
728  if (config > 0) {
729  uint32_t layout_tag;
730  int nb_omitted_channels = av_popcount64(omitted_channel_map);
731 
732  if (layout->nb_channels <= 0 || layout->nb_channels > UINT16_MAX - nb_omitted_channels)
733  return AVERROR_INVALIDDATA;
734 
735  layout_tag = (config << 16) | (layout->nb_channels + nb_omitted_channels);
736  return mov_get_channel_layout(layout, layout_tag, omitted_channel_map, iso_ch_layout_map);
737  }
738  return 1;
739 }
740 
742  uint8_t *position, int position_num)
743 {
744  enum AVChannel channel;
745 
746  if (position_num < layout->nb_channels)
747  return AVERROR(EINVAL);
748 
749  for (int i = 0; i < layout->nb_channels; i++) {
750  position[i] = 127;
752  if (channel == AV_CHAN_NONE)
753  return AVERROR(EINVAL);
754 
755  for (int j = 0; j < FF_ARRAY_ELEMS(iso_channel_position); j++) {
756  if (iso_channel_position[j] == channel) {
757  position[i] = j;
758  break;
759  }
760  }
761  if (position[i] == 127)
762  return AVERROR(EINVAL);
763  }
764 
765  return 0;
766 }
767 
769 {
770  int stream_structure = avio_r8(pb);
771  int base_channel_count;
772  int obj_count = 0;
773  int ret;
774 
775  if (version == 1) {
776  stream_structure >>= 4;
777  base_channel_count = avio_r8(pb);
778  }
779 
780  // stream carries channels
781  if (stream_structure & 1) {
782  int layout = avio_r8(pb);
783 
784  av_log(s, AV_LOG_TRACE, "'chnl' layout %d\n", layout);
785  if (!layout) {
786  AVChannelLayout tmp = { 0 }, *ch_layout = &st->codecpar->ch_layout;
787  int nb_channels = ch_layout->nb_channels;
788 
789  if (version == 1) {
790  nb_channels = avio_r8(pb);
791  obj_count = base_channel_count - nb_channels;
792  if (obj_count < 0)
793  return AVERROR_INVALIDDATA;
794  }
795 
796  ret = av_channel_layout_custom_init(&tmp, nb_channels);
797  if (ret < 0)
798  return ret;
799 
800  for (int i = 0; i < nb_channels; i++) {
801  int speaker_pos = avio_r8(pb);
802  enum AVChannel channel;
803 
804  if (speaker_pos == 126) // explicit position
805  avio_skip(pb, 3); // azimuth, elevation
806 
807  if (speaker_pos >= FF_ARRAY_ELEMS(iso_channel_position))
809  else
810  channel = iso_channel_position[speaker_pos];
811 
812  if (channel == AV_CHAN_NONE) {
813  av_log(s, AV_LOG_WARNING, "speaker position %d is not implemented\n", speaker_pos);
815  }
816 
817  tmp.u.map[i].id = channel;
818  }
819 
821  if (ret < 0) {
823  return ret;
824  }
825  av_channel_layout_uninit(ch_layout);
826  *ch_layout = tmp;
827  } else {
828  uint64_t omitted_channel_map = 0;
829  int omitted_channel_present = 1, channel_order_definition = 0;
830 
831  if (version == 1) {
832  int byte = avio_r8(pb);
833  omitted_channel_present = byte & 1;
834  channel_order_definition = (byte >> 1) & 0x7;
835  }
836 
837  if (omitted_channel_present)
838  omitted_channel_map = avio_rb64(pb);
839  if (!channel_order_definition) {
840  ret = mov_get_channel_layout_from_config(layout, &st->codecpar->ch_layout, omitted_channel_map);
841  if (ret < 0)
842  return ret;
843  } else
844  av_log(s, AV_LOG_TRACE, "'chnl' with channel_order_definition %d\n", channel_order_definition);
845 
846  if (version == 1)
847  obj_count = base_channel_count - st->codecpar->ch_layout.nb_channels;
848  }
849  }
850 
851  // stream carries objects
852  if (stream_structure & 2) {
853  if (version == 0)
854  obj_count = avio_r8(pb);
855  av_log(s, AV_LOG_TRACE, "'chnl' with object_count %d\n", obj_count);
856  }
857 
858  return 0;
859 }
MOV_CH_LAYOUT_QUADRAPHONIC
@ MOV_CH_LAYOUT_QUADRAPHONIC
Definition: mov_chan.h:64
AV_CODEC_ID_PCM_S16LE
@ AV_CODEC_ID_PCM_S16LE
Definition: codec_id.h:330
AV_CODEC_ID_MACE6
@ AV_CODEC_ID_MACE6
Definition: codec_id.h:462
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:216
AV_CODEC_ID_PCM_F32BE
@ AV_CODEC_ID_PCM_F32BE
Definition: codec_id.h:350
AV_CODEC_ID_ADPCM_IMA_QT
@ AV_CODEC_ID_ADPCM_IMA_QT
Definition: codec_id.h:369
AV_CODEC_ID_AC3
@ AV_CODEC_ID_AC3
Definition: codec_id.h:455
c_Lt
@ c_Lt
Definition: mov_chan.c:54
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
iso_Cvr
@ iso_Cvr
Definition: mov_chan.c:95
iso_Lsr
@ iso_Lsr
Definition: mov_chan.c:83
MOV_CH_LAYOUT_MPEG_5_1_A
@ MOV_CH_LAYOUT_MPEG_5_1_A
Definition: mov_chan.h:77
out
static FILE * out
Definition: movenc.c:55
codec_id
enum AVCodecID codec_id
Definition: mov_chan.c:334
c_Vhr
@ c_Vhr
Definition: mov_chan.c:50
iso_ch_layout_map
static const struct MovChannelLayoutMap iso_ch_layout_map[]
Definition: mov_chan.c:244
AVCodecParameters
This struct describes the properties of an encoded stream.
Definition: codec_par.h:49
av_popcount64
#define av_popcount64
Definition: common.h:157
layouts
enum MovChannelLayoutTag * layouts
Definition: mov_chan.c:335
AV_CHAN_WIDE_LEFT
@ AV_CHAN_WIDE_LEFT
Definition: channel_layout.h:72
MOV_CH_LAYOUT_DTS_8_0_A
@ MOV_CH_LAYOUT_DTS_8_0_A
Definition: mov_chan.h:134
int64_t
long long int64_t
Definition: coverity.c:34
AV_CHAN_TOP_SURROUND_LEFT
@ AV_CHAN_TOP_SURROUND_LEFT
+110 degrees, Lvs, TpLS
Definition: channel_layout.h:84
iso_Rsd
@ iso_Rsd
Definition: mov_chan.c:102
MOV_CH_LAYOUT_AC3_3_0_1
@ MOV_CH_LAYOUT_AC3_3_0_1
Definition: mov_chan.h:107
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:674
c_LFE
@ c_LFE
Definition: mov_chan.c:39
R
#define R
Definition: huffyuv.h:44
AV_CODEC_ID_ALAC
@ AV_CODEC_ID_ALAC
Definition: codec_id.h:468
mov_ch_layout_map
static const struct MovChannelLayoutMap mov_ch_layout_map[]
Definition: mov_chan.c:233
FF_COMPLIANCE_STRICT
#define FF_COMPLIANCE_STRICT
Strictly conform to all the things in the spec no matter what consequences.
Definition: defs.h:59
CHLIST01
#define CHLIST01(_tag, _1)
Definition: mov_chan.c:125
MOV_CH_LAYOUT_ITU_2_1
@ MOV_CH_LAYOUT_ITU_2_1
Definition: mov_chan.h:87
AVChannelLayout::order
enum AVChannelOrder order
Channel order used in this layout.
Definition: channel_layout.h:324
MOV_CH_LAYOUT_AAC_7_0
@ MOV_CH_LAYOUT_AAC_7_0
Definition: mov_chan.h:100
AVChannelLayout::mask
uint64_t mask
This member must be used for AV_CHANNEL_ORDER_NATIVE, and may be used for AV_CHANNEL_ORDER_AMBISONIC ...
Definition: channel_layout.h:351
iso_Rss
@ iso_Rss
Definition: mov_chan.c:110
av_popcount
#define av_popcount
Definition: common.h:154
CHLIST24
#define CHLIST24(_tag, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24)
Definition: mov_chan.c:140
ff_mov_get_channel_layout_tag
int ff_mov_get_channel_layout_tag(const AVCodecParameters *par, uint32_t *layout, uint32_t *bitmap, uint32_t **pchannel_desc)
Get the channel layout tag for the specified codec id and channel layout.
Definition: mov_chan.c:476
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:329
tf_sess_config.config
config
Definition: tf_sess_config.py:33
MOV_CH_LAYOUT_AC3_3_0
@ MOV_CH_LAYOUT_AC3_3_0
Definition: mov_chan.h:105
c_Rw
@ c_Rw
Definition: mov_chan.c:57
MOV_CH_LAYOUT_DTS_6_0_A
@ MOV_CH_LAYOUT_DTS_6_0_A
Definition: mov_chan.h:125
mov_get_channel_layout
static int mov_get_channel_layout(AVChannelLayout *ch_layout, uint32_t tag, uint64_t omitted_channel_map, const struct MovChannelLayoutMap *map)
Get the channel layout for the specified non-special channel layout tag if known.
Definition: mov_chan.c:377
MOV_CH_LAYOUT_MATRIXSTEREO
@ MOV_CH_LAYOUT_MATRIXSTEREO
Definition: mov_chan.h:59
c_Rt
@ c_Rt
Definition: mov_chan.c:55
iso_LFE
@ iso_LFE
Definition: mov_chan.c:82
AV_CHAN_SURROUND_DIRECT_LEFT
@ AV_CHAN_SURROUND_DIRECT_LEFT
Definition: channel_layout.h:74
c_R
@ c_R
Definition: mov_chan.c:37
MOV_CH_LAYOUT_MPEG_5_0_A
@ MOV_CH_LAYOUT_MPEG_5_0_A
Definition: mov_chan.h:73
c_Lc
@ c_Lc
Definition: mov_chan.c:42
c_Ls
@ c_Ls
Definition: mov_chan.c:45
AV_CODEC_ID_SPEEX
@ AV_CODEC_ID_SPEEX
Definition: codec_id.h:487
AV_CODEC_ID_PCM_S16BE
@ AV_CODEC_ID_PCM_S16BE
Definition: codec_id.h:331
AV_CHAN_TOP_BACK_RIGHT
@ AV_CHAN_TOP_BACK_RIGHT
Definition: channel_layout.h:67
MOV_CH_LAYOUT_MPEG_5_1_D
@ MOV_CH_LAYOUT_MPEG_5_1_D
Definition: mov_chan.h:80
c_Cs
@ c_Cs
Definition: mov_chan.c:44
mov_ch_layouts_alac
static enum MovChannelLayoutTag mov_ch_layouts_alac[]
Definition: mov_chan.c:306
iso_Lc
@ iso_Lc
Definition: mov_chan.c:85
iso_Rvs
@ iso_Rvs
Definition: mov_chan.c:113
mov_get_channel_layout_from_config
static int mov_get_channel_layout_from_config(int config, AVChannelLayout *layout, uint64_t omitted_channel_map)
Get AVChannelLayout from ISO/IEC 23001-8 ChannelConfiguration.
Definition: mov_chan.c:726
MOV_CH_LAYOUT_MONO
@ MOV_CH_LAYOUT_MONO
Definition: mov_chan.h:56
c_Rs
@ c_Rs
Definition: mov_chan.c:46
AV_CHAN_STEREO_RIGHT
@ AV_CHAN_STEREO_RIGHT
See above.
Definition: channel_layout.h:71
iso_C
@ iso_C
Definition: mov_chan.c:81
MOV_CH_LAYOUT_ITU_2_2
@ MOV_CH_LAYOUT_ITU_2_2
Definition: mov_chan.h:88
C
s EdgeDetect Foobar g libavfilter vf_edgedetect c libavfilter vf_foobar c edit libavfilter and add an entry for foobar following the pattern of the other filters edit libavfilter allfilters and add an entry for foobar following the pattern of the other filters configure make j< whatever > ffmpeg ffmpeg i you should get a foobar png with Lena edge detected That s your new playground is ready Some little details about what s going which in turn will define variables for the build system and the C
Definition: writing_filters.txt:58
iso_LFE2
@ iso_LFE2
Definition: mov_chan.c:103
AV_CODEC_ID_PCM_S8
@ AV_CODEC_ID_PCM_S8
Definition: codec_id.h:334
avassert.h
AV_CHAN_BOTTOM_FRONT_LEFT
@ AV_CHAN_BOTTOM_FRONT_LEFT
Definition: channel_layout.h:80
avio_rb32
unsigned int avio_rb32(AVIOContext *s)
Definition: aviobuf.c:764
AV_LOG_TRACE
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
Definition: log.h:236
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:210
AV_CODEC_ID_MACE3
@ AV_CODEC_ID_MACE3
Definition: codec_id.h:461
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
MOV_CH_LAYOUT_AC3_1_0_1
@ MOV_CH_LAYOUT_AC3_1_0_1
Definition: mov_chan.h:104
codec_id.h
MOV_CH_LAYOUT_MPEG_5_1_C
@ MOV_CH_LAYOUT_MPEG_5_1_C
Definition: mov_chan.h:79
c_VI
@ c_VI
Definition: mov_chan.c:74
MOV_CH_LAYOUT_AAC_6_0
@ MOV_CH_LAYOUT_AAC_6_0
Definition: mov_chan.h:98
s
#define s(width, name)
Definition: cbs_vp9.c:198
find_layout_map
static const struct MovChannelLayoutMap * find_layout_map(uint32_t tag, const struct MovChannelLayoutMap *map)
Definition: mov_chan.c:361
AV_CHAN_UNKNOWN
@ AV_CHAN_UNKNOWN
Channel contains data, but its position is unknown.
Definition: channel_layout.h:94
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:119
av_channel_layout_from_mask
int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask)
Initialize a native channel layout from a bitmask indicating which channels are present.
Definition: channel_layout.c:253
AV_CHAN_SIDE_RIGHT
@ AV_CHAN_SIDE_RIGHT
Definition: channel_layout.h:60
MOV_CH_LAYOUT_AC3_3_1
@ MOV_CH_LAYOUT_AC3_3_1
Definition: mov_chan.h:106
iso_Lvss
@ iso_Lvss
Definition: mov_chan.c:104
CHLIST08
#define CHLIST08(_tag, _1, _2, _3, _4, _5, _6, _7, _8)
Definition: mov_chan.c:132
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:231
channels
channels
Definition: aptx.h:31
iso_Rc
@ iso_Rc
Definition: mov_chan.c:86
iso_Cs
@ iso_Cs
Definition: mov_chan.c:87
ff_mov_read_chnl
int ff_mov_read_chnl(AVFormatContext *s, AVIOContext *pb, AVStream *st, int version)
Read 'chnl' tag from the input stream.
Definition: mov_chan.c:768
AV_CODEC_ID_PCM_MULAW
@ AV_CODEC_ID_PCM_MULAW
Definition: codec_id.h:336
MOV_CH_LAYOUT_MPEG_7_1_B
@ MOV_CH_LAYOUT_MPEG_7_1_B
Definition: mov_chan.h:83
CHLIST04
#define CHLIST04(_tag, _1, _2, _3, _4)
Definition: mov_chan.c:128
tmp
static uint8_t tmp[40]
Definition: aes_ctr.c:52
AV_CHAN_TOP_SIDE_LEFT
@ AV_CHAN_TOP_SIDE_LEFT
Definition: channel_layout.h:77
AV_CHAN_TOP_SIDE_RIGHT
@ AV_CHAN_TOP_SIDE_RIGHT
Definition: channel_layout.h:78
iso_Rvr
@ iso_Rvr
Definition: mov_chan.c:96
AVFormatContext
Format I/O context.
Definition: avformat.h:1314
AV_CHAN_SIDE_SURROUND_LEFT
@ AV_CHAN_SIDE_SURROUND_LEFT
+90 degrees, Lss, SiL
Definition: channel_layout.h:82
AV_CODEC_ID_PCM_ALAW
@ AV_CODEC_ID_PCM_ALAW
Definition: codec_id.h:337
MOV_CH_LAYOUT_SMPTE_DTV
@ MOV_CH_LAYOUT_SMPTE_DTV
Definition: mov_chan.h:86
c_Lsd
@ c_Lsd
Definition: mov_chan.c:58
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:770
MovChannelLayoutTag
MovChannelLayoutTag
mov 'chan' tag reading/writing.
Definition: mov_chan.h:51
c_HI
@ c_HI
Definition: mov_chan.c:73
MOV_CH_LAYOUT_STEREO
@ MOV_CH_LAYOUT_STEREO
Definition: mov_chan.h:57
NULL
#define NULL
Definition: coverity.c:32
c_L
@ c_L
Definition: mov_chan.c:36
MOV_CH_LAYOUT_DTS_4_1
@ MOV_CH_LAYOUT_DTS_4_1
Definition: mov_chan.h:124
MOV_CH_LAYOUT_MAP
#define MOV_CH_LAYOUT_MAP
Definition: mov_chan.c:145
iso_Lsd
@ iso_Lsd
Definition: mov_chan.c:101
c_Lw
@ c_Lw
Definition: mov_chan.c:56
AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL
#define AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL
The specified retype target order is ignored and the simplest possible (canonical) order is used for ...
Definition: channel_layout.h:721
c_Vhc
@ c_Vhc
Definition: mov_chan.c:49
c_Rlt
@ c_Rlt
Definition: mov_chan.c:51
AV_CHAN_TOP_BACK_CENTER
@ AV_CHAN_TOP_BACK_CENTER
Definition: channel_layout.h:66
MOV_CH_LAYOUT_UNKNOWN
#define MOV_CH_LAYOUT_UNKNOWN
Definition: mov_chan.h:52
avio_rb64
uint64_t avio_rb64(AVIOContext *s)
Definition: aviobuf.c:911
CHLIST05
#define CHLIST05(_tag, _1, _2, _3, _4, _5)
Definition: mov_chan.c:129
mov_get_channel_id
static enum AVChannel mov_get_channel_id(uint32_t label)
Definition: mov_chan.c:416
AV_CHAN_BOTTOM_FRONT_RIGHT
@ AV_CHAN_BOTTOM_FRONT_RIGHT
Definition: channel_layout.h:81
MOV_CH_LAYOUT_MPEG_3_0_B
@ MOV_CH_LAYOUT_MPEG_3_0_B
Definition: mov_chan.h:70
ff_mov_get_channel_positions_from_layout
int ff_mov_get_channel_positions_from_layout(const AVChannelLayout *layout, uint8_t *position, int position_num)
Get ISO/IEC 23001-8 OutputChannelPosition from AVChannelLayout.
Definition: mov_chan.c:741
c_Rsd
@ c_Rsd
Definition: mov_chan.c:59
AV_CHAN_TOP_CENTER
@ AV_CHAN_TOP_CENTER
Definition: channel_layout.h:61
iso_Rb
@ iso_Rb
Definition: mov_chan.c:108
AVCodecParameters::ch_layout
AVChannelLayout ch_layout
The channel layout and number of channels.
Definition: codec_par.h:207
MovChannelLayoutMap
Definition: mov_chan.c:116
AV_CHAN_FRONT_RIGHT_OF_CENTER
@ AV_CHAN_FRONT_RIGHT_OF_CENTER
Definition: channel_layout.h:57
AVCodecID
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition: codec_id.h:47
AV_CHAN_FRONT_RIGHT
@ AV_CHAN_FRONT_RIGHT
Definition: channel_layout.h:51
AV_CHAN_FRONT_CENTER
@ AV_CHAN_FRONT_CENTER
Definition: channel_layout.h:52
AV_CODEC_ID_AAC
@ AV_CODEC_ID_AAC
Definition: codec_id.h:454
ff_mov_get_channel_config_from_layout
int ff_mov_get_channel_config_from_layout(const AVChannelLayout *layout, int *config)
Get ISO/IEC 23001-8 ChannelConfiguration from AVChannelLayout.
Definition: mov_chan.c:705
iso_R
@ iso_R
Definition: mov_chan.c:80
iso_Lvr
@ iso_Lvr
Definition: mov_chan.c:94
iso_Cv
@ iso_Cv
Definition: mov_chan.c:92
c_LFE1
@ c_LFE1
Definition: mov_chan.c:71
avio_rl32
unsigned int avio_rl32(AVIOContext *s)
Definition: aviobuf.c:733
AVIOContext
Bytestream IO Context.
Definition: avio.h:160
AV_CODEC_ID_PCM_S24LE
@ AV_CODEC_ID_PCM_S24LE
Definition: codec_id.h:342
iso_Lb
@ iso_Lb
Definition: mov_chan.c:107
c_W
@ c_W
Definition: mov_chan.c:66
MOV_CH_LAYOUT_AAC_6_1
@ MOV_CH_LAYOUT_AAC_6_1
Definition: mov_chan.h:99
iso_Rw
@ iso_Rw
Definition: mov_chan.c:100
AVChannelLayout
An AVChannelLayout holds information about the channel layout of audio data.
Definition: channel_layout.h:319
i
#define i(width, name, range_min, range_max)
Definition: cbs_h264.c:63
CHLIST07
#define CHLIST07(_tag, _1, _2, _3, _4, _5, _6, _7)
Definition: mov_chan.c:131
c_X
@ c_X
Definition: mov_chan.c:69
AV_CHAN_LOW_FREQUENCY
@ AV_CHAN_LOW_FREQUENCY
Definition: channel_layout.h:53
size
int size
Definition: twinvq_data.h:10344
c_Rrt
@ c_Rrt
Definition: mov_chan.c:53
AV_CHAN_BACK_RIGHT
@ AV_CHAN_BACK_RIGHT
Definition: channel_layout.h:55
c_Y
@ c_Y
Definition: mov_chan.c:67
AV_CHAN_SIDE_LEFT
@ AV_CHAN_SIDE_LEFT
Definition: channel_layout.h:59
c_Rrs
@ c_Rrs
Definition: mov_chan.c:41
MOV_CH_LAYOUT_MPEG_7_1_A
@ MOV_CH_LAYOUT_MPEG_7_1_A
Definition: mov_chan.h:82
c_Rc
@ c_Rc
Definition: mov_chan.c:43
c_LFE2
@ c_LFE2
Definition: mov_chan.c:60
avio_r8
int avio_r8(AVIOContext *s)
Definition: aviobuf.c:606
av_channel_layout_retype
int av_channel_layout_retype(AVChannelLayout *channel_layout, enum AVChannelOrder order, int flags)
Change the AVChannelOrder of a channel layout.
Definition: channel_layout.c:887
iso_Cb
@ iso_Cb
Definition: mov_chan.c:106
MOV_CH_LAYOUT_DTS_6_1_A
@ MOV_CH_LAYOUT_DTS_6_1_A
Definition: mov_chan.h:128
MOV_CH_LAYOUT_MPEG_3_0_A
@ MOV_CH_LAYOUT_MPEG_3_0_A
Definition: mov_chan.h:69
AV_CHAN_TOP_FRONT_RIGHT
@ AV_CHAN_TOP_FRONT_RIGHT
Definition: channel_layout.h:64
iso_L
@ iso_L
Definition: mov_chan.c:79
AV_CHANNEL_ORDER_NATIVE
@ AV_CHANNEL_ORDER_NATIVE
The native channel order, i.e.
Definition: channel_layout.h:125
AV_CHAN_FRONT_LEFT_OF_CENTER
@ AV_CHAN_FRONT_LEFT_OF_CENTER
Definition: channel_layout.h:56
MOV_CH_LAYOUT_DVD_18
@ MOV_CH_LAYOUT_DVD_18
Definition: mov_chan.h:94
version
version
Definition: libkvazaar.c:313
AV_CHAN_UNUSED
@ AV_CHAN_UNUSED
Channel is empty can be safely skipped.
Definition: channel_layout.h:91
AVChannelLayout::u
union AVChannelLayout::@522 u
Details about which channels are present in this layout.
av_channel_layout_custom_init
int av_channel_layout_custom_init(AVChannelLayout *channel_layout, int nb_channels)
Initialize a custom channel layout with the specified number of channels.
Definition: channel_layout.c:233
layout
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 layout
Definition: filter_design.txt:18
AVChannel
AVChannel
Definition: channel_layout.h:47
MOV_CH_LAYOUT_MPEG_5_0_D
@ MOV_CH_LAYOUT_MPEG_5_0_D
Definition: mov_chan.h:76
c_C
@ c_C
Definition: mov_chan.c:38
AV_CHAN_TOP_SURROUND_RIGHT
@ AV_CHAN_TOP_SURROUND_RIGHT
-110 degrees, Rvs, TpRS
Definition: channel_layout.h:85
c_Rls
@ c_Rls
Definition: mov_chan.c:40
AV_CHAN_SURROUND_DIRECT_RIGHT
@ AV_CHAN_SURROUND_DIRECT_RIGHT
Definition: channel_layout.h:75
AV_CODEC_ID_NONE
@ AV_CODEC_ID_NONE
Definition: codec_id.h:48
av_malloc_array
#define av_malloc_array(a, b)
Definition: tableprint_vlc.h:32
CHLIST03
#define CHLIST03(_tag, _1, _2, _3)
Definition: mov_chan.c:127
iso_Rv
@ iso_Rv
Definition: mov_chan.c:93
AV_CODEC_ID_PCM_F64BE
@ AV_CODEC_ID_PCM_F64BE
Definition: codec_id.h:352
MOV_CH_LAYOUT_MPEG_6_1_A
@ MOV_CH_LAYOUT_MPEG_6_1_A
Definition: mov_chan.h:81
iso_Ts
@ iso_Ts
Definition: mov_chan.c:90
AV_CODEC_ID_PCM_S32BE
@ AV_CODEC_ID_PCM_S32BE
Definition: codec_id.h:339
CHLIST06
#define CHLIST06(_tag, _1, _2, _3, _4, _5, _6)
Definition: mov_chan.c:130
iso_Lv
@ iso_Lv
Definition: mov_chan.c:91
c_Z
@ c_Z
Definition: mov_chan.c:68
MOV_CH_LAYOUT_AC3_2_1_1
@ MOV_CH_LAYOUT_AC3_2_1_1
Definition: mov_chan.h:108
AV_CHAN_STEREO_LEFT
@ AV_CHAN_STEREO_LEFT
Stereo downmix.
Definition: channel_layout.h:69
MOV_CH_LAYOUT_MPEG_4_0_B
@ MOV_CH_LAYOUT_MPEG_4_0_B
Definition: mov_chan.h:72
MovChannelLayoutMap::tag
uint32_t tag
Definition: mov_chan.c:118
MOV_CH_LAYOUT_MPEG_5_0_C
@ MOV_CH_LAYOUT_MPEG_5_0_C
Definition: mov_chan.h:75
mov_chan.h
tag
uint32_t tag
Definition: movenc.c:2054
ret
ret
Definition: filter_design.txt:187
AVStream
Stream structure.
Definition: avformat.h:747
MOV_CH_LAYOUT_DVD_4
@ MOV_CH_LAYOUT_DVD_4
Definition: mov_chan.h:89
id
enum AVCodecID id
Definition: dts2pts.c:578
AV_CHAN_BACK_CENTER
@ AV_CHAN_BACK_CENTER
Definition: channel_layout.h:58
AV_CHAN_NONE
@ AV_CHAN_NONE
Invalid channel index.
Definition: channel_layout.h:49
channel_layout.h
AV_CHAN_LOW_FREQUENCY_2
@ AV_CHAN_LOW_FREQUENCY_2
Definition: channel_layout.h:76
AV_CHAN_TOP_BACK_LEFT
@ AV_CHAN_TOP_BACK_LEFT
Definition: channel_layout.h:65
c_Vhl
@ c_Vhl
Definition: mov_chan.c:48
iso_Lw
@ iso_Lw
Definition: mov_chan.c:99
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:443
iso_Rs
@ iso_Rs
Definition: mov_chan.c:89
AV_CHAN_BACK_LEFT
@ AV_CHAN_BACK_LEFT
Definition: channel_layout.h:54
mov_codec_ch_layouts
static const struct @494 mov_codec_ch_layouts[]
L
#define L(x)
Definition: vpx_arith.h:36
AVIOContext::eof_reached
int eof_reached
true if was unable to read due to error or eof
Definition: avio.h:238
c_Csd
@ c_Csd
Definition: mov_chan.c:72
iso_Rsr
@ iso_Rsr
Definition: mov_chan.c:84
MOV_CH_LAYOUT_MPEG_7_1_C
@ MOV_CH_LAYOUT_MPEG_7_1_C
Definition: mov_chan.h:84
AV_CHAN_BOTTOM_FRONT_CENTER
@ AV_CHAN_BOTTOM_FRONT_CENTER
Definition: channel_layout.h:79
avio_skip
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition: aviobuf.c:321
MovChannelLayoutMap::id
enum AVChannel id
Definition: mov_chan.c:119
is_layout_valid_for_tag
static int is_layout_valid_for_tag(const AVChannelLayout *ch_layout, uint32_t tag, const struct MovChannelLayoutMap *map)
Definition: mov_chan.c:454
mov_ch_layouts_aac
static enum MovChannelLayoutTag mov_ch_layouts_aac[]
Definition: mov_chan.c:261
MOV_CH_LAYOUT_AAC_OCTAGONAL
@ MOV_CH_LAYOUT_AAC_OCTAGONAL
Definition: mov_chan.h:101
c_Ts
@ c_Ts
Definition: mov_chan.c:47
iso_channel_position
static enum AVChannel iso_channel_position[]
Definition: mov_chan.c:653
iso_Lss
@ iso_Lss
Definition: mov_chan.c:109
AV_CHAN_TOP_FRONT_CENTER
@ AV_CHAN_TOP_FRONT_CENTER
Definition: channel_layout.h:63
AV_CODEC_ID_PCM_S32LE
@ AV_CODEC_ID_PCM_S32LE
Definition: codec_id.h:338
MOV_CH_LAYOUT_DTS_3_1
@ MOV_CH_LAYOUT_DTS_3_1
Definition: mov_chan.h:123
mov_get_channel_label
static uint32_t mov_get_channel_label(enum AVChannel channel)
Definition: mov_chan.c:435
AV_CHAN_SIDE_SURROUND_RIGHT
@ AV_CHAN_SIDE_SURROUND_RIGHT
-90 degrees, Rss, SiR
Definition: channel_layout.h:83
mem.h
iso_Rvss
@ iso_Rvss
Definition: mov_chan.c:105
AV_CHAN_WIDE_RIGHT
@ AV_CHAN_WIDE_RIGHT
Definition: channel_layout.h:73
AV_CODEC_ID_PCM_U8
@ AV_CODEC_ID_PCM_U8
Definition: codec_id.h:335
CHLIST02
#define CHLIST02(_tag, _1, _2)
Definition: mov_chan.c:126
c_Haptic
@ c_Haptic
Definition: mov_chan.c:75
iso_Lvs
@ iso_Lvs
Definition: mov_chan.c:112
map
const VDPAUPixFmtMap * map
Definition: hwcontext_vdpau.c:71
MOV_CH_LAYOUT_AC3_3_1_1
@ MOV_CH_LAYOUT_AC3_3_1_1
Definition: mov_chan.h:109
AV_CODEC_ID_PCM_F64LE
@ AV_CODEC_ID_PCM_F64LE
Definition: codec_id.h:353
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:57
AV_CHAN_TOP_FRONT_LEFT
@ AV_CHAN_TOP_FRONT_LEFT
Definition: channel_layout.h:62
AV_CHAN_AMBISONIC_BASE
@ AV_CHAN_AMBISONIC_BASE
Range of channels between AV_CHAN_AMBISONIC_BASE and AV_CHAN_AMBISONIC_END represent Ambisonic compon...
Definition: channel_layout.h:108
AV_CODEC_ID_PCM_F32LE
@ AV_CODEC_ID_PCM_F32LE
Definition: codec_id.h:351
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
AV_CHAN_FRONT_LEFT
@ AV_CHAN_FRONT_LEFT
Definition: channel_layout.h:50
mov_ch_layouts_wav
static enum MovChannelLayoutTag mov_ch_layouts_wav[]
Definition: mov_chan.c:318
AV_CODEC_ID_PCM_S24BE
@ AV_CODEC_ID_PCM_S24BE
Definition: codec_id.h:343
mov_ch_layouts_ac3
static enum MovChannelLayoutTag mov_ch_layouts_ac3[]
Definition: mov_chan.c:288
channel
channel
Definition: ebur128.h:39
iso_Ls
@ iso_Ls
Definition: mov_chan.c:88
MOV_CH_LAYOUT_USE_BITMAP
@ MOV_CH_LAYOUT_USE_BITMAP
Definition: mov_chan.h:54
MOV_CH_LAYOUT_USE_DESCRIPTIONS
@ MOV_CH_LAYOUT_USE_DESCRIPTIONS
Definition: mov_chan.h:53
ff_mov_read_chan
int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, AVStream *st, int64_t size)
Read 'chan' tag from the input stream.
Definition: mov_chan.c:550