2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #ifndef MPLAYER_EBML_H
20 #define MPLAYER_EBML_H
23 #include "stream/stream.h"
26 /* EBML version supported */
27 #define EBML_VERSION 1
30 * EBML element IDs. max. 32-bit.
33 /* top-level master-IDs */
34 #define EBML_ID_HEADER 0x1A45DFA3
36 /* IDs in the HEADER master */
37 #define EBML_ID_EBMLVERSION 0x4286
38 #define EBML_ID_EBMLREADVERSION 0x42F7
39 #define EBML_ID_EBMLMAXIDLENGTH 0x42F2
40 #define EBML_ID_EBMLMAXSIZELENGTH 0x42F3
41 #define EBML_ID_DOCTYPE 0x4282
42 #define EBML_ID_DOCTYPEVERSION 0x4287
43 #define EBML_ID_DOCTYPEREADVERSION 0x4285
45 /* general EBML types */
46 #define EBML_ID_VOID 0xEC
48 /* ID returned in error cases */
49 #define EBML_ID_INVALID 0xFFFFFFFF
53 * Matroska element IDs. max. 32-bit.
56 /* toplevel segment */
57 #define MATROSKA_ID_SEGMENT 0x18538067
59 /* matroska top-level master IDs */
60 #define MATROSKA_ID_INFO 0x1549A966
61 #define MATROSKA_ID_TRACKS 0x1654AE6B
62 #define MATROSKA_ID_CUES 0x1C53BB6B
63 #define MATROSKA_ID_TAGS 0x1254C367
64 #define MATROSKA_ID_SEEKHEAD 0x114D9B74
65 #define MATROSKA_ID_ATTACHMENTS 0x1941A469
66 #define MATROSKA_ID_CHAPTERS 0x1043A770
67 #define MATROSKA_ID_CLUSTER 0x1F43B675
69 /* IDs in the info master */
70 #define MATROSKA_ID_TIMECODESCALE 0x2AD7B1
71 #define MATROSKA_ID_DURATION 0x4489
72 #define MATROSKA_ID_WRITINGAPP 0x5741
73 #define MATROSKA_ID_MUXINGAPP 0x4D80
74 #define MATROSKA_ID_DATEUTC 0x4461
75 #define MATROSKA_ID_SEGMENTUID 0x73A4
77 /* ID in the tracks master */
78 #define MATROSKA_ID_TRACKENTRY 0xAE
80 /* IDs in the trackentry master */
81 #define MATROSKA_ID_TRACKNUMBER 0xD7
82 #define MATROSKA_ID_TRACKUID 0x73C5
83 #define MATROSKA_ID_TRACKTYPE 0x83
84 #define MATROSKA_ID_TRACKAUDIO 0xE1
85 #define MATROSKA_ID_TRACKVIDEO 0xE0
86 #define MATROSKA_ID_CODECID 0x86
87 #define MATROSKA_ID_CODECPRIVATE 0x63A2
88 #define MATROSKA_ID_CODECNAME 0x258688
89 #define MATROSKA_ID_CODECINFOURL 0x3B4040
90 #define MATROSKA_ID_CODECDOWNLOADURL 0x26B240
91 #define MATROSKA_ID_TRACKNAME 0x536E
92 #define MATROSKA_ID_TRACKLANGUAGE 0x22B59C
93 #define MATROSKA_ID_TRACKFLAGENABLED 0xB9
94 #define MATROSKA_ID_TRACKFLAGDEFAULT 0x88
95 #define MATROSKA_ID_TRACKFLAGLACING 0x9C
96 #define MATROSKA_ID_TRACKMINCACHE 0x6DE7
97 #define MATROSKA_ID_TRACKMAXCACHE 0x6DF8
98 #define MATROSKA_ID_TRACKDEFAULTDURATION 0x23E383
99 #define MATROSKA_ID_TRACKENCODINGS 0x6D80
101 /* IDs in the trackaudio master */
102 #define MATROSKA_ID_AUDIOSAMPLINGFREQ 0xB5
103 #define MATROSKA_ID_AUDIOBITDEPTH 0x6264
104 #define MATROSKA_ID_AUDIOCHANNELS 0x9F
106 /* IDs in the trackvideo master */
107 #define MATROSKA_ID_VIDEOFRAMERATE 0x2383E3
108 #define MATROSKA_ID_VIDEODISPLAYWIDTH 0x54B0
109 #define MATROSKA_ID_VIDEODISPLAYHEIGHT 0x54BA
110 #define MATROSKA_ID_VIDEOPIXELWIDTH 0xB0
111 #define MATROSKA_ID_VIDEOPIXELHEIGHT 0xBA
112 #define MATROSKA_ID_VIDEOFLAGINTERLACED 0x9A
113 #define MATROSKA_ID_VIDEOSTEREOMODE 0x53B9
114 #define MATROSKA_ID_VIDEODISPLAYUNIT 0x54B2
115 #define MATROSKA_ID_VIDEOASPECTRATIO 0x54B3
116 #define MATROSKA_ID_VIDEOCOLOURSPACE 0x2EB524
117 #define MATROSKA_ID_VIDEOGAMMA 0x2FB523
119 /* IDs in the trackencodings master */
120 #define MATROSKA_ID_CONTENTENCODING 0x6240
121 #define MATROSKA_ID_CONTENTENCODINGORDER 0x5031
122 #define MATROSKA_ID_CONTENTENCODINGSCOPE 0x5032
123 #define MATROSKA_ID_CONTENTENCODINGTYPE 0x5033
124 #define MATROSKA_ID_CONTENTCOMPRESSION 0x5034
125 #define MATROSKA_ID_CONTENTCOMPALGO 0x4254
126 #define MATROSKA_ID_CONTENTCOMPSETTINGS 0x4255
128 /* ID in the cues master */
129 #define MATROSKA_ID_POINTENTRY 0xBB
131 /* IDs in the pointentry master */
132 #define MATROSKA_ID_CUETIME 0xB3
133 #define MATROSKA_ID_CUETRACKPOSITION 0xB7
135 /* IDs in the cuetrackposition master */
136 #define MATROSKA_ID_CUETRACK 0xF7
137 #define MATROSKA_ID_CUECLUSTERPOSITION 0xF1
139 /* IDs in the seekhead master */
140 #define MATROSKA_ID_SEEKENTRY 0x4DBB
142 /* IDs in the seekpoint master */
143 #define MATROSKA_ID_SEEKID 0x53AB
144 #define MATROSKA_ID_SEEKPOSITION 0x53AC
146 /* IDs in the chapters master */
147 #define MATROSKA_ID_EDITIONENTRY 0x45B9
148 #define MATROSKA_ID_EDITIONFLAGDEFAULT 0x45DB
149 #define MATROSKA_ID_EDITIONFLAGORDERED 0x45DD
150 #define MATROSKA_ID_CHAPTERATOM 0xB6
151 #define MATROSKA_ID_CHAPTERTIMESTART 0x91
152 #define MATROSKA_ID_CHAPTERTIMEEND 0x92
153 #define MATROSKA_ID_CHAPTERDISPLAY 0x80
154 #define MATROSKA_ID_CHAPSTRING 0x85
155 #define MATROSKA_ID_CHAPTERSEGMENTUID 0x6E67
156 #define MATROSKA_ID_CHAPTERSEGMENTEDITIONUID\
159 /* IDs in the cluster master */
160 #define MATROSKA_ID_CLUSTERTIMECODE 0xE7
161 #define MATROSKA_ID_BLOCKGROUP 0xA0
163 /* IDs in the blockgroup master */
164 #define MATROSKA_ID_BLOCKDURATION 0x9B
165 #define MATROSKA_ID_BLOCK 0xA1
166 #define MATROSKA_ID_SIMPLEBLOCK 0xA3
167 #define MATROSKA_ID_REFERENCEBLOCK 0xFB
169 /* IDs in the attachments master */
170 #define MATROSKA_ID_ATTACHEDFILE 0x61A7
171 #define MATROSKA_ID_FILENAME 0x466E
172 #define MATROSKA_ID_FILEMIMETYPE 0x4660
173 #define MATROSKA_ID_FILEDATA 0x465C
174 #define MATROSKA_ID_FILEUID 0x46AE
176 /* matroska track types */
177 #define MATROSKA_TRACK_VIDEO 0x01 /* rectangle-shaped pictures aka video */
178 #define MATROSKA_TRACK_AUDIO 0x02 /* anything you can hear */
179 #define MATROSKA_TRACK_COMPLEX 0x03 /* audio+video in same track used by DV */
180 #define MATROSKA_TRACK_LOGO 0x10 /* overlay-pictures displayed over video*/
181 #define MATROSKA_TRACK_SUBTITLE 0x11 /* text-subtitles */
182 #define MATROSKA_TRACK_CONTROL 0x20 /* control-codes for menu or other stuff*/
184 /* matroska subtitle types */
185 #define MATROSKA_SUBTYPE_UNKNOWN 0
186 #define MATROSKA_SUBTYPE_TEXT 1
187 #define MATROSKA_SUBTYPE_SSA 2
188 #define MATROSKA_SUBTYPE_VOBSUB 3
191 #define UINT64_MAX 18446744073709551615ULL
195 #define INT64_MAX 9223372036854775807LL
198 #define EBML_UINT_INVALID UINT64_MAX
199 #define EBML_INT_INVALID INT64_MAX
200 #define EBML_FLOAT_INVALID -1000000000.0
203 uint32_t ebml_read_id (stream_t
*s
, int *length
);
204 uint64_t ebml_read_vlen_uint (uint8_t *buffer
, int *length
);
205 int64_t ebml_read_vlen_int (uint8_t *buffer
, int *length
);
206 uint64_t ebml_read_length (stream_t
*s
, int *length
);
207 uint64_t ebml_read_uint (stream_t
*s
, uint64_t *length
);
208 int64_t ebml_read_int (stream_t
*s
, uint64_t *length
);
209 long double ebml_read_float (stream_t
*s
, uint64_t *length
);
210 char *ebml_read_ascii (stream_t
*s
, uint64_t *length
);
211 char *ebml_read_utf8 (stream_t
*s
, uint64_t *length
);
212 int ebml_read_skip (stream_t
*s
, uint64_t *length
);
213 uint32_t ebml_read_master (stream_t
*s
, uint64_t *length
);
214 char *ebml_read_header (stream_t
*s
, int *version
);
216 #endif /* MPLAYER_EBML_H */