Mercurial > mplayer.hg
annotate libmpdemux/parse_mp4.h @ 34355:316f6edb49de
Avoid double conversion from utf16/ucs2 to utf8 for text subtitles.
There is code that auto-detects utf16 encoding of the subtitle stream
and forces the reading functions to convert it to native utf8.
The bug happens when using enca to (correctly) guess that the input
file has ucs2 encoding and tries to convert the input stream to utf8, again.
In my case iconv did not accept the input and discarded the subtitles
completely.
author | iive |
---|---|
date | Wed, 14 Dec 2011 00:17:49 +0000 |
parents | 32725ca88fed |
children |
rev | line source |
---|---|
28106 | 1 /* |
2 * MP4 file format parser code | |
3 * | |
28110 | 4 * Copyright (C) 2002 Felix Buenemann <atmosfear at users.sourceforge.net> |
28106 | 5 * Code inspired by libmp4 from http://mpeg4ip.sourceforge.net/. |
6 * | |
7 * This file is part of MPlayer. | |
8 * | |
9 * MPlayer is free software; you can redistribute it and/or modify | |
10 * it under the terms of the GNU General Public License as published by | |
11 * the Free Software Foundation; either version 2 of the License, or | |
12 * (at your option) any later version. | |
13 * | |
14 * MPlayer 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 | |
17 * GNU General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License along | |
20 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
5301 | 22 */ |
23 | |
26029 | 24 #ifndef MPLAYER_PARSE_MP4_H |
25 #define MPLAYER_PARSE_MP4_H | |
5301 | 26 |
27 #include <inttypes.h> | |
28 | |
29 /* one byte tag identifiers */ | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28110
diff
changeset
|
30 #define MP4ODescrTag 0x01 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28110
diff
changeset
|
31 #define MP4IODescrTag 0x02 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28110
diff
changeset
|
32 #define MP4ESDescrTag 0x03 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28110
diff
changeset
|
33 #define MP4DecConfigDescrTag 0x04 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28110
diff
changeset
|
34 #define MP4DecSpecificDescrTag 0x05 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28110
diff
changeset
|
35 #define MP4SLConfigDescrTag 0x06 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28110
diff
changeset
|
36 #define MP4ContentIdDescrTag 0x07 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28110
diff
changeset
|
37 #define MP4SupplContentIdDescrTag 0x08 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28110
diff
changeset
|
38 #define MP4IPIPtrDescrTag 0x09 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28110
diff
changeset
|
39 #define MP4IPMPPtrDescrTag 0x0A |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28110
diff
changeset
|
40 #define MP4IPMPDescrTag 0x0B |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28110
diff
changeset
|
41 #define MP4RegistrationDescrTag 0x0D |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28110
diff
changeset
|
42 #define MP4ESIDIncDescrTag 0x0E |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28110
diff
changeset
|
43 #define MP4ESIDRefDescrTag 0x0F |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28110
diff
changeset
|
44 #define MP4FileIODescrTag 0x10 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28110
diff
changeset
|
45 #define MP4FileODescrTag 0x11 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28110
diff
changeset
|
46 #define MP4ExtProfileLevelDescrTag 0x13 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28110
diff
changeset
|
47 #define MP4ExtDescrTagsStart 0x80 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28110
diff
changeset
|
48 #define MP4ExtDescrTagsEnd 0xFE |
5301 | 49 |
13954
7dfda76015c8
Extended support for other object type IDs in the ESDS. This enables e.g. MPEG2 video in the MP4 container.
mosu
parents:
5305
diff
changeset
|
50 /* object type identifiers in the ESDS */ |
7dfda76015c8
Extended support for other object type IDs in the ESDS. This enables e.g. MPEG2 video in the MP4 container.
mosu
parents:
5305
diff
changeset
|
51 /* See http://gpac.sourceforge.net/tutorial/mediatypes.htm */ |
7dfda76015c8
Extended support for other object type IDs in the ESDS. This enables e.g. MPEG2 video in the MP4 container.
mosu
parents:
5305
diff
changeset
|
52 /* BIFS stream version 1 */ |
7dfda76015c8
Extended support for other object type IDs in the ESDS. This enables e.g. MPEG2 video in the MP4 container.
mosu
parents:
5305
diff
changeset
|
53 #define MP4OTI_MPEG4Systems1 0x01 |
7dfda76015c8
Extended support for other object type IDs in the ESDS. This enables e.g. MPEG2 video in the MP4 container.
mosu
parents:
5305
diff
changeset
|
54 /* BIFS stream version 2 */ |
7dfda76015c8
Extended support for other object type IDs in the ESDS. This enables e.g. MPEG2 video in the MP4 container.
mosu
parents:
5305
diff
changeset
|
55 #define MP4OTI_MPEG4Systems2 0x02 |
7dfda76015c8
Extended support for other object type IDs in the ESDS. This enables e.g. MPEG2 video in the MP4 container.
mosu
parents:
5305
diff
changeset
|
56 /* MPEG-4 visual stream */ |
7dfda76015c8
Extended support for other object type IDs in the ESDS. This enables e.g. MPEG2 video in the MP4 container.
mosu
parents:
5305
diff
changeset
|
57 #define MP4OTI_MPEG4Visual 0x20 |
7dfda76015c8
Extended support for other object type IDs in the ESDS. This enables e.g. MPEG2 video in the MP4 container.
mosu
parents:
5305
diff
changeset
|
58 /* MPEG-4 audio stream */ |
7dfda76015c8
Extended support for other object type IDs in the ESDS. This enables e.g. MPEG2 video in the MP4 container.
mosu
parents:
5305
diff
changeset
|
59 #define MP4OTI_MPEG4Audio 0x40 |
7dfda76015c8
Extended support for other object type IDs in the ESDS. This enables e.g. MPEG2 video in the MP4 container.
mosu
parents:
5305
diff
changeset
|
60 /* MPEG-2 visual streams with various profiles */ |
7dfda76015c8
Extended support for other object type IDs in the ESDS. This enables e.g. MPEG2 video in the MP4 container.
mosu
parents:
5305
diff
changeset
|
61 #define MP4OTI_MPEG2VisualSimple 0x60 |
7dfda76015c8
Extended support for other object type IDs in the ESDS. This enables e.g. MPEG2 video in the MP4 container.
mosu
parents:
5305
diff
changeset
|
62 #define MP4OTI_MPEG2VisualMain 0x61 |
7dfda76015c8
Extended support for other object type IDs in the ESDS. This enables e.g. MPEG2 video in the MP4 container.
mosu
parents:
5305
diff
changeset
|
63 #define MP4OTI_MPEG2VisualSNR 0x62 |
7dfda76015c8
Extended support for other object type IDs in the ESDS. This enables e.g. MPEG2 video in the MP4 container.
mosu
parents:
5305
diff
changeset
|
64 #define MP4OTI_MPEG2VisualSpatial 0x63 |
7dfda76015c8
Extended support for other object type IDs in the ESDS. This enables e.g. MPEG2 video in the MP4 container.
mosu
parents:
5305
diff
changeset
|
65 #define MP4OTI_MPEG2VisualHigh 0x64 |
7dfda76015c8
Extended support for other object type IDs in the ESDS. This enables e.g. MPEG2 video in the MP4 container.
mosu
parents:
5305
diff
changeset
|
66 #define MP4OTI_MPEG2Visual422 0x65 |
7dfda76015c8
Extended support for other object type IDs in the ESDS. This enables e.g. MPEG2 video in the MP4 container.
mosu
parents:
5305
diff
changeset
|
67 /* MPEG-2 audio stream part 7 ("AAC") with various profiles */ |
7dfda76015c8
Extended support for other object type IDs in the ESDS. This enables e.g. MPEG2 video in the MP4 container.
mosu
parents:
5305
diff
changeset
|
68 #define MP4OTI_MPEG2AudioMain 0x66 |
7dfda76015c8
Extended support for other object type IDs in the ESDS. This enables e.g. MPEG2 video in the MP4 container.
mosu
parents:
5305
diff
changeset
|
69 #define MP4OTI_MPEG2AudioLowComplexity 0x67 |
7dfda76015c8
Extended support for other object type IDs in the ESDS. This enables e.g. MPEG2 video in the MP4 container.
mosu
parents:
5305
diff
changeset
|
70 #define MP4OTI_MPEG2AudioScaleableSamplingRate 0x68 |
7dfda76015c8
Extended support for other object type IDs in the ESDS. This enables e.g. MPEG2 video in the MP4 container.
mosu
parents:
5305
diff
changeset
|
71 /* MPEG-2 audio part 3 ("MP3") */ |
7dfda76015c8
Extended support for other object type IDs in the ESDS. This enables e.g. MPEG2 video in the MP4 container.
mosu
parents:
5305
diff
changeset
|
72 #define MP4OTI_MPEG2AudioPart3 0x69 |
7dfda76015c8
Extended support for other object type IDs in the ESDS. This enables e.g. MPEG2 video in the MP4 container.
mosu
parents:
5305
diff
changeset
|
73 /* MPEG-1 visual visual stream */ |
7dfda76015c8
Extended support for other object type IDs in the ESDS. This enables e.g. MPEG2 video in the MP4 container.
mosu
parents:
5305
diff
changeset
|
74 #define MP4OTI_MPEG1Visual 0x6A |
7dfda76015c8
Extended support for other object type IDs in the ESDS. This enables e.g. MPEG2 video in the MP4 container.
mosu
parents:
5305
diff
changeset
|
75 /* MPEG-1 audio stream part 3 ("MP3") */ |
7dfda76015c8
Extended support for other object type IDs in the ESDS. This enables e.g. MPEG2 video in the MP4 container.
mosu
parents:
5305
diff
changeset
|
76 #define MP4OTI_MPEG1Audio 0x6B |
7dfda76015c8
Extended support for other object type IDs in the ESDS. This enables e.g. MPEG2 video in the MP4 container.
mosu
parents:
5305
diff
changeset
|
77 /* JPEG visual stream */ |
7dfda76015c8
Extended support for other object type IDs in the ESDS. This enables e.g. MPEG2 video in the MP4 container.
mosu
parents:
5305
diff
changeset
|
78 #define MP4OTI_JPEG 0x6C |
19363 | 79 /* 3GPP2 */ |
80 #define MP4OTI_13kVoice 0xE1 | |
13954
7dfda76015c8
Extended support for other object type IDs in the ESDS. This enables e.g. MPEG2 video in the MP4 container.
mosu
parents:
5305
diff
changeset
|
81 |
5301 | 82 /* I define uint24 here for better understanding */ |
83 #ifndef uint24_t | |
84 #define uint24_t uint32_t | |
85 #endif | |
86 | |
87 /* esds_t */ | |
88 typedef struct { | |
89 uint8_t version; | |
90 uint24_t flags; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28110
diff
changeset
|
91 |
5301 | 92 /* 0x03 ESDescrTag */ |
93 uint16_t ESId; | |
94 uint8_t streamPriority; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28110
diff
changeset
|
95 |
5301 | 96 /* 0x04 DecConfigDescrTag */ |
97 uint8_t objectTypeId; | |
98 uint8_t streamType; | |
99 /* XXX: really streamType is | |
100 * only 6bit, followed by: | |
101 * 1bit upStream | |
102 * 1bit reserved | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28110
diff
changeset
|
103 */ |
5301 | 104 uint24_t bufferSizeDB; |
105 uint32_t maxBitrate; | |
106 uint32_t avgBitrate; | |
107 | |
108 /* 0x05 DecSpecificDescrTag */ | |
18666 | 109 uint16_t decoderConfigLen; |
5301 | 110 uint8_t *decoderConfig; |
111 | |
112 /* 0x06 SLConfigDescrTag */ | |
113 uint8_t SLConfigLen; | |
114 uint8_t *SLConfig; | |
115 | |
116 /* TODO: add the missing tags, | |
117 * I currently have no specs | |
118 * for them and doubt they | |
119 * are currently needed ::atmos | |
120 */ | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28110
diff
changeset
|
121 |
5301 | 122 } esds_t; |
123 | |
124 int mp4_parse_esds(unsigned char *data, int datalen, esds_t *esds); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28110
diff
changeset
|
125 void mp4_free_esds(esds_t *esds); |
5301 | 126 |
26029 | 127 #endif /* MPLAYER_PARSE_MP4_H */ |