1 /*****************************************************************************
2 * libmp4.h : LibMP4 library for mp4 module for vlc
3 *****************************************************************************
4 * Copyright (C) 2001-2004, 2010 the VideoLAN team
6 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
26 #define ATOM_root VLC_FOURCC( 'r', 'o', 'o', 't' )
27 #define ATOM_uuid VLC_FOURCC( 'u', 'u', 'i', 'd' )
29 #define ATOM_ftyp VLC_FOURCC( 'f', 't', 'y', 'p' )
30 #define ATOM_moov VLC_FOURCC( 'm', 'o', 'o', 'v' )
31 #define ATOM_foov VLC_FOURCC( 'f', 'o', 'o', 'v' )
32 #define ATOM_cmov VLC_FOURCC( 'c', 'm', 'o', 'v' )
33 #define ATOM_dcom VLC_FOURCC( 'd', 'c', 'o', 'm' )
34 #define ATOM_cmvd VLC_FOURCC( 'c', 'm', 'v', 'd' )
36 #define ATOM_moof VLC_FOURCC( 'm', 'o', 'o', 'f' )
37 #define ATOM_mdat VLC_FOURCC( 'm', 'd', 'a', 't' )
38 #define ATOM_skip VLC_FOURCC( 's', 'k', 'i', 'p' )
39 #define ATOM_free VLC_FOURCC( 'f', 'r', 'e', 'e' )
40 #define ATOM_udta VLC_FOURCC( 'u', 'd', 't', 'a' )
41 #define ATOM_wide VLC_FOURCC( 'w', 'i', 'd', 'e' )
43 #define ATOM_data VLC_FOURCC( 'd', 'a', 't', 'a' )
45 #define ATOM_trak VLC_FOURCC( 't', 'r', 'a', 'k' )
46 #define ATOM_mvhd VLC_FOURCC( 'm', 'v', 'h', 'd' )
47 #define ATOM_tkhd VLC_FOURCC( 't', 'k', 'h', 'd' )
48 #define ATOM_tref VLC_FOURCC( 't', 'r', 'e', 'f' )
49 #define ATOM_mdia VLC_FOURCC( 'm', 'd', 'i', 'a' )
50 #define ATOM_mdhd VLC_FOURCC( 'm', 'd', 'h', 'd' )
51 #define ATOM_hdlr VLC_FOURCC( 'h', 'd', 'l', 'r' )
52 #define ATOM_minf VLC_FOURCC( 'm', 'i', 'n', 'f' )
53 #define ATOM_vmhd VLC_FOURCC( 'v', 'm', 'h', 'd' )
54 #define ATOM_smhd VLC_FOURCC( 's', 'm', 'h', 'd' )
55 #define ATOM_hmhd VLC_FOURCC( 'h', 'm', 'h', 'd' )
56 #define ATOM_dinf VLC_FOURCC( 'd', 'i', 'n', 'f' )
57 #define ATOM_url VLC_FOURCC( 'u', 'r', 'l', ' ' )
58 #define ATOM_urn VLC_FOURCC( 'u', 'r', 'n', ' ' )
59 #define ATOM_dref VLC_FOURCC( 'd', 'r', 'e', 'f' )
60 #define ATOM_stbl VLC_FOURCC( 's', 't', 'b', 'l' )
61 #define ATOM_stts VLC_FOURCC( 's', 't', 't', 's' )
62 #define ATOM_ctts VLC_FOURCC( 'c', 't', 't', 's' )
63 #define ATOM_stsd VLC_FOURCC( 's', 't', 's', 'd' )
64 #define ATOM_stsz VLC_FOURCC( 's', 't', 's', 'z' )
65 #define ATOM_stz2 VLC_FOURCC( 's', 't', 'z', '2' )
66 #define ATOM_stsc VLC_FOURCC( 's', 't', 's', 'c' )
67 #define ATOM_stco VLC_FOURCC( 's', 't', 'c', 'o' )
68 #define ATOM_co64 VLC_FOURCC( 'c', 'o', '6', '4' )
69 #define ATOM_stss VLC_FOURCC( 's', 't', 's', 's' )
70 #define ATOM_stsh VLC_FOURCC( 's', 't', 's', 'h' )
71 #define ATOM_stdp VLC_FOURCC( 's', 't', 'd', 'p' )
72 #define ATOM_padb VLC_FOURCC( 'p', 'a', 'd', 'b' )
73 #define ATOM_edts VLC_FOURCC( 'e', 'd', 't', 's' )
74 #define ATOM_elst VLC_FOURCC( 'e', 'l', 's', 't' )
75 #define ATOM_mvex VLC_FOURCC( 'm', 'v', 'e', 'x' )
76 #define ATOM_trex VLC_FOURCC( 't', 'r', 'e', 'x' )
77 #define ATOM_mfhd VLC_FOURCC( 'm', 'f', 'h', 'd' )
78 #define ATOM_traf VLC_FOURCC( 't', 'r', 'a', 'f' )
79 #define ATOM_tfhd VLC_FOURCC( 't', 'f', 'h', 'd' )
80 #define ATOM_trun VLC_FOURCC( 't', 'r', 'u', 'n' )
81 #define ATOM_cprt VLC_FOURCC( 'c', 'p', 'r', 't' )
82 #define ATOM_iods VLC_FOURCC( 'i', 'o', 'd', 's' )
83 #define ATOM_pasp VLC_FOURCC( 'p', 'a', 's', 'p' )
85 #define ATOM_nmhd VLC_FOURCC( 'n', 'm', 'h', 'd' )
86 #define ATOM_mp2v VLC_FOURCC( 'm', 'p', '2', 'v' )
87 #define ATOM_mp4v VLC_FOURCC( 'm', 'p', '4', 'v' )
88 #define ATOM_mp4a VLC_FOURCC( 'm', 'p', '4', 'a' )
89 #define ATOM_mp4s VLC_FOURCC( 'm', 'p', '4', 's' )
90 #define ATOM_vide VLC_FOURCC( 'v', 'i', 'd', 'e' )
91 #define ATOM_soun VLC_FOURCC( 's', 'o', 'u', 'n' )
92 #define ATOM_hint VLC_FOURCC( 'h', 'i', 'n', 't' )
93 #define ATOM_hdv2 VLC_FOURCC( 'h', 'd', 'v', '2' )
95 #define ATOM_dpnd VLC_FOURCC( 'd', 'p', 'n', 'd' )
96 #define ATOM_ipir VLC_FOURCC( 'i', 'p', 'i', 'r' )
97 #define ATOM_mpod VLC_FOURCC( 'm', 'p', 'o', 'd' )
98 #define ATOM_hnti VLC_FOURCC( 'h', 'n', 't', 'i' )
99 #define ATOM_rtp VLC_FOURCC( 'r', 't', 'p', ' ' )
101 #define ATOM_isom VLC_FOURCC( 'i', 's', 'o', 'm' )
102 #define ATOM_3gp4 VLC_FOURCC( '3', 'g', 'p', '4' )
103 #define ATOM_esds VLC_FOURCC( 'e', 's', 'd', 's' )
105 #define ATOM__mp3 VLC_FOURCC( '.', 'm', 'p', '3' )
106 #define ATOM_ms02 VLC_FOURCC( 'm', 's', 0x0, 0x02 )
107 #define ATOM_ms11 VLC_FOURCC( 'm', 's', 0x0, 0x11 )
108 #define ATOM_ms55 VLC_FOURCC( 'm', 's', 0x0, 0x55 )
109 #define ATOM_twos VLC_FOURCC( 't', 'w', 'o', 's' )
110 #define ATOM_sowt VLC_FOURCC( 's', 'o', 'w', 't' )
111 #define ATOM_QDMC VLC_FOURCC( 'Q', 'D', 'M', 'C' )
112 #define ATOM_QDM2 VLC_FOURCC( 'Q', 'D', 'M', '2' )
113 #define ATOM_ima4 VLC_FOURCC( 'i', 'm', 'a', '4' )
114 #define ATOM_IMA4 VLC_FOURCC( 'I', 'M', 'A', '4' )
115 #define ATOM_dvi VLC_FOURCC( 'd', 'v', 'i', ' ' )
116 #define ATOM_MAC3 VLC_FOURCC( 'M', 'A', 'C', '3' )
117 #define ATOM_MAC6 VLC_FOURCC( 'M', 'A', 'C', '6' )
118 #define ATOM_alaw VLC_FOURCC( 'a', 'l', 'a', 'w' )
119 #define ATOM_ulaw VLC_FOURCC( 'u', 'l', 'a', 'w' )
120 #define ATOM_Qclp VLC_FOURCC( 'Q', 'c', 'l', 'p' )
121 #define ATOM_samr VLC_FOURCC( 's', 'a', 'm', 'r' )
122 #define ATOM_sawb VLC_FOURCC( 's', 'a', 'w', 'b' )
123 #define ATOM_OggS VLC_FOURCC( 'O', 'g', 'g', 'S' )
124 #define ATOM_alac VLC_FOURCC( 'a', 'l', 'a', 'c' )
125 #define ATOM_dac3 VLC_FOURCC( 'd', 'a', 'c', '3' )
126 #define ATOM_dec3 VLC_FOURCC( 'd', 'e', 'c', '3' )
127 #define ATOM_enda VLC_FOURCC( 'e', 'n', 'd', 'a' )
128 #define ATOM_gnre VLC_FOURCC( 'g', 'n', 'r', 'e' )
129 #define ATOM_trkn VLC_FOURCC( 't', 'r', 'k', 'n' )
131 #define ATOM_zlib VLC_FOURCC( 'z', 'l', 'i', 'b' )
132 #define ATOM_SVQ1 VLC_FOURCC( 'S', 'V', 'Q', '1' )
133 #define ATOM_SVQ3 VLC_FOURCC( 'S', 'V', 'Q', '3' )
134 #define ATOM_ZyGo VLC_FOURCC( 'Z', 'y', 'G', 'o' )
135 #define ATOM_3IV1 VLC_FOURCC( '3', 'I', 'V', '1' )
136 #define ATOM_3iv1 VLC_FOURCC( '3', 'i', 'v', '1' )
137 #define ATOM_3IV2 VLC_FOURCC( '3', 'I', 'V', '2' )
138 #define ATOM_3iv2 VLC_FOURCC( '3', 'i', 'v', '2' )
139 #define ATOM_3IVD VLC_FOURCC( '3', 'I', 'V', 'D' )
140 #define ATOM_3ivd VLC_FOURCC( '3', 'i', 'v', 'd' )
141 #define ATOM_3VID VLC_FOURCC( '3', 'V', 'I', 'D' )
142 #define ATOM_3vid VLC_FOURCC( '3', 'v', 'i', 'd' )
143 #define ATOM_h263 VLC_FOURCC( 'h', '2', '6', '3' )
144 #define ATOM_s263 VLC_FOURCC( 's', '2', '6', '3' )
145 #define ATOM_DIVX VLC_FOURCC( 'D', 'I', 'V', 'X' )
146 #define ATOM_XVID VLC_FOURCC( 'X', 'V', 'I', 'D' )
147 #define ATOM_cvid VLC_FOURCC( 'c', 'v', 'i', 'd' )
148 #define ATOM_mjpa VLC_FOURCC( 'm', 'j', 'p', 'a' )
149 #define ATOM_mjpb VLC_FOURCC( 'm', 'j', 'q', 't' )
150 #define ATOM_mjqt VLC_FOURCC( 'm', 'j', 'h', 't' )
151 #define ATOM_mjht VLC_FOURCC( 'm', 'j', 'p', 'b' )
152 #define ATOM_VP31 VLC_FOURCC( 'V', 'P', '3', '1' )
153 #define ATOM_vp31 VLC_FOURCC( 'v', 'p', '3', '1' )
154 #define ATOM_h264 VLC_FOURCC( 'h', '2', '6', '4' )
155 #define ATOM_qdrw VLC_FOURCC( 'q', 'd', 'r', 'w' )
157 #define ATOM_avc1 VLC_FOURCC( 'a', 'v', 'c', '1' )
158 #define ATOM_avcC VLC_FOURCC( 'a', 'v', 'c', 'C' )
159 #define ATOM_m4ds VLC_FOURCC( 'm', '4', 'd', 's' )
161 #define ATOM_dvc VLC_FOURCC( 'd', 'v', 'c', ' ' )
162 #define ATOM_dvp VLC_FOURCC( 'd', 'v', 'p', ' ' )
163 #define ATOM_dv5n VLC_FOURCC( 'd', 'v', '5', 'n' )
164 #define ATOM_dv5p VLC_FOURCC( 'd', 'v', '5', 'p' )
165 #define ATOM_raw VLC_FOURCC( 'r', 'a', 'w', ' ' )
167 #define ATOM_jpeg VLC_FOURCC( 'j', 'p', 'e', 'g' )
169 #define ATOM_yv12 VLC_FOURCC( 'y', 'v', '1', '2' )
170 #define ATOM_yuv2 VLC_FOURCC( 'y', 'u', 'v', '2' )
172 #define ATOM_rmra VLC_FOURCC( 'r', 'm', 'r', 'a' )
173 #define ATOM_rmda VLC_FOURCC( 'r', 'm', 'd', 'a' )
174 #define ATOM_rdrf VLC_FOURCC( 'r', 'd', 'r', 'f' )
175 #define ATOM_rmdr VLC_FOURCC( 'r', 'm', 'd', 'r' )
176 #define ATOM_rmvc VLC_FOURCC( 'r', 'm', 'v', 'c' )
177 #define ATOM_rmcd VLC_FOURCC( 'r', 'm', 'c', 'd' )
178 #define ATOM_rmqu VLC_FOURCC( 'r', 'm', 'q', 'u' )
179 #define ATOM_alis VLC_FOURCC( 'a', 'l', 'i', 's' )
181 #define ATOM_gmhd VLC_FOURCC( 'g', 'm', 'h', 'd' )
182 #define ATOM_wave VLC_FOURCC( 'w', 'a', 'v', 'e' )
184 #define ATOM_drms VLC_FOURCC( 'd', 'r', 'm', 's' )
185 #define ATOM_sinf VLC_FOURCC( 's', 'i', 'n', 'f' )
186 #define ATOM_schi VLC_FOURCC( 's', 'c', 'h', 'i' )
187 #define ATOM_user VLC_FOURCC( 'u', 's', 'e', 'r' )
188 #define ATOM_key VLC_FOURCC( 'k', 'e', 'y', ' ' )
189 #define ATOM_iviv VLC_FOURCC( 'i', 'v', 'i', 'v' )
190 #define ATOM_name VLC_FOURCC( 'n', 'a', 'm', 'e' )
191 #define ATOM_priv VLC_FOURCC( 'p', 'r', 'i', 'v' )
192 #define ATOM_drmi VLC_FOURCC( 'd', 'r', 'm', 'i' )
193 #define ATOM_frma VLC_FOURCC( 'f', 'r', 'm', 'a' )
194 #define ATOM_skcr VLC_FOURCC( 's', 'k', 'c', 'r' )
196 #define ATOM_text VLC_FOURCC( 't', 'e', 'x', 't' )
197 #define ATOM_tx3g VLC_FOURCC( 't', 'x', '3', 'g' )
198 #define ATOM_subp VLC_FOURCC( 's', 'u', 'b', 'p' )
199 #define ATOM_sbtl VLC_FOURCC( 's', 'b', 't', 'l' )
201 #define ATOM_0xa9nam VLC_FOURCC( 0xa9, 'n', 'a', 'm' )
202 #define ATOM_0xa9aut VLC_FOURCC( 0xa9, 'a', 'u', 't' )
203 #define ATOM_0xa9cpy VLC_FOURCC( 0xa9, 'c', 'p', 'y' )
204 #define ATOM_0xa9inf VLC_FOURCC( 0xa9, 'i', 'n', 'f' )
205 #define ATOM_0xa9ART VLC_FOURCC( 0xa9, 'A', 'R', 'T' )
206 #define ATOM_0xa9des VLC_FOURCC( 0xa9, 'd', 'e', 's' )
207 #define ATOM_0xa9dir VLC_FOURCC( 0xa9, 'd', 'i', 'r' )
208 #define ATOM_0xa9cmt VLC_FOURCC( 0xa9, 'c', 'm', 't' )
209 #define ATOM_0xa9req VLC_FOURCC( 0xa9, 'r', 'e', 'q' )
210 #define ATOM_0xa9day VLC_FOURCC( 0xa9, 'd', 'a', 'y' )
211 #define ATOM_0xa9fmt VLC_FOURCC( 0xa9, 'f', 'm', 't' )
212 #define ATOM_0xa9prd VLC_FOURCC( 0xa9, 'p', 'r', 'd' )
213 #define ATOM_0xa9prf VLC_FOURCC( 0xa9, 'p', 'r', 'f' )
214 #define ATOM_0xa9src VLC_FOURCC( 0xa9, 's', 'r', 'c' )
215 #define ATOM_0xa9alb VLC_FOURCC( 0xa9, 'a', 'l', 'b' )
216 #define ATOM_0xa9dis VLC_FOURCC( 0xa9, 'd', 'i', 's' )
217 #define ATOM_0xa9enc VLC_FOURCC( 0xa9, 'e', 'n', 'c' )
218 #define ATOM_0xa9trk VLC_FOURCC( 0xa9, 't', 'r', 'k' )
219 #define ATOM_0xa9url VLC_FOURCC( 0xa9, 'u', 'r', 'l' )
220 #define ATOM_0xa9dsa VLC_FOURCC( 0xa9, 'd', 's', 'a' )
221 #define ATOM_0xa9hst VLC_FOURCC( 0xa9, 'h', 's', 't' )
222 #define ATOM_0xa9ope VLC_FOURCC( 0xa9, 'o', 'p', 'e' )
223 #define ATOM_0xa9wrt VLC_FOURCC( 0xa9, 'w', 'r', 't' )
224 #define ATOM_0xa9com VLC_FOURCC( 0xa9, 'c', 'o', 'm' )
225 #define ATOM_0xa9gen VLC_FOURCC( 0xa9, 'g', 'e', 'n' )
226 #define ATOM_0xa9too VLC_FOURCC( 0xa9, 't', 'o', 'o' )
227 #define ATOM_0xa9wrn VLC_FOURCC( 0xa9, 'w', 'r', 'n' )
228 #define ATOM_0xa9swr VLC_FOURCC( 0xa9, 's', 'w', 'r' )
229 #define ATOM_0xa9mak VLC_FOURCC( 0xa9, 'm', 'a', 'k' )
230 #define ATOM_0xa9mod VLC_FOURCC( 0xa9, 'm', 'o', 'd' )
231 #define ATOM_0xa9PRD VLC_FOURCC( 0xa9, 'P', 'R', 'D' )
232 #define ATOM_0xa9grp VLC_FOURCC( 0xa9, 'g', 'r', 'p' )
233 #define ATOM_0xa9lyr VLC_FOURCC( 0xa9, 'g', 'r', 'p' )
234 #define ATOM_chpl VLC_FOURCC( 'c', 'h', 'p', 'l' )
235 #define ATOM_WLOC VLC_FOURCC( 'W', 'L', 'O', 'C' )
237 #define ATOM_meta VLC_FOURCC( 'm', 'e', 't', 'a' )
238 #define ATOM_ilst VLC_FOURCC( 'i', 'l', 's', 't' )
240 #define ATOM_chap VLC_FOURCC( 'c', 'h', 'a', 'p' )
242 /* Do you want some debug information on all read boxes ? */
243 //#define MP4_VERBOSE 1
249 /* uuid Universal Unique IDentifiers */
250 typedef struct UUID_s
255 /* specific structure for all boxes */
257 typedef struct MP4_Box_data_ftyp_s
259 uint32_t i_major_brand
;
260 uint32_t i_minor_version
;
262 uint32_t i_compatible_brands_count
;
263 uint32_t *i_compatible_brands
;
265 } MP4_Box_data_ftyp_t
;
267 typedef struct MP4_Box_data_mvhd_s
272 uint64_t i_creation_time
;
273 uint64_t i_modification_time
;
274 uint32_t i_timescale
;
280 uint32_t i_reserved2
[2];
282 uint32_t i_predefined
[6];
283 uint32_t i_next_track_id
;
285 } MP4_Box_data_mvhd_t
;
287 #define MP4_TRACK_ENABLED 0x000001
288 #define MP4_TRACK_IN_MOVIE 0x000002
289 #define MP4_TRACK_IN_PREVIEW 0x000004
290 typedef struct MP4_Box_data_tkhd_s
295 uint64_t i_creation_time
;
296 uint64_t i_modification_time
;
301 uint32_t i_reserved2
[2];
303 int16_t i_predefined
;
306 uint16_t i_reserved3
;
311 } MP4_Box_data_tkhd_t
;
313 typedef struct MP4_Box_data_mdhd_s
318 uint64_t i_creation_time
;
319 uint64_t i_modification_time
;
320 uint32_t i_timescale
;
323 /* one bit for pad */
324 uint16_t i_language_code
;
325 /* unsigned int(5)[3] language difference with 0x60*/
326 unsigned char i_language
[3];
327 uint16_t i_predefined
;
329 } MP4_Box_data_mdhd_t
;
331 typedef struct MP4_Box_data_hdlr_s
336 uint32_t i_predefined
;
337 uint32_t i_handler_type
; /* "vide" "soun" "hint" "odsm"
338 "crsm" "sdsm" "m7sm" "ocsm"
341 unsigned char *psz_name
; /* in UTF-8 */
343 } MP4_Box_data_hdlr_t
;
345 typedef struct MP4_Box_data_vmhd_s
350 int16_t i_graphics_mode
;
351 int16_t i_opcolor
[3];
353 } MP4_Box_data_vmhd_t
;
355 typedef struct MP4_Box_data_smhd_s
363 } MP4_Box_data_smhd_t
;
365 typedef struct MP4_Box_data_hmhd_s
370 uint16_t i_max_PDU_size
;
371 uint16_t i_avg_PDU_size
;
372 uint32_t i_max_bitrate
;
373 uint32_t i_avg_bitrate
;
376 } MP4_Box_data_hmhd_t
;
378 typedef struct MP4_Box_data_url_s
385 } MP4_Box_data_url_t
;
387 typedef struct MP4_Box_data_urn_s
395 } MP4_Box_data_urn_t
;
397 typedef struct MP4_Box_data_dref_s
402 uint32_t i_entry_count
;
403 /* XXX it's also a container with i_entry_count entry */
404 } MP4_Box_data_dref_t
;
406 typedef struct MP4_Box_data_stts_s
411 uint32_t i_entry_count
;
412 uint32_t *i_sample_count
; /* these are array */
413 int32_t *i_sample_delta
;
415 } MP4_Box_data_stts_t
;
417 typedef struct MP4_Box_data_ctts_s
422 uint32_t i_entry_count
;
424 uint32_t *i_sample_count
; /* these are array */
425 int32_t *i_sample_offset
;
427 } MP4_Box_data_ctts_t
;
430 typedef struct MP4_Box_data_sample_soun_s
432 uint8_t i_reserved1
[6];
433 uint16_t i_data_reference_index
;
435 //uint32_t i_reserved2[2];
436 uint16_t i_qt_version
;
437 uint16_t i_qt_revision_level
;
438 uint32_t i_qt_vendor
;
440 uint16_t i_channelcount
;
441 uint16_t i_samplesize
;
442 uint16_t i_predefined
;
443 uint16_t i_reserved3
;
444 uint16_t i_sampleratehi
; /* timescale of track */
445 uint16_t i_sampleratelo
;
447 /* for version 1 (i_reserved1[0] == 1) */
448 uint32_t i_sample_per_packet
;
449 uint32_t i_bytes_per_packet
;
450 uint32_t i_bytes_per_frame
;
451 uint32_t i_bytes_per_sample
;
454 int i_qt_description
;
455 uint8_t *p_qt_description
;
459 } MP4_Box_data_sample_soun_t
;
461 typedef struct MP4_Box_data_sample_vide_s
463 uint8_t i_reserved1
[6];
464 uint16_t i_data_reference_index
;
466 uint16_t i_qt_version
;
467 uint16_t i_qt_revision_level
;
468 uint32_t i_qt_vendor
;
470 uint32_t i_qt_temporal_quality
;
471 uint32_t i_qt_spatial_quality
;
476 uint32_t i_horizresolution
;
477 uint32_t i_vertresolution
;
479 uint32_t i_qt_data_size
;
480 uint16_t i_qt_frame_count
;
482 uint8_t i_compressorname
[32];
485 int16_t i_qt_color_table
;
487 /* XXX hack ImageDescription */
488 int i_qt_image_description
;
489 uint8_t *p_qt_image_description
;
493 } MP4_Box_data_sample_vide_t
;
495 #define MP4_TEXT_DISPLAY_FLAG_DONT_DISPLAY (1<<0)
496 #define MP4_TEXT_DISPLAY_FLAG_AUTO_SCALE (1<<1)
497 #define MP4_TEXT_DISPLAY_FLAG_CLIP_TO_TEXT_BOX (1<<2)
498 #define MP4_TEXT_DISPLAY_FLAG_USE_MOVIE_BG_COLOR (1<<3)
499 #define MP4_TEXT_DISPLAY_FLAG_SHRINK_TEXT_BOX_TO_FIT (1<<4)
500 #define MP4_TEXT_DISPLAY_FLAG_SCROLL_IN (1<<5)
501 #define MP4_TEXT_DISPLAY_FLAG_SCROLL_OUT (1<<6)
502 #define MP4_TEXT_DISPLAY_FLAG_HORIZONTAL_SCROLL (1<<7)
503 #define MP4_TEXT_DISPLAY_FLAG_REVERSE_SCROLL (1<<8)
504 #define MP4_TEXT_DISPLAY_FLAG_CONTINUOUS_SCROLL (1<<9)
505 #define MP4_TEXT_DISPLAY_FLAG_FLOW_HORIZONTAL (1<<10)
506 #define MP4_TEXT_DISPLAY_FLAG_CONTINUOUS_KARAOKE (1<<11)
507 #define MP4_TEXT_DISPLAY_FLAG_DROP_SHADOW (1<<12)
508 #define MP4_TEXT_DISPLAY_FLAG_ANTI_ALIAS (1<<13)
509 #define MP4_TEXT_DISPLAY_FLAG_KEYED_TEXT (1<<14)
510 #define MP4_TEXT_DISPLAY_FLAG_INVERSE_HILITE (1<<15)
511 #define MP4_TEXT_DISPLAY_FLAG_COLOR_HILITE (1<<16)
512 #define MP4_TEXT_DISPLAY_FLAG_WRITE_VERTICALLY (1<<17)
516 uint32_t i_reserved1
;
517 uint16_t i_reserved2
;
519 uint16_t i_data_reference_index
;
521 uint32_t i_display_flags
; // TextDescription and Tx3gDescription
523 int8_t i_justification_horizontal
; // left(0), centered(1), right(-1)
524 int8_t i_justification_vertical
; // top(0), centered(1), bottom(-1)
526 uint16_t i_background_color
[4];
528 uint16_t i_text_box_top
;
529 uint16_t i_text_box_left
;
530 uint16_t i_text_box_bottom
;
531 uint16_t i_text_box_right
;
534 } MP4_Box_data_sample_text_t
;
536 typedef struct MP4_Box_data_sample_hint_s
538 uint8_t i_reserved1
[6];
539 uint16_t i_data_reference_index
;
543 } MP4_Box_data_sample_hint_t
;
545 typedef struct MP4_Box_data_moviehintinformation_rtp_s
547 uint32_t i_description_format
;
548 unsigned char *psz_text
;
550 } MP4_Box_data_moviehintinformation_rtp_t
;
554 typedef struct MP4_Box_data_stsd_s
559 uint32_t i_entry_count
;
561 /* it contains SampleEntry handled as if it was Box */
563 } MP4_Box_data_stsd_t
;
566 typedef struct MP4_Box_data_stsz_s
571 uint32_t i_sample_size
;
572 uint32_t i_sample_count
;
574 uint32_t *i_entry_size
; /* array , empty if i_sample_size != 0 */
576 } MP4_Box_data_stsz_t
;
578 typedef struct MP4_Box_data_stz2_s
583 uint32_t i_sample_size
; /* 24 bits */
584 uint8_t i_field_size
;
585 uint32_t i_sample_count
;
587 uint32_t *i_entry_size
; /* array: unsigned int(i_field_size) entry_size */
589 } MP4_Box_data_stz2_t
;
591 typedef struct MP4_Box_data_stsc_s
596 uint32_t i_entry_count
;
598 uint32_t *i_first_chunk
; /* theses are arrays */
599 uint32_t *i_samples_per_chunk
;
600 uint32_t *i_sample_description_index
;
602 } MP4_Box_data_stsc_t
;
605 typedef struct MP4_Box_data_co64_s
610 uint32_t i_entry_count
;
612 uint64_t *i_chunk_offset
;
614 } MP4_Box_data_co64_t
;
617 typedef struct MP4_Box_data_stss_s
622 uint32_t i_entry_count
;
624 uint32_t *i_sample_number
;
626 } MP4_Box_data_stss_t
;
628 typedef struct MP4_Box_data_stsh_s
633 uint32_t i_entry_count
;
635 uint32_t *i_shadowed_sample_number
;
636 uint32_t *i_sync_sample_number
;
638 } MP4_Box_data_stsh_t
;
640 typedef struct MP4_Box_data_stdp_s
645 uint16_t *i_priority
;
647 } MP4_Box_data_stdp_t
;
649 typedef struct MP4_Box_data_padb_s
654 uint32_t i_sample_count
;
656 uint16_t *i_reserved1
; /* 1bit */
657 uint16_t *i_pad2
; /* 3bits */
658 uint16_t *i_reserved2
; /* 1bit */
659 uint16_t *i_pad1
; /* 3bits */
662 } MP4_Box_data_padb_t
;
665 typedef struct MP4_Box_data_elst_s
670 uint32_t i_entry_count
;
672 uint64_t *i_segment_duration
;
673 int64_t *i_media_time
;
674 uint16_t *i_media_rate_integer
;
675 uint16_t *i_media_rate_fraction
;
678 } MP4_Box_data_elst_t
;
680 typedef struct MP4_Box_data_cprt_s
685 unsigned char i_language
[3];
688 } MP4_Box_data_cprt_t
;
691 /* DecoderConfigDescriptor */
692 typedef struct MP4_descriptor_decoder_config_s
694 uint8_t i_objectTypeIndication
;
695 uint8_t i_streamType
;
701 int i_decoder_specific_info_len
;
702 uint8_t *p_decoder_specific_info
;
703 /* some other stuff */
705 } MP4_descriptor_decoder_config_t
;
707 typedef struct MP4_descriptor_SL_config_s
710 int i_dummy
; /* ANSI C forbids empty structures */
712 } MP4_descriptor_SL_config_t
;
715 typedef struct MP4_descriptor_ES_s
718 int b_stream_dependence
;
721 int i_stream_priority
;
723 int i_depend_on_ES_ID
; /* if b_stream_dependence set */
725 unsigned char *psz_URL
;
727 uint16_t i_OCR_ES_ID
; /* if b_OCRstream */
728 MP4_descriptor_decoder_config_t
*p_decConfigDescr
;
730 MP4_descriptor_SL_config_t
*p_slConfigDescr
;
732 /* some other stuff ... */
734 } MP4_descriptor_ES_t
;
737 typedef struct MP4_Box_data_esds_s
742 MP4_descriptor_ES_t es_descriptor
;
744 } MP4_Box_data_esds_t
;
747 typedef struct MP4_Box_data_dcom_s
749 uint32_t i_algorithm
; /* fourcc */
751 } MP4_Box_data_dcom_t
;
753 typedef struct MP4_Box_data_cmvd_s
755 uint32_t i_uncompressed_size
;
756 uint32_t i_compressed_size
;
758 int b_compressed
; /* Set to 1 if compressed data, 0 if uncompressed */
761 } MP4_Box_data_cmvd_t
;
763 typedef struct MP4_Box_data_cmov_s
765 struct MP4_Box_s
*p_moov
; /* uncompressed moov */
767 } MP4_Box_data_cmov_t
;
772 } MP4_Box_data_frma_t
;
779 } MP4_Box_data_skcr_t
;
789 } MP4_Box_data_rdrf_t
;
798 } MP4_Box_data_rmdr_t
;
805 uint32_t i_gestaltType
;
808 uint16_t i_checkType
; /* 0: val1 is version min
809 1: gestalt value & val2 == val1 */
811 } MP4_Box_data_rmvc_t
;
819 } MP4_Box_data_rmcd_t
;
825 } MP4_Box_data_rmqu_t
;
827 typedef struct MP4_Box_data_mfhd_s
829 uint32_t i_sequence_number
;
831 uint8_t *p_vendor_extension
;
833 } MP4_Box_data_mfhd_t
;
835 #define MP4_TFHD_BASE_DATA_OFFSET (1LL<<0)
836 #define MP4_TFHD_SAMPLE_DESC_INDEX (1LL<<1)
837 #define MP4_TFHD_DFLT_SAMPLE_DURATION (1LL<<3)
838 #define MP4_TFHD_DFLT_SAMPLE_SIZE (1LL<<4)
839 #define MP4_TFHD_DFLT_SAMPLE_FLAGS (1LL<<5)
840 typedef struct MP4_Box_data_tfhd_s
846 /* optional fields */
847 uint64_t i_base_data_offset
;
848 uint32_t i_sample_description_index
;
849 uint32_t i_default_sample_duration
;
850 uint32_t i_default_sample_size
;
851 uint32_t i_default_sample_flags
;
853 } MP4_Box_data_tfhd_t
;
855 #define MP4_TRUN_DATA_OFFSET (1<<0)
856 #define MP4_TRUN_FIRST_FLAGS (1<<2)
857 #define MP4_TRUN_SAMPLE_DURATION (1<<8)
858 #define MP4_TRUN_SAMPLE_SIZE (1<<9)
859 #define MP4_TRUN_SAMPLE_FLAGS (1<<10)
860 #define MP4_TRUN_SAMPLE_TIME_OFFSET (1<<11)
861 typedef struct MP4_descriptor_trun_sample_t
866 uint32_t i_composition_time_offset
;
867 } MP4_descriptor_trun_sample_t
;
869 typedef struct MP4_Box_data_trun_s
873 uint32_t i_sample_count
;
875 /* optional fields */
876 uint32_t i_data_offset
;
877 uint32_t i_first_sample_flags
;
879 MP4_descriptor_trun_sample_t
*p_samples
;
881 } MP4_Box_data_trun_t
;
888 } MP4_Box_data_0xa9xxx_t
;
894 } MP4_Box_data_name_t
;
898 uint32_t i_entry_count
;
899 uint32_t *i_track_ID
;
901 } MP4_Box_data_tref_generic_t
;
914 } MP4_Box_data_chpl_t
;
920 uint8_t i_profile_compatibility
;
923 uint8_t i_reserved1
; /* 6 bits */
924 uint8_t i_length_size
;
926 uint8_t i_reserved2
; /* 3 bits */
928 uint16_t *i_sps_length
;
932 uint16_t *i_pps_length
;
935 /* XXX: Hack raw avcC atom payload */
939 } MP4_Box_data_avcC_t
;
948 uint8_t i_bitrate_code
;
950 } MP4_Box_data_dac3_t
;
954 uint16_t i_little_endian
;
956 } MP4_Box_data_enda_t
;
962 } MP4_Box_data_gnre_t
;
966 uint32_t i_track_number
;
967 uint32_t i_track_total
;
969 } MP4_Box_data_trkn_t
;
976 uint16_t i_object_descriptor
;
977 uint8_t i_OD_profile_level
;
978 uint8_t i_scene_profile_level
;
979 uint8_t i_audio_profile_level
;
980 uint8_t i_visual_profile_level
;
981 uint8_t i_graphics_profile_level
;
983 } MP4_Box_data_iods_t
;
987 uint32_t i_horizontal_spacing
;
988 uint32_t i_vertical_spacing
;
989 } MP4_Box_data_pasp_t
;
992 typedef struct MP4_Box_data__s
1001 typedef union MP4_Box_data_s
1003 MP4_Box_data_ftyp_t
*p_ftyp
;
1004 MP4_Box_data_mvhd_t
*p_mvhd
;
1005 MP4_Box_data_mfhd_t
*p_mfhd
;
1006 MP4_Box_data_tfhd_t
*p_tfhd
;
1007 MP4_Box_data_trun_t
*p_trun
;
1008 MP4_Box_data_tkhd_t
*p_tkhd
;
1009 MP4_Box_data_mdhd_t
*p_mdhd
;
1010 MP4_Box_data_hdlr_t
*p_hdlr
;
1011 MP4_Box_data_vmhd_t
*p_vmhd
;
1012 MP4_Box_data_smhd_t
*p_smhd
;
1013 MP4_Box_data_hmhd_t
*p_hmhd
;
1014 MP4_Box_data_url_t
*p_url
;
1015 MP4_Box_data_urn_t
*p_urn
;
1016 MP4_Box_data_dref_t
*p_dref
;
1017 MP4_Box_data_stts_t
*p_stts
;
1018 MP4_Box_data_ctts_t
*p_ctts
;
1019 MP4_Box_data_stsd_t
*p_stsd
;
1020 MP4_Box_data_sample_vide_t
*p_sample_vide
;
1021 MP4_Box_data_sample_soun_t
*p_sample_soun
;
1022 MP4_Box_data_sample_text_t
*p_sample_text
;
1023 MP4_Box_data_sample_hint_t
*p_sample_hint
;
1025 MP4_Box_data_esds_t
*p_esds
;
1026 MP4_Box_data_avcC_t
*p_avcC
;
1027 MP4_Box_data_dac3_t
*p_dac3
;
1028 MP4_Box_data_enda_t
*p_enda
;
1029 MP4_Box_data_gnre_t
*p_gnre
;
1030 MP4_Box_data_trkn_t
*p_trkn
;
1031 MP4_Box_data_iods_t
*p_iods
;
1032 MP4_Box_data_pasp_t
*p_pasp
;
1034 MP4_Box_data_stsz_t
*p_stsz
;
1035 MP4_Box_data_stz2_t
*p_stz2
;
1036 MP4_Box_data_stsc_t
*p_stsc
;
1037 MP4_Box_data_co64_t
*p_co64
;
1038 MP4_Box_data_stss_t
*p_stss
;
1039 MP4_Box_data_stsh_t
*p_stsh
;
1040 MP4_Box_data_stdp_t
*p_stdp
;
1041 MP4_Box_data_padb_t
*p_padb
;
1042 MP4_Box_data_elst_t
*p_elst
;
1043 MP4_Box_data_cprt_t
*p_cprt
;
1045 MP4_Box_data_dcom_t
*p_dcom
;
1046 MP4_Box_data_cmvd_t
*p_cmvd
;
1047 MP4_Box_data_cmov_t
*p_cmov
;
1049 MP4_Box_data_moviehintinformation_rtp_t p_moviehintinformation_rtp
;
1051 MP4_Box_data_frma_t
*p_frma
;
1052 MP4_Box_data_skcr_t
*p_skcr
;
1054 MP4_Box_data_rdrf_t
*p_rdrf
;
1055 MP4_Box_data_rmdr_t
*p_rmdr
;
1056 MP4_Box_data_rmqu_t
*p_rmqu
;
1057 MP4_Box_data_rmvc_t
*p_rmvc
;
1059 MP4_Box_data_0xa9xxx_t
*p_0xa9xxx
;
1060 MP4_Box_data_chpl_t
*p_chpl
;
1061 MP4_Box_data_tref_generic_t
*p_tref_generic
;
1062 MP4_Box_data_name_t
*p_name
;
1064 void *p_data
; /* for unknow type */
1069 /* the most basic structure */
1070 typedef struct MP4_Box_s
1072 off_t i_pos
; /* absolute position */
1075 uint32_t i_shortsize
;
1077 UUID_t i_uuid
; /* Set if i_type == "uuid" */
1079 uint64_t i_size
; /* always set so use it */
1081 MP4_Box_data_t data
; /* union of pointers on extended data depending
1082 on i_type (or i_usertype) */
1084 struct MP4_Box_s
*p_father
; /* pointer on the father Box */
1086 struct MP4_Box_s
*p_first
; /* pointer on the first child Box */
1087 struct MP4_Box_s
*p_last
;
1089 struct MP4_Box_s
*p_next
; /* pointer on the next boxes at the same level */
1095 /*****************************************************************************
1096 * MP4_BoxGetRoot : Parse the entire file, and create all boxes in memory
1097 *****************************************************************************
1098 * The first box is a virtual box "root" and is the father for all first
1100 *****************************************************************************/
1101 MP4_Box_t
*MP4_BoxGetRoot( stream_t
* );
1103 /*****************************************************************************
1104 * MP4_FreeBox : free memory allocated after read with MP4_ReadBox
1105 * or MP4_BoxGetRoot, this means also children boxes
1106 * XXX : all children have to be allocated by a malloc !! and
1108 *****************************************************************************/
1109 void MP4_BoxFree( stream_t
*, MP4_Box_t
*p_box
);
1111 /*****************************************************************************
1112 * MP4_DumpBoxStructure: print the structure of the p_box
1113 *****************************************************************************
1114 * Useful while debugging
1115 *****************************************************************************/
1116 void MP4_BoxDumpStructure( stream_t
*p_input
, MP4_Box_t
*p_box
);
1118 /*****************************************************************************
1119 * MP4_BoxGet: find a box given a path relative to p_box
1120 *****************************************************************************
1121 * Path Format: . .. / as usual
1122 * [number] to specifie box number ex: trak[12]
1124 * ex: /moov/trak[12]
1126 *****************************************************************************/
1127 MP4_Box_t
*MP4_BoxGet( MP4_Box_t
*p_box
, const char *psz_fmt
, ... );
1129 /*****************************************************************************
1130 * MP4_BoxCount: find number of box given a path relative to p_box
1131 *****************************************************************************
1132 * Path Format: . .. / as usual
1133 * [number] to specifie box number ex: trak[12]
1137 *****************************************************************************/
1138 int MP4_BoxCount( MP4_Box_t
*p_box
, const char *psz_fmt
, ... );
1140 /* Internal functions exposed for MKV demux */
1141 int MP4_ReadBoxCommon( stream_t
*p_stream
, MP4_Box_t
*p_box
);
1142 int MP4_ReadBox_sample_vide( stream_t
*p_stream
, MP4_Box_t
*p_box
);
1143 void MP4_FreeBox_sample_vide( MP4_Box_t
*p_box
);