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
31
32 /* http://www.mp4ra.org */
33 /* ordered by muxing preference */
64 {
AV_CODEC_ID_FLAC , 0xC1 },
/* nonstandard, update when there is a standard value */
73 };
74
80 };
81
85 };
86
87 /* map numeric codes from mdhd atom to ISO 639 */
88 /* cf. QTFileFormat.pdf p253, qtff.pdf p205 */
89 /* http://developer.apple.com/documentation/mac/Text/Text-368.html */
90 /* deprecated by putting the code as 3*5 bits ASCII */
92 "eng", /* 0 English */
93 "fra", /* 1 French */
94 "ger", /* 2 German */
95 "ita", /* 3 Italian */
96 "dut", /* 4 Dutch */
97 "sve", /* 5 Swedish */
98 "spa", /* 6 Spanish */
99 "dan", /* 7 Danish */
100 "por", /* 8 Portuguese */
101 "nor", /* 9 Norwegian */
102 "heb", /* 10 Hebrew */
103 "jpn", /* 11 Japanese */
104 "ara", /* 12 Arabic */
105 "fin", /* 13 Finnish */
106 "gre", /* 14 Greek */
107 "ice", /* 15 Icelandic */
108 "mlt", /* 16 Maltese */
109 "tur", /* 17 Turkish */
110 "hr ", /* 18 Croatian */
111 "chi", /* 19 Traditional Chinese */
112 "urd", /* 20 Urdu */
113 "hin", /* 21 Hindi */
114 "tha", /* 22 Thai */
115 "kor", /* 23 Korean */
116 "lit", /* 24 Lithuanian */
117 "pol", /* 25 Polish */
118 "hun", /* 26 Hungarian */
119 "est", /* 27 Estonian */
120 "lav", /* 28 Latvian */
121 "smi", /* 29 Sami */
122 "fo ", /* 30 Faroese */
123 "per", /* 31 Farsi */
124 "rus", /* 32 Russian */
125 "chi", /* 33 Simplified Chinese */
126 "", /* 34 Flemish */
127 "iri", /* 35 Irish */
128 "alb", /* 36 Albanian */
129 "ron", /* 37 Romanian */
130 "ces", /* 38 Czech */
131 "slk", /* 39 Slovak */
132 "slv", /* 40 Slovenian */
133 "yid", /* 41 Yiddish */
134 "sr ", /* 42 Serbian */
135 "mac", /* 43 Macedonian */
136 "bul", /* 44 Bulgarian */
137 "ukr", /* 45 Ukrainian */
138 "bel", /* 46 Belarusian */
139 "uzb", /* 47 Uzbek */
140 "kaz", /* 48 Kazakh */
141 "aze", /* 49 Azerbaijani */
142 "aze", /* 50 AzerbaijanAr */
143 "arm", /* 51 Armenian */
144 "geo", /* 52 Georgian */
145 "mol", /* 53 Moldavian */
146 "kir", /* 54 Kirghiz */
147 "tgk", /* 55 Tajiki */
148 "tuk", /* 56 Turkmen */
149 "mon", /* 57 Mongolian */
150 "", /* 58 MongolianCyr */
151 "pus", /* 59 Pashto */
152 "kur", /* 60 Kurdish */
153 "kas", /* 61 Kashmiri */
154 "snd", /* 62 Sindhi */
155 "tib", /* 63 Tibetan */
156 "nep", /* 64 Nepali */
157 "san", /* 65 Sanskrit */
158 "mar", /* 66 Marathi */
159 "ben", /* 67 Bengali */
160 "asm", /* 68 Assamese */
161 "guj", /* 69 Gujarati */
162 "pa ", /* 70 Punjabi */
163 "ori", /* 71 Oriya */
164 "mal", /* 72 Malayalam */
165 "kan", /* 73 Kannada */
166 "tam", /* 74 Tamil */
167 "tel", /* 75 Telugu */
168 "sin", /* 76 Sinhala */
169 "bur", /* 77 Burmese */
170 "khm", /* 78 Khmer */
171 "lao", /* 79 Lao */
172 "vie", /* 80 Vietnamese */
173 "ind", /* 81 Indonesian */
174 "tgl", /* 82 Tagalog */
175 "may", /* 83 MalayRoman */
176 "may", /* 84 MalayArabic */
177 "amh", /* 85 Amharic */
178 "tir", /* 86 Galla */
179 "orm", /* 87 Oromo */
180 "som", /* 88 Somali */
181 "swa", /* 89 Swahili */
182 "kin", /* 90 Kinyarwanda */
183 "run", /* 91 Rundi */
184 "nya", /* 92 Nyanja */
185 "mlg", /* 93 Malagasy */
186 "epo", /* 94 Esperanto */
187 "", /* 95 */
188 "", /* 96 */
189 "", /* 97 */
190 "", /* 98 */
191 "", /* 99 */
192 "", /* 100 */
193 "", /* 101 */
194 "", /* 102 */
195 "", /* 103 */
196 "", /* 104 */
197 "", /* 105 */
198 "", /* 106 */
199 "", /* 107 */
200 "", /* 108 */
201 "", /* 109 */
202 "", /* 110 */
203 "", /* 111 */
204 "", /* 112 */
205 "", /* 113 */
206 "", /* 114 */
207 "", /* 115 */
208 "", /* 116 */
209 "", /* 117 */
210 "", /* 118 */
211 "", /* 119 */
212 "", /* 120 */
213 "", /* 121 */
214 "", /* 122 */
215 "", /* 123 */
216 "", /* 124 */
217 "", /* 125 */
218 "", /* 126 */
219 "", /* 127 */
220 "wel", /* 128 Welsh */
221 "baq", /* 129 Basque */
222 "cat", /* 130 Catalan */
223 "lat", /* 131 Latin */
224 "que", /* 132 Quechua */
225 "grn", /* 133 Guarani */
226 "aym", /* 134 Aymara */
227 "tat", /* 135 Tatar */
228 "uig", /* 136 Uighur */
229 "dzo", /* 137 Dzongkha */
230 "jav", /* 138 JavaneseRom */
231 };
232
234 {
236
237 /* old way, only for QT? */
241 }
242 /* XXX:can we do that in mov too? */
243 if (!mp4)
244 return -1;
245 /* handle undefined as such */
246 if (lang[0] == '0円')
247 lang = "und";
248 /* 5 bits ASCII */
249 for (
i = 0;
i < 3;
i++) {
253 return -1;
256 }
258 }
259
261 {
264 /* is it the mangled iso code? */
265 /* see http://www.geocities.com/xhelmboyx/quicktime/formats/mp4-layout.txt */
266 if (
code >= 0x400 &&
code != 0x7fff) {
267 for (
i = 2;
i >= 0;
i--) {
270 }
271 return 1;
272 }
273 /* old fashion apple lang code */
275 return 0;
277 return 0;
279 return 1;
280 }
281
283 {
285 int count = 4;
286 while (count--) {
290 break;
291 }
293 }
294
296 {
302 }
303
305 {
310 if (
flags & 0x80)
//streamDependenceFlag
312 if (
flags & 0x40) {
//URL_Flag
315 }
316 if (
flags & 0x20)
//OCRstreamFlag
318 }
319
327 };
328
330 {
334 int object_type_id =
avio_r8(pb);
338
340
348 /* As per 14496-3:2009 9.D.2.2, No decSpecificInfo is defined
349 for MPEG-1 Audio or MPEG-2 Audio; MPEG-2 AAC excluded. */
350 if (object_type_id == 0x69 || object_type_id == 0x6b)
351 return 0;
352 if (!
len || (uint64_t)
len > (1<<30))
368 else
371 "sample rate %d ext sample rate %d\n", cfg.
channels,
377 }
378 }
379 return 0;
380 }
381
386
410 { 0, 0},
411 };
412
414 {
416 uint32_t layout_tag = 0;
417
419 if (channel_layout ==
layouts->channel_layout) {
420 layout_tag =
layouts->layout_tag;
421 break;
422 }
423
424 if (layout_tag) {
425 avio_wb32(pb, layout_tag);
// mChannelLayoutTag
427 } else {
428 avio_wb32(pb, 0x10000);
// kCAFChannelLayoutTag_UseChannelBitmap
430 }
431 avio_wb32(pb, 0);
// mNumberChannelDescriptions
432 }
433
436 "caption" },
438 "commentary" },
440 "description" },
442 "dub" },
444 "forced-subtitle" },
446 };
447
451 };