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>
7 * This library 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 of the License, or (at your option) any later version.
12 * This library 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.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 /* http://gpac.sourceforge.net/tutorial/mediatypes.htm */
27 const CodecTag ff_mov_obj_type[] = {
28 { CODEC_ID_MPEG4 , 32 },
29 { CODEC_ID_H264 , 33 },
30 { CODEC_ID_AAC , 64 },
31 { CODEC_ID_MPEG2VIDEO, 96 }, /* MPEG2 Simple */
32 { CODEC_ID_MPEG2VIDEO, 97 }, /* MPEG2 Main */
33 { CODEC_ID_MPEG2VIDEO, 98 }, /* MPEG2 SNR */
34 { CODEC_ID_MPEG2VIDEO, 99 }, /* MPEG2 Spatial */
35 { CODEC_ID_MPEG2VIDEO, 100 }, /* MPEG2 High */
36 { CODEC_ID_MPEG2VIDEO, 101 }, /* MPEG2 422 */
37 { CODEC_ID_AAC , 102 }, /* MPEG2 AAC Main */
38 { CODEC_ID_AAC , 103 }, /* MPEG2 AAC Low */
39 { CODEC_ID_AAC , 104 }, /* MPEG2 AAC SSR */
40 { CODEC_ID_MP3 , 105 },
41 { CODEC_ID_MPEG1VIDEO, 106 },
42 { CODEC_ID_MP2 , 107 },
43 { CODEC_ID_MJPEG , 108 },
44 { CODEC_ID_PCM_S16LE , 224 },
45 { CODEC_ID_VORBIS , 221 },
46 { CODEC_ID_QCELP , 225 },
47 { CODEC_ID_AC3 , 226 },
48 { CODEC_ID_PCM_ALAW , 227 },
49 { CODEC_ID_PCM_MULAW , 228 },
50 { CODEC_ID_PCM_S16BE , 230 },
51 { CODEC_ID_H263 , 242 },
52 { CODEC_ID_H261 , 243 },
56 /* map numeric codes from mdhd atom to ISO 639 */
57 /* cf. QTFileFormat.pdf p253, qtff.pdf p205 */
58 /* http://developer.apple.com/documentation/mac/Text/Text-368.html */
59 /* deprecated by putting the code as 3*5bit ascii */
60 static const char *mov_mdhd_language_map[] = {
62 "eng", "fra", "ger", "ita", "dut", "sve", "spa", "dan", "por", "nor",
63 "heb", "jpn", "ara", "fin", "gre", "ice", "mlt", "tur", "hr "/*scr*/, "chi"/*ace?*/,
64 "urd", "hin", "tha", "kor", "lit", "pol", "hun", "est", "lav", NULL,
65 "fo ", NULL, "rus", "chi", NULL, "iri", "alb", "ron", "ces", "slk",
66 "slv", "yid", "sr ", "mac", "bul", "ukr", "bel", "uzb", "kaz", "aze",
68 "aze", "arm", "geo", "mol", "kir", "tgk", "tuk", "mon", NULL, "pus",
69 "kur", "kas", "snd", "tib", "nep", "san", "mar", "ben", "asm", "guj",
70 "pa ", "ori", "mal", "kan", "tam", "tel", NULL, "bur", "khm", "lao",
72 "vie", "ind", "tgl", "may", "may", "amh", "tir", "orm", "som", "swa",
74 NULL, "run", NULL, "mlg", "epo", NULL, NULL, NULL, NULL, NULL,
76 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
77 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
78 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "wel", "baq",
79 "cat", "lat", "que", "grn", "aym", "tat", "uig", "dzo", "jav"
82 int ff_mov_iso639_to_lang(const char *lang, int mp4)
86 /* old way, only for QT? */
87 for (i = 0; !mp4 && (i < (sizeof(mov_mdhd_language_map)/sizeof(char *))); i++) {
88 if (mov_mdhd_language_map[i] && !strcmp(lang, mov_mdhd_language_map[i]))
91 /* XXX:can we do that in mov too? */
94 /* handle undefined as such */
98 for (i = 0; i < 3; i++) {
99 unsigned char c = (unsigned char)lang[i];
110 int ff_mov_lang_to_iso639(int code, char *to)
113 /* is it the mangled iso code? */
114 /* see http://www.geocities.com/xhelmboyx/quicktime/formats/mp4-layout.txt */
116 for (i = 2; i >= 0; i--) {
117 to[i] = 0x60 + (code & 0x1f);
122 /* old fashion apple lang code */
123 if (code >= (sizeof(mov_mdhd_language_map)/sizeof(char *)))
125 if (!mov_mdhd_language_map[code])
127 strncpy(to, mov_mdhd_language_map[code], 4);