remuxer: Add --max-chunk-size.
[L-SMASH.git] / core / box.h
blobdf2af40ec4a36bf0b9bbf555b97a3ff418a6f9a4
1 /*****************************************************************************
2 * box.h
3 *****************************************************************************
4 * Copyright (C) 2010-2017 L-SMASH project
6 * Authors: Yusuke Nakamura <muken.the.vfrmaniac@gmail.com>
8 * Permission to use, copy, modify, and/or distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies.
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 *****************************************************************************/
21 /* This file is available under an ISC license. */
23 #ifndef LSMASH_BOX_H
24 #define LSMASH_BOX_H
26 /* For generating creation_time and modification_time.
27 * According to ISO/IEC-14496-5-2001, the difference between Unix time and Mac OS time is 2082758400.
28 * However this is wrong and 2082844800 is correct. */
29 #include <time.h>
30 #define ISOM_MAC_EPOCH_OFFSET 2082844800
32 typedef struct lsmash_box_tag isom_box_t;
33 typedef struct isom_mdhd_tag isom_mdhd_t;
34 typedef struct isom_stbl_tag isom_stbl_t;
36 typedef void (*isom_extension_destructor_t)( void *extension_data );
37 typedef int (*isom_extension_writer_t)( lsmash_bs_t *bs, isom_box_t *box );
39 typedef int (*isom_bitrate_updater_t)( isom_stbl_t *stbl, isom_mdhd_t *mdhd, uint32_t sample_description_index );
41 /* If size is 1, then largesize is actual size.
42 * If size is 0, then this box is the last one in the file. */
43 #define ISOM_BASEBOX_COMMON \
44 const lsmash_class_t *class; \
45 lsmash_root_t *root; /* pointer of root */ \
46 lsmash_file_t *file; /* pointer of file */ \
47 isom_box_t *parent; /* pointer of the parent box of this box */ \
48 uint8_t *binary; /* used only when LSMASH_BINARY_CODED_BOX */ \
49 isom_extension_destructor_t destruct; /* box specific destructor */ \
50 isom_extension_writer_t write; /* box specific writer */ \
51 uint32_t manager; /* flags for L-SMASH */ \
52 uint64_t precedence; /* precedence of the box position */ \
53 uint64_t pos; /* starting position of this box in the file */ \
54 lsmash_entry_list_t extensions; /* extension boxes */ \
55 uint64_t size; /* the number of bytes in this box */ \
56 lsmash_box_type_t type
58 #define ISOM_FULLBOX_COMMON \
59 ISOM_BASEBOX_COMMON; \
60 uint8_t version; /* Basically, version is either 0 or 1 */ \
61 uint32_t flags /* In the actual structure of box, flags is 24 bits. */
63 #define ISOM_BASEBOX_COMMON_SIZE 8
64 #define ISOM_FULLBOX_COMMON_SIZE 12
65 #define ISOM_LIST_FULLBOX_COMMON_SIZE 16
67 /* flags for L-SMASH */
68 #define LSMASH_UNKNOWN_BOX 0x001
69 #define LSMASH_ABSENT_IN_FILE 0x002
70 #define LSMASH_QTFF_BASE 0x004
71 #define LSMASH_VIDEO_DESCRIPTION 0x008
72 #define LSMASH_AUDIO_DESCRIPTION 0x010
73 #define LSMASH_FULLBOX 0x020
74 #define LSMASH_LAST_BOX 0x040
75 #define LSMASH_INCOMPLETE_BOX 0x080
76 #define LSMASH_BINARY_CODED_BOX 0x100
77 #define LSMASH_PLACEHOLDER 0x200
78 #define LSMASH_WRITTEN_BOX 0x400
80 /* 12-byte ISO reserved value:
81 * 0xXXXXXXXX-0011-0010-8000-00AA00389B71 */
82 static const uint8_t static_lsmash_iso_12_bytes[12]
83 = { 0x00, 0x11, 0x00, 0x10, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 };
84 #define LSMASH_ISO_12_BYTES static_lsmash_iso_12_bytes
86 /* L-SMASH original 12-byte QuickTime file format value for CODEC discrimination mainly:
87 * 0xXXXXXXXX-0F11-4DA5-BF4E-F2C48C6AA11E */
88 static const uint8_t static_lsmash_qtff_12_bytes[12]
89 = { 0x0F, 0x11, 0x4D, 0xA5, 0xBF, 0x4E, 0xF2, 0xC4, 0x8C, 0x6A, 0xA1, 0x1E };
90 #define LSMASH_QTFF_12_BYTES static_lsmash_qtff_12_bytes
92 struct lsmash_box_tag
94 ISOM_FULLBOX_COMMON;
97 /* Unknown Box
98 * This structure is for boxes we don't know or define yet.
99 * This box must be always appended as an extension box. */
100 typedef struct
102 ISOM_BASEBOX_COMMON;
103 uint32_t unknown_size;
104 uint8_t *unknown_field;
105 } isom_unknown_box_t;
107 /* File Type Box
108 * This box identifies the specifications to which this file complies.
109 * This box shall occur before any variable-length box.
110 * In the absence of this box, the file is QuickTime file format or MP4 version 1 file format.
111 * In MP4 version 1 file format, Object Descriptor Box is mandatory.
112 * In QuickTime file format, Object Descriptor Box isn't defined.
113 * Therefore, if this box and an Object Descriptor Box are absent in the file, the file shall be QuickTime file format. */
114 typedef struct
116 ISOM_BASEBOX_COMMON;
117 uint32_t major_brand; /* brand identifier */
118 uint32_t minor_version; /* the minor version of the major brand */
119 uint32_t *compatible_brands; /* a list, to the end of the box, of brands */
121 uint32_t brand_count; /* the number of factors in compatible_brands array */
122 } isom_ftyp_t;
124 /* Color Table Box
125 * This box defines a list of preferred colors for displaying the movie on devices that support only 256 colors.
126 * The list may contain up to 256 colors. This box contains a Macintosh color table data structure.
127 * This box is defined in QuickTime File Format Specification.
128 * The color table structure is also defined in struct ColorTable defined in Quickdraw.h. */
129 typedef struct
131 /* An array of colors.
132 * Each color is made of four unsigned 16-bit integers. */
133 uint16_t value; /* index or other value
134 * Must be set to 0. */
135 /* true color */
136 uint16_t r; /* magnitude of red component */
137 uint16_t g; /* magnitude of green component */
138 uint16_t b; /* magnitude of blue component */
139 } isom_qt_color_array_t;
141 typedef struct
143 uint32_t seed; /* unique identifier for table
144 * Must be set to 0. */
145 uint16_t flags; /* high bit: 0 = PixMap; 1 = device
146 * Must be set to 0x8000. */
147 uint16_t size; /* the number of colors in the following color array
148 * This is a zero-relative value;
149 * setting this field to 0 means that there is one color in the array. */
150 isom_qt_color_array_t *array;
151 } isom_qt_color_table_t;
153 typedef struct
155 ISOM_BASEBOX_COMMON;
156 isom_qt_color_table_t color_table;
157 } isom_ctab_t;
159 /* Track Header Box
160 * This box specifies the characteristics of a single track. */
161 typedef struct
163 /* version is either 0 or 1
164 * flags
165 * 0x000001: Indicates that the track is enabled.
166 * A disabled track is treated as if it were not present.
167 * 0x000002: Indicates that the track is used in the presentation.
168 * 0x000004: Indicates that the track is used when previewing the presentation.
169 * 0x000008: Indicates that the track is used in the movie's poster. (only defined in QuickTime file format)
170 * ISOM: If in a presentation all tracks have neither track_in_movie nor track_in_preview set,
171 * then all tracks shall be treated as if both flags were set on all tracks. */
172 ISOM_FULLBOX_COMMON;
173 /* version == 0: uint64_t -> uint32_t */
174 uint64_t creation_time; /* the creation time of this track (in seconds since midnight, Jan. 1, 1904, in UTC time) */
175 uint64_t modification_time; /* the most recent time the track was modified (in seconds since midnight, Jan. 1, 1904, in UTC time) */
176 uint32_t track_ID; /* an integer that uniquely identifies the track
177 * Track IDs are never re-used and cannot be zero. */
178 uint32_t reserved1;
179 uint64_t duration; /* the duration of this track expressed in the movie timescale units */
180 /* The following fields are treated as
181 * ISOM: template fields.
182 * MP41: reserved fields.
183 * MP42: ignored fileds since compositions are done using BIFS system.
184 * 3GPP: ignored fields except for alternate_group.
185 * QTFF: usable fields. */
186 uint32_t reserved2[2];
187 int16_t layer; /* the front-to-back ordering of video tracks; tracks with lower numbers are closer to the viewer. */
188 int16_t alternate_group; /* an integer that specifies a group or collection of tracks
189 * If this field is not 0, it should be the same for tracks that contain alternate data for one another
190 * and different for tracks belonging to different such groups.
191 * Only one track within an alternate group should be played or streamed at any one time. */
192 int16_t volume; /* fixed point 8.8 number. 0x0100 is full volume. */
193 uint16_t reserved3;
194 int32_t matrix[9]; /* transformation matrix for the video */
195 /* track's visual presentation size
196 * All images in the sequence are scaled to this size, before any overall transformation of the track represented by the matrix.
197 * Note: these fields are treated as reserved in MP4 version 1. */
198 uint32_t width; /* fixed point 16.16 number */
199 uint32_t height; /* fixed point 16.16 number */
200 /* */
201 } isom_tkhd_t;
203 /* Track Clean Aperture Dimensions Box
204 * A presentation mode where clap and pasp are reflected. */
205 typedef struct
207 ISOM_FULLBOX_COMMON;
208 uint32_t width; /* fixed point 16.16 number */
209 uint32_t height; /* fixed point 16.16 number */
210 } isom_clef_t;
212 /* Track Production Aperture Dimensions Box
213 * A presentation mode where pasp is reflected. */
214 typedef struct
216 ISOM_FULLBOX_COMMON;
217 uint32_t width; /* fixed point 16.16 number */
218 uint32_t height; /* fixed point 16.16 number */
219 } isom_prof_t;
221 /* Track Encoded Pixels Dimensions Box
222 * A presentation mode where clap and pasp are not reflected. */
223 typedef struct
225 ISOM_FULLBOX_COMMON;
226 uint32_t width; /* fixed point 16.16 number */
227 uint32_t height; /* fixed point 16.16 number */
228 } isom_enof_t;
230 /* Track Aperture Mode Dimensions Box */
231 typedef struct
233 ISOM_BASEBOX_COMMON;
234 isom_clef_t *clef; /* Track Clean Aperture Dimensions Box */
235 isom_prof_t *prof; /* Track Production Aperture Dimensions Box */
236 isom_enof_t *enof; /* Track Encoded Pixels Dimensions Box */
237 } isom_tapt_t;
239 /* Edit List Box
240 * This box contains an explicit timeline map.
241 * Each entry defines part of the track timeline: by mapping part of the media timeline, or by indicating 'empty' time,
242 * or by defining a 'dwell', where a single time-point in the media is held for a period.
243 * The last edit in a track shall never be an empty edit.
244 * Any difference between the duration in the Movie Header Box, and the track's duration is expressed as an implicit empty edit at the end.
245 * It is recommended that any edits, explicit or implied, not select any portion of the composition timeline that doesn't map to a sample.
246 * Therefore, if the first sample in the track has non-zero CTS, then this track should have at least one edit and the start time in it should
247 * correspond to the value of the CTS the first sample has or more not to exceed the largest CTS in this track. */
248 typedef struct
250 /* This entry is called Timeline Mapping Edit (TME) entry in UltraViolet Common File Format.
251 * version == 0: 64bits -> 32bits */
252 uint64_t segment_duration; /* the duration of this edit expressed in the movie timescale units */
253 int64_t media_time; /* the starting composition time within the media of this edit segment
254 * If this field is set to -1, it is an empty edit. */
255 int32_t media_rate; /* the relative rate at which to play the media corresponding to this edit segment
256 * If this value is 0, then the edit is specifying a 'dwell':
257 * the media at media_time is presented for the segment_duration.
258 * This field is expressed as 16.16 fixed-point number. */
259 } isom_elst_entry_t;
261 typedef struct
263 ISOM_FULLBOX_COMMON; /* version is either 0 or 1 */
264 lsmash_entry_list_t *list;
265 } isom_elst_t;
267 /* Edit Box
268 * This optional box maps the presentation time-line to the media time-line as it is stored in the file.
269 * In the absence of this box, there is an implicit one-to-one mapping of these time-lines,
270 * and the presentation of a track starts at the beginning of the presentation. */
271 typedef struct
273 ISOM_BASEBOX_COMMON;
274 isom_elst_t *elst; /* Edit List Box */
275 } isom_edts_t;
277 /* Track Reference Box
278 * The Track Reference Box contains Track Reference Type Boxes.
279 * Track Reference Type Boxes define relationships between tracks.
280 * They allow one track to specify how it is related to other tracks. */
281 typedef struct
283 ISOM_BASEBOX_COMMON;
284 uint32_t *track_ID; /* track_IDs of reference tracks / Zero value must not be used */
286 uint32_t ref_count; /* number of reference tracks */
287 } isom_tref_type_t;
289 typedef struct
291 ISOM_BASEBOX_COMMON;
292 lsmash_entry_list_t ref_list; /* Track Reference Type Boxes */
293 } isom_tref_t;
295 /* Media Header Box
296 * This box declares overall information that is media-independent, and relevant to characteristics of the media in a track.*/
297 struct isom_mdhd_tag
299 ISOM_FULLBOX_COMMON; /* version is either 0 or 1 */
300 /* version == 0: uint64_t -> uint32_t */
301 uint64_t creation_time; /* the creation time of the media in this track (in seconds since midnight, Jan. 1, 1904, in UTC time) */
302 uint64_t modification_time; /* the most recent time the media in this track was modified (in seconds since midnight, Jan. 1, 1904, in UTC time) */
303 uint32_t timescale; /* media timescale: timescale for this media */
304 uint64_t duration; /* the duration of this media expressed in the timescale indicated in this box */
305 /* */
306 uint16_t language; /* ISOM: ISO-639-2/T language codes. Most significant 1-bit is 0.
307 * Each character is packed as the difference between its ASCII value and 0x60.
308 * QTFF: Macintosh language codes is usually used.
309 * Mac's value is less than 0x800 while ISO's value is 0x800 or greater. */
310 int16_t quality; /* ISOM: pre_defined / QTFF: the media's playback quality */
313 /* Handler Reference Box
314 * In Media Box, this box is mandatory and (ISOM: should/QTFF: must) come before Media Information Box.
315 * ISOM: this box might be also in Meta Box.
316 * QTFF: this box might be also in Media Information Box. If this box is present there, it must come before Data Information Box. */
317 typedef struct
319 ISOM_FULLBOX_COMMON;
320 uint32_t componentType; /* ISOM: pre_difined = 0
321 * QTFF: 'mhlr' for Media Handler Reference Box and 'dhlr' for Data Handler Reference Box */
322 uint32_t componentSubtype; /* Both ISOM and QT: when present in Media Handler Reference Box, this field defines the type of media data.
323 * ISOM: when present in Metadata Handler Reference Box, this field defines the format of the meta box contents.
324 * QTFF: when present in Data Handler Reference Box, this field defines the data reference type. */
325 /* The following fields are defined in QTFF however these fields aren't mentioned in QuickTime SDK and are reserved in the specification.
326 * In ISOM, these fields are still defined as reserved. */
327 uint32_t componentManufacturer; /* vendor indentification / A value of 0 matches any manufacturer. */
328 uint32_t componentFlags; /* flags describing required component capabilities
329 * The high-order 8 bits should be set to 0.
330 * The low-order 24 bits are specific to each component type. */
331 uint32_t componentFlagsMask; /* This field indicates which flags in the componentFlags field are relevant to this operation. */
332 /* */
333 uint8_t *componentName; /* ISOM: a null-terminated string in UTF-8 characters
334 * QTFF: Pascal string */
336 uint32_t componentName_length;
337 } isom_hdlr_t;
340 /** Media Information Header Boxes
341 ** There is a different media information header for each track type
342 ** (corresponding to the media handler-type); the matching header shall be present. **/
343 /* Video Media Header Box
344 * This box contains general presentation information, independent of the coding, for video media. */
345 typedef struct
347 ISOM_FULLBOX_COMMON; /* flags is 1 */
348 uint16_t graphicsmode; /* template: graphicsmode = 0 */
349 uint16_t opcolor[3]; /* template: opcolor = { 0, 0, 0 } */
350 } isom_vmhd_t;
352 /* Sound Media Header Box
353 * This box contains general presentation information, independent of the coding, for audio media. */
354 typedef struct
356 ISOM_FULLBOX_COMMON;
357 int16_t balance; /* a fixed-point 8.8 number that places mono audio tracks in a stereo space. template: balance = 0 */
358 uint16_t reserved;
359 } isom_smhd_t;
361 /* Hint Media Header Box
362 * This box contains general information, independent of the protocol, for hint tracks. (A PDU is a Protocol Data Unit.) */
363 typedef struct
365 ISOM_FULLBOX_COMMON;
366 uint16_t maxPDUsize; /* the size in bytes of the largest PDU in this (hint) stream */
367 uint16_t avgPDUsize; /* the average size of a PDU over the entire presentation */
368 uint32_t maxbitrate; /* the maximum rate in bits/second over any window of one second */
369 uint32_t avgbitrate; /* the average rate in bits/second over the entire presentation */
370 uint32_t reserved;
371 } isom_hmhd_t;
373 /* Null Media Header Box
374 * This box may be used for streams other than visual and audio (e.g., timed metadata streams). */
375 typedef struct
377 /* Streams other than visual and audio may use a Null Media Header Box */
378 ISOM_FULLBOX_COMMON; /* flags is currently all zero */
379 } isom_nmhd_t;
381 /* Generic Media Information Box */
382 typedef struct
384 ISOM_FULLBOX_COMMON;
385 uint16_t graphicsmode;
386 uint16_t opcolor[3];
387 int16_t balance; /* This field is nomally set to 0. */
388 uint16_t reserved; /* Reserved for use by Apple. Set this field to 0. */
389 } isom_gmin_t;
391 /* Text Media Information Box */
392 typedef struct
394 ISOM_BASEBOX_COMMON;
395 int32_t matrix[9]; /* Unkown fields. Default values are probably:
396 * { 0x00010000, 0, 0, 0, 0x00010000, 0, 0, 0, 0x40000000 } */
397 } isom_text_t;
399 /* Generic Media Information Header Box */
400 typedef struct
402 ISOM_BASEBOX_COMMON;
403 isom_gmin_t *gmin; /* Generic Media Information Box */
404 isom_text_t *text; /* Text Media Information Box */
405 } isom_gmhd_t;
406 /** **/
408 /* Data Reference Box
409 * name and location fields are expressed in null-terminated string using UTF-8 characters. */
410 typedef struct
412 /* This box is DataEntryUrlBox or DataEntryUrnBox */
413 ISOM_FULLBOX_COMMON; /* flags == 0x000001 means that the media data is in the same file
414 * as the Movie Box containing this data reference. */
415 char *name; /* only for DataEntryUrnBox */
416 char *location; /* a location to find the resource with the given name */
418 uint32_t name_length;
419 uint32_t location_length;
420 lsmash_file_t *ref_file; /* pointer to the handle of the referenced file */
421 } isom_dref_entry_t;
423 typedef struct
425 ISOM_FULLBOX_COMMON;
426 lsmash_entry_list_t list;
427 } isom_dref_t;
429 /* Data Information Box */
430 typedef struct
432 /* This box is in Media Information Box or Meta Box */
433 ISOM_BASEBOX_COMMON;
434 isom_dref_t *dref; /* Data Reference Box */
435 } isom_dinf_t;
437 /** Sample Description **/
438 /* ES Descriptor Box */
439 struct mp4sys_ES_Descriptor_t; /* FIXME: I think these structs using mp4sys should be placed in isom.c */
440 typedef struct
442 ISOM_FULLBOX_COMMON;
443 struct mp4sys_ES_Descriptor_t *ES;
444 } isom_esds_t;
446 /* MPEG-4 Bit Rate Box
447 * This box signals the bit rate information of the AVC video stream. */
448 typedef struct
450 ISOM_BASEBOX_COMMON;
451 uint32_t bufferSizeDB; /* the size of the decoding buffer for the elementary stream in bytes */
452 uint32_t maxBitrate; /* the maximum rate in bits/second over any window of one second */
453 uint32_t avgBitrate; /* the average rate in bits/second over the entire presentation */
454 } isom_btrt_t;
456 /* Global Header Box */
457 typedef struct
459 ISOM_BASEBOX_COMMON;
460 uint32_t header_size;
461 uint8_t *header_data;
462 } isom_glbl_t;
464 /* Clean Aperture Box
465 * There are notionally four values in this box and these parameters are represented as a fraction N/D.
466 * Here, we refer to the pair of parameters fooN and fooD as foo.
467 * Considering the pixel dimensions as defined by the VisualSampleEntry width and height.
468 * If picture centre of the image is at pcX and pcY, then horizOff and vertOff are defined as follows:
469 * pcX = horizOff + (width - 1)/2;
470 * pcY = vertOff + (height - 1)/2;
471 * The leftmost/rightmost pixel and the topmost/bottommost line of the clean aperture fall at:
472 * pcX +/- (cleanApertureWidth - 1)/2;
473 * pcY +/- (cleanApertureHeight - 1)/2;
474 * QTFF: this box is a mandatory extension for all uncompressed Y'CbCr data formats. */
475 typedef struct
477 ISOM_BASEBOX_COMMON;
478 uint32_t cleanApertureWidthN;
479 uint32_t cleanApertureWidthD;
480 uint32_t cleanApertureHeightN;
481 uint32_t cleanApertureHeightD;
482 int32_t horizOffN;
483 uint32_t horizOffD;
484 int32_t vertOffN;
485 uint32_t vertOffD;
486 } isom_clap_t;
488 /* Pixel Aspect Ratio Box
489 * This box specifies the aspect ratio of a pixel, in arbitrary units.
490 * If a pixel appears H wide and V tall, then hSpacing/vSpacing is equal to H/V.
491 * When adjusting pixel aspect ratio, normally, the horizontal dimension of the video is scaled, if needed. */
492 typedef struct
494 ISOM_BASEBOX_COMMON;
495 uint32_t hSpacing; /* horizontal spacing */
496 uint32_t vSpacing; /* vertical spacing */
497 } isom_pasp_t;
499 /* ISOM: Colour Information Box / QTFF: Color Parameter Box
500 * This box is used to map the numerical values of pixels in the file to a common representation of color
501 * in which images can be correctly compared, combined, and displayed.
502 * If colour information is supplied in both this box, and also in the video bitstream,
503 * this box takes precedence, and over-rides the information in the bitstream.
504 * For QuickTime file format:
505 * This box ('colr') supersedes the Gamma Level Box ('gama').
506 * Writers of QTFF should never write both into an Image Description, and readers of QTFF should ignore 'gama' if 'colr' is present.
507 * Note: this box is a mandatory extension for all uncompressed Y'CbCr data formats.
508 * For ISO Base Media file format:
509 * Colour information may be supplied in one or more Colour Information Boxes placed in a VisualSampleEntry.
510 * These should be placed in order in the sample entry starting with the most accurate (and potentially the most difficult to process), in progression to the least.
511 * These are advisory and concern rendering and colour conversion, and there is no normative behaviour associated with them; a reader may choose to use the most suitable. */
512 typedef struct
514 ISOM_BASEBOX_COMMON;
515 uint32_t color_parameter_type; /* QTFF: 'nclc' or 'prof'
516 * ISOM: 'nclx', 'rICC' or 'prof' */
517 /* for 'nclc' and 'nclx' */
518 uint16_t primaries_index; /* CIE 1931 xy chromaticity coordinates */
519 uint16_t transfer_function_index; /* nonlinear transfer function from RGB to ErEgEb */
520 uint16_t matrix_index; /* matrix from ErEgEb to EyEcbEcr */
521 /* for 'nclx' */
522 unsigned full_range_flag : 1;
523 unsigned reserved : 7;
524 } isom_colr_t;
526 /* Gamma Level Box
527 * This box is used to indicate that the decompressor corrects gamma level at display time.
528 * This box is defined in QuickTime File Format Specification and ImageCompression.h. */
529 typedef struct
531 ISOM_BASEBOX_COMMON;
532 uint32_t level; /* A fixed-point 16.16 number indicating the gamma level at which the image was captured.
533 * Zero value indicates platform's standard gamma. */
534 } isom_gama_t;
536 /* Field/Frame Information Box
537 * This box is used by applications to modify decompressed image data or by decompressor components to determine field display order.
538 * This box is defined in QuickTime File Format Specification, dispatch019 and ImageCodec.h.
539 * Note: this box is a mandatory extension for all uncompressed Y'CbCr data formats. */
540 typedef struct
542 ISOM_BASEBOX_COMMON;
543 uint8_t fields; /* the number of fields per frame
544 * 1: progressive scan
545 * 2: 2:1 interlaced */
546 uint8_t detail; /* field ordering */
547 } isom_fiel_t;
549 /* Colorspace Box
550 * This box is defined in ImageCompression.h. */
551 typedef struct
553 ISOM_BASEBOX_COMMON;
554 uint32_t pixel_format; /* the native pixel format of an image */
555 } isom_cspc_t;
557 /* Significant Bits Box
558 * This box is defined in Letters from the Ice Floe dispatch019.
559 * Note: this box is a mandatory extension for 'v216' (Uncompressed Y'CbCr, 10, 12, 14, or 16-bit-per-component 4:2:2). */
560 typedef struct
562 ISOM_BASEBOX_COMMON;
563 uint8_t significantBits; /* the number of significant bits per component */
564 } isom_sgbt_t;
566 /* Sample Scale Box
567 * If this box is present and can be interpreted by the decoder,
568 * all samples shall be displayed according to the scaling behaviour that is specified in this box.
569 * Otherwise, all samples are scaled to the size that is indicated by the width and height field in the Track Header Box.
570 * This box is defined in ISO Base Media file format. */
571 typedef struct
573 ISOM_FULLBOX_COMMON;
574 uint8_t constraint_flag; /* Upper 7-bits are reserved.
575 * If this flag is set, all samples described by this sample entry shall be scaled
576 * according to the method specified by the field 'scale_method'. */
577 uint8_t scale_method; /* The semantics of the values for scale_method are as specified for the 'fit' attribute of regions in SMIL 1.0. */
578 int16_t display_center_x;
579 int16_t display_center_y;
580 } isom_stsl_t;
582 /* Sample Entry */
583 #define ISOM_SAMPLE_ENTRY \
584 ISOM_BASEBOX_COMMON; \
585 uint8_t reserved[6]; \
586 uint16_t data_reference_index
588 typedef struct
590 ISOM_SAMPLE_ENTRY;
591 } isom_sample_entry_t;
593 /* Mpeg Sample Entry */
594 typedef struct
596 ISOM_SAMPLE_ENTRY;
597 } isom_mp4s_entry_t;
599 /* ISOM: Visual Sample Entry / QTFF: Image Description
600 * For maximum compatibility, the following extension boxes should follow, not precede,
601 * any extension boxes defined in or required by derived specifications.
602 * Clean Aperture Box
603 * Pixel Aspect Ratio Box */
604 typedef struct
606 ISOM_SAMPLE_ENTRY;
607 int16_t version; /* ISOM: pre_defined / QTFF: sample description version */
608 int16_t revision_level; /* ISOM: reserved / QTFF: version of the CODEC */
609 int32_t vendor; /* ISOM: pre_defined / QTFF: whose CODEC */
610 uint32_t temporalQuality; /* ISOM: pre_defined / QTFF: the temporal quality factor */
611 uint32_t spatialQuality; /* ISOM: pre_defined / QTFF: the spatial quality factor */
612 /* The width and height are the maximum pixel counts that the codec will deliver.
613 * Since these are counts they do not take into account pixel aspect ratio. */
614 uint16_t width;
615 uint16_t height;
616 /* */
617 uint32_t horizresolution; /* 16.16 fixed-point / template: horizresolution = 0x00480000 / 72 dpi */
618 uint32_t vertresolution; /* 16.16 fixed-point / template: vertresolution = 0x00480000 / 72 dpi */
619 uint32_t dataSize; /* ISOM: reserved / QTFF: if known, the size of data for this descriptor */
620 uint16_t frame_count; /* frame per sample / template: frame_count = 1 */
621 char compressorname[33]; /* a fixed 32-byte field, with the first byte set to the number of bytes to be displayed */
622 uint16_t depth; /* ISOM: template: depth = 0x0018
623 * AVC : 0x0018: colour with no alpha
624 * 0x0028: grayscale with no alpha
625 * 0x0020: gray or colour with alpha
626 * QTFF: depth of this data (1-32) or (33-40 grayscale) */
627 int16_t color_table_ID; /* ISOM: template: pre_defined = -1
628 * QTFF: color table ID
629 * If this field is set to -1, the default color table should be used for the specified depth
630 * If the color table ID is set to 0, a color table is contained within the sample description itself.
631 * The color table immediately follows the color table ID field. */
632 /* Color table follows color_table_ID only when color_table_ID is set to 0. */
633 isom_qt_color_table_t color_table; /* a list of preferred colors for displaying the movie on devices that support only 256 colors */
634 } isom_visual_entry_t;
636 /* Format Box
637 * This box shows the data format of the stored sound media.
638 * ISO base media file format also defines the same four-character-code for the type field,
639 * however, that is used to indicate original sample description of the media when a protected sample entry is used. */
640 typedef struct
642 ISOM_BASEBOX_COMMON;
643 uint32_t data_format; /* copy of sample description type */
644 } isom_frma_t;
646 /* Audio Endian Box */
647 typedef struct
649 ISOM_BASEBOX_COMMON;
650 int16_t littleEndian;
651 } isom_enda_t;
653 /* MPEG-4 Audio Box */
654 typedef struct
656 ISOM_BASEBOX_COMMON;
657 uint32_t unknown; /* always 0? */
658 } isom_mp4a_t;
660 /* Terminator Box
661 * This box is present to indicate the end of the sound description. It contains no data. */
662 typedef struct
664 ISOM_BASEBOX_COMMON; /* size = 8, type = 0x00000000 */
665 } isom_terminator_t;
667 /* Sound Information Decompression Parameters Box
668 * This box is defined in QuickTime file format.
669 * This box provides the ability to store data specific to a given audio decompressor in the sound description.
670 * The contents of this box are dependent on the audio decompressor. */
671 typedef struct
673 ISOM_BASEBOX_COMMON;
674 isom_frma_t *frma; /* Format Box */
675 isom_enda_t *enda; /* Audio Endian Box */
676 isom_mp4a_t *mp4a; /* MPEG-4 Audio Box */
677 isom_terminator_t *terminator; /* Terminator Box */
678 } isom_wave_t;
680 /* Audio Channel Layout Box
681 * This box is defined in QuickTime file format or Apple Lossless Audio inside ISO Base Media. */
682 typedef struct
684 uint32_t channelLabel; /* the channelLabel that describes the channel */
685 uint32_t channelFlags; /* flags that control the interpretation of coordinates */
686 uint32_t coordinates[3]; /* an ordered triple that specifies a precise speaker location / 32-bit floating point */
687 } isom_channel_description_t;
689 typedef struct
691 ISOM_FULLBOX_COMMON;
692 uint32_t channelLayoutTag; /* the channelLayoutTag indicates the layout */
693 uint32_t channelBitmap; /* If channelLayoutTag is set to 0x00010000, this field is the channel usage bitmap. */
694 uint32_t numberChannelDescriptions; /* the number of items in the Channel Descriptions array */
695 /* Channel Descriptions array */
696 isom_channel_description_t *channelDescriptions;
697 } isom_chan_t;
699 /* Sampling Rate Box
700 * This box may be present only in an AudioSampleEntryV1, and when present,
701 * it overrides the samplerate field and documents the actual sampling rate.
702 * When this box is present, the media timescale should be the same as the
703 * sampling rate, or an integer division or multiple of it. */
704 typedef struct
706 ISOM_FULLBOX_COMMON;
707 uint32_t sampling_rate; /* the actual sampling rate of the audio media, expressed as a 32-bit integer
708 * The value of this field overrides the samplerate field in the AudioSampleEntryV1
709 * and documents the actual sampling rate. */
710 } isom_srat_t;
712 /* ISOM: Audio Sample Entry / QTFF: Sound Description */
713 typedef struct
715 ISOM_SAMPLE_ENTRY;
716 int16_t version; /* ISOM: version = 0 is used to support non-high samplerate audio format.
717 * version = 1, called AudioSampleEntryV1, is used to support high samplerate audio format.
718 * An AudioSampleEntryV1 requires that the enclosing Sample Description Box also takes the version 1.
719 * For maximum compatibility, an AudioSampleEntryV1 should only be used when needed.
720 * QTFF: version = 0 supports only 'raw ' or 'twos' audio format.
721 * version = 1 is used to support out-of-band configuration settings for decompression.
722 * version = 2 is used to support high samplerate, or 3 or more multichannel audio format. */
723 int16_t revision_level; /* ISOM: reserved / QTFF: version of the CODEC */
724 int32_t vendor; /* ISOM: reserved / QTFF: whose CODEC */
725 uint16_t channelcount; /* ISOM: template: channelcount = 2
726 * channelcount is a value greater than zero that indicates the maximum number of channels that the
727 * audio could deliver.
728 * A channelcount of 1 indicates mono audio, and 2 indicates stereo (left/right).
729 * When values greater than 2 are used, the codec configuration should identify the channel assignment.
730 * QTFF: the number of audio channels
731 * Allowable values are 1 (mono) or 2 (stereo).
732 * For more than 2, set this field to 3 and use numAudioChannels instead of this field. */
733 uint16_t samplesize; /* ISOM: template: samplesize = 16
734 * QTFF: the number of bits in each uncompressed sample for a single channel
735 * Allowable values are 8 or 16.
736 * For non-mod8, set this field to 16 and use constBitsPerChannel instead of this field.
737 * For more than 16, set this field to 16 and use bytesPerPacket instead of this field. */
738 int16_t compression_ID; /* ISOM: pre_defined
739 * QTFF: version = 0 -> must be set to 0.
740 * version = 2 -> must be set to -2. */
741 uint16_t packet_size; /* ISOM: reserved / QTFF: must be set to 0. */
742 uint32_t samplerate; /* the sampling rate expressed as a 16.16 fixed-point number
743 * ISOM: template: samplerate = {default samplerate of media}<<16
744 * When it is desired to indicate an audio sampling rate greater than the value that can be represented in
745 * this field, this field should contain a value left-shifted 16 bits that matches the media timescale,
746 * or be an integer division or multiple of it.
747 * QTFF: the integer portion should match the media's timescale.
748 * If this field is invalid because of higher samplerate,
749 * then set this field to 0x00010000 and use audioSampleRate instead of this field. */
750 /* QTFF-based version 1 fields
751 * These fields are for description of the compression ratio of fixed ratio audio compression algorithms.
752 * If these fields are not used, they are set to 0. */
753 uint32_t samplesPerPacket; /* For compressed audio, be set to the number of uncompressed frames generated by a compressed frame.
754 * For uncompressed audio, shall be set to 1. */
755 uint32_t bytesPerPacket; /* the number of bytes in a sample for a single channel */
756 uint32_t bytesPerFrame; /* the number of bytes in a frame */
757 uint32_t bytesPerSample; /* 8-bit audio: 1, other audio: 2 */
758 /* QTFF-based version 2 fields
759 * LPCMFrame: one sample from each channel.
760 * AudioPacket: For uncompressed audio, an AudioPacket is simply one LPCMFrame.
761 * For compressed audio, an AudioPacket is the natural compressed access unit of that format. */
762 uint32_t sizeOfStructOnly; /* offset to extensions */
763 uint64_t audioSampleRate; /* 64-bit floating point */
764 uint32_t numAudioChannels; /* any channel assignment info will be in Audio Channel Layout Box. */
765 int32_t always7F000000; /* always 0x7F000000 */
766 uint32_t constBitsPerChannel; /* only set if constant (and only for uncompressed audio) */
767 uint32_t formatSpecificFlags;
768 uint32_t constBytesPerAudioPacket; /* only set if constant */
769 uint32_t constLPCMFramesPerAudioPacket; /* only set if constant */
770 } isom_audio_entry_t;
772 /* Hint Sample Entry */
773 #define ISOM_HINT_SAMPLE_ENTRY \
774 ISOM_SAMPLE_ENTRY; \
775 uint8_t *data
777 typedef struct
779 ISOM_HINT_SAMPLE_ENTRY;
780 uint32_t data_length;
781 } isom_hint_entry_t;
783 /* Metadata Sample Entry */
784 #define ISOM_METADATA_SAMPLE_ENTRY \
785 ISOM_SAMPLE_ENTRY
787 typedef struct
789 ISOM_METADATA_SAMPLE_ENTRY;
790 } isom_metadata_entry_t;
792 /* QuickTime Text Sample Description */
793 typedef struct
795 ISOM_SAMPLE_ENTRY;
796 int32_t displayFlags;
797 int32_t textJustification;
798 uint16_t bgColor[3]; /* background RGB color */
799 /* defaultTextBox */
800 int16_t top;
801 int16_t left;
802 int16_t bottom;
803 int16_t right;
804 /* defaultStyle */
805 int32_t scrpStartChar; /* starting character position */
806 int16_t scrpHeight;
807 int16_t scrpAscent;
808 int16_t scrpFont;
809 uint16_t scrpFace; /* only first 8-bits are used */
810 int16_t scrpSize;
811 uint16_t scrpColor[3]; /* foreground RGB color */
812 /* defaultFontName is Pascal string */
813 uint8_t font_name_length;
814 char *font_name;
815 } isom_qt_text_entry_t;
817 /* FontRecord */
818 typedef struct
820 uint16_t font_ID;
821 /* Pascal string */
822 uint8_t font_name_length;
823 char *font_name;
824 } isom_font_record_t;
826 /* Font Table Box */
827 typedef struct
829 ISOM_BASEBOX_COMMON;
830 /* FontRecord
831 * entry_count is uint16_t. */
832 lsmash_entry_list_t *list;
833 } isom_ftab_t;
835 /* 3GPP Timed Text Sample Entry */
836 typedef struct
838 ISOM_SAMPLE_ENTRY;
839 uint32_t displayFlags;
840 int8_t horizontal_justification;
841 int8_t vertical_justification;
842 uint8_t background_color_rgba[4];
843 /* BoxRecord default_text_box */
844 int16_t top;
845 int16_t left;
846 int16_t bottom;
847 int16_t right;
848 /* StyleRecord default_style */
849 uint16_t startChar; /* always 0 */
850 uint16_t endChar; /* always 0 */
851 uint16_t font_ID;
852 uint8_t face_style_flags;
853 uint8_t font_size;
854 uint8_t text_color_rgba[4];
855 /* Font Table Box font_table */
856 isom_ftab_t *ftab;
857 } isom_tx3g_entry_t;
859 /* Sample Description Box */
860 typedef struct
862 ISOM_FULLBOX_COMMON;
863 uint32_t entry_count; /* print only */
864 lsmash_entry_list_t list;
865 } isom_stsd_t;
866 /** **/
868 /* Decoding Time to Sample Box
869 * This box contains a compact version of a table that allows indexing from decoding time to sample number.
870 * Each entry in the table gives the number of consecutive samples with the same time delta, and the delta of those samples.
871 * By adding the deltas a complete time-to-sample map may be built.
872 * All samples must have non-zero durations except for the last one.
873 * The sum of all deltas gives the media duration in the track (not mapped to the movie timescale, and not considering any edit list).
874 * DTS is an abbreviation of 'decoding time stamp'. */
875 typedef struct
877 uint32_t sample_count; /* number of consecutive samples that have the given sample_delta */
878 uint32_t sample_delta; /* DTS[0] = 0; DTS[n+1] = DTS[n] + sample_delta[n]; */
879 } isom_stts_entry_t;
881 typedef struct
883 ISOM_FULLBOX_COMMON;
884 lsmash_entry_list_t *list;
885 } isom_stts_t;
887 /* Composition Time to Sample Box
888 * This box provides the offset between decoding time and composition time.
889 * CTS is an abbreviation of 'composition time stamp'.
890 * This box is optional and must only be present if DTS and CTS differ for any samples. */
891 typedef struct
893 uint32_t sample_count; /* number of consecutive samples that have the given sample_offset */
894 uint32_t sample_offset; /* CTS[n] = DTS[n] + sample_offset[n];
895 * ISOM: if version is set to 1, sample_offset is signed 32-bit integer.
896 * QTFF: sample_offset is always signed 32-bit integer. */
897 } isom_ctts_entry_t;
899 typedef struct
901 ISOM_FULLBOX_COMMON;
902 lsmash_entry_list_t *list;
903 } isom_ctts_t;
905 /* Composition to Decode Box (Composition Shift Least Greatest Box)
906 * This box may be used to relate the composition and decoding timelines,
907 * and deal with some of the ambiguities that signed composition offsets introduce. */
908 typedef struct
910 ISOM_FULLBOX_COMMON;
911 int32_t compositionToDTSShift; /* If this value is added to the composition times (as calculated by the CTS offsets from the DTS),
912 * then for all samples, their CTS is guaranteed to be greater than or equal to their DTS,
913 * and the buffer model implied by the indicated profile/level will be honoured;
914 * if leastDecodeToDisplayDelta is positive or zero, this field can be 0;
915 * otherwise it should be at least (- leastDecodeToDisplayDelta). */
916 int32_t leastDecodeToDisplayDelta; /* the smallest sample_offset in this track */
917 int32_t greatestDecodeToDisplayDelta; /* the largest sample_offset in this track */
918 int32_t compositionStartTime; /* the smallest CTS for any sample */
919 int32_t compositionEndTime; /* the CTS plus the composition duration, of the sample with the largest CTS in this track */
920 } isom_cslg_t;
922 /* Sample Size Box / Compact Sample Size Box
923 * This box contains the sample count and a table giving the size in bytes of each sample.
924 * The total number of samples in the media within the initial movie is always indicated in the sample_count.
925 * Note: a sample size of zero is not prohibited in general, but it must be valid and defined for the coding system,
926 * as defined by the sample entry, that the sample belongs to. */
927 typedef struct
929 uint32_t entry_size; /* the size of a sample */
930 } isom_stsz_entry_t;
932 typedef struct
934 ISOM_FULLBOX_COMMON;
935 uint32_t sample_size; /* the default sample size
936 * If this field is set to 0, then the samples have different sizes. */
937 uint32_t sample_count; /* the number of samples in the media within the initial movie */
938 lsmash_entry_list_t *list; /* available if sample_size == 0 */
939 } isom_stsz_t;
941 typedef struct
943 ISOM_FULLBOX_COMMON;
944 unsigned int reserved : 24; /* 0 */
945 unsigned int field_size : 8; /* the size in bits of the entries in the following table
946 * It shall take the value 4, 8 or 16. If the value 4 is used, then each byte contains two values
947 * entry[i]<<4 + entry[i+1]; if the sizes do not fill an integral number of bytes, the last byte is
948 * padded with zero. */
949 uint32_t sample_count; /* the number of entries in the following table */
950 lsmash_entry_list_t *list; /* L-SMASH uses isom_stsz_entry_t for its internal processes. */
951 } isom_stz2_t;
953 /* Sync Sample Box
954 * If this box is not present, every sample is a random access point.
955 * In AVC streams, this box cannot point non-IDR samples.
956 * The table is arranged in strictly increasing order of sample number. */
957 typedef struct
959 uint32_t sample_number; /* the numbers of the samples that are random access points in the stream. */
960 } isom_stss_entry_t;
962 typedef struct
964 ISOM_FULLBOX_COMMON;
965 lsmash_entry_list_t *list;
966 } isom_stss_t;
968 /* Partial Sync Sample Box
969 * Tip from QT engineering - Open-GOP intra frames need to be marked as "partial sync samples".
970 * Partial sync frames perform a partial reset of inter-frame dependencies;
971 * decoding two partial sync frames and the non-droppable difference frames between them is
972 * sufficient to prepare a decompressor for correctly decoding the difference frames that follow. */
973 typedef struct
975 uint32_t sample_number; /* the numbers of the samples that are partial sync samples in the stream. */
976 } isom_stps_entry_t;
978 typedef struct
980 ISOM_FULLBOX_COMMON;
981 lsmash_entry_list_t *list;
982 } isom_stps_t;
984 /* Independent and Disposable Samples Box */
985 typedef struct
987 unsigned is_leading : 2; /* ISOM: leading / QTFF: samples later in decode order may have earlier display times */
988 unsigned sample_depends_on : 2; /* independency */
989 unsigned sample_is_depended_on : 2; /* disposable */
990 unsigned sample_has_redundancy : 2; /* redundancy */
991 } isom_sdtp_entry_t;
993 typedef struct
995 ISOM_FULLBOX_COMMON;
996 /* According to the specification, the size of the table, sample_count, doesn't exist in this box.
997 * Instead of this, it is taken from the sample_count in the stsz or the stz2 box. */
998 lsmash_entry_list_t *list;
999 } isom_sdtp_t;
1001 /* Sample To Chunk Box
1002 * This box can be used to find the chunk that contains a sample, its position, and the associated sample description.
1003 * The table is compactly coded. Each entry gives the index of the first chunk of a run of chunks with the same characteristics.
1004 * By subtracting one entry here from the previous one, you can compute how many chunks are in this run.
1005 * You can convert this to a sample count by multiplying by the appropriate samples_per_chunk. */
1006 typedef struct
1008 uint32_t first_chunk; /* the index of the first chunk in this run of chunks that share the same samples_per_chunk and sample_description_index */
1009 uint32_t samples_per_chunk; /* the number of samples in each of these chunks */
1010 uint32_t sample_description_index; /* the index of the sample entry that describes the samples in this chunk */
1011 } isom_stsc_entry_t;
1013 typedef struct
1015 ISOM_FULLBOX_COMMON;
1016 lsmash_entry_list_t *list;
1017 } isom_stsc_t;
1019 /* Chunk Offset Box
1020 * chunk_offset is the offset of the start of a chunk into its containing media file.
1021 * Offsets are file offsets, not the offset into any box within the file. */
1022 typedef struct
1024 uint32_t chunk_offset;
1025 } isom_stco_entry_t;
1027 typedef struct
1029 /* for large presentations */
1030 uint64_t chunk_offset;
1031 } isom_co64_entry_t;
1033 typedef struct
1035 ISOM_FULLBOX_COMMON; /* type = 'stco': 32-bit chunk offsets / type = 'co64': 64-bit chunk offsets */
1036 lsmash_entry_list_t *list;
1038 uint8_t large_presentation; /* Set 1 to this if 64-bit chunk-offset are needed. */
1039 } isom_stco_t; /* share with co64 box */
1041 /* Sample Group Description Box
1042 * This box gives information about the characteristics of sample groups. */
1043 typedef struct
1045 ISOM_FULLBOX_COMMON; /* Use of version 0 entries is deprecated. */
1046 uint32_t grouping_type; /* an integer that identifies the sbgp that is associated with this sample group description */
1047 uint32_t default_length; /* the length of every group entry (if the length is constant), or zero (if it is variable)
1048 * This field is available only if version == 1. */
1049 lsmash_entry_list_t *list;
1050 } isom_sgpd_t;
1052 /* Random Access Entry
1053 * Samples marked by this group must be random access points, and may also be sync points. */
1054 typedef struct
1056 /* grouping_type is 'rap ' */
1057 uint32_t description_length; /* This field is available only if version == 1 and default_length == 0. */
1058 unsigned num_leading_samples_known : 1; /* the value of one indicates that the number of leading samples is known for each sample in this group,
1059 * and the number is specified by num_leading_samples. */
1060 unsigned num_leading_samples : 7; /* the number of leading samples for each sample in this group
1061 * Note: when num_leading_samples_known is equal to 0, this field should be ignored. */
1062 } isom_rap_entry_t;
1064 /* Roll Recovery Entry
1065 * This grouping type is defined as that group of samples having the same roll distance. */
1066 typedef struct
1068 /* grouping_type is 'roll' */
1069 uint32_t description_length; /* This field is available only if version == 1 and default_length == 0. */
1070 int16_t roll_distance; /* the number of samples that must be decoded in order for a sample to be decoded correctly
1071 * A positive value indicates post-roll, and a negative value indicates pre-roll.
1072 * The value zero must not be used. */
1073 } isom_roll_entry_t;
1075 /* Sample to Group Box
1076 * This box is used to find the group that a sample belongs to and the associated description of that sample group. */
1077 typedef struct
1079 ISOM_FULLBOX_COMMON;
1080 uint32_t grouping_type; /* Links it to its sample group description table with the same value for grouping type. */
1081 uint32_t grouping_type_parameter; /* an indication of the sub-type of the grouping
1082 * This field is available only if version == 1. */
1083 lsmash_entry_list_t *list;
1084 } isom_sbgp_t;
1086 typedef struct
1088 uint32_t sample_count; /* the number of consecutive samples with the same sample group descriptor */
1089 uint32_t group_description_index; /* the index of the sample group entry which describes the samples in this group
1090 * The index ranges from 1 to the number of sample group entries in the Sample Group Description Box,
1091 * or takes the value 0 to indicate that this sample is a member of no group of this type.
1092 * Within the Sample to Group Box in movie fragment, the group description indexes for groups defined
1093 * within the same fragment start at 0x10001, i.e. the index value 1, with the value 1 in the top 16 bits. */
1094 } isom_group_assignment_entry_t;
1096 /* Sample Table Box */
1097 struct isom_stbl_tag
1099 ISOM_BASEBOX_COMMON;
1100 isom_stsd_t *stsd; /* Sample Description Box */
1101 isom_stts_t *stts; /* Decoding Time to Sample Box */
1102 isom_ctts_t *ctts; /* Composition Time to Sample Box */
1103 isom_cslg_t *cslg; /* ISOM: Composition to Decode Box / QTFF: Composition Shift Least Greatest Box */
1104 isom_stss_t *stss; /* Sync Sample Box */
1105 isom_stps_t *stps; /* ISOM: null / QTFF: Partial Sync Sample Box */
1106 isom_sdtp_t *sdtp; /* Independent and Disposable Samples Box */
1107 isom_stsc_t *stsc; /* Sample To Chunk Box */
1108 isom_stsz_t *stsz; /* Sample Size Box */
1109 isom_stz2_t *stz2; /* Compact Sample Size Box */
1110 isom_stco_t *stco; /* Chunk Offset Box */
1111 lsmash_entry_list_t sgpd_list; /* Sample Group Description Boxes */
1112 lsmash_entry_list_t sbgp_list; /* Sample To Group Boxes */
1114 /* Use 'stz2' instead of 'stsz' if possible. (write mode only) */
1115 int (*compress_sample_size_table)( isom_stbl_t *stbl );
1116 /* Add independent and disposable info for each sample if possible. (write mode only) */
1117 int (*add_dependency_type)( isom_stbl_t *stbl, lsmash_file_t *file, lsmash_sample_property_t *prop );
1120 /* Media Information Box */
1121 typedef struct
1123 ISOM_BASEBOX_COMMON;
1124 /* Media Information Header Boxes */
1125 isom_vmhd_t *vmhd; /* Video Media Header Box */
1126 isom_smhd_t *smhd; /* Sound Media Header Box */
1127 isom_hmhd_t *hmhd; /* ISOM: Hint Media Header Box / QTFF: null */
1128 isom_nmhd_t *nmhd; /* ISOM: Null Media Header Box / QTFF: null */
1129 isom_gmhd_t *gmhd; /* ISOM: null / QTFF: Generic Media Information Header Box */
1130 /* */
1131 isom_hdlr_t *hdlr; /* ISOM: null / QTFF: Data Handler Reference Box
1132 * Note: this box must come before Data Information Box. */
1133 isom_dinf_t *dinf; /* Data Information Box */
1134 isom_stbl_t *stbl; /* Sample Table Box */
1135 } isom_minf_t;
1137 /* Media Box */
1138 typedef struct
1140 ISOM_BASEBOX_COMMON;
1141 isom_mdhd_t *mdhd; /* Media Header Box */
1142 isom_hdlr_t *hdlr; /* ISOM: Handler Reference Box / QTFF: Media Handler Reference Box
1143 * Note: this box must come before Media Information Box. */
1144 isom_minf_t *minf; /* Media Information Box */
1145 } isom_mdia_t;
1147 /* Movie Header Box
1148 * This box defines overall information which is media-independent, and relevant to the entire presentation considered as a whole. */
1149 typedef struct
1151 ISOM_FULLBOX_COMMON; /* version is either 0 or 1 */
1152 /* version == 0: uint64_t -> uint32_t */
1153 uint64_t creation_time; /* the creation time of the presentation (in seconds since midnight, Jan. 1, 1904, in UTC time) */
1154 uint64_t modification_time; /* the most recent time the presentation was modified (in seconds since midnight, Jan. 1, 1904, in UTC time) */
1155 uint32_t timescale; /* movie timescale: timescale for the entire presentation */
1156 uint64_t duration; /* the duration, expressed in movie timescale, of the longest track */
1157 /* The following fields are treated as
1158 * ISOM: template fields.
1159 * MP41: reserved fields.
1160 * MP42: ignored fileds since compositions are done using BIFS system.
1161 * 3GPP: ignored fields.
1162 * QTFF: usable fields. */
1163 int32_t rate; /* fixed point 16.16 number. 0x00010000 is normal forward playback. */
1164 int16_t volume; /* fixed point 8.8 number. 0x0100 is full volume. */
1165 int16_t reserved;
1166 int32_t preferredLong[2]; /* ISOM: reserved / QTFF: unknown */
1167 int32_t matrix[9]; /* transformation matrix for the video */
1168 /* The following fields are defined in QuickTime file format.
1169 * In ISO Base Media file format, these fields are treated as pre_defined. */
1170 int32_t previewTime; /* the time value in the movie at which the preview begins */
1171 int32_t previewDuration; /* the duration of the movie preview in movie timescale units */
1172 int32_t posterTime; /* the time value of the time of the movie poster */
1173 int32_t selectionTime; /* the time value for the start time of the current selection */
1174 int32_t selectionDuration; /* the duration of the current selection in movie timescale units */
1175 int32_t currentTime; /* the time value for current time position within the movie */
1176 /* */
1177 uint32_t next_track_ID; /* larger than the largest track-ID in use */
1178 } isom_mvhd_t;
1180 /* Object Descriptor Box
1181 * Note that this box is mandatory under 14496-1:2001 (mp41) while not mandatory under 14496-14:2003 (mp42). */
1182 struct mp4sys_ObjectDescriptor_t; /* FIXME: I think these structs using mp4sys should be placed in isom.c */
1183 typedef struct
1185 ISOM_FULLBOX_COMMON;
1186 struct mp4sys_ObjectDescriptor_t *OD;
1187 } isom_iods_t;
1189 /* Media Data Box
1190 * This box contains the media data.
1191 * A presentation may contain zero or more Media Data Boxes.*/
1192 typedef struct
1194 ISOM_BASEBOX_COMMON; /* If size is 0, then this box is the last box. */
1196 uint64_t media_size; /* the total media size already written in this box */
1197 } isom_mdat_t;
1199 /* Free Space Box
1200 * The contents of a free-space box are irrelevant and may be ignored without affecting the presentation. */
1201 typedef struct
1203 ISOM_BASEBOX_COMMON; /* type is 'free' or 'skip' */
1204 uint32_t length;
1205 uint8_t *data;
1206 } isom_free_t;
1208 typedef isom_free_t isom_skip_t;
1210 /* Chapter List Box
1211 * This box is NOT defined in the ISO/MPEG-4 specs.
1212 * Basically, this box exists in User Data Box inside Movie Box if present. */
1213 typedef struct
1215 uint64_t start_time; /* version = 0: expressed in movie timescale units
1216 * version = 1: expressed in 100 nanoseconds */
1217 /* Chapter name is Pascal string */
1218 uint8_t chapter_name_length;
1219 char *chapter_name;
1220 } isom_chpl_entry_t;
1222 typedef struct
1224 ISOM_FULLBOX_COMMON; /* version = 0 is defined in F4V file format. */
1225 uint8_t unknown; /* only available under version = 1 */
1226 lsmash_entry_list_t *list; /* if version is set to 0, entry_count is uint8_t. */
1227 } isom_chpl_t;
1229 typedef struct
1231 char *chapter_name;
1232 uint64_t start_time;
1233 } isom_chapter_entry_t;
1235 /* Metadata Item Keys Box */
1236 typedef struct
1238 ISOM_FULLBOX_COMMON;
1239 lsmash_entry_list_t *list;
1240 } isom_keys_t;
1242 typedef struct
1244 uint32_t key_size; /* the size of the entire structure containing a key definition
1245 * key_size = sizeof(key_size) + sizeof(key_namespace) + sizeof(key_value) */
1246 uint32_t key_namespace; /* a naming scheme used for metadata keys
1247 * Location metadata keys, for example, use the 'mdta' key namespace. */
1248 uint8_t *key_value; /* the actual name of the metadata key
1249 * Keys with the 'mdta' namespace use a reverse DNS naming convention. */
1250 } isom_keys_entry_t;
1252 /* Meaning Box */
1253 typedef struct
1255 ISOM_FULLBOX_COMMON;
1256 uint8_t *meaning_string; /* to fill the box */
1258 uint32_t meaning_string_length;
1259 } isom_mean_t;
1261 /* Name Box */
1262 typedef struct
1264 ISOM_FULLBOX_COMMON;
1265 uint8_t *name; /* to fill the box */
1267 uint32_t name_length;
1268 } isom_name_t;
1270 /* Data Box */
1271 typedef struct
1273 ISOM_BASEBOX_COMMON;
1274 /* type indicator */
1275 uint16_t reserved; /* always 0 */
1276 uint8_t type_set_identifier; /* 0: type set of the common basic data types */
1277 uint8_t type_code; /* type of data code */
1278 /* */
1279 uint32_t the_locale; /* reserved to be 0 */
1280 uint8_t *value; /* to fill the box */
1282 uint32_t value_length;
1283 } isom_data_t;
1285 /* Metadata Item Box */
1286 typedef struct
1288 ISOM_BASEBOX_COMMON;
1289 isom_mean_t *mean; /* Meaning Box */
1290 isom_name_t *name; /* Name Box */
1291 isom_data_t *data; /* Data Box */
1292 } isom_metaitem_t;
1294 /* Metadata Item List Box */
1295 typedef struct
1297 ISOM_BASEBOX_COMMON;
1298 lsmash_entry_list_t metaitem_list; /* Metadata Item Box List
1299 * There is no entry_count field. */
1300 } isom_ilst_t;
1302 /* Meta Box */
1303 typedef struct
1305 ISOM_FULLBOX_COMMON; /* ISOM: FullBox / QTFF: BaseBox */
1306 isom_hdlr_t *hdlr; /* Metadata Handler Reference Box */
1307 isom_dinf_t *dinf; /* ISOM: Data Information Box / QTFF: null */
1308 isom_keys_t *keys; /* ISOM: null / QTFF: Metadata Item Keys Box */
1309 isom_ilst_t *ilst; /* Metadata Item List Box only defined in Apple MPEG-4 and QTFF */
1310 } isom_meta_t;
1312 /* Window Location Box */
1313 typedef struct
1315 ISOM_BASEBOX_COMMON;
1316 /* default window location for movie */
1317 uint16_t x;
1318 uint16_t y;
1319 } isom_WLOC_t;
1321 /* Looping Box */
1322 typedef struct
1324 ISOM_BASEBOX_COMMON;
1325 uint32_t looping_mode; /* 0 for none, 1 for looping, 2 for palindromic looping */
1326 } isom_LOOP_t;
1328 /* Play Selection Only Box */
1329 typedef struct
1331 ISOM_BASEBOX_COMMON;
1332 uint8_t selection_only; /* whether only the selected area of the movie should be played */
1333 } isom_SelO_t;
1335 /* Play All Frames Box */
1336 typedef struct
1338 ISOM_BASEBOX_COMMON;
1339 uint8_t play_all_frames; /* whether all frames of video should be played, regardless of timing */
1340 } isom_AllF_t;
1342 /* Copyright Box
1343 * The Copyright box contains a copyright declaration which applies to the entire presentation,
1344 * when contained within the Movie Box, or, when contained in a track, to that entire track.
1345 * There may be multiple copyright boxes using different language codes. */
1346 typedef struct
1348 ISOM_FULLBOX_COMMON;
1349 uint16_t language; /* ISO-639-2/T language codes. Most significant 1-bit is 0.
1350 * Each character is packed as the difference between its ASCII value and 0x60. */
1351 uint8_t *notice; /* a null-terminated string in either UTF-8 or UTF-16 characters, giving a copyright notice.
1352 * If UTF-16 is used, the string shall start with the BYTE ORDER MARK (0xFEFF), to distinguish it from a UTF-8 string.
1353 * This mark does not form part of the final string. */
1354 uint32_t notice_length;
1355 } isom_cprt_t;
1357 /* User Data Box
1358 * This box is a container box for informative user-data.
1359 * This user data is formatted as a set of boxes with more specific box types, which declare more precisely their content.
1360 * QTFF: for historical reasons, this box is optionally terminated by a 32-bit integer set to 0. */
1361 typedef struct
1363 ISOM_BASEBOX_COMMON;
1364 isom_chpl_t *chpl; /* Chapter List Box */
1365 isom_meta_t *meta; /* Meta Box extended by Apple for iTunes movie */
1366 /* QuickTime user data */
1367 isom_WLOC_t *WLOC; /* Window Location Box */
1368 isom_LOOP_t *LOOP; /* Looping Box */
1369 isom_SelO_t *SelO; /* Play Selection Only Box */
1370 isom_AllF_t *AllF; /* Play All Frames Box */
1371 /* Copyright Box List */
1372 lsmash_entry_list_t cprt_list; /* Copyright Boxes is defined in ISO Base Media and 3GPP file format */
1373 } isom_udta_t;
1375 /** Caches for handling tracks **/
1376 typedef struct
1378 uint64_t alloc; /* total buffer size for the pool */
1379 uint64_t size; /* total size of samples in the pool */
1380 uint32_t sample_count; /* number of samples in the pool */
1381 uint8_t *data; /* actual data of samples in the pool */
1382 } isom_sample_pool_t;
1384 typedef struct
1386 uint32_t chunk_number; /* chunk number */
1387 uint32_t sample_description_index; /* sample description index */
1388 uint64_t first_dts; /* the first DTS in chunk */
1389 isom_sample_pool_t *pool; /* samples pooled to interleave */
1390 } isom_chunk_t;
1392 typedef struct
1394 uint64_t dts;
1395 uint64_t cts;
1396 int32_t ctd_shift;
1397 } isom_timestamp_t;
1399 typedef struct
1401 isom_group_assignment_entry_t *assignment; /* the address corresponding to the entry in Sample to Group Box */
1402 isom_group_assignment_entry_t *prev_assignment; /* the address of the previous assignment */
1403 isom_rap_entry_t *random_access; /* the address corresponding to the random access entry in Sample Group Description Box */
1404 uint8_t is_prev_rap; /* whether the previous sample is a random access point or not */
1405 } isom_rap_group_t;
1407 typedef struct
1409 isom_group_assignment_entry_t *assignment; /* the address corresponding to the entry in Sample to Group Box */
1410 isom_sgpd_t *sgpd; /* the address to the active Sample Group Description Box */
1411 uint32_t first_sample; /* the number of the first sample of the group */
1412 uint32_t recovery_point; /* the identifier necessary for the recovery from its starting point to be completed */
1413 uint64_t rp_cts; /* the CTS of the recovery point */
1414 int16_t roll_distance; /* the current roll_distance
1415 * The value may be updated when 'described' is set to ROLL_DISTANCE_INITIALIZED. */
1416 #define MAX_ROLL_WAIT_AND_SEE_COUNT 64
1417 uint8_t wait_and_see_count; /* Wait-and-see after initialization of roll_distance until reaching MAX_ROLL_WAIT_AND_SEE. */
1418 uint8_t is_fragment; /* the flag if the current group is in fragment */
1419 uint8_t prev_is_recovery_start; /* whether the previous sample is a starting point of recovery or not */
1420 uint8_t delimited; /* the flag if the sample_count is determined */
1421 #define ROLL_DISTANCE_INITIALIZED 1
1422 #define ROLL_DISTANCE_DETERMINED 2
1423 uint8_t described; /* the status of the group description */
1424 } isom_roll_group_t;
1426 typedef struct
1428 lsmash_entry_list_t *pool; /* grouping pooled to delimit and describe */
1429 } isom_grouping_t;
1431 typedef struct
1433 uint64_t largest_cts; /* the largest CTS of a subsegment of the reference stream */
1434 uint64_t smallest_cts; /* the smallest CTS of a subsegment of the reference stream */
1435 uint64_t first_cts; /* the CTS of the first sample of a subsegment of the reference stream */
1436 uint64_t segment_duration; /* the sum of the subsegment_duration of preceeding subsegments */
1437 /* SAP related info within the active subsegment of the reference stream */
1438 uint64_t first_ed_cts; /* the earliest CTS of decodable samples after the first recovery point */
1439 uint64_t first_rp_cts; /* the CTS of the first recovery point */
1440 uint32_t first_rp_number; /* the number of the first recovery point */
1441 uint32_t first_ra_number; /* the number of the first random accessible sample */
1442 lsmash_random_access_flag first_ra_flags; /* the flags of the first random accessible sample */
1443 int decodable;
1444 } isom_subsegment_t;
1446 typedef struct
1448 uint8_t has_samples;
1449 uint8_t roll_grouping;
1450 uint8_t rap_grouping;
1451 uint32_t traf_number;
1452 uint32_t last_duration; /* the last sample duration in this track fragment */
1453 uint64_t largest_cts; /* the largest CTS in this track fragment */
1454 uint64_t sample_count; /* the number of samples in this track fragment */
1455 isom_subsegment_t subsegment;
1456 } isom_fragment_t;
1458 typedef struct
1460 uint8_t all_sync; /* if all samples are sync sample */
1461 uint8_t is_audio;
1462 isom_chunk_t chunk;
1463 isom_timestamp_t timestamp;
1464 isom_grouping_t roll;
1465 isom_rap_group_t *rap;
1466 isom_fragment_t *fragment;
1467 } isom_cache_t;
1469 /** Movie Fragments Boxes **/
1470 /* Track Fragments Flags ('tf_flags') */
1471 typedef enum
1473 ISOM_TF_FLAGS_BASE_DATA_OFFSET_PRESENT = 0x000001, /* base-data-offset-present:
1474 * This flag indicates the presence of the base_data_offset field.
1475 * The base_data_offset is the base offset to use when calculating data offsets.
1476 * Offsets are file offsets as like as chunk_offset in Chunk Offset Box.
1477 * If this flag is set and default-base-is-moof is not set, the base_data_offset
1478 * for the first track in the movie fragment is the position of the first byte
1479 * of the enclosing Movie Fragment Box, and for second and subsequent track
1480 * fragments, the default is the end of the data defined by the preceding fragment. */
1481 ISOM_TF_FLAGS_SAMPLE_DESCRIPTION_INDEX_PRESENT = 0x000002, /* sample-description-index-present
1482 * This flag indicates the presence of the sample_description_index field. */
1483 ISOM_TF_FLAGS_DEFAULT_SAMPLE_DURATION_PRESENT = 0x000008, /* default-sample-duration-present:
1484 * This flag indicates the presence of the default_sample_duration field. */
1485 ISOM_TF_FLAGS_DEFAULT_SAMPLE_SIZE_PRESENT = 0x000010, /* default-sample-size-present:
1486 * This flag indicates the presence of the default_sample_size field. */
1487 ISOM_TF_FLAGS_DEFAULT_SAMPLE_FLAGS_PRESENT = 0x000020, /* default-sample-flags-present:
1488 * This flag indicates the presence of the default_sample_flags field. */
1489 ISOM_TF_FLAGS_DURATION_IS_EMPTY = 0x010000, /* duration-is-empty:
1490 * This flag indicates there are no samples for this time interval. */
1491 ISOM_TF_FLAGS_DEFAULT_BASE_IS_MOOF = 0x020000, /* default-base-is-moof:
1492 * If base-data-offset-present is not set, this flag indicates the implicit
1493 * base_data_offset is always equal to the position of the first byte of the
1494 * enclosing Movie Fragment BOX.
1495 * This flag is only available under the 'iso5' or later brands and cannot be set
1496 * when earlier brands are included in the File Type box. */
1497 } isom_tf_flags_code;
1499 /* Track Run Flags ('tr_flags') */
1500 typedef enum
1502 ISOM_TR_FLAGS_DATA_OFFSET_PRESENT = 0x000001, /* data-offset-present:
1503 * This flag indicates the presence of the data_offset field. */
1504 ISOM_TR_FLAGS_FIRST_SAMPLE_FLAGS_PRESENT = 0x000004, /* first-sample-flags-present:
1505 * This flag indicates the presence of the first_sample_flags field. */
1506 ISOM_TR_FLAGS_SAMPLE_DURATION_PRESENT = 0x000100, /* sample-duration-present:
1507 * This flag indicates the presence of the sample_duration field. */
1508 ISOM_TR_FLAGS_SAMPLE_SIZE_PRESENT = 0x000200, /* sample-size-present:
1509 * This flag indicates the presence of the sample_size field. */
1510 ISOM_TR_FLAGS_SAMPLE_FLAGS_PRESENT = 0x000400, /* sample-flags-present:
1511 * This flag indicates the presence of the sample_flags field. */
1512 ISOM_TR_FLAGS_SAMPLE_COMPOSITION_TIME_OFFSET_PRESENT = 0x000800, /* sample-composition-time-offsets-present:
1513 * This flag indicates the presence of the sample_composition_time_offset field. */
1514 } isom_tr_flags_code;
1516 /* Sample Flags */
1517 typedef struct
1519 unsigned reserved : 4;
1520 /* The definition of the following fields is quite the same as Independent and Disposable Samples Box. */
1521 unsigned is_leading : 2;
1522 unsigned sample_depends_on : 2;
1523 unsigned sample_is_depended_on : 2;
1524 unsigned sample_has_redundancy : 2;
1525 /* */
1526 unsigned sample_padding_value : 3; /* the number of bits at the end of this sample */
1527 unsigned sample_is_non_sync_sample : 1; /* 0 value means this sample is sync sample. */
1528 uint16_t sample_degradation_priority;
1529 } isom_sample_flags_t;
1531 /* Movie Extends Header Box
1532 * This box is omitted when used in live streaming.
1533 * If this box is not present, the overall duration must be computed by examining each fragment. */
1534 typedef struct
1536 ISOM_FULLBOX_COMMON;
1537 /* version == 0: uint64_t -> uint32_t */
1538 uint64_t fragment_duration; /* the duration of the longest track, in the timescale indicated in the Movie Header Box, including movie fragments. */
1539 } isom_mehd_t;
1541 /* Track Extends Box
1542 * This box sets up default values used by the movie fragments. */
1543 typedef struct
1545 ISOM_FULLBOX_COMMON;
1546 uint32_t track_ID; /* identifier of the track; this shall be the track ID of a track in the Movie Box */
1547 uint32_t default_sample_description_index;
1548 uint32_t default_sample_duration;
1549 uint32_t default_sample_size;
1550 isom_sample_flags_t default_sample_flags;
1551 } isom_trex_t;
1553 /* Movie Extends Box
1554 * This box warns readers that there might be Movie Fragment Boxes in this file. */
1555 typedef struct
1557 ISOM_BASEBOX_COMMON;
1558 isom_mehd_t *mehd; /* Movie Extends Header Box / omitted when used in live streaming */
1559 lsmash_entry_list_t trex_list; /* Track Extends Box */
1560 } isom_mvex_t;
1562 /* Movie Fragment Header Box
1563 * This box contains a sequence number, as a safety check.
1564 * The sequence number 'usually' starts at 1 and must increase for each movie fragment in the file, in the order in which they occur. */
1565 typedef struct
1567 ISOM_FULLBOX_COMMON;
1568 uint32_t sequence_number; /* the ordinal number of this fragment, in increasing order */
1569 } isom_mfhd_t;
1571 /* Track Fragment Header Box
1572 * Each movie fragment can contain zero or more fragments for each track;
1573 * and a track fragment can contain zero or more contiguous runs of samples.
1574 * This box sets up information and defaults used for those runs of samples. */
1575 typedef struct
1577 ISOM_FULLBOX_COMMON; /* flags field is used for 'tf_flags'. */
1578 uint32_t track_ID;
1579 /* all the following are optional fields */
1580 uint64_t base_data_offset; /* an explicit anchor for the data offsets in each track run
1581 * To avoid the case this field might overflow, e.g. semi-permanent live streaming and broadcasting,
1582 * you shall not use this optional field. */
1583 uint32_t sample_description_index; /* override default_sample_description_index in Track Extends Box */
1584 uint32_t default_sample_duration; /* override default_sample_duration in Track Extends Box */
1585 uint32_t default_sample_size; /* override default_sample_size in Track Extends Box */
1586 isom_sample_flags_t default_sample_flags; /* override default_sample_flags in Track Extends Box */
1587 } isom_tfhd_t;
1589 /* Track Fragment Base Media Decode Time Box
1590 * This box provides the absolute decode time, measured on the media timeline, of the first sample in decode order in the track fragment.
1591 * This can be useful, for example, when performing random access in a file;
1592 * it is not necessary to sum the sample durations of all preceding samples in previous fragments to find this value
1593 * (where the sample durations are the deltas in the Decoding Time to Sample Box and the sample_durations in the preceding track runs).
1594 * This box, if present, shall be positioned after the Track Fragment Header Box and before the first Track Fragment Run box. */
1595 typedef struct
1597 ISOM_FULLBOX_COMMON; /* version is either 0 or 1 */
1598 /* version == 0: 64bits -> 32bits */
1599 uint64_t baseMediaDecodeTime; /* an integer equal to the sum of the decode durations of all earlier samples in the media, expressed in the media's timescale
1600 * It does not include the samples added in the enclosing track fragment.
1601 * NOTE: the decode timeline is a media timeline, established before any explicit or implied mapping of media time to presentation time,
1602 * for example by an edit list or similar structure. */
1603 } isom_tfdt_t;
1605 /* Track Fragment Run Box
1606 * Within the Track Fragment Box, there are zero or more Track Fragment Run Boxes.
1607 * If the duration-is-empty flag is set in the tf_flags, there are no track runs.
1608 * A track run documents a contiguous set of samples for a track. */
1609 typedef struct
1611 ISOM_FULLBOX_COMMON; /* flags field is used for 'tr_flags'. */
1612 uint32_t sample_count; /* the number of samples being added in this run; also the number of rows in the following table */
1613 /* The following are optional fields. */
1614 int32_t data_offset; /* This value is added to the implicit or explicit data_offset established in the Track Fragment Header Box.
1615 * If this field is not present, then the data for this run starts immediately after the data of the previous run,
1616 * or at the base_data_offset defined by the Track Fragment Header Box if this is the first run in a track fragment. */
1617 isom_sample_flags_t first_sample_flags; /* a set of flags for the first sample only of this run */
1618 lsmash_entry_list_t *optional; /* all fields in this array are optional. */
1619 } isom_trun_t;
1621 typedef struct
1623 /* If the following fields is present, each field overrides default value described in Track Fragment Header Box or Track Extends Box. */
1624 uint32_t sample_duration; /* override default_sample_duration */
1625 uint32_t sample_size; /* override default_sample_size */
1626 isom_sample_flags_t sample_flags; /* override default_sample_flags */
1627 /* */
1628 uint32_t sample_composition_time_offset; /* composition time offset
1629 * If version == 0, unsigned 32-bit integer.
1630 * Otherwise, signed 32-bit integer. */
1631 } isom_trun_optional_row_t;
1633 /* Track Fragment Box */
1634 typedef struct
1636 ISOM_BASEBOX_COMMON;
1637 isom_tfhd_t *tfhd; /* Track Fragment Header Box */
1638 isom_tfdt_t *tfdt; /* Track Fragment Base Media Decode Time Box */
1639 lsmash_entry_list_t trun_list; /* Track Fragment Run Box List
1640 * If the duration-is-empty flag is set in the tf_flags, there are no track runs. */
1641 isom_sdtp_t *sdtp; /* Independent and Disposable Samples Box (available under Protected Interoperable File Format) */
1642 lsmash_entry_list_t sgpd_list; /* Sample Group Description Boxes (available under ISO Base Media version 6 or later) */
1643 lsmash_entry_list_t sbgp_list; /* Sample To Group Boxes */
1645 isom_cache_t *cache; /* taken over from corresponding 'trak' */
1646 } isom_traf_t;
1648 /* Movie Fragment Box */
1649 typedef struct
1651 ISOM_BASEBOX_COMMON;
1652 isom_mfhd_t *mfhd; /* Movie Fragment Header Box */
1653 lsmash_entry_list_t traf_list; /* Track Fragment Box List */
1654 } isom_moof_t;
1656 /* Track Fragment Random Access Box
1657 * Each entry in this box contains the location and the presentation time of the sync sample.
1658 * Note that not every sync sample in the track needs to be listed in the table.
1659 * The absence of this box does not mean that all the samples are sync samples. */
1660 typedef struct
1662 ISOM_FULLBOX_COMMON;
1663 uint32_t track_ID;
1664 unsigned int reserved : 26;
1665 unsigned int length_size_of_traf_num : 2; /* the length in byte of the traf_number field minus one */
1666 unsigned int length_size_of_trun_num : 2; /* the length in byte of the trun_number field minus one */
1667 unsigned int length_size_of_sample_num : 2; /* the length in byte of the sample_number field minus one */
1668 uint32_t number_of_entry; /* the number of the entries for this track
1669 * Value zero indicates that every sample is a sync sample and no table entry follows. */
1670 lsmash_entry_list_t *list; /* entry_count corresponds to number_of_entry. */
1671 } isom_tfra_t;
1673 typedef struct
1675 /* version == 0: 64bits -> 32bits */
1676 uint64_t time; /* the presentation time of the sync sample in units defined in the Media Header Box of the associated track
1677 * For segments based on movie sample tables or movie fragments, presentation times are in the movie timeline,
1678 * that is they are composition times after the application of any edit list for the track.
1679 * Note: the definition of segment is portion of an ISO base media file format file, consisting of either
1680 * (a) a movie box, with its associated media data (if any) and other associated boxes
1681 * or
1682 * (b) one or more movie fragment boxes, with their associated media data, and other associated boxes. */
1683 uint64_t moof_offset; /* the offset of the Movie Fragment Box used in this entry
1684 * Offset is the byte-offset between the beginning of the file and the beginning of the Movie Fragment Box. */
1685 /* */
1686 uint32_t traf_number; /* the Track Fragment Box ('traf') number that contains the sync sample
1687 * The number ranges from 1 in each Movie Fragment Box ('moof'). */
1688 uint32_t trun_number; /* the Track Fragment Run Box ('trun') number that contains the sync sample
1689 * The number ranges from 1 in each Track Fragment Box ('traf'). */
1690 uint32_t sample_number; /* the sample number that contains the sync sample
1691 * The number ranges from 1 in each Track Fragment Run Box ('trun'). */
1692 } isom_tfra_location_time_entry_t;
1694 /* Movie Fragment Random Access Offset Box
1695 * This box provides a copy of the length field from the enclosing Movie Fragment Random Access Box. */
1696 typedef struct
1698 ISOM_FULLBOX_COMMON;
1699 uint32_t length; /* an integer gives the number of bytes of the enclosing Movie Fragment Random Access Box
1700 * This field is placed at the last of the enclosing box to assist readers scanning
1701 * from the end of the file in finding the Movie Fragment Random Access Box. */
1702 } isom_mfro_t;
1704 /* Movie Fragment Random Access Box
1705 * This box provides a table which may assist readers in finding sync samples in a file using movie fragments,
1706 * and is usually placed at or near the end of the file.
1707 * The last box within the Movie Fragment Random Access Box, which is called Movie Fragment Random Access Offset Box,
1708 * provides a copy of the length field from the Movie Fragment Random Access Box. */
1709 typedef struct
1711 ISOM_BASEBOX_COMMON;
1712 lsmash_entry_list_t tfra_list; /* Track Fragment Random Access Box */
1713 isom_mfro_t *mfro; /* Movie Fragment Random Access Offset Box */
1714 } isom_mfra_t;
1716 /* Movie fragment manager
1717 * The presence of this means we use the structure of movie fragments. */
1718 typedef struct
1720 #define FIRST_MOOF_POS_UNDETERMINED UINT64_MAX
1721 isom_moof_t *movie; /* the address corresponding to the current Movie Fragment Box */
1722 uint64_t first_moof_pos;
1723 uint64_t pool_size; /* the total sample size in the current movie fragment */
1724 uint64_t sample_count; /* the number of samples within the current movie fragment */
1725 lsmash_entry_list_t *pool; /* samples pooled to interleave for the current movie fragment */
1726 } isom_fragment_manager_t;
1728 /** **/
1730 /* Track Box */
1731 typedef struct
1733 ISOM_BASEBOX_COMMON;
1734 isom_tkhd_t *tkhd; /* Track Header Box */
1735 isom_tapt_t *tapt; /* ISOM: null / QTFF: Track Aperture Mode Dimensions Box */
1736 isom_edts_t *edts; /* Edit Box */
1737 isom_tref_t *tref; /* Track Reference Box */
1738 isom_mdia_t *mdia; /* Media Box */
1739 isom_udta_t *udta; /* User Data Box */
1740 isom_meta_t *meta; /* Meta Box */
1742 isom_cache_t *cache;
1743 uint32_t related_track_ID;
1744 uint8_t is_chapter;
1745 } isom_trak_t;
1747 /* Movie Box */
1748 typedef struct
1750 ISOM_BASEBOX_COMMON;
1751 isom_mvhd_t *mvhd; /* Movie Header Box */
1752 isom_iods_t *iods; /* MP4: Object Descriptor Box */
1753 lsmash_entry_list_t trak_list; /* Track Box List */
1754 isom_udta_t *udta; /* User Data Box */
1755 isom_ctab_t *ctab; /* ISOM: null / QTFF: Color Table Box */
1756 isom_meta_t *meta; /* Meta Box */
1757 isom_mvex_t *mvex; /* Movie Extends Box */
1758 } isom_moov_t;
1760 /** Segments
1761 * segment
1762 * portion of an ISO base media file format file, consisting of either (a) a movie box, with its associated media data
1763 * (if any) and other associated boxes or (b) one or more movie fragment boxes, with their associated media data, and
1764 * and other associated boxes
1765 * subsegment
1766 * time interval of a segment formed from movie fragment boxes, that is also a valid segment
1767 * A subsegment is defined as a time interval of the containing (sub)segment, and corresponds to a single range of
1768 * bytes of the containing (sub)segment. The durations of all the subsegments sum to the duration of the containing
1769 * (sub)segment.
1771 /* Segment Type Box
1772 * Media presentations may be divided into segments for delivery, for example, it is possible (e.g. in HTTP streaming) to
1773 * form files that contain a segment ? or concatenated segments ? which would not necessarily form ISO Base Media file
1774 * format compliant files (e.g. they do not contain a Movie Box).
1775 * If segments are stored in separate files (e.g. on a standard HTTP server) it is recommended that these 'segment files'
1776 * contain a Segment Type Box, which must be first if present, to enable identification of those files, and declaration of
1777 * the specifications with which they are compliant.
1778 * Segment Type Boxes that are not first in a file may be ignored.
1779 * Valid Segment Type Boxes shall be the first box in a segment.
1780 * Note:
1781 * The 'valid' here does not always mean that any brand of that segment has compatibility against other brands of it.
1782 * After concatenations of segments, the result file might contain incompatibilities among brands. */
1783 typedef isom_ftyp_t isom_styp_t;
1785 /* Segment Index Box
1786 * This box provides a compact index of one media stream within the media segment to which it applies.
1788 * Each Segment Index Box documents how a (sub)segment is divided into one or more subsegments (which may themselves be
1789 * further subdivided using Segment Index boxes).
1791 * Each entry in the Segment Index Box contains a reference type that indicates whether the reference points directly to
1792 * the media bytes of a referenced leaf subsegment, which is a subsegment that does not contain any indexing information
1793 * that would enable its further division into subsegments, or to a Segment Index box that describes how the referenced
1794 * subsegment is further subdivided; as a result, the segment may be indexed in a 'hierarchical' or 'daisy-chain' or
1795 * other form by documenting time and byte offset information for other Segment Index Boxes applying to portions of the
1796 * same (sub)segment.
1798 * For segments based on ISO Base Media file format (i.e. based on movie sample tables or movie fragments):
1799 * ! an access unit is a sample;
1800 * ! a subsegment is a self-contained set of one or more consecutive movie fragments; a self-contained set contains
1801 * one or more Movie Fragment Boxes with the corresponding Media Data Box(es), and a Media Data Box containing data
1802 * referenced by a Movie Fragment Box must follow that Movie Fragment Box and precede the next Movie Fragment box
1803 * containing information about the same track;
1804 * ! Segment Index Boxes shall be placed before subsegment material they document, that is, before any Movie Fragment
1805 * Box of the documented material of the subsegment;
1806 * ! streams are tracks in the file format, and stream IDs are track IDs;
1807 * ! a subsegment contains a stream access point if a track fragment within the subsegment for the track with track_ID
1808 * equal to reference_ID contains a stream access point;
1809 * ! initialisation data for SAPs consists of the Movie Box;
1810 * ! presentation times are in the movie timeline, that is they are composition times after the application of any edit
1811 * list for the track;
1812 * ! the ISAP is a position exactly pointing to the start of a top-level box, such as a Movie Fragment Box;
1813 * ! a SAP of type 1 or type 2 is indicated as a sync sample;
1814 * ! a SAP of type 3 is marked as a member of a sample group of type 'rap ';
1815 * ! a SAP of type 4 is marked as a member of a sample group of type 'roll' where the value of the roll_distance field
1816 * is greater than 0.
1817 * For SAPs of type 5 and 6, no specific signalling in the ISO Base Media file format is supported. */
1818 typedef struct
1820 unsigned int reference_type : 1; /* 1: the reference is to a Segment Index Box
1821 * 0: the reference is to media content
1822 * For files based on the ISO Base Media file format, the reference is to a
1823 * Movie Fragment Box.
1824 * If a separate index segment is used, then entries with reference type 1 are
1825 * in the index segment, and entries with reference type 0 are in the media file. */
1826 unsigned int reference_size : 31; /* the distance in bytes from the first byte of the referenced item to the first
1827 * byte of the next referenced item, or in the case of the last entry, the end of
1828 * the referenced material */
1829 uint32_t subsegment_duration; /* when the reference is to Segment Index Box, i.e. reference_type is equal to 1:
1830 * this field carries the sum of the subsegment_duration fields in that box;
1831 * when the reference is to a subsegment:
1832 * this field carries the difference between the earliest presentation time of
1833 * any access unit of the reference stream in the next subsegment (or the first
1834 * subsegment of the next segment, if this is the last subsegment of the segment,
1835 * or the end presentation time of the reference stream if this is the last
1836 * subsegment of the stream) and the earliest presentation time of any access
1837 * unit of the reference stream in the referenced subsegment;
1838 * The duration is expressed in the timescale of the enclosing Segment Index Box. */
1839 unsigned int starts_with_SAP : 1; /* whether the referenced subsegments start with a SAP */
1840 unsigned int SAP_type : 3; /* a SAP type or the value 0
1841 * When starting with a SAP, the value 0 means a SAP may be of an unknown type.
1842 * Otherwise, the value 0 means no information of SAPs is provided. */
1843 unsigned int SAP_delta_time : 28; /* TSAP of the first SAP, in decoding order, in the referenced subsegment for
1844 * the reference stream
1845 * If the referenced subsegments do not contain a SAP, SAP_delta_time is
1846 * reserved with the value 0, otherwise SAP_delta_time is the difference between
1847 * the earliest presentation time of the subsegment, and the TSAP.
1848 * Note that this difference may be zero, in the case that the subsegment starts
1849 * with a SAP. */
1850 } isom_sidx_referenced_item_t;
1852 typedef struct
1854 ISOM_FULLBOX_COMMON;
1855 uint32_t reference_ID; /* the stream ID for the reference stream
1856 * If this Segment Index box is referenced from a "parent" Segment Index box, the value
1857 * of the value of reference_ID shall be the same as the value of reference_ID of the
1858 * "parent" Segment Index Box. */
1859 uint32_t timescale; /* the timescale, in ticks per second, for the time and duration fields within this box
1860 * It is recommended that this match the timescale of the reference stream or track.
1861 * For files based on the ISO Base Media file format, that is the timescale field of
1862 * the Media Header Box of the track. */
1863 /* version == 0: 64bits -> 32bits */
1864 uint64_t earliest_presentation_time; /* the earliest presentation time of any access unit in the reference stream
1865 * in the first subsegment, in the timescale indicated in the timescale field */
1866 uint64_t first_offset; /* the distance in bytes, in the file containing media, from the anchor point,
1867 * to the first byte of the indexed material */
1868 /* */
1869 uint16_t reserved; /* 0 */
1870 uint16_t reference_count; /* the number of referenced items */
1871 lsmash_entry_list_t *list; /* entry_count corresponds to reference_count. */
1872 } isom_sidx_t;
1874 /** **/
1876 /* File */
1877 struct lsmash_file_tag
1879 ISOM_FULLBOX_COMMON; /* The 'size' field indicates total file size.
1880 * The 'flags' field indicates file mode. */
1881 isom_ftyp_t *ftyp; /* File Type Box */
1882 lsmash_entry_list_t styp_list; /* Segment Type Box List */
1883 isom_moov_t *moov; /* Movie Box */
1884 lsmash_entry_list_t sidx_list; /* Segment Index Box List */
1885 lsmash_entry_list_t moof_list; /* Movie Fragment Box List */
1886 isom_mdat_t *mdat; /* Media Data Box */
1887 isom_free_t *free; /* Free Space Box */
1888 isom_meta_t *meta; /* Meta Box */
1889 isom_mfra_t *mfra; /* Movie Fragment Random Access Box */
1891 lsmash_bs_t *bs; /* bytestream manager */
1892 isom_fragment_manager_t *fragment; /* movie fragment manager */
1893 lsmash_entry_list_t *print;
1894 lsmash_entry_list_t *timeline;
1895 lsmash_file_t *initializer;
1896 struct importer_tag *importer;
1897 uint64_t fragment_count; /* the number of movie fragments we created */
1898 double max_chunk_duration; /* max duration per chunk in seconds */
1899 double max_async_tolerance; /* max tolerance, in seconds, for amount of interleaving asynchronization between tracks */
1900 uint64_t max_chunk_size; /* max size per chunk in bytes. */
1901 uint32_t brand_count;
1902 uint32_t *compatible_brands; /* the backup of the compatible brands in the File Type Box or the valid Segment Type Box */
1903 uint8_t fake_file_mode; /* If set to 1, the bytestream manager handles fake-file stream. */
1904 /* flags for compatibility */
1905 #define COMPAT_FLAGS_OFFSET offsetof( lsmash_file_t, qt_compatible )
1906 uint8_t qt_compatible; /* compatibility with QuickTime file format */
1907 uint8_t isom_compatible; /* compatibility with ISO Base Media file format */
1908 uint8_t avc_extensions; /* compatibility with AVC extensions */
1909 uint8_t mp4_version1; /* compatibility with MP4 ver.1 file format */
1910 uint8_t mp4_version2; /* compatibility with MP4 ver.2 file format */
1911 uint8_t itunes_movie; /* compatibility with iTunes Movie */
1912 uint8_t max_3gpp_version; /* maximum 3GPP version */
1913 uint8_t max_isom_version; /* maximum ISO Base Media file format version */
1914 uint8_t min_isom_version; /* minimum ISO Base Media file format version */
1915 uint8_t forbid_tref; /* If set to 1, track reference is forbidden. */
1916 uint8_t undefined_64_ver; /* If set to 1, 64-bit version fields, e.g. duration, are undefined. */
1917 uint8_t allow_moof_base; /* If set to 1, default-base-is-moof is available for muxing. */
1918 uint8_t media_segment; /* If set to 1, this file is a media segment. */
1921 /* fake-file stream */
1922 typedef struct
1924 uint32_t size;
1925 uint8_t *data;
1926 uint32_t pos;
1927 } fake_file_stream_t;
1929 /* ROOT */
1930 struct lsmash_root_tag
1932 ISOM_FULLBOX_COMMON; /* The 'file' field contains the address of the current active file. */
1933 lsmash_entry_list_t file_list; /* the list of all files the ROOT contains */
1936 /** **/
1938 /* Box types
1940 * For developers :
1941 * Be careful about the use of the following defined BOX identifiers.
1942 * Values of array XXXX_BOX_TYPE_YYYY.user.id may be invalid/disappeared value.
1943 * For some systems, e.g.,
1944 * uint8_t id[12];
1945 * memcpy( id, ISOM_BOX_TYPE_MOOV.user.id, 12 * sizeof(uint8_t) );
1946 * brings about undefined behaviour.
1947 * If you want to access values of array XXXX_BOX_TYPE_YYYY.user.id, you shall do like
1948 * uint8_t id[12];
1949 * lsmash_box_type_t type = ISOM_BOX_TYPE_MOOV;
1950 * memcpy( id, type.user.id, 12 * sizeof(uint8_t) );
1952 #define ISOM_BOX_TYPE_ID32 lsmash_form_iso_box_type( LSMASH_4CC( 'I', 'D', '3', '2' ) )
1953 #define ISOM_BOX_TYPE_ALBM lsmash_form_iso_box_type( LSMASH_4CC( 'a', 'l', 'b', 'm' ) )
1954 #define ISOM_BOX_TYPE_AUTH lsmash_form_iso_box_type( LSMASH_4CC( 'a', 'u', 't', 'h' ) )
1955 #define ISOM_BOX_TYPE_BPCC lsmash_form_iso_box_type( LSMASH_4CC( 'b', 'p', 'c', 'c' ) )
1956 #define ISOM_BOX_TYPE_BUFF lsmash_form_iso_box_type( LSMASH_4CC( 'b', 'u', 'f', 'f' ) )
1957 #define ISOM_BOX_TYPE_BXML lsmash_form_iso_box_type( LSMASH_4CC( 'b', 'x', 'm', 'l' ) )
1958 #define ISOM_BOX_TYPE_CCID lsmash_form_iso_box_type( LSMASH_4CC( 'c', 'c', 'i', 'd' ) )
1959 #define ISOM_BOX_TYPE_CDEF lsmash_form_iso_box_type( LSMASH_4CC( 'c', 'd', 'e', 'f' ) )
1960 #define ISOM_BOX_TYPE_CLSF lsmash_form_iso_box_type( LSMASH_4CC( 'c', 'l', 's', 'f' ) )
1961 #define ISOM_BOX_TYPE_CMAP lsmash_form_iso_box_type( LSMASH_4CC( 'c', 'm', 'a', 'p' ) )
1962 #define ISOM_BOX_TYPE_CO64 lsmash_form_iso_box_type( LSMASH_4CC( 'c', 'o', '6', '4' ) )
1963 #define ISOM_BOX_TYPE_COLR lsmash_form_iso_box_type( LSMASH_4CC( 'c', 'o', 'l', 'r' ) )
1964 #define ISOM_BOX_TYPE_CPRT lsmash_form_iso_box_type( LSMASH_4CC( 'c', 'p', 'r', 't' ) )
1965 #define ISOM_BOX_TYPE_CSLG lsmash_form_iso_box_type( LSMASH_4CC( 'c', 's', 'l', 'g' ) )
1966 #define ISOM_BOX_TYPE_CTTS lsmash_form_iso_box_type( LSMASH_4CC( 'c', 't', 't', 's' ) )
1967 #define ISOM_BOX_TYPE_CVRU lsmash_form_iso_box_type( LSMASH_4CC( 'c', 'v', 'r', 'u' ) )
1968 #define ISOM_BOX_TYPE_DCFD lsmash_form_iso_box_type( LSMASH_4CC( 'd', 'c', 'f', 'D' ) )
1969 #define ISOM_BOX_TYPE_DINF lsmash_form_iso_box_type( LSMASH_4CC( 'd', 'i', 'n', 'f' ) )
1970 #define ISOM_BOX_TYPE_DREF lsmash_form_iso_box_type( LSMASH_4CC( 'd', 'r', 'e', 'f' ) )
1971 #define ISOM_BOX_TYPE_DSCP lsmash_form_iso_box_type( LSMASH_4CC( 'd', 's', 'c', 'p' ) )
1972 #define ISOM_BOX_TYPE_DSGD lsmash_form_iso_box_type( LSMASH_4CC( 'd', 's', 'g', 'd' ) )
1973 #define ISOM_BOX_TYPE_DSTG lsmash_form_iso_box_type( LSMASH_4CC( 'd', 's', 't', 'g' ) )
1974 #define ISOM_BOX_TYPE_EDTS lsmash_form_iso_box_type( LSMASH_4CC( 'e', 'd', 't', 's' ) )
1975 #define ISOM_BOX_TYPE_ELST lsmash_form_iso_box_type( LSMASH_4CC( 'e', 'l', 's', 't' ) )
1976 #define ISOM_BOX_TYPE_FECI lsmash_form_iso_box_type( LSMASH_4CC( 'f', 'e', 'c', 'i' ) )
1977 #define ISOM_BOX_TYPE_FECR lsmash_form_iso_box_type( LSMASH_4CC( 'f', 'e', 'c', 'r' ) )
1978 #define ISOM_BOX_TYPE_FIIN lsmash_form_iso_box_type( LSMASH_4CC( 'f', 'i', 'i', 'n' ) )
1979 #define ISOM_BOX_TYPE_FIRE lsmash_form_iso_box_type( LSMASH_4CC( 'f', 'i', 'r', 'e' ) )
1980 #define ISOM_BOX_TYPE_FPAR lsmash_form_iso_box_type( LSMASH_4CC( 'f', 'p', 'a', 'r' ) )
1981 #define ISOM_BOX_TYPE_FREE lsmash_form_iso_box_type( LSMASH_4CC( 'f', 'r', 'e', 'e' ) )
1982 #define ISOM_BOX_TYPE_FRMA lsmash_form_iso_box_type( LSMASH_4CC( 'f', 'r', 'm', 'a' ) )
1983 #define ISOM_BOX_TYPE_FTYP lsmash_form_iso_box_type( LSMASH_4CC( 'f', 't', 'y', 'p' ) )
1984 #define ISOM_BOX_TYPE_GITN lsmash_form_iso_box_type( LSMASH_4CC( 'g', 'i', 't', 'n' ) )
1985 #define ISOM_BOX_TYPE_GNRE lsmash_form_iso_box_type( LSMASH_4CC( 'g', 'n', 'r', 'e' ) )
1986 #define ISOM_BOX_TYPE_GRPI lsmash_form_iso_box_type( LSMASH_4CC( 'g', 'r', 'p', 'i' ) )
1987 #define ISOM_BOX_TYPE_HDLR lsmash_form_iso_box_type( LSMASH_4CC( 'h', 'd', 'l', 'r' ) )
1988 #define ISOM_BOX_TYPE_HMHD lsmash_form_iso_box_type( LSMASH_4CC( 'h', 'm', 'h', 'd' ) )
1989 #define ISOM_BOX_TYPE_ICNU lsmash_form_iso_box_type( LSMASH_4CC( 'i', 'c', 'n', 'u' ) )
1990 #define ISOM_BOX_TYPE_IDAT lsmash_form_iso_box_type( LSMASH_4CC( 'i', 'd', 'a', 't' ) )
1991 #define ISOM_BOX_TYPE_IHDR lsmash_form_iso_box_type( LSMASH_4CC( 'i', 'h', 'd', 'r' ) )
1992 #define ISOM_BOX_TYPE_IINF lsmash_form_iso_box_type( LSMASH_4CC( 'i', 'i', 'n', 'f' ) )
1993 #define ISOM_BOX_TYPE_ILOC lsmash_form_iso_box_type( LSMASH_4CC( 'i', 'l', 'o', 'c' ) )
1994 #define ISOM_BOX_TYPE_IMIF lsmash_form_iso_box_type( LSMASH_4CC( 'i', 'm', 'i', 'f' ) )
1995 #define ISOM_BOX_TYPE_INFU lsmash_form_iso_box_type( LSMASH_4CC( 'i', 'n', 'f', 'u' ) )
1996 #define ISOM_BOX_TYPE_IODS lsmash_form_iso_box_type( LSMASH_4CC( 'i', 'o', 'd', 's' ) )
1997 #define ISOM_BOX_TYPE_IPHD lsmash_form_iso_box_type( LSMASH_4CC( 'i', 'p', 'h', 'd' ) )
1998 #define ISOM_BOX_TYPE_IPMC lsmash_form_iso_box_type( LSMASH_4CC( 'i', 'p', 'm', 'c' ) )
1999 #define ISOM_BOX_TYPE_IPRO lsmash_form_iso_box_type( LSMASH_4CC( 'i', 'p', 'r', 'o' ) )
2000 #define ISOM_BOX_TYPE_IREF lsmash_form_iso_box_type( LSMASH_4CC( 'i', 'r', 'e', 'f' ) )
2001 #define ISOM_BOX_TYPE_JP lsmash_form_iso_box_type( LSMASH_4CC( 'j', 'p', ' ', ' ' ) )
2002 #define ISOM_BOX_TYPE_JP2C lsmash_form_iso_box_type( LSMASH_4CC( 'j', 'p', '2', 'c' ) )
2003 #define ISOM_BOX_TYPE_JP2H lsmash_form_iso_box_type( LSMASH_4CC( 'j', 'p', '2', 'h' ) )
2004 #define ISOM_BOX_TYPE_JP2I lsmash_form_iso_box_type( LSMASH_4CC( 'j', 'p', '2', 'i' ) )
2005 #define ISOM_BOX_TYPE_KYWD lsmash_form_iso_box_type( LSMASH_4CC( 'k', 'y', 'w', 'd' ) )
2006 #define ISOM_BOX_TYPE_LOCI lsmash_form_iso_box_type( LSMASH_4CC( 'l', 'o', 'c', 'i' ) )
2007 #define ISOM_BOX_TYPE_LRCU lsmash_form_iso_box_type( LSMASH_4CC( 'l', 'r', 'c', 'u' ) )
2008 #define ISOM_BOX_TYPE_MDAT lsmash_form_iso_box_type( LSMASH_4CC( 'm', 'd', 'a', 't' ) )
2009 #define ISOM_BOX_TYPE_MDHD lsmash_form_iso_box_type( LSMASH_4CC( 'm', 'd', 'h', 'd' ) )
2010 #define ISOM_BOX_TYPE_MDIA lsmash_form_iso_box_type( LSMASH_4CC( 'm', 'd', 'i', 'a' ) )
2011 #define ISOM_BOX_TYPE_MDRI lsmash_form_iso_box_type( LSMASH_4CC( 'm', 'd', 'r', 'i' ) )
2012 #define ISOM_BOX_TYPE_MECO lsmash_form_iso_box_type( LSMASH_4CC( 'm', 'e', 'c', 'o' ) )
2013 #define ISOM_BOX_TYPE_MEHD lsmash_form_iso_box_type( LSMASH_4CC( 'm', 'e', 'h', 'd' ) )
2014 #define ISOM_BOX_TYPE_M7HD lsmash_form_iso_box_type( LSMASH_4CC( 'm', '7', 'h', 'd' ) )
2015 #define ISOM_BOX_TYPE_MERE lsmash_form_iso_box_type( LSMASH_4CC( 'm', 'e', 'r', 'e' ) )
2016 #define ISOM_BOX_TYPE_META lsmash_form_iso_box_type( LSMASH_4CC( 'm', 'e', 't', 'a' ) )
2017 #define ISOM_BOX_TYPE_MFHD lsmash_form_iso_box_type( LSMASH_4CC( 'm', 'f', 'h', 'd' ) )
2018 #define ISOM_BOX_TYPE_MFRA lsmash_form_iso_box_type( LSMASH_4CC( 'm', 'f', 'r', 'a' ) )
2019 #define ISOM_BOX_TYPE_MFRO lsmash_form_iso_box_type( LSMASH_4CC( 'm', 'f', 'r', 'o' ) )
2020 #define ISOM_BOX_TYPE_MINF lsmash_form_iso_box_type( LSMASH_4CC( 'm', 'i', 'n', 'f' ) )
2021 #define ISOM_BOX_TYPE_MJHD lsmash_form_iso_box_type( LSMASH_4CC( 'm', 'j', 'h', 'd' ) )
2022 #define ISOM_BOX_TYPE_MOOF lsmash_form_iso_box_type( LSMASH_4CC( 'm', 'o', 'o', 'f' ) )
2023 #define ISOM_BOX_TYPE_MOOV lsmash_form_iso_box_type( LSMASH_4CC( 'm', 'o', 'o', 'v' ) )
2024 #define ISOM_BOX_TYPE_MVCG lsmash_form_iso_box_type( LSMASH_4CC( 'm', 'v', 'c', 'g' ) )
2025 #define ISOM_BOX_TYPE_MVCI lsmash_form_iso_box_type( LSMASH_4CC( 'm', 'v', 'c', 'i' ) )
2026 #define ISOM_BOX_TYPE_MVEX lsmash_form_iso_box_type( LSMASH_4CC( 'm', 'v', 'e', 'x' ) )
2027 #define ISOM_BOX_TYPE_MVHD lsmash_form_iso_box_type( LSMASH_4CC( 'm', 'v', 'h', 'd' ) )
2028 #define ISOM_BOX_TYPE_MVRA lsmash_form_iso_box_type( LSMASH_4CC( 'm', 'v', 'r', 'a' ) )
2029 #define ISOM_BOX_TYPE_NMHD lsmash_form_iso_box_type( LSMASH_4CC( 'n', 'm', 'h', 'd' ) )
2030 #define ISOM_BOX_TYPE_OCHD lsmash_form_iso_box_type( LSMASH_4CC( 'o', 'c', 'h', 'd' ) )
2031 #define ISOM_BOX_TYPE_ODAF lsmash_form_iso_box_type( LSMASH_4CC( 'o', 'd', 'a', 'f' ) )
2032 #define ISOM_BOX_TYPE_ODDA lsmash_form_iso_box_type( LSMASH_4CC( 'o', 'd', 'd', 'a' ) )
2033 #define ISOM_BOX_TYPE_ODHD lsmash_form_iso_box_type( LSMASH_4CC( 'o', 'd', 'h', 'd' ) )
2034 #define ISOM_BOX_TYPE_ODHE lsmash_form_iso_box_type( LSMASH_4CC( 'o', 'd', 'h', 'e' ) )
2035 #define ISOM_BOX_TYPE_ODRB lsmash_form_iso_box_type( LSMASH_4CC( 'o', 'd', 'r', 'b' ) )
2036 #define ISOM_BOX_TYPE_ODRM lsmash_form_iso_box_type( LSMASH_4CC( 'o', 'd', 'r', 'm' ) )
2037 #define ISOM_BOX_TYPE_ODTT lsmash_form_iso_box_type( LSMASH_4CC( 'o', 'd', 't', 't' ) )
2038 #define ISOM_BOX_TYPE_OHDR lsmash_form_iso_box_type( LSMASH_4CC( 'o', 'h', 'd', 'r' ) )
2039 #define ISOM_BOX_TYPE_PADB lsmash_form_iso_box_type( LSMASH_4CC( 'p', 'a', 'd', 'b' ) )
2040 #define ISOM_BOX_TYPE_PAEN lsmash_form_iso_box_type( LSMASH_4CC( 'p', 'a', 'e', 'n' ) )
2041 #define ISOM_BOX_TYPE_PCLR lsmash_form_iso_box_type( LSMASH_4CC( 'p', 'c', 'l', 'r' ) )
2042 #define ISOM_BOX_TYPE_PDIN lsmash_form_iso_box_type( LSMASH_4CC( 'p', 'd', 'i', 'n' ) )
2043 #define ISOM_BOX_TYPE_PERF lsmash_form_iso_box_type( LSMASH_4CC( 'p', 'e', 'r', 'f' ) )
2044 #define ISOM_BOX_TYPE_PITM lsmash_form_iso_box_type( LSMASH_4CC( 'p', 'i', 't', 'm' ) )
2045 #define ISOM_BOX_TYPE_RES lsmash_form_iso_box_type( LSMASH_4CC( 'r', 'e', 's', ' ' ) )
2046 #define ISOM_BOX_TYPE_RESC lsmash_form_iso_box_type( LSMASH_4CC( 'r', 'e', 's', 'c' ) )
2047 #define ISOM_BOX_TYPE_RESD lsmash_form_iso_box_type( LSMASH_4CC( 'r', 'e', 's', 'd' ) )
2048 #define ISOM_BOX_TYPE_RTNG lsmash_form_iso_box_type( LSMASH_4CC( 'r', 't', 'n', 'g' ) )
2049 #define ISOM_BOX_TYPE_SBGP lsmash_form_iso_box_type( LSMASH_4CC( 's', 'b', 'g', 'p' ) )
2050 #define ISOM_BOX_TYPE_SCHI lsmash_form_iso_box_type( LSMASH_4CC( 's', 'c', 'h', 'i' ) )
2051 #define ISOM_BOX_TYPE_SCHM lsmash_form_iso_box_type( LSMASH_4CC( 's', 'c', 'h', 'm' ) )
2052 #define ISOM_BOX_TYPE_SDEP lsmash_form_iso_box_type( LSMASH_4CC( 's', 'd', 'e', 'p' ) )
2053 #define ISOM_BOX_TYPE_SDHD lsmash_form_iso_box_type( LSMASH_4CC( 's', 'd', 'h', 'd' ) )
2054 #define ISOM_BOX_TYPE_SDTP lsmash_form_iso_box_type( LSMASH_4CC( 's', 'd', 't', 'p' ) )
2055 #define ISOM_BOX_TYPE_SDVP lsmash_form_iso_box_type( LSMASH_4CC( 's', 'd', 'v', 'p' ) )
2056 #define ISOM_BOX_TYPE_SEGR lsmash_form_iso_box_type( LSMASH_4CC( 's', 'e', 'g', 'r' ) )
2057 #define ISOM_BOX_TYPE_SGPD lsmash_form_iso_box_type( LSMASH_4CC( 's', 'g', 'p', 'd' ) )
2058 #define ISOM_BOX_TYPE_SIDX lsmash_form_iso_box_type( LSMASH_4CC( 's', 'i', 'd', 'x' ) )
2059 #define ISOM_BOX_TYPE_SINF lsmash_form_iso_box_type( LSMASH_4CC( 's', 'i', 'n', 'f' ) )
2060 #define ISOM_BOX_TYPE_SKIP lsmash_form_iso_box_type( LSMASH_4CC( 's', 'k', 'i', 'p' ) )
2061 #define ISOM_BOX_TYPE_SMHD lsmash_form_iso_box_type( LSMASH_4CC( 's', 'm', 'h', 'd' ) )
2062 #define ISOM_BOX_TYPE_SRMB lsmash_form_iso_box_type( LSMASH_4CC( 's', 'r', 'm', 'b' ) )
2063 #define ISOM_BOX_TYPE_SRMC lsmash_form_iso_box_type( LSMASH_4CC( 's', 'r', 'm', 'c' ) )
2064 #define ISOM_BOX_TYPE_SRPP lsmash_form_iso_box_type( LSMASH_4CC( 's', 'r', 'p', 'p' ) )
2065 #define ISOM_BOX_TYPE_STBL lsmash_form_iso_box_type( LSMASH_4CC( 's', 't', 'b', 'l' ) )
2066 #define ISOM_BOX_TYPE_STCO lsmash_form_iso_box_type( LSMASH_4CC( 's', 't', 'c', 'o' ) )
2067 #define ISOM_BOX_TYPE_STDP lsmash_form_iso_box_type( LSMASH_4CC( 's', 't', 'd', 'p' ) )
2068 #define ISOM_BOX_TYPE_STSC lsmash_form_iso_box_type( LSMASH_4CC( 's', 't', 's', 'c' ) )
2069 #define ISOM_BOX_TYPE_STSD lsmash_form_iso_box_type( LSMASH_4CC( 's', 't', 's', 'd' ) )
2070 #define ISOM_BOX_TYPE_STSH lsmash_form_iso_box_type( LSMASH_4CC( 's', 't', 's', 'h' ) )
2071 #define ISOM_BOX_TYPE_STSS lsmash_form_iso_box_type( LSMASH_4CC( 's', 't', 's', 's' ) )
2072 #define ISOM_BOX_TYPE_STSZ lsmash_form_iso_box_type( LSMASH_4CC( 's', 't', 's', 'z' ) )
2073 #define ISOM_BOX_TYPE_STZ2 lsmash_form_iso_box_type( LSMASH_4CC( 's', 't', 'z', '2' ) )
2074 #define ISOM_BOX_TYPE_STTS lsmash_form_iso_box_type( LSMASH_4CC( 's', 't', 't', 's' ) )
2075 #define ISOM_BOX_TYPE_STYP lsmash_form_iso_box_type( LSMASH_4CC( 's', 't', 'y', 'p' ) )
2076 #define ISOM_BOX_TYPE_STZ2 lsmash_form_iso_box_type( LSMASH_4CC( 's', 't', 'z', '2' ) )
2077 #define ISOM_BOX_TYPE_SUBS lsmash_form_iso_box_type( LSMASH_4CC( 's', 'u', 'b', 's' ) )
2078 #define ISOM_BOX_TYPE_SWTC lsmash_form_iso_box_type( LSMASH_4CC( 's', 'w', 't', 'c' ) )
2079 #define ISOM_BOX_TYPE_TFHD lsmash_form_iso_box_type( LSMASH_4CC( 't', 'f', 'h', 'd' ) )
2080 #define ISOM_BOX_TYPE_TFDT lsmash_form_iso_box_type( LSMASH_4CC( 't', 'f', 'd', 't' ) )
2081 #define ISOM_BOX_TYPE_TFRA lsmash_form_iso_box_type( LSMASH_4CC( 't', 'f', 'r', 'a' ) )
2082 #define ISOM_BOX_TYPE_TIBR lsmash_form_iso_box_type( LSMASH_4CC( 't', 'i', 'b', 'r' ) )
2083 #define ISOM_BOX_TYPE_TIRI lsmash_form_iso_box_type( LSMASH_4CC( 't', 'i', 'r', 'i' ) )
2084 #define ISOM_BOX_TYPE_TITL lsmash_form_iso_box_type( LSMASH_4CC( 't', 'i', 't', 'l' ) )
2085 #define ISOM_BOX_TYPE_TKHD lsmash_form_iso_box_type( LSMASH_4CC( 't', 'k', 'h', 'd' ) )
2086 #define ISOM_BOX_TYPE_TRAF lsmash_form_iso_box_type( LSMASH_4CC( 't', 'r', 'a', 'f' ) )
2087 #define ISOM_BOX_TYPE_TRAK lsmash_form_iso_box_type( LSMASH_4CC( 't', 'r', 'a', 'k' ) )
2088 #define ISOM_BOX_TYPE_TREF lsmash_form_iso_box_type( LSMASH_4CC( 't', 'r', 'e', 'f' ) )
2089 #define ISOM_BOX_TYPE_TREX lsmash_form_iso_box_type( LSMASH_4CC( 't', 'r', 'e', 'x' ) )
2090 #define ISOM_BOX_TYPE_TRGR lsmash_form_iso_box_type( LSMASH_4CC( 't', 'r', 'g', 'r' ) )
2091 #define ISOM_BOX_TYPE_TRUN lsmash_form_iso_box_type( LSMASH_4CC( 't', 'r', 'u', 'n' ) )
2092 #define ISOM_BOX_TYPE_TSEL lsmash_form_iso_box_type( LSMASH_4CC( 't', 's', 'e', 'l' ) )
2093 #define ISOM_BOX_TYPE_UDTA lsmash_form_iso_box_type( LSMASH_4CC( 'u', 'd', 't', 'a' ) )
2094 #define ISOM_BOX_TYPE_UINF lsmash_form_iso_box_type( LSMASH_4CC( 'u', 'i', 'n', 'f' ) )
2095 #define ISOM_BOX_TYPE_ULST lsmash_form_iso_box_type( LSMASH_4CC( 'u', 'l', 's', 't' ) )
2096 #define ISOM_BOX_TYPE_URL lsmash_form_iso_box_type( LSMASH_4CC( 'u', 'r', 'l', ' ' ) )
2097 #define ISOM_BOX_TYPE_URN lsmash_form_iso_box_type( LSMASH_4CC( 'u', 'r', 'n', ' ' ) )
2098 #define ISOM_BOX_TYPE_UUID lsmash_form_iso_box_type( LSMASH_4CC( 'u', 'u', 'i', 'd' ) )
2099 #define ISOM_BOX_TYPE_VMHD lsmash_form_iso_box_type( LSMASH_4CC( 'v', 'm', 'h', 'd' ) )
2100 #define ISOM_BOX_TYPE_VWDI lsmash_form_iso_box_type( LSMASH_4CC( 'v', 'w', 'd', 'i' ) )
2101 #define ISOM_BOX_TYPE_XML lsmash_form_iso_box_type( LSMASH_4CC( 'x', 'm', 'l', ' ' ) )
2102 #define ISOM_BOX_TYPE_YRRC lsmash_form_iso_box_type( LSMASH_4CC( 'y', 'r', 'r', 'c' ) )
2104 #define ISOM_BOX_TYPE_BTRT lsmash_form_iso_box_type( LSMASH_4CC( 'b', 't', 'r', 't' ) )
2105 #define ISOM_BOX_TYPE_CLAP lsmash_form_iso_box_type( LSMASH_4CC( 'c', 'l', 'a', 'p' ) )
2106 #define ISOM_BOX_TYPE_PASP lsmash_form_iso_box_type( LSMASH_4CC( 'p', 'a', 's', 'p' ) )
2107 #define ISOM_BOX_TYPE_SRAT lsmash_form_iso_box_type( LSMASH_4CC( 's', 'r', 'a', 't' ) )
2108 #define ISOM_BOX_TYPE_STSL lsmash_form_iso_box_type( LSMASH_4CC( 's', 't', 's', 'l' ) )
2110 #define ISOM_BOX_TYPE_FTAB lsmash_form_iso_box_type( LSMASH_4CC( 'f', 't', 'a', 'b' ) )
2112 /* iTunes Metadata */
2113 #define ISOM_BOX_TYPE_DATA lsmash_form_iso_box_type( LSMASH_4CC( 'd', 'a', 't', 'a' ) )
2114 #define ISOM_BOX_TYPE_ILST lsmash_form_iso_box_type( LSMASH_4CC( 'i', 'l', 's', 't' ) )
2115 #define ISOM_BOX_TYPE_MEAN lsmash_form_iso_box_type( LSMASH_4CC( 'm', 'e', 'a', 'n' ) )
2116 #define ISOM_BOX_TYPE_NAME lsmash_form_iso_box_type( LSMASH_4CC( 'n', 'a', 'm', 'e' ) )
2118 /* Tyrant extension */
2119 #define ISOM_BOX_TYPE_CHPL lsmash_form_iso_box_type( LSMASH_4CC( 'c', 'h', 'p', 'l' ) )
2121 /* Decoder Specific Info */
2122 #define ISOM_BOX_TYPE_ALAC lsmash_form_iso_box_type( LSMASH_4CC( 'a', 'l', 'a', 'c' ) )
2123 #define ISOM_BOX_TYPE_AVCC lsmash_form_iso_box_type( LSMASH_4CC( 'a', 'v', 'c', 'C' ) )
2124 #define ISOM_BOX_TYPE_DAC3 lsmash_form_iso_box_type( LSMASH_4CC( 'd', 'a', 'c', '3' ) )
2125 #define ISOM_BOX_TYPE_DAMR lsmash_form_iso_box_type( LSMASH_4CC( 'd', 'a', 'm', 'r' ) )
2126 #define ISOM_BOX_TYPE_DDTS lsmash_form_iso_box_type( LSMASH_4CC( 'd', 'd', 't', 's' ) )
2127 #define ISOM_BOX_TYPE_DEC3 lsmash_form_iso_box_type( LSMASH_4CC( 'd', 'e', 'c', '3' ) )
2128 #define ISOM_BOX_TYPE_DVC1 lsmash_form_iso_box_type( LSMASH_4CC( 'd', 'v', 'c', '1' ) )
2129 #define ISOM_BOX_TYPE_ESDS lsmash_form_iso_box_type( LSMASH_4CC( 'e', 's', 'd', 's' ) )
2130 #define ISOM_BOX_TYPE_HVCC lsmash_form_iso_box_type( LSMASH_4CC( 'h', 'v', 'c', 'C' ) )
2131 #define ISOM_BOX_TYPE_WFEX lsmash_form_iso_box_type( LSMASH_4CC( 'w', 'f', 'e', 'x' ) )
2133 #define QT_BOX_TYPE_ALLF lsmash_form_qtff_box_type( LSMASH_4CC( 'A', 'l', 'l', 'F' ) )
2134 #define QT_BOX_TYPE_CLEF lsmash_form_qtff_box_type( LSMASH_4CC( 'c', 'l', 'e', 'f' ) )
2135 #define QT_BOX_TYPE_CLIP lsmash_form_qtff_box_type( LSMASH_4CC( 'c', 'l', 'i', 'p' ) )
2136 #define QT_BOX_TYPE_CRGN lsmash_form_qtff_box_type( LSMASH_4CC( 'c', 'r', 'g', 'n' ) )
2137 #define QT_BOX_TYPE_CTAB lsmash_form_qtff_box_type( LSMASH_4CC( 'c', 't', 'a', 'b' ) )
2138 #define QT_BOX_TYPE_ENOF lsmash_form_qtff_box_type( LSMASH_4CC( 'e', 'n', 'o', 'f' ) )
2139 #define QT_BOX_TYPE_GMHD lsmash_form_qtff_box_type( LSMASH_4CC( 'g', 'm', 'h', 'd' ) )
2140 #define QT_BOX_TYPE_GMIN lsmash_form_qtff_box_type( LSMASH_4CC( 'g', 'm', 'i', 'n' ) )
2141 #define QT_BOX_TYPE_ILST lsmash_form_qtff_box_type( LSMASH_4CC( 'i', 'l', 's', 't' ) )
2142 #define QT_BOX_TYPE_IMAP lsmash_form_qtff_box_type( LSMASH_4CC( 'i', 'm', 'a', 'p' ) )
2143 #define QT_BOX_TYPE_KEYS lsmash_form_qtff_box_type( LSMASH_4CC( 'k', 'e', 'y', 's' ) )
2144 #define QT_BOX_TYPE_KMAT lsmash_form_qtff_box_type( LSMASH_4CC( 'k', 'm', 'a', 't' ) )
2145 #define QT_BOX_TYPE_LOAD lsmash_form_qtff_box_type( LSMASH_4CC( 'l', 'o', 'a', 'd' ) )
2146 #define QT_BOX_TYPE_LOOP lsmash_form_qtff_box_type( LSMASH_4CC( 'L', 'O', 'O', 'P' ) )
2147 #define QT_BOX_TYPE_MATT lsmash_form_qtff_box_type( LSMASH_4CC( 'm', 'a', 't', 't' ) )
2148 #define QT_BOX_TYPE_META lsmash_form_qtff_box_type( LSMASH_4CC( 'm', 'e', 't', 'a' ) )
2149 #define QT_BOX_TYPE_PNOT lsmash_form_qtff_box_type( LSMASH_4CC( 'p', 'n', 'o', 't' ) )
2150 #define QT_BOX_TYPE_PROF lsmash_form_qtff_box_type( LSMASH_4CC( 'p', 'r', 'o', 'f' ) )
2151 #define QT_BOX_TYPE_SELO lsmash_form_qtff_box_type( LSMASH_4CC( 'S', 'e', 'l', 'O' ) )
2152 #define QT_BOX_TYPE_STPS lsmash_form_qtff_box_type( LSMASH_4CC( 's', 't', 'p', 's' ) )
2153 #define QT_BOX_TYPE_TAPT lsmash_form_qtff_box_type( LSMASH_4CC( 't', 'a', 'p', 't' ) )
2154 #define QT_BOX_TYPE_TEXT lsmash_form_qtff_box_type( LSMASH_4CC( 't', 'e', 'x', 't' ) )
2155 #define QT_BOX_TYPE_WLOC lsmash_form_qtff_box_type( LSMASH_4CC( 'W', 'L', 'O', 'C' ) )
2157 #define QT_BOX_TYPE_ALIS lsmash_form_qtff_box_type( LSMASH_4CC( 'a', 'l', 'i', 's' ) )
2158 #define QT_BOX_TYPE_RSRC lsmash_form_qtff_box_type( LSMASH_4CC( 'r', 's', 'r', 'c' ) )
2160 #define QT_BOX_TYPE_CHAN lsmash_form_qtff_box_type( LSMASH_4CC( 'c', 'h', 'a', 'n' ) )
2161 #define QT_BOX_TYPE_COLR lsmash_form_qtff_box_type( LSMASH_4CC( 'c', 'o', 'l', 'r' ) )
2162 #define QT_BOX_TYPE_CSPC lsmash_form_qtff_box_type( LSMASH_4CC( 'c', 's', 'p', 'c' ) )
2163 #define QT_BOX_TYPE_ENDA lsmash_form_qtff_box_type( LSMASH_4CC( 'e', 'n', 'd', 'a' ) )
2164 #define QT_BOX_TYPE_FIEL lsmash_form_qtff_box_type( LSMASH_4CC( 'f', 'i', 'e', 'l' ) )
2165 #define QT_BOX_TYPE_FRMA lsmash_form_qtff_box_type( LSMASH_4CC( 'f', 'r', 'm', 'a' ) )
2166 #define QT_BOX_TYPE_GAMA lsmash_form_qtff_box_type( LSMASH_4CC( 'g', 'a', 'm', 'a' ) )
2167 #define QT_BOX_TYPE_SGBT lsmash_form_qtff_box_type( LSMASH_4CC( 's', 'g', 'b', 't' ) )
2168 #define QT_BOX_TYPE_WAVE lsmash_form_qtff_box_type( LSMASH_4CC( 'w', 'a', 'v', 'e' ) )
2169 #define QT_BOX_TYPE_TERMINATOR lsmash_form_qtff_box_type( 0x00000000 )
2171 /* Decoder Specific Info */
2172 #define QT_BOX_TYPE_ALAC lsmash_form_qtff_box_type( LSMASH_4CC( 'a', 'l', 'a', 'c' ) )
2173 #define QT_BOX_TYPE_ESDS lsmash_form_qtff_box_type( LSMASH_4CC( 'e', 's', 'd', 's' ) )
2174 #define QT_BOX_TYPE_GLBL lsmash_form_qtff_box_type( LSMASH_4CC( 'g', 'l', 'b', 'l' ) )
2175 #define QT_BOX_TYPE_MP4A lsmash_form_qtff_box_type( LSMASH_4CC( 'm', 'p', '4', 'a' ) )
2177 /* Pre-defined precedence */
2178 #define LSMASH_BOX_PRECEDENCE_ISOM_FTYP (LSMASH_BOX_PRECEDENCE_H - 0 * LSMASH_BOX_PRECEDENCE_S)
2179 #define LSMASH_BOX_PRECEDENCE_ISOM_STYP (LSMASH_BOX_PRECEDENCE_H - 0 * LSMASH_BOX_PRECEDENCE_S)
2180 #define LSMASH_BOX_PRECEDENCE_ISOM_SIDX (LSMASH_BOX_PRECEDENCE_N + 1 * LSMASH_BOX_PRECEDENCE_S) /* shall be placed before any 'moof' of the documented subsegments */
2181 #define LSMASH_BOX_PRECEDENCE_ISOM_MOOV (LSMASH_BOX_PRECEDENCE_N - 0 * LSMASH_BOX_PRECEDENCE_S)
2182 #define LSMASH_BOX_PRECEDENCE_ISOM_MVHD (LSMASH_BOX_PRECEDENCE_HM - 0 * LSMASH_BOX_PRECEDENCE_S)
2183 #define LSMASH_BOX_PRECEDENCE_ISOM_IODS (LSMASH_BOX_PRECEDENCE_HM - 2 * LSMASH_BOX_PRECEDENCE_S)
2184 #define LSMASH_BOX_PRECEDENCE_ISOM_TRAK (LSMASH_BOX_PRECEDENCE_N - 2 * LSMASH_BOX_PRECEDENCE_S)
2185 #define LSMASH_BOX_PRECEDENCE_ISOM_TKHD (LSMASH_BOX_PRECEDENCE_HM - 0 * LSMASH_BOX_PRECEDENCE_S)
2186 #define LSMASH_BOX_PRECEDENCE_QTFF_TAPT (LSMASH_BOX_PRECEDENCE_N - 1 * LSMASH_BOX_PRECEDENCE_S)
2187 #define LSMASH_BOX_PRECEDENCE_QTFF_CLEF (LSMASH_BOX_PRECEDENCE_N - 0 * LSMASH_BOX_PRECEDENCE_S)
2188 #define LSMASH_BOX_PRECEDENCE_QTFF_PROF (LSMASH_BOX_PRECEDENCE_N - 1 * LSMASH_BOX_PRECEDENCE_S)
2189 #define LSMASH_BOX_PRECEDENCE_QTFF_ENOF (LSMASH_BOX_PRECEDENCE_N - 2 * LSMASH_BOX_PRECEDENCE_S)
2190 #define LSMASH_BOX_PRECEDENCE_ISOM_EDTS (LSMASH_BOX_PRECEDENCE_N - 2 * LSMASH_BOX_PRECEDENCE_S)
2191 #define LSMASH_BOX_PRECEDENCE_ISOM_ELST (LSMASH_BOX_PRECEDENCE_N - 0 * LSMASH_BOX_PRECEDENCE_S)
2192 #define LSMASH_BOX_PRECEDENCE_ISOM_TREF (LSMASH_BOX_PRECEDENCE_N - 3 * LSMASH_BOX_PRECEDENCE_S)
2193 #define LSMASH_BOX_PRECEDENCE_ISOM_TREF_TYPE (LSMASH_BOX_PRECEDENCE_N - 0 * LSMASH_BOX_PRECEDENCE_S)
2194 #define LSMASH_BOX_PRECEDENCE_ISOM_MDIA (LSMASH_BOX_PRECEDENCE_N - 4 * LSMASH_BOX_PRECEDENCE_S)
2195 #define LSMASH_BOX_PRECEDENCE_ISOM_MDHD (LSMASH_BOX_PRECEDENCE_HM - 0 * LSMASH_BOX_PRECEDENCE_S)
2196 #define LSMASH_BOX_PRECEDENCE_ISOM_HDLR (LSMASH_BOX_PRECEDENCE_N - 0 * LSMASH_BOX_PRECEDENCE_S)
2197 #define LSMASH_BOX_PRECEDENCE_ISOM_MINF (LSMASH_BOX_PRECEDENCE_N - 1 * LSMASH_BOX_PRECEDENCE_S)
2198 #define LSMASH_BOX_PRECEDENCE_ISOM_VMHD (LSMASH_BOX_PRECEDENCE_HM - 0 * LSMASH_BOX_PRECEDENCE_S)
2199 #define LSMASH_BOX_PRECEDENCE_ISOM_SMHD (LSMASH_BOX_PRECEDENCE_HM - 0 * LSMASH_BOX_PRECEDENCE_S)
2200 #define LSMASH_BOX_PRECEDENCE_ISOM_HMHD (LSMASH_BOX_PRECEDENCE_HM - 0 * LSMASH_BOX_PRECEDENCE_S)
2201 #define LSMASH_BOX_PRECEDENCE_ISOM_NMHD (LSMASH_BOX_PRECEDENCE_HM - 0 * LSMASH_BOX_PRECEDENCE_S)
2202 #define LSMASH_BOX_PRECEDENCE_QTFF_GMHD (LSMASH_BOX_PRECEDENCE_HM - 0 * LSMASH_BOX_PRECEDENCE_S)
2203 #define LSMASH_BOX_PRECEDENCE_QTFF_GMIN (LSMASH_BOX_PRECEDENCE_N - 0 * LSMASH_BOX_PRECEDENCE_S)
2204 #define LSMASH_BOX_PRECEDENCE_QTFF_TEXT (LSMASH_BOX_PRECEDENCE_N - 1 * LSMASH_BOX_PRECEDENCE_S)
2205 #define LSMASH_BOX_PRECEDENCE_ISOM_DINF (LSMASH_BOX_PRECEDENCE_N - 1 * LSMASH_BOX_PRECEDENCE_S)
2206 #define LSMASH_BOX_PRECEDENCE_ISOM_DREF (LSMASH_BOX_PRECEDENCE_N - 1 * LSMASH_BOX_PRECEDENCE_S)
2207 #define LSMASH_BOX_PRECEDENCE_ISOM_DREF_ENTRY (LSMASH_BOX_PRECEDENCE_N - 0 * LSMASH_BOX_PRECEDENCE_S)
2208 #define LSMASH_BOX_PRECEDENCE_ISOM_STBL (LSMASH_BOX_PRECEDENCE_N - 2 * LSMASH_BOX_PRECEDENCE_S)
2209 #define LSMASH_BOX_PRECEDENCE_ISOM_STSD (LSMASH_BOX_PRECEDENCE_N - 0 * LSMASH_BOX_PRECEDENCE_S)
2210 #define LSMASH_BOX_PRECEDENCE_QTFF_GLBL (LSMASH_BOX_PRECEDENCE_HM - 0 * LSMASH_BOX_PRECEDENCE_S)
2211 #define LSMASH_BOX_PRECEDENCE_ISOM_ESDS (LSMASH_BOX_PRECEDENCE_HM - 0 * LSMASH_BOX_PRECEDENCE_S)
2212 #define LSMASH_BOX_PRECEDENCE_QTFF_ESDS (LSMASH_BOX_PRECEDENCE_HM - 1 * LSMASH_BOX_PRECEDENCE_S) /* preceded by 'frma' and 'mp4a' */
2213 #define LSMASH_BOX_PRECEDENCE_ISOM_BTRT (LSMASH_BOX_PRECEDENCE_HM - 1 * LSMASH_BOX_PRECEDENCE_S)
2214 #define LSMASH_BOX_PRECEDENCE_ISOM_COLR (LSMASH_BOX_PRECEDENCE_LP + 2 * LSMASH_BOX_PRECEDENCE_S)
2215 #define LSMASH_BOX_PRECEDENCE_QTFF_COLR (LSMASH_BOX_PRECEDENCE_LP + 2 * LSMASH_BOX_PRECEDENCE_S)
2216 #define LSMASH_BOX_PRECEDENCE_QTFF_GAMA (LSMASH_BOX_PRECEDENCE_N - 0 * LSMASH_BOX_PRECEDENCE_S)
2217 #define LSMASH_BOX_PRECEDENCE_QTFF_FIEL (LSMASH_BOX_PRECEDENCE_N - 0 * LSMASH_BOX_PRECEDENCE_S)
2218 #define LSMASH_BOX_PRECEDENCE_QTFF_CSPC (LSMASH_BOX_PRECEDENCE_N - 0 * LSMASH_BOX_PRECEDENCE_S)
2219 #define LSMASH_BOX_PRECEDENCE_QTFF_SGBT (LSMASH_BOX_PRECEDENCE_HM - 0 * LSMASH_BOX_PRECEDENCE_S) /* 'v216' specific */
2220 #define LSMASH_BOX_PRECEDENCE_ISOM_CLAP (LSMASH_BOX_PRECEDENCE_LP + 1 * LSMASH_BOX_PRECEDENCE_S)
2221 #define LSMASH_BOX_PRECEDENCE_ISOM_PASP (LSMASH_BOX_PRECEDENCE_LP - 0 * LSMASH_BOX_PRECEDENCE_S)
2222 #define LSMASH_BOX_PRECEDENCE_ISOM_STSL (LSMASH_BOX_PRECEDENCE_N - 0 * LSMASH_BOX_PRECEDENCE_S)
2223 #define LSMASH_BOX_PRECEDENCE_ISOM_CHAN (LSMASH_BOX_PRECEDENCE_LP - 0 * LSMASH_BOX_PRECEDENCE_S)
2224 #define LSMASH_BOX_PRECEDENCE_QTFF_CHAN (LSMASH_BOX_PRECEDENCE_LP - 0 * LSMASH_BOX_PRECEDENCE_S)
2225 #define LSMASH_BOX_PRECEDENCE_QTFF_WAVE (LSMASH_BOX_PRECEDENCE_HM - 0 * LSMASH_BOX_PRECEDENCE_S)
2226 #define LSMASH_BOX_PRECEDENCE_QTFF_FRMA (LSMASH_BOX_PRECEDENCE_HM + 1 * LSMASH_BOX_PRECEDENCE_S) /* precede any as much as possible */
2227 #define LSMASH_BOX_PRECEDENCE_QTFF_ENDA (LSMASH_BOX_PRECEDENCE_N - 0 * LSMASH_BOX_PRECEDENCE_S)
2228 #define LSMASH_BOX_PRECEDENCE_QTFF_MP4A (LSMASH_BOX_PRECEDENCE_HM - 0 * LSMASH_BOX_PRECEDENCE_S)
2229 #define LSMASH_BOX_PRECEDENCE_QTFF_TERMINATOR (LSMASH_BOX_PRECEDENCE_L - 0 * LSMASH_BOX_PRECEDENCE_S)
2230 #define LSMASH_BOX_PRECEDENCE_ISOM_SRAT (LSMASH_BOX_PRECEDENCE_LP - 1 * LSMASH_BOX_PRECEDENCE_S) /* place at the end for maximum compatibility */
2231 #define LSMASH_BOX_PRECEDENCE_ISOM_FTAB (LSMASH_BOX_PRECEDENCE_N - 0 * LSMASH_BOX_PRECEDENCE_S)
2232 #define LSMASH_BOX_PRECEDENCE_ISOM_STTS (LSMASH_BOX_PRECEDENCE_N - 2 * LSMASH_BOX_PRECEDENCE_S)
2233 #define LSMASH_BOX_PRECEDENCE_ISOM_CTTS (LSMASH_BOX_PRECEDENCE_N - 4 * LSMASH_BOX_PRECEDENCE_S)
2234 #define LSMASH_BOX_PRECEDENCE_ISOM_CSLG (LSMASH_BOX_PRECEDENCE_N - 6 * LSMASH_BOX_PRECEDENCE_S)
2235 #define LSMASH_BOX_PRECEDENCE_ISOM_STSS (LSMASH_BOX_PRECEDENCE_N - 8 * LSMASH_BOX_PRECEDENCE_S)
2236 #define LSMASH_BOX_PRECEDENCE_QTFF_STPS (LSMASH_BOX_PRECEDENCE_N - 10 * LSMASH_BOX_PRECEDENCE_S)
2237 #define LSMASH_BOX_PRECEDENCE_ISOM_SDTP (LSMASH_BOX_PRECEDENCE_N - 12 * LSMASH_BOX_PRECEDENCE_S)
2238 #define LSMASH_BOX_PRECEDENCE_ISOM_STSC (LSMASH_BOX_PRECEDENCE_N - 14 * LSMASH_BOX_PRECEDENCE_S)
2239 #define LSMASH_BOX_PRECEDENCE_ISOM_STSZ (LSMASH_BOX_PRECEDENCE_N - 16 * LSMASH_BOX_PRECEDENCE_S)
2240 #define LSMASH_BOX_PRECEDENCE_ISOM_STZ2 (LSMASH_BOX_PRECEDENCE_N - 16 * LSMASH_BOX_PRECEDENCE_S)
2241 #define LSMASH_BOX_PRECEDENCE_ISOM_STCO (LSMASH_BOX_PRECEDENCE_N - 18 * LSMASH_BOX_PRECEDENCE_S)
2242 #define LSMASH_BOX_PRECEDENCE_ISOM_CO64 (LSMASH_BOX_PRECEDENCE_N - 18 * LSMASH_BOX_PRECEDENCE_S)
2243 #define LSMASH_BOX_PRECEDENCE_ISOM_SGPD (LSMASH_BOX_PRECEDENCE_N - 20 * LSMASH_BOX_PRECEDENCE_S)
2244 #define LSMASH_BOX_PRECEDENCE_ISOM_SBGP (LSMASH_BOX_PRECEDENCE_N - 22 * LSMASH_BOX_PRECEDENCE_S)
2245 #define LSMASH_BOX_PRECEDENCE_ISOM_UDTA (LSMASH_BOX_PRECEDENCE_N - 5 * LSMASH_BOX_PRECEDENCE_S)
2246 #define LSMASH_BOX_PRECEDENCE_ISOM_MEAN (LSMASH_BOX_PRECEDENCE_N - 0 * LSMASH_BOX_PRECEDENCE_S)
2247 #define LSMASH_BOX_PRECEDENCE_ISOM_NAME (LSMASH_BOX_PRECEDENCE_N - 1 * LSMASH_BOX_PRECEDENCE_S)
2248 #define LSMASH_BOX_PRECEDENCE_ISOM_DATA (LSMASH_BOX_PRECEDENCE_N - 2 * LSMASH_BOX_PRECEDENCE_S)
2249 #define LSMASH_BOX_PRECEDENCE_QTFF_KEYS (LSMASH_BOX_PRECEDENCE_N - 1 * LSMASH_BOX_PRECEDENCE_S)
2250 #define LSMASH_BOX_PRECEDENCE_ISOM_ILST (LSMASH_BOX_PRECEDENCE_N - 2 * LSMASH_BOX_PRECEDENCE_S)
2251 #define LSMASH_BOX_PRECEDENCE_ISOM_METAITEM (LSMASH_BOX_PRECEDENCE_N - 0 * LSMASH_BOX_PRECEDENCE_S)
2252 #define LSMASH_BOX_PRECEDENCE_ISOM_CHPL (LSMASH_BOX_PRECEDENCE_N - 0 * LSMASH_BOX_PRECEDENCE_S)
2253 #define LSMASH_BOX_PRECEDENCE_ISOM_META (LSMASH_BOX_PRECEDENCE_N - 7 * LSMASH_BOX_PRECEDENCE_S)
2254 #define LSMASH_BOX_PRECEDENCE_QTFF_WLOC (LSMASH_BOX_PRECEDENCE_N - 8 * LSMASH_BOX_PRECEDENCE_S)
2255 #define LSMASH_BOX_PRECEDENCE_QTFF_LOOP (LSMASH_BOX_PRECEDENCE_N - 9 * LSMASH_BOX_PRECEDENCE_S)
2256 #define LSMASH_BOX_PRECEDENCE_QTFF_SELO (LSMASH_BOX_PRECEDENCE_N - 10 * LSMASH_BOX_PRECEDENCE_S)
2257 #define LSMASH_BOX_PRECEDENCE_QTFF_ALLF (LSMASH_BOX_PRECEDENCE_N - 11 * LSMASH_BOX_PRECEDENCE_S)
2258 #define LSMASH_BOX_PRECEDENCE_ISOM_CPRT (LSMASH_BOX_PRECEDENCE_N - 12 * LSMASH_BOX_PRECEDENCE_S)
2259 #define LSMASH_BOX_PRECEDENCE_QTFF_CTAB (LSMASH_BOX_PRECEDENCE_N - 6 * LSMASH_BOX_PRECEDENCE_S)
2260 #define LSMASH_BOX_PRECEDENCE_ISOM_MVEX (LSMASH_BOX_PRECEDENCE_N - 8 * LSMASH_BOX_PRECEDENCE_S)
2261 #define LSMASH_BOX_PRECEDENCE_ISOM_MEHD (LSMASH_BOX_PRECEDENCE_HM - 0 * LSMASH_BOX_PRECEDENCE_S)
2262 #define LSMASH_BOX_PRECEDENCE_ISOM_TREX (LSMASH_BOX_PRECEDENCE_N - 0 * LSMASH_BOX_PRECEDENCE_S)
2263 #define LSMASH_BOX_PRECEDENCE_ISOM_MOOF (LSMASH_BOX_PRECEDENCE_N - 0 * LSMASH_BOX_PRECEDENCE_S)
2264 #define LSMASH_BOX_PRECEDENCE_ISOM_MFHD (LSMASH_BOX_PRECEDENCE_HM - 0 * LSMASH_BOX_PRECEDENCE_S)
2265 #define LSMASH_BOX_PRECEDENCE_ISOM_TRAF (LSMASH_BOX_PRECEDENCE_N - 0 * LSMASH_BOX_PRECEDENCE_S)
2266 #define LSMASH_BOX_PRECEDENCE_ISOM_TFHD (LSMASH_BOX_PRECEDENCE_HM - 0 * LSMASH_BOX_PRECEDENCE_S)
2267 #define LSMASH_BOX_PRECEDENCE_ISOM_TFDT (LSMASH_BOX_PRECEDENCE_HM - 1 * LSMASH_BOX_PRECEDENCE_S) /* shall be positioned after 'tfhd' and before 'trun' */
2268 #define LSMASH_BOX_PRECEDENCE_ISOM_TRUN (LSMASH_BOX_PRECEDENCE_N - 0 * LSMASH_BOX_PRECEDENCE_S)
2269 #define LSMASH_BOX_PRECEDENCE_ISOM_MFRA (LSMASH_BOX_PRECEDENCE_L - 0 * LSMASH_BOX_PRECEDENCE_S)
2270 #define LSMASH_BOX_PRECEDENCE_ISOM_TFRA (LSMASH_BOX_PRECEDENCE_N - 0 * LSMASH_BOX_PRECEDENCE_S)
2271 #define LSMASH_BOX_PRECEDENCE_ISOM_MFRO (LSMASH_BOX_PRECEDENCE_L - 0 * LSMASH_BOX_PRECEDENCE_S)
2272 #define LSMASH_BOX_PRECEDENCE_ISOM_MDAT (LSMASH_BOX_PRECEDENCE_N - 0 * LSMASH_BOX_PRECEDENCE_S)
2273 #define LSMASH_BOX_PRECEDENCE_ISOM_FREE (LSMASH_BOX_PRECEDENCE_N - 0 * LSMASH_BOX_PRECEDENCE_S)
2274 #define LSMASH_BOX_PRECEDENCE_ISOM_SKIP (LSMASH_BOX_PRECEDENCE_N - 0 * LSMASH_BOX_PRECEDENCE_S)
2276 /* Track reference types */
2277 typedef enum
2279 ISOM_TREF_TYPE_AVCP = LSMASH_4CC( 'a', 'v', 'c', 'p' ), /* AVC parameter set stream link */
2280 ISOM_TREF_TYPE_CDSC = LSMASH_4CC( 'c', 'd', 's', 'c' ), /* This track describes the referenced track. */
2281 ISOM_TREF_TYPE_DPND = LSMASH_4CC( 'd', 'p', 'n', 'd' ), /* This track has an MPEG-4 dependency on the referenced track. */
2282 ISOM_TREF_TYPE_HIND = LSMASH_4CC( 'h', 'i', 'n', 'd' ), /* Hint dependency */
2283 ISOM_TREF_TYPE_HINT = LSMASH_4CC( 'h', 'i', 'n', 't' ), /* Links hint track to original media track */
2284 ISOM_TREF_TYPE_IPIR = LSMASH_4CC( 'i', 'p', 'i', 'r' ), /* This track contains IPI declarations for the referenced track. */
2285 ISOM_TREF_TYPE_MPOD = LSMASH_4CC( 'm', 'p', 'o', 'd' ), /* This track is an OD track which uses the referenced track as an included elementary stream track. */
2286 ISOM_TREF_TYPE_SBAS = LSMASH_4CC( 's', 'b', 'a', 's' ), /* Scalable base */
2287 ISOM_TREF_TYPE_SCAL = LSMASH_4CC( 's', 'c', 'a', 'l' ), /* Scalable extraction */
2288 ISOM_TREF_TYPE_SWFR = LSMASH_4CC( 's', 'w', 'f', 'r' ), /* AVC Switch from */
2289 ISOM_TREF_TYPE_SWTO = LSMASH_4CC( 's', 'w', 't', 'o' ), /* AVC Switch to */
2290 ISOM_TREF_TYPE_SYNC = LSMASH_4CC( 's', 'y', 'n', 'c' ), /* This track uses the referenced track as its synchronization source. */
2291 ISOM_TREF_TYPE_VDEP = LSMASH_4CC( 'v', 'd', 'e', 'p' ), /* Auxiliary video depth */
2292 ISOM_TREF_TYPE_VPLX = LSMASH_4CC( 'v', 'p', 'l', 'x' ), /* Auxiliary video parallax */
2294 QT_TREF_TYPE_CHAP = LSMASH_4CC( 'c', 'h', 'a', 'p' ), /* Chapter or scene list. Usually references a text track. */
2295 QT_TREF_TYPE_SCPT = LSMASH_4CC( 's', 'c', 'p', 't' ), /* Transcript. Usually references a text track. */
2296 QT_TREF_TYPE_SSRC = LSMASH_4CC( 's', 's', 'r', 'c' ), /* Nonprimary source. Indicates that the referenced track should send its data to this track, rather than presenting it. */
2297 QT_TREF_TYPE_TMCD = LSMASH_4CC( 't', 'm', 'c', 'd' ), /* Time code. Usually references a time code track. */
2298 } isom_track_reference_type;
2300 /* Handler types */
2301 enum isom_handler_type
2303 QT_HANDLER_TYPE_DATA = LSMASH_4CC( 'd', 'h', 'l', 'r' ),
2304 QT_HANDLER_TYPE_MEDIA = LSMASH_4CC( 'm', 'h', 'l', 'r' ),
2307 enum isom_meta_type
2309 ISOM_META_HANDLER_TYPE_ITUNES_METADATA = LSMASH_4CC( 'm', 'd', 'i', 'r' ),
2312 /* Data reference types */
2313 enum isom_data_reference_type
2315 ISOM_REFERENCE_HANDLER_TYPE_URL = LSMASH_4CC( 'u', 'r', 'l', ' ' ),
2316 ISOM_REFERENCE_HANDLER_TYPE_URN = LSMASH_4CC( 'u', 'r', 'n', ' ' ),
2318 QT_REFERENCE_HANDLER_TYPE_ALIAS = LSMASH_4CC( 'a', 'l', 'i', 's' ),
2319 QT_REFERENCE_HANDLER_TYPE_RESOURCE = LSMASH_4CC( 'r', 's', 'r', 'c' ),
2320 QT_REFERENCE_HANDLER_TYPE_URL = LSMASH_4CC( 'u', 'r', 'l', ' ' ),
2323 /* Lanuage codes */
2324 typedef struct
2326 uint16_t mac_value;
2327 uint16_t iso_name;
2328 } isom_language_t;
2330 static const isom_language_t isom_languages[] =
2332 { 0, ISOM_LANGUAGE_CODE_ENGLISH },
2333 { 1, ISOM_LANGUAGE_CODE_FRENCH },
2334 { 2, ISOM_LANGUAGE_CODE_GERMAN },
2335 { 3, ISOM_LANGUAGE_CODE_ITALIAN },
2336 { 4, ISOM_LANGUAGE_CODE_DUTCH_M },
2337 { 5, ISOM_LANGUAGE_CODE_SWEDISH },
2338 { 6, ISOM_LANGUAGE_CODE_SPANISH },
2339 { 7, ISOM_LANGUAGE_CODE_DANISH },
2340 { 8, ISOM_LANGUAGE_CODE_PORTUGUESE },
2341 { 9, ISOM_LANGUAGE_CODE_NORWEGIAN },
2342 { 10, ISOM_LANGUAGE_CODE_HEBREW },
2343 { 11, ISOM_LANGUAGE_CODE_JAPANESE },
2344 { 12, ISOM_LANGUAGE_CODE_ARABIC },
2345 { 13, ISOM_LANGUAGE_CODE_FINNISH },
2346 { 14, ISOM_LANGUAGE_CODE_GREEK },
2347 { 15, ISOM_LANGUAGE_CODE_ICELANDIC },
2348 { 16, ISOM_LANGUAGE_CODE_MALTESE },
2349 { 17, ISOM_LANGUAGE_CODE_TURKISH },
2350 { 18, ISOM_LANGUAGE_CODE_CROATIAN },
2351 { 19, ISOM_LANGUAGE_CODE_CHINESE },
2352 { 20, ISOM_LANGUAGE_CODE_URDU },
2353 { 21, ISOM_LANGUAGE_CODE_HINDI },
2354 { 22, ISOM_LANGUAGE_CODE_THAI },
2355 { 23, ISOM_LANGUAGE_CODE_KOREAN },
2356 { 24, ISOM_LANGUAGE_CODE_LITHUANIAN },
2357 { 25, ISOM_LANGUAGE_CODE_POLISH },
2358 { 26, ISOM_LANGUAGE_CODE_HUNGARIAN },
2359 { 27, ISOM_LANGUAGE_CODE_ESTONIAN },
2360 { 28, ISOM_LANGUAGE_CODE_LATVIAN },
2361 { 29, ISOM_LANGUAGE_CODE_SAMI },
2362 { 30, ISOM_LANGUAGE_CODE_FAROESE },
2363 { 32, ISOM_LANGUAGE_CODE_RUSSIAN },
2364 { 33, ISOM_LANGUAGE_CODE_CHINESE },
2365 { 34, ISOM_LANGUAGE_CODE_DUTCH },
2366 { 35, ISOM_LANGUAGE_CODE_IRISH },
2367 { 36, ISOM_LANGUAGE_CODE_ALBANIAN },
2368 { 37, ISOM_LANGUAGE_CODE_ROMANIAN },
2369 { 38, ISOM_LANGUAGE_CODE_CZECH },
2370 { 39, ISOM_LANGUAGE_CODE_SLOVAK },
2371 { 40, ISOM_LANGUAGE_CODE_SLOVENIA },
2372 { 41, ISOM_LANGUAGE_CODE_YIDDISH },
2373 { 42, ISOM_LANGUAGE_CODE_SERBIAN },
2374 { 43, ISOM_LANGUAGE_CODE_MACEDONIAN },
2375 { 44, ISOM_LANGUAGE_CODE_BULGARIAN },
2376 { 45, ISOM_LANGUAGE_CODE_UKRAINIAN },
2377 { 46, ISOM_LANGUAGE_CODE_BELARUSIAN },
2378 { 47, ISOM_LANGUAGE_CODE_UZBEK },
2379 { 48, ISOM_LANGUAGE_CODE_KAZAKH },
2380 { 49, ISOM_LANGUAGE_CODE_AZERBAIJANI },
2381 { 51, ISOM_LANGUAGE_CODE_ARMENIAN },
2382 { 52, ISOM_LANGUAGE_CODE_GEORGIAN },
2383 { 53, ISOM_LANGUAGE_CODE_MOLDAVIAN },
2384 { 54, ISOM_LANGUAGE_CODE_KIRGHIZ },
2385 { 55, ISOM_LANGUAGE_CODE_TAJIK },
2386 { 56, ISOM_LANGUAGE_CODE_TURKMEN },
2387 { 57, ISOM_LANGUAGE_CODE_MONGOLIAN },
2388 { 59, ISOM_LANGUAGE_CODE_PASHTO },
2389 { 60, ISOM_LANGUAGE_CODE_KURDISH },
2390 { 61, ISOM_LANGUAGE_CODE_KASHMIRI },
2391 { 62, ISOM_LANGUAGE_CODE_SINDHI },
2392 { 63, ISOM_LANGUAGE_CODE_TIBETAN },
2393 { 64, ISOM_LANGUAGE_CODE_NEPALI },
2394 { 65, ISOM_LANGUAGE_CODE_SANSKRIT },
2395 { 66, ISOM_LANGUAGE_CODE_MARATHI },
2396 { 67, ISOM_LANGUAGE_CODE_BENGALI },
2397 { 68, ISOM_LANGUAGE_CODE_ASSAMESE },
2398 { 69, ISOM_LANGUAGE_CODE_GUJARATI },
2399 { 70, ISOM_LANGUAGE_CODE_PUNJABI },
2400 { 71, ISOM_LANGUAGE_CODE_ORIYA },
2401 { 72, ISOM_LANGUAGE_CODE_MALAYALAM },
2402 { 73, ISOM_LANGUAGE_CODE_KANNADA },
2403 { 74, ISOM_LANGUAGE_CODE_TAMIL },
2404 { 75, ISOM_LANGUAGE_CODE_TELUGU },
2405 { 76, ISOM_LANGUAGE_CODE_SINHALESE },
2406 { 77, ISOM_LANGUAGE_CODE_BURMESE },
2407 { 78, ISOM_LANGUAGE_CODE_KHMER },
2408 { 79, ISOM_LANGUAGE_CODE_LAO },
2409 { 80, ISOM_LANGUAGE_CODE_VIETNAMESE },
2410 { 81, ISOM_LANGUAGE_CODE_INDONESIAN },
2411 { 82, ISOM_LANGUAGE_CODE_TAGALOG },
2412 { 83, ISOM_LANGUAGE_CODE_MALAY_ROMAN },
2413 { 84, ISOM_LANGUAGE_CODE_MAYAY_ARABIC },
2414 { 85, ISOM_LANGUAGE_CODE_AMHARIC },
2415 { 87, ISOM_LANGUAGE_CODE_OROMO },
2416 { 88, ISOM_LANGUAGE_CODE_SOMALI },
2417 { 89, ISOM_LANGUAGE_CODE_SWAHILI },
2418 { 90, ISOM_LANGUAGE_CODE_KINYARWANDA },
2419 { 91, ISOM_LANGUAGE_CODE_RUNDI },
2420 { 92, ISOM_LANGUAGE_CODE_CHEWA },
2421 { 93, ISOM_LANGUAGE_CODE_MALAGASY },
2422 { 94, ISOM_LANGUAGE_CODE_ESPERANTO },
2423 { 128, ISOM_LANGUAGE_CODE_WELSH },
2424 { 129, ISOM_LANGUAGE_CODE_BASQUE },
2425 { 130, ISOM_LANGUAGE_CODE_CATALAN },
2426 { 131, ISOM_LANGUAGE_CODE_LATIN },
2427 { 132, ISOM_LANGUAGE_CODE_QUECHUA },
2428 { 133, ISOM_LANGUAGE_CODE_GUARANI },
2429 { 134, ISOM_LANGUAGE_CODE_AYMARA },
2430 { 135, ISOM_LANGUAGE_CODE_TATAR },
2431 { 136, ISOM_LANGUAGE_CODE_UIGHUR },
2432 { 137, ISOM_LANGUAGE_CODE_DZONGKHA },
2433 { 138, ISOM_LANGUAGE_CODE_JAVANESE },
2434 { UINT16_MAX, 0 }
2437 /* Color parameters */
2438 enum isom_color_patameter_type
2440 ISOM_COLOR_PARAMETER_TYPE_NCLX = LSMASH_4CC( 'n', 'c', 'l', 'x' ), /* on-screen colours */
2441 ISOM_COLOR_PARAMETER_TYPE_RICC = LSMASH_4CC( 'r', 'I', 'C', 'C' ), /* restricted ICC profile */
2442 ISOM_COLOR_PARAMETER_TYPE_PROF = LSMASH_4CC( 'p', 'r', 'o', 'f' ), /* unrestricted ICC profile */
2444 QT_COLOR_PARAMETER_TYPE_NCLC = LSMASH_4CC( 'n', 'c', 'l', 'c' ), /* NonConstant Luminance Coding */
2445 QT_COLOR_PARAMETER_TYPE_PROF = LSMASH_4CC( 'p', 'r', 'o', 'f' ), /* ICC profile */
2448 /* Sample grouping types */
2449 typedef enum
2451 ISOM_GROUP_TYPE_3GAG = LSMASH_4CC( '3', 'g', 'a', 'g' ), /* Text track3GPP PSS Annex G video buffer parameters */
2452 ISOM_GROUP_TYPE_ALST = LSMASH_4CC( 'a', 'l', 's', 't' ), /* Alternative startup sequence */
2453 ISOM_GROUP_TYPE_AVCB = LSMASH_4CC( 'a', 'v', 'c', 'b' ), /* AVC HRD parameters */
2454 ISOM_GROUP_TYPE_AVLL = LSMASH_4CC( 'a', 'v', 'l', 'l' ), /* AVC Layer */
2455 ISOM_GROUP_TYPE_AVSS = LSMASH_4CC( 'a', 'v', 's', 's' ), /* AVC Sub Sequence */
2456 ISOM_GROUP_TYPE_DTRT = LSMASH_4CC( 'd', 't', 'r', 't' ), /* Decode re-timing */
2457 ISOM_GROUP_TYPE_MVIF = LSMASH_4CC( 'm', 'v', 'i', 'f' ), /* MVC Scalability Information */
2458 ISOM_GROUP_TYPE_PROL = LSMASH_4CC( 'p', 'r', 'o', 'l' ), /* Pre-roll */
2459 ISOM_GROUP_TYPE_RAP = LSMASH_4CC( 'r', 'a', 'p', ' ' ), /* Random Access Point */
2460 ISOM_GROUP_TYPE_RASH = LSMASH_4CC( 'r', 'a', 's', 'h' ), /* Rate Share */
2461 ISOM_GROUP_TYPE_ROLL = LSMASH_4CC( 'r', 'o', 'l', 'l' ), /* Pre-roll/Post-roll */
2462 ISOM_GROUP_TYPE_SCIF = LSMASH_4CC( 's', 'c', 'i', 'f' ), /* SVC Scalability Information */
2463 ISOM_GROUP_TYPE_SCNM = LSMASH_4CC( 's', 'c', 'n', 'm' ), /* AVC/SVC/MVC map groups */
2464 ISOM_GROUP_TYPE_VIPR = LSMASH_4CC( 'v', 'i', 'p', 'r' ), /* View priority */
2465 } isom_grouping_type;
2467 /* wrapper to avoid boring cast */
2468 #define isom_init_box_common( box, parent, box_type, precedence, destructor ) \
2469 isom_init_box_common_orig( box, parent, box_type, precedence, (isom_extension_destructor_t)(destructor) )
2471 void isom_init_box_common_orig
2473 void *box,
2474 void *parent,
2475 lsmash_box_type_t box_type,
2476 uint64_t precedence,
2477 isom_extension_destructor_t destructor
2480 int isom_is_fullbox( void *box );
2481 int isom_is_lpcm_audio( void *box );
2482 int isom_is_qt_audio( lsmash_codec_type_t type );
2483 int isom_is_uncompressed_ycbcr( lsmash_codec_type_t type );
2484 int isom_is_waveform_audio( lsmash_box_type_t type );
2486 size_t isom_skip_box_common
2488 uint8_t **p_data
2491 uint8_t *isom_get_child_box_position
2493 uint8_t *parent_data,
2494 uint32_t parent_size,
2495 lsmash_box_type_t child_type,
2496 uint32_t *child_size
2499 void isom_bs_put_basebox_common( lsmash_bs_t *bs, isom_box_t *box );
2500 void isom_bs_put_fullbox_common( lsmash_bs_t *bs, isom_box_t *box );
2501 void isom_bs_put_box_common( lsmash_bs_t *bs, void *box );
2503 #define isom_is_printable_char( c ) ((c) >= 32 && (c) < 128)
2504 #define isom_is_printable_4cc( fourcc ) \
2505 (isom_is_printable_char( ((fourcc) >> 24) & 0xff ) \
2506 && isom_is_printable_char( ((fourcc) >> 16) & 0xff ) \
2507 && isom_is_printable_char( ((fourcc) >> 8) & 0xff ) \
2508 && isom_is_printable_char( (fourcc) & 0xff ))
2510 #define isom_4cc2str( fourcc ) (const char [5]){ (fourcc) >> 24, (fourcc) >> 16, (fourcc) >> 8, (fourcc), 0 }
2512 int isom_check_initializer_present( lsmash_root_t *root );
2514 isom_trak_t *isom_get_trak( lsmash_file_t *file, uint32_t track_ID );
2515 isom_trex_t *isom_get_trex( isom_mvex_t *mvex, uint32_t track_ID );
2516 isom_traf_t *isom_get_traf( isom_moof_t *moof, uint32_t track_ID );
2517 isom_tfra_t *isom_get_tfra( isom_mfra_t *mfra, uint32_t track_ID );
2518 isom_sgpd_t *isom_get_sample_group_description( isom_stbl_t *stbl, uint32_t grouping_type );
2519 isom_sbgp_t *isom_get_sample_to_group( isom_stbl_t *stbl, uint32_t grouping_type );
2520 isom_sgpd_t *isom_get_roll_recovery_sample_group_description( lsmash_entry_list_t *list );
2521 isom_sbgp_t *isom_get_roll_recovery_sample_to_group( lsmash_entry_list_t *list );
2522 isom_sgpd_t *isom_get_fragment_sample_group_description( isom_traf_t *traf, uint32_t grouping_type );
2523 isom_sbgp_t *isom_get_fragment_sample_to_group( isom_traf_t *traf, uint32_t grouping_type );
2525 isom_trak_t *isom_track_create( lsmash_file_t *file, lsmash_media_type media_type );
2526 isom_moov_t *isom_movie_create( lsmash_file_t *file );
2528 int isom_setup_handler_reference( isom_hdlr_t *hdlr, uint32_t media_type );
2529 int isom_setup_iods( isom_moov_t *moov );
2531 uint32_t isom_get_sample_count
2533 isom_trak_t *trak
2536 isom_sample_pool_t *isom_create_sample_pool
2538 uint64_t size
2541 int isom_update_sample_tables
2543 isom_trak_t *trak,
2544 lsmash_sample_t *sample,
2545 uint32_t *samples_per_packet,
2546 isom_sample_entry_t *sample_entry
2549 int isom_pool_sample
2551 isom_sample_pool_t *pool,
2552 lsmash_sample_t *sample,
2553 uint32_t samples_per_packet
2556 int isom_append_sample_by_type
2558 void *track,
2559 lsmash_sample_t *sample,
2560 isom_sample_entry_t *sample_entry,
2561 int (*func_append_sample)( void *, lsmash_sample_t *, isom_sample_entry_t * )
2564 int isom_calculate_bitrate_description
2566 isom_stbl_t *stbl,
2567 isom_mdhd_t *mdhd,
2568 uint32_t *bufferSizeDB,
2569 uint32_t *maxBitrate,
2570 uint32_t *avgBitrate,
2571 uint32_t sample_description_index
2574 int isom_is_variable_size
2576 isom_stbl_t *stbl
2579 uint32_t isom_get_first_sample_size
2581 isom_stbl_t *stbl
2584 /* Utilities for sample entry type decision
2585 * NOTE: This implementation does not work when 'mdia' and/or 'hdlr' is stored as binary string. */
2586 static inline int isom_check_media_hdlr_from_stsd( isom_stsd_t *stsd )
2588 return ((isom_stbl_t *)stsd->parent
2589 && (isom_minf_t *)stsd->parent->parent
2590 && (isom_mdia_t *)stsd->parent->parent->parent
2591 && ((isom_mdia_t *)stsd->parent->parent->parent)->hdlr);
2593 static inline lsmash_media_type isom_get_media_type_from_stsd( isom_stsd_t *stsd )
2595 assert( isom_check_media_hdlr_from_stsd( stsd ) );
2596 return ((isom_mdia_t *)stsd->parent->parent->parent)->hdlr->componentSubtype;
2599 int isom_add_sample_grouping( isom_box_t *parent, isom_grouping_type grouping_type );
2600 int isom_group_random_access( isom_box_t *parent, isom_cache_t *cache, lsmash_sample_t *sample );
2601 int isom_group_roll_recovery( isom_box_t *parent, isom_cache_t *cache, lsmash_sample_t *sample );
2603 int isom_update_tkhd_duration( isom_trak_t *trak );
2604 int isom_update_bitrate_description( isom_mdia_t *mdia );
2605 int isom_complement_data_reference( isom_minf_t *minf );
2606 int isom_check_large_offset_requirement( isom_moov_t *moov, uint64_t meta_size );
2607 void isom_add_preceding_box_size( isom_moov_t *moov, uint64_t preceding_size );
2608 int isom_establish_movie( lsmash_file_t *file );
2609 int isom_rap_grouping_established( isom_rap_group_t *group, int num_leading_samples_known, isom_sgpd_t *sgpd, int is_fragment );
2610 int isom_all_recovery_completed( isom_sbgp_t *sbgp, lsmash_entry_list_t *pool );
2612 lsmash_file_t *isom_add_file( lsmash_root_t *root );
2613 isom_ftyp_t *isom_add_ftyp( lsmash_file_t *file );
2614 isom_moov_t *isom_add_moov( lsmash_file_t *file );
2615 isom_mvhd_t *isom_add_mvhd( isom_moov_t *moov );
2616 isom_iods_t *isom_add_iods( isom_moov_t *moov );
2617 isom_ctab_t *isom_add_ctab( void *parent_box );
2618 isom_trak_t *isom_add_trak( isom_moov_t *moov );
2619 isom_tkhd_t *isom_add_tkhd( isom_trak_t *trak );
2620 isom_tapt_t *isom_add_tapt( isom_trak_t *trak );
2621 isom_clef_t *isom_add_clef( isom_tapt_t *tapt );
2622 isom_prof_t *isom_add_prof( isom_tapt_t *tapt );
2623 isom_enof_t *isom_add_enof( isom_tapt_t *tapt );
2624 isom_edts_t *isom_add_edts( isom_trak_t *trak );
2625 isom_elst_t *isom_add_elst( isom_edts_t *edts );
2626 isom_tref_t *isom_add_tref( isom_trak_t *trak );
2627 isom_tref_type_t *isom_add_track_reference_type( isom_tref_t *tref, isom_track_reference_type type );
2628 isom_mdia_t *isom_add_mdia( isom_trak_t *trak );
2629 isom_mdhd_t *isom_add_mdhd( isom_mdia_t *mdia );
2630 isom_hdlr_t *isom_add_hdlr( void *parent_box );
2631 isom_minf_t *isom_add_minf( isom_mdia_t *mdia );
2632 isom_vmhd_t *isom_add_vmhd( isom_minf_t *minf );
2633 isom_smhd_t *isom_add_smhd( isom_minf_t *minf );
2634 isom_hmhd_t *isom_add_hmhd( isom_minf_t *minf );
2635 isom_nmhd_t *isom_add_nmhd( isom_minf_t *minf );
2636 isom_gmhd_t *isom_add_gmhd( isom_minf_t *minf );
2637 isom_gmin_t *isom_add_gmin( isom_gmhd_t *gmhd );
2638 isom_text_t *isom_add_text( isom_gmhd_t *gmhd );
2639 isom_dinf_t *isom_add_dinf( void *parent_box );
2640 isom_dref_t *isom_add_dref( isom_dinf_t *dinf );
2641 isom_dref_entry_t *isom_add_dref_entry( isom_dref_t *dref, lsmash_box_type_t type );
2642 isom_stbl_t *isom_add_stbl( isom_minf_t *minf );
2643 isom_stsd_t *isom_add_stsd( isom_stbl_t *stbl );
2644 isom_visual_entry_t *isom_add_visual_description( isom_stsd_t *stsd, lsmash_codec_type_t sample_type );
2645 isom_audio_entry_t *isom_add_audio_description( isom_stsd_t *stsd, lsmash_codec_type_t sample_type );
2646 isom_qt_text_entry_t *isom_add_qt_text_description( isom_stsd_t *stsd );
2647 isom_tx3g_entry_t *isom_add_tx3g_description( isom_stsd_t *stsd );
2648 isom_esds_t *isom_add_esds( void *parent_box );
2649 isom_glbl_t *isom_add_glbl( void *parent_box );
2650 isom_clap_t *isom_add_clap( isom_visual_entry_t *visual );
2651 isom_pasp_t *isom_add_pasp( isom_visual_entry_t *visual );
2652 isom_colr_t *isom_add_colr( isom_visual_entry_t *visual );
2653 isom_gama_t *isom_add_gama( isom_visual_entry_t *visual );
2654 isom_fiel_t *isom_add_fiel( isom_visual_entry_t *visual );
2655 isom_cspc_t *isom_add_cspc( isom_visual_entry_t *visual );
2656 isom_sgbt_t *isom_add_sgbt( isom_visual_entry_t *visual );
2657 isom_stsl_t *isom_add_stsl( isom_visual_entry_t *visual );
2658 isom_btrt_t *isom_add_btrt( isom_visual_entry_t *visual );
2659 isom_wave_t *isom_add_wave( isom_audio_entry_t *audio );
2660 isom_frma_t *isom_add_frma( isom_wave_t *wave );
2661 isom_enda_t *isom_add_enda( isom_wave_t *wave );
2662 isom_mp4a_t *isom_add_mp4a( isom_wave_t *wave );
2663 isom_terminator_t *isom_add_terminator( isom_wave_t *wave );
2664 isom_chan_t *isom_add_chan( isom_audio_entry_t *audio );
2665 isom_srat_t *isom_add_srat( isom_audio_entry_t *audio );
2666 isom_ftab_t *isom_add_ftab( isom_tx3g_entry_t *tx3g );
2667 isom_stts_t *isom_add_stts( isom_stbl_t *stbl );
2668 isom_ctts_t *isom_add_ctts( isom_stbl_t *stbl );
2669 isom_cslg_t *isom_add_cslg( isom_stbl_t *stbl );
2670 isom_stsc_t *isom_add_stsc( isom_stbl_t *stbl );
2671 isom_stsz_t *isom_add_stsz( isom_stbl_t *stbl );
2672 isom_stz2_t *isom_add_stz2( isom_stbl_t *stbl );
2673 isom_stss_t *isom_add_stss( isom_stbl_t *stbl );
2674 isom_stps_t *isom_add_stps( isom_stbl_t *stbl );
2675 isom_sdtp_t *isom_add_sdtp( isom_box_t *parent );
2676 isom_sgpd_t *isom_add_sgpd( void *parent_box );
2677 isom_sbgp_t *isom_add_sbgp( void *parent_box );
2678 isom_stco_t *isom_add_stco( isom_stbl_t *stbl );
2679 isom_stco_t *isom_add_co64( isom_stbl_t *stbl );
2680 isom_udta_t *isom_add_udta( void *parent_box );
2681 isom_cprt_t *isom_add_cprt( isom_udta_t *udta );
2682 isom_WLOC_t *isom_add_WLOC( isom_udta_t *udta );
2683 isom_LOOP_t *isom_add_LOOP( isom_udta_t *udta );
2684 isom_SelO_t *isom_add_SelO( isom_udta_t *udta );
2685 isom_AllF_t *isom_add_AllF( isom_udta_t *udta );
2686 isom_chpl_t *isom_add_chpl( isom_udta_t *udta );
2687 isom_meta_t *isom_add_meta( void *parent_box );
2688 isom_keys_t *isom_add_keys( isom_meta_t *meta );
2689 isom_ilst_t *isom_add_ilst( isom_meta_t *meta );
2690 isom_metaitem_t *isom_add_metaitem( isom_ilst_t *ilst, lsmash_itunes_metadata_item item );
2691 isom_mean_t *isom_add_mean( isom_metaitem_t *metaitem );
2692 isom_name_t *isom_add_name( isom_metaitem_t *metaitem );
2693 isom_data_t *isom_add_data( isom_metaitem_t *metaitem );
2694 isom_mvex_t *isom_add_mvex( isom_moov_t *moov );
2695 isom_mehd_t *isom_add_mehd( isom_mvex_t *mvex );
2696 isom_trex_t *isom_add_trex( isom_mvex_t *mvex );
2697 isom_moof_t *isom_add_moof( lsmash_file_t *file );
2698 isom_mfhd_t *isom_add_mfhd( isom_moof_t *moof );
2699 isom_traf_t *isom_add_traf( isom_moof_t *moof );
2700 isom_tfhd_t *isom_add_tfhd( isom_traf_t *traf );
2701 isom_tfdt_t *isom_add_tfdt( isom_traf_t *traf );
2702 isom_trun_t *isom_add_trun( isom_traf_t *traf );
2703 isom_mfra_t *isom_add_mfra( lsmash_file_t *file );
2704 isom_tfra_t *isom_add_tfra( isom_mfra_t *mfra );
2705 isom_mfro_t *isom_add_mfro( isom_mfra_t *mfra );
2706 isom_mdat_t *isom_add_mdat( lsmash_file_t *file );
2707 isom_free_t *isom_add_free( void *parent_box );
2708 isom_styp_t *isom_add_styp( lsmash_file_t *file );
2709 isom_sidx_t *isom_add_sidx( lsmash_file_t *file );
2711 void isom_remove_sample_description( isom_sample_entry_t *sample );
2712 void isom_remove_unknown_box( isom_unknown_box_t *unknown_box );
2713 void isom_remove_sample_pool( isom_sample_pool_t *pool );
2715 uint64_t isom_update_box_size( void *box );
2717 int isom_add_extension_binary( void *parent_box, lsmash_box_type_t box_type, uint64_t precedence, uint8_t *box_data, uint32_t box_size );
2718 void isom_remove_all_extension_boxes( lsmash_entry_list_t *extensions );
2719 isom_box_t *isom_get_extension_box( lsmash_entry_list_t *extensions, lsmash_box_type_t box_type );
2720 void *isom_get_extension_box_format( lsmash_entry_list_t *extensions, lsmash_box_type_t box_type );
2721 void isom_remove_box_by_itself( void *opaque_box );
2723 #endif