FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavformat/isom.c
Date: 2022-12-05 20:26:17
Exec Total Coverage
Lines: 94 106 88.7%
Functions: 7 7 100.0%
Branches: 51 70 72.9%

Line Branch Exec Source
1 /*
2 * ISO Media common code
3 * Copyright (c) 2001 Fabrice Bellard
4 * Copyright (c) 2002 Francois Revol <revol@free.fr>
5 * Copyright (c) 2006 Baptiste Coudurier <baptiste.coudurier@free.fr>
6 *
7 * This file is part of FFmpeg.
8 *
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24 #include "avformat.h"
25 #include "demux.h"
26 #include "internal.h"
27 #include "isom.h"
28 #include "libavcodec/mpeg4audio.h"
29 #include "libavcodec/mpegaudiodata.h"
30 #include "libavutil/channel_layout.h"
31
32 /* http://www.mp4ra.org */
33 /* ordered by muxing preference */
34 const AVCodecTag ff_mp4_obj_type[] = {
35 { AV_CODEC_ID_MOV_TEXT , 0x08 },
36 { AV_CODEC_ID_MPEG4 , 0x20 },
37 { AV_CODEC_ID_H264 , 0x21 },
38 { AV_CODEC_ID_HEVC , 0x23 },
39 { AV_CODEC_ID_AAC , 0x40 },
40 { AV_CODEC_ID_MP4ALS , 0x40 }, /* 14496-3 ALS */
41 { AV_CODEC_ID_MPEG2VIDEO , 0x61 }, /* MPEG-2 Main */
42 { AV_CODEC_ID_MPEG2VIDEO , 0x60 }, /* MPEG-2 Simple */
43 { AV_CODEC_ID_MPEG2VIDEO , 0x62 }, /* MPEG-2 SNR */
44 { AV_CODEC_ID_MPEG2VIDEO , 0x63 }, /* MPEG-2 Spatial */
45 { AV_CODEC_ID_MPEG2VIDEO , 0x64 }, /* MPEG-2 High */
46 { AV_CODEC_ID_MPEG2VIDEO , 0x65 }, /* MPEG-2 422 */
47 { AV_CODEC_ID_AAC , 0x66 }, /* MPEG-2 AAC Main */
48 { AV_CODEC_ID_AAC , 0x67 }, /* MPEG-2 AAC Low */
49 { AV_CODEC_ID_AAC , 0x68 }, /* MPEG-2 AAC SSR */
50 { AV_CODEC_ID_MP3 , 0x69 }, /* 13818-3 */
51 { AV_CODEC_ID_MP2 , 0x69 }, /* 11172-3 */
52 { AV_CODEC_ID_MPEG1VIDEO , 0x6A }, /* 11172-2 */
53 { AV_CODEC_ID_MP3 , 0x6B }, /* 11172-3 */
54 { AV_CODEC_ID_MJPEG , 0x6C }, /* 10918-1 */
55 { AV_CODEC_ID_PNG , 0x6D },
56 { AV_CODEC_ID_JPEG2000 , 0x6E }, /* 15444-1 */
57 { AV_CODEC_ID_VC1 , 0xA3 },
58 { AV_CODEC_ID_DIRAC , 0xA4 },
59 { AV_CODEC_ID_AC3 , 0xA5 },
60 { AV_CODEC_ID_EAC3 , 0xA6 },
61 { AV_CODEC_ID_DTS , 0xA9 }, /* mp4ra.org */
62 { AV_CODEC_ID_OPUS , 0xAD }, /* mp4ra.org */
63 { AV_CODEC_ID_VP9 , 0xB1 }, /* mp4ra.org */
64 { AV_CODEC_ID_TSCC2 , 0xD0 }, /* nonstandard, camtasia uses it */
65 { AV_CODEC_ID_EVRC , 0xD1 }, /* nonstandard, pvAuthor uses it */
66 { AV_CODEC_ID_VORBIS , 0xDD }, /* nonstandard, gpac uses it */
67 { AV_CODEC_ID_DVD_SUBTITLE, 0xE0 }, /* nonstandard, see unsupported-embedded-subs-2.mp4 */
68 { AV_CODEC_ID_QCELP , 0xE1 },
69 { AV_CODEC_ID_MPEG4SYSTEMS, 0x01 },
70 { AV_CODEC_ID_MPEG4SYSTEMS, 0x02 },
71 { AV_CODEC_ID_NONE , 0 },
72 };
73
74 const AVCodecTag ff_codec_movsubtitle_tags[] = {
75 { AV_CODEC_ID_MOV_TEXT, MKTAG('t', 'e', 'x', 't') },
76 { AV_CODEC_ID_MOV_TEXT, MKTAG('t', 'x', '3', 'g') },
77 { AV_CODEC_ID_EIA_608, MKTAG('c', '6', '0', '8') },
78 { AV_CODEC_ID_NONE, 0 },
79 };
80
81 const AVCodecTag ff_codec_movdata_tags[] = {
82 { AV_CODEC_ID_BIN_DATA, MKTAG('g', 'p', 'm', 'd') },
83 { AV_CODEC_ID_NONE, 0 },
84 };
85
86 /* map numeric codes from mdhd atom to ISO 639 */
87 /* cf. QTFileFormat.pdf p253, qtff.pdf p205 */
88 /* http://developer.apple.com/documentation/mac/Text/Text-368.html */
89 /* deprecated by putting the code as 3*5 bits ASCII */
90 static const char mov_mdhd_language_map[][4] = {
91 "eng", /* 0 English */
92 "fra", /* 1 French */
93 "ger", /* 2 German */
94 "ita", /* 3 Italian */
95 "dut", /* 4 Dutch */
96 "sve", /* 5 Swedish */
97 "spa", /* 6 Spanish */
98 "dan", /* 7 Danish */
99 "por", /* 8 Portuguese */
100 "nor", /* 9 Norwegian */
101 "heb", /* 10 Hebrew */
102 "jpn", /* 11 Japanese */
103 "ara", /* 12 Arabic */
104 "fin", /* 13 Finnish */
105 "gre", /* 14 Greek */
106 "ice", /* 15 Icelandic */
107 "mlt", /* 16 Maltese */
108 "tur", /* 17 Turkish */
109 "hr ", /* 18 Croatian */
110 "chi", /* 19 Traditional Chinese */
111 "urd", /* 20 Urdu */
112 "hin", /* 21 Hindi */
113 "tha", /* 22 Thai */
114 "kor", /* 23 Korean */
115 "lit", /* 24 Lithuanian */
116 "pol", /* 25 Polish */
117 "hun", /* 26 Hungarian */
118 "est", /* 27 Estonian */
119 "lav", /* 28 Latvian */
120 "smi", /* 29 Sami */
121 "fo ", /* 30 Faroese */
122 "per", /* 31 Farsi */
123 "rus", /* 32 Russian */
124 "chi", /* 33 Simplified Chinese */
125 "", /* 34 Flemish */
126 "iri", /* 35 Irish */
127 "alb", /* 36 Albanian */
128 "ron", /* 37 Romanian */
129 "ces", /* 38 Czech */
130 "slk", /* 39 Slovak */
131 "slv", /* 40 Slovenian */
132 "yid", /* 41 Yiddish */
133 "sr ", /* 42 Serbian */
134 "mac", /* 43 Macedonian */
135 "bul", /* 44 Bulgarian */
136 "ukr", /* 45 Ukrainian */
137 "bel", /* 46 Belarusian */
138 "uzb", /* 47 Uzbek */
139 "kaz", /* 48 Kazakh */
140 "aze", /* 49 Azerbaijani */
141 "aze", /* 50 AzerbaijanAr */
142 "arm", /* 51 Armenian */
143 "geo", /* 52 Georgian */
144 "mol", /* 53 Moldavian */
145 "kir", /* 54 Kirghiz */
146 "tgk", /* 55 Tajiki */
147 "tuk", /* 56 Turkmen */
148 "mon", /* 57 Mongolian */
149 "", /* 58 MongolianCyr */
150 "pus", /* 59 Pashto */
151 "kur", /* 60 Kurdish */
152 "kas", /* 61 Kashmiri */
153 "snd", /* 62 Sindhi */
154 "tib", /* 63 Tibetan */
155 "nep", /* 64 Nepali */
156 "san", /* 65 Sanskrit */
157 "mar", /* 66 Marathi */
158 "ben", /* 67 Bengali */
159 "asm", /* 68 Assamese */
160 "guj", /* 69 Gujarati */
161 "pa ", /* 70 Punjabi */
162 "ori", /* 71 Oriya */
163 "mal", /* 72 Malayalam */
164 "kan", /* 73 Kannada */
165 "tam", /* 74 Tamil */
166 "tel", /* 75 Telugu */
167 "sin", /* 76 Sinhala */
168 "bur", /* 77 Burmese */
169 "khm", /* 78 Khmer */
170 "lao", /* 79 Lao */
171 "vie", /* 80 Vietnamese */
172 "ind", /* 81 Indonesian */
173 "tgl", /* 82 Tagalog */
174 "may", /* 83 MalayRoman */
175 "may", /* 84 MalayArabic */
176 "amh", /* 85 Amharic */
177 "tir", /* 86 Galla */
178 "orm", /* 87 Oromo */
179 "som", /* 88 Somali */
180 "swa", /* 89 Swahili */
181 "kin", /* 90 Kinyarwanda */
182 "run", /* 91 Rundi */
183 "nya", /* 92 Nyanja */
184 "mlg", /* 93 Malagasy */
185 "epo", /* 94 Esperanto */
186 "", /* 95 */
187 "", /* 96 */
188 "", /* 97 */
189 "", /* 98 */
190 "", /* 99 */
191 "", /* 100 */
192 "", /* 101 */
193 "", /* 102 */
194 "", /* 103 */
195 "", /* 104 */
196 "", /* 105 */
197 "", /* 106 */
198 "", /* 107 */
199 "", /* 108 */
200 "", /* 109 */
201 "", /* 110 */
202 "", /* 111 */
203 "", /* 112 */
204 "", /* 113 */
205 "", /* 114 */
206 "", /* 115 */
207 "", /* 116 */
208 "", /* 117 */
209 "", /* 118 */
210 "", /* 119 */
211 "", /* 120 */
212 "", /* 121 */
213 "", /* 122 */
214 "", /* 123 */
215 "", /* 124 */
216 "", /* 125 */
217 "", /* 126 */
218 "", /* 127 */
219 "wel", /* 128 Welsh */
220 "baq", /* 129 Basque */
221 "cat", /* 130 Catalan */
222 "lat", /* 131 Latin */
223 "que", /* 132 Quechua */
224 "grn", /* 133 Guarani */
225 "aym", /* 134 Aymara */
226 "tat", /* 135 Tatar */
227 "uig", /* 136 Uighur */
228 "dzo", /* 137 Dzongkha */
229 "jav", /* 138 JavaneseRom */
230 };
231
232 260 int ff_mov_iso639_to_lang(const char lang[4], int mp4)
233 {
234 260 int i, code = 0;
235
236 /* old way, only for QT? */
237
5/6
✓ Branch 0 taken 19442 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19330 times.
✓ Branch 3 taken 112 times.
✓ Branch 4 taken 19192 times.
✓ Branch 5 taken 138 times.
19442 for (i = 0; lang[0] && !mp4 && i < FF_ARRAY_ELEMS(mov_mdhd_language_map); i++) {
238
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 19182 times.
19192 if (!strcmp(lang, mov_mdhd_language_map[i]))
239 10 return i;
240 }
241 /* XXX:can we do that in mov too? */
242
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 112 times.
250 if (!mp4)
243 138 return -1;
244 /* handle undefined as such */
245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
112 if (lang[0] == '\0')
246 lang = "und";
247 /* 5 bits ASCII */
248
2/2
✓ Branch 0 taken 336 times.
✓ Branch 1 taken 112 times.
448 for (i = 0; i < 3; i++) {
249 336 uint8_t c = lang[i];
250 336 c -= 0x60;
251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 336 times.
336 if (c > 0x1f)
252 return -1;
253 336 code <<= 5;
254 336 code |= c;
255 }
256 112 return code;
257 }
258
259 622 int ff_mov_lang_to_iso639(unsigned code, char to[4])
260 {
261 int i;
262 622 memset(to, 0, 4);
263 /* is it the mangled iso code? */
264 /* see http://www.geocities.com/xhelmboyx/quicktime/formats/mp4-layout.txt */
265
4/4
✓ Branch 0 taken 417 times.
✓ Branch 1 taken 205 times.
✓ Branch 2 taken 265 times.
✓ Branch 3 taken 152 times.
622 if (code >= 0x400 && code != 0x7fff) {
266
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 265 times.
1060 for (i = 2; i >= 0; i--) {
267 795 to[i] = 0x60 + (code & 0x1f);
268 795 code >>= 5;
269 }
270 265 return 1;
271 }
272 /* old fashion apple lang code */
273
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 205 times.
357 if (code >= FF_ARRAY_ELEMS(mov_mdhd_language_map))
274 152 return 0;
275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if (!mov_mdhd_language_map[code][0])
276 return 0;
277 205 memcpy(to, mov_mdhd_language_map[code], 4);
278 205 return 1;
279 }
280
281 966 int ff_mp4_read_descr_len(AVIOContext *pb)
282 {
283 966 int len = 0;
284 966 int count = 4;
285
1/2
✓ Branch 0 taken 2339 times.
✗ Branch 1 not taken.
2339 while (count--) {
286 2339 int c = avio_r8(pb);
287 2339 len = (len << 7) | (c & 0x7f);
288
2/2
✓ Branch 0 taken 966 times.
✓ Branch 1 taken 1373 times.
2339 if (!(c & 0x80))
289 966 break;
290 }
291 966 return len;
292 }
293
294 426 int ff_mp4_read_descr(AVFormatContext *fc, AVIOContext *pb, int *tag)
295 {
296 int len;
297 426 *tag = avio_r8(pb);
298 426 len = ff_mp4_read_descr_len(pb);
299 426 av_log(fc, AV_LOG_TRACE, "MPEG-4 description: tag=0x%02x len=%d\n", *tag, len);
300 426 return len;
301 }
302
303 142 void ff_mp4_parse_es_descr(AVIOContext *pb, int *es_id)
304 {
305 int flags;
306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 if (es_id) *es_id = avio_rb16(pb);
307 142 else avio_rb16(pb);
308 142 flags = avio_r8(pb);
309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 if (flags & 0x80) //streamDependenceFlag
310 avio_rb16(pb);
311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 if (flags & 0x40) { //URL_Flag
312 int len = avio_r8(pb);
313 avio_skip(pb, len);
314 }
315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 if (flags & 0x20) //OCRstreamFlag
316 avio_rb16(pb);
317 142 }
318
319 static const AVCodecTag mp4_audio_types[] = {
320 { AV_CODEC_ID_MP3ON4, AOT_PS }, /* old mp3on4 draft */
321 { AV_CODEC_ID_MP3ON4, AOT_L1 }, /* layer 1 */
322 { AV_CODEC_ID_MP3ON4, AOT_L2 }, /* layer 2 */
323 { AV_CODEC_ID_MP3ON4, AOT_L3 }, /* layer 3 */
324 { AV_CODEC_ID_MP4ALS, AOT_ALS }, /* MPEG-4 ALS */
325 { AV_CODEC_ID_NONE, AOT_NULL },
326 };
327
328 142 int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext *pb)
329 {
330 enum AVCodecID codec_id;
331 int len, tag;
332 int ret;
333 142 int object_type_id = avio_r8(pb);
334 142 avio_r8(pb); /* stream type */
335 142 avio_rb24(pb); /* buffer size db */
336 142 avio_rb32(pb); /* rc_max_rate */
337
338 142 st->codecpar->bit_rate = avio_rb32(pb); /* avg bitrate */
339
340 142 codec_id= ff_codec_get_id(ff_mp4_obj_type, object_type_id);
341
1/2
✓ Branch 0 taken 142 times.
✗ Branch 1 not taken.
142 if (codec_id)
342 142 st->codecpar->codec_id = codec_id;
343 142 av_log(fc, AV_LOG_TRACE, "esds object type id 0x%02x\n", object_type_id);
344 142 len = ff_mp4_read_descr(fc, pb, &tag);
345
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1 times.
142 if (tag == MP4DecSpecificDescrTag) {
346 141 av_log(fc, AV_LOG_TRACE, "Specific MPEG-4 header len=%d\n", len);
347 /* As per 14496-3:2009 9.D.2.2, No decSpecificInfo is defined
348 for MPEG-1 Audio or MPEG-2 Audio; MPEG-2 AAC excluded. */
349
2/4
✓ Branch 0 taken 141 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 141 times.
141 if (object_type_id == 0x69 || object_type_id == 0x6b)
350 return 0;
351
2/4
✓ Branch 0 taken 141 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 141 times.
141 if (!len || (uint64_t)len > (1<<30))
352 return AVERROR_INVALIDDATA;
353
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 141 times.
141 if ((ret = ff_get_extradata(fc, st->codecpar, pb, len)) < 0)
354 return ret;
355
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 21 times.
141 if (st->codecpar->codec_id == AV_CODEC_ID_AAC) {
356 120 MPEG4AudioConfig cfg = {0};
357 120 ret = avpriv_mpeg4audio_get_config2(&cfg, st->codecpar->extradata,
358 120 st->codecpar->extradata_size, 1, fc);
359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if (ret < 0)
360 return ret;
361 120 st->codecpar->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;
362 120 st->codecpar->ch_layout.nb_channels = cfg.channels;
363
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
120 if (cfg.object_type == 29 && cfg.sampling_index < 3) // old mp3on4
364 st->codecpar->sample_rate = ff_mpa_freq_tab[cfg.sampling_index];
365
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 92 times.
120 else if (cfg.ext_sample_rate)
366 28 st->codecpar->sample_rate = cfg.ext_sample_rate;
367 else
368 92 st->codecpar->sample_rate = cfg.sample_rate;
369 120 av_log(fc, AV_LOG_TRACE, "mp4a config channels %d obj %d ext obj %d "
370 "sample rate %d ext sample rate %d\n", cfg.channels,
371 cfg.object_type, cfg.ext_object_type,
372 cfg.sample_rate, cfg.ext_sample_rate);
373
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 7 times.
120 if (!(st->codecpar->codec_id = ff_codec_get_id(mp4_audio_types,
374 120 cfg.object_type)))
375 113 st->codecpar->codec_id = AV_CODEC_ID_AAC;
376 }
377 }
378 142 return 0;
379 }
380
381 typedef struct MovChannelLayout {
382 int64_t channel_layout;
383 uint32_t layout_tag;
384 } MovChannelLayout;
385
386 static const MovChannelLayout mov_channel_layout[] = {
387 { AV_CH_LAYOUT_MONO, (100<<16) | 1}, // kCAFChannelLayoutTag_Mono
388 { AV_CH_LAYOUT_STEREO, (101<<16) | 2}, // kCAFChannelLayoutTag_Stereo
389 { AV_CH_LAYOUT_STEREO, (102<<16) | 2}, // kCAFChannelLayoutTag_StereoHeadphones
390 { AV_CH_LAYOUT_2_1, (131<<16) | 3}, // kCAFChannelLayoutTag_ITU_2_1
391 { AV_CH_LAYOUT_QUAD, (132<<16) | 4}, // kCAFChannelLayoutTag_ITU_2_2
392 { AV_CH_LAYOUT_2_2, (132<<16) | 4}, // kCAFChannelLayoutTag_ITU_2_2
393 { AV_CH_LAYOUT_QUAD, (108<<16) | 4}, // kCAFChannelLayoutTag_Quadraphonic
394 { AV_CH_LAYOUT_SURROUND, (113<<16) | 3}, // kCAFChannelLayoutTag_MPEG_3_0_A
395 { AV_CH_LAYOUT_4POINT0, (115<<16) | 4}, // kCAFChannelLayoutTag_MPEG_4_0_A
396 { AV_CH_LAYOUT_5POINT0_BACK, (117<<16) | 5}, // kCAFChannelLayoutTag_MPEG_5_0_A
397 { AV_CH_LAYOUT_5POINT0, (117<<16) | 5}, // kCAFChannelLayoutTag_MPEG_5_0_A
398 { AV_CH_LAYOUT_5POINT1_BACK, (121<<16) | 6}, // kCAFChannelLayoutTag_MPEG_5_1_A
399 { AV_CH_LAYOUT_5POINT1, (121<<16) | 6}, // kCAFChannelLayoutTag_MPEG_5_1_A
400 { AV_CH_LAYOUT_7POINT1, (128<<16) | 8}, // kCAFChannelLayoutTag_MPEG_7_1_C
401 { AV_CH_LAYOUT_7POINT1_WIDE, (126<<16) | 8}, // kCAFChannelLayoutTag_MPEG_7_1_A
402 { AV_CH_LAYOUT_5POINT1_BACK|AV_CH_LAYOUT_STEREO_DOWNMIX, (130<<16) | 8}, // kCAFChannelLayoutTag_SMPTE_DTV
403 { AV_CH_LAYOUT_STEREO|AV_CH_LOW_FREQUENCY, (133<<16) | 3}, // kCAFChannelLayoutTag_DVD_4
404 { AV_CH_LAYOUT_2_1|AV_CH_LOW_FREQUENCY, (134<<16) | 4}, // kCAFChannelLayoutTag_DVD_5
405 { AV_CH_LAYOUT_QUAD|AV_CH_LOW_FREQUENCY, (135<<16) | 4}, // kCAFChannelLayoutTag_DVD_6
406 { AV_CH_LAYOUT_2_2|AV_CH_LOW_FREQUENCY, (135<<16) | 4}, // kCAFChannelLayoutTag_DVD_6
407 { AV_CH_LAYOUT_SURROUND|AV_CH_LOW_FREQUENCY, (136<<16) | 4}, // kCAFChannelLayoutTag_DVD_10
408 { AV_CH_LAYOUT_4POINT0|AV_CH_LOW_FREQUENCY, (137<<16) | 5}, // kCAFChannelLayoutTag_DVD_11
409 { 0, 0},
410 };
411
412 8 void ff_mov_write_chan(AVIOContext *pb, int64_t channel_layout)
413 {
414 const MovChannelLayout *layouts;
415 8 uint32_t layout_tag = 0;
416
417
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1 times.
34 for (layouts = mov_channel_layout; layouts->channel_layout; layouts++)
418
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 26 times.
33 if (channel_layout == layouts->channel_layout) {
419 7 layout_tag = layouts->layout_tag;
420 7 break;
421 }
422
423
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
8 if (layout_tag) {
424 7 avio_wb32(pb, layout_tag); // mChannelLayoutTag
425 7 avio_wb32(pb, 0); // mChannelBitmap
426 } else {
427 1 avio_wb32(pb, 0x10000); // kCAFChannelLayoutTag_UseChannelBitmap
428 1 avio_wb32(pb, channel_layout);
429 }
430 8 avio_wb32(pb, 0); // mNumberChannelDescriptions
431 8 }
432
433 static const struct MP4TrackKindValueMapping dash_role_map[] = {
434 { AV_DISPOSITION_HEARING_IMPAIRED|AV_DISPOSITION_CAPTIONS,
435 "caption" },
436 { AV_DISPOSITION_COMMENT,
437 "commentary" },
438 { AV_DISPOSITION_VISUAL_IMPAIRED|AV_DISPOSITION_DESCRIPTIONS,
439 "description" },
440 { AV_DISPOSITION_DUB,
441 "dub" },
442 { AV_DISPOSITION_FORCED,
443 "forced-subtitle" },
444 { 0, NULL }
445 };
446
447 const struct MP4TrackKindMapping ff_mov_track_kind_table[] = {
448 { "urn:mpeg:dash:role:2011", dash_role_map },
449 { 0, NULL }
450 };
451