write: Fix type size for mdcv luminance
[L-SMASH.git] / lsmash.h
blob289c75058034d0b23680ffac4431ec99be97de6d
1 /*****************************************************************************
2 * lsmash.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_H
24 #define LSMASH_H
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
30 #include <stddef.h>
31 #include <stdint.h>
33 #define PRIVATE /* If this declaration is placed at a variable, any user shall NOT use it. */
35 /**************************************************************************************
36 * Handle windows dll imports. The user must define this before including this header.
37 **************************************************************************************/
38 #ifdef LSMASH_API_IMPORTS
39 #define LSMASH_API __declspec(dllimport)
40 #else
41 #define LSMASH_API
42 #endif
44 #define LSMASH_4CC( a, b, c, d ) (((a)<<24) | ((b)<<16) | ((c)<<8) | (d))
46 /****************************************************************************
47 * Version
48 ****************************************************************************/
49 #define LSMASH_VERSION_MAJOR 2
50 #define LSMASH_VERSION_MINOR 16
51 #define LSMASH_VERSION_MICRO 1
53 #define LSMASH_VERSION_INT( a, b, c ) (((a) << 16) | ((b) << 8) | (c))
55 #define LIBLSMASH_VERSION_INT LSMASH_VERSION_INT( LSMASH_VERSION_MAJOR, \
56 LSMASH_VERSION_MINOR, \
57 LSMASH_VERSION_MICRO )
59 /****************************************************************************
60 * Error Values
61 ****************************************************************************/
62 enum
64 LSMASH_ERR_NAMELESS = -1, /* An error but not assigned to any following errors */
65 LSMASH_ERR_MEMORY_ALLOC = -2, /* There is not enough room in the heap. */
66 LSMASH_ERR_INVALID_DATA = -3, /* Invalid data was found. */
67 LSMASH_ERR_FUNCTION_PARAM = -4, /* An error in the parameter list of the function */
68 LSMASH_ERR_PATCH_WELCOME = -5, /* Not implemented yet, so patches welcome. */
69 LSMASH_ERR_UNKNOWN = -6, /* Unknown error occured. */
70 LSMASH_ERR_IO = -7, /* I/O error occurred. */
73 /****************************************************************************
74 * ROOT
75 * The top-level opaque handler for whole file handling.
76 ****************************************************************************/
77 typedef struct lsmash_root_tag lsmash_root_t;
79 /* Allocate a ROOT.
80 * The allocated ROOT can be deallocate by lsmash_destroy_root().
82 * Return the address of an allocated ROOT if successful.
83 * Return NULL otherwise. */
84 lsmash_root_t *lsmash_create_root
86 void
89 /* Deallocate a given ROOT. */
90 void lsmash_destroy_root
92 lsmash_root_t *root /* the address of a ROOT you want to deallocate */
95 /****************************************************************************
96 * File Layer
97 ****************************************************************************/
98 typedef struct lsmash_file_tag lsmash_file_t;
100 typedef enum
102 LSMASH_FILE_MODE_WRITE = 1, /* output/muxing */
103 LSMASH_FILE_MODE_READ = 1<<1, /* input/demuxing */
104 LSMASH_FILE_MODE_FRAGMENTED = 1<<2, /* movie fragments */
105 LSMASH_FILE_MODE_DUMP = 1<<3,
106 LSMASH_FILE_MODE_BOX = 1<<4, /* box structure */
107 LSMASH_FILE_MODE_INITIALIZATION = 1<<5, /* movie sample table */
108 LSMASH_FILE_MODE_MEDIA = 1<<6, /* media data */
109 LSMASH_FILE_MODE_INDEX = 1<<7,
110 LSMASH_FILE_MODE_SEGMENT = 1<<8, /* segment */
111 LSMASH_FILE_MODE_WRITE_FRAGMENTED = LSMASH_FILE_MODE_WRITE | LSMASH_FILE_MODE_FRAGMENTED, /* deprecated */
112 } lsmash_file_mode;
114 typedef enum
116 ISOM_BRAND_TYPE_3G2A = LSMASH_4CC( '3', 'g', '2', 'a' ), /* 3GPP2 */
117 ISOM_BRAND_TYPE_3GE6 = LSMASH_4CC( '3', 'g', 'e', '6' ), /* 3GPP Release 6 Extended Presentation Profile */
118 ISOM_BRAND_TYPE_3GE9 = LSMASH_4CC( '3', 'g', 'e', '9' ), /* 3GPP Release 9 Extended Presentation Profile */
119 ISOM_BRAND_TYPE_3GF9 = LSMASH_4CC( '3', 'g', 'f', '9' ), /* 3GPP Release 9 File-delivery Server Profile */
120 ISOM_BRAND_TYPE_3GG6 = LSMASH_4CC( '3', 'g', 'g', '6' ), /* 3GPP Release 6 General Profile */
121 ISOM_BRAND_TYPE_3GG9 = LSMASH_4CC( '3', 'g', 'g', '9' ), /* 3GPP Release 9 General Profile */
122 ISOM_BRAND_TYPE_3GH9 = LSMASH_4CC( '3', 'g', 'h', '9' ), /* 3GPP Release 9 Adaptive Streaming Profile */
123 ISOM_BRAND_TYPE_3GM9 = LSMASH_4CC( '3', 'g', 'm', '9' ), /* 3GPP Release 9 Media Segment Profile */
124 ISOM_BRAND_TYPE_3GP4 = LSMASH_4CC( '3', 'g', 'p', '4' ), /* 3GPP Release 4 */
125 ISOM_BRAND_TYPE_3GP5 = LSMASH_4CC( '3', 'g', 'p', '5' ), /* 3GPP Release 5 */
126 ISOM_BRAND_TYPE_3GP6 = LSMASH_4CC( '3', 'g', 'p', '6' ), /* 3GPP Release 6 Basic Profile */
127 ISOM_BRAND_TYPE_3GP7 = LSMASH_4CC( '3', 'g', 'p', '7' ), /* 3GPP Release 7 */
128 ISOM_BRAND_TYPE_3GP8 = LSMASH_4CC( '3', 'g', 'p', '8' ), /* 3GPP Release 8 */
129 ISOM_BRAND_TYPE_3GP9 = LSMASH_4CC( '3', 'g', 'p', '9' ), /* 3GPP Release 9 Basic Profile */
130 ISOM_BRAND_TYPE_3GR6 = LSMASH_4CC( '3', 'g', 'r', '6' ), /* 3GPP Release 6 Progressive Download Profile */
131 ISOM_BRAND_TYPE_3GR9 = LSMASH_4CC( '3', 'g', 'r', '9' ), /* 3GPP Release 9 Progressive Download Profile */
132 ISOM_BRAND_TYPE_3GS6 = LSMASH_4CC( '3', 'g', 's', '6' ), /* 3GPP Release 6 Streaming Server Profile */
133 ISOM_BRAND_TYPE_3GS9 = LSMASH_4CC( '3', 'g', 's', '9' ), /* 3GPP Release 9 Streaming Server Profile */
134 ISOM_BRAND_TYPE_3GT9 = LSMASH_4CC( '3', 'g', 't', '9' ), /* 3GPP Release 9 Media Stream Recording Profile */
135 ISOM_BRAND_TYPE_ARRI = LSMASH_4CC( 'A', 'R', 'R', 'I' ), /* ARRI Digital Camera */
136 ISOM_BRAND_TYPE_CAEP = LSMASH_4CC( 'C', 'A', 'E', 'P' ), /* Canon Digital Camera */
137 ISOM_BRAND_TYPE_CDES = LSMASH_4CC( 'C', 'D', 'e', 's' ), /* Convergent Designs */
138 ISOM_BRAND_TYPE_LCAG = LSMASH_4CC( 'L', 'C', 'A', 'G' ), /* Leica digital camera */
139 ISOM_BRAND_TYPE_M4A = LSMASH_4CC( 'M', '4', 'A', ' ' ), /* iTunes MPEG-4 audio protected or not */
140 ISOM_BRAND_TYPE_M4B = LSMASH_4CC( 'M', '4', 'B', ' ' ), /* iTunes AudioBook protected or not */
141 ISOM_BRAND_TYPE_M4P = LSMASH_4CC( 'M', '4', 'P', ' ' ), /* MPEG-4 protected audio */
142 ISOM_BRAND_TYPE_M4V = LSMASH_4CC( 'M', '4', 'V', ' ' ), /* MPEG-4 protected audio+video */
143 ISOM_BRAND_TYPE_MFSM = LSMASH_4CC( 'M', 'F', 'S', 'M' ), /* Media File for Samsung video Metadata */
144 ISOM_BRAND_TYPE_MPPI = LSMASH_4CC( 'M', 'P', 'P', 'I' ), /* Photo Player Multimedia Application Format */
145 ISOM_BRAND_TYPE_ROSS = LSMASH_4CC( 'R', 'O', 'S', 'S' ), /* Ross Video */
146 ISOM_BRAND_TYPE_AVC1 = LSMASH_4CC( 'a', 'v', 'c', '1' ), /* Advanced Video Coding extensions */
147 ISOM_BRAND_TYPE_BBXM = LSMASH_4CC( 'b', 'b', 'x', 'm' ), /* Blinkbox Master File */
148 ISOM_BRAND_TYPE_CAQV = LSMASH_4CC( 'c', 'a', 'q', 'v' ), /* Casio Digital Camera */
149 ISOM_BRAND_TYPE_CCFF = LSMASH_4CC( 'c', 'c', 'f', 'f' ), /* Common container file format */
150 ISOM_BRAND_TYPE_DA0A = LSMASH_4CC( 'd', 'a', '0', 'a' ), /* DMB AF */
151 ISOM_BRAND_TYPE_DA0B = LSMASH_4CC( 'd', 'a', '0', 'b' ), /* DMB AF */
152 ISOM_BRAND_TYPE_DA1A = LSMASH_4CC( 'd', 'a', '1', 'a' ), /* DMB AF */
153 ISOM_BRAND_TYPE_DA1B = LSMASH_4CC( 'd', 'a', '1', 'b' ), /* DMB AF */
154 ISOM_BRAND_TYPE_DA2A = LSMASH_4CC( 'd', 'a', '2', 'a' ), /* DMB AF */
155 ISOM_BRAND_TYPE_DA2B = LSMASH_4CC( 'd', 'a', '2', 'b' ), /* DMB AF */
156 ISOM_BRAND_TYPE_DA3A = LSMASH_4CC( 'd', 'a', '3', 'a' ), /* DMB AF */
157 ISOM_BRAND_TYPE_DA3B = LSMASH_4CC( 'd', 'a', '3', 'b' ), /* DMB AF */
158 ISOM_BRAND_TYPE_DASH = LSMASH_4CC( 'd', 'a', 's', 'h' ), /* Indexed self-initializing Media Segment */
159 ISOM_BRAND_TYPE_DBY1 = LSMASH_4CC( 'd', 'b', 'y', '1' ), /* MP4 files with Dolby content */
160 ISOM_BRAND_TYPE_DMB1 = LSMASH_4CC( 'd', 'm', 'b', '1' ), /* DMB AF */
161 ISOM_BRAND_TYPE_DSMS = LSMASH_4CC( 'd', 's', 'm', 's' ), /* Self-initializing Media Segment */
162 ISOM_BRAND_TYPE_DV1A = LSMASH_4CC( 'd', 'v', '1', 'a' ), /* DMB AF */
163 ISOM_BRAND_TYPE_DV1B = LSMASH_4CC( 'd', 'v', '1', 'b' ), /* DMB AF */
164 ISOM_BRAND_TYPE_DV2A = LSMASH_4CC( 'd', 'v', '2', 'a' ), /* DMB AF */
165 ISOM_BRAND_TYPE_DV2B = LSMASH_4CC( 'd', 'v', '2', 'b' ), /* DMB AF */
166 ISOM_BRAND_TYPE_DV3A = LSMASH_4CC( 'd', 'v', '3', 'a' ), /* DMB AF */
167 ISOM_BRAND_TYPE_DV3B = LSMASH_4CC( 'd', 'v', '3', 'b' ), /* DMB AF */
168 ISOM_BRAND_TYPE_DVR1 = LSMASH_4CC( 'd', 'v', 'r', '1' ), /* DVB RTP */
169 ISOM_BRAND_TYPE_DVT1 = LSMASH_4CC( 'd', 'v', 't', '1' ), /* DVB Transport Stream */
170 ISOM_BRAND_TYPE_IFRM = LSMASH_4CC( 'i', 'f', 'r', 'm' ), /* Apple iFrame */
171 ISOM_BRAND_TYPE_ISC2 = LSMASH_4CC( 'i', 's', 'c', '2' ), /* Files encrypted according to ISMACryp 2.0 */
172 ISOM_BRAND_TYPE_ISO2 = LSMASH_4CC( 'i', 's', 'o', '2' ), /* ISO Base Media file format version 2 */
173 ISOM_BRAND_TYPE_ISO3 = LSMASH_4CC( 'i', 's', 'o', '3' ), /* ISO Base Media file format version 3 */
174 ISOM_BRAND_TYPE_ISO4 = LSMASH_4CC( 'i', 's', 'o', '4' ), /* ISO Base Media file format version 4 */
175 ISOM_BRAND_TYPE_ISO5 = LSMASH_4CC( 'i', 's', 'o', '5' ), /* ISO Base Media file format version 5 */
176 ISOM_BRAND_TYPE_ISO6 = LSMASH_4CC( 'i', 's', 'o', '6' ), /* ISO Base Media file format version 6 */
177 ISOM_BRAND_TYPE_ISO7 = LSMASH_4CC( 'i', 's', 'o', '7' ), /* ISO Base Media file format version 7 */
178 ISOM_BRAND_TYPE_ISOM = LSMASH_4CC( 'i', 's', 'o', 'm' ), /* ISO Base Media file format version 1 */
179 ISOM_BRAND_TYPE_JPSI = LSMASH_4CC( 'j', 'p', 's', 'i' ), /* The JPSearch data interchange format */
180 ISOM_BRAND_TYPE_LMSG = LSMASH_4CC( 'l', 'm', 's', 'g' ), /* last Media Segment indicator */
181 ISOM_BRAND_TYPE_MJ2S = LSMASH_4CC( 'm', 'j', '2', 's' ), /* Motion JPEG 2000 simple profile */
182 ISOM_BRAND_TYPE_MJP2 = LSMASH_4CC( 'm', 'j', 'p', '2' ), /* Motion JPEG 2000, general profile */
183 ISOM_BRAND_TYPE_MP21 = LSMASH_4CC( 'm', 'p', '2', '1' ), /* MPEG-21 */
184 ISOM_BRAND_TYPE_MP41 = LSMASH_4CC( 'm', 'p', '4', '1' ), /* MP4 version 1 */
185 ISOM_BRAND_TYPE_MP42 = LSMASH_4CC( 'm', 'p', '4', '2' ), /* MP4 version 2 */
186 ISOM_BRAND_TYPE_MP71 = LSMASH_4CC( 'm', 'p', '7', '1' ), /* MPEG-7 file-level metadata */
187 ISOM_BRAND_TYPE_MSDH = LSMASH_4CC( 'm', 's', 'd', 'h' ), /* Media Segment */
188 ISOM_BRAND_TYPE_MSIX = LSMASH_4CC( 'm', 's', 'i', 'x' ), /* Indexed Media Segment */
189 ISOM_BRAND_TYPE_NIKO = LSMASH_4CC( 'n', 'i', 'k', 'o' ), /* Nikon Digital Camera */
190 ISOM_BRAND_TYPE_ODCF = LSMASH_4CC( 'o', 'd', 'c', 'f' ), /* OMA DCF */
191 ISOM_BRAND_TYPE_OPF2 = LSMASH_4CC( 'o', 'p', 'f', '2' ), /* OMA PDCF */
192 ISOM_BRAND_TYPE_OPX2 = LSMASH_4CC( 'o', 'p', 'x', '2' ), /* OMA Adapted PDCF */
193 ISOM_BRAND_TYPE_PANA = LSMASH_4CC( 'p', 'a', 'n', 'a' ), /* Panasonic Digital Camera */
194 ISOM_BRAND_TYPE_PIFF = LSMASH_4CC( 'p', 'i', 'f', 'f' ), /* Protected Interoperable File Format */
195 ISOM_BRAND_TYPE_PNVI = LSMASH_4CC( 'p', 'n', 'v', 'i' ), /* Panasonic Video Intercom */
196 ISOM_BRAND_TYPE_QT = LSMASH_4CC( 'q', 't', ' ', ' ' ), /* QuickTime file format */
197 ISOM_BRAND_TYPE_RISX = LSMASH_4CC( 'r', 'i', 's', 'x' ), /* Representation Index Segment */
198 ISOM_BRAND_TYPE_SDV = LSMASH_4CC( 's', 'd', 'v', ' ' ), /* SD Video */
199 ISOM_BRAND_TYPE_SIMS = LSMASH_4CC( 's', 'i', 'm', 's' ), /* Sub-Indexed Media Segment */
200 ISOM_BRAND_TYPE_SISX = LSMASH_4CC( 's', 'i', 's', 'x' ), /* Single Index Segment */
201 ISOM_BRAND_TYPE_SSSS = LSMASH_4CC( 's', 's', 's', 's' ), /* Subsegment Index Segment */
202 } lsmash_brand_type;
204 typedef struct
206 lsmash_file_mode mode; /* file modes */
207 /** custom I/O stuff **/
208 void *opaque; /* custom I/O opaque handler used for the following callback functions */
209 /* Attempt to read up to 'size' bytes from the file referenced by 'opaque' into the buffer starting at 'buf'.
211 * Return the number of bytes read if successful.
212 * Return 0 if no more read.
213 * Return a negative value otherwise. */
214 int (*read)
216 void *opaque,
217 uint8_t *buf,
218 int size
220 /* Write up to 'size' bytes to the file referenced by 'opaque' from the buffer starting at 'buf'.
222 * Return the number of bytes written if successful.
223 * Return a negative value otherwise. */
224 int (*write)
226 void *opaque,
227 uint8_t *buf,
228 int size
230 /* Change the location of the read/write pointer of 'opaque'.
231 * The offset of the pointer is determined according to the directive 'whence' as follows:
232 * If 'whence' is set to SEEK_SET, the offset is set to 'offset' bytes.
233 * If 'whence' is set to SEEK_CUR, the offset is set to its current location plus 'offset' bytes.
234 * If 'whence' is set to SEEK_END, the offset is set to the size of the file plus 'offset' bytes.
236 * Return the resulting offset of the location in bytes from the beginning of the file if successful.
237 * Return a negative value otherwise. */
238 int64_t (*seek)
240 void *opaque,
241 int64_t offset,
242 int whence
244 /** file types or segment types **/
245 lsmash_brand_type major_brand; /* the best used brand */
246 lsmash_brand_type *brands; /* the list of compatible brands */
247 uint32_t brand_count; /* the number of compatible brands used in the file */
248 uint32_t minor_version; /* minor version of the best used brand
249 * minor_version is informative only i.e. not specifying requirements but merely providing information.
250 * It must not be used to determine the conformance of a file to a standard. */
251 /** muxing only **/
252 double max_chunk_duration; /* max duration per chunk in seconds. 0.5 is default value. */
253 double max_async_tolerance; /* max tolerance, in seconds, for amount of interleaving asynchronization between tracks.
254 * 2.0 is default value. At least twice of max_chunk_duration is used. */
255 uint64_t max_chunk_size; /* max size per chunk in bytes. 4*1024*1024 (4MiB) is default value. */
256 /** demuxing only **/
257 uint64_t max_read_size; /* max size of reading from the file at a time. 4*1024*1024 (4MiB) is default value. */
258 } lsmash_file_parameters_t;
260 typedef int (*lsmash_adhoc_remux_callback)( void *param, uint64_t done, uint64_t total );
261 typedef struct
263 uint64_t buffer_size;
264 lsmash_adhoc_remux_callback func;
265 void *param;
266 } lsmash_adhoc_remux_t;
268 /* Open a file where the path is given.
269 * And if successful, set up the parameters by 'open_mode'.
270 * Here, the 'open_mode' parameter is either 0 or 1 as follows:
271 * 0: Create a file for output/muxing operations.
272 * If a file with the same name already exists, its contents are discarded and the file is treated as a new file.
273 * If user specifies "-" for 'filename', operations are done on stdout.
274 * The file types or segment types are set up as specified in 'param'.
275 * 1: Open a file for input/demuxing operations. The file must exist.
276 * If user specifies "-" for 'filename', operations are done on stdin.
278 * This function sets up file modes minimally.
279 * User can add additional modes and/or remove modes already set later.
280 * The other parameters except for the custom I/O stuff are set to a default.
281 * User shall not touch the custom I/O stuff for the opened file if using this function.
283 * The opened file can be closed by lsmash_close_file().
285 * Note:
286 * 'filename' must be encoded by UTF-8 if 'open_mode' is equal to 0.
287 * On Windows, lsmash_convert_ansi_to_utf8() may help you.
289 * Return 0 if successful.
290 * Return a negative value otherwise. */
291 int lsmash_open_file
293 const char *filename,
294 int open_mode,
295 lsmash_file_parameters_t *param
298 /* Close a file opened by lsmash_open_file().
300 * Return 0 if successful.
301 * Return a negative value otherwise. */
302 int lsmash_close_file
304 lsmash_file_parameters_t *param
307 /* Associate a file with a ROOT and allocate the handle of that file.
308 * The all allocated handles can be deallocated by lsmash_destroy_root().
309 * If the ROOT has no associated file yet, the first associated file is activated.
311 * Return the address of the allocated handle of the added file if successful.
312 * Return NULL otherwise. */
313 lsmash_file_t *lsmash_set_file
315 lsmash_root_t *root,
316 lsmash_file_parameters_t *param
319 /* Read whole boxes in a given file.
320 * You can also get file modes and file types or segment types by this function.
322 * Return the file size (if seekable) or 0 if successful.
323 * Return a negative value otherwise. */
324 int64_t lsmash_read_file
326 lsmash_file_t *file,
327 lsmash_file_parameters_t *param
330 /* Deallocate all boxes within the current active file in a given ROOT. */
331 void lsmash_discard_boxes
333 lsmash_root_t *root /* the address of a ROOT you want to deallocate all boxes within the active file in it */
336 /* Activate a file associated with a ROOT.
338 * Return 0 if successful.
339 * Return a negative value otherwise. */
340 int lsmash_activate_file
342 lsmash_root_t *root,
343 lsmash_file_t *file
346 /* Switch from the current segment file to the following media segment file.
347 * After switching, the followed segment file can be closed unless that file is an initialization segment.
349 * The first followed segment file must be also an initialization segment.
350 * The second or later segment files must not be an initialization segment.
351 * For media segment files flagging LSMASH_FILE_MODE_INDEX, 'remux' must be set.
353 * Users shall call lsmash_flush_pooled_samples() for each track before calling this function.
355 * Return 0 if successful.
356 * Return a negative value otherwise. */
357 int lsmash_switch_media_segment
359 lsmash_root_t *root,
360 lsmash_file_t *successor,
361 lsmash_adhoc_remux_t *remux
364 /****************************************************************************
365 * Basic Types
366 ****************************************************************************/
367 /* rational types */
368 typedef struct
370 uint32_t n; /* numerator */
371 uint32_t d; /* denominator */
372 } lsmash_rational_u32_t;
374 typedef struct
376 int32_t n; /* numerator */
377 uint32_t d; /* denominator */
378 } lsmash_rational_s32_t;
380 typedef enum
382 LSMASH_BOOLEAN_FALSE = 0,
383 LSMASH_BOOLEAN_TRUE = 1
384 } lsmash_boolean_t;
386 /****************************************************************************
387 * Allocation
388 ****************************************************************************/
389 /* Allocate a memory block.
390 * The allocated memory block can be deallocate by lsmash_free().
392 * Return the address to the beginning of a memory block if successful.
393 * Return NULL otherwise. */
394 void *lsmash_malloc
396 size_t size /* size of a memory block, in bytes */
399 /* Allocate a memory block.
400 * The allocated memory block shall be initialized to all bits 0.
401 * The allocated memory block can be deallocate by lsmash_free().
403 * Return the address to the beginning of a memory block if successful.
404 * Return NULL otherwise. */
405 void *lsmash_malloc_zero
407 size_t size /* size of a memory block, in bytes */
410 /* Reallocate a memory block.
411 * The reallocated memory block can be deallocate by lsmash_free().
412 * If this function succeed, the given memory block is deallocated and the address is invalid.
413 * If this function fails, the address to the given memory block is still valid and the memory block is unchanged.
415 * Return the address to the beginning of a memory block if successful.
416 * Return NULL otherwise. */
417 void *lsmash_realloc
419 void *ptr, /* an address to a memory block previously allocated with
420 * lsmash_malloc(), lsmash_malloc_zero(), lsmash_realloc() or lsmash_memdup()
421 * Alternatively, NULL makes this function to allocate a new memory block. */
422 size_t size /* size of a memory block, in bytes */
425 /* Allocate a memory block and copy all bits from a given memory block.
426 * The allocated memory block can be deallocate by lsmash_free().
428 * Return the address to the beginning of an allocated memory block if successful.
429 * Return NULL otherwise. */
430 void *lsmash_memdup
432 const void *ptr, /* an address to the source of data to be copied */
433 size_t size /* number of bytes to copy */
436 /* Deallocate a given memory block.
437 * If the given address to a memory block is NULL, this function does nothing. */
438 void lsmash_free
440 void *ptr /* an address to a memory block previously allocated with
441 * lsmash_malloc(), lsmash_malloc_zero(), lsmash_realloc() or lsmash_memdup() */
444 /* Deallocate a given memory block.
445 * If the given address to a memory block is NULL, this function does nothing.
446 * Set NULL to the pointer to the memory block after deallocating.
448 * As an example of usage.
449 * Let's say you allocate a memory block and set the address to the beginning of it to the pointer 'ptr'.
450 * You can deallocate the memory block and set NULL to 'ptr' by lsmash_freep( &ptr ).
452 void lsmash_freep
454 void *ptrptr /* the address to a pointer to a memory block previously allocated with
455 * lsmash_malloc(), lsmash_malloc_zero(), lsmash_realloc() or lsmash_memdup() */
458 /****************************************************************************
459 * Box
460 ****************************************************************************/
461 typedef struct lsmash_box_tag lsmash_box_t;
462 typedef uint32_t lsmash_compact_box_type_t;
464 /* An UUID structure for extended box type */
465 typedef struct
467 uint32_t fourcc; /* four characters codes that identify extended box type partially
468 * If the box is not a UUID box, this field shall be the same as the box type.
469 * Note: characters in this field aren't always printable. */
470 uint8_t id[12]; /* If the box is not a UUID box, this field shall be set to 12-byte ISO reserved value
471 * { 0x00, 0x11, 0x00, 0x10, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 }
472 * and shall not be written into the stream together with above-defined four characters codes.
473 * As an exception, we could set the value
474 * { 0x0F, 0x11, 0x4D, 0xA5, 0xBF, 0x4E, 0xF2, 0xC4, 0x8C, 0x6A, 0xA1, 0x1E }
475 * to indicate the box is derived from QuickTime file format. */
476 } lsmash_extended_box_type_t;
478 typedef struct
480 lsmash_compact_box_type_t fourcc; /* four characters codes that identify box type
481 * Note: characters in this field aren't always printable. */
482 lsmash_extended_box_type_t user; /* Universal Unique IDentifier, i.e. UUID */
483 /* If 'fourcc' doesn't equal 'uuid', ignore this field. */
484 } lsmash_box_type_t;
486 typedef struct
488 lsmash_box_type_t type; /* box type */
489 uint32_t number; /* the number of box in ascending order excluding boxes unspecified by 'type' within
490 * the same level of the box nested structure. */
491 } lsmash_box_path_t;
493 #define LSMASH_BOX_TYPE_INITIALIZER { 0x00000000, { 0x00000000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } }
494 #define LSMASH_BOX_TYPE_UNSPECIFIED static_lsmash_box_type_unspecified
495 LSMASH_API extern const lsmash_box_type_t static_lsmash_box_type_unspecified;
497 /* Return extended box type that consists of combination of given FourCC and 12-byte ID. */
498 lsmash_extended_box_type_t lsmash_form_extended_box_type
500 uint32_t fourcc,
501 const uint8_t id[12]
504 /* Return box type that consists of combination of given compact and extended box type. */
505 lsmash_box_type_t lsmash_form_box_type
507 lsmash_compact_box_type_t type,
508 lsmash_extended_box_type_t user
511 #define LSMASH_ISO_BOX_TYPE_INITIALIZER( x ) { x, { x, { 0x00, 0x11, 0x00, 0x10, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71 } } }
512 #define LSMASH_QTFF_BOX_TYPE_INITIALIZER( x ) { x, { x, { 0x0F, 0x11, 0x4D, 0xA5, 0xBF, 0x4E, 0xF2, 0xC4, 0x8C, 0x6A, 0xA1, 0x1E } } }
513 lsmash_box_type_t lsmash_form_iso_box_type
515 lsmash_compact_box_type_t type
518 lsmash_box_type_t lsmash_form_qtff_box_type
520 lsmash_compact_box_type_t type
523 /* precedence of the box position
524 * Box with higher value will precede physically other boxes with lower one.
525 * The lower 32-bits are intended to determine order of boxes with the same box type. */
526 #define LSMASH_BOX_PRECEDENCE_L 0x0000000000800000ULL /* Lowest */
527 #define LSMASH_BOX_PRECEDENCE_LP 0x000FFFFF00000000ULL /* Lowest+ */
528 #define LSMASH_BOX_PRECEDENCE_N 0x0080000000000000ULL /* Normal */
529 #define LSMASH_BOX_PRECEDENCE_HM 0xFFEEEEEE00000000ULL /* Highest- */
530 #define LSMASH_BOX_PRECEDENCE_H 0xFFFFFFFF00800000ULL /* Highest */
531 #define LSMASH_BOX_PRECEDENCE_S 0x0000010000000000ULL /* Step */
533 /* Check if the type of two boxes is identical or not.
535 * Return 1 if the both box types are identical.
536 * Return 0 otherwise. */
537 int lsmash_check_box_type_identical
539 lsmash_box_type_t a,
540 lsmash_box_type_t b
543 /* Check if the type of a given box is already specified or not.
545 * Return 1 if the box type is specified.
546 * Return 0 otherwise, i.e. LSMASH_BOX_TYPE_UNSPECIFIED. */
547 int lsmash_check_box_type_specified
549 const lsmash_box_type_t *box_type
552 /* Allocate a box.
553 * The allocated box can be deallocated by lsmash_destroy_box().
555 * Return the address of an allocated box if successful.
556 * Return NULL otherwise. */
557 lsmash_box_t *lsmash_create_box
559 lsmash_box_type_t type,
560 uint8_t *data,
561 uint32_t size,
562 uint64_t precedence
565 /* Get a box under a given 'parent' box.
566 * The path of a box must be terminated by LSMASH_BOX_TYPE_UNSPECIFIED.
568 * Return the address of the box specified by 'box_path'.
569 * Return NULL otherwise. */
570 lsmash_box_t *lsmash_get_box
572 lsmash_box_t *parent,
573 const lsmash_box_path_t box_path[]
576 /* Add a box into 'parent' box as a child box.
578 * Return 0 if successful.
579 * Return a negative value otherwise. */
580 int lsmash_add_box
582 lsmash_box_t *parent,
583 lsmash_box_t *box
586 /* Add a box into 'parent' box as a child box.
587 * If the adding child box is known and its children (if any) are known, expand them into known
588 * struct formats for the internal references within the L-SMASH library.
589 * If this function succeed, the adding child box is deallocated and the address is invalid.
590 * Instead of that, this function replaces the invalid address with the valid one of the new
591 * allocated memory block representing the added and expanded child box.
593 * Return 0 if successful.
594 * Return a negative value otherwise. */
595 int lsmash_add_box_ex
597 lsmash_box_t *parent,
598 lsmash_box_t **box
601 /* Deallocate a given box and its children. */
602 void lsmash_destroy_box
604 lsmash_box_t *box
607 /* Deallocate all children of a given box. */
608 void lsmash_destroy_children
610 lsmash_box_t *box
613 /* Get the precedence of a given box.
615 * Return 0 if successful.
616 * Return a negative value otherwise. */
617 int lsmash_get_box_precedence
619 lsmash_box_t *box,
620 uint64_t *precedence
623 /* This function allows you to handle a ROOT as if it is a box.
624 * Of course, you can deallocate the ROOT by lsmash_destroy_box().
626 * Return the address of a given ROOT as a box. */
627 lsmash_box_t *lsmash_root_as_box
629 lsmash_root_t *root
632 /* This function allows you to handle the handle of a file as if it is a box.
633 * Of course, you can deallocate the handle of the file by lsmash_destroy_box().
635 * Return the address of the handle of a given file as a box. */
636 lsmash_box_t *lsmash_file_as_box
638 lsmash_file_t *file
641 /* Write a top level box and its children already added to a file.
642 * WARNING:
643 * You should not use this function as long as media data is incompletely written.
644 * That is before starting to write a media data or after finishing of writing that.
646 * Return 0 if successful.
647 * Return a negative value otherwise. */
648 int lsmash_write_top_level_box
650 lsmash_box_t *box
653 /* Export the data of a given box and its children as the binary string.
654 * The returned address is of the beginning of an allocated memory block.
655 * You can deallocate the memory block by lsmash_free().
657 * Note that some boxes cannot be exported since L-SMASH might skip the cache for them.
658 * Media Data Box is an unexportable example.
660 * Return the address to the beginning of the binary string if successful.
661 * Return NULL otherwise. */
662 uint8_t *lsmash_export_box
664 lsmash_box_t *box,
665 uint32_t *size
668 /****************************************************************************
669 * CODEC identifiers
670 ****************************************************************************/
671 typedef lsmash_box_type_t lsmash_codec_type_t;
673 #define LSMASH_CODEC_TYPE_INITIALIZER LSMASH_BOX_TYPE_INITIALIZER
674 #define LSMASH_CODEC_TYPE_UNSPECIFIED LSMASH_BOX_TYPE_UNSPECIFIED
676 #ifndef LSMASH_INITIALIZE_CODEC_ID_HERE
677 #define DEFINE_ISOM_CODEC_TYPE( BOX_TYPE_NAME, BOX_TYPE_FOURCC ) \
678 LSMASH_API extern const lsmash_codec_type_t BOX_TYPE_NAME
679 #define DEFINE_QTFF_CODEC_TYPE( BOX_TYPE_NAME, BOX_TYPE_FOURCC ) \
680 LSMASH_API extern const lsmash_codec_type_t BOX_TYPE_NAME
681 #else
682 #define DEFINE_ISOM_CODEC_TYPE( BOX_TYPE_NAME, BOX_TYPE_FOURCC ) \
683 const lsmash_codec_type_t BOX_TYPE_NAME = LSMASH_ISO_BOX_TYPE_INITIALIZER( BOX_TYPE_FOURCC )
684 #define DEFINE_QTFF_CODEC_TYPE( BOX_TYPE_NAME, BOX_TYPE_FOURCC ) \
685 const lsmash_codec_type_t BOX_TYPE_NAME = LSMASH_QTFF_BOX_TYPE_INITIALIZER( BOX_TYPE_FOURCC )
686 #endif
688 /* Audio CODEC identifiers */
689 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_AC_3_AUDIO, LSMASH_4CC( 'a', 'c', '-', '3' ) ); /* AC-3 audio */
690 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_ALAC_AUDIO, LSMASH_4CC( 'a', 'l', 'a', 'c' ) ); /* Apple lossless audio codec */
691 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_DRA1_AUDIO, LSMASH_4CC( 'd', 'r', 'a', '1' ) ); /* DRA Audio */
692 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_DTSEL_AUDIO, LSMASH_4CC( 'd', 't', 's', '+' ) ); /* Enhancement layer for DTS layered audio */
693 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_DTSDL_AUDIO, LSMASH_4CC( 'd', 't', 's', '-' ) ); /* Dependent base layer for DTS layered audio */
694 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_DTSC_AUDIO, LSMASH_4CC( 'd', 't', 's', 'c' ) ); /* DTS Coherent Acoustics audio */
695 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_DTSE_AUDIO, LSMASH_4CC( 'd', 't', 's', 'e' ) ); /* DTS Express low bit rate audio, also known as DTS LBR */
696 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_DTSH_AUDIO, LSMASH_4CC( 'd', 't', 's', 'h' ) ); /* DTS-HD High Resolution Audio */
697 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_DTSL_AUDIO, LSMASH_4CC( 'd', 't', 's', 'l' ) ); /* DTS-HD Master Audio */
698 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_DTSX_AUDIO, LSMASH_4CC( 'd', 't', 's', 'x' ) ); /* DTS:X */
699 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_EC_3_AUDIO, LSMASH_4CC( 'e', 'c', '-', '3' ) ); /* Enhanced AC-3 audio */
700 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_ENCA_AUDIO, LSMASH_4CC( 'e', 'n', 'c', 'a' ) ); /* Encrypted/Protected audio */
701 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_G719_AUDIO, LSMASH_4CC( 'g', '7', '1', '9' ) ); /* ITU-T Recommendation G.719 (2008) ); */
702 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_G726_AUDIO, LSMASH_4CC( 'g', '7', '2', '6' ) ); /* ITU-T Recommendation G.726 (1990) ); */
703 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_M4AE_AUDIO, LSMASH_4CC( 'm', '4', 'a', 'e' ) ); /* MPEG-4 Audio Enhancement */
704 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_MLPA_AUDIO, LSMASH_4CC( 'm', 'l', 'p', 'a' ) ); /* MLP Audio */
705 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_MP4A_AUDIO, LSMASH_4CC( 'm', 'p', '4', 'a' ) ); /* MPEG-4 Audio */
706 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_RAW_AUDIO, LSMASH_4CC( 'r', 'a', 'w', ' ' ) ); /* Uncompressed audio */
707 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_SAMR_AUDIO, LSMASH_4CC( 's', 'a', 'm', 'r' ) ); /* Narrowband AMR voice */
708 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_SAWB_AUDIO, LSMASH_4CC( 's', 'a', 'w', 'b' ) ); /* Wideband AMR voice */
709 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_SAWP_AUDIO, LSMASH_4CC( 's', 'a', 'w', 'p' ) ); /* Extended AMR-WB (AMR-WB+) ); */
710 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_SEVC_AUDIO, LSMASH_4CC( 's', 'e', 'v', 'c' ) ); /* EVRC Voice */
711 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_SQCP_AUDIO, LSMASH_4CC( 's', 'q', 'c', 'p' ) ); /* 13K Voice */
712 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_SSMV_AUDIO, LSMASH_4CC( 's', 's', 'm', 'v' ) ); /* SMV Voice */
713 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_TWOS_AUDIO, LSMASH_4CC( 't', 'w', 'o', 's' ) ); /* Uncompressed 16-bit audio */
714 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_WMA_AUDIO, LSMASH_4CC( 'w', 'm', 'a', ' ' ) ); /* Windows Media Audio V2 or V3 (not registered at MP4RA) */
716 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_23NI_AUDIO, LSMASH_4CC( '2', '3', 'n', 'i' ) ); /* 32-bit little endian integer uncompressed */
717 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_MAC3_AUDIO, LSMASH_4CC( 'M', 'A', 'C', '3' ) ); /* MACE 3:1 */
718 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_MAC6_AUDIO, LSMASH_4CC( 'M', 'A', 'C', '6' ) ); /* MACE 6:1 */
719 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_NONE_AUDIO, LSMASH_4CC( 'N', 'O', 'N', 'E' ) ); /* either 'raw ' or 'twos' */
720 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_QDM2_AUDIO, LSMASH_4CC( 'Q', 'D', 'M', '2' ) ); /* Qdesign music 2 */
721 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_QDMC_AUDIO, LSMASH_4CC( 'Q', 'D', 'M', 'C' ) ); /* Qdesign music 1 */
722 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_QCLP_AUDIO, LSMASH_4CC( 'Q', 'c', 'l', 'p' ) ); /* Qualcomm PureVoice */
723 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_AC_3_AUDIO, LSMASH_4CC( 'a', 'c', '-', '3' ) ); /* Digital Audio Compression Standard (AC-3, Enhanced AC-3) */
724 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_AGSM_AUDIO, LSMASH_4CC( 'a', 'g', 's', 'm' ) ); /* GSM */
725 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_ALAC_AUDIO, LSMASH_4CC( 'a', 'l', 'a', 'c' ) ); /* Apple lossless audio codec */
726 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_ALAW_AUDIO, LSMASH_4CC( 'a', 'l', 'a', 'w' ) ); /* a-Law 2:1 */
727 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_CDX2_AUDIO, LSMASH_4CC( 'c', 'd', 'x', '2' ) ); /* CD/XA 2:1 */
728 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_CDX4_AUDIO, LSMASH_4CC( 'c', 'd', 'x', '4' ) ); /* CD/XA 4:1 */
729 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_DVCA_AUDIO, LSMASH_4CC( 'd', 'v', 'c', 'a' ) ); /* DV Audio */
730 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_DVI_AUDIO, LSMASH_4CC( 'd', 'v', 'i', ' ' ) ); /* DVI (as used in RTP, 4:1 compression) */
731 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_FL32_AUDIO, LSMASH_4CC( 'f', 'l', '3', '2' ) ); /* 32-bit float */
732 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_FL64_AUDIO, LSMASH_4CC( 'f', 'l', '6', '4' ) ); /* 64-bit float */
733 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_IMA4_AUDIO, LSMASH_4CC( 'i', 'm', 'a', '4' ) ); /* IMA (International Multimedia Assocation, defunct, 4:1) */
734 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_IN24_AUDIO, LSMASH_4CC( 'i', 'n', '2', '4' ) ); /* 24-bit integer uncompressed */
735 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_IN32_AUDIO, LSMASH_4CC( 'i', 'n', '3', '2' ) ); /* 32-bit integer uncompressed */
736 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_LPCM_AUDIO, LSMASH_4CC( 'l', 'p', 'c', 'm' ) ); /* Uncompressed audio (various integer and float formats) */
737 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_MP4A_AUDIO, LSMASH_4CC( 'm', 'p', '4', 'a' ) ); /* MPEG-4 Audio */
738 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_RAW_AUDIO, LSMASH_4CC( 'r', 'a', 'w', ' ' ) ); /* 8-bit offset-binary uncompressed */
739 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_SOWT_AUDIO, LSMASH_4CC( 's', 'o', 'w', 't' ) ); /* 16-bit little endian uncompressed */
740 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_TWOS_AUDIO, LSMASH_4CC( 't', 'w', 'o', 's' ) ); /* 8-bit or 16-bit big endian uncompressed */
741 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_ULAW_AUDIO, LSMASH_4CC( 'u', 'l', 'a', 'w' ) ); /* uLaw 2:1 */
742 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_VDVA_AUDIO, LSMASH_4CC( 'v', 'd', 'v', 'a' ) ); /* DV audio (variable duration per video frame) */
743 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_FULLMP3_AUDIO, LSMASH_4CC( '.', 'm', 'p', '3' ) ); /* MPEG-1 layer 3, CBR & VBR (QT4.1 and later) */
744 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_MP3_AUDIO, 0x6D730055 ); /* MPEG-1 layer 3, CBR only (pre-QT4.1) */
745 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_ADPCM2_AUDIO, 0x6D730002 ); /* Microsoft ADPCM - ACM code 2 */
746 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_ADPCM17_AUDIO, 0x6D730011 ); /* DVI/Intel IMA ADPCM - ACM code 17 */
747 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_GSM49_AUDIO, 0x6D730031 ); /* Microsoft GSM 6.10 - ACM code 49 */
748 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_NOT_SPECIFIED, 0x00000000 ); /* either 'raw ' or 'twos' */
750 /* Video CODEC identifiers */
751 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_AVC1_VIDEO, LSMASH_4CC( 'a', 'v', 'c', '1' ) ); /* Advanced Video Coding
752 * Any sample must not contain any paramerter set and filler data. */
753 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_AVC2_VIDEO, LSMASH_4CC( 'a', 'v', 'c', '2' ) ); /* Advanced Video Coding
754 * Any sample must not contain any paramerter set and filler data.
755 * May only be used when Extractors or Aggregators are required to be supported. */
756 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_AVC3_VIDEO, LSMASH_4CC( 'a', 'v', 'c', '3' ) ); /* Advanced Video Coding
757 * It is allowed that sample contains parameter sets and filler data. */
758 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_AVC4_VIDEO, LSMASH_4CC( 'a', 'v', 'c', '4' ) ); /* Advanced Video Coding
759 * It is allowed that sample contains parameter sets and filler data.
760 * May only be used when Extractors or Aggregators are required to be supported. */
761 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_AVCP_VIDEO, LSMASH_4CC( 'a', 'v', 'c', 'p' ) ); /* Advanced Video Coding Parameters */
762 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_DRAC_VIDEO, LSMASH_4CC( 'd', 'r', 'a', 'c' ) ); /* Dirac Video Coder */
763 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_ENCV_VIDEO, LSMASH_4CC( 'e', 'n', 'c', 'v' ) ); /* Encrypted/protected video */
764 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_HVC1_VIDEO, LSMASH_4CC( 'h', 'v', 'c', '1' ) ); /* High Efficiency Video Coding
765 * The default and mandatory value of array_completeness is 1 for arrays of
766 * all types of parameter sets, and 0 for all other arrays.
767 * This means any sample must not contain any paramerter set and filler data. */
768 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_HEV1_VIDEO, LSMASH_4CC( 'h', 'e', 'v', '1' ) ); /* High Efficiency Video Coding
769 * The default value of array_completeness is 0 for all arrays.
770 * It is allowed that sample contains parameter sets and filler data. */
771 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_MJP2_VIDEO, LSMASH_4CC( 'm', 'j', 'p', '2' ) ); /* Motion JPEG 2000 */
772 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_MP4V_VIDEO, LSMASH_4CC( 'm', 'p', '4', 'v' ) ); /* MPEG-4 Visual */
773 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_MVC1_VIDEO, LSMASH_4CC( 'm', 'v', 'c', '1' ) ); /* Multiview coding */
774 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_MVC2_VIDEO, LSMASH_4CC( 'm', 'v', 'c', '2' ) ); /* Multiview coding */
775 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_S263_VIDEO, LSMASH_4CC( 's', '2', '6', '3' ) ); /* ITU H.263 video (3GPP format) */
776 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_SVC1_VIDEO, LSMASH_4CC( 's', 'v', 'c', '1' ) ); /* Scalable Video Coding */
777 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_VC_1_VIDEO, LSMASH_4CC( 'v', 'c', '-', '1' ) ); /* SMPTE VC-1 */
779 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_2VUY_VIDEO, LSMASH_4CC( '2', 'v', 'u', 'y' ) ); /* Uncompressed Y'CbCr, 8-bit-per-component 4:2:2
780 * |Cb(8)|Y'0(8)|Cr(8)|Y'1(8)| */
781 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_CFHD_VIDEO, LSMASH_4CC( 'C', 'F', 'H', 'D' ) ); /* CineForm High-Definition (HD) wavelet codec */
782 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_DV10_VIDEO, LSMASH_4CC( 'D', 'V', '1', '0' ) ); /* Digital Voodoo 10 bit Uncompressed 4:2:2 codec */
783 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_DVOO_VIDEO, LSMASH_4CC( 'D', 'V', 'O', 'O' ) ); /* Digital Voodoo 8 bit Uncompressed 4:2:2 codec */
784 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_DVOR_VIDEO, LSMASH_4CC( 'D', 'V', 'O', 'R' ) ); /* Digital Voodoo intermediate raw */
785 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_DVTV_VIDEO, LSMASH_4CC( 'D', 'V', 'T', 'V' ) ); /* Digital Voodoo intermediate 2vuy */
786 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_DVVT_VIDEO, LSMASH_4CC( 'D', 'V', 'V', 'T' ) ); /* Digital Voodoo intermediate v210 */
787 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_HD10_VIDEO, LSMASH_4CC( 'H', 'D', '1', '0' ) ); /* Digital Voodoo 10 bit Uncompressed 4:2:2 HD codec */
788 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_M105_VIDEO, LSMASH_4CC( 'M', '1', '0', '5' ) ); /* Internal format of video data supported by Matrox hardware; pixel organization is proprietary*/
789 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_PNTG_VIDEO, LSMASH_4CC( 'P', 'N', 'T', 'G' ) ); /* Apple MacPaint image format */
790 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_SVQ1_VIDEO, LSMASH_4CC( 'S', 'V', 'Q', '1' ) ); /* Sorenson Video 1 video */
791 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_SVQ3_VIDEO, LSMASH_4CC( 'S', 'V', 'Q', '3' ) ); /* Sorenson Video 3 video */
792 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_SHR0_VIDEO, LSMASH_4CC( 'S', 'h', 'r', '0' ) ); /* Generic SheerVideo codec */
793 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_SHR1_VIDEO, LSMASH_4CC( 'S', 'h', 'r', '1' ) ); /* SheerVideo RGB[A] 8b - at 8 bits/channel */
794 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_SHR2_VIDEO, LSMASH_4CC( 'S', 'h', 'r', '2' ) ); /* SheerVideo Y'CbCr[A] 8bv 4:4:4[:4] - at 8 bits/channel, in ITU-R BT.601-4 video range */
795 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_SHR3_VIDEO, LSMASH_4CC( 'S', 'h', 'r', '3' ) ); /* SheerVideo Y'CbCr 8bv 4:2:2 - 2:1 chroma subsampling, at 8 bits/channel, in ITU-R BT.601-4 video range */
796 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_SHR4_VIDEO, LSMASH_4CC( 'S', 'h', 'r', '4' ) ); /* SheerVideo Y'CbCr 8bw 4:2:2 - 2:1 chroma subsampling, at 8 bits/channel, with full-range luma and wide-range two's-complement chroma */
797 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_WRLE_VIDEO, LSMASH_4CC( 'W', 'R', 'L', 'E' ) ); /* Windows BMP image format */
798 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_APCH_VIDEO, LSMASH_4CC( 'a', 'p', 'c', 'h' ) ); /* Apple ProRes 422 High Quality */
799 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_APCN_VIDEO, LSMASH_4CC( 'a', 'p', 'c', 'n' ) ); /* Apple ProRes 422 Standard Definition */
800 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_APCS_VIDEO, LSMASH_4CC( 'a', 'p', 'c', 's' ) ); /* Apple ProRes 422 LT */
801 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_APCO_VIDEO, LSMASH_4CC( 'a', 'p', 'c', 'o' ) ); /* Apple ProRes 422 Proxy */
802 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_AP4H_VIDEO, LSMASH_4CC( 'a', 'p', '4', 'h' ) ); /* Apple ProRes 4444 */
803 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_AP4X_VIDEO, LSMASH_4CC( 'a', 'p', '4', 'x' ) ); /* Apple ProRes 4444 XQ */
804 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_CIVD_VIDEO, LSMASH_4CC( 'c', 'i', 'v', 'd' ) ); /* Cinepak Video */
805 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_DRAC_VIDEO, LSMASH_4CC( 'd', 'r', 'a', 'c' ) ); /* Dirac Video Coder */
806 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_DVC_VIDEO, LSMASH_4CC( 'd', 'v', 'c', ' ' ) ); /* DV NTSC format */
807 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_DVCP_VIDEO, LSMASH_4CC( 'd', 'v', 'c', 'p' ) ); /* DV PAL format */
808 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_DVPP_VIDEO, LSMASH_4CC( 'd', 'v', 'p', 'p' ) ); /* Panasonic DVCPro PAL format */
809 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_DV5N_VIDEO, LSMASH_4CC( 'd', 'v', '5', 'n' ) ); /* Panasonic DVCPro-50 NTSC format */
810 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_DV5P_VIDEO, LSMASH_4CC( 'd', 'v', '5', 'p' ) ); /* Panasonic DVCPro-50 PAL format */
811 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_DVH2_VIDEO, LSMASH_4CC( 'd', 'v', 'h', '2' ) ); /* Panasonic DVCPro-HD 1080p25 format */
812 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_DVH3_VIDEO, LSMASH_4CC( 'd', 'v', 'h', '3' ) ); /* Panasonic DVCPro-HD 1080p30 format */
813 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_DVH5_VIDEO, LSMASH_4CC( 'd', 'v', 'h', '5' ) ); /* Panasonic DVCPro-HD 1080i50 format */
814 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_DVH6_VIDEO, LSMASH_4CC( 'd', 'v', 'h', '6' ) ); /* Panasonic DVCPro-HD 1080i60 format */
815 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_DVHP_VIDEO, LSMASH_4CC( 'd', 'v', 'h', 'p' ) ); /* Panasonic DVCPro-HD 720p60 format */
816 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_DVHQ_VIDEO, LSMASH_4CC( 'd', 'v', 'h', 'q' ) ); /* Panasonic DVCPro-HD 720p50 format */
817 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_FLIC_VIDEO, LSMASH_4CC( 'f', 'l', 'i', 'c' ) ); /* Autodesk FLIC animation format */
818 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_GIF_VIDEO, LSMASH_4CC( 'g', 'i', 'f', ' ' ) ); /* GIF image format */
819 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_H261_VIDEO, LSMASH_4CC( 'h', '2', '6', '1' ) ); /* ITU H.261 video */
820 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_H263_VIDEO, LSMASH_4CC( 'h', '2', '6', '3' ) ); /* ITU H.263 video */
821 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_JPEG_VIDEO, LSMASH_4CC( 'j', 'p', 'e', 'g' ) ); /* JPEG image format */
822 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_MJPA_VIDEO, LSMASH_4CC( 'm', 'j', 'p', 'a' ) ); /* Motion-JPEG (format A) */
823 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_MJPB_VIDEO, LSMASH_4CC( 'm', 'j', 'p', 'b' ) ); /* Motion-JPEG (format B) */
824 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_PNG_VIDEO, LSMASH_4CC( 'p', 'n', 'g', ' ' ) ); /* W3C Portable Network Graphics (PNG) */
825 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_RAW_VIDEO, LSMASH_4CC( 'r', 'a', 'w', ' ' ) ); /* Uncompressed RGB */
826 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_RLE_VIDEO, LSMASH_4CC( 'r', 'l', 'e', ' ' ) ); /* Apple animation codec */
827 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_RPZA_VIDEO, LSMASH_4CC( 'r', 'p', 'z', 'a' ) ); /* Apple simple video 'road pizza' compression */
828 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_TGA_VIDEO, LSMASH_4CC( 't', 'g', 'a', ' ' ) ); /* Truvision Targa video format */
829 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_TIFF_VIDEO, LSMASH_4CC( 't', 'i', 'f', 'f' ) ); /* Tagged Image File Format (Adobe) */
830 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_ULRA_VIDEO, LSMASH_4CC( 'U', 'L', 'R', 'A' ) ); /* Ut Video RGBA 4:4:4:4 8bit full-range */
831 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_ULRG_VIDEO, LSMASH_4CC( 'U', 'L', 'R', 'G' ) ); /* Ut Video RGB 4:4:4 8bit full-range */
832 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_ULY0_VIDEO, LSMASH_4CC( 'U', 'L', 'Y', '0' ) ); /* Ut Video YCbCr (BT.601) 4:2:0 8bit limited */
833 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_ULY2_VIDEO, LSMASH_4CC( 'U', 'L', 'Y', '2' ) ); /* Ut Video YCbCr (BT.601) 4:2:2 8bit limited */
834 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_ULH0_VIDEO, LSMASH_4CC( 'U', 'L', 'H', '0' ) ); /* Ut Video YCbCr (BT.709) 4:2:0 8bit limited */
835 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_ULH2_VIDEO, LSMASH_4CC( 'U', 'L', 'H', '2' ) ); /* Ut Video YCbCr (BT.709) 4:2:2 8bit limited */
836 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_UQY2_VIDEO, LSMASH_4CC( 'U', 'Q', 'Y', '2' ) ); /* Ut Video Pro YCbCr 4:2:2 10bit */
837 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_V210_VIDEO, LSMASH_4CC( 'v', '2', '1', '0' ) ); /* Uncompressed Y'CbCr, 10-bit-per-component 4:2:2
838 * |Cb0(10)|Y'0(10)|Cr0(10)|XX(2)|
839 * |Y'1(10)|Cb1(10)|Y'2(10)|XX(2)|
840 * |Cr1(10)|Y'3(10)|Cb2(10)|XX(2)|
841 * |Y'4(10)|Cr2(10)|Y'5(10)|XX(2)| (X is a zero bit) */
842 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_V216_VIDEO, LSMASH_4CC( 'v', '2', '1', '6' ) ); /* Uncompressed Y'CbCr, 10, 12, 14, or 16-bit-per-component 4:2:2
843 * |Cb(16 LE)|Y'0(16 LE)|Cr(16 LE)|Y'1(16 LE)| */
844 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_V308_VIDEO, LSMASH_4CC( 'v', '3', '0', '8' ) ); /* Uncompressed Y'CbCr, 8-bit-per-component 4:4:4
845 * |Cr(8)|Y'(8)|Cb(8)| */
846 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_V408_VIDEO, LSMASH_4CC( 'v', '4', '0', '8' ) ); /* Uncompressed Y'CbCrA, 8-bit-per-component 4:4:4:4
847 * |Cb(8)|Y'(8)|Cr(8)|A(8)| */
848 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_V410_VIDEO, LSMASH_4CC( 'v', '4', '1', '0' ) ); /* Uncompressed Y'CbCr, 10-bit-per-component 4:4:4
849 * |XX(2)|Cb(10)|Y'(10)|Cr(10)| (X is a zero bit) */
850 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_YUV2_VIDEO, LSMASH_4CC( 'y', 'u', 'v', '2' ) ); /* Uncompressed Y'CbCr, 8-bit-per-component 4:2:2
851 * |Y'0(8)|Cb(8)|Y'1(8)|Cr(8)| */
853 /* Text CODEC identifiers */
854 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_ENCT_TEXT, LSMASH_4CC( 'e', 'n', 'c', 't' ) ); /* Encrypted Text */
855 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_STPP_TEXT, LSMASH_4CC( 's', 't', 'p', 'p' ) ); /* Sub-titles (Timed Text) */
856 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_TX3G_TEXT, LSMASH_4CC( 't', 'x', '3', 'g' ) ); /* 3GPP Timed Text stream */
858 DEFINE_QTFF_CODEC_TYPE( QT_CODEC_TYPE_TEXT_TEXT, LSMASH_4CC( 't', 'e', 'x', 't' ) ); /* QuickTime Text Media */
860 /* Hint CODEC identifiers */
861 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_FDP_HINT, LSMASH_4CC( 'f', 'd', 'p', ' ' ) ); /* File delivery hints */
862 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_M2TS_HINT, LSMASH_4CC( 'm', '2', 't', 's' ) ); /* MPEG-2 transport stream for DMB */
863 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_PM2T_HINT, LSMASH_4CC( 'p', 'm', '2', 't' ) ); /* Protected MPEG-2 Transport */
864 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_PRTP_HINT, LSMASH_4CC( 'p', 'r', 't', 'p' ) ); /* Protected RTP Reception */
865 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_RM2T_HINT, LSMASH_4CC( 'r', 'm', '2', 't' ) ); /* MPEG-2 Transport Reception */
866 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_RRTP_HINT, LSMASH_4CC( 'r', 'r', 't', 'p' ) ); /* RTP reception */
867 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_RSRP_HINT, LSMASH_4CC( 'r', 's', 'r', 'p' ) ); /* SRTP Reception */
868 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_RTP_HINT, LSMASH_4CC( 'r', 't', 'p', ' ' ) ); /* RTP Hints */
869 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_SM2T_HINT, LSMASH_4CC( 's', 'm', '2', 't' ) ); /* MPEG-2 Transport Server */
870 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_SRTP_HINT, LSMASH_4CC( 's', 'r', 't', 'p' ) ); /* SRTP Hints */
872 /* Metadata CODEC identifiers */
873 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_IXSE_META, LSMASH_4CC( 'i', 'x', 's', 'e' ) ); /* DVB Track Level Index Track */
874 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_METT_META, LSMASH_4CC( 'm', 'e', 't', 't' ) ); /* Text timed metadata */
875 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_METX_META, LSMASH_4CC( 'm', 'e', 't', 'x' ) ); /* XML timed metadata */
876 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_MLIX_META, LSMASH_4CC( 'm', 'l', 'i', 'x' ) ); /* DVB Movie level index track */
877 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_OKSD_META, LSMASH_4CC( 'o', 'k', 's', 'd' ) ); /* OMA Keys */
878 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_SVCM_META, LSMASH_4CC( 's', 'v', 'c', 'M' ) ); /* SVC metadata */
879 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_TEXT_META, LSMASH_4CC( 't', 'e', 'x', 't' ) ); /* Textual meta-data with MIME type */
880 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_URIM_META, LSMASH_4CC( 'u', 'r', 'i', 'm' ) ); /* URI identified timed metadata */
881 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_XML_META, LSMASH_4CC( 'x', 'm', 'l', ' ' ) ); /* XML-formatted meta-data */
883 /* Other CODEC identifiers */
884 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_ENCS_SYSTEM, LSMASH_4CC( 'e', 'n', 'c', 's' ) ); /* Encrypted Systems stream */
885 DEFINE_ISOM_CODEC_TYPE( ISOM_CODEC_TYPE_MP4S_SYSTEM, LSMASH_4CC( 'm', 'p', '4', 's' ) ); /* MPEG-4 Systems */
887 DEFINE_QTFF_CODEC_TYPE( LSMASH_CODEC_TYPE_RAW, LSMASH_4CC( 'r', 'a', 'w', ' ' ) ); /* Either video or audio */
889 /* Check if the identifier of two CODECs is identical or not.
891 * Return 1 if the both CODEC identifiers are identical.
892 * Return 0 otherwise. */
893 int lsmash_check_codec_type_identical
895 lsmash_codec_type_t a,
896 lsmash_codec_type_t b
899 /****************************************************************************
900 * Summary of Stream Configuration
901 * This is L-SMASH's original structure.
902 ****************************************************************************/
903 typedef enum
905 LSMASH_SUMMARY_TYPE_UNKNOWN = 0,
906 LSMASH_SUMMARY_TYPE_VIDEO,
907 LSMASH_SUMMARY_TYPE_AUDIO,
908 LSMASH_SUMMARY_TYPE_HINT,
909 } lsmash_summary_type;
911 typedef enum
913 LSMASH_CODEC_SPECIFIC_DATA_TYPE_UNSPECIFIED = -1, /* must be LSMASH_CODEC_SPECIFIC_FORMAT_UNSPECIFIED */
915 LSMASH_CODEC_SPECIFIC_DATA_TYPE_UNKNOWN = 0, /* must be LSMASH_CODEC_SPECIFIC_FORMAT_UNSTRUCTURED */
917 LSMASH_CODEC_SPECIFIC_DATA_TYPE_MP4SYS_DECODER_CONFIG,
919 LSMASH_CODEC_SPECIFIC_DATA_TYPE_ISOM_VIDEO_H264,
920 LSMASH_CODEC_SPECIFIC_DATA_TYPE_ISOM_VIDEO_HEVC,
921 LSMASH_CODEC_SPECIFIC_DATA_TYPE_ISOM_VIDEO_VC_1,
922 LSMASH_CODEC_SPECIFIC_DATA_TYPE_ISOM_AUDIO_AC_3,
923 LSMASH_CODEC_SPECIFIC_DATA_TYPE_ISOM_AUDIO_EC_3,
924 LSMASH_CODEC_SPECIFIC_DATA_TYPE_ISOM_AUDIO_DTS,
925 LSMASH_CODEC_SPECIFIC_DATA_TYPE_ISOM_AUDIO_ALAC,
927 LSMASH_CODEC_SPECIFIC_DATA_TYPE_ISOM_VIDEO_SAMPLE_SCALE,
928 LSMASH_CODEC_SPECIFIC_DATA_TYPE_ISOM_VIDEO_H264_BITRATE,
929 LSMASH_CODEC_SPECIFIC_DATA_TYPE_ISOM_RTP_HINT_COMMON,
931 LSMASH_CODEC_SPECIFIC_DATA_TYPE_QT_VIDEO_COMMON, /* must be LSMASH_CODEC_SPECIFIC_FORMAT_STRUCTURED */
932 LSMASH_CODEC_SPECIFIC_DATA_TYPE_QT_AUDIO_COMMON, /* must be LSMASH_CODEC_SPECIFIC_FORMAT_STRUCTURED */
933 LSMASH_CODEC_SPECIFIC_DATA_TYPE_QT_AUDIO_FORMAT_SPECIFIC_FLAGS, /* must be LSMASH_CODEC_SPECIFIC_FORMAT_STRUCTURED */
934 LSMASH_CODEC_SPECIFIC_DATA_TYPE_QT_AUDIO_DECOMPRESSION_PARAMETERS, /* must be LSMASH_CODEC_SPECIFIC_FORMAT_UNSTRUCTURED */
936 LSMASH_CODEC_SPECIFIC_DATA_TYPE_QT_VIDEO_FIELD_INFO,
937 LSMASH_CODEC_SPECIFIC_DATA_TYPE_QT_VIDEO_PIXEL_FORMAT,
938 LSMASH_CODEC_SPECIFIC_DATA_TYPE_QT_VIDEO_SIGNIFICANT_BITS,
939 LSMASH_CODEC_SPECIFIC_DATA_TYPE_QT_VIDEO_GAMMA_LEVEL,
940 LSMASH_CODEC_SPECIFIC_DATA_TYPE_QT_VIDEO_CONTENT_LIGHT_LEVEL_INFO,
941 LSMASH_CODEC_SPECIFIC_DATA_TYPE_QT_VIDEO_MASTERING_DISPLAY_COLOR_VOLUME,
942 LSMASH_CODEC_SPECIFIC_DATA_TYPE_QT_AUDIO_CHANNEL_LAYOUT,
944 LSMASH_CODEC_SPECIFIC_DATA_TYPE_CODEC_GLOBAL_HEADER,
945 } lsmash_codec_specific_data_type;
947 typedef enum
949 LSMASH_CODEC_SPECIFIC_FORMAT_UNSPECIFIED = -1,
950 LSMASH_CODEC_SPECIFIC_FORMAT_STRUCTURED = 0,
951 LSMASH_CODEC_SPECIFIC_FORMAT_UNSTRUCTURED = 1
952 } lsmash_codec_specific_format;
954 typedef union
956 void *always_null; /* LSMASH_CODEC_SPECIFIC_FORMAT_UNSPECIFIED */
957 void *structured; /* LSMASH_CODEC_SPECIFIC_FORMAT_STRUCTURED */
958 uint8_t *unstructured; /* LSMASH_CODEC_SPECIFIC_FORMAT_UNSTRUCTURED */
959 } lsmash_codec_specific_data_t;
961 typedef void (*lsmash_codec_specific_destructor_t)( void * );
962 typedef struct
964 lsmash_codec_specific_data_type type;
965 lsmash_codec_specific_format format;
966 lsmash_codec_specific_data_t data;
967 uint32_t size;
968 lsmash_codec_specific_destructor_t destruct;
969 } lsmash_codec_specific_t;
971 typedef struct lsmash_codec_specific_list_tag lsmash_codec_specific_list_t;
973 typedef enum
975 LSMASH_CODEC_SUPPORT_FLAG_NONE = 0,
976 LSMASH_CODEC_SUPPORT_FLAG_MUX = 1 << 0, /* It's expected that L-SMASH can mux CODEC stream properly.
977 * If not flagged, L-SMASH may recognize and/or handle CODEC specific info incorrectly when muxing. */
978 LSMASH_CODEC_SUPPORT_FLAG_DEMUX = 1 << 1, /* It's expected that L-SMASH can demux CODEC stream properly.
979 * If not flagged, L-SMASH may recognize and/or handle CODEC specific info incorrectly when demuxing. */
980 LSMASH_CODEC_SUPPORT_FLAG_REMUX = LSMASH_CODEC_SUPPORT_FLAG_MUX | LSMASH_CODEC_SUPPORT_FLAG_DEMUX,
981 } lsmash_codec_support_flag;
983 #define LSMASH_BASE_SUMMARY \
984 lsmash_summary_type summary_type; \
985 lsmash_codec_type_t sample_type; \
986 lsmash_codec_specific_list_t *opaque; \
987 uint32_t max_au_length; /* buffer length for 1 access unit, \
988 * typically max size of 1 audio/video frame */ \
989 uint32_t data_ref_index; /* the index of a data reference */
991 typedef struct
993 LSMASH_BASE_SUMMARY
994 } lsmash_summary_t;
996 /* Allocate a summary by 'summary_type'.
997 * The allocated summary can be deallocated by lsmash_cleanup_summary().
999 * Return the address of an allocated summary if successful.
1000 * Return NULL otherwise. */
1001 lsmash_summary_t *lsmash_create_summary
1003 lsmash_summary_type summary_type /* a type of summary you want */
1006 /* Deallocate a given summary. */
1007 void lsmash_cleanup_summary
1009 lsmash_summary_t *summary /* the address of a summary you want to deallocate */
1012 /* Allocate and append a new sample description to a track by 'summary'.
1014 * Return the index of an allocated and appended sample description if successful.
1015 * Return 0 otherwise. */
1016 int lsmash_add_sample_entry
1018 lsmash_root_t *root, /* the address of the ROOT containing a track to which you want to append a new sample description */
1019 uint32_t track_ID, /* the track_ID of a track to which you want to append a new sample description */
1020 void *summary /* the summary of a sample description you want to append */
1023 /* Count the number of summaries in a track.
1025 * Return the number of summaries in a track if no error.
1026 * Return 0 otherwise. */
1027 uint32_t lsmash_count_summary
1029 lsmash_root_t *root, /* the address of the ROOT containing a track in which you want to count the number of summaries */
1030 uint32_t track_ID /* the track_ID of a track in which you want to count the number of summaries */
1033 /* Get the summary of a sample description you want in a track.
1034 * The summary returned by this function is allocated internally, and can be deallocate by lsmash_cleanup_summary().
1036 * Return the address of an allocated summary you want if successful.
1037 * Return NULL otherwise. */
1038 lsmash_summary_t *lsmash_get_summary
1040 lsmash_root_t *root, /* the address of the ROOT containing a track which contains a sample description you want */
1041 uint32_t track_ID, /* the track_ID of a track containing a sample description you want */
1042 uint32_t description_number /* the index of a sample description you want */
1045 /* Allocate and initialize a CODEC specific configuration by 'type' and 'format'.
1046 * The allocated CODEC specific configuration can be deallocated by lsmash_destroy_codec_specific_data().
1048 * Return the address of an allocated and initialized CODEC specific configuration if successful.
1049 * Return NULL otherwise. */
1050 lsmash_codec_specific_t *lsmash_create_codec_specific_data
1052 lsmash_codec_specific_data_type type,
1053 lsmash_codec_specific_format format
1056 /* Deallocate a CODEC specific configuration. */
1057 void lsmash_destroy_codec_specific_data
1059 lsmash_codec_specific_t *specific /* the address of a CODEC specific configuration you want to deallocate */
1062 /* Allocate a CODEC specific configuration which is a copy of 'specific', and append it to 'summary'.
1064 * Return 0 if successful.
1065 * Return a negative value otherwise. */
1066 int lsmash_add_codec_specific_data
1068 lsmash_summary_t *summary,
1069 lsmash_codec_specific_t *specific
1072 /* Count the number of CODEC specific configuration in a summary.
1074 * Return the number of CODEC specific configuration in a summary if successful.
1075 * Return 0 otherwise. */
1076 uint32_t lsmash_count_codec_specific_data
1078 lsmash_summary_t *summary /* the address of a summary in which you want to count the number of CODEC specific configuration */
1081 /* Get a CODEC specific configuration you want in a summary.
1083 * Return the address of a CODEC specific configuration if successful.
1084 * Return NULL otherwise. */
1085 lsmash_codec_specific_t *lsmash_get_codec_specific_data
1087 lsmash_summary_t *summary,
1088 uint32_t extension_number
1091 /* Convert a data format of CODEC specific configuration into another.
1092 * User can specify the same data format for the destination.
1093 * If so, a returned CODEC specific configuration is a copy of the source.
1095 * Return an allocated CODEC specific configuration by specified 'format' from 'specific' if successful.
1096 * Return NULL otherwise. */
1097 lsmash_codec_specific_t *lsmash_convert_codec_specific_format
1099 lsmash_codec_specific_t *specific, /* the address of a CODEC specific configuration as the source */
1100 lsmash_codec_specific_format format /* a data format of the destination */
1103 /* Compare two summaries.
1105 * Return 0 if the two summaries are identical.
1106 * Return 1 if the two summaries are different.
1107 * Return a negative value if there is any error. */
1108 int lsmash_compare_summary
1110 lsmash_summary_t *a,
1111 lsmash_summary_t *b
1114 /* Check status of CODEC support.
1116 * Return support flags of a given CODEC. */
1117 lsmash_codec_support_flag lsmash_check_codec_support
1119 lsmash_codec_type_t codec_type
1122 /****************************************************************************
1123 * Audio Description Layer
1124 ****************************************************************************/
1125 /* Audio Object Types */
1126 typedef enum
1128 MP4A_AUDIO_OBJECT_TYPE_NULL = 0,
1129 MP4A_AUDIO_OBJECT_TYPE_AAC_MAIN = 1, /* ISO/IEC 14496-3 subpart 4 */
1130 MP4A_AUDIO_OBJECT_TYPE_AAC_LC = 2, /* ISO/IEC 14496-3 subpart 4 */
1131 MP4A_AUDIO_OBJECT_TYPE_AAC_SSR = 3, /* ISO/IEC 14496-3 subpart 4 */
1132 MP4A_AUDIO_OBJECT_TYPE_AAC_LTP = 4, /* ISO/IEC 14496-3 subpart 4 */
1133 MP4A_AUDIO_OBJECT_TYPE_SBR = 5, /* ISO/IEC 14496-3 subpart 4 */
1134 MP4A_AUDIO_OBJECT_TYPE_AAC_scalable = 6, /* ISO/IEC 14496-3 subpart 4 */
1135 MP4A_AUDIO_OBJECT_TYPE_TwinVQ = 7, /* ISO/IEC 14496-3 subpart 4 */
1136 MP4A_AUDIO_OBJECT_TYPE_CELP = 8, /* ISO/IEC 14496-3 subpart 3 */
1137 MP4A_AUDIO_OBJECT_TYPE_HVXC = 9, /* ISO/IEC 14496-3 subpart 2 */
1138 MP4A_AUDIO_OBJECT_TYPE_TTSI = 12, /* ISO/IEC 14496-3 subpart 6 */
1139 MP4A_AUDIO_OBJECT_TYPE_Main_synthetic = 13, /* ISO/IEC 14496-3 subpart 5 */
1140 MP4A_AUDIO_OBJECT_TYPE_Wavetable_synthesis = 14, /* ISO/IEC 14496-3 subpart 5 */
1141 MP4A_AUDIO_OBJECT_TYPE_General_MIDI = 15, /* ISO/IEC 14496-3 subpart 5 */
1142 MP4A_AUDIO_OBJECT_TYPE_Algorithmic_Synthesis_Audio_FX = 16, /* ISO/IEC 14496-3 subpart 5 */
1143 MP4A_AUDIO_OBJECT_TYPE_ER_AAC_LC = 17, /* ISO/IEC 14496-3 subpart 4 */
1144 MP4A_AUDIO_OBJECT_TYPE_ER_AAC_LTP = 19, /* ISO/IEC 14496-3 subpart 4 */
1145 MP4A_AUDIO_OBJECT_TYPE_ER_AAC_scalable = 20, /* ISO/IEC 14496-3 subpart 4 */
1146 MP4A_AUDIO_OBJECT_TYPE_ER_Twin_VQ = 21, /* ISO/IEC 14496-3 subpart 4 */
1147 MP4A_AUDIO_OBJECT_TYPE_ER_BSAC = 22, /* ISO/IEC 14496-3 subpart 4 */
1148 MP4A_AUDIO_OBJECT_TYPE_ER_AAC_LD = 23, /* ISO/IEC 14496-3 subpart 4 */
1149 MP4A_AUDIO_OBJECT_TYPE_ER_CELP = 24, /* ISO/IEC 14496-3 subpart 3 */
1150 MP4A_AUDIO_OBJECT_TYPE_ER_HVXC = 25, /* ISO/IEC 14496-3 subpart 2 */
1151 MP4A_AUDIO_OBJECT_TYPE_ER_HILN = 26, /* ISO/IEC 14496-3 subpart 7 */
1152 MP4A_AUDIO_OBJECT_TYPE_ER_Parametric = 27, /* ISO/IEC 14496-3 subpart 2 and 7 */
1153 MP4A_AUDIO_OBJECT_TYPE_SSC = 28, /* ISO/IEC 14496-3 subpart 8 */
1154 MP4A_AUDIO_OBJECT_TYPE_PS = 29, /* ISO/IEC 14496-3 subpart 8 */
1155 MP4A_AUDIO_OBJECT_TYPE_MPEG_Surround = 30, /* ISO/IEC 23003-1 */
1156 MP4A_AUDIO_OBJECT_TYPE_ESCAPE = 31,
1157 MP4A_AUDIO_OBJECT_TYPE_Layer_1 = 32, /* ISO/IEC 14496-3 subpart 9 */
1158 MP4A_AUDIO_OBJECT_TYPE_Layer_2 = 33, /* ISO/IEC 14496-3 subpart 9 */
1159 MP4A_AUDIO_OBJECT_TYPE_Layer_3 = 34, /* ISO/IEC 14496-3 subpart 9 */
1160 MP4A_AUDIO_OBJECT_TYPE_DST = 35, /* ISO/IEC 14496-3 subpart 10 */
1161 MP4A_AUDIO_OBJECT_TYPE_ALS = 36, /* ISO/IEC 14496-3 subpart 11 */
1162 MP4A_AUDIO_OBJECT_TYPE_SLS = 37, /* ISO/IEC 14496-3 subpart 12 */
1163 MP4A_AUDIO_OBJECT_TYPE_SLS_non_core = 38, /* ISO/IEC 14496-3 subpart 12 */
1164 MP4A_AUDIO_OBJECT_TYPE_ER_AAC_ELD = 39, /* ISO/IEC 14496-3 subpart 4 */
1165 MP4A_AUDIO_OBJECT_TYPE_SMR_Simple = 40, /* ISO/IEC 14496-23 */
1166 MP4A_AUDIO_OBJECT_TYPE_SMR_Main = 41, /* ISO/IEC 14496-23 */
1167 MP4A_AUDIO_OBJECT_TYPE_SAOC = 43, /* ISO/IEC 23003-2 */
1168 } lsmash_mp4a_AudioObjectType;
1170 /* See ISO/IEC 14496-3 Signaling of SBR, SBR Signaling and Corresponding Decoder Behavior */
1171 typedef enum
1173 MP4A_AAC_SBR_NOT_SPECIFIED = 0x0, /* not mention to SBR presence. Implicit signaling. */
1174 MP4A_AAC_SBR_NONE, /* explicitly signals SBR does not present. Useless in general. */
1175 MP4A_AAC_SBR_BACKWARD_COMPATIBLE, /* explicitly signals SBR present. Recommended method to signal SBR. */
1176 MP4A_AAC_SBR_HIERARCHICAL /* SBR exists. SBR dedicated method. */
1177 } lsmash_mp4a_aac_sbr_mode;
1179 typedef struct
1181 LSMASH_BASE_SUMMARY
1182 lsmash_mp4a_AudioObjectType aot; /* detailed codec type
1183 * If neither ISOM_CODEC_TYPE_MP4A_AUDIO nor QT_CODEC_TYPE_MP4A_AUDIO, just ignored. */
1184 uint32_t frequency; /* the audio sampling rate (in Hz) at the default output playback
1185 * For some audio, this field is used as a nominal value.
1186 * For HE-AAC v1/SBR stream, this is base AAC's one.
1187 * For ISOM_CODEC_TYPE_AC_3_AUDIO and ISOM_CODEC_TYPE_EC_3_AUDIO, this shall be
1188 * equal to the sampling rate (in Hz) of the stream and the media timescale. */
1189 uint32_t channels; /* the number of audio channels at the default output playback
1190 * Even if the stream is HE-AAC v2/SBR+PS, this is base AAC's one. */
1191 uint32_t sample_size; /* For uncompressed audio,
1192 * the number of bits in each uncompressed sample for a single channel.
1193 * For some compressed audio, such as audio that uses MDCT,
1194 * N/A (not applicable), and may be set to 16. */
1195 uint32_t samples_in_frame; /* the number of decoded PCM samples in an audio frame at 'frequency'
1196 * Even if the stream is HE-AAC/aacPlus/SBR(+PS), this is base AAC's one, so 1024. */
1197 lsmash_mp4a_aac_sbr_mode sbr_mode; /* SBR treatment
1198 * Currently we always set this as mp4a_AAC_SBR_NOT_SPECIFIED (Implicit signaling).
1199 * User can set this for treatment in other way. */
1200 uint32_t bytes_per_frame; /* the number of bytes per audio frame
1201 * If variable, shall be set to 0. */
1202 } lsmash_audio_summary_t;
1204 /* Facilitate to make exdata (typically DecoderSpecificInfo or AudioSpecificConfig). */
1205 int lsmash_setup_AudioSpecificConfig
1207 lsmash_audio_summary_t* summary
1210 /****************************************************************************
1211 * Video Description Layer
1212 ****************************************************************************/
1213 /* Clean Aperture */
1214 typedef struct
1216 lsmash_rational_u32_t width;
1217 lsmash_rational_u32_t height;
1218 lsmash_rational_s32_t horizontal_offset;
1219 lsmash_rational_s32_t vertical_offset;
1220 } lsmash_clap_t;
1222 typedef struct
1224 lsmash_rational_u32_t top;
1225 lsmash_rational_u32_t left;
1226 lsmash_rational_u32_t bottom;
1227 lsmash_rational_u32_t right;
1228 } lsmash_crop_t;
1230 /* Video depth */
1231 typedef enum
1233 ISOM_DEPTH_TEMPLATE = 0x0018,
1235 /* H.264/AVC */
1236 AVC_DEPTH_COLOR_WITH_NO_ALPHA = 0x0018, /* color with no alpha */
1237 AVC_DEPTH_GRAYSCALE_WITH_NO_ALPHA = 0x0028, /* grayscale with no alpha */
1238 AVC_DEPTH_WITH_ALPHA = 0x0020, /* gray or color with alpha */
1240 /* QuickTime Video
1241 * (1-32) or (33-40 grayscale) */
1242 QT_VIDEO_DEPTH_COLOR_1 = 0x0001,
1243 QT_VIDEO_DEPTH_COLOR_2 = 0x0002,
1244 QT_VIDEO_DEPTH_COLOR_4 = 0x0004,
1245 QT_VIDEO_DEPTH_COLOR_8 = 0x0008,
1246 QT_VIDEO_DEPTH_COLOR_16 = 0x0010,
1247 QT_VIDEO_DEPTH_COLOR_24 = 0x0018,
1248 QT_VIDEO_DEPTH_COLOR_32 = 0x0020,
1249 QT_VIDEO_DEPTH_GRAYSCALE_1 = 0x0021,
1250 QT_VIDEO_DEPTH_GRAYSCALE_2 = 0x0022,
1251 QT_VIDEO_DEPTH_GRAYSCALE_4 = 0x0024,
1252 QT_VIDEO_DEPTH_GRAYSCALE_8 = 0x0028,
1254 /* QuickTime Uncompressed RGB */
1255 QT_VIDEO_DEPTH_555RGB = 0x0010,
1256 QT_VIDEO_DEPTH_24RGB = 0x0018,
1257 QT_VIDEO_DEPTH_32ARGB = 0x0020,
1258 } lsmash_video_depth;
1260 /* Index for the chromaticity coordinates of the color primaries */
1261 enum
1263 /* for ISO Base Media file format */
1264 ISOM_PRIMARIES_INDEX_ITU_R709_5 = 1, /* ITU-R BT.709-2/5, ITU-R BT.1361,
1265 * SMPTE 274M-1995, SMPTE 296M-1997,
1266 * IEC 61966-2-1 (sRGB or sYCC), IEC 61966-2-4 (xvYCC),
1267 * SMPTE RP 177M-1993 Annex B
1268 * green x = 0.300 y = 0.600
1269 * blue x = 0.150 y = 0.060
1270 * red x = 0.640 y = 0.330
1271 * white x = 0.3127 y = 0.3290 (CIE III. D65) */
1272 ISOM_PRIMARIES_INDEX_UNSPECIFIED = 2, /* Unspecified */
1273 ISOM_PRIMARIES_INDEX_ITU_R470M = 4, /* ITU-R BT.470-6 System M
1274 * green x = 0.21 y = 0.71
1275 * blue x = 0.14 y = 0.08
1276 * red x = 0.67 y = 0.33
1277 * white x = 0.310 y = 0.316 */
1278 ISOM_PRIMARIES_INDEX_ITU_R470BG = 5, /* EBU Tech. 3213 (1981), ITU-R BT.470-6 System B, G,
1279 * ITU-R BT.601-6 625, ITU-R BT.1358 625,
1280 * ITU-R BT.1700 625 PAL and 625 SECAM
1281 * green x = 0.29 y = 0.60
1282 * blue x = 0.15 y = 0.06
1283 * red x = 0.64 y = 0.33
1284 * white x = 0.3127 y = 0.3290 (CIE III. D65) */
1285 ISOM_PRIMARIES_INDEX_SMPTE_170M_2004 = 6, /* SMPTE C Primaries from SMPTE RP 145-1993, SMPTE 170M-2004,
1286 * ITU-R BT.601-6 525, ITU-R BT.1358 525,
1287 * ITU-R BT.1700 NTSC, SMPTE 170M-2004
1288 * green x = 0.310 y = 0.595
1289 * blue x = 0.155 y = 0.070
1290 * red x = 0.630 y = 0.340
1291 * white x = 0.3127 y = 0.3290 (CIE III. D65) */
1292 ISOM_PRIMARIES_INDEX_SMPTE_240M_1999 = 7, /* SMPTE 240M-1999
1293 * functionally the same as the value ISOM_PRIMARIES_INDEX_SMPTE_170M_2004 */
1295 /* for QuickTime file format */
1296 QT_PRIMARIES_INDEX_ITU_R709_2 = 1, /* the same as the value ISOM_PRIMARIES_INDEX_ITU_R709_5 */
1297 QT_PRIMARIES_INDEX_UNSPECIFIED = 2, /* Unspecified */
1298 QT_PRIMARIES_INDEX_EBU_3213 = 5, /* the same as the value ISOM_PRIMARIES_INDEX_ITU_R470BG */
1299 QT_PRIMARIES_INDEX_SMPTE_C = 6, /* the same as the value ISOM_PRIMARIES_INDEX_SMPTE_170M_2004 */
1302 /* Index for the opto-electronic transfer characteristic of the image color components */
1303 enum
1305 /* for ISO Base Media file format */
1306 ISOM_TRANSFER_INDEX_ITU_R709_5 = 1, /* ITU-R BT.709-2/5, ITU-R BT.1361
1307 * SMPTE 274M-1995, SMPTE 296M-1997,
1308 * SMPTE 293M-1996, SMPTE 170M-1994
1309 * vV = 1.099 * vLc^0.45 - 0.099 for 1 >= vLc >= 0.018
1310 * vV = 4.500 * vLc for 0.018 > vLc >= 0 */
1311 ISOM_TRANSFER_INDEX_UNSPECIFIED = 2, /* Unspecified */
1312 ISOM_TRANSFER_INDEX_ITU_R470M = 4, /* ITU-R BT.470-6 System M, ITU-R BT.1700 625 PAL and 625 SECAM
1313 * Assumed display gamma 2.2 */
1314 ISOM_TRANSFER_INDEX_ITU_R470BG = 5, /* ITU-R BT.470-6 System B, G
1315 * Assumed display gamma 2.8 */
1316 ISOM_TRANSFER_INDEX_SMPTE_170M_2004 = 6, /* ITU-R BT.601-6 525 or 625, ITU-R BT.1358 525 or 625,
1317 * ITU-R BT.1700 NTSC, SMPTE 170M-2004
1318 * functionally the same as the value ISOM_TRANSFER_INDEX_ITU_R709_5
1319 * vV = 1.099 * vLc^0.45 - 0.099 for 1 >= vLc >= 0.018
1320 * vV = 4.500 * vLc for 0.018 > vLc >= 0 */
1321 ISOM_TRANSFER_INDEX_SMPTE_240M_1999 = 7, /* SMPTE 240M-1995/1999, interim color implementation of SMPTE 274M-1995
1322 * vV = 1.1115 * vLc^0.45 - 0.1115 for 1 >= vLc >= 0.0228
1323 * vV = 4.0 * vLc for 0.0228 > vLc >= 0 */
1324 ISOM_TRANSFER_INDEX_LINEAR = 8, /* Linear transfer characteristics */
1325 ISOM_TRANSFER_INDEX_XVYCC = 11, /* IEC 61966-2-4 (xvYCC)
1326 * vV = 1.099 * vLc^0.45 - 0.099 for vLc >= 0.018
1327 * vV = 4.500 * vLc for 0.018 > vLc > -0.018
1328 * vV = -1.099 * (-vLc)^0.45 + 0.099 for -0.018 >= vLc */
1329 ISOM_TRANSFER_INDEX_ITU_R1361 = 12, /* ITU-R BT.1361
1330 * vV = 1.099 * vLc^0.45 - 0.099 for 1.33 > vLc >= 0.018
1331 * vV = 4.500 * vLc for 0.018 > vLc >= -0.0045
1332 * vV = -(1.099 * (-4 * vLc)^0.45 + 0.099) / 4 for -0.0045 > vLc >= -0.25 */
1333 ISOM_TRANSFER_INDEX_SRGB = 13, /* IEC 61966-2-1 (sRGB or sYCC)
1334 * vV = 1.055 * vLc^(1/2.4) - 0.055 for 1 > vLc >= 0.0031308
1335 * vV = 12.92 * vLc for 0.0031308 > vLc >= 0 */
1337 /* for QuickTime file format */
1338 QT_TRANSFER_INDEX_ITU_R709_2 = 1, /* the same as the value ISOM_TRANSFER_INDEX_ITU_R709_5 */
1339 QT_TRANSFER_INDEX_UNSPECIFIED = 2, /* Unspecified */
1340 QT_TRANSFER_INDEX_SMPTE_240M_1995 = 7, /* the same as the value ISOM_TRANSFER_INDEX_SMPTE_240M_1999 */
1343 /* Index for the matrix coefficients associated with derivation of luma and chroma signals from the green, blue, and red primaries */
1344 enum
1346 /* for ISO Base Media file format */
1347 ISOM_MATRIX_INDEX_NO_MATRIX = 0, /* No matrix transformation
1348 * IEC 61966-2-1 (sRGB) */
1349 ISOM_MATRIX_INDEX_ITU_R_709_5 = 1, /* ITU-R BT.709-2/5, ITU-R BT.1361,
1350 * SMPTE 274M-1995, SMPTE 296M-1997
1351 * IEC 61966-2-1 (sYCC), IEC 61966-2-4 xvYCC_709,
1352 * SMPTE RP 177M-1993 Annex B
1353 * vKr = 0.2126; vKb = 0.0722 */
1354 ISOM_MATRIX_INDEX_UNSPECIFIED = 2, /* Unspecified */
1355 ISOM_MATRIX_INDEX_USFCCT_47_CFR = 4, /* United States Federal Communications Commission Title 47 Code of Federal Regulations
1356 * vKr = 0.30; vKb = 0.11 */
1357 ISOM_MATRIX_INDEX_ITU_R470BG = 5, /* ITU-R BT.470-6 System B, G,
1358 * ITU-R BT.601-4/6 625, ITU-R BT.1358 625,
1359 * ITU-R BT.1700 625 PAL and 625 SECAM, IEC 61966-2-4 xvYCC601
1360 * vKr = 0.299; vKb = 0.114 */
1361 ISOM_MATRIX_INDEX_SMPTE_170M_2004 = 6, /* ITU-R BT.601-4/6 525, ITU-R BT.1358 525,
1362 * ITU-R BT.1700 NTSC,
1363 * SMPTE 170M-1994, SMPTE 293M-1996
1364 * functionally the same as the value ISOM_MATRIX_INDEX_ITU_R470BG
1365 * vKr = 0.299; vKb = 0.114 */
1366 ISOM_MATRIX_INDEX_SMPTE_240M_1999 = 7, /* SMPTE 240M-1995, interim color implementation of SMPTE 274M-1995
1367 * vKr = 0.212; vKb = 0.087 */
1368 ISOM_MATRIX_INDEX_YCGCO = 8, /* YCoCg */
1370 /* for QuickTime file format */
1371 QT_MATRIX_INDEX_ITU_R_709_2 = 1, /* the same as the value ISOM_MATRIX_INDEX_ITU_R_709_5 */
1372 QT_MATRIX_INDEX_UNSPECIFIED = 2, /* Unspecified */
1373 QT_MATRIX_INDEX_ITU_R_601_4 = 6, /* the same as the value ISOM_MATRIX_INDEX_SMPTE_170M_2004 */
1374 QT_MATRIX_INDEX_SMPTE_240M_1995 = 7 /* the same as the value ISOM_MATRIX_INDEX_SMPTE_240M_1999 */
1377 typedef struct
1379 LSMASH_BASE_SUMMARY
1380 // lsmash_mp4v_VideoObjectType vot; /* Detailed codec type. If not mp4v, just ignored. */
1381 uint32_t timescale; /* media timescale
1382 * User can't set this parameter manually. */
1383 uint32_t timebase; /* increment unit of timestamp
1384 * User can't set this parameter manually. */
1385 uint8_t vfr; /* whether a stream is assumed as variable frame rate
1386 * User can't set this parameter manually. */
1387 uint8_t sample_per_field; /* whether a stream may have a sample per field
1388 * User can't set this parameter manually. */
1389 uint32_t width; /* pixel counts of width samples have */
1390 uint32_t height; /* pixel counts of height samples have */
1391 char compressorname[33]; /* a 32-byte Pascal string containing the name of the compressor that created the image */
1392 lsmash_video_depth depth; /* data size of a pixel */
1393 lsmash_clap_t clap; /* clean aperture */
1394 uint32_t par_h; /* horizontal factor of pixel aspect ratio */
1395 uint32_t par_v; /* vertical factor of pixel aspect ratio */
1396 struct
1398 /* To omit to write these field, set zero value to all them. */
1399 uint16_t primaries_index; /* the chromaticity coordinates of the color primaries */
1400 uint16_t transfer_index; /* the opto-electronic transfer characteristic of the image color components */
1401 uint16_t matrix_index; /* the matrix coefficients associated with derivation of luma and chroma signals from the green, blue, and red primaries */
1402 uint8_t full_range;
1403 } color;
1404 } lsmash_video_summary_t;
1406 int lsmash_convert_crop_into_clap
1408 lsmash_crop_t crop,
1409 uint32_t width,
1410 uint32_t height,
1411 lsmash_clap_t *clap
1414 int lsmash_convert_clap_into_crop
1416 lsmash_clap_t clap,
1417 uint32_t width,
1418 uint32_t height,
1419 lsmash_crop_t *crop
1422 /****************************************************************************
1423 * Hint Description Layer
1424 ****************************************************************************/
1426 typedef struct
1428 LSMASH_BASE_SUMMARY
1429 uint16_t version; /* = 1 */
1430 uint16_t highestcompatibleversion; /* = 1 */
1431 uint32_t maxpacketsize; /* maximum size of one packet */
1432 } lsmash_hint_summary_t;
1434 /****************************************************************************
1435 * Media Sample
1436 ****************************************************************************/
1437 typedef enum
1439 /* allow_ealier */
1440 QT_SAMPLE_EARLIER_PTS_ALLOWED = 1,
1441 /* leading */
1442 ISOM_SAMPLE_LEADING_UNKNOWN = 0,
1443 ISOM_SAMPLE_IS_UNDECODABLE_LEADING = 1,
1444 ISOM_SAMPLE_IS_NOT_LEADING = 2,
1445 ISOM_SAMPLE_IS_DECODABLE_LEADING = 3,
1446 /* independent */
1447 ISOM_SAMPLE_INDEPENDENCY_UNKNOWN = 0,
1448 ISOM_SAMPLE_IS_NOT_INDEPENDENT = 1,
1449 ISOM_SAMPLE_IS_INDEPENDENT = 2,
1450 /* disposable */
1451 ISOM_SAMPLE_DISPOSABLE_UNKNOWN = 0,
1452 ISOM_SAMPLE_IS_NOT_DISPOSABLE = 1,
1453 ISOM_SAMPLE_IS_DISPOSABLE = 2,
1454 /* redundant */
1455 ISOM_SAMPLE_REDUNDANCY_UNKNOWN = 0,
1456 ISOM_SAMPLE_HAS_REDUNDANCY = 1,
1457 ISOM_SAMPLE_HAS_NO_REDUNDANCY = 2,
1458 } lsmash_sample_dependency;
1460 typedef enum
1462 /* flags for ISO Base Media file format */
1463 ISOM_SAMPLE_RANDOM_ACCESS_FLAG_NONE = 0,
1464 ISOM_SAMPLE_RANDOM_ACCESS_FLAG_SYNC = 1 << 0, /* a sync sample */
1465 ISOM_SAMPLE_RANDOM_ACCESS_FLAG_RAP = 1 << 2, /* the first sample of a closed or an open GOP */
1466 ISOM_SAMPLE_RANDOM_ACCESS_FLAG_CLOSED = 1 << 3, /* a sample in a closed GOP
1467 * This flag shall be set together with ISOM_SAMPLE_RANDOM_ACCESS_FLAG_RAP. */
1468 ISOM_SAMPLE_RANDOM_ACCESS_FLAG_OPEN = 1 << 4, /* a sample in an open GOP
1469 * This flag shall be set together with ISOM_SAMPLE_RANDOM_ACCESS_FLAG_RAP. */
1470 ISOM_SAMPLE_RANDOM_ACCESS_FLAG_GDR = 1 << 5, /* a sample on gradual decoder refresh or random access recovery */
1471 ISOM_SAMPLE_RANDOM_ACCESS_FLAG_GDR_START = 1 << 6, /* a sample that is the starting point of gradual decoder refresh or random access recovery
1472 * This flag shall be set together with ISOM_SAMPLE_RANDOM_ACCESS_FLAG_GDR. */
1473 ISOM_SAMPLE_RANDOM_ACCESS_FLAG_GDR_END = 1 << 7, /* a sample that is the ending point of gradual decoder refresh or random access recovery
1474 * This flag shall be set together with ISOM_SAMPLE_RANDOM_ACCESS_FLAG_GDR. */
1476 ISOM_SAMPLE_RANDOM_ACCESS_FLAG_CLOSED_RAP /* the first sample of a closed GOP */
1477 = ISOM_SAMPLE_RANDOM_ACCESS_FLAG_RAP
1478 | ISOM_SAMPLE_RANDOM_ACCESS_FLAG_CLOSED,
1479 ISOM_SAMPLE_RANDOM_ACCESS_FLAG_OPEN_RAP /* the first sample of an open GOP */
1480 = ISOM_SAMPLE_RANDOM_ACCESS_FLAG_RAP
1481 | ISOM_SAMPLE_RANDOM_ACCESS_FLAG_OPEN,
1482 ISOM_SAMPLE_RANDOM_ACCESS_FLAG_POST_ROLL_START /* the post-roll starting point of random access recovery */
1483 = ISOM_SAMPLE_RANDOM_ACCESS_FLAG_GDR
1484 | ISOM_SAMPLE_RANDOM_ACCESS_FLAG_GDR_START,
1485 ISOM_SAMPLE_RANDOM_ACCESS_FLAG_PRE_ROLL_END /* the pre-roll ending point of random access recovery */
1486 = ISOM_SAMPLE_RANDOM_ACCESS_FLAG_GDR
1487 | ISOM_SAMPLE_RANDOM_ACCESS_FLAG_GDR_END,
1489 /* flags for QuickTime file format */
1490 QT_SAMPLE_RANDOM_ACCESS_FLAG_NONE = 0, /* alias of ISOM_SAMPLE_RANDOM_ACCESS_FLAG_NONE */
1491 QT_SAMPLE_RANDOM_ACCESS_FLAG_SYNC = ISOM_SAMPLE_RANDOM_ACCESS_FLAG_SYNC,
1492 QT_SAMPLE_RANDOM_ACCESS_FLAG_PARTIAL_SYNC = 1 << 1, /* partial sync sample
1493 * Partial sync sample is a sample
1494 * such that this sample and samples following in decoding order can be correctly decoded
1495 * using the first sample of the previous GOP and samples following in decoding order,
1496 * in addition, this sample and non-leading samples following in decoding order can be correctly decoded from this. */
1497 QT_SAMPLE_RANDOM_ACCESS_FLAG_RAP = ISOM_SAMPLE_RANDOM_ACCESS_FLAG_RAP,
1498 QT_SAMPLE_RANDOM_ACCESS_FLAG_CLOSED = ISOM_SAMPLE_RANDOM_ACCESS_FLAG_CLOSED,
1499 QT_SAMPLE_RANDOM_ACCESS_FLAG_OPEN = ISOM_SAMPLE_RANDOM_ACCESS_FLAG_OPEN,
1501 QT_SAMPLE_RANDOM_ACCESS_FLAG_CLOSED_RAP /* the first sample of a closed GOP */
1502 = QT_SAMPLE_RANDOM_ACCESS_FLAG_RAP
1503 | QT_SAMPLE_RANDOM_ACCESS_FLAG_CLOSED,
1504 QT_SAMPLE_RANDOM_ACCESS_FLAG_OPEN_RAP /* the first sample of an open GOP */
1505 = QT_SAMPLE_RANDOM_ACCESS_FLAG_RAP
1506 | QT_SAMPLE_RANDOM_ACCESS_FLAG_OPEN,
1507 } lsmash_random_access_flag;
1509 #define LSMASH_FLAGS_SATISFIED( x, y ) (((x) & (y)) == (y))
1510 #define LSMASH_IS_CLOSED_RAP( x ) LSMASH_FLAGS_SATISFIED( (x), ISOM_SAMPLE_RANDOM_ACCESS_FLAG_CLOSED_RAP )
1511 #define LSMASH_IS_OPEN_RAP( x ) LSMASH_FLAGS_SATISFIED( (x), ISOM_SAMPLE_RANDOM_ACCESS_FLAG_OPEN_RAP )
1512 #define LSMASH_IS_POST_ROLL_START( x ) LSMASH_FLAGS_SATISFIED( (x), ISOM_SAMPLE_RANDOM_ACCESS_FLAG_POST_ROLL_START )
1513 #define LSMASH_IS_PRE_ROLL_END( x ) LSMASH_FLAGS_SATISFIED( (x), ISOM_SAMPLE_RANDOM_ACCESS_FLAG_PRE_ROLL_END )
1515 typedef struct
1517 uint32_t identifier; /* the identifier of sample
1518 * If this identifier equals a certain identifier of random access recovery point,
1519 * then this sample is the random access recovery point of the earliest unestablished post-roll group. */
1520 uint32_t complete; /* the identifier of future random access recovery point, which is necessary for the recovery from its starting point to be completed
1521 * For muxing, this value is used only if (ra_flags & ISOM_SAMPLE_RANDOM_ACCESS_TYPE_POST_ROLL_START) is true.
1522 * The following is an example of use for gradual decoder refresh of H.264/AVC.
1523 * For each sample, set 'frame_num' to the 'identifier'.
1524 * For samples with recovery point SEI message, add ISOM_SAMPLE_RANDOM_ACCESS_TYPE_POST_ROLL_START to ra_flags
1525 * and set '(frame_num + recovery_frame_cnt) % MaxFrameNum' to the 'complete'.
1526 * The above-mentioned values are set appropriately, then L-SMASH will establish appropriate post-roll grouping. */
1527 } lsmash_post_roll_t;
1529 typedef struct
1531 uint32_t distance; /* the distance from the previous random access point or pre-roll starting point
1532 * of the random access recovery point to this sample.
1533 * For muxing, this value is used only if ra_flags is not set to ISOM_SAMPLE_RANDOM_ACCESS_TYPE_NONE
1534 * and LSMASH_IS_POST_ROLL_START( ra_flags ) is false.
1535 * Some derived specifications forbid using pre-roll settings and use post-roll settings instead (e.g. AVC uses only post-roll).
1536 * The following is an example of pre-roll distance for representing audio decoder delay derived from composition.
1537 * Typical AAC encoding uses a transform over consecutive sets of 2048 audio samples,
1538 * applied every 1024 audio samples (MDCTs are overlapped).
1539 * For correct audio to be decoded, both transforms for any period of 1024 audio samples are needed.
1540 * For this AAC stream, therefore, 'distance' of each sample shall be set to 1 (one AAC access unit).
1541 * Note: the number of priming audio sample i.e. encoder delay shall be represented by 'start_time' in an edit. */
1542 } lsmash_pre_roll_t;
1544 typedef struct
1546 lsmash_random_access_flag ra_flags; /* random access flags */
1547 lsmash_post_roll_t post_roll;
1548 lsmash_pre_roll_t pre_roll;
1549 uint8_t allow_earlier; /* only for QuickTime file format */
1550 uint8_t leading;
1551 uint8_t independent;
1552 uint8_t disposable;
1553 uint8_t redundant;
1554 uint8_t reserved[3]; /* broken link
1555 * ??? */
1556 } lsmash_sample_property_t;
1558 typedef struct
1560 #define LSMASH_TIMESTAMP_UNDEFINED UINT64_MAX
1561 uint32_t length; /* size of sample data
1562 * Note: this is NOT always an allocated size. */
1563 uint8_t *data; /* sample data */
1564 uint64_t dts; /* Decoding TimeStamp in units of media timescale
1565 * No two samples in the same track have the same Decoding TimeStamp.
1566 * Any user must not set Decoding TimeStamp of any sample to LSMASH_TIMESTAMP_UNDEFINED. */
1567 uint64_t cts; /* Composition TimeStamp in units of media timescale
1568 * No two samples in the same track have the same Composition TimeStamp.
1569 * If sample is a non-output sample i.e. decoded but not used, set its Composition TimeStamp to LSMASH_TIMESTAMP_UNDEFINED.
1570 * Composition TimeStamp of any non-output sample makes no sense. Note that explicit timeline maps shall be used to exclude
1571 * non-output samples from presentation timeline. */
1572 uint64_t pos; /* absolute file offset of sample data (read-only) */
1573 uint32_t index; /* index of sample description */
1574 lsmash_sample_property_t prop;
1575 } lsmash_sample_t;
1577 typedef struct
1579 uint64_t dts; /* Decoding TimeStamp in units of media timescale */
1580 uint64_t cts; /* Composition TimeStamp in units of media timescale */
1581 } lsmash_media_ts_t;
1583 typedef struct
1585 uint32_t sample_count;
1586 lsmash_media_ts_t *timestamp;
1587 } lsmash_media_ts_list_t;
1589 /* Allocate a sample and then allocate data of the allocated sample by 'size'.
1590 * If 'size' is set to 0, data of the allocated sample won't be allocated and will be set to NULL instead.
1591 * The allocated sample can be deallocated by lsmash_delete_sample().
1593 * Return the address of an allocated sample if successful.
1594 * Return NULL otherwise. */
1595 lsmash_sample_t *lsmash_create_sample
1597 uint32_t size /* size of sample data you request */
1600 /* Allocate data of a given allocated sample by 'size'.
1601 * If the sample data is already allocated, reallocate it by 'size'.
1603 * Return 0 if successful.
1604 * Return a negative value otherwise. */
1605 int lsmash_sample_alloc
1607 lsmash_sample_t *sample, /* the address of a sample you want to allocate its sample data */
1608 uint32_t size /* size of sample data you request */
1611 /* Deallocate a given sample. */
1612 void lsmash_delete_sample
1614 lsmash_sample_t *sample /* the address of a sample you want to deallocate */
1617 /* Append a sample to a track.
1618 * Note:
1619 * The appended sample will be deleted by lsmash_delete_sample() internally.
1620 * Users shall not deallocate the sample by lsmash_delete_sample() if successful to append the sample.
1622 * Return 0 if successful.
1623 * Return a negative value otherwise. */
1624 int lsmash_append_sample
1626 lsmash_root_t *root,
1627 uint32_t track_ID,
1628 lsmash_sample_t *sample
1631 /****************************************************************************
1632 * Media Layer
1633 ****************************************************************************/
1634 /* Media handler types */
1635 typedef enum
1637 ISOM_MEDIA_HANDLER_TYPE_3GPP_SCENE_DESCRIPTION = LSMASH_4CC( '3', 'g', 's', 'd' ),
1638 ISOM_MEDIA_HANDLER_TYPE_ID3_VERSION2_METADATA = LSMASH_4CC( 'I', 'D', '3', '2' ),
1639 ISOM_MEDIA_HANDLER_TYPE_AUXILIARY_VIDEO_TRACK = LSMASH_4CC( 'a', 'u', 'x', 'v' ),
1640 ISOM_MEDIA_HANDLER_TYPE_CPCM_AUXILIARY_METADATA = LSMASH_4CC( 'c', 'p', 'a', 'd' ),
1641 ISOM_MEDIA_HANDLER_TYPE_CLOCK_REFERENCE_STREAM = LSMASH_4CC( 'c', 'r', 's', 'm' ),
1642 ISOM_MEDIA_HANDLER_TYPE_DVB_MANDATORY_BASIC_DESCRIPTION = LSMASH_4CC( 'd', 'm', 'b', 'd' ),
1643 ISOM_MEDIA_HANDLER_TYPE_TV_ANYTIME = LSMASH_4CC( 'd', 't', 'v', 'a' ),
1644 ISOM_MEDIA_HANDLER_TYPE_BROADBAND_CONTENT_GUIDE = LSMASH_4CC( 'd', 't', 'v', 'a' ),
1645 ISOM_MEDIA_HANDLER_TYPE_FONT_DATA_STREAM = LSMASH_4CC( 'f', 'd', 's', 'm' ),
1646 ISOM_MEDIA_HANDLER_TYPE_GENERAL_MPEG4_SYSTEM_STREAM = LSMASH_4CC( 'g', 'e', 's', 'm' ),
1647 ISOM_MEDIA_HANDLER_TYPE_HINT_TRACK = LSMASH_4CC( 'h', 'i', 'n', 't' ),
1648 ISOM_MEDIA_HANDLER_TYPE_IPDC_ELECTRONIC_SERVICE_GUIDE = LSMASH_4CC( 'i', 'p', 'd', 'c' ),
1649 ISOM_MEDIA_HANDLER_TYPE_IPMP_STREAM = LSMASH_4CC( 'i', 'p', 's', 'm' ),
1650 ISOM_MEDIA_HANDLER_TYPE_MPEG7_STREAM = LSMASH_4CC( 'm', '7', 's', 'm' ),
1651 ISOM_MEDIA_HANDLER_TYPE_TIMED_METADATA_TRACK = LSMASH_4CC( 'm', 'e', 't', 'a' ),
1652 ISOM_MEDIA_HANDLER_TYPE_MPEGJ_STREAM = LSMASH_4CC( 'm', 'j', 's', 'm' ),
1653 ISOM_MEDIA_HANDLER_TYPE_MPEG21_DIGITAL_ITEM = LSMASH_4CC( 'm', 'p', '2', '1' ),
1654 ISOM_MEDIA_HANDLER_TYPE_OBJECT_CONTENT_INFO_STREAM = LSMASH_4CC( 'o', 'c', 's', 'm' ),
1655 ISOM_MEDIA_HANDLER_TYPE_OBJECT_DESCRIPTOR_STREAM = LSMASH_4CC( 'o', 'd', 's', 'm' ),
1656 ISOM_MEDIA_HANDLER_TYPE_SCENE_DESCRIPTION_STREAM = LSMASH_4CC( 's', 'd', 's', 'm' ),
1657 ISOM_MEDIA_HANDLER_TYPE_KEY_MANAGEMENT_MESSAGES = LSMASH_4CC( 's', 'k', 'm', 'm' ),
1658 ISOM_MEDIA_HANDLER_TYPE_AUDIO_TRACK = LSMASH_4CC( 's', 'o', 'u', 'n' ),
1659 ISOM_MEDIA_HANDLER_TYPE_TEXT_TRACK = LSMASH_4CC( 't', 'e', 'x', 't' ),
1660 ISOM_MEDIA_HANDLER_TYPE_PROPRIETARY_DESCRIPTIVE_METADATA = LSMASH_4CC( 'u', 'r', 'i', ' ' ),
1661 ISOM_MEDIA_HANDLER_TYPE_VIDEO_TRACK = LSMASH_4CC( 'v', 'i', 'd', 'e' ),
1662 } lsmash_media_type;
1664 /* ISO language codes */
1665 typedef enum
1667 #define LSMASH_PACK_ISO_LANGUAGE( a, b, c ) ((((a-0x60)&0x1f)<<10) | (((b-0x60)&0x1f)<<5) | ((c-0x60)&0x1f))
1668 ISOM_LANGUAGE_CODE_ENGLISH = LSMASH_PACK_ISO_LANGUAGE( 'e', 'n', 'g' ),
1669 ISOM_LANGUAGE_CODE_FRENCH = LSMASH_PACK_ISO_LANGUAGE( 'f', 'r', 'a' ),
1670 ISOM_LANGUAGE_CODE_GERMAN = LSMASH_PACK_ISO_LANGUAGE( 'd', 'e', 'u' ),
1671 ISOM_LANGUAGE_CODE_ITALIAN = LSMASH_PACK_ISO_LANGUAGE( 'i', 't', 'a' ),
1672 ISOM_LANGUAGE_CODE_DUTCH_M = LSMASH_PACK_ISO_LANGUAGE( 'd', 'u', 'm' ),
1673 ISOM_LANGUAGE_CODE_SWEDISH = LSMASH_PACK_ISO_LANGUAGE( 's', 'w', 'e' ),
1674 ISOM_LANGUAGE_CODE_SPANISH = LSMASH_PACK_ISO_LANGUAGE( 's', 'p', 'a' ),
1675 ISOM_LANGUAGE_CODE_DANISH = LSMASH_PACK_ISO_LANGUAGE( 'd', 'a', 'n' ),
1676 ISOM_LANGUAGE_CODE_PORTUGUESE = LSMASH_PACK_ISO_LANGUAGE( 'p', 'o', 'r' ),
1677 ISOM_LANGUAGE_CODE_NORWEGIAN = LSMASH_PACK_ISO_LANGUAGE( 'n', 'o', 'r' ),
1678 ISOM_LANGUAGE_CODE_HEBREW = LSMASH_PACK_ISO_LANGUAGE( 'h', 'e', 'b' ),
1679 ISOM_LANGUAGE_CODE_JAPANESE = LSMASH_PACK_ISO_LANGUAGE( 'j', 'p', 'n' ),
1680 ISOM_LANGUAGE_CODE_ARABIC = LSMASH_PACK_ISO_LANGUAGE( 'a', 'r', 'a' ),
1681 ISOM_LANGUAGE_CODE_FINNISH = LSMASH_PACK_ISO_LANGUAGE( 'f', 'i', 'n' ),
1682 ISOM_LANGUAGE_CODE_GREEK = LSMASH_PACK_ISO_LANGUAGE( 'e', 'l', 'l' ),
1683 ISOM_LANGUAGE_CODE_ICELANDIC = LSMASH_PACK_ISO_LANGUAGE( 'i', 's', 'l' ),
1684 ISOM_LANGUAGE_CODE_MALTESE = LSMASH_PACK_ISO_LANGUAGE( 'm', 'l', 't' ),
1685 ISOM_LANGUAGE_CODE_TURKISH = LSMASH_PACK_ISO_LANGUAGE( 't', 'u', 'r' ),
1686 ISOM_LANGUAGE_CODE_CROATIAN = LSMASH_PACK_ISO_LANGUAGE( 'h', 'r', 'v' ),
1687 ISOM_LANGUAGE_CODE_CHINESE = LSMASH_PACK_ISO_LANGUAGE( 'z', 'h', 'o' ),
1688 ISOM_LANGUAGE_CODE_URDU = LSMASH_PACK_ISO_LANGUAGE( 'u', 'r', 'd' ),
1689 ISOM_LANGUAGE_CODE_HINDI = LSMASH_PACK_ISO_LANGUAGE( 'h', 'i', 'n' ),
1690 ISOM_LANGUAGE_CODE_THAI = LSMASH_PACK_ISO_LANGUAGE( 't', 'h', 'a' ),
1691 ISOM_LANGUAGE_CODE_KOREAN = LSMASH_PACK_ISO_LANGUAGE( 'k', 'o', 'r' ),
1692 ISOM_LANGUAGE_CODE_LITHUANIAN = LSMASH_PACK_ISO_LANGUAGE( 'l', 'i', 't' ),
1693 ISOM_LANGUAGE_CODE_POLISH = LSMASH_PACK_ISO_LANGUAGE( 'p', 'o', 'l' ),
1694 ISOM_LANGUAGE_CODE_HUNGARIAN = LSMASH_PACK_ISO_LANGUAGE( 'h', 'u', 'n' ),
1695 ISOM_LANGUAGE_CODE_ESTONIAN = LSMASH_PACK_ISO_LANGUAGE( 'e', 's', 't' ),
1696 ISOM_LANGUAGE_CODE_LATVIAN = LSMASH_PACK_ISO_LANGUAGE( 'l', 'a', 'v' ),
1697 ISOM_LANGUAGE_CODE_SAMI = LSMASH_PACK_ISO_LANGUAGE( 's', 'm', 'i' ),
1698 ISOM_LANGUAGE_CODE_FAROESE = LSMASH_PACK_ISO_LANGUAGE( 'f', 'a', 'o' ),
1699 ISOM_LANGUAGE_CODE_RUSSIAN = LSMASH_PACK_ISO_LANGUAGE( 'r', 'u', 's' ),
1700 ISOM_LANGUAGE_CODE_DUTCH = LSMASH_PACK_ISO_LANGUAGE( 'n', 'l', 'd' ),
1701 ISOM_LANGUAGE_CODE_IRISH = LSMASH_PACK_ISO_LANGUAGE( 'g', 'l', 'e' ),
1702 ISOM_LANGUAGE_CODE_ALBANIAN = LSMASH_PACK_ISO_LANGUAGE( 's', 'q', 'i' ),
1703 ISOM_LANGUAGE_CODE_ROMANIAN = LSMASH_PACK_ISO_LANGUAGE( 'r', 'o', 'n' ),
1704 ISOM_LANGUAGE_CODE_CZECH = LSMASH_PACK_ISO_LANGUAGE( 'c', 'e', 's' ),
1705 ISOM_LANGUAGE_CODE_SLOVAK = LSMASH_PACK_ISO_LANGUAGE( 's', 'l', 'k' ),
1706 ISOM_LANGUAGE_CODE_SLOVENIA = LSMASH_PACK_ISO_LANGUAGE( 's', 'l', 'v' ),
1707 ISOM_LANGUAGE_CODE_YIDDISH = LSMASH_PACK_ISO_LANGUAGE( 'y', 'i', 'd' ),
1708 ISOM_LANGUAGE_CODE_SERBIAN = LSMASH_PACK_ISO_LANGUAGE( 's', 'r', 'p' ),
1709 ISOM_LANGUAGE_CODE_MACEDONIAN = LSMASH_PACK_ISO_LANGUAGE( 'm', 'k', 'd' ),
1710 ISOM_LANGUAGE_CODE_BULGARIAN = LSMASH_PACK_ISO_LANGUAGE( 'b', 'u', 'l' ),
1711 ISOM_LANGUAGE_CODE_UKRAINIAN = LSMASH_PACK_ISO_LANGUAGE( 'u', 'k', 'r' ),
1712 ISOM_LANGUAGE_CODE_BELARUSIAN = LSMASH_PACK_ISO_LANGUAGE( 'b', 'e', 'l' ),
1713 ISOM_LANGUAGE_CODE_UZBEK = LSMASH_PACK_ISO_LANGUAGE( 'u', 'z', 'b' ),
1714 ISOM_LANGUAGE_CODE_KAZAKH = LSMASH_PACK_ISO_LANGUAGE( 'k', 'a', 'z' ),
1715 ISOM_LANGUAGE_CODE_AZERBAIJANI = LSMASH_PACK_ISO_LANGUAGE( 'a', 'z', 'e' ),
1716 ISOM_LANGUAGE_CODE_ARMENIAN = LSMASH_PACK_ISO_LANGUAGE( 'h', 'y', 'e' ),
1717 ISOM_LANGUAGE_CODE_GEORGIAN = LSMASH_PACK_ISO_LANGUAGE( 'k', 'a', 't' ),
1718 ISOM_LANGUAGE_CODE_MOLDAVIAN = LSMASH_PACK_ISO_LANGUAGE( 'r', 'o', 'n' ),
1719 ISOM_LANGUAGE_CODE_KIRGHIZ = LSMASH_PACK_ISO_LANGUAGE( 'k', 'i', 'r' ),
1720 ISOM_LANGUAGE_CODE_TAJIK = LSMASH_PACK_ISO_LANGUAGE( 't', 'g', 'k' ),
1721 ISOM_LANGUAGE_CODE_TURKMEN = LSMASH_PACK_ISO_LANGUAGE( 't', 'u', 'k' ),
1722 ISOM_LANGUAGE_CODE_MONGOLIAN = LSMASH_PACK_ISO_LANGUAGE( 'm', 'o', 'n' ),
1723 ISOM_LANGUAGE_CODE_PASHTO = LSMASH_PACK_ISO_LANGUAGE( 'p', 'u', 's' ),
1724 ISOM_LANGUAGE_CODE_KURDISH = LSMASH_PACK_ISO_LANGUAGE( 'k', 'u', 'r' ),
1725 ISOM_LANGUAGE_CODE_KASHMIRI = LSMASH_PACK_ISO_LANGUAGE( 'k', 'a', 's' ),
1726 ISOM_LANGUAGE_CODE_SINDHI = LSMASH_PACK_ISO_LANGUAGE( 's', 'n', 'd' ),
1727 ISOM_LANGUAGE_CODE_TIBETAN = LSMASH_PACK_ISO_LANGUAGE( 'b', 'o', 'd' ),
1728 ISOM_LANGUAGE_CODE_NEPALI = LSMASH_PACK_ISO_LANGUAGE( 'n', 'e', 'p' ),
1729 ISOM_LANGUAGE_CODE_SANSKRIT = LSMASH_PACK_ISO_LANGUAGE( 's', 'a', 'n' ),
1730 ISOM_LANGUAGE_CODE_MARATHI = LSMASH_PACK_ISO_LANGUAGE( 'm', 'a', 'r' ),
1731 ISOM_LANGUAGE_CODE_BENGALI = LSMASH_PACK_ISO_LANGUAGE( 'b', 'e', 'n' ),
1732 ISOM_LANGUAGE_CODE_ASSAMESE = LSMASH_PACK_ISO_LANGUAGE( 'a', 's', 'm' ),
1733 ISOM_LANGUAGE_CODE_GUJARATI = LSMASH_PACK_ISO_LANGUAGE( 'g', 'u', 'j' ),
1734 ISOM_LANGUAGE_CODE_PUNJABI = LSMASH_PACK_ISO_LANGUAGE( 'p', 'a', 'n' ),
1735 ISOM_LANGUAGE_CODE_ORIYA = LSMASH_PACK_ISO_LANGUAGE( 'o', 'r', 'i' ),
1736 ISOM_LANGUAGE_CODE_MALAYALAM = LSMASH_PACK_ISO_LANGUAGE( 'm', 'a', 'l' ),
1737 ISOM_LANGUAGE_CODE_KANNADA = LSMASH_PACK_ISO_LANGUAGE( 'k', 'a', 'n' ),
1738 ISOM_LANGUAGE_CODE_TAMIL = LSMASH_PACK_ISO_LANGUAGE( 't', 'a', 'm' ),
1739 ISOM_LANGUAGE_CODE_TELUGU = LSMASH_PACK_ISO_LANGUAGE( 't', 'e', 'l' ),
1740 ISOM_LANGUAGE_CODE_SINHALESE = LSMASH_PACK_ISO_LANGUAGE( 's', 'i', 'n' ),
1741 ISOM_LANGUAGE_CODE_BURMESE = LSMASH_PACK_ISO_LANGUAGE( 'm', 'y', 'a' ),
1742 ISOM_LANGUAGE_CODE_KHMER = LSMASH_PACK_ISO_LANGUAGE( 'k', 'h', 'm' ),
1743 ISOM_LANGUAGE_CODE_LAO = LSMASH_PACK_ISO_LANGUAGE( 'l', 'a', 'o' ),
1744 ISOM_LANGUAGE_CODE_VIETNAMESE = LSMASH_PACK_ISO_LANGUAGE( 'v', 'i', 'e' ),
1745 ISOM_LANGUAGE_CODE_INDONESIAN = LSMASH_PACK_ISO_LANGUAGE( 'i', 'n', 'd' ),
1746 ISOM_LANGUAGE_CODE_TAGALOG = LSMASH_PACK_ISO_LANGUAGE( 't', 'g', 'l' ),
1747 ISOM_LANGUAGE_CODE_MALAY_ROMAN = LSMASH_PACK_ISO_LANGUAGE( 'm', 's', 'a' ),
1748 ISOM_LANGUAGE_CODE_MAYAY_ARABIC = LSMASH_PACK_ISO_LANGUAGE( 'm', 's', 'a' ),
1749 ISOM_LANGUAGE_CODE_AMHARIC = LSMASH_PACK_ISO_LANGUAGE( 'a', 'm', 'h' ),
1750 ISOM_LANGUAGE_CODE_OROMO = LSMASH_PACK_ISO_LANGUAGE( 'o', 'r', 'm' ),
1751 ISOM_LANGUAGE_CODE_SOMALI = LSMASH_PACK_ISO_LANGUAGE( 's', 'o', 'm' ),
1752 ISOM_LANGUAGE_CODE_SWAHILI = LSMASH_PACK_ISO_LANGUAGE( 's', 'w', 'a' ),
1753 ISOM_LANGUAGE_CODE_KINYARWANDA = LSMASH_PACK_ISO_LANGUAGE( 'k', 'i', 'n' ),
1754 ISOM_LANGUAGE_CODE_RUNDI = LSMASH_PACK_ISO_LANGUAGE( 'r', 'u', 'n' ),
1755 ISOM_LANGUAGE_CODE_CHEWA = LSMASH_PACK_ISO_LANGUAGE( 'n', 'y', 'a' ),
1756 ISOM_LANGUAGE_CODE_MALAGASY = LSMASH_PACK_ISO_LANGUAGE( 'm', 'l', 'g' ),
1757 ISOM_LANGUAGE_CODE_ESPERANTO = LSMASH_PACK_ISO_LANGUAGE( 'e', 'p', 'o' ),
1758 ISOM_LANGUAGE_CODE_WELSH = LSMASH_PACK_ISO_LANGUAGE( 'c', 'y', 'm' ),
1759 ISOM_LANGUAGE_CODE_BASQUE = LSMASH_PACK_ISO_LANGUAGE( 'e', 'u', 's' ),
1760 ISOM_LANGUAGE_CODE_CATALAN = LSMASH_PACK_ISO_LANGUAGE( 'c', 'a', 't' ),
1761 ISOM_LANGUAGE_CODE_LATIN = LSMASH_PACK_ISO_LANGUAGE( 'l', 'a', 't' ),
1762 ISOM_LANGUAGE_CODE_QUECHUA = LSMASH_PACK_ISO_LANGUAGE( 'q', 'u', 'e' ),
1763 ISOM_LANGUAGE_CODE_GUARANI = LSMASH_PACK_ISO_LANGUAGE( 'g', 'r', 'n' ),
1764 ISOM_LANGUAGE_CODE_AYMARA = LSMASH_PACK_ISO_LANGUAGE( 'a', 'y', 'm' ),
1765 ISOM_LANGUAGE_CODE_TATAR = LSMASH_PACK_ISO_LANGUAGE( 'c', 'r', 'h' ),
1766 ISOM_LANGUAGE_CODE_UIGHUR = LSMASH_PACK_ISO_LANGUAGE( 'u', 'i', 'g' ),
1767 ISOM_LANGUAGE_CODE_DZONGKHA = LSMASH_PACK_ISO_LANGUAGE( 'd', 'z', 'o' ),
1768 ISOM_LANGUAGE_CODE_JAVANESE = LSMASH_PACK_ISO_LANGUAGE( 'j', 'a', 'v' ),
1769 ISOM_LANGUAGE_CODE_UNDEFINED = LSMASH_PACK_ISO_LANGUAGE( 'u', 'n', 'd' ),
1770 } lsmash_iso_language_code;
1772 typedef struct
1774 lsmash_media_type handler_type; /* the nature of the media
1775 * You can't change handler_type through this parameter manually. */
1776 uint32_t timescale; /* media timescale: timescale for this media */
1777 uint64_t duration; /* the duration of this media, expressed in the media timescale
1778 * You can't set this parameter manually. */
1779 uint8_t roll_grouping; /* roll recovery grouping present
1780 * Require 'avc1' brand, or ISO Base Media File Format version 2 or later. */
1781 uint8_t rap_grouping; /* random access point grouping present
1782 * Require ISO Base Media File Format version 6 or later. */
1783 /* Use either type of language code. */
1784 uint16_t MAC_language; /* Macintosh language code for this media */
1785 uint16_t ISO_language; /* ISO 639-2/T language code for this media */
1786 /* human-readable name for the track type (for debugging and inspection purposes) */
1787 char *media_handler_name;
1788 char *data_handler_name;
1789 /* Any user shouldn't use the following parameters. */
1790 PRIVATE char media_handler_name_shadow[256];
1791 PRIVATE char data_handler_name_shadow[256];
1792 /* */
1793 uint8_t compact_sample_size_table; /* 1: Use compact size table if possible. (output/muxing mode)
1794 * Compact sample size table is used. (input/demuxing mode) */
1795 uint8_t no_sample_dependency_table; /* 1: Don't write sample dependency type table. (output/muxing mode)
1796 * Sample dependency type table is absent. (input/demuxing mode) */
1797 uint8_t reserved[2];
1798 } lsmash_media_parameters_t;
1800 typedef struct
1802 uint32_t index; /* the index of a data reference */
1803 char *location; /* URL; location of referenced media file */
1804 /* Probably, additional string fields such as thing to indicate URN will be added in the future. */
1805 } lsmash_data_reference_t;
1807 /* Set all the given media parameters to default. */
1808 void lsmash_initialize_media_parameters
1810 lsmash_media_parameters_t *param /* the address of the media parameters to which you want to set default value */
1813 /* Set media parameters to a track.
1815 * Return 0 if successful.
1816 * Return a negative value otherwise. */
1817 int lsmash_set_media_parameters
1819 lsmash_root_t *root, /* the address of a ROOT containing a track to which you want to set the media parameters */
1820 uint32_t track_ID, /* the track_ID of a track to which you want to set the media parameters */
1821 lsmash_media_parameters_t *param /* the address of the media parameters you want to set to a track. */
1824 /* Set the duration of the last sample to a track.
1826 * Return 0 if successful.
1827 * Return a negative value otherwise. */
1828 int lsmash_set_last_sample_delta
1830 lsmash_root_t *root,
1831 uint32_t track_ID,
1832 uint32_t sample_delta
1835 /* Flush samples in the internal pool in a track.
1836 * Users shall call this function for each track before calling lsmash_finish_movie() or lsmash_create_fragment_movie().
1838 * Return 0 if successful.
1839 * Return a negative value otherwise. */
1840 int lsmash_flush_pooled_samples
1842 lsmash_root_t *root,
1843 uint32_t track_ID,
1844 uint32_t last_sample_delta
1847 /* Update the modification time of a media to the most recent.
1848 * If the creation time of that media is larger than the modification time,
1849 * then override the creation one with the modification one.
1851 * Return 0 if successful.
1852 * Return a negative value otherwise. */
1853 int lsmash_update_media_modification_time
1855 lsmash_root_t *root,
1856 uint32_t track_ID
1859 /* Get the media parameters in a track.
1861 * Return 0 if successful.
1862 * Return a negative value otherwise. */
1863 int lsmash_get_media_parameters
1865 lsmash_root_t *root,
1866 uint32_t track_ID,
1867 lsmash_media_parameters_t *param
1870 /* Get the duration of a media.
1872 * Return the duration of a media if successful.
1873 * Return 0 otherwise. */
1874 uint64_t lsmash_get_media_duration
1876 lsmash_root_t *root,
1877 uint32_t track_ID
1880 /* Get the timescale of a media.
1882 * Return the timescale of a media if successful.
1883 * Return 0 otherwise. */
1884 uint32_t lsmash_get_media_timescale
1886 lsmash_root_t *root,
1887 uint32_t track_ID
1890 /* Get the duration of the last sample in a track.
1892 * Return the duration of the last sample in a track if successful.
1893 * Return 0 otherwise. */
1894 uint32_t lsmash_get_last_sample_delta
1896 lsmash_root_t *root,
1897 uint32_t track_ID
1900 /* Get the composition time offset of the first sample in a track.
1902 * Return the composition time offset of the first sample in a track if successful.
1903 * Return 0 otherwise. */
1904 uint32_t lsmash_get_start_time_offset
1906 lsmash_root_t *root,
1907 uint32_t track_ID
1910 /* Get the shift of composition timeline to decode timeline in a track.
1912 * Return the shift of composition timeline to decode timeline in a track. if successful.
1913 * Return 0 otherwise. */
1914 uint32_t lsmash_get_composition_to_decode_shift
1916 lsmash_root_t *root,
1917 uint32_t track_ID
1920 /* Pack a string of ISO 639-2/T language code into 16-bit data.
1922 * Return a packed 16-bit ISO 639-2/T language if successful.
1923 * Return 0 otherwise. */
1924 uint16_t lsmash_pack_iso_language
1926 char *iso_language /* a string of ISO 639-2/T language code */
1929 /* Count the number of data references in a track.
1931 * Return the number of data references in a track if no error.
1932 * Return 0 otherwise. */
1933 uint32_t lsmash_count_data_reference
1935 lsmash_root_t *root,
1936 uint32_t track_ID
1939 /* Get the location of a data reference in a track by specifying the index in 'data_ref'.
1940 * The string fields in 'data_ref' may be allocated if referencing external media data.
1941 * If referencing self-contained media data, the all string fields are set to NULL.
1942 * You can deallocate the allocated fields by lsmash_free().
1943 * Also you can deallocate all of the allocated fields by lsmash_cleanup_data_reference() at a time.
1945 * Return 0 if successful.
1946 * Return a negative value otherwise. */
1947 int lsmash_get_data_reference
1949 lsmash_root_t *root,
1950 uint32_t track_ID,
1951 lsmash_data_reference_t *data_ref
1954 /* Deallocate all of allocated fields in a given data reference at a time.
1955 * The deallocated fields are set to NULL. */
1956 void lsmash_cleanup_data_reference
1958 lsmash_data_reference_t *data_ref
1961 /* Create a data reference in a track and specify its location on playback for writing.
1962 * If no settings for data references in a track, the location of the first data reference is specified to
1963 * the location of the same file implicitly.
1964 * Note that referenced files shall be used as a media, i.e. LSMASH_FILE_MODE_MEDIA shall be set to the 'mode'
1965 * in the lsmash_file_parameters_t before calling lsmash_set_file().
1967 * As restrictions of the libary,
1968 * WARNING1: The box structured media files cannot be used as a reference data yet.
1969 * WARNING2: The external media files cannot be used as a reference data for movie fragments yet.
1971 * Return 0 if successful.
1972 * Return a negative value otherwise. */
1973 int lsmash_create_data_reference
1975 lsmash_root_t *root,
1976 uint32_t track_ID,
1977 lsmash_data_reference_t *data_ref,
1978 lsmash_file_t *file
1981 /* Assign a data reference in a track to a read file.
1983 * Return 0 if successful.
1984 * Return a negative value otherwise. */
1985 int lsmash_assign_data_reference
1987 lsmash_root_t *root,
1988 uint32_t track_ID,
1989 uint32_t data_ref_index,
1990 lsmash_file_t *file
1993 /****************************************************************************
1994 * Track Layer
1995 ****************************************************************************/
1996 /* Track mode */
1997 typedef enum
1999 /* In MP4 and/or ISO base media file format, if in a presentation all tracks have neither track_in_movie nor track_in_preview set,
2000 * then all tracks shall be treated as if both flags were set on all tracks. */
2001 ISOM_TRACK_ENABLED = 0x000001, /* Track_enabled: Indicates that the track is enabled.
2002 * A disabled track is treated as if it were not present. */
2003 ISOM_TRACK_IN_MOVIE = 0x000002, /* Track_in_movie: Indicates that the track is used in the presentation. */
2004 ISOM_TRACK_IN_PREVIEW = 0x000004, /* Track_in_preview: Indicates that the track is used when previewing the presentation. */
2006 QT_TRACK_IN_POSTER = 0x000008, /* Track_in_poster: Indicates that the track is used in the movie's poster. (only defined in QuickTime file format) */
2007 } lsmash_track_mode;
2009 typedef struct
2011 lsmash_track_mode mode;
2012 uint32_t track_ID; /* an integer that uniquely identifies the track
2013 * Don't set to value already used except for zero value.
2014 * Zero value don't override established track_ID. */
2015 uint64_t duration; /* the duration of this track expressed in the movie timescale units
2016 * If there is any edit, your setting is ignored. */
2017 int16_t alternate_group; /* an integer that specifies a group or collection of tracks
2018 * If this field is not 0, it should be the same for tracks that contain alternate data for one another
2019 * and different for tracks belonging to different such groups.
2020 * Only one track within an alternate group should be played or streamed at any one time.
2021 * Note: alternate_group is ignored when a file is read as an MPEG-4. */
2022 /* The following parameters are ignored when a file is read as an MPEG-4 or 3GPP file format. */
2023 int16_t video_layer; /* the front-to-back ordering of video tracks; tracks with lower numbers are closer to the viewer. */
2024 int16_t audio_volume; /* fixed point 8.8 number. 0x0100 is full volume. */
2025 int32_t matrix[9]; /* transformation matrix for the video
2026 * Each value represents, in order, a, b, u, c, d, v, x, y and w.
2027 * All the values in a matrix are stored as 16.16 fixed-point values,
2028 * except for u, v and w, which are stored as 2.30 fixed-point values.
2029 * Not all derived specifications use matrices.
2030 * If a matrix is used, the point (p, q) is transformed into (p', q') using the matrix as follows:
2031 * | a b u |
2032 * (p, q, 1) * | c d v | = z * (p', q', 1)
2033 * | x y w |
2034 * p' = (a * p + c * q + x) / z; q' = (b * p + d * q + y) / z; z = u * p + v * q + w
2035 * Note: transformation matrix is applied after scaling to display size up to display_width and display_height. */
2036 /* visual presentation region size */
2037 uint32_t display_width; /* visual presentation region size of horizontal direction as fixed point 16.16 number. */
2038 uint32_t display_height; /* visual presentation region size of vertical direction as fixed point 16.16 number. */
2039 /* */
2040 uint8_t aperture_modes; /* track aperture modes present
2041 * This feature is only available under QuickTime file format.
2042 * Automatically disabled if multiple sample description is present or scaling method is specified. */
2043 } lsmash_track_parameters_t;
2045 /* Explicit Timeline Map (Edit)
2046 * There are two types of timeline; one is the media timeline, the other is the presentation timeline (or the movie timeline).
2047 * An edit maps the presentation timeline to the media timeline.
2048 * Therefore, an edit can select any portion within the media and specify its playback speed.
2049 * The media within the track is played through the presentation timeline, so you can construct any complex presentation from a media by edits.
2050 * In the absence of any edit, there is an implicit one-to-one mapping of these timelines, and the presentation of a track starts at the beginning of the presentation.
2051 * Note: any edit doesn't restrict decoding and composition. So, if a sample in an edit need to decode from a sample in outside of that edit,
2052 * the decoder shall start to decode from there but player shall not display any sample in outside of that edit. */
2053 #define ISOM_EDIT_MODE_NORMAL (1<<16)
2054 #define ISOM_EDIT_MODE_DWELL 0
2055 #define ISOM_EDIT_MODE_EMPTY -1
2056 #define ISOM_EDIT_DURATION_UNKNOWN32 0xffffffff
2057 #define ISOM_EDIT_DURATION_UNKNOWN64 0xffffffffffffffff
2058 #define ISOM_EDIT_DURATION_IMPLICIT 0
2060 typedef struct
2062 uint64_t duration; /* the duration of this edit expressed in the movie timescale units
2063 * An edit can refer to the media within fragmented tracks.
2064 * The duration can be unknown at the time of creation of the initial movie due to various limiting factors that include
2065 * real-time generation of content, such as live streaming. In such a case it is recommended that the duration is set to
2066 * either ISOM_EDIT_DURATION_UNKNOWN32 (the maximum 32-bit unsigned integer), ISOM_EDIT_DURATION_UNKNOWN64 (the maximum
2067 * 64-bit unsigned integer) or ISOM_EDIT_DURATION_IMPLICIT.
2068 * If you have no interest in the duration of this edit but want to set the offset from media composition time to movie
2069 * presentation time, ISOM_EDIT_DURATION_IMPLICIT is useful for the provision of the offset for the movie and subsequent
2070 * movie fragments. The duration is expected to be constructed by demuxer. */
2071 int64_t start_time; /* the starting composition time within the media of this edit
2072 * If set to ISOM_EDIT_MODE_EMPTY (-1), it construct an empty edit, which doesn't select any portion within the media. */
2073 int32_t rate; /* the relative rate at which to play the media corresponding to this edit, expressed as 16.16 fixed-point number
2074 * If set to ISOM_EDIT_MODE_NORMAL (0x00010000), there is no rate change for timeline mapping.
2075 * If set to ISOM_EDIT_MODE_DWELL (0), the media at start_time is presented for the duration. */
2076 } lsmash_edit_t;
2078 /* Create a track in a movie.
2079 * Users can destroy the created track by lsmash_delete_track().
2080 * When a track is created, its track_ID is assigned automatically so that any duplication of track_ID may be avoided.
2082 * Return the current track_ID of a track created by this function if successful.
2083 * Return 0 otherwise. */
2084 uint32_t lsmash_create_track
2086 lsmash_root_t *root,
2087 lsmash_media_type media_type
2090 /* Destroy the track of a given track_ID in a movie. */
2091 void lsmash_delete_track
2093 lsmash_root_t *root,
2094 uint32_t track_ID
2097 /* Set all the given track parameters to default. */
2098 void lsmash_initialize_track_parameters
2100 lsmash_track_parameters_t *param
2103 /* Set track parameters to a track.
2105 * Return 0 if successful.
2106 * Return a negative value otherwise. */
2107 int lsmash_set_track_parameters
2109 lsmash_root_t *root,
2110 uint32_t track_ID,
2111 lsmash_track_parameters_t *param
2114 /* Update the duration of a track with a new duration of its last sample.
2116 * Return 0 if successful.
2117 * Return a negative value otherwise. */
2118 int lsmash_update_track_duration
2120 lsmash_root_t *root,
2121 uint32_t track_ID,
2122 uint32_t last_sample_delta
2125 /* Update the modification time of a track to the most recent.
2126 * If the creation time of that track is larger than the modification time,
2127 * then override the creation one with the modification one.
2129 * Return 0 if successful.
2130 * Return a negative value otherwise. */
2131 int lsmash_update_track_modification_time
2133 lsmash_root_t *root,
2134 uint32_t track_ID
2137 /* Get a track_ID by a track number.
2138 * A track number is given in created order in a movie.
2139 * If a track is removed, the track number of tracks with higher track number than one of just removed track will be decremented.
2141 * Return a track_ID if successful.
2142 * Return 0 otherwise. */
2143 uint32_t lsmash_get_track_ID
2145 lsmash_root_t *root,
2146 uint32_t track_number
2149 /* Get the track parameters in a track.
2151 * Return 0 if successful.
2152 * Return a negative value otherwise. */
2153 int lsmash_get_track_parameters
2155 lsmash_root_t *root,
2156 uint32_t track_ID,
2157 lsmash_track_parameters_t *param
2160 /* Get the duration of a track.
2162 * Return the duration of a track if successful.
2163 * Return 0 otherwise. */
2164 uint64_t lsmash_get_track_duration
2166 lsmash_root_t *root,
2167 uint32_t track_ID
2170 /* Create an explicit timeline map (edit) and append it into a track.
2171 * Users can destroy ALL created edits in a track by lsmash_delete_explicit_timeline_map().
2173 * Return 0 if successful.
2174 * Return a negative value otherwise. */
2175 int lsmash_create_explicit_timeline_map
2177 lsmash_root_t *root,
2178 uint32_t track_ID,
2179 lsmash_edit_t edit
2182 /* Destroy ALL created edits in a track.
2184 * Return 0 if successful.
2185 * Return a negative value otherwise. */
2186 int lsmash_delete_explicit_timeline_map
2188 lsmash_root_t *root,
2189 uint32_t track_ID
2192 /* Count the number of edits in a track.
2194 * Return the number of edits in a track if successful.
2195 * Return 0 otherwise. */
2196 uint32_t lsmash_count_explicit_timeline_map
2198 lsmash_root_t *root,
2199 uint32_t track_ID
2202 /* Get an edit in a track by an edit number.
2203 * An edit number is given in created order in a track.
2204 * If an edit is removed, the edit number of edits with higher edit number than one of just removed edit will be decremented.
2206 * Return 0 if successful.
2207 * Return a negative value otherwise. */
2208 int lsmash_get_explicit_timeline_map
2210 lsmash_root_t *root,
2211 uint32_t track_ID,
2212 uint32_t edit_number,
2213 lsmash_edit_t *edit
2216 /* Modify an edit in a track by an edit number.
2217 * An edit number is given in created order in a track.
2218 * If an edit is removed, the edit number of edits with higher edit number than one of just removed edit will be decremented.
2220 * Return 0 if successful.
2221 * Return a negative value otherwise. */
2222 int lsmash_modify_explicit_timeline_map
2224 lsmash_root_t *root,
2225 uint32_t track_ID,
2226 uint32_t edit_number,
2227 lsmash_edit_t edit
2230 /****************************************************************************
2231 * Movie Layer
2232 ****************************************************************************/
2233 typedef struct
2235 uint32_t timescale; /* movie timescale: timescale for the entire presentation */
2236 uint64_t duration; /* the duration, expressed in movie timescale, of the longest track
2237 * You can't set this parameter manually. */
2238 uint32_t number_of_tracks; /* the number of tracks in the movie
2239 * You can't set this parameter manually. */
2240 /* The following parameters are recognized only when a file is read as an Apple MPEG-4 or QuickTime file format. */
2241 int32_t playback_rate; /* fixed point 16.16 number. 0x00010000 is normal forward playback and default value. */
2242 int32_t playback_volume; /* fixed point 8.8 number. 0x0100 is full volume and default value. */
2243 int32_t preview_time; /* the time value in the movie at which the preview begins */
2244 int32_t preview_duration; /* the duration of the movie preview in movie timescale units */
2245 int32_t poster_time; /* the time value of the time of the movie poster */
2246 } lsmash_movie_parameters_t;
2248 /* Set all the given movie parameters to default. */
2249 void lsmash_initialize_movie_parameters
2251 lsmash_movie_parameters_t *param
2254 /* Set movie parameters to a movie.
2256 * Return 0 if successful.
2257 * Return a negative value otherwise. */
2258 int lsmash_set_movie_parameters
2260 lsmash_root_t *root,
2261 lsmash_movie_parameters_t *param
2264 /* Finalize a movie.
2265 * If the movie is not fragmented and 'remux' is set to non-NULL,
2266 * move overall necessary data to access and decode samples into the very front of the file at the end.
2267 * This is useful for progressive downloading.
2268 * Users shall call lsmash_flush_pooled_samples() for each track before calling this function.
2270 * Return 0 if successful.
2271 * Return a negative value otherwise. */
2272 int lsmash_finish_movie
2274 lsmash_root_t *root,
2275 lsmash_adhoc_remux_t *remux
2278 /* Update the modification time of a movie to the most recent.
2279 * If the creation time of that movie is larger than the modification time,
2280 * then override the creation one with the modification one.
2282 * Return 0 if successful.
2283 * Return a negative value otherwise. */
2284 int lsmash_update_movie_modification_time
2286 lsmash_root_t *root
2289 /* Get the movie parameters in a movie.
2291 * Return 0 if successful.
2292 * Return a negative value otherwise. */
2293 int lsmash_get_movie_parameters
2295 lsmash_root_t *root,
2296 lsmash_movie_parameters_t *param
2299 /* Get the timescale of a movie.
2301 * Return the timescale of a movie if successful.
2302 * Return 0 otherwise. */
2303 uint32_t lsmash_get_movie_timescale
2305 lsmash_root_t *root
2308 /* Reserve the size of the media data region for a non-fragmented movie.
2309 * This enables to get rid of requirement of seekability for rewriting the actual size of the media data region when finishing
2310 * a non-fragmented movie. Note that the specified size is excluding the type and the size fields of the enclosing box and
2311 * this function must be called before any lsmash_append_sample(). If the actual size is greater than the reserved size when
2312 * finishing a non-fragmented movie, seek and rewrite the size of the box enclosing the media data region.
2314 * Return 0 if successful.
2315 * Return a negative value otherwise. */
2316 int lsmash_reserve_media_data_size
2318 lsmash_root_t *root,
2319 uint64_t media_data_size
2322 /****************************************************************************
2323 * Chapter list
2324 ****************************************************************************/
2325 /* Create a track as a chapter list referenced by another track.
2327 * Return 0 if successful.
2328 * Return a negative value otherwise. */
2329 int lsmash_create_reference_chapter_track
2331 lsmash_root_t *root,
2332 uint32_t track_ID,
2333 char *file_name
2336 /* Create and set a chapter list as a user data to a movie.
2337 * The created chapter list in a movie can be destroyed by lsmash_delete_tyrant_chapter().
2339 * Return 0 if successful.
2340 * Return a negative value otherwise. */
2341 int lsmash_set_tyrant_chapter
2343 lsmash_root_t *root,
2344 char *file_name,
2345 int add_bom
2348 /* Destroy a chapter list as a user data in a movie. */
2349 void lsmash_delete_tyrant_chapter
2351 lsmash_root_t *root
2354 /* Count chapters in the chapter list (moov.udta.chpl). */
2355 uint32_t lsmash_count_tyrant_chapter
2357 lsmash_root_t *root
2360 /* Retrieve a chapter entry from the chapter list (moov.udta.chpl).
2361 * Returned pointer is owned by the ROOT structure, so user shall not
2362 * modify or free it.
2364 * Return chapter title string if successful, otherwise NULL.
2366 char *lsmash_get_tyrant_chapter
2368 lsmash_root_t *root,
2369 uint32_t index, /* index of chapter ( >= 1) */
2370 double *timestamp /* timestamp of the chapter entry (in seconds) */
2373 /****************************************************************************
2374 * Fragments
2375 ****************************************************************************/
2376 /* Flush the current movie fragment and create a new movie fragment.
2377 * Users shall call lsmash_flush_pooled_samples() for each track before calling this function.
2379 * Return 0 if successful.
2380 * Return a negative value otherwise. */
2381 int lsmash_create_fragment_movie
2383 lsmash_root_t *root
2386 /* Create an empty duration track in the current movie fragment.
2387 * Don't specify track_ID any track fragment in the current movie fragment has.
2389 * Return 0 if successful.
2390 * Return a negative value otherwise. */
2391 int lsmash_create_fragment_empty_duration
2393 lsmash_root_t *root,
2394 uint32_t track_ID,
2395 uint32_t duration
2398 /****************************************************************************
2399 * Dump / Print
2400 ****************************************************************************/
2401 /* Dump and print box structure of ROOT into the destination.
2403 * Return 0 if successful.
2404 * Return a negative value otherwise. */
2405 int lsmash_print_movie
2407 lsmash_root_t *root, /* the address of ROOT you want to dump and print */
2408 const char *filename /* the path of a file as the destination */
2411 /* Print a chapter list written as a user data on stdout.
2412 * This function might output BOM on Windows.
2414 * Return 0 if successful.
2415 * Return a negative value otherwise. */
2416 int lsmash_print_chapter_list
2418 lsmash_root_t *root
2421 /****************************************************************************
2422 * Timeline
2423 ****************************************************************************/
2424 /* Copy all edits from the source track to the destination track.
2426 * Return 0 if successful.
2427 * Return a negative value otherwise. */
2428 int lsmash_copy_timeline_map
2430 lsmash_root_t *dst,
2431 uint32_t dst_track_ID,
2432 lsmash_root_t *src,
2433 uint32_t src_track_ID
2436 /* Construct the timeline for a track.
2437 * The constructed timeline can be destructed by lsmash_destruct_timeline().
2439 * Return 0 if successful.
2440 * Return a negative value otherwise. */
2441 int lsmash_construct_timeline
2443 lsmash_root_t *root,
2444 uint32_t track_ID
2447 /* Destruct the timeline for a given track. */
2448 void lsmash_destruct_timeline
2450 lsmash_root_t *root,
2451 uint32_t track_ID
2454 /* Get the duration of the last sample from the media timeline for a track.
2456 * Return 0 if successful.
2457 * Return a negative value otherwise. */
2458 int lsmash_get_last_sample_delta_from_media_timeline
2460 lsmash_root_t *root,
2461 uint32_t track_ID,
2462 uint32_t *last_sample_delta /* the address of a variable to which the duration of the last sample will be set */
2465 /* Get the duration of a sample from the media timeline for a track.
2467 * Return 0 if successful.
2468 * Return a negative value otherwise. */
2469 int lsmash_get_sample_delta_from_media_timeline
2471 lsmash_root_t *root,
2472 uint32_t track_ID,
2473 uint32_t sample_number,
2474 uint32_t *sample_delta /* the address of a variable to which the duration of a sample will be set */
2477 /* Get the decoding timestamp of a sample from the media timeline for a track.
2479 * Return 0 if successful.
2480 * Return a negative value otherwise. */
2481 int lsmash_get_dts_from_media_timeline
2483 lsmash_root_t *root,
2484 uint32_t track_ID,
2485 uint32_t sample_number,
2486 uint64_t *dts /* the address of a variable to which a decoding timestamp will be set */
2489 /* Get the composition timestamp of a sample from the media timeline for a track.
2491 * Return 0 if successful.
2492 * Return a negative value otherwise. */
2493 int lsmash_get_cts_from_media_timeline
2495 lsmash_root_t *root,
2496 uint32_t track_ID,
2497 uint32_t sample_number,
2498 uint64_t *cts /* the address of a variable to which a composition timestamp will be set */
2501 /* Get the shift of composition timeline to decode timeline from the media timeline for a track.
2503 * Return 0 if successful.
2504 * Return a negative value otherwise. */
2505 int lsmash_get_composition_to_decode_shift_from_media_timeline
2507 lsmash_root_t *root,
2508 uint32_t track_ID,
2509 uint32_t *ctd_shift /* the address of a variable to which the shift of composition timeline to decode timeline will be set */
2512 /* Get the sample number which is the closest random accessible point to the sample
2513 * corresponding to a given sample number from the media timeline for a track.
2514 * This function tries to find the closest random accessible point from the past at the first.
2515 * If not found, try to find it from the future.
2516 * Note:
2517 * the closest random accessible point doesn't always guarantee that
2518 * the sample corresponding to a given number can be decodable correctly by decoding from there.
2520 * Return 0 if successful.
2521 * Return a negative value otherwise. */
2522 int lsmash_get_closest_random_accessible_point_from_media_timeline
2524 lsmash_root_t *root,
2525 uint32_t track_ID,
2526 uint32_t sample_number,
2527 uint32_t *rap_number /* the address of a variable to which the sample number of the closest random accessible point will be set */
2530 /* Get the detailed information of the closest random accessible point to the sample
2531 * corresponding to a given sample number from the media timeline for a track.
2532 * Note:
2533 * the closest random accessible point doesn't always guarantee that
2534 * the sample corresponding to a given number can be decodable correctly by decoding from there.
2536 * Return 0 if successful.
2537 * Return a negative value otherwise. */
2538 int lsmash_get_closest_random_accessible_point_detail_from_media_timeline
2540 lsmash_root_t *root,
2541 uint32_t track_ID,
2542 uint32_t sample_number,
2543 uint32_t *rap_number, /* the address of a variable to which the sample number of the closest random accessible point will be set */
2544 lsmash_random_access_flag *ra_flags, /* the address of a variable to which the flags of the closest random accessible point will be set */
2545 uint32_t *leading, /* the address of a variable to which the number of leading samples will be set */
2546 uint32_t *distance /* the address of a variable to which a distance from the closest random accessible point to a point which guarantees
2547 * that the sample corresponding to a given number can be decodable correctly by decoding from there will be set */
2550 /* Get the number of samples in the media timeline for a track.
2552 * Return the number of samples in a track if successful.
2553 * Return 0 otherwise. */
2554 uint32_t lsmash_get_sample_count_in_media_timeline
2556 lsmash_root_t *root,
2557 uint32_t track_ID
2560 /* Get the maximum size of sample in the media timeline for a track.
2562 * Return the maximum size of the samples in a track if successful.
2563 * Return 0 otherwise. */
2564 uint32_t lsmash_get_max_sample_size_in_media_timeline
2566 lsmash_root_t *root,
2567 uint32_t track_ID
2570 /* Get the duration of the media from the media timeline for a track.
2572 * Return the duration of the media in a track if successful.
2573 * Return 0 otherwise. */
2574 uint64_t lsmash_get_media_duration_from_media_timeline
2576 lsmash_root_t *root,
2577 uint32_t track_ID
2580 /* Allocate and get the sample corresponding to a given sample number from the media timeline for a track.
2581 * The allocated sample can be deallocated by lsmash_delete_sample().
2583 * Return the address of an allocated and gotten sample if successful.
2584 * Return NULL otherwise. */
2585 lsmash_sample_t *lsmash_get_sample_from_media_timeline
2587 lsmash_root_t *root,
2588 uint32_t track_ID,
2589 uint32_t sample_number
2592 /* Get the information of the sample correspondint to a given sample number from the media timeline for a track.
2593 * The information includes the size, timestamps and properties of the sample.
2595 * Return 0 if successful.
2596 * Return a negative value otherwise. */
2597 int lsmash_get_sample_info_from_media_timeline
2599 lsmash_root_t *root,
2600 uint32_t track_ID,
2601 uint32_t sample_number,
2602 lsmash_sample_t *sample
2605 /* Get the properties of the sample correspondint to a given sample number from the media timeline for a track.
2607 * Return 0 if successful.
2608 * Return a negative value otherwise. */
2609 int lsmash_get_sample_property_from_media_timeline
2611 lsmash_root_t *root,
2612 uint32_t track_ID,
2613 uint32_t sample_number,
2614 lsmash_sample_property_t *prop
2617 /* Check if the sample corresponding to a given sample number exists in the media timeline for a track.
2619 * Return 1 if the sample exists.
2620 * Return 0 otherwise. */
2621 int lsmash_check_sample_existence_in_media_timeline
2623 lsmash_root_t *root,
2624 uint32_t track_ID,
2625 uint32_t sample_number
2628 /* Set or change the decoding and composition timestamps in the media timeline for a track.
2629 * This function doesn't support for any LPCM track currently.
2631 * Return 0 if successful.
2632 * Return a negative value othewise. */
2633 int lsmash_set_media_timestamps
2635 lsmash_root_t *root,
2636 uint32_t track_ID,
2637 lsmash_media_ts_list_t *ts_list
2640 /* Allocate and get the decoding and composition timestamps from the media timeline for a track.
2641 * The allocated decoding and composition timestamps can be deallocated by lsmash_delete_media_timestamps().
2643 * Return 0 if successful.
2644 * Return a negative value othewise. */
2645 int lsmash_get_media_timestamps
2647 lsmash_root_t *root,
2648 uint32_t track_ID,
2649 lsmash_media_ts_list_t *ts_list
2652 /* Deallocate the decoding and composition timestamps in a given media timestamp list. */
2653 void lsmash_delete_media_timestamps
2655 lsmash_media_ts_list_t *ts_list
2658 /* Get the maximum composition delay derived from composition reordering.
2660 * Return 0 if successful.
2661 * Return a negative value otherwise. */
2662 int lsmash_get_max_sample_delay
2664 lsmash_media_ts_list_t *ts_list,
2665 uint32_t *max_sample_delay
2668 /* Sort decoding and composition timestamps in decoding order. */
2669 void lsmash_sort_timestamps_decoding_order
2671 lsmash_media_ts_list_t *ts_list
2674 /* Sort decoding and composition timestamps in composition order. */
2675 void lsmash_sort_timestamps_composition_order
2677 lsmash_media_ts_list_t *ts_list
2680 /****************************************************************************
2681 * Tools for creating CODEC Specific Information Extensions (Magic Cookies)
2682 ****************************************************************************/
2683 /* MPEG-4 Systems Specific Information
2684 * Mandatory :
2685 * ISOM_CODEC_TYPE_MP4A_AUDIO
2686 * QT_CODEC_TYPE_MP4A_AUDIO
2687 * ISOM_CODEC_TYPE_MP4V_AUDIO
2688 * ISOM_CODEC_TYPE_MP4S_AUDIO */
2689 /* objectTypeIndication */
2690 typedef enum
2692 MP4SYS_OBJECT_TYPE_Forbidden = 0x00, /* Forbidden */
2693 MP4SYS_OBJECT_TYPE_Systems_ISO_14496_1 = 0x01, /* Systems ISO/IEC 14496-1
2694 * For all 14496-1 streams unless specifically indicated to the contrary.
2695 * Scene Description scenes, which are identified with StreamType=0x03, using
2696 * this object type value shall use the BIFSConfig. */
2697 MP4SYS_OBJECT_TYPE_Systems_ISO_14496_1_BIFSv2 = 0x02, /* Systems ISO/IEC 14496-1
2698 * This object type shall be used, with StreamType=0x03, for Scene
2699 * Description streams that use the BIFSv2Config.
2700 * Its use with other StreamTypes is reserved. */
2701 MP4SYS_OBJECT_TYPE_Interaction_Stream = 0x03, /* Interaction Stream */
2702 MP4SYS_OBJECT_TYPE_Extended_BIFS = 0x04, /* Extended BIFS
2703 * Used, with StreamType=0x03, for Scene Description streams that use the BIFSConfigEx;
2704 * its use with other StreamTypes is reserved.
2705 * (Was previously reserved for MUCommandStream but not used for that purpose.) */
2706 MP4SYS_OBJECT_TYPE_AFX_Stream = 0x05, /* AFX Stream
2707 * Used, with StreamType=0x03, for Scene Description streams that use the AFXConfig;
2708 * its use with other StreamTypes is reserved. */
2709 MP4SYS_OBJECT_TYPE_Font_Data_Stream = 0x06, /* Font Data Stream */
2710 MP4SYS_OBJECT_TYPE_Synthetised_Texture = 0x07, /* Synthetised Texture */
2711 MP4SYS_OBJECT_TYPE_Text_Stream = 0x08, /* Text Stream */
2712 MP4SYS_OBJECT_TYPE_Visual_ISO_14496_2 = 0x20, /* Visual ISO/IEC 14496-2
2713 * The actual object types are within the DecoderSpecificInfo and defined in 14496-2. */
2714 MP4SYS_OBJECT_TYPE_Visual_H264_ISO_14496_10 = 0x21, /* Visual ITU-T Recommendation H.264 | ISO/IEC 14496-10
2715 * The actual object types are within the DecoderSpecificInfo and defined in H.264 | 14496-10. */
2716 MP4SYS_OBJECT_TYPE_Parameter_Sets_H_264_ISO_14496_10 = 0x22, /* Parameter Sets for ITU-T Recommendation H.264 | ISO/IEC 14496-10
2717 * The actual object types are within the DecoderSpecificInfo and defined in H.264 | 14496-10. */
2718 MP4SYS_OBJECT_TYPE_Audio_ISO_14496_3 = 0x40, /* Audio ISO/IEC 14496-3 (MPEG-4 Audio)
2719 * The actual object types are defined in 14496-3 and are in the DecoderSpecificInfo as specified in 14496-3. */
2720 MP4SYS_OBJECT_TYPE_Visual_ISO_13818_2_Simple_Profile = 0x60, /* Visual ISO/IEC 13818-2 Simple Profile (MPEG-2 Video) */
2721 MP4SYS_OBJECT_TYPE_Visual_ISO_13818_2_Main_Profile = 0x61, /* Visual ISO/IEC 13818-2 Main Profile */
2722 MP4SYS_OBJECT_TYPE_Visual_ISO_13818_2_SNR_Profile = 0x62, /* Visual ISO/IEC 13818-2 SNR Profile */
2723 MP4SYS_OBJECT_TYPE_Visual_ISO_13818_2_Spatial_Profile = 0x63, /* Visual ISO/IEC 13818-2 Spatial Profile */
2724 MP4SYS_OBJECT_TYPE_Visual_ISO_13818_2_High_Profile = 0x64, /* Visual ISO/IEC 13818-2 High Profile */
2725 MP4SYS_OBJECT_TYPE_Visual_ISO_13818_2_422_Profile = 0x65, /* Visual ISO/IEC 13818-2 422 Profile */
2726 MP4SYS_OBJECT_TYPE_Audio_ISO_13818_7_Main_Profile = 0x66, /* Audio ISO/IEC 13818-7 Main Profile (MPEG-2 Audio)(AAC) */
2727 MP4SYS_OBJECT_TYPE_Audio_ISO_13818_7_LC_Profile = 0x67, /* Audio ISO/IEC 13818-7 LowComplexity Profile */
2728 MP4SYS_OBJECT_TYPE_Audio_ISO_13818_7_SSR_Profile = 0x68, /* Audio ISO/IEC 13818-7 Scaleable Sampling Rate Profile
2729 * For streams kinda 13818-7 the decoder specific information consists of the ADIF header if present
2730 * (or none if not present) and an access unit is a "raw_data_block()" as defined in 13818-7. */
2731 MP4SYS_OBJECT_TYPE_Audio_ISO_13818_3 = 0x69, /* Audio ISO/IEC 13818-3 (MPEG-2 BC-Audio)(redefined MPEG-1 Audio in MPEG-2)
2732 * For streams kinda 13818-3 the decoder specific information is empty since all necessary data is in the bitstream frames itself.
2733 * The access units in this case are the "frame()" bitstream element as is defined in 11172-3. */
2734 MP4SYS_OBJECT_TYPE_Visual_ISO_11172_2 = 0x6A, /* Visual ISO/IEC 11172-2 (MPEG-1 Video) */
2735 MP4SYS_OBJECT_TYPE_Audio_ISO_11172_3 = 0x6B, /* Audio ISO/IEC 11172-3 (MPEG-1 Audio) */
2736 MP4SYS_OBJECT_TYPE_Visual_ISO_10918_1 = 0x6C, /* Visual ISO/IEC 10918-1 (JPEG) */
2737 MP4SYS_OBJECT_TYPE_PNG = 0x6D, /* Portable Network Graphics */
2738 MP4SYS_OBJECT_TYPE_Visual_ISO_15444_1_JPEG2000 = 0x6E, /* Visual ISO/IEC 15444-1 (JPEG 2000) */
2740 /* FIXME: rename these symbols to be explaining, rather than based on four cc */
2741 MP4SYS_OBJECT_TYPE_EVRC_AUDIO = 0xA0, /* EVRC Voice */
2742 MP4SYS_OBJECT_TYPE_SSMV_AUDIO = 0xA1, /* SMV Voice */
2743 MP4SYS_OBJECT_TYPE_3GPP2_CMF = 0xA2, /* 3GPP2 Compact Multimedia Format (CMF) */
2744 MP4SYS_OBJECT_TYPE_VC_1_VIDEO = 0xA3, /* SMPTE VC-1 Video */
2745 MP4SYS_OBJECT_TYPE_DRAC_VIDEO = 0xA4, /* Dirac Video Coder */
2746 MP4SYS_OBJECT_TYPE_AC_3_AUDIO = 0xA5, /* AC-3 Audio */
2747 MP4SYS_OBJECT_TYPE_EC_3_AUDIO = 0xA6, /* Enhanced AC-3 audio */
2748 MP4SYS_OBJECT_TYPE_DRA1_AUDIO = 0xA7, /* DRA Audio */
2749 MP4SYS_OBJECT_TYPE_G719_AUDIO = 0xA8, /* ITU G.719 Audio */
2750 MP4SYS_OBJECT_TYPE_DTSC_AUDIO = 0xA9, /* DTS Coherent Acoustics audio */
2751 MP4SYS_OBJECT_TYPE_DTSH_AUDIO = 0xAA, /* DTS-HD High Resolution Audio */
2752 MP4SYS_OBJECT_TYPE_DTSL_AUDIO = 0xAB, /* DTS-HD Master Audio */
2753 MP4SYS_OBJECT_TYPE_DTSE_AUDIO = 0xAC, /* DTS Express low bit rate audio, also known as DTS LBR */
2754 MP4SYS_OBJECT_TYPE_SQCP_AUDIO = 0xE1, /* 13K Voice */
2756 MP4SYS_OBJECT_TYPE_NONE = 0xFF, /* no object type specified
2757 * Streams with this value with a StreamType indicating a systems stream (values 1,2,3,6,7,8,9)
2758 * shall be treated as if the ObjectTypeIndication had been set to 0x01. */
2759 } lsmash_mp4sys_object_type_indication;
2761 /* streamType */
2762 typedef enum
2764 MP4SYS_STREAM_TYPE_Forbidden = 0x00, /* Forbidden */
2765 MP4SYS_STREAM_TYPE_ObjectDescriptorStream = 0x01, /* ObjectDescriptorStream */
2766 MP4SYS_STREAM_TYPE_ClockReferenceStream = 0x02, /* ClockReferenceStream */
2767 MP4SYS_STREAM_TYPE_SceneDescriptionStream = 0x03, /* SceneDescriptionStream */
2768 MP4SYS_STREAM_TYPE_VisualStream = 0x04, /* VisualStream */
2769 MP4SYS_STREAM_TYPE_AudioStream = 0x05, /* AudioStream */
2770 MP4SYS_STREAM_TYPE_MPEG7Stream = 0x06, /* MPEG7Stream */
2771 MP4SYS_STREAM_TYPE_IPMPStream = 0x07, /* IPMPStream */
2772 MP4SYS_STREAM_TYPE_ObjectContentInfoStream = 0x08, /* ObjectContentInfoStream */
2773 MP4SYS_STREAM_TYPE_MPEGJStream = 0x09, /* MPEGJStream */
2774 MP4SYS_STREAM_TYPE_InteractionStream = 0x0A, /* Interaction Stream */
2775 MP4SYS_STREAM_TYPE_IPMPToolStream = 0x0B, /* IPMPToolStream */
2776 MP4SYS_STREAM_TYPE_FontDataStream = 0x0C, /* FontDataStream */
2777 MP4SYS_STREAM_TYPE_StreamingText = 0x0D, /* StreamingText */
2778 } lsmash_mp4sys_stream_type;
2780 /* MPEG-4 Systems Decoder Specific Information
2781 * an opaque container with information for a specific media decoder
2782 * The existence and semantics of decoder specific information depends on the values of streamType and objectTypeIndication. */
2783 typedef struct lsmash_mp4sys_decoder_specific_info_tag lsmash_mp4sys_decoder_specific_info_t;
2785 /* Note: bufferSizeDB, maxBitrate and avgBitrate are calculated internally when calling lsmash_finish_movie().
2786 * You need not to set up them manually when muxing streams by L-SMASH. */
2787 typedef struct
2789 lsmash_mp4sys_object_type_indication objectTypeIndication;
2790 lsmash_mp4sys_stream_type streamType;
2791 uint32_t bufferSizeDB; /* the size of the decoding buffer for this elementary stream in byte */
2792 uint32_t maxBitrate; /* the maximum bitrate in bits per second of the elementary stream in
2793 * any time window of one second duration */
2794 uint32_t avgBitrate; /* the average bitrate in bits per second of the elementary stream
2795 * Set to 0 if the stream is encoded as variable bitrate. */
2796 lsmash_mp4sys_decoder_specific_info_t *dsi; /* zero or one decoder specific information */
2797 } lsmash_mp4sys_decoder_parameters_t;
2799 int lsmash_set_mp4sys_decoder_specific_info
2801 lsmash_mp4sys_decoder_parameters_t *param,
2802 uint8_t *payload,
2803 uint32_t payload_length
2806 void lsmash_destroy_mp4sys_decoder_specific_info
2808 lsmash_mp4sys_decoder_parameters_t *param
2811 uint8_t *lsmash_create_mp4sys_decoder_config
2813 lsmash_mp4sys_decoder_parameters_t *param,
2814 uint32_t *data_length
2817 /* Return MP4SYS_OBJECT_TYPE_Forbidden if objectTypeIndication is not found or there is an error to find it. */
2818 lsmash_mp4sys_object_type_indication lsmash_mp4sys_get_object_type_indication
2820 lsmash_summary_t *summary
2823 /* Return -1 if any error.
2824 * Even if the decoder specific information is not found, it is not an error since no decoder specific information is allowed for some stream formats. */
2825 int lsmash_get_mp4sys_decoder_specific_info
2827 lsmash_mp4sys_decoder_parameters_t *param,
2828 uint8_t **payload,
2829 uint32_t *payload_length
2832 /* AC-3 Specific Information
2833 * Mandatory :
2834 * ISOM_CODEC_TYPE_AC_3_AUDIO
2836 * Unlike MPEG-4 Audio formats, the decoder does not require this for the initialization.
2837 * Each AC-3 sample is self-contained.
2838 * Users shall set the actual sample rate to 'frequency', which is a member of lsmash_audio_summary_t. */
2839 typedef struct
2841 uint8_t fscod; /* the same value as the fscod field in the AC-3 bitstream */
2842 uint8_t bsid; /* the same value as the bsid field in the AC-3 bitstream */
2843 uint8_t bsmod; /* the same value as the bsmod field in the AC-3 bitstream */
2844 uint8_t acmod; /* the same value as the acmod field in the AC-3 bitstream */
2845 uint8_t lfeon; /* the same value as the lfeon field in the AC-3 bitstream */
2846 uint8_t frmsizecod; /* the same value as the frmsizecod field in the AC-3 bitstream */
2847 } lsmash_ac3_specific_parameters_t;
2849 int lsmash_setup_ac3_specific_parameters_from_syncframe
2851 lsmash_ac3_specific_parameters_t *param,
2852 uint8_t *data,
2853 uint32_t data_length
2856 uint8_t *lsmash_create_ac3_specific_info
2858 lsmash_ac3_specific_parameters_t *param,
2859 uint32_t *data_length
2862 /* Enhanced AC-3 Specific Information
2863 * Mandatory :
2864 * ISOM_CODEC_TYPE_EC_3_AUDIO
2866 * Unlike MPEG-4 Audio formats, the decoder does not require this for the initialization.
2867 * Each Enhanced AC-3 sample is self-contained.
2868 * Note that this cannot document reduced sample rates (24000, 22050 or 16000 Hz).
2869 * Therefore, users shall set the actual sample rate to 'frequency', which is a member of lsmash_audio_summary_t. */
2870 typedef struct
2872 uint8_t fscod; /* the same value as the fscod field in the independent substream */
2873 uint8_t bsid; /* the same value as the bsid field in the independent substream */
2874 uint8_t bsmod; /* the same value as the bsmod field in the independent substream
2875 * If the bsmod field is not present in the independent substream, this field shall be set to 0. */
2876 uint8_t acmod; /* the same value as the acmod field in the independent substream */
2877 uint8_t lfeon; /* the same value as the lfeon field in the independent substream */
2878 uint8_t num_dep_sub; /* the number of dependent substreams that are associated with the independent substream */
2879 uint16_t chan_loc; /* channel locations of dependent substreams associated with the independent substream
2880 * This information is extracted from the chanmap field of each dependent substream. */
2881 } lsmash_eac3_substream_info_t;
2883 typedef struct
2885 uint16_t data_rate; /* the data rate of the Enhanced AC-3 bitstream in kbit/s
2886 * If the Enhanced AC-3 stream is variable bitrate, then this value indicates the maximum data rate of the stream. */
2887 uint8_t num_ind_sub; /* the number of independent substreams that are present in the Enhanced AC-3 bitstream
2888 * The value of this field is one less than the number of independent substreams present
2889 * and shall be in the range of 0 to 7, inclusive. */
2890 lsmash_eac3_substream_info_t independent_info[8];
2891 } lsmash_eac3_specific_parameters_t;
2893 int lsmash_setup_eac3_specific_parameters_from_frame
2895 lsmash_eac3_specific_parameters_t *param,
2896 uint8_t *data,
2897 uint32_t data_length
2900 uint16_t lsmash_eac3_get_chan_loc_from_chanmap
2902 uint16_t chanmap
2905 uint8_t *lsmash_create_eac3_specific_info
2907 lsmash_eac3_specific_parameters_t *param,
2908 uint32_t *data_length
2911 /* DTS Audio Specific Information
2912 * Mandatory :
2913 * ISOM_CODEC_TYPE_DTSC_AUDIO
2914 * ISOM_CODEC_TYPE_DTSH_AUDIO
2915 * ISOM_CODEC_TYPE_DTSL_AUDIO
2916 * ISOM_CODEC_TYPE_DTSE_AUDIO
2918 * Unlike MPEG-4 Audio formats, the decoder does not require this for the initialization.
2919 * Each DTS Audio sample is self-contained. */
2920 typedef enum
2922 DTS_CORE_SUBSTREAM_CORE_FLAG = 0x00000001,
2923 DTS_CORE_SUBSTREAM_XXCH_FLAG = 0x00000002,
2924 DTS_CORE_SUBSTREAM_X96_FLAG = 0x00000004,
2925 DTS_CORE_SUBSTREAM_XCH_FLAG = 0x00000008,
2926 DTS_EXT_SUBSTREAM_CORE_FLAG = 0x00000010,
2927 DTS_EXT_SUBSTREAM_XBR_FLAG = 0x00000020,
2928 DTS_EXT_SUBSTREAM_XXCH_FLAG = 0x00000040,
2929 DTS_EXT_SUBSTREAM_X96_FLAG = 0x00000080,
2930 DTS_EXT_SUBSTREAM_LBR_FLAG = 0x00000100,
2931 DTS_EXT_SUBSTREAM_XLL_FLAG = 0x00000200,
2932 } lsmash_dts_construction_flag;
2934 typedef struct lsmash_dts_reserved_box_tag lsmash_dts_reserved_box_t;
2936 typedef struct
2938 uint32_t DTSSamplingFrequency; /* the maximum sampling frequency stored in the compressed audio stream
2939 * 'frequency', which is a member of lsmash_audio_summary_t, shall be set according to DTSSamplingFrequency of either:
2940 * 48000 for original sampling frequencies of 24000Hz, 48000Hz, 96000Hz or 192000Hz;
2941 * 44100 for original sampling frequencies of 22050Hz, 44100Hz, 88200Hz or 176400Hz;
2942 * 32000 for original sampling frequencies of 16000Hz, 32000Hz, 64000Hz or 128000Hz. */
2943 uint32_t maxBitrate; /* the peak bit rate, in bits per second, of the audio elementary stream for the duration of the track,
2944 * including the core substream (if present) and all extension substreams.
2945 * If the stream is a constant bit rate, this parameter shall have the same value as avgBitrate.
2946 * If the maximum bit rate is unknown, this parameter shall be set to 0. */
2947 uint32_t avgBitrate; /* the average bit rate, in bits per second, of the audio elementary stream for the duration of the track,
2948 * including the core substream and any extension substream that may be present. */
2949 uint8_t pcmSampleDepth; /* the bit depth of the rendered audio
2950 * The value is 16 or 24 bits. */
2951 uint8_t FrameDuration; /* the number of audio samples decoded in a complete audio access unit at DTSSamplingFrequency
2952 * 0: 512, 1: 1024, 2: 2048, 3: 4096 */
2953 uint8_t StreamConstruction; /* complete information on the existence and of location of extensions in any synchronized frame */
2954 uint8_t CoreLFEPresent; /* the presence of an LFE channel in the core
2955 * 0: none
2956 * 1: LFE exists */
2957 uint8_t CoreLayout; /* the channel layout of the core within the core substream
2958 * If no core substream exists, this parameter shall be ignored and ChannelLayout or
2959 * RepresentationType shall be used to determine channel configuration. */
2960 uint16_t CoreSize; /* The size of a core substream AU in bytes.
2961 * If no core substream exists, CoreSize = 0. */
2962 uint8_t StereoDownmix; /* the presence of an embedded stereo downmix in the stream
2963 * 0: none
2964 * 1: embedded downmix present */
2965 uint8_t RepresentationType; /* This indicates special properties of the audio presentation.
2966 * 0: Audio asset designated for mixing with another audio asset
2967 * 2: Lt/Rt Encoded for matrix surround decoding
2968 * 3: Audio processed for headphone playback
2969 * otherwise: Reserved
2970 * If ChannelLayout != 0, this value shall be ignored. */
2971 uint16_t ChannelLayout; /* complete information on channels coded in the audio stream including core and extensions */
2972 uint8_t MultiAssetFlag; /* This flag shall set if the stream contains more than one asset.
2973 * 0: single asset
2974 * 1: multiple asset
2975 * When multiple assets exist, the remaining parameters only reflect the coding parameters of the first asset. */
2976 uint8_t LBRDurationMod; /* This flag indicates a special case of the LBR coding bandwidth, resulting in 1/3 or 2/3 band limiting.
2977 * If set to 1, LBR frame duration is 50 % larger than indicated in FrameDuration */
2978 lsmash_dts_reserved_box_t *box;
2979 } lsmash_dts_specific_parameters_t;
2981 int lsmash_setup_dts_specific_parameters_from_frame
2983 lsmash_dts_specific_parameters_t *param,
2984 uint8_t *data,
2985 uint32_t data_length
2988 uint8_t lsmash_dts_get_stream_construction
2990 lsmash_dts_construction_flag flags
2993 lsmash_dts_construction_flag lsmash_dts_get_construction_flags
2995 uint8_t stream_construction
2998 lsmash_codec_type_t lsmash_dts_get_codingname
3000 lsmash_dts_specific_parameters_t *param
3003 uint8_t *lsmash_create_dts_specific_info
3005 lsmash_dts_specific_parameters_t *param,
3006 uint32_t *data_length
3009 int lsmash_append_dts_reserved_box
3011 lsmash_dts_specific_parameters_t *param,
3012 const uint8_t *box_data,
3013 uint32_t box_size
3016 void lsmash_remove_dts_reserved_box
3018 lsmash_dts_specific_parameters_t *param
3021 /* Apple Lossless Audio Specific Information
3022 * Mandatory :
3023 * ISOM_CODEC_TYPE_ALAC_AUDIO
3024 * QT_CODEC_TYPE_ALAC_AUDIO */
3025 typedef struct
3027 uint32_t frameLength; /* the frames per packet when no explicit frames per packet setting is present in the packet header
3028 * The encoder frames per packet can be explicitly set but for maximum compatibility,
3029 * the default encoder setting of 4096 should be used. */
3030 uint8_t bitDepth; /* the bit depth of the source PCM data (maximum value = 32) */
3031 uint8_t numChannels; /* the channel count (1 = mono, 2 = stereo, etc...)
3032 * When channel layout info is not provided in the Channel Layout extension,
3033 * a channel count > 2 describes a set of discreet channels with no specific ordering. */
3034 uint32_t maxFrameBytes; /* the maximum size of an Apple Lossless packet within the encoded stream
3035 * Value of 0 indicates unknown. */
3036 uint32_t avgBitrate; /* the average bit rate in bits per second of the Apple Lossless stream
3037 * Value of 0 indicates unknown. */
3038 uint32_t sampleRate; /* sample rate of the encoded stream */
3039 } lsmash_alac_specific_parameters_t;
3041 uint8_t *lsmash_create_alac_specific_info
3043 lsmash_alac_specific_parameters_t *param,
3044 uint32_t *data_length
3047 /* MPEG-4 Bitrate Information.
3048 * Optional :
3049 * ISOM_CODEC_TYPE_AVC1_VIDEO
3050 * ISOM_CODEC_TYPE_AVC2_VIDEO
3051 * ISOM_CODEC_TYPE_AVC3_VIDEO
3052 * ISOM_CODEC_TYPE_AVC4_VIDEO
3053 * ISOM_CODEC_TYPE_HVC1_VIDEO
3054 * ISOM_CODEC_TYPE_HEV1_VIDEO
3056 * Though you need not to set these fields manually since lsmash_finish_movie() calls the function
3057 * that calculates these values internally, these fields are optional.
3058 * Therefore, if you want to add this info, append this as an extension via LSMASH_CODEC_SPECIFIC_DATA_TYPE_ISOM_VIDEO_H264_BITRATE at least. */
3059 typedef struct
3061 uint32_t bufferSizeDB; /* the size of the decoding buffer for the elementary stream in bytes */
3062 uint32_t maxBitrate; /* the maximum rate in bits/second over any window of one second */
3063 uint32_t avgBitrate; /* the average rate in bits/second over the entire presentation */
3064 } lsmash_h264_bitrate_t;
3066 /* Appendability of NAL unit into Decoder Configuration Record */
3067 typedef enum
3069 DCR_NALU_APPEND_NEW_SAMPLE_ENTRY_REQUIRED = -3, /* A new sample description entry is needed because e.g. visual presentation size changes. */
3070 DCR_NALU_APPEND_NEW_DCR_REQUIRED = -2, /* A new Decoder Configuration Record is needed. */
3071 DCR_NALU_APPEND_ERROR = -1, /* something of errors */
3072 DCR_NALU_APPEND_DUPLICATED = 0, /* The same NAL unit is in the Decoder Configuration Record. */
3073 DCR_NALU_APPEND_POSSIBLE = 1, /* It is possible to append the NAL unit into the Decoder Configuration Record. */
3074 } lsmash_dcr_nalu_appendable;
3076 /* H.264/AVC Specific Information
3077 * Mandatory :
3078 * ISOM_CODEC_TYPE_AVC1_VIDEO
3079 * ISOM_CODEC_TYPE_AVC2_VIDEO
3080 * ISOM_CODEC_TYPE_AVC3_VIDEO
3081 * ISOM_CODEC_TYPE_AVC4_VIDEO
3083 * All members in lsmash_h264_specific_parameters_t except for lengthSizeMinusOne shall be automatically set up
3084 * when appending SPS NAL units by calling lsmash_append_h264_parameter_set(). */
3085 typedef enum
3087 H264_PARAMETER_SET_TYPE_SPS = 0, /* SPS (Sequence Parameter Set) */
3088 H264_PARAMETER_SET_TYPE_PPS = 1, /* PPS (Picture Parameter Set) */
3089 H264_PARAMETER_SET_TYPE_SPSEXT = 2, /* SPS Ext (Sequence Parameter Set Extension) */
3090 /* The number of the NAL unit types defined for AVC Decoder Configuration Record */
3091 H264_PARAMETER_SET_TYPE_NUM
3092 } lsmash_h264_parameter_set_type;
3094 typedef struct lsmash_h264_parameter_sets_tag lsmash_h264_parameter_sets_t;
3096 typedef struct
3098 uint8_t AVCProfileIndication; /* profile_idc in sequence parameter sets
3099 * This field must indicate a profile to which the stream associated with
3100 * this configuration record conforms.
3101 * Note: there is no profile to which the entire stream conforms, then
3102 * the entire stream must be split into two or more sub-streams with
3103 * separate configuration records in which these rules can be met. */
3104 uint8_t profile_compatibility; /* constraint_set_flags in sequence parameter sets
3105 * The each bit may only be set if all the included parameter sets set that flag. */
3106 uint8_t AVCLevelIndication; /* level_idc in sequence parameter sets
3107 * This field must indicate a level of capability equal to or greater than
3108 * the highest level indicated in the included parameter sets. */
3109 uint8_t lengthSizeMinusOne; /* the length in bytes of the NALUnitLength field prior to NAL unit
3110 * The value of this field shall be one of 0, 1, or 3
3111 * corresponding to a length encoded with 1, 2, or 4 bytes, respectively.
3112 * NALUnitLength indicates the size of a NAL unit measured in bytes,
3113 * and includes the size of both the one byte NAL header and the EBSP payload
3114 * but does not include the length field itself. */
3115 /* chroma format and bit depth information
3116 * These fields must be identical in all the parameter sets. */
3117 uint8_t chroma_format; /* chroma_format_idc in sequence parameter sets */
3118 uint8_t bit_depth_luma_minus8; /* bit_depth_luma_minus8 in sequence parameter sets */
3119 uint8_t bit_depth_chroma_minus8; /* bit_depth_chroma_minus8 in sequence parameter sets */
3120 /* a set of arrays to carry initialization NAL units
3121 * The NAL unit types are restricted to indicate SPS, PPS and SPS Ext NAL units only. */
3122 lsmash_h264_parameter_sets_t *parameter_sets;
3123 } lsmash_h264_specific_parameters_t;
3125 int lsmash_setup_h264_specific_parameters_from_access_unit
3127 lsmash_h264_specific_parameters_t *param,
3128 uint8_t *data,
3129 uint32_t data_length
3132 void lsmash_destroy_h264_parameter_sets
3134 lsmash_h264_specific_parameters_t *param
3137 lsmash_dcr_nalu_appendable lsmash_check_h264_parameter_set_appendable
3139 lsmash_h264_specific_parameters_t *param,
3140 lsmash_h264_parameter_set_type ps_type,
3141 void *ps_data,
3142 uint32_t ps_length
3145 int lsmash_append_h264_parameter_set
3147 lsmash_h264_specific_parameters_t *param,
3148 lsmash_h264_parameter_set_type ps_type,
3149 void *ps_data,
3150 uint32_t ps_length
3153 uint8_t *lsmash_create_h264_specific_info
3155 lsmash_h264_specific_parameters_t *param,
3156 uint32_t *data_length
3159 /* H.265/HEVC Specific Information
3160 * Mandatory :
3161 * ISOM_CODEC_TYPE_HVC1_VIDEO
3162 * ISOM_CODEC_TYPE_HEV1_VIDEO
3164 * All members in lsmash_hevc_specific_parameters_t except for avgFrameRate and lengthSizeMinusOne shall be
3165 * automatically set up when appending VPS and SPS NAL units by calling lsmash_append_hevc_dcr_nalu().
3166 * It is recommended that you should append VPS, SPS and PPS in this order so that a parameter set can reference
3167 * another parameter set. */
3168 typedef enum
3170 /* Parameter sets
3171 * When the CODEC identifier ISOM_CODEC_TYPE_HVC1_VIDEO is used, at least one parameter set for each array
3172 * of parameter set shall be in the configuration record. */
3173 HEVC_DCR_NALU_TYPE_VPS = 0, /* VPS (Video Parameter Set) */
3174 HEVC_DCR_NALU_TYPE_SPS = 1, /* SPS (Sequence Parameter Set) */
3175 HEVC_DCR_NALU_TYPE_PPS = 2, /* PPS (Picture Parameter Set) */
3176 /* SEI (Supplemental Enhancement Information)
3177 * Only the 'declarative' SEI messages that provide information about the stream as
3178 * a whole are allowed because SEIs themselves basically have no identifier and
3179 * no one can reference dynamically in a configuration record. */
3180 HEVC_DCR_NALU_TYPE_PREFIX_SEI = 3, /* Prefix SEI */
3181 HEVC_DCR_NALU_TYPE_SUFFIX_SEI = 4, /* Suffix SEI */
3182 /* The number of the NAL unit types defined for HEVC Decoder Configuration Record */
3183 HEVC_DCR_NALU_TYPE_NUM
3184 } lsmash_hevc_dcr_nalu_type;
3186 typedef struct lsmash_hevc_parameter_arrays_tag lsmash_hevc_parameter_arrays_t;
3188 typedef struct
3190 /* general profile, tier and level from VPS and/or SPS */
3191 uint8_t general_profile_space; /* general_profile_space
3192 * The value in all the parameter sets must be identical. */
3193 uint8_t general_tier_flag; /* general_tier_flag
3194 * The value must indicate a tier equal to or greater than the highest
3195 * tier indicated in all the parameter sets. */
3196 uint8_t general_profile_idc; /* general_profile_idc
3197 * The value must indicate a profile to which the stream associated with
3198 * this configuration record conforms.
3199 * Note: there is no profile to which the entire stream conforms, then
3200 * the entire stream must be split into two or more sub-streams with
3201 * separate configuration records in which these rules can be met. */
3202 uint32_t general_profile_compatibility_flags; /* general_profile_compatibility_flag[j] for j from 0 to 31
3203 * The each bit may only be set if all the parameter sets set that bit. */
3204 uint64_t general_constraint_indicator_flags; /* the 6 bytes starting with the byte containing the general_progressive_source_flag
3205 * The each bit may only be set if all the parameter sets set that bit. */
3206 uint8_t general_level_idc; /* general_level_idc
3207 * The value must indicate a level of capability equal to or greater
3208 * than the highest level indicated for the highest tier in all the
3209 * parameter sets. */
3210 /* */
3211 uint16_t min_spatial_segmentation_idc; /* min_spatial_segmentation_idc in VUI (Video Usability Information)
3212 * The value must indicate a level of spatial segmentation equal to
3213 * or less than the lowest level of spatial segmentation indicated in
3214 * all the parameter sets. */
3215 uint8_t parallelismType; /* parallelismType indicates the type of parallelism that is used to meet the
3216 * restrictions imposed by min_spatial_segmentation_idc when the value of
3217 * min_spatial_segmentation_idc is greater than 0.
3218 * For the stream to which this configuration record applies,
3219 * 0: mixed types of parallel decoding or parallelism type is unknown
3220 * 1: slice based parallel decoding
3221 * 2: tile based parallel decoding
3222 * 3: entropy coding synchronization based parallel decoding
3223 * (WPP: Wavefront Parallel Processing) */
3224 /* chroma format and bit depth information
3225 * These fields must be identical in all the parameter sets. */
3226 uint8_t chromaFormat; /* chroma_format_idc in sequence parameter sets */
3227 uint8_t bitDepthLumaMinus8; /* bit_depth_luma_minus8 in sequence parameter sets */
3228 uint8_t bitDepthChromaMinus8; /* bit_depth_chroma_minus8 in sequence parameter sets */
3229 /* miscellaneous */
3230 uint16_t avgFrameRate; /* the average frame rate in units of frames/(256 seconds)
3231 * Value 0 indicates an unspecified average frame rate. */
3232 uint8_t constantFrameRate; /* 0: the stream may or may not be of constant frame rate.
3233 * 1: that the stream to which this configuration record applies is of
3234 * constant frame rate
3235 * 2: the representation of each temporal layer in the stream is of
3236 * constant frame rate. */
3237 uint8_t numTemporalLayers; /* 0: it is unknown whether the stream is temporally scalable.
3238 * 1: the stream is not temporally scalable.
3239 * otherwise: the stream to which this configuration record applies is
3240 * temporally scalable and the contained number of temporal layers
3241 * (also referred to as temporal sublayer or sub-layer) is equal
3242 * is equal to numTemporalLayers. */
3243 uint8_t temporalIdNested; /* 0: at least one of the SPSs that are activated when the stream to which
3244 * this configuration record applies is decoded has sps_temporal_id_nesting_flag
3245 * equal to 0.
3246 * 1: all SPSs that are activated when the stream to which this configuration
3247 * record applies is decoded have sps_temporal_id_nesting_flag equal to 1
3248 * and temporal sub-layer up-switching to any higher temporal layer can be
3249 * performed at any sample.
3250 * Any step-wise temporal sub-layer access picture shall not be present in
3251 * the sequences to which this configuration record applies. */
3252 uint8_t lengthSizeMinusOne; /* the length in bytes of the NALUnitLength field prior to NAL unit
3253 * The value of this field shall be one of 0, 1, or 3
3254 * corresponding to a length encoded with 1, 2, or 4 bytes, respectively.
3255 * NALUnitLength indicates the size of a NAL unit measured in bytes,
3256 * and includes the size of both the one byte NAL header and the EBSP payload
3257 * but does not include the length field itself. */
3258 /* a set of arrays to carry initialization NAL units
3259 * The NAL unit types are restricted to indicate VPS, SPS, PPS, and SEI NAL units only. */
3260 lsmash_hevc_parameter_arrays_t *parameter_arrays;
3261 } lsmash_hevc_specific_parameters_t;
3263 int lsmash_setup_hevc_specific_parameters_from_access_unit
3265 lsmash_hevc_specific_parameters_t *param,
3266 uint8_t *data,
3267 uint32_t data_length
3270 void lsmash_destroy_hevc_parameter_arrays
3272 lsmash_hevc_specific_parameters_t *param
3275 lsmash_dcr_nalu_appendable lsmash_check_hevc_dcr_nalu_appendable
3277 lsmash_hevc_specific_parameters_t *param,
3278 lsmash_hevc_dcr_nalu_type ps_type,
3279 void *ps_data,
3280 uint32_t ps_length
3283 int lsmash_append_hevc_dcr_nalu
3285 lsmash_hevc_specific_parameters_t *param,
3286 lsmash_hevc_dcr_nalu_type ps_type,
3287 void *ps_data,
3288 uint32_t ps_length
3291 int lsmash_set_hevc_array_completeness
3293 lsmash_hevc_specific_parameters_t *param,
3294 lsmash_hevc_dcr_nalu_type ps_type,
3295 int array_completeness
3298 int lsmash_get_hevc_array_completeness
3300 lsmash_hevc_specific_parameters_t *param,
3301 lsmash_hevc_dcr_nalu_type ps_type,
3302 int *array_completeness
3305 uint8_t *lsmash_create_hevc_specific_info
3307 lsmash_hevc_specific_parameters_t *param,
3308 uint32_t *data_length
3311 /* VC-1 Specific Information
3312 * Mandatory :
3313 * ISOM_CODEC_TYPE_VC_1_VIDEO
3315 * We support only advanced profile at present. */
3316 typedef struct lsmash_vc1_header_tag lsmash_vc1_header_t;
3318 typedef struct
3320 /* Note: multiple_sequence, multiple_entry, slice_present and bframe_present shall be decided through overall VC-1 bitstream. */
3321 uint8_t profile; /* the encoding profile used in the VC-1 bitstream
3322 * 0: simple profile (not supported)
3323 * 4: main profile (not supported)
3324 * 12: advanced profile
3325 * Currently, only 12 for advanced profile is available. */
3326 uint8_t level; /* the highest encoding level used in the VC-1 bitstream */
3327 uint8_t cbr; /* 0: non-constant bitrate model
3328 * 1: constant bitrate model */
3329 uint8_t interlaced; /* 0: interlaced coding of frames is not used.
3330 * 1: frames may use interlaced coding. */
3331 uint8_t multiple_sequence; /* 0: the track contains no sequence headers (stored only in VC-1 specific info structure),
3332 * or
3333 * all sequence headers in the track are identical to the sequence header that is specified in the seqhdr field.
3334 * In this case, random access points are samples that contain an entry-point header.
3335 * 1: the track may contain Sequence headers that are different from the sequence header specified in the seqhdr field.
3336 * In this case, random access points are samples that contain both a sequence Header and an entry-point header. */
3337 uint8_t multiple_entry; /* 0: all entry-point headers in the track are identical to the entry-point header that is specified in the ephdr field.
3338 * 1: the track may contain entry-point headers that are different from the entry-point header specified in the ephdr field. */
3339 uint8_t slice_present; /* 0: frames are not coded as multiple slices.
3340 * 1: frames may be coded as multiple slices. */
3341 uint8_t bframe_present; /* 0: neither B-frames nor BI-frames are present in the track.
3342 * 1: B-frames or BI-frames may be present in the track. */
3343 uint32_t framerate; /* the rounded frame rate (frames per second) of the track
3344 * Should be set to 0xffffffff if the frame rate is not known, unspecified, or non-constant. */
3345 lsmash_vc1_header_t *seqhdr; /* a sequence header EBDU (mandatory) */
3346 lsmash_vc1_header_t *ephdr; /* an entry-point header EBDU (mandatory) */
3347 } lsmash_vc1_specific_parameters_t;
3349 int lsmash_setup_vc1_specific_parameters_from_access_unit
3351 lsmash_vc1_specific_parameters_t *param,
3352 uint8_t *data,
3353 uint32_t data_length
3356 void lsmash_destroy_vc1_headers
3358 lsmash_vc1_specific_parameters_t *param
3361 int lsmash_put_vc1_header
3363 lsmash_vc1_specific_parameters_t *param,
3364 void *hdr_data,
3365 uint32_t hdr_length
3368 uint8_t *lsmash_create_vc1_specific_info
3370 lsmash_vc1_specific_parameters_t *param,
3371 uint32_t *data_length
3374 /* Sample scaling
3375 * Without this extension, video samples are scaled into the visual presentation region to fill it. */
3376 typedef enum
3378 ISOM_SCALE_METHOD_FILL = 1,
3379 ISOM_SCALE_METHOD_HIDDEN = 2,
3380 ISOM_SCALE_METHOD_MEET = 3,
3381 ISOM_SCALE_METHOD_SLICE_X = 4,
3382 ISOM_SCALE_METHOD_SLICE_Y = 5,
3383 } lsmash_scale_method;
3385 typedef struct
3387 uint8_t constraint_flag; /* Upper 7-bits are reserved.
3388 * If this flag is set, all samples described by this sample entry shall be scaled
3389 * according to the method specified by the field 'scale_method'. */
3390 lsmash_scale_method scale_method; /* The semantics of the values for scale_method are as specified for the 'fit' attribute of regions in SMIL 1.0. */
3391 int16_t display_center_x;
3392 int16_t display_center_y;
3393 } lsmash_isom_sample_scale_t;
3395 /* QuickTime Video CODEC tools */
3396 typedef enum
3398 QT_COMPRESSION_QUALITY_LOSSLESS = 0x00000400, /* only valid for spatial compression */
3399 QT_COMPRESSION_QUALITY_MAX = 0x000003FF,
3400 QT_COMPRESSION_QUALITY_MIN = 0x00000000,
3401 QT_COMPRESSION_QUALITY_LOW = 0x00000100,
3402 QT_COMPRESSION_QUALITY_NORMAL = 0x00000200,
3403 QT_COMPRESSION_QUALITY_HIGH = 0x00000300
3404 } lsmash_qt_compression_quality;
3406 typedef struct
3408 uint32_t seed; /* Must be set to 0. */
3409 uint16_t flags; /* Must be set to 0x8000. */
3410 uint16_t size; /* the number of colors in the following color array
3411 * This is a zero-relative value;
3412 * setting this field to 0 means that there is one color in the array. */
3413 /* Color array
3414 * An array of colors. Each color is made of four unsigned 16-bit integers.
3415 * We support up to 256 elements. */
3416 struct
3418 uint16_t unused; /* Must be set to 0. */
3419 /* true color */
3420 uint16_t r; /* magnitude of red component */
3421 uint16_t g; /* magnitude of green component */
3422 uint16_t b; /* magnitude of blue component */
3423 } array[256];
3424 } lsmash_qt_color_table_t;
3426 typedef struct
3428 int16_t revision_level; /* version of the CODEC */
3429 int32_t vendor; /* whose CODEC */
3430 lsmash_qt_compression_quality temporalQuality; /* the temporal quality factor (0-1023) */
3431 lsmash_qt_compression_quality spatialQuality; /* the spatial quality factor (0-1024) */
3432 uint32_t horizontal_resolution; /* a 16.16 fixed-point number containing the horizontal resolution of the image in pixels per inch. */
3433 uint32_t vertical_resolution; /* a 16.16 fixed-point number containing the vertical resolution of the image in pixels per inch. */
3434 uint32_t dataSize; /* if known, the size of data for this descriptor */
3435 uint16_t frame_count; /* frame per sample */
3436 int16_t color_table_ID; /* color table ID
3437 * If this field is set to -1, the default color table should be used for the specified depth
3438 * If the color table ID is set to 0, a color table is contained within the sample description itself.
3439 * The color table immediately follows the color table ID field. */
3440 lsmash_qt_color_table_t color_table; /* a list of preferred colors for displaying the movie on devices that support only 256 colors */
3441 } lsmash_qt_video_common_t;
3443 typedef struct
3445 uint32_t level; /* A fixed-point 16.16 number indicating the gamma level at which the image was captured. */
3446 } lsmash_qt_gamma_t;
3448 /* Content Light Level Info */
3449 typedef struct
3451 uint16_t max_content_light_level;
3452 uint16_t max_pic_average_light_level;
3453 } lsmash_qt_content_light_level_info_t;
3455 /* Mastering Display Color Volume */
3456 typedef struct
3458 uint16_t display_primaries_g_x;
3459 uint16_t display_primaries_g_y;
3460 uint16_t display_primaries_b_x;
3461 uint16_t display_primaries_b_y;
3462 uint16_t display_primaries_r_x;
3463 uint16_t display_primaries_r_y;
3464 uint16_t white_point_x;
3465 uint16_t white_point_y;
3466 uint32_t max_display_mastering_luminance;
3467 uint32_t min_display_mastering_luminance;
3468 } lsmash_qt_mastering_display_color_volume_t;
3470 typedef enum
3472 QT_FIELEDS_SCAN_PROGRESSIVE = 1, /* progressive scan */
3473 QT_FIELEDS_SCAN_INTERLACED = 2, /* 2:1 interlaced */
3474 } lsmash_qt_number_of_fields;
3476 /* field ordering for interlaced material */
3477 typedef enum
3479 QT_FIELD_ORDERINGS_UNKNOWN = 0,
3480 QT_FIELD_ORDERINGS_TEMPORAL_TOP_FIRST = 1,
3481 QT_FIELD_ORDERINGS_TEMPORAL_BOTTOM_FIRST = 6,
3482 QT_FIELD_ORDERINGS_SPATIAL_FIRST_LINE_EARLY = 9,
3483 QT_FIELD_ORDERINGS_SPATIAL_FIRST_LINE_LATE = 14
3484 } lsmash_qt_field_orderings;
3486 typedef struct
3488 lsmash_qt_number_of_fields fields;
3489 lsmash_qt_field_orderings detail;
3490 } lsmash_qt_field_info_t;
3492 /* the native pixel format */
3493 typedef enum
3495 QT_PIXEL_FORMAT_TYPE_1_MONOCHROME = 0x00000001, /* 1 bit indexed */
3496 QT_PIXEL_FORMAT_TYPE_2_INDEXED = 0x00000002, /* 2 bit indexed */
3497 QT_PIXEL_FORMAT_TYPE_4_INDEXED = 0x00000004, /* 4 bit indexed */
3498 QT_PIXEL_FORMAT_TYPE_8_INDEXED = 0x00000008, /* 8 bit indexed */
3499 QT_PIXEL_FORMAT_TYPE_1_INDEXED_GRAY_WHITE_IS_ZERO = 0x00000021, /* 1 bit indexed gray, white is zero */
3500 QT_PIXEL_FORMAT_TYPE_2_INDEXED_GRAY_WHITE_IS_ZERO = 0x00000022, /* 2 bit indexed gray, white is zero */
3501 QT_PIXEL_FORMAT_TYPE_4_INDEXED_GRAY_WHITE_IS_ZERO = 0x00000024, /* 4 bit indexed gray, white is zero */
3502 QT_PIXEL_FORMAT_TYPE_8_INDEXED_GRAY_WHITE_IS_ZERO = 0x00000028, /* 8 bit indexed gray, white is zero */
3503 QT_PIXEL_FORMAT_TYPE_16BE555 = 0x00000010, /* 16 bit BE RGB 555 */
3504 QT_PIXEL_FORMAT_TYPE_16LE555 = LSMASH_4CC( 'L', '5', '5', '5' ), /* 16 bit LE RGB 555 */
3505 QT_PIXEL_FORMAT_TYPE_16LE5551 = LSMASH_4CC( '5', '5', '5', '1' ), /* 16 bit LE RGB 5551 */
3506 QT_PIXEL_FORMAT_TYPE_16BE565 = LSMASH_4CC( 'B', '5', '6', '5' ), /* 16 bit BE RGB 565 */
3507 QT_PIXEL_FORMAT_TYPE_16LE565 = LSMASH_4CC( 'L', '5', '6', '5' ), /* 16 bit LE RGB 565 */
3508 QT_PIXEL_FORMAT_TYPE_24RGB = 0x00000018, /* 24 bit RGB */
3509 QT_PIXEL_FORMAT_TYPE_24BGR = LSMASH_4CC( '2', '4', 'B', 'G' ), /* 24 bit BGR */
3510 QT_PIXEL_FORMAT_TYPE_32ARGB = 0x00000020, /* 32 bit ARGB */
3511 QT_PIXEL_FORMAT_TYPE_32BGRA = LSMASH_4CC( 'B', 'G', 'R', 'A' ), /* 32 bit BGRA */
3512 QT_PIXEL_FORMAT_TYPE_32ABGR = LSMASH_4CC( 'A', 'B', 'G', 'R' ), /* 32 bit ABGR */
3513 QT_PIXEL_FORMAT_TYPE_32RGBA = LSMASH_4CC( 'R', 'G', 'B', 'A' ), /* 32 bit RGBA */
3514 QT_PIXEL_FORMAT_TYPE_64ARGB = LSMASH_4CC( 'b', '6', '4', 'a' ), /* 64 bit ARGB, 16-bit big-endian samples */
3515 QT_PIXEL_FORMAT_TYPE_48RGB = LSMASH_4CC( 'b', '4', '8', 'r' ), /* 48 bit RGB, 16-bit big-endian samples */
3516 QT_PIXEL_FORMAT_TYPE_32_ALPHA_GRAY = LSMASH_4CC( 'b', '3', '2', 'a' ), /* 32 bit AlphaGray, 16-bit big-endian samples, black is zero */
3517 QT_PIXEL_FORMAT_TYPE_16_GRAY = LSMASH_4CC( 'b', '1', '6', 'g' ), /* 16 bit Grayscale, 16-bit big-endian samples, black is zero */
3518 QT_PIXEL_FORMAT_TYPE_30RGB = LSMASH_4CC( 'R', '1', '0', 'k' ), /* 30 bit RGB, 10-bit big-endian samples, 2 unused padding bits (at least significant end) */
3519 QT_PIXEL_FORMAT_TYPE_422YpCbCr8 = LSMASH_4CC( '2', 'v', 'u', 'y' ), /* Component Y'CbCr 8-bit 4:2:2, ordered Cb Y'0 Cr Y'1 */
3520 QT_PIXEL_FORMAT_TYPE_4444YpCbCrA8 = LSMASH_4CC( 'v', '4', '0', '8' ), /* Component Y'CbCrA 8-bit 4:4:4:4, ordered Cb Y' Cr A */
3521 QT_PIXEL_FORMAT_TYPE_4444YpCbCrA8R = LSMASH_4CC( 'r', '4', '0', '8' ), /* Component Y'CbCrA 8-bit 4:4:4:4, rendering format. full range alpha, zero biased YUV, ordered A Y' Cb Cr */
3522 QT_PIXEL_FORMAT_TYPE_4444AYpCbCr8 = LSMASH_4CC( 'y', '4', '0', '8' ), /* Component Y'CbCrA 8-bit 4:4:4:4, ordered A Y' Cb Cr, full range alpha, video range Y'CbCr */
3523 QT_PIXEL_FORMAT_TYPE_4444AYpCbCr16 = LSMASH_4CC( 'y', '4', '1', '6' ), /* Component Y'CbCrA 16-bit 4:4:4:4, ordered A Y' Cb Cr, full range alpha, video range Y'CbCr, 16-bit little-endian samples */
3524 QT_PIXEL_FORMAT_TYPE_444YpCbCr8 = LSMASH_4CC( 'v', '3', '0', '8' ), /* Component Y'CbCr 8-bit 4:4:4 */
3525 QT_PIXEL_FORMAT_TYPE_422YpCbCr16 = LSMASH_4CC( 'v', '2', '1', '6' ), /* Component Y'CbCr 10,12,14,16-bit 4:2:2 */
3526 QT_PIXEL_FORMAT_TYPE_422YpCbCr10 = LSMASH_4CC( 'v', '2', '1', '0' ), /* Component Y'CbCr 10-bit 4:2:2 */
3527 QT_PIXEL_FORMAT_TYPE_444YpCbCr10 = LSMASH_4CC( 'v', '4', '1', '0' ), /* Component Y'CbCr 10-bit 4:4:4 */
3528 QT_PIXEL_FORMAT_TYPE_420YpCbCr8_PLANAR = LSMASH_4CC( 'y', '4', '2', '0' ), /* Planar Component Y'CbCr 8-bit 4:2:0 */
3529 QT_PIXEL_FORMAT_TYPE_420YpCbCr8_PLANAR_FULL_RANGE = LSMASH_4CC( 'f', '4', '2', '0' ), /* Planar Component Y'CbCr 8-bit 4:2:0, full range */
3530 QT_PIXEL_FORMAT_TYPE_422YpCbCr_4A_8_BIPLANAR = LSMASH_4CC( 'a', '2', 'v', 'y' ), /* First plane: Video-range Component Y'CbCr 8-bit 4:2:2, ordered Cb Y'0 Cr Y'1; second plane: alpha 8-bit 0-255 */
3531 QT_PIXEL_FORMAT_TYPE_420YpCbCr8_BIPLANAR_VIDEO_RANGE = LSMASH_4CC( '4', '2', '0', 'v' ), /* Bi-Planar Component Y'CbCr 8-bit 4:2:0, video-range (luma=[16,235] chroma=[16,240]) */
3532 QT_PIXEL_FORMAT_TYPE_420YpCbCr8_BIPLANAR_FULL_RANGE = LSMASH_4CC( '4', '2', '0', 'f' ), /* Bi-Planar Component Y'CbCr 8-bit 4:2:0, full-range (luma=[0,255] chroma=[1,255]) */
3533 QT_PIXEL_FORMAT_TYPE_422YpCbCr8_YUVS = LSMASH_4CC( 'y', 'u', 'v', 's' ), /* Component Y'CbCr 8-bit 4:2:2, ordered Y'0 Cb Y'1 Cr */
3534 QT_PIXEL_FORMAT_TYPE_422YpCbCr8_FULL_RANGE = LSMASH_4CC( 'y', 'u', 'v', 'f' ), /* Component Y'CbCr 8-bit 4:2:2, full range, ordered Y'0 Cb Y'1 Cr */
3536 /* Developer specific FourCCs (from dispatch 20) */
3537 QT_PIXEL_FORMAT_TYPE_SOFTVOUT_SOFTCODEC = LSMASH_4CC( 's', 'o', 'f', 't' ), /* Intermediary pixel format used by SoftVout and SoftCodec */
3538 QT_PIXEL_FORMAT_TYPE_VIEW_GRAPHICS = LSMASH_4CC( 'v', 'w', 'g', 'r' ), /* Intermediary pixel format used by View Graphics */
3539 QT_PIXEL_FORMAT_TYPE_SGI = LSMASH_4CC( 'S', 'G', 'V', 'C' ), /* Intermediary pixel format used by SGI */
3540 } lsmash_qt_pixel_format;
3542 typedef struct
3544 lsmash_qt_pixel_format pixel_format; /* the native pixel format of an image */
3545 } lsmash_qt_pixel_format_t;
3547 /* Significant Bits Extension
3548 * mandatory extension for 'v216' (Uncompressed Y'CbCr, 10, 12, 14, or 16-bit-per-component 4:2:2) */
3549 typedef struct
3551 uint8_t significantBits; /* the number of significant bits per component */
3552 } lsmash_qt_significant_bits_t;
3554 /* QuickTime Audio CODEC tools */
3555 typedef enum
3557 QT_AUDIO_COMPRESSION_ID_NOT_COMPRESSED = 0,
3558 QT_AUDIO_COMPRESSION_ID_FIXED_COMPRESSION = -1,
3559 QT_AUDIO_COMPRESSION_ID_VARIABLE_COMPRESSION = -2,
3560 QT_AUDIO_COMPRESSION_ID_TWO_TO_ONE = 1,
3561 QT_AUDIO_COMPRESSION_ID_EIGHT_TO_THREE = 2,
3562 QT_AUDIO_COMPRESSION_ID_THREE_TO_ONE = 3,
3563 QT_AUDIO_COMPRESSION_ID_SIX_TO_ONE = 4,
3564 QT_AUDIO_COMPRESSION_ID_SIX_TO_ONE_PACKET_SIZE = 8,
3565 QT_AUDIO_COMPRESSION_ID_THREE_TO_ONE_PACKET_SIZE = 16,
3566 } lsmash_qt_audio_compression_id;
3568 typedef struct
3570 int16_t revision_level; /* version of the CODEC */
3571 int32_t vendor; /* whose CODEC */
3572 lsmash_qt_audio_compression_id compression_ID;
3573 } lsmash_qt_audio_common_t;
3575 /* Audio Channel Layout
3576 * This CODEC specific extension is for
3577 * QuickTime Audio inside QuickTime file format
3578 * and
3579 * Apple Lossless Audio inside ISO Base Media file format.
3580 * When audio stream has 3 or more number of channels, this extension shall be present. */
3581 typedef enum
3583 QT_CHANNEL_LABEL_UNKNOWN = (signed)0xffffffff, /* unknown or unspecified other use */
3584 QT_CHANNEL_LABEL_UNUSED = 0, /* channel is present, but has no intended use or destination */
3585 QT_CHANNEL_LABEL_USE_COORDINATES = 100, /* channel is described by the coordinates fields. */
3587 QT_CHANNEL_LABEL_LEFT = 1,
3588 QT_CHANNEL_LABEL_RIGHT = 2,
3589 QT_CHANNEL_LABEL_CENTER = 3,
3590 QT_CHANNEL_LABEL_LFE_SCREEN = 4,
3591 QT_CHANNEL_LABEL_LEFT_SURROUND = 5, /* WAVE: "Back Left" */
3592 QT_CHANNEL_LABEL_RIGHT_SUROUND = 6, /* WAVE: "Back Right" */
3593 QT_CHANNEL_LABEL_LEFT_CENTER = 7,
3594 QT_CHANNEL_LABEL_RIGHT_CENTER = 8,
3595 QT_CHANNEL_LABEL_CENTER_SURROUND = 9, /* WAVE: "Back Center" or plain "Rear Surround" */
3596 QT_CHANNEL_LABEL_LEFT_SURROUND_DIRECT = 10, /* WAVE: "Side Left" */
3597 QT_CHANNEL_LABEL_RIGHT_SURROUND_DIRECT = 11, /* WAVE: "Side Right" */
3598 QT_CHANNEL_LABEL_TOP_CENTER_SURROUND = 12,
3599 QT_CHANNEL_LABEL_VERTICAL_HEIGHT_LEFT = 13, /* WAVE: "Top Front Left" */
3600 QT_CHANNEL_LABEL_VERTICAL_HEIGHT_CENTER = 14, /* WAVE: "Top Front Center" */
3601 QT_CHANNEL_LABEL_VERTICAL_HEIGHT_RIGHT = 15, /* WAVE: "Top Front Right" */
3603 QT_CHANNEL_LABEL_TOP_BACK_LEFT = 16,
3604 QT_CHANNEL_LABEL_TOP_BACK_CENTER = 17,
3605 QT_CHANNEL_LABEL_TOP_BACK_RIGHT = 18,
3607 QT_CHANNEL_LABEL_REAR_SURROUND_LEFT = 33,
3608 QT_CHANNEL_LABEL_REAR_SURROUND_RIGHT = 34,
3609 QT_CHANNEL_LABEL_LEFT_WIDE = 35,
3610 QT_CHANNEL_LABEL_RIGHT_WIDE = 36,
3611 QT_CHANNEL_LABEL_LFE2 = 37,
3612 QT_CHANNEL_LABEL_LEFT_TOTAL = 38, /* matrix encoded 4 channels */
3613 QT_CHANNEL_LABEL_RIGHT_TOTAL = 39, /* matrix encoded 4 channels */
3614 QT_CHANNEL_LABEL_HEARING_IMPAIRED = 40,
3615 QT_CHANNEL_LABEL_NARRATION = 41,
3616 QT_CHANNEL_LABEL_MONO = 42,
3617 QT_CHANNEL_LABEL_DIALOG_CENTRIC_MIX = 43,
3619 QT_CHANNEL_LABEL_CENTER_SURROUND_DIRECT = 44, /* back center, non diffuse */
3621 QT_CHANNEL_LABEL_HAPTIC = 45,
3623 /* first order ambisonic channels */
3624 QT_CHANNEL_LABEL_AMBISONIC_W = 200,
3625 QT_CHANNEL_LABEL_AMBISONIC_X = 201,
3626 QT_CHANNEL_LABEL_AMBISONIC_Y = 202,
3627 QT_CHANNEL_LABEL_AMBISONIC_Z = 203,
3629 /* Mid/Side Recording */
3630 QT_CHANNEL_LABEL_MS_MID = 204,
3631 QT_CHANNEL_LABEL_MS_SIDE = 205,
3633 /* X-Y Recording */
3634 QT_CHANNEL_LABEL_XY_X = 206,
3635 QT_CHANNEL_LABEL_XY_Y = 207,
3637 /* other */
3638 QT_CHANNEL_LABEL_HEADPHONES_LEFT = 301,
3639 QT_CHANNEL_LABEL_HEADPHONES_RIGHT = 302,
3640 QT_CHANNEL_LABEL_CLICK_TRACK = 304,
3641 QT_CHANNEL_LABEL_FOREIGN_LANGUAGE = 305,
3643 /* generic discrete channel */
3644 QT_CHANNEL_LABEL_DISCRETE = 400,
3646 /* numbered discrete channel */
3647 QT_CHANNEL_LABEL_DISCRETE_0 = (1<<16),
3648 QT_CHANNEL_LABEL_DISCRETE_1 = (1<<16) | 1,
3649 QT_CHANNEL_LABEL_DISCRETE_2 = (1<<16) | 2,
3650 QT_CHANNEL_LABEL_DISCRETE_3 = (1<<16) | 3,
3651 QT_CHANNEL_LABEL_DISCRETE_4 = (1<<16) | 4,
3652 QT_CHANNEL_LABEL_DISCRETE_5 = (1<<16) | 5,
3653 QT_CHANNEL_LABEL_DISCRETE_6 = (1<<16) | 6,
3654 QT_CHANNEL_LABEL_DISCRETE_7 = (1<<16) | 7,
3655 QT_CHANNEL_LABEL_DISCRETE_8 = (1<<16) | 8,
3656 QT_CHANNEL_LABEL_DISCRETE_9 = (1<<16) | 9,
3657 QT_CHANNEL_LABEL_DISCRETE_10 = (1<<16) | 10,
3658 QT_CHANNEL_LABEL_DISCRETE_11 = (1<<16) | 11,
3659 QT_CHANNEL_LABEL_DISCRETE_12 = (1<<16) | 12,
3660 QT_CHANNEL_LABEL_DISCRETE_13 = (1<<16) | 13,
3661 QT_CHANNEL_LABEL_DISCRETE_14 = (1<<16) | 14,
3662 QT_CHANNEL_LABEL_DISCRETE_15 = (1<<16) | 15,
3663 QT_CHANNEL_LABEL_DISCRETE_65535 = (1<<16) | 65535,
3664 } lsmash_channel_label;
3666 typedef enum
3668 QT_CHANNEL_BIT_LEFT = 1,
3669 QT_CHANNEL_BIT_RIGHT = 1<<1,
3670 QT_CHANNEL_BIT_CENTER = 1<<2,
3671 QT_CHANNEL_BIT_LFE_SCREEN = 1<<3,
3672 QT_CHANNEL_BIT_LEFT_SURROUND = 1<<4, /* WAVE: "Back Left" */
3673 QT_CHANNEL_BIT_RIGHT_SURROUND = 1<<5, /* WAVE: "Back Right" */
3674 QT_CHANNEL_BIT_LEFT_CENTER = 1<<6,
3675 QT_CHANNEL_BIT_RIGHT_CENTER = 1<<7,
3676 QT_CHANNEL_BIT_CENTER_SURROUND = 1<<8, /* WAVE: "Back Center" */
3677 QT_CHANNEL_BIT_LEFT_SURROUND_DIRECT = 1<<9, /* WAVE: "Side Left" */
3678 QT_CHANNEL_BIT_RIGHT_SURROUND_DIRECT = 1<<10, /* WAVE: "Side Right" */
3679 QT_CHANNEL_BIT_TOP_CENTER_SURROUND = 1<<11,
3680 QT_CHANNEL_BIT_VERTICAL_HEIGHT_LEFT = 1<<12, /* WAVE: "Top Front Left" */
3681 QT_CHANNEL_BIT_VERTICAL_HEIGHT_CENTER = 1<<13, /* WAVE: "Top Front Center" */
3682 QT_CHANNEL_BIT_VERTICAL_HEIGHT_RIGHT = 1<<14, /* WAVE: "Top Front Right" */
3683 QT_CHANNEL_BIT_TOP_BACK_LEFT = 1<<15,
3684 QT_CHANNEL_BIT_TOP_BACK_CENTER = 1<<16,
3685 QT_CHANNEL_BIT_TOP_BACK_RIGHT = 1<<17,
3686 QT_CHANNEL_BIT_FULL = 0x3ffff,
3687 } lsmash_channel_bitmap;
3689 typedef enum
3691 QT_CHANNEL_FLAGS_ALL_OFF = 0,
3692 QT_CHANNEL_FLAGS_RECTANGULAR_COORDINATES = 1,
3693 QT_CHANNEL_FLAGS_SPHERICAL_COORDINATES = 1<<1,
3694 QT_CHANNEL_FLAGS_METERS = 1<<2,
3695 } lsmash_channel_flags;
3697 typedef enum
3699 /* indices for accessing the coordinates array in Channel Descriptions */
3700 /* for rectangulare coordinates */
3701 QT_CHANNEL_COORDINATES_LEFT_RIGHT = 0, /* Negative is left and positive is right. */
3702 QT_CHANNEL_COORDINATES_BACK_FRONT = 1, /* Negative is back and positive is front. */
3703 QT_CHANNEL_COORDINATES_DOWN_UP = 2, /* Negative is below ground level, 0 is ground level, and positive is above ground level. */
3704 /* for spherical coordinates */
3705 QT_CHANNEL_COORDINATES_AZIMUTH = 0, /* 0 is front center, positive is right, negative is left. This is measured in degrees. */
3706 QT_CHANNEL_COORDINATES_ELEVATION = 1, /* +90 is zenith, 0 is horizontal, -90 is nadir. This is measured in degrees. */
3707 QT_CHANNEL_COORDINATES_DISTANCE = 2, /* The units are described by flags. */
3708 } lsmash_channel_coordinates_index;
3710 typedef enum
3712 /* channel abbreviations:
3713 * L - left
3714 * R - right
3715 * C - center
3716 * Ls - left surround
3717 * Rs - right surround
3718 * Cs - center surround
3719 * Rls - rear left surround
3720 * Rrs - rear right surround
3721 * Lw - left wide
3722 * Rw - right wide
3723 * Lsd - left surround direct
3724 * Rsd - right surround direct
3725 * Lc - left center
3726 * Rc - right center
3727 * Ts - top surround
3728 * Vhl - vertical height left
3729 * Vhc - vertical height center
3730 * Vhr - vertical height right
3731 * Lt - left matrix total. for matrix encoded stereo.
3732 * Rt - right matrix total. for matrix encoded stereo. */
3734 /* General layouts */
3735 QT_CHANNEL_LAYOUT_USE_CHANNEL_DESCRIPTIONS = 0, /* use the array of Channel Descriptions to define the mapping. */
3736 QT_CHANNEL_LAYOUT_USE_CHANNEL_BITMAP = 1<<16, /* use the bitmap to define the mapping. */
3738 QT_CHANNEL_LAYOUT_MONO = (100<<16) | 1, /* a standard mono stream */
3739 QT_CHANNEL_LAYOUT_STEREO = (101<<16) | 2, /* a standard stereo stream (L R) - implied playback */
3740 QT_CHANNEL_LAYOUT_STEREO_HEADPHONES = (102<<16) | 2, /* a standard stereo stream (L R) - implied headphone playback */
3741 QT_CHANNEL_LAYOUT_MATRIX_STEREO = (103<<16) | 2, /* a matrix encoded stereo stream (Lt, Rt) */
3742 QT_CHANNEL_LAYOUT_MID_SIDE = (104<<16) | 2, /* mid/side recording */
3743 QT_CHANNEL_LAYOUT_XY = (105<<16) | 2, /* coincident mic pair (often 2 figure 8's) */
3744 QT_CHANNEL_LAYOUT_BINAURAL = (106<<16) | 2, /* binaural stereo (left, right) */
3745 QT_CHANNEL_LAYOUT_AMBISONIC_B_FORMAT = (107<<16) | 4, /* W, X, Y, Z */
3747 QT_CHANNEL_LAYOUT_QUADRAPHONIC = (108<<16) | 4, /* front left, front right, back left, back right */
3749 QT_CHANNEL_LAYOUT_PENTAGONAL = (109<<16) | 5, /* left, right, rear left, rear right, center */
3751 QT_CHANNEL_LAYOUT_HEXAGONAL = (110<<16) | 6, /* left, right, rear left, rear right, center, rear */
3753 QT_CHANNEL_LAYOUT_OCTAGONAL = (111<<16) | 8, /* front left, front right, rear left, rear right,
3754 * front center, rear center, side left, side right */
3756 QT_CHANNEL_LAYOUT_CUBE = (112<<16) | 8, /* left, right, rear left, rear right,
3757 * top left, top right, top rear left, top rear right */
3759 /* MPEG defined layouts */
3760 QT_CHANNEL_LAYOUT_MPEG_1_0 = QT_CHANNEL_LAYOUT_MONO, /* C */
3761 QT_CHANNEL_LAYOUT_MPEG_2_0 = QT_CHANNEL_LAYOUT_STEREO, /* L R */
3762 QT_CHANNEL_LAYOUT_MPEG_3_0_A = (113<<16) | 3, /* L R C */
3763 QT_CHANNEL_LAYOUT_MPEG_3_0_B = (114<<16) | 3, /* C L R */
3764 QT_CHANNEL_LAYOUT_MPEG_4_0_A = (115<<16) | 4, /* L R C Cs */
3765 QT_CHANNEL_LAYOUT_MPEG_4_0_B = (116<<16) | 4, /* C L R Cs */
3766 QT_CHANNEL_LAYOUT_MPEG_5_0_A = (117<<16) | 5, /* L R C Ls Rs */
3767 QT_CHANNEL_LAYOUT_MPEG_5_0_B = (118<<16) | 5, /* L R Ls Rs C */
3768 QT_CHANNEL_LAYOUT_MPEG_5_0_C = (119<<16) | 5, /* L C R Ls Rs */
3769 QT_CHANNEL_LAYOUT_MPEG_5_0_D = (120<<16) | 5, /* C L R Ls Rs */
3770 QT_CHANNEL_LAYOUT_MPEG_5_1_A = (121<<16) | 6, /* L R C LFE Ls Rs */
3771 QT_CHANNEL_LAYOUT_MPEG_5_1_B = (122<<16) | 6, /* L R Ls Rs C LFE */
3772 QT_CHANNEL_LAYOUT_MPEG_5_1_C = (123<<16) | 6, /* L C R Ls Rs LFE */
3773 QT_CHANNEL_LAYOUT_MPEG_5_1_D = (124<<16) | 6, /* C L R Ls Rs LFE */
3774 QT_CHANNEL_LAYOUT_MPEG_6_1_A = (125<<16) | 7, /* L R C LFE Ls Rs Cs */
3775 QT_CHANNEL_LAYOUT_MPEG_7_1_A = (126<<16) | 8, /* L R C LFE Ls Rs Lc Rc */
3776 QT_CHANNEL_LAYOUT_MPEG_7_1_B = (127<<16) | 8, /* C Lc Rc L R Ls Rs LFE (doc: IS-13818-7 MPEG2-AAC Table 3.1) */
3777 QT_CHANNEL_LAYOUT_MPEG_7_1_C = (128<<16) | 8, /* L R C LFE Ls Rs Rls Rrs */
3778 QT_CHANNEL_LAYOUT_EMAGIC_DEFAULT_7_1 = (129<<16) | 8, /* L R Ls Rs C LFE Lc Rc */
3779 QT_CHANNEL_LAYOUT_SMPTE_DTV = (130<<16) | 8, /* L R C LFE Ls Rs Lt Rt */
3781 /* ITU defined layouts */
3782 QT_CHANNEL_LAYOUT_ITU_1_0 = QT_CHANNEL_LAYOUT_MONO, /* C */
3783 QT_CHANNEL_LAYOUT_ITU_2_0 = QT_CHANNEL_LAYOUT_STEREO, /* L R */
3785 QT_CHANNEL_LAYOUT_ITU_2_1 = (131<<16) | 3, /* L R Cs */
3786 QT_CHANNEL_LAYOUT_ITU_2_2 = (132<<16) | 4, /* L R Ls Rs */
3787 QT_CHANNEL_LAYOUT_ITU_3_0 = QT_CHANNEL_LAYOUT_MPEG_3_0_A, /* L R C */
3788 QT_CHANNEL_LAYOUT_ITU_3_1 = QT_CHANNEL_LAYOUT_MPEG_4_0_A, /* L R C Cs */
3790 QT_CHANNEL_LAYOUT_ITU_3_2 = QT_CHANNEL_LAYOUT_MPEG_5_0_A, /* L R C Ls Rs */
3791 QT_CHANNEL_LAYOUT_ITU_3_2_1 = QT_CHANNEL_LAYOUT_MPEG_5_1_A, /* L R C LFE Ls Rs */
3792 QT_CHANNEL_LAYOUT_ITU_3_4_1 = QT_CHANNEL_LAYOUT_MPEG_7_1_C, /* L R C LFE Ls Rs Rls Rrs */
3794 /* DVD defined layouts */
3795 QT_CHANNEL_LAYOUT_DVD_0 = QT_CHANNEL_LAYOUT_MONO, /* C (mono) */
3796 QT_CHANNEL_LAYOUT_DVD_1 = QT_CHANNEL_LAYOUT_STEREO, /* L R */
3797 QT_CHANNEL_LAYOUT_DVD_2 = QT_CHANNEL_LAYOUT_ITU_2_1, /* L R Cs */
3798 QT_CHANNEL_LAYOUT_DVD_3 = QT_CHANNEL_LAYOUT_ITU_2_2, /* L R Ls Rs */
3799 QT_CHANNEL_LAYOUT_DVD_4 = (133<<16) | 3, /* L R LFE */
3800 QT_CHANNEL_LAYOUT_DVD_5 = (134<<16) | 4, /* L R LFE Cs */
3801 QT_CHANNEL_LAYOUT_DVD_6 = (135<<16) | 5, /* L R LFE Ls Rs */
3802 QT_CHANNEL_LAYOUT_DVD_7 = QT_CHANNEL_LAYOUT_MPEG_3_0_A, /* L R C */
3803 QT_CHANNEL_LAYOUT_DVD_8 = QT_CHANNEL_LAYOUT_MPEG_4_0_A, /* L R C Cs */
3804 QT_CHANNEL_LAYOUT_DVD_9 = QT_CHANNEL_LAYOUT_MPEG_5_0_A, /* L R C Ls Rs */
3805 QT_CHANNEL_LAYOUT_DVD_10 = (136<<16) | 4, /* L R C LFE */
3806 QT_CHANNEL_LAYOUT_DVD_11 = (137<<16) | 5, /* L R C LFE Cs */
3807 QT_CHANNEL_LAYOUT_DVD_12 = QT_CHANNEL_LAYOUT_MPEG_5_1_A, /* L R C LFE Ls Rs */
3808 /* 13 through 17 are duplicates of 8 through 12. */
3809 QT_CHANNEL_LAYOUT_DVD_13 = QT_CHANNEL_LAYOUT_DVD_8, /* L R C Cs */
3810 QT_CHANNEL_LAYOUT_DVD_14 = QT_CHANNEL_LAYOUT_DVD_9, /* L R C Ls Rs */
3811 QT_CHANNEL_LAYOUT_DVD_15 = QT_CHANNEL_LAYOUT_DVD_10, /* L R C LFE */
3812 QT_CHANNEL_LAYOUT_DVD_16 = QT_CHANNEL_LAYOUT_DVD_11, /* L R C LFE Cs */
3813 QT_CHANNEL_LAYOUT_DVD_17 = QT_CHANNEL_LAYOUT_DVD_12, /* L R C LFE Ls Rs */
3814 QT_CHANNEL_LAYOUT_DVD_18 = (138<<16) | 5, /* L R Ls Rs LFE */
3815 QT_CHANNEL_LAYOUT_DVD_19 = QT_CHANNEL_LAYOUT_MPEG_5_0_B, /* L R Ls Rs C */
3816 QT_CHANNEL_LAYOUT_DVD_20 = QT_CHANNEL_LAYOUT_MPEG_5_1_B, /* L R Ls Rs C LFE */
3818 /* These are the symmetrical layouts. */
3819 QT_CHANNEL_LAYOUT_AUDIO_UNIT_4 = QT_CHANNEL_LAYOUT_QUADRAPHONIC,
3820 QT_CHANNEL_LAYOUT_AUDIO_UNIT_5 = QT_CHANNEL_LAYOUT_PENTAGONAL,
3821 QT_CHANNEL_LAYOUT_AUDIO_UNIT_6 = QT_CHANNEL_LAYOUT_HEXAGONAL,
3822 QT_CHANNEL_LAYOUT_AUDIO_UNIT_8 = QT_CHANNEL_LAYOUT_OCTAGONAL,
3823 /* These are the surround-based layouts. */
3824 QT_CHANNEL_LAYOUT_AUDIO_UNIT_5_0 = QT_CHANNEL_LAYOUT_MPEG_5_0_B, /* L R Ls Rs C */
3825 QT_CHANNEL_LAYOUT_AUDIO_UNIT_6_0 = (139<<16) | 6, /* L R Ls Rs C Cs */
3826 QT_CHANNEL_LAYOUT_AUDIO_UNIT_7_0 = (140<<16) | 7, /* L R Ls Rs C Rls Rrs */
3827 QT_CHANNEL_LAYOUT_AUDIO_UNIT_7_0_FRONT = (148<<16) | 7, /* L R Ls Rs C Lc Rc */
3828 QT_CHANNEL_LAYOUT_AUDIO_UNIT_5_1 = QT_CHANNEL_LAYOUT_MPEG_5_1_A, /* L R C LFE Ls Rs */
3829 QT_CHANNEL_LAYOUT_AUDIO_UNIT_6_1 = QT_CHANNEL_LAYOUT_MPEG_6_1_A, /* L R C LFE Ls Rs Cs */
3830 QT_CHANNEL_LAYOUT_AUDIO_UNIT_7_1 = QT_CHANNEL_LAYOUT_MPEG_7_1_C, /* L R C LFE Ls Rs Rls Rrs */
3831 QT_CHANNEL_LAYOUT_AUDIO_UNIT_7_1_FRONT = QT_CHANNEL_LAYOUT_MPEG_7_1_A, /* L R C LFE Ls Rs Lc Rc */
3833 QT_CHANNEL_LAYOUT_AAC_3_0 = QT_CHANNEL_LAYOUT_MPEG_3_0_B, /* C L R */
3834 QT_CHANNEL_LAYOUT_AAC_QUADRAPHONIC = QT_CHANNEL_LAYOUT_QUADRAPHONIC, /* L R Ls Rs */
3835 QT_CHANNEL_LAYOUT_AAC_4_0 = QT_CHANNEL_LAYOUT_MPEG_4_0_B, /* C L R Cs */
3836 QT_CHANNEL_LAYOUT_AAC_5_0 = QT_CHANNEL_LAYOUT_MPEG_5_0_D, /* C L R Ls Rs */
3837 QT_CHANNEL_LAYOUT_AAC_5_1 = QT_CHANNEL_LAYOUT_MPEG_5_1_D, /* C L R Ls Rs LFE */
3838 QT_CHANNEL_LAYOUT_AAC_6_0 = (141<<16) | 6, /* C L R Ls Rs Cs */
3839 QT_CHANNEL_LAYOUT_AAC_6_1 = (142<<16) | 7, /* C L R Ls Rs Cs LFE */
3840 QT_CHANNEL_LAYOUT_AAC_7_0 = (143<<16) | 7, /* C L R Ls Rs Rls Rrs */
3841 QT_CHANNEL_LAYOUT_AAC_7_1 = QT_CHANNEL_LAYOUT_MPEG_7_1_B, /* C Lc Rc L R Ls Rs LFE */
3842 QT_CHANNEL_LAYOUT_AAC_OCTAGONAL = (144<<16) | 8, /* C L R Ls Rs Rls Rrs Cs */
3844 QT_CHANNEL_LAYOUT_TMH_10_2_STD = (145<<16) | 16, /* L R C Vhc Lsd Rsd Ls Rs Vhl Vhr Lw Rw Csd Cs LFE1 LFE2 */
3845 QT_CHANNEL_LAYOUT_TMH_10_2_FULL = (146<<16) | 21, /* TMH_10_2_std plus: Lc Rc HI VI Haptic */
3847 QT_CHANNEL_LAYOUT_AC3_1_0_1 = (149<<16) | 2, /* C LFE */
3848 QT_CHANNEL_LAYOUT_AC3_3_0 = (150<<16) | 3, /* L C R */
3849 QT_CHANNEL_LAYOUT_AC3_3_1 = (151<<16) | 4, /* L C R Cs */
3850 QT_CHANNEL_LAYOUT_AC3_3_0_1 = (152<<16) | 4, /* L C R LFE */
3851 QT_CHANNEL_LAYOUT_AC3_2_1_1 = (153<<16) | 4, /* L R Cs LFE */
3852 QT_CHANNEL_LAYOUT_AC3_3_1_1 = (154<<16) | 5, /* L C R Cs LFE */
3854 QT_CHANNEL_LAYOUT_EAC_6_0_A = (155<<16) | 6, /* L C R Ls Rs Cs */
3855 QT_CHANNEL_LAYOUT_EAC_7_0_A = (156<<16) | 7, /* L C R Ls Rs Rls Rrs */
3857 QT_CHANNEL_LAYOUT_EAC3_6_1_A = (157<<16) | 7, /* L C R Ls Rs LFE Cs */
3858 QT_CHANNEL_LAYOUT_EAC3_6_1_B = (158<<16) | 7, /* L C R Ls Rs LFE Ts */
3859 QT_CHANNEL_LAYOUT_EAC3_6_1_C = (159<<16) | 7, /* L C R Ls Rs LFE Vhc */
3860 QT_CHANNEL_LAYOUT_EAC3_7_1_A = (160<<16) | 8, /* L C R Ls Rs LFE Rls Rrs */
3861 QT_CHANNEL_LAYOUT_EAC3_7_1_B = (161<<16) | 8, /* L C R Ls Rs LFE Lc Rc */
3862 QT_CHANNEL_LAYOUT_EAC3_7_1_C = (162<<16) | 8, /* L C R Ls Rs LFE Lsd Rsd */
3863 QT_CHANNEL_LAYOUT_EAC3_7_1_D = (163<<16) | 8, /* L C R Ls Rs LFE Lw Rw */
3864 QT_CHANNEL_LAYOUT_EAC3_7_1_E = (164<<16) | 8, /* L C R Ls Rs LFE Vhl Vhr */
3866 QT_CHANNEL_LAYOUT_EAC3_7_1_F = (165<<16) | 8, /* L C R Ls Rs LFE Cs Ts */
3867 QT_CHANNEL_LAYOUT_EAC3_7_1_G = (166<<16) | 8, /* L C R Ls Rs LFE Cs Vhc */
3868 QT_CHANNEL_LAYOUT_EAC3_7_1_H = (167<<16) | 8, /* L C R Ls Rs LFE Ts Vhc */
3870 QT_CHANNEL_LAYOUT_DTS_3_1 = (168<<16) | 4, /* C L R LFE */
3871 QT_CHANNEL_LAYOUT_DTS_4_1 = (169<<16) | 5, /* C L R Cs LFE */
3872 QT_CHANNEL_LAYOUT_DTS_6_0_A = (170<<16) | 6, /* Lc Rc L R Ls Rs */
3873 QT_CHANNEL_LAYOUT_DTS_6_0_B = (171<<16) | 6, /* C L R Rls Rrs Ts */
3874 QT_CHANNEL_LAYOUT_DTS_6_0_C = (172<<16) | 6, /* C Cs L R Rls Rrs */
3875 QT_CHANNEL_LAYOUT_DTS_6_1_A = (173<<16) | 7, /* Lc Rc L R Ls Rs LFE */
3876 QT_CHANNEL_LAYOUT_DTS_6_1_B = (174<<16) | 7, /* C L R Rls Rrs Ts LFE */
3877 QT_CHANNEL_LAYOUT_DTS_6_1_C = (175<<16) | 7, /* C Cs L R Rls Rrs LFE */
3878 QT_CHANNEL_LAYOUT_DTS_7_0 = (176<<16) | 7, /* Lc C Rc L R Ls Rs */
3879 QT_CHANNEL_LAYOUT_DTS_7_1 = (177<<16) | 8, /* Lc C Rc L R Ls Rs LFE */
3880 QT_CHANNEL_LAYOUT_DTS_8_0_A = (178<<16) | 8, /* Lc Rc L R Ls Rs Rls Rrs */
3881 QT_CHANNEL_LAYOUT_DTS_8_0_B = (179<<16) | 8, /* Lc C Rc L R Ls Cs Rs */
3882 QT_CHANNEL_LAYOUT_DTS_8_1_A = (180<<16) | 9, /* Lc Rc L R Ls Rs Rls Rrs LFE */
3883 QT_CHANNEL_LAYOUT_DTS_8_1_B = (181<<16) | 9, /* Lc C Rc L R Ls Cs Rs LFE */
3884 QT_CHANNEL_LAYOUT_DTS_6_1_D = (182<<16) | 7, /* C L R Ls Rs LFE Cs */
3886 QT_CHANNEL_LAYOUT_ALAC_MONO = QT_CHANNEL_LAYOUT_MONO, /* C */
3887 QT_CHANNEL_LAYOUT_ALAC_STEREO = QT_CHANNEL_LAYOUT_STEREO, /* L R */
3888 QT_CHANNEL_LAYOUT_ALAC_3_0 = QT_CHANNEL_LAYOUT_MPEG_3_0_B, /* C L R */
3889 QT_CHANNEL_LAYOUT_ALAC_4_0 = QT_CHANNEL_LAYOUT_MPEG_4_0_B, /* C L R Cs */
3890 QT_CHANNEL_LAYOUT_ALAC_5_0 = QT_CHANNEL_LAYOUT_MPEG_5_0_D, /* C L R Ls Rs */
3891 QT_CHANNEL_LAYOUT_ALAC_5_1 = QT_CHANNEL_LAYOUT_MPEG_5_1_D, /* C L R Ls Rs LFE */
3892 QT_CHANNEL_LAYOUT_ALAC_6_1 = QT_CHANNEL_LAYOUT_AAC_6_1, /* C L R Ls Rs Cs LFE */
3893 QT_CHANNEL_LAYOUT_ALAC_7_1 = QT_CHANNEL_LAYOUT_MPEG_7_1_B, /* C Lc Rc L R Ls Rs LFE */
3895 QT_CHANNEL_LAYOUT_DISCRETE_IN_ORDER = 147<<16, /* needs to be ORed with the actual number of channels */
3896 QT_CHANNEL_LAYOUT_UNKNOWN = (signed)0xffff0000, /* needs to be ORed with the actual number of channels */
3897 } lsmash_channel_layout_tag;
3899 typedef struct
3901 lsmash_channel_layout_tag channelLayoutTag; /* channel layout */
3902 lsmash_channel_bitmap channelBitmap; /* Only available when layout_tag is set to QT_CHANNEL_LAYOUT_USE_CHANNEL_BITMAP. */
3903 } lsmash_qt_audio_channel_layout_t;
3905 /* QuickTime Audio Format Specific Flags
3906 * Some values are ignored i.e. as if treated as unspecified when you specify certain CODECs.
3907 * For instance, you specify QT_CODEC_TYPE_SOWT_AUDIO, then all these values are ignored.
3908 * These values are basically used for QT_CODEC_TYPE_LPCM_AUDIO.
3909 * The endiannes value can be used for QT_CODEC_TYPE_FL32_AUDIO, QT_CODEC_TYPE_FL64_AUDIO, QT_CODEC_TYPE_IN24_AUDIO and QT_CODEC_TYPE_IN32_AUDIO. */
3910 typedef enum
3912 QT_AUDIO_FORMAT_FLAG_FLOAT = 1, /* Set for floating point, clear for integer. */
3913 QT_AUDIO_FORMAT_FLAG_BIG_ENDIAN = 1<<1, /* Set for big endian, clear for little endian. */
3914 QT_AUDIO_FORMAT_FLAG_SIGNED_INTEGER = 1<<2, /* Set for signed integer, clear for unsigned integer.
3915 * This is only valid if QT_AUDIO_FORMAT_FLAG_FLOAT is clear. */
3916 QT_AUDIO_FORMAT_FLAG_PACKED = 1<<3, /* Set if the sample bits occupy the entire available bits for the channel,
3917 * clear if they are high or low aligned within the channel. */
3918 QT_AUDIO_FORMAT_FLAG_ALIGNED_HIGH = 1<<4, /* Set if the sample bits are placed into the high bits of the channel, clear for low bit placement.
3919 * This is only valid if QT_AUDIO_FORMAT_FLAG_PACKED is clear. */
3920 QT_AUDIO_FORMAT_FLAG_NON_INTERLEAVED = 1<<5, /* Set if the samples for each channel are located contiguously and the channels are layed out end to end,
3921 * clear if the samples for each frame are layed out contiguously and the frames layed out end to end. */
3922 QT_AUDIO_FORMAT_FLAG_NON_MIXABLE = 1<<6, /* Set to indicate when a format is non-mixable.
3923 * Note that this flag is only used when interacting with the HAL's stream format information.
3924 * It is not a valid flag for any other uses. */
3925 QT_AUDIO_FORMAT_FLAG_ALL_CLEAR = (int)(1u << 31), /* Set if all the flags would be clear in order to preserve 0 as the wild card value. */
3927 QT_LPCM_FORMAT_FLAG_FLOAT = QT_AUDIO_FORMAT_FLAG_FLOAT,
3928 QT_LPCM_FORMAT_FLAG_BIG_ENDIAN = QT_AUDIO_FORMAT_FLAG_BIG_ENDIAN,
3929 QT_LPCM_FORMAT_FLAG_SIGNED_INTEGER = QT_AUDIO_FORMAT_FLAG_SIGNED_INTEGER,
3930 QT_LPCM_FORMAT_FLAG_PACKED = QT_AUDIO_FORMAT_FLAG_PACKED,
3931 QT_LPCM_FORMAT_FLAG_ALIGNED_HIGH = QT_AUDIO_FORMAT_FLAG_ALIGNED_HIGH,
3932 QT_LPCM_FORMAT_FLAG_NON_INTERLEAVED = QT_AUDIO_FORMAT_FLAG_NON_INTERLEAVED,
3933 QT_LPCM_FORMAT_FLAG_NON_MIXABLE = QT_AUDIO_FORMAT_FLAG_NON_MIXABLE,
3934 QT_LPCM_FORMAT_FLAG_ALL_CLEAR = QT_AUDIO_FORMAT_FLAG_ALL_CLEAR,
3936 /* These flags are set for Apple Lossless data that was sourced from N bit native endian signed integer data. */
3937 QT_ALAC_FORMAT_FLAG_16BIT_SOURCE_DATA = 1,
3938 QT_ALAC_FORMAT_FLAG_20BIT_SOURCE_DATA = 2,
3939 QT_ALAC_FORMAT_FLAG_24BIT_SOURCE_DATA = 3,
3940 QT_ALAC_FORMAT_FLAG_32BIT_SOURCE_DATA = 4,
3941 } lsmash_qt_audio_format_specific_flag;
3943 typedef struct
3945 lsmash_qt_audio_format_specific_flag format_flags;
3946 } lsmash_qt_audio_format_specific_flags_t;
3948 /* Global Header
3949 * Ut Video inside QuickTime file format requires this extension for storing CODEC specific information. */
3950 typedef struct
3952 uint32_t header_size;
3953 uint8_t *header_data;
3954 } lsmash_codec_global_header_t;
3956 /****************************************************************************
3957 * iTunes Metadata
3958 ****************************************************************************/
3959 typedef enum
3961 /* UTF String type */
3962 ITUNES_METADATA_ITEM_ALBUM_NAME = (int)LSMASH_4CC( 0xA9u, 'a', 'l', 'b' ), /* Album Name */
3963 ITUNES_METADATA_ITEM_ARTIST = (int)LSMASH_4CC( 0xA9u, 'A', 'R', 'T' ), /* Artist */
3964 ITUNES_METADATA_ITEM_USER_COMMENT = (int)LSMASH_4CC( 0xA9u, 'c', 'm', 't' ), /* User Comment */
3965 ITUNES_METADATA_ITEM_RELEASE_DATE = (int)LSMASH_4CC( 0xA9u, 'd', 'a', 'y' ), /* YYYY-MM-DD format string (may be incomplete, i.e. only year) */
3966 ITUNES_METADATA_ITEM_ENCODED_BY = (int)LSMASH_4CC( 0xA9u, 'e', 'n', 'c' ), /* Person or company that encoded the recording */
3967 ITUNES_METADATA_ITEM_USER_GENRE = (int)LSMASH_4CC( 0xA9u, 'g', 'e', 'n' ), /* User Genre user-specified string */
3968 ITUNES_METADATA_ITEM_GROUPING = (int)LSMASH_4CC( 0xA9u, 'g', 'r', 'p' ), /* Grouping */
3969 ITUNES_METADATA_ITEM_LYRICS = (int)LSMASH_4CC( 0xA9u, 'l', 'y', 'r' ), /* Lyrics */
3970 ITUNES_METADATA_ITEM_TITLE = (int)LSMASH_4CC( 0xA9u, 'n', 'a', 'm' ), /* Title / Song Name */
3971 ITUNES_METADATA_ITEM_TRACK_SUBTITLE = (int)LSMASH_4CC( 0xA9u, 's', 't', '3' ), /* Track Sub-Title */
3972 ITUNES_METADATA_ITEM_ENCODING_TOOL = (int)LSMASH_4CC( 0xA9u, 't', 'o', 'o' ), /* Software which encoded the recording */
3973 ITUNES_METADATA_ITEM_COMPOSER = (int)LSMASH_4CC( 0xA9u, 'w', 'r', 't' ), /* Composer */
3974 ITUNES_METADATA_ITEM_ALBUM_ARTIST = LSMASH_4CC( 'a', 'A', 'R', 'T' ), /* Artist for the whole album (if different than the individual tracks) */
3975 ITUNES_METADATA_ITEM_PODCAST_CATEGORY = LSMASH_4CC( 'c', 'a', 't', 'g' ), /* Podcast Category */
3976 ITUNES_METADATA_ITEM_COPYRIGHT = LSMASH_4CC( 'c', 'p', 'r', 't' ), /* Copyright */
3977 ITUNES_METADATA_ITEM_DESCRIPTION = LSMASH_4CC( 'd', 'e', 's', 'c' ), /* Description (limited to 255 bytes) */
3978 ITUNES_METADATA_ITEM_GROUPING_DRAFT = LSMASH_4CC( 'g', 'r', 'u', 'p' ), /* Grouping
3979 * Note: This identifier is defined in
3980 * iTunes Metadata Format Specification (Preliminary draft),
3981 * but not used by iTunes actually it seems.
3982 * We recommend you use ITUNES_METADATA_ITEM_GROUPING instead of this. */
3983 ITUNES_METADATA_ITEM_PODCAST_KEYWORD = LSMASH_4CC( 'k', 'e', 'y', 'w' ), /* Podcast Keywords */
3984 ITUNES_METADATA_ITEM_LONG_DESCRIPTION = LSMASH_4CC( 'l', 'd', 'e', 's' ), /* Long Description */
3985 ITUNES_METADATA_ITEM_PURCHASE_DATE = LSMASH_4CC( 'p', 'u', 'r', 'd' ), /* Purchase Date */
3986 ITUNES_METADATA_ITEM_TV_EPISODE_ID = LSMASH_4CC( 't', 'v', 'e', 'n' ), /* TV Episode ID */
3987 ITUNES_METADATA_ITEM_TV_NETWORK = LSMASH_4CC( 't', 'v', 'n', 'n' ), /* TV Network Name */
3988 ITUNES_METADATA_ITEM_TV_SHOW_NAME = LSMASH_4CC( 't', 'v', 's', 'h' ), /* TV Show Name */
3989 ITUNES_METADATA_ITEM_ITUNES_PURCHASE_ACCOUNT_ID = LSMASH_4CC( 'a', 'p', 'I', 'D' ), /* iTunes Account Used for Purchase */
3990 ITUNES_METADATA_ITEM_ITUNES_SORT_ALBUM = LSMASH_4CC( 's', 'o', 'a', 'l' ), /* Sort Album */
3991 ITUNES_METADATA_ITEM_ITUNES_SORT_ARTIST = LSMASH_4CC( 's', 'o', 'a', 'r' ), /* Sort Artist */
3992 ITUNES_METADATA_ITEM_ITUNES_SORT_ALBUM_ARTIST = LSMASH_4CC( 's', 'o', 'a', 'a' ), /* Sort Album Artist */
3993 ITUNES_METADATA_ITEM_ITUNES_SORT_COMPOSER = LSMASH_4CC( 's', 'o', 'c', 'o' ), /* Sort Composer */
3994 ITUNES_METADATA_ITEM_ITUNES_SORT_NAME = LSMASH_4CC( 's', 'o', 'n', 'm' ), /* Sort Name */
3995 ITUNES_METADATA_ITEM_ITUNES_SORT_SHOW = LSMASH_4CC( 's', 'o', 's', 'n' ), /* Sort Show */
3997 /* Integer type
3998 * (X): X means length of bytes */
3999 ITUNES_METADATA_ITEM_EPISODE_GLOBAL_ID = LSMASH_4CC( 'e', 'g', 'i', 'd' ), /* (1) Episode Global Unique ID */
4000 ITUNES_METADATA_ITEM_PREDEFINED_GENRE = LSMASH_4CC( 'g', 'n', 'r', 'e' ), /* (2) Pre-defined Genre / Enumerated value from ID3 tag set, plus 1 */
4001 ITUNES_METADATA_ITEM_PODCAST_URL = LSMASH_4CC( 'p', 'u', 'r', 'l' ), /* (?) Podcast URL */
4002 ITUNES_METADATA_ITEM_CONTENT_RATING = LSMASH_4CC( 'r', 't', 'n', 'g' ), /* (1) Content Rating / Does song have explicit content? 0: none, 2: clean, 4: explicit */
4003 ITUNES_METADATA_ITEM_MEDIA_TYPE = LSMASH_4CC( 's', 't', 'i', 'k' ), /* (1) Media Type */
4004 ITUNES_METADATA_ITEM_BEATS_PER_MINUTE = LSMASH_4CC( 't', 'm', 'p', 'o' ), /* (2) Beats Per Minute */
4005 ITUNES_METADATA_ITEM_TV_EPISODE = LSMASH_4CC( 't', 'v', 'e', 's' ), /* (4) TV Episode */
4006 ITUNES_METADATA_ITEM_TV_SEASON = LSMASH_4CC( 't', 'v', 's', 'n' ), /* (4) TV Season */
4007 ITUNES_METADATA_ITEM_ITUNES_ACCOUNT_TYPE = LSMASH_4CC( 'a', 'k', 'I', 'D' ), /* (1) iTunes Account Type / 0: iTunes, 1: AOL */
4008 ITUNES_METADATA_ITEM_ITUNES_ARTIST_ID = LSMASH_4CC( 'a', 't', 'I', 'D' ), /* (4) iTunes Artist ID */
4009 ITUNES_METADATA_ITEM_ITUNES_COMPOSER_ID = LSMASH_4CC( 'c', 'm', 'I', 'D' ), /* (4) iTunes Composer ID */
4010 ITUNES_METADATA_ITEM_ITUNES_CATALOG_ID = LSMASH_4CC( 'c', 'n', 'I', 'D' ), /* (4) iTunes Catalog ID */
4011 ITUNES_METADATA_ITEM_ITUNES_TV_GENRE_ID = LSMASH_4CC( 'g', 'e', 'I', 'D' ), /* (4) iTunes TV Genre ID */
4012 ITUNES_METADATA_ITEM_ITUNES_PLAYLIST_ID = LSMASH_4CC( 'p', 'l', 'I', 'D' ), /* (8) iTunes Playlist ID */
4013 ITUNES_METADATA_ITEM_ITUNES_COUNTRY_CODE = LSMASH_4CC( 's', 'f', 'I', 'D' ), /* (4) iTunes Country Code */
4015 /* Boolean type */
4016 ITUNES_METADATA_ITEM_DISC_COMPILATION = LSMASH_4CC( 'c', 'p', 'i', 'l' ), /* Disc Compilation / Is disc part of a compilation? 0: No, 1: Yes */
4017 ITUNES_METADATA_ITEM_HIGH_DEFINITION_VIDEO = LSMASH_4CC( 'h', 'd', 'v', 'd' ), /* High Definition Video / 0: No, 1: Yes */
4018 ITUNES_METADATA_ITEM_PODCAST = LSMASH_4CC( 'p', 'c', 's', 't' ), /* Podcast / 0: No, 1: Yes */
4019 ITUNES_METADATA_ITEM_GAPLESS_PLAYBACK = LSMASH_4CC( 'p', 'g', 'a', 'p' ), /* Gapless Playback / 0: insert gap, 1: no gap */
4021 /* Binary type */
4022 ITUNES_METADATA_ITEM_COVER_ART = LSMASH_4CC( 'c', 'o', 'v', 'r' ), /* One or more cover art images (JPEG/PNG/BMP data) */
4023 ITUNES_METADATA_ITEM_DISC_NUMBER = LSMASH_4CC( 'd', 'i', 's', 'k' ), /* Disc Number */
4024 ITUNES_METADATA_ITEM_TRACK_NUMBER = LSMASH_4CC( 't', 'r', 'k', 'n' ), /* Track Number */
4026 /* Custom type */
4027 ITUNES_METADATA_ITEM_CUSTOM = LSMASH_4CC( '-', '-', '-', '-' ), /* Custom */
4028 } lsmash_itunes_metadata_item;
4030 typedef enum
4032 ITUNES_METADATA_TYPE_NONE = 0,
4033 ITUNES_METADATA_TYPE_STRING = 1,
4034 ITUNES_METADATA_TYPE_INTEGER = 2,
4035 ITUNES_METADATA_TYPE_BOOLEAN = 3,
4036 ITUNES_METADATA_TYPE_BINARY = 4,
4037 } lsmash_itunes_metadata_type;
4039 typedef enum
4041 ITUNES_METADATA_SUBTYPE_IMPLICIT = 0, /* for use with tags for which no type needs to be indicated because only one type is allowed */
4042 ITUNES_METADATA_SUBTYPE_UTF8 = 1, /* without any count or null terminator */
4043 ITUNES_METADATA_SUBTYPE_UTF16 = 2, /* also known as UTF-16BE */
4044 ITUNES_METADATA_SUBTYPE_SJIS = 3, /* deprecated unless it is needed for special Japanese characters */
4045 ITUNES_METADATA_SUBTYPE_HTML = 6, /* the HTML file header specifies which HTML version */
4046 ITUNES_METADATA_SUBTYPE_XML = 7, /* the XML header must identify the DTD or schemas */
4047 ITUNES_METADATA_SUBTYPE_UUID = 8, /* also known as GUID; stored as 16 bytes in binary (valid as an ID) */
4048 ITUNES_METADATA_SUBTYPE_ISRC = 9, /* stored as UTF-8 text (valid as an ID) */
4049 ITUNES_METADATA_SUBTYPE_MI3P = 10, /* stored as UTF-8 text (valid as an ID) */
4050 ITUNES_METADATA_SUBTYPE_GIF = 12, /* (deprecated) a GIF image */
4051 ITUNES_METADATA_SUBTYPE_JPEG = 13, /* in a JFIF wrapper */
4052 ITUNES_METADATA_SUBTYPE_PNG = 14, /* in a PNG wrapper */
4053 ITUNES_METADATA_SUBTYPE_URL = 15, /* absolute, in UTF-8 characters */
4054 ITUNES_METADATA_SUBTYPE_DURATION = 16, /* in milliseconds, a 32-bit integer */
4055 ITUNES_METADATA_SUBTYPE_TIME = 17, /* in UTC, counting seconds since midnight on 1 January, 1904; 32 or 64 bits */
4056 ITUNES_METADATA_SUBTYPE_GENRES = 18, /* a list of values from the enumerated set */
4057 ITUNES_METADATA_SUBTYPE_INTEGER = 21, /* A signed big-endian integer in 1,2,3,4 or 8 bytes */
4058 ITUNES_METADATA_SUBTYPE_RIAAPA = 24, /* RIAA Parental advisory; -1=no, 1=yes, 0=unspecified. 8-bit integer */
4059 ITUNES_METADATA_SUBTYPE_UPC = 25, /* Universal Product Code, in text UTF-8 format (valid as an ID) */
4060 ITUNES_METADATA_SUBTYPE_BMP = 27, /* Windows bitmap format graphics */
4061 } lsmash_itunes_metadata_subtype;
4063 typedef union
4065 char *string; /* for ITUNES_METADATA_TYPE_STRING (UTF-8 string) */
4066 uint64_t integer; /* for ITUNES_METADATA_TYPE_INTEGER */
4067 lsmash_boolean_t boolean; /* for ITUNES_METADATA_TYPE_BOOLEAN */
4068 /* for ITUNES_METADATA_TYPE_BINARY */
4069 struct
4071 lsmash_itunes_metadata_subtype subtype;
4072 uint32_t size;
4073 uint8_t *data;
4074 } binary;
4075 } lsmash_itunes_metadata_value_t;
4077 typedef struct
4079 /* When 'item' is specified as ITUNES_METADATA_ITEM_CUSTOM, 'type' and 'meaning' is mandatory while 'name' is optionally valid.
4080 * Otherwise 'type', 'meaning' and 'name' are just ignored. 'value' is always mandatory. */
4081 lsmash_itunes_metadata_item item;
4082 lsmash_itunes_metadata_type type;
4083 lsmash_itunes_metadata_value_t value;
4084 char *meaning;
4085 char *name;
4086 } lsmash_itunes_metadata_t;
4088 /* Append an iTunes metadata to a movie.
4090 * Return 0 if successful.
4091 * Return a negative value otherwise. */
4092 int lsmash_set_itunes_metadata
4094 lsmash_root_t *root,
4095 lsmash_itunes_metadata_t metadata
4098 /* Count the number of iTunes metadata in a movie.
4100 * Return the number of iTunes metadata in a movie if successful.
4101 * Return 0 otherwise. */
4102 uint32_t lsmash_count_itunes_metadata
4104 lsmash_root_t *root
4107 /* Get an iTunes metadata in a movie.
4108 * String and/or binary fields in 'metadata' are allocated if successful.
4109 * You can deallocate the allocated fields by lsmash_free().
4110 * Also you can deallocate all of the allocated fields by lsmash_cleanup_itunes_metadata() at a time.
4112 * Return 0 if successful.
4113 * Return a negative value otherwise. */
4114 int lsmash_get_itunes_metadata
4116 lsmash_root_t *root,
4117 uint32_t metadata_number,
4118 lsmash_itunes_metadata_t *metadata
4121 /* Deallocate all of allocated fields in a given iTunes metadata at a time.
4122 * The deallocated fields are set to NULL.
4123 * Note: the given iTunes metadata itself is NOT deallocated by this function. */
4124 void lsmash_cleanup_itunes_metadata
4126 lsmash_itunes_metadata_t *metadata
4129 /****************************************************************************
4130 * Others
4131 ****************************************************************************/
4132 /* Set a copyright declaration to a track.
4133 * track_ID == 0 means copyright declaration applies to the entire presentation, not an entire track.
4135 * Return 0 if successful.
4136 * Return a negative value otherwise. */
4137 int lsmash_set_copyright
4139 lsmash_root_t *root,
4140 uint32_t track_ID,
4141 uint16_t ISO_language,
4142 char *notice
4145 int lsmash_create_object_descriptor
4147 lsmash_root_t *root
4150 /* Set a session description protocol (SDP) to a track.
4151 * track_ID == 0 means SDP applies to the entire presentation, not an entire track.
4152 * Recommendation: Record session level section of SDP to movie and media-level sections to track
4154 * Return 0 if successful.
4155 * Return a negative value otherwise. */
4156 int lsmash_set_sdp
4158 lsmash_root_t *root,
4159 uint32_t track_ID,
4160 char *sdptext
4163 /* Timestamp synchronization */
4164 typedef enum
4166 ISOM_SYNC_ANY = 0,
4167 ISOM_SYNC_RECIEVED_RTP = 1,
4168 ISOM_SYNC_OTHER_TRACKS = 2,
4169 ISOM_SYNC_RESERVED = 3,
4170 } timestamp_sync_t;
4172 typedef struct
4174 uint32_t timescale; /* timscale of this track */
4175 uint32_t time_offset; /* Beginning time stamp offset compared to */
4176 uint8_t reserved_timestamp_sync; /* first 6 bits = 0, last two indicate whether tracks have been synchronized */
4177 } lsmash_isom_rtp_reception_hint_t;
4179 #ifdef _WIN32
4180 /* Convert string encoded by ACP (ANSI CODE PAGE) to UTF-8.
4182 * Return the size of converted string (bytes) if successful.
4183 * Return 0 otherwise. */
4184 int lsmash_convert_ansi_to_utf8
4186 const char *string_ansi, /* string encoded by ACP */
4187 char *string_utf8, /* buffer for converted string from ACP */
4188 int max_length /* size of 'string_utf8' */
4190 #endif
4192 #undef PRIVATE
4194 #ifdef __cplusplus
4196 #endif
4198 #endif