demux: mp4: support the 360 spherical video box
[vlc.git] / modules / demux / mp4 / libmp4.h
blobc72f85a797d7dcda6fb9c11dfa13e7cbd547496e
1 /*****************************************************************************
2 * libmp4.h : LibMP4 library for mp4 module for vlc
3 *****************************************************************************
4 * Copyright (C) 2001-2004, 2010 VLC authors and VideoLAN
6 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
22 #ifndef VLC_MP4_LIBMP4_H_
23 #define VLC_MP4_LIBMP4_H_
25 #include <vlc_es.h>
26 #include <vlc_codecs.h>
28 /* Use alias for scaled time */
29 typedef int64_t stime_t;
31 #define BLOCK16x16 (1<<16)
33 #define MAJOR_3gp4 VLC_FOURCC( '3', 'g', 'p', '4' )
34 #define MAJOR_3gp5 VLC_FOURCC( '3', 'g', 'p', '5' )
35 #define MAJOR_3gp6 VLC_FOURCC( '3', 'g', 'p', '6' )
36 #define MAJOR_3gp7 VLC_FOURCC( '3', 'g', 'p', '7' )
37 #define MAJOR_isml VLC_FOURCC( 'i', 's', 'm', 'l' )
38 #define MAJOR_isom VLC_FOURCC( 'i', 's', 'o', 'm' )
39 #define MAJOR_qt__ VLC_FOURCC( 'q', 't', ' ', ' ' )
40 #define MAJOR_dash VLC_FOURCC( 'd', 'a', 's', 'h' )
41 #define MAJOR_mp41 VLC_FOURCC( 'm', 'p', '4', '1' )
42 #define MAJOR_avc1 VLC_FOURCC( 'a', 'v', 'c', '1' )
44 #define ATOM_root VLC_FOURCC( 'r', 'o', 'o', 't' )
45 #define ATOM_uuid VLC_FOURCC( 'u', 'u', 'i', 'd' )
47 #define ATOM_ftyp VLC_FOURCC( 'f', 't', 'y', 'p' )
48 #define ATOM_moov VLC_FOURCC( 'm', 'o', 'o', 'v' )
49 #define ATOM_foov VLC_FOURCC( 'f', 'o', 'o', 'v' )
50 #define ATOM_cmov VLC_FOURCC( 'c', 'm', 'o', 'v' )
51 #define ATOM_dcom VLC_FOURCC( 'd', 'c', 'o', 'm' )
52 #define ATOM_cmvd VLC_FOURCC( 'c', 'm', 'v', 'd' )
54 #define ATOM_styp VLC_FOURCC( 's', 't', 'y', 'p' )
55 #define ATOM_moof VLC_FOURCC( 'm', 'o', 'o', 'f' )
56 #define ATOM_mdat VLC_FOURCC( 'm', 'd', 'a', 't' )
57 #define ATOM_skip VLC_FOURCC( 's', 'k', 'i', 'p' )
58 #define ATOM_free VLC_FOURCC( 'f', 'r', 'e', 'e' )
59 #define ATOM_udta VLC_FOURCC( 'u', 'd', 't', 'a' )
60 #define ATOM_wide VLC_FOURCC( 'w', 'i', 'd', 'e' )
61 #define ATOM_binm VLC_FOURCC( 0x82, 0x82, 0x7f, 0x7d ) /* binary Computer Graphics Metafile */
63 /* Quicktime preview */
64 #define ATOM_pnot VLC_FOURCC( 'p', 'n', 'o', 't' )
65 #define ATOM_pict VLC_FOURCC( 'p', 'i', 'c', 't' )
66 #define ATOM_PICT VLC_FOURCC( 'P', 'I', 'C', 'T' )
68 #define ATOM_data VLC_FOURCC( 'd', 'a', 't', 'a' )
70 #define ATOM_trak VLC_FOURCC( 't', 'r', 'a', 'k' )
71 #define ATOM_mvhd VLC_FOURCC( 'm', 'v', 'h', 'd' )
72 #define ATOM_tkhd VLC_FOURCC( 't', 'k', 'h', 'd' )
73 #define ATOM_tref VLC_FOURCC( 't', 'r', 'e', 'f' )
74 #define ATOM_load VLC_FOURCC( 'l', 'o', 'a', 'd' )
75 #define ATOM_mdia VLC_FOURCC( 'm', 'd', 'i', 'a' )
76 #define ATOM_mdhd VLC_FOURCC( 'm', 'd', 'h', 'd' )
77 #define ATOM_hdlr VLC_FOURCC( 'h', 'd', 'l', 'r' )
78 #define ATOM_minf VLC_FOURCC( 'm', 'i', 'n', 'f' )
79 #define ATOM_vmhd VLC_FOURCC( 'v', 'm', 'h', 'd' )
80 #define ATOM_smhd VLC_FOURCC( 's', 'm', 'h', 'd' )
81 #define ATOM_hmhd VLC_FOURCC( 'h', 'm', 'h', 'd' )
82 #define ATOM_dinf VLC_FOURCC( 'd', 'i', 'n', 'f' )
83 #define ATOM_url VLC_FOURCC( 'u', 'r', 'l', ' ' )
84 #define ATOM_urn VLC_FOURCC( 'u', 'r', 'n', ' ' )
85 #define ATOM_dref VLC_FOURCC( 'd', 'r', 'e', 'f' )
86 #define ATOM_stbl VLC_FOURCC( 's', 't', 'b', 'l' )
87 #define ATOM_stts VLC_FOURCC( 's', 't', 't', 's' )
88 #define ATOM_ctts VLC_FOURCC( 'c', 't', 't', 's' )
89 #define ATOM_stsd VLC_FOURCC( 's', 't', 's', 'd' )
90 #define ATOM_stsz VLC_FOURCC( 's', 't', 's', 'z' )
91 #define ATOM_stz2 VLC_FOURCC( 's', 't', 'z', '2' )
92 #define ATOM_stsc VLC_FOURCC( 's', 't', 's', 'c' )
93 #define ATOM_stco VLC_FOURCC( 's', 't', 'c', 'o' )
94 #define ATOM_co64 VLC_FOURCC( 'c', 'o', '6', '4' )
95 #define ATOM_sbgp VLC_FOURCC( 's', 'b', 'g', 'p' )
96 #define ATOM_sgpd VLC_FOURCC( 's', 'g', 'p', 'd' )
97 #define ATOM_stss VLC_FOURCC( 's', 't', 's', 's' )
98 #define ATOM_stsh VLC_FOURCC( 's', 't', 's', 'h' )
99 #define ATOM_stdp VLC_FOURCC( 's', 't', 'd', 'p' )
100 #define ATOM_padb VLC_FOURCC( 'p', 'a', 'd', 'b' )
101 #define ATOM_edts VLC_FOURCC( 'e', 'd', 't', 's' )
102 #define ATOM_elst VLC_FOURCC( 'e', 'l', 's', 't' )
103 #define ATOM_mvex VLC_FOURCC( 'm', 'v', 'e', 'x' )
104 #define ATOM_sdtp VLC_FOURCC( 's', 'd', 't', 'p' )
105 #define ATOM_trex VLC_FOURCC( 't', 'r', 'e', 'x' )
106 #define ATOM_mehd VLC_FOURCC( 'm', 'e', 'h', 'd' )
107 #define ATOM_mfhd VLC_FOURCC( 'm', 'f', 'h', 'd' )
108 #define ATOM_traf VLC_FOURCC( 't', 'r', 'a', 'f' )
109 #define ATOM_sidx VLC_FOURCC( 's', 'i', 'd', 'x' )
110 #define ATOM_tfhd VLC_FOURCC( 't', 'f', 'h', 'd' )
111 #define ATOM_tfdt VLC_FOURCC( 't', 'f', 'd', 't' )
112 #define ATOM_trun VLC_FOURCC( 't', 'r', 'u', 'n' )
113 #define ATOM_cprt VLC_FOURCC( 'c', 'p', 'r', 't' )
114 #define ATOM_iods VLC_FOURCC( 'i', 'o', 'd', 's' )
115 #define ATOM_pasp VLC_FOURCC( 'p', 'a', 's', 'p' )
116 #define ATOM_mfra VLC_FOURCC( 'm', 'f', 'r', 'a' )
117 #define ATOM_mfro VLC_FOURCC( 'm', 'f', 'r', 'o' )
118 #define ATOM_tfra VLC_FOURCC( 't', 'f', 'r', 'a' )
119 #define ATOM_keys VLC_FOURCC( 'k', 'e', 'y', 's' )
121 #define ATOM_nmhd VLC_FOURCC( 'n', 'm', 'h', 'd' )
122 #define ATOM_mp2v VLC_FOURCC( 'm', 'p', '2', 'v' )
123 #define ATOM_mp4v VLC_FOURCC( 'm', 'p', '4', 'v' )
124 #define ATOM_mp4a VLC_FOURCC( 'm', 'p', '4', 'a' )
125 #define ATOM_mp4s VLC_FOURCC( 'm', 'p', '4', 's' )
126 #define ATOM_vide VLC_FOURCC( 'v', 'i', 'd', 'e' )
127 #define ATOM_soun VLC_FOURCC( 's', 'o', 'u', 'n' )
128 #define ATOM_hint VLC_FOURCC( 'h', 'i', 'n', 't' )
129 #define ATOM_hdv2 VLC_FOURCC( 'h', 'd', 'v', '2' )
130 #define ATOM_rrtp VLC_FOURCC( 'r', 'r', 't', 'p' )
132 #define ATOM_dpnd VLC_FOURCC( 'd', 'p', 'n', 'd' )
133 #define ATOM_cdsc VLC_FOURCC( 'c', 'd', 's', 'c' )
134 #define ATOM_ipir VLC_FOURCC( 'i', 'p', 'i', 'r' )
135 #define ATOM_mpod VLC_FOURCC( 'm', 'p', 'o', 'd' )
136 #define ATOM_hnti VLC_FOURCC( 'h', 'n', 't', 'i' )
137 #define ATOM_rtp VLC_FOURCC( 'r', 't', 'p', ' ' )
138 #define ATOM_btrt VLC_FOURCC( 'b', 't', 'r', 't' )
139 #define ATOM_sdp VLC_FOURCC( 's', 'd', 'p', ' ' )
141 #define ATOM_tims VLC_FOURCC( 't', 'i', 'm', 's' )
142 #define ATOM_tsro VLC_FOURCC( 't', 's', 'r', 'o' )
143 #define ATOM_tssy VLC_FOURCC( 't', 's', 's', 'y' )
145 #define ATOM_esds VLC_FOURCC( 'e', 's', 'd', 's' )
147 #define ATOM_lpcm VLC_FOURCC( 'l', 'p', 'c', 'm' )
148 #define ATOM__mp3 VLC_FOURCC( '.', 'm', 'p', '3' )
149 #define ATOM_ms02 VLC_FOURCC( 'm', 's', 0x0, 0x02 )
150 #define ATOM_ms11 VLC_FOURCC( 'm', 's', 0x0, 0x11 )
151 #define ATOM_ms55 VLC_FOURCC( 'm', 's', 0x0, 0x55 )
152 #define ATOM_twos VLC_FOURCC( 't', 'w', 'o', 's' )
153 #define ATOM_sowt VLC_FOURCC( 's', 'o', 'w', 't' )
154 #define ATOM_QDMC VLC_FOURCC( 'Q', 'D', 'M', 'C' )
155 #define ATOM_QDM2 VLC_FOURCC( 'Q', 'D', 'M', '2' )
156 #define ATOM_XiFL VLC_FOURCC( 'X', 'i', 'F', 'L' )
157 #define ATOM_XiVs VLC_FOURCC( 'X', 'i', 'V', 's' )
158 #define ATOM_ima4 VLC_FOURCC( 'i', 'm', 'a', '4' )
159 #define ATOM_IMA4 VLC_FOURCC( 'I', 'M', 'A', '4' )
160 #define ATOM_dvi VLC_FOURCC( 'd', 'v', 'i', ' ' )
161 #define ATOM_MAC3 VLC_FOURCC( 'M', 'A', 'C', '3' )
162 #define ATOM_MAC6 VLC_FOURCC( 'M', 'A', 'C', '6' )
163 #define ATOM_alaw VLC_FOURCC( 'a', 'l', 'a', 'w' )
164 #define ATOM_ulaw VLC_FOURCC( 'u', 'l', 'a', 'w' )
165 #define ATOM_Qclp VLC_FOURCC( 'Q', 'c', 'l', 'p' )
166 #define ATOM_samr VLC_FOURCC( 's', 'a', 'm', 'r' )
167 #define ATOM_sawb VLC_FOURCC( 's', 'a', 'w', 'b' )
168 #define ATOM_OggS VLC_FOURCC( 'O', 'g', 'g', 'S' )
169 #define ATOM_agsm VLC_FOURCC( 'a', 'g', 's', 'm' )
170 #define ATOM_alac VLC_FOURCC( 'a', 'l', 'a', 'c' )
171 #define ATOM_ac3 VLC_FOURCC( 'a', 'c', '-', '3' )
172 #define ATOM_eac3 VLC_FOURCC( 'e', 'c', '-', '3' )
173 #define ATOM_dac3 VLC_FOURCC( 'd', 'a', 'c', '3' )
174 #define ATOM_dec3 VLC_FOURCC( 'd', 'e', 'c', '3' )
175 #define ATOM_vc1 VLC_FOURCC( 'v', 'c', '-', '1' )
176 #define ATOM_dvc1 VLC_FOURCC( 'd', 'v', 'c', '1' )
177 #define ATOM_WMA2 VLC_FOURCC( 'W', 'M', 'A', '2' )
178 #define ATOM_wma VLC_FOURCC( 'w', 'm', 'a', ' ' )
179 #define ATOM_enda VLC_FOURCC( 'e', 'n', 'd', 'a' )
180 #define ATOM_gnre VLC_FOURCC( 'g', 'n', 'r', 'e' )
181 #define ATOM_trkn VLC_FOURCC( 't', 'r', 'k', 'n' )
182 #define ATOM_chan VLC_FOURCC( 'c', 'h', 'a', 'n' )
183 #define ATOM_in24 VLC_FOURCC( 'i', 'n', '2', '4' )
184 #define ATOM_in32 VLC_FOURCC( 'i', 'n', '3', '2' )
185 #define ATOM_fl32 VLC_FOURCC( 'f', 'l', '3', '2' )
186 #define ATOM_fl64 VLC_FOURCC( 'f', 'l', '6', '4' )
187 #define ATOM_Opus VLC_FOURCC( 'O', 'p', 'u', 's' )
189 /* XiphQT */
190 #define ATOM_fCtS VLC_FOURCC( 'f', 'C', 't', 'S' )
191 #define ATOM_vCtH VLC_FOURCC( 'v', 'C', 't', 'H' )
192 #define ATOM_vCtC VLC_FOURCC( 'v', 'C', 't', 'C' )
193 #define ATOM_vCtd VLC_FOURCC( 'v', 'C', 't', '#' )
195 #define ATOM_zlib VLC_FOURCC( 'z', 'l', 'i', 'b' )
196 #define ATOM_SVQ1 VLC_FOURCC( 'S', 'V', 'Q', '1' )
197 #define ATOM_SVQ3 VLC_FOURCC( 'S', 'V', 'Q', '3' )
198 #define ATOM_ZyGo VLC_FOURCC( 'Z', 'y', 'G', 'o' )
199 #define ATOM_3IV1 VLC_FOURCC( '3', 'I', 'V', '1' )
200 #define ATOM_3iv1 VLC_FOURCC( '3', 'i', 'v', '1' )
201 #define ATOM_3IV2 VLC_FOURCC( '3', 'I', 'V', '2' )
202 #define ATOM_3iv2 VLC_FOURCC( '3', 'i', 'v', '2' )
203 #define ATOM_3IVD VLC_FOURCC( '3', 'I', 'V', 'D' )
204 #define ATOM_3ivd VLC_FOURCC( '3', 'i', 'v', 'd' )
205 #define ATOM_3VID VLC_FOURCC( '3', 'V', 'I', 'D' )
206 #define ATOM_3vid VLC_FOURCC( '3', 'v', 'i', 'd' )
207 #define ATOM_FFV1 VLC_FOURCC( 'F', 'F', 'V', '1' )
208 #define ATOM_h263 VLC_FOURCC( 'h', '2', '6', '3' )
209 #define ATOM_s263 VLC_FOURCC( 's', '2', '6', '3' )
210 #define ATOM_DIVX VLC_FOURCC( 'D', 'I', 'V', 'X' )
211 #define ATOM_XVID VLC_FOURCC( 'X', 'V', 'I', 'D' )
212 #define ATOM_cvid VLC_FOURCC( 'c', 'v', 'i', 'd' )
213 #define ATOM_mjpa VLC_FOURCC( 'm', 'j', 'p', 'a' )
214 #define ATOM_mjpb VLC_FOURCC( 'm', 'j', 'q', 't' )
215 #define ATOM_mjqt VLC_FOURCC( 'm', 'j', 'h', 't' )
216 #define ATOM_mjht VLC_FOURCC( 'm', 'j', 'p', 'b' )
217 #define ATOM_VP31 VLC_FOURCC( 'V', 'P', '3', '1' )
218 #define ATOM_vp31 VLC_FOURCC( 'v', 'p', '3', '1' )
219 #define ATOM_h264 VLC_FOURCC( 'h', '2', '6', '4' )
220 #define ATOM_qdrw VLC_FOURCC( 'q', 'd', 'r', 'w' )
221 #define ATOM_vp08 VLC_FOURCC( 'v', 'p', '0', '8' )
222 #define ATOM_vp09 VLC_FOURCC( 'v', 'p', '0', '9' )
223 #define ATOM_vp10 VLC_FOURCC( 'v', 'p', '1', '0' )
224 #define ATOM_WMV3 VLC_FOURCC( 'W', 'M', 'V', '3' )
226 #define ATOM_avc1 VLC_FOURCC( 'a', 'v', 'c', '1' )
227 #define ATOM_avc3 VLC_FOURCC( 'a', 'v', 'c', '3' )
228 #define ATOM_avcC VLC_FOURCC( 'a', 'v', 'c', 'C' )
229 #define ATOM_vpcC VLC_FOURCC( 'v', 'p', 'c', 'C' )
230 #define ATOM_m4ds VLC_FOURCC( 'm', '4', 'd', 's' )
232 #define ATOM_fiel VLC_FOURCC( 'f', 'i', 'e', 'l' )
233 #define ATOM_glbl VLC_FOURCC( 'g', 'l', 'b', 'l' )
234 #define ATOM_hvcC VLC_FOURCC( 'h', 'v', 'c', 'C' )
236 #define ATOM_dvc VLC_FOURCC( 'd', 'v', 'c', ' ' )
237 #define ATOM_dvp VLC_FOURCC( 'd', 'v', 'p', ' ' )
238 #define ATOM_dv5n VLC_FOURCC( 'd', 'v', '5', 'n' )
239 #define ATOM_dv5p VLC_FOURCC( 'd', 'v', '5', 'p' )
240 #define ATOM_raw VLC_FOURCC( 'r', 'a', 'w', ' ' )
241 #define ATOM_dOps VLC_FOURCC( 'd', 'O', 'p', 's' )
242 #define ATOM_wfex VLC_FOURCC( 'w', 'f', 'e', 'x' )
244 #define ATOM_jpeg VLC_FOURCC( 'j', 'p', 'e', 'g' )
246 #define ATOM_yv12 VLC_FOURCC( 'y', 'v', '1', '2' )
247 #define ATOM_yuv2 VLC_FOURCC( 'y', 'u', 'v', '2' )
249 #define ATOM_rmra VLC_FOURCC( 'r', 'm', 'r', 'a' )
250 #define ATOM_rmda VLC_FOURCC( 'r', 'm', 'd', 'a' )
251 #define ATOM_rdrf VLC_FOURCC( 'r', 'd', 'r', 'f' )
252 #define ATOM_rmdr VLC_FOURCC( 'r', 'm', 'd', 'r' )
253 #define ATOM_rmvc VLC_FOURCC( 'r', 'm', 'v', 'c' )
254 #define ATOM_rmcd VLC_FOURCC( 'r', 'm', 'c', 'd' )
255 #define ATOM_rmqu VLC_FOURCC( 'r', 'm', 'q', 'u' )
256 #define ATOM_alis VLC_FOURCC( 'a', 'l', 'i', 's' )
258 #define ATOM_gmhd VLC_FOURCC( 'g', 'm', 'h', 'd' )
259 #define ATOM_wave VLC_FOURCC( 'w', 'a', 'v', 'e' )
260 #define ATOM_strf VLC_FOURCC( 's', 't', 'r', 'f' )
262 #define ATOM_drms VLC_FOURCC( 'd', 'r', 'm', 's' )
263 #define ATOM_sinf VLC_FOURCC( 's', 'i', 'n', 'f' )
264 #define ATOM_schi VLC_FOURCC( 's', 'c', 'h', 'i' )
265 #define ATOM_user VLC_FOURCC( 'u', 's', 'e', 'r' )
266 #define ATOM_key VLC_FOURCC( 'k', 'e', 'y', ' ' )
267 #define ATOM_iviv VLC_FOURCC( 'i', 'v', 'i', 'v' )
268 #define ATOM_name VLC_FOURCC( 'n', 'a', 'm', 'e' )
269 #define ATOM_priv VLC_FOURCC( 'p', 'r', 'i', 'v' )
270 #define ATOM_drmi VLC_FOURCC( 'd', 'r', 'm', 'i' )
271 #define ATOM_frma VLC_FOURCC( 'f', 'r', 'm', 'a' )
272 #define ATOM_skcr VLC_FOURCC( 's', 'k', 'c', 'r' )
273 #define ATOM_ASF VLC_FOURCC( 'A', 'S', 'F', ' ' )
275 #define ATOM_text VLC_FOURCC( 't', 'e', 'x', 't' )
276 #define ATOM_tx3g VLC_FOURCC( 't', 'x', '3', 'g' )
277 #define ATOM_subp VLC_FOURCC( 's', 'u', 'b', 'p' )
278 #define ATOM_sbtl VLC_FOURCC( 's', 'b', 't', 'l' )
279 #define ATOM_clcp VLC_FOURCC( 'c', 'l', 'c', 'p' )
280 #define ATOM_c608 VLC_FOURCC( 'c', '6', '0', '8' )
281 #define ATOM_c708 VLC_FOURCC( 'c', '7', '0', '8' )
283 #define ATOM_0xa9nam VLC_FOURCC( 0xa9, 'n', 'a', 'm' )
284 #define ATOM_0xa9aut VLC_FOURCC( 0xa9, 'a', 'u', 't' )
285 #define ATOM_0xa9cpy VLC_FOURCC( 0xa9, 'c', 'p', 'y' )
286 #define ATOM_0xa9inf VLC_FOURCC( 0xa9, 'i', 'n', 'f' )
287 #define ATOM_0xa9isr VLC_FOURCC( 0xa9, 'i', 's', 'r' )
288 #define ATOM_0xa9lab VLC_FOURCC( 0xa9, 'l', 'a', 'b' )
289 #define ATOM_0xa9lal VLC_FOURCC( 0xa9, 'l', 'a', 'l' )
290 #define ATOM_0xa9ART VLC_FOURCC( 0xa9, 'A', 'R', 'T' )
291 #define ATOM_0xa9des VLC_FOURCC( 0xa9, 'd', 'e', 's' )
292 #define ATOM_0xa9dir VLC_FOURCC( 0xa9, 'd', 'i', 'r' )
293 #define ATOM_0xa9cmt VLC_FOURCC( 0xa9, 'c', 'm', 't' )
294 #define ATOM_0xa9req VLC_FOURCC( 0xa9, 'r', 'e', 'q' )
295 #define ATOM_0xa9day VLC_FOURCC( 0xa9, 'd', 'a', 'y' )
296 #define ATOM_0xa9fmt VLC_FOURCC( 0xa9, 'f', 'm', 't' )
297 #define ATOM_0xa9prd VLC_FOURCC( 0xa9, 'p', 'r', 'd' )
298 #define ATOM_0xa9prf VLC_FOURCC( 0xa9, 'p', 'r', 'f' )
299 #define ATOM_0xa9src VLC_FOURCC( 0xa9, 's', 'r', 'c' )
300 #define ATOM_0xa9alb VLC_FOURCC( 0xa9, 'a', 'l', 'b' )
301 #define ATOM_0xa9dis VLC_FOURCC( 0xa9, 'd', 'i', 's' )
302 #define ATOM_0xa9enc VLC_FOURCC( 0xa9, 'e', 'n', 'c' )
303 #define ATOM_0xa9trk VLC_FOURCC( 0xa9, 't', 'r', 'k' )
304 #define ATOM_0xa9url VLC_FOURCC( 0xa9, 'u', 'r', 'l' )
305 #define ATOM_0xa9dsa VLC_FOURCC( 0xa9, 'd', 's', 'a' )
306 #define ATOM_0xa9hst VLC_FOURCC( 0xa9, 'h', 's', 't' )
307 #define ATOM_0xa9ope VLC_FOURCC( 0xa9, 'o', 'p', 'e' )
308 #define ATOM_0xa9wrt VLC_FOURCC( 0xa9, 'w', 'r', 't' )
309 #define ATOM_0xa9com VLC_FOURCC( 0xa9, 'c', 'o', 'm' )
310 #define ATOM_0xa9gen VLC_FOURCC( 0xa9, 'g', 'e', 'n' )
311 #define ATOM_0xa9too VLC_FOURCC( 0xa9, 't', 'o', 'o' )
312 #define ATOM_0xa9wrn VLC_FOURCC( 0xa9, 'w', 'r', 'n' )
313 #define ATOM_0xa9swr VLC_FOURCC( 0xa9, 's', 'w', 'r' )
314 #define ATOM_0xa9mak VLC_FOURCC( 0xa9, 'm', 'a', 'k' )
315 #define ATOM_0xa9mal VLC_FOURCC( 0xa9, 'm', 'a', 'l' )
316 #define ATOM_0xa9mod VLC_FOURCC( 0xa9, 'm', 'o', 'd' )
317 #define ATOM_0xa9PRD VLC_FOURCC( 0xa9, 'P', 'R', 'D' )
318 #define ATOM_0xa9grp VLC_FOURCC( 0xa9, 'g', 'r', 'p' )
319 #define ATOM_0xa9lyr VLC_FOURCC( 0xa9, 'l', 'y', 'r' )
320 #define ATOM_0xa9gen VLC_FOURCC( 0xa9, 'g', 'e', 'n' )
321 #define ATOM_0xa9st3 VLC_FOURCC( 0xa9, 's', 't', '3' )
322 #define ATOM_0xa9ard VLC_FOURCC( 0xa9, 'a', 'r', 'd' )
323 #define ATOM_0xa9arg VLC_FOURCC( 0xa9, 'a', 'r', 'g' )
324 #define ATOM_0xa9cak VLC_FOURCC( 0xa9, 'c', 'a', 'k' )
325 #define ATOM_0xa9con VLC_FOURCC( 0xa9, 'c', 'o', 'n' )
326 #define ATOM_0xa9des VLC_FOURCC( 0xa9, 'd', 'e', 's' )
327 #define ATOM_0xa9lnt VLC_FOURCC( 0xa9, 'l', 'n', 't' )
328 #define ATOM_0xa9phg VLC_FOURCC( 0xa9, 'p', 'h', 'g' )
329 #define ATOM_0xa9pub VLC_FOURCC( 0xa9, 'p', 'u', 'b' )
330 #define ATOM_0xa9sne VLC_FOURCC( 0xa9, 's', 'n', 'e' )
331 #define ATOM_0xa9snm VLC_FOURCC( 0xa9, 's', 'n', 'm' )
332 #define ATOM_0xa9sol VLC_FOURCC( 0xa9, 's', 'o', 'l' )
333 #define ATOM_0xa9thx VLC_FOURCC( 0xa9, 't', 'h', 'x' )
334 #define ATOM_0xa9xpd VLC_FOURCC( 0xa9, 'x', 'p', 'd' )
335 #define ATOM_0xa9xyz VLC_FOURCC( 0xa9, 'x', 'y', 'z' )
336 #define ATOM_aART VLC_FOURCC( 'a', 'A', 'R', 'T' )
337 #define ATOM_chpl VLC_FOURCC( 'c', 'h', 'p', 'l' )
338 #define ATOM_HMMT VLC_FOURCC( 'H', 'M', 'M', 'T' )
339 #define ATOM_disk VLC_FOURCC( 'd', 'i', 's', 'k' )
340 #define ATOM_WLOC VLC_FOURCC( 'W', 'L', 'O', 'C' )
342 #define ATOM_meta VLC_FOURCC( 'm', 'e', 't', 'a' )
343 #define ATOM_atID VLC_FOURCC( 'a', 't', 'I', 'D' )
344 #define ATOM_ilst VLC_FOURCC( 'i', 'l', 's', 't' )
345 #define ATOM_cnID VLC_FOURCC( 'c', 'n', 'I', 'D' )
346 #define ATOM_covr VLC_FOURCC( 'c', 'o', 'v', 'r' )
347 #define ATOM_flvr VLC_FOURCC( 'f', 'l', 'v', 'r' )
348 #define ATOM_rtng VLC_FOURCC( 'r', 't', 'n', 'g' )
349 #define ATOM_tsel VLC_FOURCC( 't', 's', 'e', 'l' )
350 #define ATOM_xid_ VLC_FOURCC( 'x', 'i', 'd', ' ' )
351 #define ATOM_gshh VLC_FOURCC( 'g', 's', 'h', 'h' )
352 #define ATOM_gspm VLC_FOURCC( 'g', 's', 'p', 'm' )
353 #define ATOM_gspu VLC_FOURCC( 'g', 's', 'p', 'u' )
354 #define ATOM_gssd VLC_FOURCC( 'g', 's', 's', 'd' )
355 #define ATOM_gsst VLC_FOURCC( 'g', 's', 's', 't' )
356 #define ATOM_gstd VLC_FOURCC( 'g', 's', 't', 'd' )
357 #define ATOM_colr VLC_FOURCC( 'c', 'o', 'l', 'r' )
359 #define ATOM_0x40PRM VLC_FOURCC( '@', 'P', 'R', 'M' )
360 #define ATOM_0x40PRQ VLC_FOURCC( '@', 'P', 'R', 'Q' )
361 #define ATOM_chap VLC_FOURCC( 'c', 'h', 'a', 'p' )
362 #define ATOM_MCPS VLC_FOURCC( 'M', 'C', 'P', 'S' )
363 #define ATOM_SDLN VLC_FOURCC( 'S', 'D', 'L', 'N' )
364 #define ATOM_vndr VLC_FOURCC( 'v', 'n', 'd', 'r' )
366 #define HANDLER_mdta VLC_FOURCC('m', 'd', 't', 'a')
367 #define HANDLER_mdir VLC_FOURCC('m', 'd', 'i', 'r')
369 #define SAMPLEGROUP_rap VLC_FOURCC('r', 'a', 'p', ' ')
371 /* Do you want some debug information on all read boxes ? */
372 #ifndef NDEBUG
373 # define MP4_VERBOSE 1
374 //# define MP4_ULTRA_VERBOSE 1
375 #endif
377 struct MP4_Box_s;
379 #define MP4_MFRO_BOXSIZE 16
381 /* uuid Universal Unique IDentifiers */
382 typedef struct UUID_s
384 uint8_t b[16];
385 } UUID_t;
387 /* specific structure for all boxes */
389 typedef struct MP4_Box_data_tfxd_s
391 uint8_t i_version;
392 uint32_t i_flags;
394 uint64_t i_fragment_duration;
395 uint64_t i_fragment_abs_time;
397 } MP4_Box_data_tfxd_t;
399 typedef struct TfrfBoxDataFields_s
401 uint64_t i_fragment_duration;
402 uint64_t i_fragment_abs_time;
404 } TfrfBoxDataFields_t;
406 typedef struct MP4_Box_data_tfrf_s
408 uint8_t i_version;
409 uint8_t i_fragment_count;
410 uint32_t i_flags;
412 TfrfBoxDataFields_t *p_tfrf_data_fields;
414 } MP4_Box_data_tfrf_t;
416 typedef struct MP4_Box_data_ftyp_s
418 uint32_t i_major_brand;
419 uint32_t i_minor_version;
421 uint32_t i_compatible_brands_count;
422 uint32_t *i_compatible_brands;
424 } MP4_Box_data_ftyp_t;
426 typedef struct MP4_Box_data_mvhd_s
428 uint8_t i_version;
429 uint32_t i_flags;
431 uint64_t i_creation_time;
432 uint64_t i_modification_time;
433 uint32_t i_timescale;
434 uint64_t i_duration;
436 int32_t i_rate;
437 int16_t i_volume;
438 int16_t i_reserved1;
439 uint32_t i_reserved2[2];
440 int32_t i_matrix[9];
441 uint32_t i_predefined[6];
442 uint32_t i_next_track_id;
444 } MP4_Box_data_mvhd_t;
446 #define MP4_TRACK_ENABLED 0x000001
447 #define MP4_TRACK_IN_MOVIE 0x000002
448 #define MP4_TRACK_IN_PREVIEW 0x000004
449 typedef struct MP4_Box_data_tkhd_s
451 uint8_t i_version;
452 uint32_t i_flags;
454 uint64_t i_creation_time;
455 uint64_t i_modification_time;
456 uint32_t i_track_ID;
457 uint32_t i_reserved;
458 uint64_t i_duration;
460 uint32_t i_reserved2[2];
461 int16_t i_layer;
462 int16_t i_predefined;
464 int16_t i_volume;
465 uint16_t i_reserved3;
466 int32_t i_matrix[9];
467 int32_t i_width;
468 int32_t i_height;
469 float f_rotation;
471 } MP4_Box_data_tkhd_t;
473 typedef struct
475 uint32_t i_start_time;
476 int32_t i_duration;
477 uint32_t i_flags;
478 uint32_t i_hints;
479 } MP4_Box_data_load_t;
481 typedef struct MP4_Box_data_mdhd_s
483 uint8_t i_version;
484 uint32_t i_flags;
486 uint64_t i_creation_time;
487 uint64_t i_modification_time;
488 uint32_t i_timescale;
489 uint64_t i_duration;
491 char rgs_language[3]; /* ISO-639-2/T or Mac lang table */
492 bool b_mac_encoding; /* media using mac encoding */
494 uint16_t i_quality;
496 } MP4_Box_data_mdhd_t;
498 typedef struct MP4_Box_data_hdlr_s
500 uint8_t i_version;
501 uint32_t i_flags;
503 uint32_t i_predefined;
504 uint32_t i_handler_type; /* "vide" "soun" "hint" "odsm"
505 "crsm" "sdsm" "m7sm" "ocsm"
506 "ipsm" "mjsm" */
508 unsigned char *psz_name; /* in UTF-8 */
510 } MP4_Box_data_hdlr_t;
512 typedef struct MP4_Box_data_vmhd_s
514 uint8_t i_version;
515 uint32_t i_flags;
517 int16_t i_graphics_mode;
518 int16_t i_opcolor[3];
520 } MP4_Box_data_vmhd_t;
522 typedef struct MP4_Box_data_smhd_s
524 uint8_t i_version;
525 uint32_t i_flags;
527 int16_t i_balance;
528 int16_t i_reserved;
530 } MP4_Box_data_smhd_t;
532 typedef struct MP4_Box_data_hmhd_s
534 uint8_t i_version;
535 uint32_t i_flags;
537 uint16_t i_max_PDU_size;
538 uint16_t i_avg_PDU_size;
539 uint32_t i_max_bitrate;
540 uint32_t i_avg_bitrate;
541 uint32_t i_reserved;
543 } MP4_Box_data_hmhd_t;
545 typedef struct MP4_Box_data_url_s
547 uint8_t i_version;
548 uint32_t i_flags;
550 char *psz_location;
552 } MP4_Box_data_url_t;
554 typedef struct MP4_Box_data_urn_s
556 uint8_t i_version;
557 uint32_t i_flags;
559 char *psz_name;
560 char *psz_location;
562 } MP4_Box_data_urn_t;
564 typedef struct MP4_Box_data_lcont_s
566 uint8_t i_version;
567 uint32_t i_flags;
569 uint32_t i_entry_count;
570 /* XXX it's also a container with i_entry_count entry */
571 } MP4_Box_data_lcont_t;
573 typedef struct MP4_Box_data_stts_s
575 uint8_t i_version;
576 uint32_t i_flags;
578 uint32_t i_entry_count;
579 uint32_t *pi_sample_count; /* these are array */
580 int32_t *pi_sample_delta;
582 } MP4_Box_data_stts_t;
584 typedef struct MP4_Box_data_ctts_s
586 uint8_t i_version;
587 uint32_t i_flags;
589 uint32_t i_entry_count;
591 uint32_t *pi_sample_count; /* these are array */
592 int32_t *pi_sample_offset;
594 } MP4_Box_data_ctts_t;
596 // https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html#//apple_ref/doc/uid/TP40000939-CH205-125526
597 typedef struct MP4_Box_data_colr_s
599 uint32_t i_type;
600 union
602 struct
604 uint16_t i_primary_idx;
605 uint16_t i_transfer_function_idx;
606 uint16_t i_matrix_idx;
607 uint8_t i_full_range;
608 } nclc;
610 } MP4_Box_data_colr_t;
612 typedef struct MP4_Box_data_sample_soun_s
614 uint8_t i_reserved1[6];
615 uint16_t i_data_reference_index;
617 //uint32_t i_reserved2[2];
618 uint16_t i_qt_version;
619 uint16_t i_qt_revision_level;
620 uint32_t i_qt_vendor;
622 uint16_t i_channelcount;
623 uint16_t i_samplesize;
624 uint16_t i_compressionid;
625 uint16_t i_reserved3;
626 uint16_t i_sampleratehi; /* timescale of track */
627 uint16_t i_sampleratelo;
629 /* for version 1 (i_reserved1[0] == 1) */
630 uint32_t i_sample_per_packet;
631 uint32_t i_bytes_per_packet;
632 uint32_t i_bytes_per_frame;
633 uint32_t i_bytes_per_sample;
635 /* v2 */
636 uint32_t i_constbitsperchannel; /* consts are nonzero only if constant */
637 uint32_t i_formatflags;
638 uint32_t i_constbytesperaudiopacket;
639 uint32_t i_constLPCMframesperaudiopacket;
641 /* XXX hack */
642 int i_qt_description;
643 uint8_t *p_qt_description;
645 } MP4_Box_data_sample_soun_t;
647 typedef struct MP4_Box_data_sample_vide_s
649 uint8_t i_reserved1[6];
650 uint16_t i_data_reference_index;
652 uint16_t i_qt_version;
653 uint16_t i_qt_revision_level;
654 uint32_t i_qt_vendor;
656 uint32_t i_qt_temporal_quality;
657 uint32_t i_qt_spatial_quality;
659 int16_t i_width;
660 int16_t i_height;
662 uint32_t i_horizresolution;
663 uint32_t i_vertresolution;
665 uint32_t i_qt_data_size;
666 uint16_t i_qt_frame_count;
668 char sz_compressorname[32];
669 int16_t i_depth;
671 int16_t i_qt_color_table;
673 /* XXX hack ImageDescription */
674 int i_qt_image_description;
675 uint8_t *p_qt_image_description;
677 } MP4_Box_data_sample_vide_t;
679 #define MP4_TEXT_DISPLAY_FLAG_DONT_DISPLAY (1<<0)
680 #define MP4_TEXT_DISPLAY_FLAG_AUTO_SCALE (1<<1)
681 #define MP4_TEXT_DISPLAY_FLAG_CLIP_TO_TEXT_BOX (1<<2)
682 #define MP4_TEXT_DISPLAY_FLAG_USE_MOVIE_BG_COLOR (1<<3)
683 #define MP4_TEXT_DISPLAY_FLAG_SHRINK_TEXT_BOX_TO_FIT (1<<4)
684 #define MP4_TEXT_DISPLAY_FLAG_SCROLL_IN (1<<5)
685 #define MP4_TEXT_DISPLAY_FLAG_SCROLL_OUT (1<<6)
686 #define MP4_TEXT_DISPLAY_FLAG_HORIZONTAL_SCROLL (1<<7)
687 #define MP4_TEXT_DISPLAY_FLAG_REVERSE_SCROLL (1<<8)
688 #define MP4_TEXT_DISPLAY_FLAG_CONTINUOUS_SCROLL (1<<9)
689 #define MP4_TEXT_DISPLAY_FLAG_FLOW_HORIZONTAL (1<<10)
690 #define MP4_TEXT_DISPLAY_FLAG_CONTINUOUS_KARAOKE (1<<11)
691 #define MP4_TEXT_DISPLAY_FLAG_DROP_SHADOW (1<<12)
692 #define MP4_TEXT_DISPLAY_FLAG_ANTI_ALIAS (1<<13)
693 #define MP4_TEXT_DISPLAY_FLAG_KEYED_TEXT (1<<14)
694 #define MP4_TEXT_DISPLAY_FLAG_INVERSE_HILITE (1<<15)
695 #define MP4_TEXT_DISPLAY_FLAG_COLOR_HILITE (1<<16)
696 #define MP4_TEXT_DISPLAY_FLAG_WRITE_VERTICALLY (1<<17)
698 typedef struct
700 uint32_t i_reserved1;
701 uint16_t i_reserved2;
703 uint16_t i_data_reference_index;
705 uint32_t i_display_flags; // TextDescription and Tx3gDescription
707 int8_t i_justification_horizontal; // left(0), centered(1), right(-1)
708 int8_t i_justification_vertical; // top(0), centered(1), bottom(-1)
710 uint16_t i_background_color[4];
712 uint16_t i_text_box_top;
713 uint16_t i_text_box_left;
714 uint16_t i_text_box_bottom;
715 uint16_t i_text_box_right;
717 uint32_t i_reserved3;
719 uint16_t i_font_id;
720 uint8_t i_font_face;
721 uint8_t i_font_size;
722 uint32_t i_font_color; //RGBA
724 // TODO to complete
725 } MP4_Box_data_sample_text_t;
727 typedef struct
729 uint8_t i_reserved1[6];
730 uint16_t i_data_reference_index;
732 } MP4_Box_data_sample_clcp_t;
734 typedef struct MP4_Box_data_sample_hint_s
736 uint8_t i_reserved1[6];
737 uint16_t i_data_reference_index;
739 uint8_t *p_data;
741 } MP4_Box_data_sample_hint_t;
743 typedef struct MP4_Box_data_rrtp_sample_s
745 uint16_t i_hinttrackversion;
746 uint16_t i_highestcompatibleversion;
747 uint32_t i_maxpacketsize;
749 uint8_t *p_additionaldata;
751 } MP4_Box_data_rrtp_sample_t;
753 typedef struct MP4_Box_data_timescale_entry_s
755 uint32_t i_timescale;
757 } MP4_Box_data_timescale_entry_t;
759 typedef struct MP4_Box_data_time_offset_s
761 uint32_t i_offset;
763 } MP4_Box_data_time_offset_t;
765 typedef struct MP4_Box_data_timestampsynchrony_s
767 uint8_t i_reserved_timestamp_sync;
769 } MP4_Box_data_timestampsynchrony_t;
771 typedef struct MP4_Box_data_moviehintinformation_rtp_s
773 uint32_t i_description_format;
774 unsigned char *psz_text;
776 } MP4_Box_data_moviehintinformation_rtp_t;
778 typedef struct MP4_Box_data_sdp_s
780 char *psz_text;
782 } MP4_Box_data_sdp_t;
784 typedef struct MP4_Box_data_tims_s
786 uint32_t i_timescale;
788 } MP4_Box_data_tims_t;
790 typedef struct MP4_Box_data_tsro_s
792 int32_t i_offset;
794 } MP4_Box_data_tsro_t;
796 typedef struct MP4_Box_data_tssy_s
798 uint8_t i_reserved_timestamp_sync;
800 } MP4_Box_data_tssy_t;
802 typedef struct MP4_Box_data_stsd_s
804 uint8_t i_version;
805 uint32_t i_flags;
807 uint32_t i_entry_count;
809 /* it contains SampleEntry handled as if it was Box */
811 } MP4_Box_data_stsd_t;
814 typedef struct MP4_Box_data_stsz_s
816 uint8_t i_version;
817 uint32_t i_flags;
819 uint32_t i_sample_size;
820 uint32_t i_sample_count;
822 uint32_t *i_entry_size; /* array , empty if i_sample_size != 0 */
824 } MP4_Box_data_stsz_t;
826 typedef struct MP4_Box_data_stz2_s
828 uint8_t i_version;
829 uint32_t i_flags;
831 uint32_t i_sample_size; /* 24 bits */
832 uint8_t i_field_size;
833 uint32_t i_sample_count;
835 uint32_t *i_entry_size; /* array: unsigned int(i_field_size) entry_size */
837 } MP4_Box_data_stz2_t;
839 typedef struct MP4_Box_data_stsc_s
841 uint8_t i_version;
842 uint32_t i_flags;
844 uint32_t i_entry_count;
846 uint32_t *i_first_chunk; /* theses are arrays */
847 uint32_t *i_samples_per_chunk;
848 uint32_t *i_sample_description_index;
850 } MP4_Box_data_stsc_t;
853 typedef struct MP4_Box_data_co64_s
855 uint8_t i_version;
856 uint32_t i_flags;
858 uint32_t i_entry_count;
860 uint64_t *i_chunk_offset;
862 } MP4_Box_data_co64_t;
865 typedef struct MP4_Box_data_stss_s
867 uint8_t i_version;
868 uint32_t i_flags;
870 uint32_t i_entry_count;
872 uint32_t *i_sample_number;
874 } MP4_Box_data_stss_t;
876 typedef struct MP4_Box_data_stsh_s
878 uint8_t i_version;
879 uint32_t i_flags;
881 uint32_t i_entry_count;
883 uint32_t *i_shadowed_sample_number;
884 uint32_t *i_sync_sample_number;
886 } MP4_Box_data_stsh_t;
888 typedef struct MP4_Box_data_stdp_s
890 uint8_t i_version;
891 uint32_t i_flags;
893 uint16_t *i_priority;
895 } MP4_Box_data_stdp_t;
897 typedef struct MP4_Box_data_padb_s
899 uint8_t i_version;
900 uint32_t i_flags;
902 uint32_t i_sample_count;
904 uint16_t *i_reserved1; /* 1bit */
905 uint16_t *i_pad2; /* 3bits */
906 uint16_t *i_reserved2; /* 1bit */
907 uint16_t *i_pad1; /* 3bits */
910 } MP4_Box_data_padb_t;
913 typedef struct MP4_Box_data_elst_s
915 uint8_t i_version;
916 uint32_t i_flags;
918 uint32_t i_entry_count;
920 uint64_t *i_segment_duration;
921 int64_t *i_media_time;
922 uint16_t *i_media_rate_integer;
923 uint16_t *i_media_rate_fraction;
926 } MP4_Box_data_elst_t;
928 typedef struct MP4_Box_data_cprt_s
930 uint8_t i_version;
931 uint32_t i_flags;
933 char rgs_language[3]; /* ISO-639-2/T */
935 char *psz_notice;
936 } MP4_Box_data_cprt_t;
939 /* DecoderConfigDescriptor */
940 typedef struct MP4_descriptor_decoder_config_s
942 uint8_t i_objectProfileIndication;
943 uint8_t i_streamType;
944 int b_upStream;
945 int i_buffer_sizeDB;
946 int i_max_bitrate;
947 int i_avg_bitrate;
949 int i_decoder_specific_info_len;
950 uint8_t *p_decoder_specific_info;
951 /* some other stuff */
953 } MP4_descriptor_decoder_config_t;
955 typedef struct MP4_descriptor_SL_config_s
958 int i_dummy; /* ANSI C forbids empty structures */
960 } MP4_descriptor_SL_config_t;
963 typedef struct MP4_descriptor_ES_s
965 uint16_t i_ES_ID;
966 int b_stream_dependence;
967 int b_url;
968 int b_OCRstream;
969 int i_stream_priority;
971 int i_depend_on_ES_ID; /* if b_stream_dependence set */
973 unsigned char *psz_URL;
975 uint16_t i_OCR_ES_ID; /* if b_OCRstream */
976 MP4_descriptor_decoder_config_t *p_decConfigDescr;
978 MP4_descriptor_SL_config_t *p_slConfigDescr;
980 /* some other stuff ... */
982 } MP4_descriptor_ES_t;
984 /* ES descriptor */
985 typedef struct MP4_Box_data_esds_s
987 uint8_t i_version;
988 uint32_t i_flags;
990 MP4_descriptor_ES_t es_descriptor;
992 } MP4_Box_data_esds_t;
995 typedef struct MP4_Box_data_dcom_s
997 uint32_t i_algorithm; /* fourcc */
999 } MP4_Box_data_dcom_t;
1001 typedef struct MP4_Box_data_cmvd_s
1003 uint32_t i_uncompressed_size;
1004 uint32_t i_compressed_size;
1006 int b_compressed; /* Set to 1 if compressed data, 0 if uncompressed */
1007 uint8_t *p_data;
1009 } MP4_Box_data_cmvd_t;
1011 typedef struct MP4_Box_data_cmov_s
1013 struct MP4_Box_s *p_moov; /* uncompressed moov */
1015 } MP4_Box_data_cmov_t;
1017 typedef struct
1019 uint32_t i_type;
1020 } MP4_Box_data_frma_t;
1022 typedef struct
1024 uint32_t i_init;
1025 uint32_t i_encr;
1026 uint32_t i_decr;
1027 } MP4_Box_data_skcr_t;
1029 typedef struct
1031 uint8_t i_version;
1032 uint32_t i_flags;
1034 uint32_t i_ref_type;
1035 char *psz_ref;
1037 } MP4_Box_data_rdrf_t;
1039 typedef struct
1041 uint8_t i_version;
1042 uint32_t i_flags;
1044 uint32_t i_rate;
1046 } MP4_Box_data_rmdr_t;
1048 typedef struct
1050 uint8_t i_version;
1051 uint32_t i_flags;
1053 uint32_t i_gestaltType;
1054 uint32_t i_val1;
1055 uint32_t i_val2;
1056 uint16_t i_checkType; /* 0: val1 is version min
1057 1: gestalt value & val2 == val1 */
1059 } MP4_Box_data_rmvc_t;
1061 typedef struct
1063 uint8_t i_version;
1064 uint32_t i_flags;
1067 } MP4_Box_data_rmcd_t;
1069 typedef struct
1071 uint32_t i_quality;
1073 } MP4_Box_data_rmqu_t;
1075 typedef struct MP4_Box_data_mfhd_s
1077 uint8_t i_version;
1078 uint32_t i_flags;
1080 uint32_t i_sequence_number;
1082 } MP4_Box_data_mfhd_t;
1084 typedef struct MP4_Box_sidx_item_s
1086 bool b_reference_type;
1087 uint32_t i_referenced_size;
1088 uint32_t i_subsegment_duration;
1089 bool b_starts_with_SAP;
1090 uint8_t i_SAP_type;
1091 uint32_t i_SAP_delta_time;
1093 } MP4_Box_sidx_item_t;
1095 typedef struct MP4_Box_data_sidx_s
1097 uint8_t i_version;
1098 uint32_t i_flags;
1100 uint32_t i_reference_ID;
1101 uint32_t i_timescale;
1102 uint64_t i_earliest_presentation_time;
1103 uint64_t i_first_offset;
1104 uint16_t i_reference_count;
1106 MP4_Box_sidx_item_t *p_items;
1108 } MP4_Box_data_sidx_t;
1110 #define MP4_TFHD_BASE_DATA_OFFSET (1LL<<0)
1111 #define MP4_TFHD_SAMPLE_DESC_INDEX (1LL<<1)
1112 #define MP4_TFHD_DFLT_SAMPLE_DURATION (1LL<<3)
1113 #define MP4_TFHD_DFLT_SAMPLE_SIZE (1LL<<4)
1114 #define MP4_TFHD_DFLT_SAMPLE_FLAGS (1LL<<5)
1115 #define MP4_TFHD_DURATION_IS_EMPTY (1LL<<16)
1116 #define MP4_TFHD_DEFAULT_BASE_IS_MOOF (1LL<<17)
1117 typedef struct MP4_Box_data_tfhd_s
1119 uint8_t i_version;
1120 bool b_empty;
1121 uint32_t i_flags;
1122 uint32_t i_track_ID;
1124 /* optional fields */
1125 uint64_t i_base_data_offset;
1126 uint32_t i_sample_description_index;
1127 uint32_t i_default_sample_duration;
1128 uint32_t i_default_sample_size;
1129 uint32_t i_default_sample_flags;
1131 } MP4_Box_data_tfhd_t;
1133 #define MP4_TRUN_DATA_OFFSET (1<<0)
1134 #define MP4_TRUN_FIRST_FLAGS (1<<2)
1135 #define MP4_TRUN_SAMPLE_DURATION (1<<8)
1136 #define MP4_TRUN_SAMPLE_SIZE (1<<9)
1137 #define MP4_TRUN_SAMPLE_FLAGS (1<<10)
1138 #define MP4_TRUN_SAMPLE_TIME_OFFSET (1<<11)
1139 typedef struct MP4_descriptor_trun_sample_t
1141 uint32_t i_duration;
1142 uint32_t i_size;
1143 uint32_t i_flags;
1144 uint32_t i_composition_time_offset; /* version == 0 ? signed : unsigned */
1145 } MP4_descriptor_trun_sample_t;
1147 typedef struct MP4_Box_data_trun_s
1149 uint8_t i_version;
1150 uint32_t i_flags;
1151 uint32_t i_sample_count;
1153 /* optional fields */
1154 int32_t i_data_offset;
1155 uint32_t i_first_sample_flags;
1157 MP4_descriptor_trun_sample_t *p_samples;
1159 } MP4_Box_data_trun_t;
1161 typedef struct MP4_Box_data_tfdt_s
1163 uint8_t i_version;
1164 uint32_t i_flags;
1165 int64_t i_base_media_decode_time;
1167 } MP4_Box_data_tfdt_t;
1169 typedef struct
1171 uint32_t i_date;
1172 uint32_t i_type;
1173 uint16_t i_index;
1174 } MP4_Box_data_pnot_t;
1176 typedef struct
1178 char *psz_text;
1180 } MP4_Box_data_string_t;
1182 typedef struct
1184 uint8_t *p_blob;
1185 uint32_t i_blob;
1186 } MP4_Box_data_binary_t;
1188 typedef struct
1190 uint32_t i_entry_count;
1191 uint32_t *i_track_ID;
1193 } MP4_Box_data_tref_generic_t;
1195 typedef struct
1197 uint8_t i_version;
1198 uint32_t i_flags;
1200 uint8_t i_chapter;
1201 struct
1203 char *psz_name;
1204 int64_t i_start;
1205 } chapter[256];
1206 } MP4_Box_data_chpl_t;
1208 typedef struct
1210 uint32_t i_chapter_count;
1211 uint32_t *pi_chapter_start;
1213 } MP4_Box_data_HMMT_t;
1215 typedef struct
1217 uint8_t i_version;
1218 uint8_t i_profile;
1219 uint8_t i_profile_compatibility;
1220 uint8_t i_level;
1222 uint8_t i_reserved1; /* 6 bits */
1223 uint8_t i_length_size;
1225 uint8_t i_reserved2; /* 3 bits */
1226 uint8_t i_sps;
1227 uint16_t *i_sps_length;
1228 uint8_t **sps;
1230 uint8_t i_pps;
1231 uint16_t *i_pps_length;
1232 uint8_t **pps;
1234 /* XXX: Hack raw avcC atom payload */
1235 int i_avcC;
1236 uint8_t *p_avcC;
1238 } MP4_Box_data_avcC_t;
1240 typedef struct
1242 uint8_t i_profile;
1243 uint8_t i_level;
1244 uint8_t i_bit_depth;
1245 uint8_t i_color_space;
1246 uint8_t i_chroma_subsampling;
1247 uint8_t i_xfer_function;
1248 uint8_t i_fullrange;
1249 uint16_t i_codec_init_datasize;
1250 uint8_t *p_codec_init_data;
1251 } MP4_Box_data_vpcC_t;
1253 typedef struct
1255 WAVEFORMATEX Format;
1256 uint32_t i_extra;
1257 char *p_extra;
1258 } MP4_Box_data_WMA2_t;
1260 typedef struct
1262 VLC_BITMAPINFOHEADER bmiHeader;
1263 uint32_t i_extra;
1264 char *p_extra;
1265 } MP4_Box_data_strf_t;
1267 typedef struct
1269 uint8_t i_stream_number;
1270 } MP4_Box_data_ASF_t;
1272 typedef struct
1274 uint8_t i_version;
1275 uint32_t i_grouping_type;
1276 uint32_t i_default_sample_description_index;
1277 uint32_t i_entry_count;
1278 union
1280 struct
1282 uint8_t i_num_leading_samples_known;
1283 uint8_t i_num_leading_samples;
1284 } rap;
1285 } *p_entries;
1286 } MP4_Box_data_sgpd_t;
1288 typedef struct
1290 uint8_t i_version;
1291 uint32_t i_grouping_type;
1292 uint32_t i_grouping_type_parameter;
1293 uint32_t i_entry_count;
1294 struct
1296 uint32_t *pi_sample_count;
1297 uint32_t *pi_group_description_index;
1298 } entries;
1299 } MP4_Box_data_sbgp_t;
1301 /* According to Apple's CoreAudio/CoreAudioTypes.h */
1302 #define MP4_CHAN_USE_CHANNELS_DESC 0
1303 #define MP4_CHAN_USE_CHANNELS_BITMAP (1<<16)
1305 #define MP4_CHAN_BITMAP_LEFT (1<<0)
1306 #define MP4_CHAN_BITMAP_RIGHT (1<<1)
1307 #define MP4_CHAN_BITMAP_CENTER (1<<2)
1308 #define MP4_CHAN_BITMAP_LFESCREEN (1<<3)
1309 #define MP4_CHAN_BITMAP_BACKLEFT (1<<4)
1310 #define MP4_CHAN_BITMAP_BACKRIGHT (1<<5)
1311 #define MP4_CHAN_BITMAP_LEFTCENTER (1<<6)
1312 #define MP4_CHAN_BITMAP_RIGHTCENTER (1<<7)
1313 #define MP4_CHAN_BITMAP_BACKCENTER (1<<8)
1314 #define MP4_CHAN_BITMAP_SIDELEFT (1<<9)
1315 #define MP4_CHAN_BITMAP_SIDERIGHT (1<<10)
1316 #define MP4_CHAN_BITMAP_TOPCENTER (1<<11)
1317 #define MP4_CHAN_BITMAP_TOPFRONTLEFT (1<<12)
1318 #define MP4_CHAN_BITMAP_TOPFRONTENTER (1<<13)
1319 #define MP4_CHAN_BITMAP_TOPFRONTRIGHT (1<<14)
1320 #define MP4_CHAN_BITMAP_TOPBACKLEFT (1<<15)
1321 #define MP4_CHAN_BITMAP_TOPBACKCENTER (1<<16)
1322 #define MP4_CHAN_BITMAP_TOPBACKRIGHT (1<<17)
1324 #define MP4_CHAN_BITMAP_MAPPING_COUNT 18
1325 static const struct
1327 uint32_t i_bitmap;
1328 uint32_t i_vlc;
1329 } chan_bitmap_mapping[MP4_CHAN_BITMAP_MAPPING_COUNT] = {
1330 { MP4_CHAN_BITMAP_LEFT, AOUT_CHAN_LEFT },
1331 { MP4_CHAN_BITMAP_RIGHT, AOUT_CHAN_RIGHT },
1332 { MP4_CHAN_BITMAP_CENTER, AOUT_CHAN_CENTER },
1333 { MP4_CHAN_BITMAP_LFESCREEN, AOUT_CHAN_LFE },
1334 { MP4_CHAN_BITMAP_BACKLEFT, AOUT_CHAN_REARLEFT },
1335 { MP4_CHAN_BITMAP_BACKRIGHT, AOUT_CHAN_REARRIGHT },
1336 { MP4_CHAN_BITMAP_LEFTCENTER, AOUT_CHAN_MIDDLELEFT },
1337 { MP4_CHAN_BITMAP_RIGHTCENTER, AOUT_CHAN_MIDDLERIGHT },
1338 { MP4_CHAN_BITMAP_BACKCENTER, AOUT_CHAN_REARCENTER },
1339 { MP4_CHAN_BITMAP_SIDELEFT, AOUT_CHAN_LEFT },
1340 { MP4_CHAN_BITMAP_SIDERIGHT, AOUT_CHAN_RIGHT },
1341 { MP4_CHAN_BITMAP_TOPCENTER, AOUT_CHAN_CENTER },
1342 { MP4_CHAN_BITMAP_TOPFRONTLEFT, AOUT_CHAN_LEFT },
1343 { MP4_CHAN_BITMAP_TOPFRONTENTER,AOUT_CHAN_CENTER },
1344 { MP4_CHAN_BITMAP_TOPFRONTRIGHT,AOUT_CHAN_RIGHT },
1345 { MP4_CHAN_BITMAP_TOPBACKLEFT, AOUT_CHAN_REARLEFT },
1346 { MP4_CHAN_BITMAP_TOPBACKCENTER,AOUT_CHAN_REARCENTER },
1347 { MP4_CHAN_BITMAP_TOPBACKRIGHT, AOUT_CHAN_REARRIGHT },
1350 typedef struct
1352 uint8_t i_version;
1353 uint32_t i_channels_flags; /* 24 bits */
1354 struct
1356 uint32_t i_channels_layout_tag;
1357 uint32_t i_channels_bitmap;
1358 uint32_t i_channels_description_count;
1359 struct
1361 uint32_t i_channel_label;
1362 uint32_t i_channel_flags;
1363 float f_coordinates[3];
1364 } *p_descriptions;
1365 } layout;
1366 } MP4_Box_data_chan_t;
1368 typedef struct
1370 uint16_t i_data_rate;
1371 uint8_t i_num_ind_sub;
1372 struct
1374 uint8_t i_fscod;
1375 uint8_t i_bsid;
1376 uint8_t i_bsmod;
1377 uint8_t i_acmod;
1378 uint8_t i_lfeon;
1379 uint8_t i_num_dep_sub;
1380 uint16_t i_chan_loc;
1381 } stream[8];
1383 } MP4_Box_data_dec3_t;
1385 typedef struct
1387 uint8_t i_fscod;
1388 uint8_t i_bsid;
1389 uint8_t i_bsmod;
1390 uint8_t i_acmod;
1391 uint8_t i_lfeon;
1392 uint8_t i_bitrate_code;
1394 } MP4_Box_data_dac3_t;
1396 typedef struct
1398 uint8_t i_profile_level;
1400 uint32_t i_vc1;
1401 uint8_t *p_vc1;
1403 } MP4_Box_data_dvc1_t;
1405 typedef struct
1407 uint32_t i_flags;
1408 } MP4_Box_data_fiel_t;
1410 typedef struct
1412 uint16_t i_little_endian;
1414 } MP4_Box_data_enda_t;
1416 typedef struct
1418 uint32_t i_entry_count;
1419 struct
1421 uint32_t i_namespace;
1422 char *psz_value;
1423 } *p_entries;
1424 } MP4_Box_data_keys_t;
1426 typedef struct
1428 uint8_t i_version;
1429 uint32_t i_flags;
1431 uint16_t i_object_descriptor;
1432 uint8_t i_OD_profile_level;
1433 uint8_t i_scene_profile_level;
1434 uint8_t i_audio_profile_level;
1435 uint8_t i_visual_profile_level;
1436 uint8_t i_graphics_profile_level;
1438 } MP4_Box_data_iods_t;
1440 typedef struct
1442 uint32_t i_buffer_size;
1443 uint32_t i_max_bitrate;
1444 uint32_t i_avg_bitrate;
1445 } MP4_Box_data_btrt_t;
1447 typedef struct
1449 uint32_t i_horizontal_spacing;
1450 uint32_t i_vertical_spacing;
1451 } MP4_Box_data_pasp_t;
1453 typedef struct
1455 uint8_t i_version;
1456 uint32_t i_flags;
1458 uint64_t i_fragment_duration;
1459 } MP4_Box_data_mehd_t;
1461 typedef struct
1463 uint8_t i_version;
1464 uint32_t i_flags;
1466 uint32_t i_track_ID;
1467 uint32_t i_default_sample_description_index;
1468 uint32_t i_default_sample_duration;
1469 uint32_t i_default_sample_size;
1470 uint32_t i_default_sample_flags;
1471 } MP4_Box_data_trex_t;
1473 typedef struct
1475 uint8_t i_version;
1476 uint32_t i_flags;
1478 uint8_t *p_sample_table;
1479 } MP4_Box_data_sdtp_t;
1481 typedef struct
1483 uint32_t i_switch_group;
1484 } MP4_Box_data_tsel_t;
1486 typedef struct
1488 uint8_t i_version;
1489 uint32_t i_flags;
1491 uint32_t i_size;
1492 } MP4_Box_data_mfro_t;
1494 typedef struct
1496 uint8_t i_version;
1497 uint32_t i_flags;
1499 uint32_t i_track_ID;
1500 uint32_t i_number_of_entries;
1502 uint8_t i_length_size_of_traf_num;
1503 uint8_t i_length_size_of_trun_num;
1504 uint8_t i_length_size_of_sample_num;
1506 uint32_t *p_time;
1507 uint32_t *p_moof_offset;
1508 uint8_t *p_traf_number;
1509 uint8_t *p_trun_number;
1510 uint8_t *p_sample_number;
1511 } MP4_Box_data_tfra_t;
1513 typedef struct
1515 enum
1517 DATA_WKT_RESERVED = 0,
1518 DATA_WKT_UTF8 = 1,
1519 DATA_WKT_UTF16 = 2,
1520 DATA_WKT_SJIS = 3,
1521 DATA_WKT_UTF8_SORT = 4,
1522 DATA_WKT_UTF16_SORT = 5,
1523 DATA_WKT_JPEG = 13,
1524 DATA_WKT_PNG = 14,
1525 DATA_WKT_BE_SIGNED = 21,
1526 DATA_WKT_BE_UNSIGNED = 22,
1527 DATA_WKT_BE_FLOAT32 = 23,
1528 DATA_WKT_BE_FLOAT64 = 24,
1529 DATA_WKT_BMP = 27,
1530 DATA_WKT_QUICKTIME_METADATA_ATOM = 28,
1531 } e_wellknowntype;
1532 struct
1534 uint16_t i_country;
1535 uint16_t i_language;
1536 } locale;
1537 uint8_t *p_blob;
1538 uint32_t i_blob;
1539 } MP4_Box_data_data_t;
1541 typedef struct
1543 uint32_t i_projection_mode;
1544 } MP4_Box_data_360_t;
1547 typedef struct MP4_Box_data__s
1549 uint8_t i_version;
1550 uint32_t i_flags;
1552 } MP4_Box_data__t;
1556 typedef union MP4_Box_data_s
1558 MP4_Box_data_ftyp_t *p_ftyp;
1559 MP4_Box_data_mvhd_t *p_mvhd;
1560 MP4_Box_data_mfhd_t *p_mfhd;
1561 MP4_Box_data_sidx_t *p_sidx;
1562 MP4_Box_data_tfhd_t *p_tfhd;
1563 MP4_Box_data_trun_t *p_trun;
1564 MP4_Box_data_tfdt_t *p_tfdt;
1565 MP4_Box_data_tkhd_t *p_tkhd;
1566 MP4_Box_data_mdhd_t *p_mdhd;
1567 MP4_Box_data_hdlr_t *p_hdlr;
1568 MP4_Box_data_vmhd_t *p_vmhd;
1569 MP4_Box_data_smhd_t *p_smhd;
1570 MP4_Box_data_hmhd_t *p_hmhd;
1571 MP4_Box_data_url_t *p_url;
1572 MP4_Box_data_urn_t *p_urn;
1573 MP4_Box_data_lcont_t *p_lcont;
1574 MP4_Box_data_stts_t *p_stts;
1575 MP4_Box_data_ctts_t *p_ctts;
1576 MP4_Box_data_colr_t *p_colr;
1578 MP4_Box_data_sbgp_t *p_sbgp;
1579 MP4_Box_data_sgpd_t *p_sgpd;
1581 MP4_Box_data_sample_vide_t *p_sample_vide;
1582 MP4_Box_data_sample_soun_t *p_sample_soun;
1583 MP4_Box_data_sample_text_t *p_sample_text;
1584 MP4_Box_data_sample_clcp_t *p_sample_clcp;
1585 MP4_Box_data_sample_hint_t *p_sample_hint;
1587 MP4_Box_data_esds_t *p_esds;
1588 MP4_Box_data_avcC_t *p_avcC;
1589 MP4_Box_data_dac3_t *p_dac3;
1590 MP4_Box_data_dec3_t *p_dec3;
1591 MP4_Box_data_dvc1_t *p_dvc1;
1592 MP4_Box_data_fiel_t *p_fiel;
1593 MP4_Box_data_chan_t *p_chan;
1594 MP4_Box_data_enda_t *p_enda;
1595 MP4_Box_data_keys_t *p_keys;
1596 MP4_Box_data_iods_t *p_iods;
1597 MP4_Box_data_btrt_t *p_btrt;
1598 MP4_Box_data_pasp_t *p_pasp;
1599 MP4_Box_data_trex_t *p_trex;
1600 MP4_Box_data_mehd_t *p_mehd;
1601 MP4_Box_data_sdtp_t *p_sdtp;
1602 MP4_Box_data_tsel_t *p_tsel;
1603 MP4_Box_data_load_t *p_load;
1604 MP4_Box_data_vpcC_t *p_vpcC;
1606 MP4_Box_data_tfra_t *p_tfra;
1607 MP4_Box_data_mfro_t *p_mfro;
1609 MP4_Box_data_sdp_t *p_sdp;
1611 MP4_Box_data_tims_t *p_tims;
1612 MP4_Box_data_tsro_t *p_tsro;
1613 MP4_Box_data_tssy_t *p_tssy;
1615 MP4_Box_data_stsz_t *p_stsz;
1616 MP4_Box_data_stz2_t *p_stz2;
1617 MP4_Box_data_stsc_t *p_stsc;
1618 MP4_Box_data_co64_t *p_co64;
1619 MP4_Box_data_stss_t *p_stss;
1620 MP4_Box_data_stsh_t *p_stsh;
1621 MP4_Box_data_stdp_t *p_stdp;
1622 MP4_Box_data_padb_t *p_padb;
1623 MP4_Box_data_elst_t *p_elst;
1624 MP4_Box_data_cprt_t *p_cprt;
1626 MP4_Box_data_dcom_t *p_dcom;
1627 MP4_Box_data_cmvd_t *p_cmvd;
1628 MP4_Box_data_cmov_t *p_cmov;
1630 MP4_Box_data_moviehintinformation_rtp_t *p_moviehintinformation_rtp;
1632 MP4_Box_data_frma_t *p_frma;
1633 MP4_Box_data_skcr_t *p_skcr;
1635 MP4_Box_data_rdrf_t *p_rdrf;
1636 MP4_Box_data_rmdr_t *p_rmdr;
1637 MP4_Box_data_rmqu_t *p_rmqu;
1638 MP4_Box_data_rmvc_t *p_rmvc;
1640 MP4_Box_data_pnot_t *p_pnot;
1641 MP4_Box_data_chpl_t *p_chpl;
1642 MP4_Box_data_HMMT_t *p_hmmt;
1643 MP4_Box_data_tref_generic_t *p_tref_generic;
1645 MP4_Box_data_tfrf_t *p_tfrf;
1646 MP4_Box_data_tfxd_t *p_tfxd;
1647 MP4_Box_data_WMA2_t *p_WMA2; /* flip4mac Little endian audio config */
1648 MP4_Box_data_strf_t *p_strf; /* flip4mac Little endian video config */
1649 MP4_Box_data_ASF_t *p_asf; /* flip4mac asf streams indicator */
1651 MP4_Box_data_360_t *p_360;
1653 /* for generic handlers */
1654 MP4_Box_data_string_t *p_string;
1655 MP4_Box_data_binary_t *p_binary;
1656 MP4_Box_data_data_t *p_data;
1658 void *p_payload; /* for unknown type */
1659 } MP4_Box_data_t;
1661 #define BOXDATA(type) type->data.type
1663 typedef struct MP4_Box_s MP4_Box_t;
1664 /* the most basic structure */
1665 struct MP4_Box_s
1667 uint64_t i_pos; /* absolute position */
1669 uint32_t i_type;
1670 uint32_t i_shortsize;
1671 uint32_t i_handler; /**/
1672 uint32_t i_index; /* indexed list (ilst) */
1674 enum
1676 BOX_FLAG_NONE = 0,
1677 BOX_FLAG_INCOMPLETE,
1678 } e_flags;
1680 UUID_t i_uuid; /* Set if i_type == "uuid" */
1682 uint64_t i_size; /* always set so use it */
1684 MP4_Box_t *p_father; /* pointer on the father Box */
1685 MP4_Box_t *p_first; /* pointer on the first child Box */
1686 MP4_Box_t *p_last;
1687 MP4_Box_t *p_next; /* pointer on the next boxes at the same level */
1689 void (*pf_free)( MP4_Box_t *p_box ); /* pointer to free function for this box */
1691 MP4_Box_data_t data; /* union of pointers on extended data depending
1692 on i_type (or i_usertype) */
1695 static inline size_t mp4_box_headersize( MP4_Box_t *p_box )
1697 return 8
1698 + ( p_box->i_shortsize == 1 ? 8 : 0 )
1699 + ( p_box->i_type == ATOM_uuid ? 16 : 0 );
1702 #define MP4_GETX_PRIVATE(dst, code, size) do { \
1703 if( (i_read) >= (size) ) { dst = (code); p_peek += (size); } \
1704 else { dst = 0; } \
1705 i_read -= (size); \
1706 } while(0)
1708 #define MP4_GET1BYTE( dst ) MP4_GETX_PRIVATE( dst, *p_peek, 1 )
1709 #define MP4_GET2BYTES( dst ) MP4_GETX_PRIVATE( dst, GetWBE(p_peek), 2 )
1710 #define MP4_GET3BYTES( dst ) MP4_GETX_PRIVATE( dst, Get24bBE(p_peek), 3 )
1711 #define MP4_GET4BYTES( dst ) MP4_GETX_PRIVATE( dst, GetDWBE(p_peek), 4 )
1712 #define MP4_GET8BYTES( dst ) MP4_GETX_PRIVATE( dst, GetQWBE(p_peek), 8 )
1713 #define MP4_GETFOURCC( dst ) MP4_GETX_PRIVATE( dst, \
1714 VLC_FOURCC(p_peek[0],p_peek[1],p_peek[2],p_peek[3]), 4)
1716 #define MP4_GET2BYTESLE( dst ) MP4_GETX_PRIVATE( dst, GetWLE(p_peek), 2 )
1717 #define MP4_GET4BYTESLE( dst ) MP4_GETX_PRIVATE( dst, GetDWLE(p_peek), 4 )
1718 #define MP4_GET8BYTESLE( dst ) MP4_GETX_PRIVATE( dst, GetQWLE(p_peek), 8 )
1720 #define MP4_GETVERSIONFLAGS( p_void ) \
1721 MP4_GET1BYTE( p_void->i_version ); \
1722 MP4_GET3BYTES( p_void->i_flags )
1724 #define MP4_GETSTRINGZ( p_str ) \
1725 if( (i_read > 0) && (p_peek[0]) ) \
1727 const int __i_copy__ = strnlen( (char*)p_peek, i_read-1 ); \
1728 p_str = malloc( __i_copy__+1 ); \
1729 if( p_str ) \
1731 memcpy( p_str, p_peek, __i_copy__ ); \
1732 p_str[__i_copy__] = 0; \
1734 p_peek += __i_copy__ + 1; \
1735 i_read -= __i_copy__ + 1; \
1737 else \
1739 p_str = NULL; \
1742 #define MP4_READBOX_ENTER_PARTIAL( MP4_Box_data_TYPE_t, maxread, release ) \
1743 int64_t i_read = p_box->i_size; \
1744 if( maxread < (uint64_t)i_read ) i_read = maxread;\
1745 uint8_t *p_peek, *p_buff; \
1746 ssize_t i_actually_read; \
1747 if( !( p_peek = p_buff = malloc( i_read ) ) ) \
1749 return( 0 ); \
1751 i_actually_read = vlc_stream_Read( p_stream, p_peek, i_read ); \
1752 if( i_actually_read < 0 || i_actually_read < i_read )\
1754 msg_Warn( p_stream, "MP4_READBOX_ENTER: I got %zd bytes, "\
1755 "but I requested %" PRId64, i_actually_read, i_read );\
1756 free( p_buff ); \
1757 return( 0 ); \
1759 p_peek += mp4_box_headersize( p_box ); \
1760 i_read -= mp4_box_headersize( p_box ); \
1761 if( !( p_box->data.p_payload = calloc( 1, sizeof( MP4_Box_data_TYPE_t ) ) ) ) \
1763 free( p_buff ); \
1764 return( 0 ); \
1766 p_box->pf_free = release;
1768 #define MP4_READBOX_ENTER( MP4_Box_data_TYPE_t, release ) \
1769 MP4_READBOX_ENTER_PARTIAL( MP4_Box_data_TYPE_t, p_box->i_size, release )
1771 #define MP4_READBOX_EXIT( i_code ) \
1772 do \
1774 free( p_buff ); \
1775 if( i_read < 0 ) \
1776 msg_Warn( p_stream, "Not enough data" ); \
1777 return( i_code ); \
1778 } while (0)
1781 /* This macro is used when we want to printf the box type
1782 * APPLE annotation box is :
1783 * either 0xA9 + 24-bit ASCII text string (and 0xA9 isn't printable)
1784 * either 32-bit ASCII text string
1786 #define MP4_BOX_TYPE_ASCII() ( ((char*)&p_box->i_type)[0] != (char)0xA9 )
1788 static inline uint32_t Get24bBE( const uint8_t *p )
1790 return( ( p[0] <<16 ) + ( p[1] <<8 ) + p[2] );
1793 static inline void GetUUID( UUID_t *p_uuid, const uint8_t *p_buff )
1795 memcpy( p_uuid, p_buff, 16 );
1798 static inline int CmpUUID( const UUID_t *u1, const UUID_t *u2 )
1800 return memcmp( u1, u2, 16 );
1803 static const UUID_t TfrfBoxUUID = {
1804 { 0xd4, 0x80, 0x7e, 0xf2, 0xca, 0x39, 0x46, 0x95,
1805 0x8e, 0x54, 0x26, 0xcb, 0x9e, 0x46, 0xa7, 0x9f } };
1807 static const UUID_t TfxdBoxUUID = {
1808 { 0x6d, 0x1d, 0x9b, 0x05, 0x42, 0xd5, 0x44, 0xe6,
1809 0x80, 0xe2, 0x14, 0x1d, 0xaf, 0xf7, 0x57, 0xb2 } };
1811 static const UUID_t XML360BoxUUID = {
1812 { 0xff, 0xcc, 0x82, 0x63, 0xf8, 0x55, 0x4a, 0x93,
1813 0x88, 0x14, 0x58, 0x7a, 0x02, 0x52, 0x1f, 0xdd } };
1815 /*****************************************************************************
1816 * MP4_BoxGetNextChunk : Parse the entire moof box.
1817 *****************************************************************************
1818 * The first box is a virtual box "root" and is the father of the boxes
1819 * 'moof' and, possibly, 'sidx'.
1820 *****************************************************************************/
1821 MP4_Box_t *MP4_BoxGetNextChunk( stream_t * );
1823 /*****************************************************************************
1824 * MP4_BoxGetRoot : Parse the entire file, and create all boxes in memory
1825 *****************************************************************************
1826 * The first box is a virtual box "root" and is the father for all first
1827 * level boxes
1828 *****************************************************************************/
1829 MP4_Box_t *MP4_BoxGetRoot( stream_t * );
1831 /*****************************************************************************
1832 * MP4_BoxNew : Allocates a new MP4 Box with its atom type
1833 *****************************************************************************
1834 * returns NULL on failure
1835 *****************************************************************************/
1836 MP4_Box_t * MP4_BoxNew( uint32_t i_type );
1838 /*****************************************************************************
1839 * MP4_FreeBox : free memory allocated after read with MP4_ReadBox
1840 * or MP4_BoxGetRoot, this means also children boxes
1841 * XXX : all children have to be allocated by a malloc !! and
1842 * p_box is freed
1843 *****************************************************************************/
1844 void MP4_BoxFree( MP4_Box_t *p_box );
1846 /*****************************************************************************
1847 * MP4_DumpBoxStructure: print the structure of the p_box
1848 *****************************************************************************
1849 * Useful while debugging
1850 *****************************************************************************/
1851 void MP4_BoxDumpStructure( stream_t *p_input, const MP4_Box_t *p_box );
1853 /*****************************************************************************
1854 * MP4_BoxGet: find a box given a path relative to p_box
1855 *****************************************************************************
1856 * Path Format: . .. / as usual
1857 * [number] to specifie box number ex: trak[12]
1859 * ex: /moov/trak[12]
1860 * ../mdia
1861 *****************************************************************************/
1862 MP4_Box_t *MP4_BoxGet( const MP4_Box_t *p_box, const char *psz_fmt, ... );
1864 /*****************************************************************************
1865 * MP4_BoxCount: find number of box given a path relative to p_box
1866 *****************************************************************************
1867 * Path Format: . .. / as usual
1868 * [number] to specifie box number ex: trak[12]
1870 * ex: /moov/trak
1871 * ../mdia
1872 *****************************************************************************/
1873 unsigned MP4_BoxCount( const MP4_Box_t *p_box, const char *psz_fmt, ... );
1875 MP4_Box_t * MP4_BoxExtract( MP4_Box_t **pp_chain, uint32_t i_type );
1877 /* Internal functions exposed for demuxers */
1878 int MP4_ReadBoxContainerChildren( stream_t *p_stream, MP4_Box_t *p_container,
1879 const uint32_t stoplist[] );
1880 int MP4_ReadBox_sample_vide( stream_t *p_stream, MP4_Box_t *p_box );
1882 #endif