annotate libmpdemux/parse_mp4.h @ 32676:db882cd69776

Do not #define _WIN32 on the command line for Cygwin. Newer Cygwin versions no longer do this and hopefully we should be able to survive without this hack as well. This change necessitates adapting two #ifdefs in the MPlayer codebase. It is committed untested as I do not have access to a Cygwin system.
author diego
date Thu, 06 Jan 2011 12:42:59 +0000
parents 32725ca88fed
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28106
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 26029
diff changeset
1 /*
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 26029
diff changeset
2 * MP4 file format parser code
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 26029
diff changeset
3 *
28110
fc04fa771074 license header consistency cosmetics
diego
parents: 28106
diff changeset
4 * Copyright (C) 2002 Felix Buenemann <atmosfear at users.sourceforge.net>
28106
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 26029
diff changeset
5 * Code inspired by libmp4 from http://mpeg4ip.sourceforge.net/.
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 26029
diff changeset
6 *
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 26029
diff changeset
7 * This file is part of MPlayer.
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 26029
diff changeset
8 *
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 26029
diff changeset
9 * MPlayer is free software; you can redistribute it and/or modify
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 26029
diff changeset
10 * it under the terms of the GNU General Public License as published by
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 26029
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 26029
diff changeset
12 * (at your option) any later version.
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 26029
diff changeset
13 *
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 26029
diff changeset
14 * MPlayer is distributed in the hope that it will be useful,
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 26029
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 26029
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 26029
diff changeset
17 * GNU General Public License for more details.
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 26029
diff changeset
18 *
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 26029
diff changeset
19 * You should have received a copy of the GNU General Public License along
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 26029
diff changeset
20 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 26029
diff changeset
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
5301
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
22 */
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
23
26029
4129c8cfa742 Add MPLAYER_ prefix to multiple inclusion guards.
diego
parents: 25546
diff changeset
24 #ifndef MPLAYER_PARSE_MP4_H
4129c8cfa742 Add MPLAYER_ prefix to multiple inclusion guards.
diego
parents: 25546
diff changeset
25 #define MPLAYER_PARSE_MP4_H
5301
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
26
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
27 #include <inttypes.h>
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
28
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
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
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
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
2e3981fa938c Add support for 13k Voice (Qclp) in 3g2 files
rtogni
parents: 18666
diff changeset
79 /* 3GPP2 */
2e3981fa938c Add support for 13k Voice (Qclp) in 3g2 files
rtogni
parents: 18666
diff changeset
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
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
82 /* I define uint24 here for better understanding */
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
83 #ifndef uint24_t
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
84 #define uint24_t uint32_t
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
85 #endif
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
86
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
87 /* esds_t */
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
88 typedef struct {
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
89 uint8_t version;
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
90 uint24_t flags;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28110
diff changeset
91
5301
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
92 /* 0x03 ESDescrTag */
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
93 uint16_t ESId;
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
94 uint8_t streamPriority;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28110
diff changeset
95
5301
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
96 /* 0x04 DecConfigDescrTag */
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
97 uint8_t objectTypeId;
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
98 uint8_t streamType;
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
99 /* XXX: really streamType is
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
100 * only 6bit, followed by:
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
101 * 1bit upStream
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
102 * 1bit reserved
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28110
diff changeset
103 */
5301
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
104 uint24_t bufferSizeDB;
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
105 uint32_t maxBitrate;
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
106 uint32_t avgBitrate;
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
107
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
108 /* 0x05 DecSpecificDescrTag */
18666
492c6d674c3e decoderConfigLen can be larger than 255 bytes
nicodvb
parents: 13954
diff changeset
109 uint16_t decoderConfigLen;
5301
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
110 uint8_t *decoderConfig;
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
111
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
112 /* 0x06 SLConfigDescrTag */
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
113 uint8_t SLConfigLen;
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
114 uint8_t *SLConfig;
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
115
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
116 /* TODO: add the missing tags,
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
117 * I currently have no specs
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
118 * for them and doubt they
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
119 * are currently needed ::atmos
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
120 */
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28110
diff changeset
121
5301
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
122 } esds_t;
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
123
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
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
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
126
26029
4129c8cfa742 Add MPLAYER_ prefix to multiple inclusion guards.
diego
parents: 25546
diff changeset
127 #endif /* MPLAYER_PARSE_MP4_H */