• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Matroska constants
3  * Copyright (c) 2003-2004 The FFmpeg project
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg 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.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg 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.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #ifndef AVFORMAT_MATROSKA_H
23 #define AVFORMAT_MATROSKA_H
24 
25 #include "libavcodec/avcodec.h"
26 #include "metadata.h"
27 #include "internal.h"
28 
29 /* EBML version supported */
30 #define EBML_VERSION 1
31 
32 /* top-level master-IDs */
33 #define EBML_ID_HEADER             0x1A45DFA3
34 
35 /* IDs in the HEADER master */
36 #define EBML_ID_EBMLVERSION        0x4286
37 #define EBML_ID_EBMLREADVERSION    0x42F7
38 #define EBML_ID_EBMLMAXIDLENGTH    0x42F2
39 #define EBML_ID_EBMLMAXSIZELENGTH  0x42F3
40 #define EBML_ID_DOCTYPE            0x4282
41 #define EBML_ID_DOCTYPEVERSION     0x4287
42 #define EBML_ID_DOCTYPEREADVERSION 0x4285
43 
44 /* general EBML types */
45 #define EBML_ID_VOID               0xEC
46 #define EBML_ID_CRC32              0xBF
47 
48 /*
49  * Matroska element IDs, max. 32 bits
50  */
51 
52 /* toplevel segment */
53 #define MATROSKA_ID_SEGMENT    0x18538067
54 
55 /* Matroska top-level master IDs */
56 #define MATROSKA_ID_INFO       0x1549A966
57 #define MATROSKA_ID_TRACKS     0x1654AE6B
58 #define MATROSKA_ID_CUES       0x1C53BB6B
59 #define MATROSKA_ID_TAGS       0x1254C367
60 #define MATROSKA_ID_SEEKHEAD   0x114D9B74
61 #define MATROSKA_ID_ATTACHMENTS 0x1941A469
62 #define MATROSKA_ID_CLUSTER    0x1F43B675
63 #define MATROSKA_ID_CHAPTERS   0x1043A770
64 
65 /* IDs in the info master */
66 #define MATROSKA_ID_TIMECODESCALE 0x2AD7B1
67 #define MATROSKA_ID_DURATION   0x4489
68 #define MATROSKA_ID_TITLE      0x7BA9
69 #define MATROSKA_ID_WRITINGAPP 0x5741
70 #define MATROSKA_ID_MUXINGAPP  0x4D80
71 #define MATROSKA_ID_DATEUTC    0x4461
72 #define MATROSKA_ID_SEGMENTUID 0x73A4
73 
74 /* ID in the tracks master */
75 #define MATROSKA_ID_TRACKENTRY 0xAE
76 
77 /* IDs in the trackentry master */
78 #define MATROSKA_ID_TRACKNUMBER 0xD7
79 #define MATROSKA_ID_TRACKUID   0x73C5
80 #define MATROSKA_ID_TRACKTYPE  0x83
81 #define MATROSKA_ID_TRACKVIDEO     0xE0
82 #define MATROSKA_ID_TRACKAUDIO     0xE1
83 #define MATROSKA_ID_TRACKOPERATION 0xE2
84 #define MATROSKA_ID_TRACKCOMBINEPLANES 0xE3
85 #define MATROSKA_ID_TRACKPLANE         0xE4
86 #define MATROSKA_ID_TRACKPLANEUID      0xE5
87 #define MATROSKA_ID_TRACKPLANETYPE     0xE6
88 #define MATROSKA_ID_CODECID    0x86
89 #define MATROSKA_ID_CODECPRIVATE 0x63A2
90 #define MATROSKA_ID_CODECNAME  0x258688
91 #define MATROSKA_ID_CODECINFOURL 0x3B4040
92 #define MATROSKA_ID_CODECDOWNLOADURL 0x26B240
93 #define MATROSKA_ID_CODECDECODEALL 0xAA
94 #define MATROSKA_ID_CODECDELAY 0x56AA
95 #define MATROSKA_ID_SEEKPREROLL 0x56BB
96 #define MATROSKA_ID_TRACKNAME  0x536E
97 #define MATROSKA_ID_TRACKLANGUAGE 0x22B59C
98 #define MATROSKA_ID_TRACKFLAGENABLED 0xB9
99 #define MATROSKA_ID_TRACKFLAGDEFAULT 0x88
100 #define MATROSKA_ID_TRACKFLAGFORCED 0x55AA
101 #define MATROSKA_ID_TRACKFLAGHEARINGIMPAIRED  0x55AB
102 #define MATROSKA_ID_TRACKFLAGVISUALIMPAIRED   0x55AC
103 #define MATROSKA_ID_TRACKFLAGTEXTDESCRIPTIONS 0x55AD
104 #define MATROSKA_ID_TRACKFLAGORIGINAL         0x55AE
105 #define MATROSKA_ID_TRACKFLAGCOMMENTARY       0x55AF
106 #define MATROSKA_ID_TRACKFLAGLACING 0x9C
107 #define MATROSKA_ID_TRACKMINCACHE 0x6DE7
108 #define MATROSKA_ID_TRACKMAXCACHE 0x6DF8
109 #define MATROSKA_ID_TRACKDEFAULTDURATION 0x23E383
110 #define MATROSKA_ID_TRACKCONTENTENCODINGS 0x6D80
111 #define MATROSKA_ID_TRACKCONTENTENCODING 0x6240
112 #define MATROSKA_ID_TRACKTIMECODESCALE 0x23314F
113 #define MATROSKA_ID_TRACKMAXBLKADDID 0x55EE
114 
115 /* IDs in the trackvideo master */
116 #define MATROSKA_ID_VIDEOFRAMERATE 0x2383E3
117 #define MATROSKA_ID_VIDEODISPLAYWIDTH 0x54B0
118 #define MATROSKA_ID_VIDEODISPLAYHEIGHT 0x54BA
119 #define MATROSKA_ID_VIDEOPIXELWIDTH 0xB0
120 #define MATROSKA_ID_VIDEOPIXELHEIGHT 0xBA
121 #define MATROSKA_ID_VIDEOPIXELCROPB 0x54AA
122 #define MATROSKA_ID_VIDEOPIXELCROPT 0x54BB
123 #define MATROSKA_ID_VIDEOPIXELCROPL 0x54CC
124 #define MATROSKA_ID_VIDEOPIXELCROPR 0x54DD
125 #define MATROSKA_ID_VIDEODISPLAYUNIT 0x54B2
126 #define MATROSKA_ID_VIDEOFLAGINTERLACED 0x9A
127 #define MATROSKA_ID_VIDEOFIELDORDER 0x9D
128 #define MATROSKA_ID_VIDEOSTEREOMODE 0x53B8
129 #define MATROSKA_ID_VIDEOALPHAMODE 0x53C0
130 #define MATROSKA_ID_VIDEOASPECTRATIO 0x54B3
131 #define MATROSKA_ID_VIDEOCOLORSPACE 0x2EB524
132 #define MATROSKA_ID_VIDEOCOLOR 0x55B0
133 
134 #define MATROSKA_ID_VIDEOCOLORMATRIXCOEFF 0x55B1
135 #define MATROSKA_ID_VIDEOCOLORBITSPERCHANNEL 0x55B2
136 #define MATROSKA_ID_VIDEOCOLORCHROMASUBHORZ 0x55B3
137 #define MATROSKA_ID_VIDEOCOLORCHROMASUBVERT 0x55B4
138 #define MATROSKA_ID_VIDEOCOLORCBSUBHORZ 0x55B5
139 #define MATROSKA_ID_VIDEOCOLORCBSUBVERT 0x55B6
140 #define MATROSKA_ID_VIDEOCOLORCHROMASITINGHORZ 0x55B7
141 #define MATROSKA_ID_VIDEOCOLORCHROMASITINGVERT 0x55B8
142 #define MATROSKA_ID_VIDEOCOLORRANGE 0x55B9
143 #define MATROSKA_ID_VIDEOCOLORTRANSFERCHARACTERISTICS 0x55BA
144 
145 #define MATROSKA_ID_VIDEOCOLORPRIMARIES 0x55BB
146 #define MATROSKA_ID_VIDEOCOLORMAXCLL 0x55BC
147 #define MATROSKA_ID_VIDEOCOLORMAXFALL 0x55BD
148 
149 #define MATROSKA_ID_VIDEOCOLORMASTERINGMETA 0x55D0
150 #define MATROSKA_ID_VIDEOCOLOR_RX 0x55D1
151 #define MATROSKA_ID_VIDEOCOLOR_RY 0x55D2
152 #define MATROSKA_ID_VIDEOCOLOR_GX 0x55D3
153 #define MATROSKA_ID_VIDEOCOLOR_GY 0x55D4
154 #define MATROSKA_ID_VIDEOCOLOR_BX 0x55D5
155 #define MATROSKA_ID_VIDEOCOLOR_BY 0x55D6
156 #define MATROSKA_ID_VIDEOCOLOR_WHITEX 0x55D7
157 #define MATROSKA_ID_VIDEOCOLOR_WHITEY 0x55D8
158 #define MATROSKA_ID_VIDEOCOLOR_LUMINANCEMAX 0x55D9
159 #define MATROSKA_ID_VIDEOCOLOR_LUMINANCEMIN 0x55DA
160 
161 #define MATROSKA_ID_VIDEOPROJECTION 0x7670
162 #define MATROSKA_ID_VIDEOPROJECTIONTYPE 0x7671
163 #define MATROSKA_ID_VIDEOPROJECTIONPRIVATE 0x7672
164 #define MATROSKA_ID_VIDEOPROJECTIONPOSEYAW 0x7673
165 #define MATROSKA_ID_VIDEOPROJECTIONPOSEPITCH 0x7674
166 #define MATROSKA_ID_VIDEOPROJECTIONPOSEROLL 0x7675
167 
168 /* IDs in the trackaudio master */
169 #define MATROSKA_ID_AUDIOSAMPLINGFREQ 0xB5
170 #define MATROSKA_ID_AUDIOOUTSAMPLINGFREQ 0x78B5
171 
172 #define MATROSKA_ID_AUDIOBITDEPTH 0x6264
173 #define MATROSKA_ID_AUDIOCHANNELS 0x9F
174 
175 /* IDs in the content encoding master */
176 #define MATROSKA_ID_ENCODINGORDER 0x5031
177 #define MATROSKA_ID_ENCODINGSCOPE 0x5032
178 #define MATROSKA_ID_ENCODINGTYPE 0x5033
179 #define MATROSKA_ID_ENCODINGCOMPRESSION 0x5034
180 #define MATROSKA_ID_ENCODINGCOMPALGO 0x4254
181 #define MATROSKA_ID_ENCODINGCOMPSETTINGS 0x4255
182 
183 #define MATROSKA_ID_ENCODINGENCRYPTION 0x5035
184 #define MATROSKA_ID_ENCODINGENCAESSETTINGS 0x47E7
185 #define MATROSKA_ID_ENCODINGENCALGO 0x47E1
186 #define MATROSKA_ID_ENCODINGENCKEYID 0x47E2
187 #define MATROSKA_ID_ENCODINGSIGALGO 0x47E5
188 #define MATROSKA_ID_ENCODINGSIGHASHALGO 0x47E6
189 #define MATROSKA_ID_ENCODINGSIGKEYID 0x47E4
190 #define MATROSKA_ID_ENCODINGSIGNATURE 0x47E3
191 
192 /* ID in the cues master */
193 #define MATROSKA_ID_POINTENTRY 0xBB
194 
195 /* IDs in the pointentry master */
196 #define MATROSKA_ID_CUETIME    0xB3
197 #define MATROSKA_ID_CUETRACKPOSITION 0xB7
198 
199 /* IDs in the cuetrackposition master */
200 #define MATROSKA_ID_CUETRACK   0xF7
201 #define MATROSKA_ID_CUECLUSTERPOSITION 0xF1
202 #define MATROSKA_ID_CUERELATIVEPOSITION 0xF0
203 #define MATROSKA_ID_CUEDURATION 0xB2
204 #define MATROSKA_ID_CUEBLOCKNUMBER 0x5378
205 
206 /* IDs in the tags master */
207 #define MATROSKA_ID_TAG                 0x7373
208 #define MATROSKA_ID_SIMPLETAG           0x67C8
209 #define MATROSKA_ID_TAGNAME             0x45A3
210 #define MATROSKA_ID_TAGSTRING           0x4487
211 #define MATROSKA_ID_TAGLANG             0x447A
212 #define MATROSKA_ID_TAGDEFAULT          0x4484
213 #define MATROSKA_ID_TAGDEFAULT_BUG      0x44B4
214 #define MATROSKA_ID_TAGTARGETS          0x63C0
215 #define MATROSKA_ID_TAGTARGETS_TYPE       0x63CA
216 #define MATROSKA_ID_TAGTARGETS_TYPEVALUE  0x68CA
217 #define MATROSKA_ID_TAGTARGETS_TRACKUID   0x63C5
218 #define MATROSKA_ID_TAGTARGETS_CHAPTERUID 0x63C4
219 #define MATROSKA_ID_TAGTARGETS_ATTACHUID  0x63C6
220 
221 /* IDs in the seekhead master */
222 #define MATROSKA_ID_SEEKENTRY  0x4DBB
223 
224 /* IDs in the seekpoint master */
225 #define MATROSKA_ID_SEEKID     0x53AB
226 #define MATROSKA_ID_SEEKPOSITION 0x53AC
227 
228 /* IDs in the cluster master */
229 #define MATROSKA_ID_CLUSTERTIMECODE 0xE7
230 #define MATROSKA_ID_CLUSTERPOSITION 0xA7
231 #define MATROSKA_ID_CLUSTERPREVSIZE 0xAB
232 #define MATROSKA_ID_BLOCKGROUP 0xA0
233 #define MATROSKA_ID_BLOCKADDITIONS 0x75A1
234 #define MATROSKA_ID_BLOCKMORE 0xA6
235 #define MATROSKA_ID_BLOCKADDID 0xEE
236 #define MATROSKA_ID_BLOCKADDITIONAL 0xA5
237 #define MATROSKA_ID_SIMPLEBLOCK 0xA3
238 
239 /* IDs in the blockgroup master */
240 #define MATROSKA_ID_BLOCK      0xA1
241 #define MATROSKA_ID_BLOCKDURATION 0x9B
242 #define MATROSKA_ID_BLOCKREFERENCE 0xFB
243 #define MATROSKA_ID_CODECSTATE 0xA4
244 #define MATROSKA_ID_DISCARDPADDING 0x75A2
245 
246 /* IDs in the attachments master */
247 #define MATROSKA_ID_ATTACHEDFILE        0x61A7
248 #define MATROSKA_ID_FILEDESC            0x467E
249 #define MATROSKA_ID_FILENAME            0x466E
250 #define MATROSKA_ID_FILEMIMETYPE        0x4660
251 #define MATROSKA_ID_FILEDATA            0x465C
252 #define MATROSKA_ID_FILEUID             0x46AE
253 
254 /* IDs in the chapters master */
255 #define MATROSKA_ID_EDITIONENTRY        0x45B9
256 #define MATROSKA_ID_CHAPTERATOM         0xB6
257 #define MATROSKA_ID_CHAPTERTIMESTART    0x91
258 #define MATROSKA_ID_CHAPTERTIMEEND      0x92
259 #define MATROSKA_ID_CHAPTERDISPLAY      0x80
260 #define MATROSKA_ID_CHAPSTRING          0x85
261 #define MATROSKA_ID_CHAPLANG            0x437C
262 #define MATROSKA_ID_CHAPCOUNTRY         0x437E
263 #define MATROSKA_ID_EDITIONUID          0x45BC
264 #define MATROSKA_ID_EDITIONFLAGHIDDEN   0x45BD
265 #define MATROSKA_ID_EDITIONFLAGDEFAULT  0x45DB
266 #define MATROSKA_ID_EDITIONFLAGORDERED  0x45DD
267 #define MATROSKA_ID_CHAPTERUID          0x73C4
268 #define MATROSKA_ID_CHAPTERFLAGHIDDEN   0x98
269 #define MATROSKA_ID_CHAPTERFLAGENABLED  0x4598
270 #define MATROSKA_ID_CHAPTERPHYSEQUIV    0x63C3
271 
272 typedef enum {
273   MATROSKA_TRACK_TYPE_NONE     = 0x0,
274   MATROSKA_TRACK_TYPE_VIDEO    = 0x1,
275   MATROSKA_TRACK_TYPE_AUDIO    = 0x2,
276   MATROSKA_TRACK_TYPE_COMPLEX  = 0x3,
277   MATROSKA_TRACK_TYPE_LOGO     = 0x10,
278   MATROSKA_TRACK_TYPE_SUBTITLE = 0x11,
279   MATROSKA_TRACK_TYPE_BUTTONS  = 0x12,
280   MATROSKA_TRACK_TYPE_CONTROL  = 0x20,
281   MATROSKA_TRACK_TYPE_METADATA = 0x21,
282 } MatroskaTrackType;
283 
284 typedef enum {
285   MATROSKA_TRACK_ENCODING_COMP_ZLIB        = 0,
286   MATROSKA_TRACK_ENCODING_COMP_BZLIB       = 1,
287   MATROSKA_TRACK_ENCODING_COMP_LZO         = 2,
288   MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP = 3,
289 } MatroskaTrackEncodingCompAlgo;
290 
291 typedef enum {
292     MATROSKA_VIDEO_INTERLACE_FLAG_UNDETERMINED = 0,
293     MATROSKA_VIDEO_INTERLACE_FLAG_INTERLACED   = 1,
294     MATROSKA_VIDEO_INTERLACE_FLAG_PROGRESSIVE  = 2,
295 } MatroskaVideoInterlaceFlag;
296 
297 typedef enum {
298     MATROSKA_VIDEO_FIELDORDER_PROGRESSIVE  = 0,
299     MATROSKA_VIDEO_FIELDORDER_TT           = 1,
300     MATROSKA_VIDEO_FIELDORDER_UNDETERMINED = 2,
301     MATROSKA_VIDEO_FIELDORDER_BB           = 6,
302     MATROSKA_VIDEO_FIELDORDER_TB           = 9,
303     MATROSKA_VIDEO_FIELDORDER_BT           = 14,
304 } MatroskaVideoFieldOrder;
305 
306 typedef enum {
307   MATROSKA_VIDEO_STEREOMODE_TYPE_MONO               = 0,
308   MATROSKA_VIDEO_STEREOMODE_TYPE_LEFT_RIGHT         = 1,
309   MATROSKA_VIDEO_STEREOMODE_TYPE_BOTTOM_TOP         = 2,
310   MATROSKA_VIDEO_STEREOMODE_TYPE_TOP_BOTTOM         = 3,
311   MATROSKA_VIDEO_STEREOMODE_TYPE_CHECKERBOARD_RL    = 4,
312   MATROSKA_VIDEO_STEREOMODE_TYPE_CHECKERBOARD_LR    = 5,
313   MATROSKA_VIDEO_STEREOMODE_TYPE_ROW_INTERLEAVED_RL = 6,
314   MATROSKA_VIDEO_STEREOMODE_TYPE_ROW_INTERLEAVED_LR = 7,
315   MATROSKA_VIDEO_STEREOMODE_TYPE_COL_INTERLEAVED_RL = 8,
316   MATROSKA_VIDEO_STEREOMODE_TYPE_COL_INTERLEAVED_LR = 9,
317   MATROSKA_VIDEO_STEREOMODE_TYPE_ANAGLYPH_CYAN_RED  = 10,
318   MATROSKA_VIDEO_STEREOMODE_TYPE_RIGHT_LEFT         = 11,
319   MATROSKA_VIDEO_STEREOMODE_TYPE_ANAGLYPH_GREEN_MAG = 12,
320   MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_LR = 13,
321   MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_RL = 14,
322   MATROSKA_VIDEO_STEREOMODE_TYPE_NB,
323 } MatroskaVideoStereoModeType;
324 
325 typedef enum {
326   MATROSKA_VIDEO_DISPLAYUNIT_PIXELS      = 0,
327   MATROSKA_VIDEO_DISPLAYUNIT_CENTIMETERS = 1,
328   MATROSKA_VIDEO_DISPLAYUNIT_INCHES      = 2,
329   MATROSKA_VIDEO_DISPLAYUNIT_DAR         = 3,
330   MATROSKA_VIDEO_DISPLAYUNIT_UNKNOWN     = 4,
331 } MatroskaVideoDisplayUnit;
332 
333 typedef enum {
334   MATROSKA_COLOUR_CHROMASITINGHORZ_UNDETERMINED     = 0,
335   MATROSKA_COLOUR_CHROMASITINGHORZ_LEFT             = 1,
336   MATROSKA_COLOUR_CHROMASITINGHORZ_HALF             = 2,
337   MATROSKA_COLOUR_CHROMASITINGHORZ_NB
338 } MatroskaColourChromaSitingHorz;
339 
340 typedef enum {
341   MATROSKA_COLOUR_CHROMASITINGVERT_UNDETERMINED     = 0,
342   MATROSKA_COLOUR_CHROMASITINGVERT_TOP              = 1,
343   MATROSKA_COLOUR_CHROMASITINGVERT_HALF             = 2,
344   MATROSKA_COLOUR_CHROMASITINGVERT_NB
345 } MatroskaColourChromaSitingVert;
346 
347 typedef enum {
348   MATROSKA_VIDEO_PROJECTION_TYPE_RECTANGULAR        = 0,
349   MATROSKA_VIDEO_PROJECTION_TYPE_EQUIRECTANGULAR    = 1,
350   MATROSKA_VIDEO_PROJECTION_TYPE_CUBEMAP            = 2,
351   MATROSKA_VIDEO_PROJECTION_TYPE_MESH               = 3,
352 } MatroskaVideoProjectionType;
353 
354 /*
355  * Matroska Codec IDs, strings
356  */
357 
358 typedef struct CodecTags{
359     char str[22];
360     enum AVCodecID id;
361 }CodecTags;
362 
363 /* max. depth in the EBML tree structure */
364 #define EBML_MAX_DEPTH 16
365 
366 #define MATROSKA_VIDEO_STEREO_PLANE_COUNT  3
367 
368 extern const CodecTags ff_mkv_codec_tags[];
369 extern const CodecTags ff_webm_codec_tags[];
370 extern const AVMetadataConv ff_mkv_metadata_conv[];
371 extern const char * const ff_matroska_video_stereo_mode[MATROSKA_VIDEO_STEREOMODE_TYPE_NB];
372 extern const char * const ff_matroska_video_stereo_plane[MATROSKA_VIDEO_STEREO_PLANE_COUNT];
373 
374 /* AVStream Metadata tag keys for WebM Dash Manifest */
375 #define INITIALIZATION_RANGE "webm_dash_manifest_initialization_range"
376 #define CUES_START "webm_dash_manifest_cues_start"
377 #define CUES_END "webm_dash_manifest_cues_end"
378 #define FILENAME "webm_dash_manifest_file_name"
379 #define BANDWIDTH "webm_dash_manifest_bandwidth"
380 #define DURATION "webm_dash_manifest_duration"
381 #define CLUSTER_KEYFRAME "webm_dash_manifest_cluster_keyframe"
382 #define CUE_TIMESTAMPS "webm_dash_manifest_cue_timestamps"
383 #define TRACK_NUMBER "webm_dash_manifest_track_number"
384 #define CODEC_PRIVATE_SIZE "webm_dash_manifest_codec_priv_size"
385 
386 int ff_mkv_stereo3d_conv(AVStream *st, MatroskaVideoStereoModeType stereo_mode);
387 
388 #endif /* AVFORMAT_MATROSKA_H */
389