]> git.sesse.net Git - vlc/blob - modules/demux/mp4/libmp4.h
f1c5d70e5bb2008462f31e579717bfff8a764c10
[vlc] / modules / demux / mp4 / libmp4.h
1 /*****************************************************************************
2  * libmp4.h : LibMP4 library for mp4 module for vlc
3  *****************************************************************************
4  * Copyright (C) 2001-2004, 2010 VLC authors and VideoLAN
5  *
6  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
7  *
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.
12  *
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.
17  *
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
23 #ifndef _VLC_LIBMP4_H
24 #define _VLC_LIBMP4_H 1
25
26 #include <vlc_es.h>
27 #include <vlc_codecs.h>
28
29 #define BLOCK16x16 (1<<16)
30
31 #define MAJOR_3gp4 VLC_FOURCC( '3', 'g', 'p', '4' )
32 #define MAJOR_3gp5 VLC_FOURCC( '3', 'g', 'p', '5' )
33 #define MAJOR_3gp6 VLC_FOURCC( '3', 'g', 'p', '6' )
34 #define MAJOR_3gp7 VLC_FOURCC( '3', 'g', 'p', '7' )
35 #define MAJOR_isml VLC_FOURCC( 'i', 's', 'm', 'l' )
36 #define MAJOR_isom VLC_FOURCC( 'i', 's', 'o', 'm' )
37 #define MAJOR_qt__ VLC_FOURCC( 'q', 't', ' ', ' ' )
38
39 #define ATOM_root VLC_FOURCC( 'r', 'o', 'o', 't' )
40 #define ATOM_uuid VLC_FOURCC( 'u', 'u', 'i', 'd' )
41
42 #define ATOM_ftyp VLC_FOURCC( 'f', 't', 'y', 'p' )
43 #define ATOM_moov VLC_FOURCC( 'm', 'o', 'o', 'v' )
44 #define ATOM_foov VLC_FOURCC( 'f', 'o', 'o', 'v' )
45 #define ATOM_cmov VLC_FOURCC( 'c', 'm', 'o', 'v' )
46 #define ATOM_dcom VLC_FOURCC( 'd', 'c', 'o', 'm' )
47 #define ATOM_cmvd VLC_FOURCC( 'c', 'm', 'v', 'd' )
48
49 #define ATOM_moof VLC_FOURCC( 'm', 'o', 'o', 'f' )
50 #define ATOM_mdat VLC_FOURCC( 'm', 'd', 'a', 't' )
51 #define ATOM_skip VLC_FOURCC( 's', 'k', 'i', 'p' )
52 #define ATOM_free VLC_FOURCC( 'f', 'r', 'e', 'e' )
53 #define ATOM_udta VLC_FOURCC( 'u', 'd', 't', 'a' )
54 #define ATOM_wide VLC_FOURCC( 'w', 'i', 'd', 'e' )
55 #define ATOM_binm VLC_FOURCC( 0x82, 0x82, 0x7f, 0x7d ) /* binary Computer Graphics Metafile */
56
57 #define ATOM_data VLC_FOURCC( 'd', 'a', 't', 'a' )
58
59 #define ATOM_trak VLC_FOURCC( 't', 'r', 'a', 'k' )
60 #define ATOM_mvhd VLC_FOURCC( 'm', 'v', 'h', 'd' )
61 #define ATOM_tkhd VLC_FOURCC( 't', 'k', 'h', 'd' )
62 #define ATOM_tref VLC_FOURCC( 't', 'r', 'e', 'f' )
63 #define ATOM_mdia VLC_FOURCC( 'm', 'd', 'i', 'a' )
64 #define ATOM_mdhd VLC_FOURCC( 'm', 'd', 'h', 'd' )
65 #define ATOM_hdlr VLC_FOURCC( 'h', 'd', 'l', 'r' )
66 #define ATOM_minf VLC_FOURCC( 'm', 'i', 'n', 'f' )
67 #define ATOM_vmhd VLC_FOURCC( 'v', 'm', 'h', 'd' )
68 #define ATOM_smhd VLC_FOURCC( 's', 'm', 'h', 'd' )
69 #define ATOM_hmhd VLC_FOURCC( 'h', 'm', 'h', 'd' )
70 #define ATOM_dinf VLC_FOURCC( 'd', 'i', 'n', 'f' )
71 #define ATOM_url  VLC_FOURCC( 'u', 'r', 'l', ' ' )
72 #define ATOM_urn  VLC_FOURCC( 'u', 'r', 'n', ' ' )
73 #define ATOM_dref VLC_FOURCC( 'd', 'r', 'e', 'f' )
74 #define ATOM_stbl VLC_FOURCC( 's', 't', 'b', 'l' )
75 #define ATOM_stts VLC_FOURCC( 's', 't', 't', 's' )
76 #define ATOM_ctts VLC_FOURCC( 'c', 't', 't', 's' )
77 #define ATOM_stsd VLC_FOURCC( 's', 't', 's', 'd' )
78 #define ATOM_stsz VLC_FOURCC( 's', 't', 's', 'z' )
79 #define ATOM_stz2 VLC_FOURCC( 's', 't', 'z', '2' )
80 #define ATOM_stsc VLC_FOURCC( 's', 't', 's', 'c' )
81 #define ATOM_stco VLC_FOURCC( 's', 't', 'c', 'o' )
82 #define ATOM_co64 VLC_FOURCC( 'c', 'o', '6', '4' )
83 #define ATOM_stss VLC_FOURCC( 's', 't', 's', 's' )
84 #define ATOM_stsh VLC_FOURCC( 's', 't', 's', 'h' )
85 #define ATOM_stdp VLC_FOURCC( 's', 't', 'd', 'p' )
86 #define ATOM_padb VLC_FOURCC( 'p', 'a', 'd', 'b' )
87 #define ATOM_edts VLC_FOURCC( 'e', 'd', 't', 's' )
88 #define ATOM_elst VLC_FOURCC( 'e', 'l', 's', 't' )
89 #define ATOM_mvex VLC_FOURCC( 'm', 'v', 'e', 'x' )
90 #define ATOM_sdtp VLC_FOURCC( 's', 'd', 't', 'p' )
91 #define ATOM_trex VLC_FOURCC( 't', 'r', 'e', 'x' )
92 #define ATOM_mehd VLC_FOURCC( 'm', 'e', 'h', 'd' )
93 #define ATOM_mfhd VLC_FOURCC( 'm', 'f', 'h', 'd' )
94 #define ATOM_traf VLC_FOURCC( 't', 'r', 'a', 'f' )
95 #define ATOM_sidx VLC_FOURCC( 's', 'i', 'd', 'x' )
96 #define ATOM_tfhd VLC_FOURCC( 't', 'f', 'h', 'd' )
97 #define ATOM_trun VLC_FOURCC( 't', 'r', 'u', 'n' )
98 #define ATOM_cprt VLC_FOURCC( 'c', 'p', 'r', 't' )
99 #define ATOM_iods VLC_FOURCC( 'i', 'o', 'd', 's' )
100 #define ATOM_pasp VLC_FOURCC( 'p', 'a', 's', 'p' )
101 #define ATOM_mfra VLC_FOURCC( 'm', 'f', 'r', 'a' )
102 #define ATOM_mfro VLC_FOURCC( 'm', 'f', 'r', 'o' )
103 #define ATOM_tfra VLC_FOURCC( 't', 'f', 'r', 'a' )
104 #define ATOM_keys VLC_FOURCC( 'k', 'e', 'y', 's' )
105
106 #define ATOM_nmhd VLC_FOURCC( 'n', 'm', 'h', 'd' )
107 #define ATOM_mp2v VLC_FOURCC( 'm', 'p', '2', 'v' )
108 #define ATOM_mp4v VLC_FOURCC( 'm', 'p', '4', 'v' )
109 #define ATOM_mp4a VLC_FOURCC( 'm', 'p', '4', 'a' )
110 #define ATOM_mp4s VLC_FOURCC( 'm', 'p', '4', 's' )
111 #define ATOM_vide VLC_FOURCC( 'v', 'i', 'd', 'e' )
112 #define ATOM_soun VLC_FOURCC( 's', 'o', 'u', 'n' )
113 #define ATOM_hint VLC_FOURCC( 'h', 'i', 'n', 't' )
114 #define ATOM_hdv2 VLC_FOURCC( 'h', 'd', 'v', '2' )
115
116 #define ATOM_dpnd VLC_FOURCC( 'd', 'p', 'n', 'd' )
117 #define ATOM_ipir VLC_FOURCC( 'i', 'p', 'i', 'r' )
118 #define ATOM_mpod VLC_FOURCC( 'm', 'p', 'o', 'd' )
119 #define ATOM_hnti VLC_FOURCC( 'h', 'n', 't', 'i' )
120 #define ATOM_rtp  VLC_FOURCC( 'r', 't', 'p', ' ' )
121
122 #define ATOM_esds VLC_FOURCC( 'e', 's', 'd', 's' )
123
124 #define ATOM_lpcm VLC_FOURCC( 'l', 'p', 'c', 'm' )
125 #define ATOM__mp3 VLC_FOURCC( '.', 'm', 'p', '3' )
126 #define ATOM_ms02 VLC_FOURCC( 'm', 's', 0x0, 0x02 )
127 #define ATOM_ms11 VLC_FOURCC( 'm', 's', 0x0, 0x11 )
128 #define ATOM_ms55 VLC_FOURCC( 'm', 's', 0x0, 0x55 )
129 #define ATOM_twos VLC_FOURCC( 't', 'w', 'o', 's' )
130 #define ATOM_sowt VLC_FOURCC( 's', 'o', 'w', 't' )
131 #define ATOM_QDMC VLC_FOURCC( 'Q', 'D', 'M', 'C' )
132 #define ATOM_QDM2 VLC_FOURCC( 'Q', 'D', 'M', '2' )
133 #define ATOM_ima4 VLC_FOURCC( 'i', 'm', 'a', '4' )
134 #define ATOM_IMA4 VLC_FOURCC( 'I', 'M', 'A', '4' )
135 #define ATOM_dvi  VLC_FOURCC( 'd', 'v', 'i', ' ' )
136 #define ATOM_MAC3 VLC_FOURCC( 'M', 'A', 'C', '3' )
137 #define ATOM_MAC6 VLC_FOURCC( 'M', 'A', 'C', '6' )
138 #define ATOM_alaw VLC_FOURCC( 'a', 'l', 'a', 'w' )
139 #define ATOM_ulaw VLC_FOURCC( 'u', 'l', 'a', 'w' )
140 #define ATOM_Qclp VLC_FOURCC( 'Q', 'c', 'l', 'p' )
141 #define ATOM_samr VLC_FOURCC( 's', 'a', 'm', 'r' )
142 #define ATOM_sawb VLC_FOURCC( 's', 'a', 'w', 'b' )
143 #define ATOM_OggS VLC_FOURCC( 'O', 'g', 'g', 'S' )
144 #define ATOM_alac VLC_FOURCC( 'a', 'l', 'a', 'c' )
145 #define ATOM_ac3  VLC_FOURCC( 'a', 'c', '-', '3' )
146 #define ATOM_eac3 VLC_FOURCC( 'e', 'c', '-', '3' )
147 #define ATOM_dac3 VLC_FOURCC( 'd', 'a', 'c', '3' )
148 #define ATOM_dec3 VLC_FOURCC( 'd', 'e', 'c', '3' )
149 #define ATOM_dvc1 VLC_FOURCC( 'd', 'v', 'c', '1' )
150 #define ATOM_WMA2 VLC_FOURCC( 'W', 'M', 'A', '2' )
151 #define ATOM_enda VLC_FOURCC( 'e', 'n', 'd', 'a' )
152 #define ATOM_gnre VLC_FOURCC( 'g', 'n', 'r', 'e' )
153 #define ATOM_trkn VLC_FOURCC( 't', 'r', 'k', 'n' )
154 #define ATOM_chan VLC_FOURCC( 'c', 'h', 'a', 'n' )
155 #define ATOM_in24 VLC_FOURCC( 'i', 'n', '2', '4' )
156 #define ATOM_in32 VLC_FOURCC( 'i', 'n', '3', '2' )
157 #define ATOM_fl32 VLC_FOURCC( 'f', 'l', '3', '2' )
158 #define ATOM_fl64 VLC_FOURCC( 'f', 'l', '6', '4' )
159
160 #define ATOM_zlib VLC_FOURCC( 'z', 'l', 'i', 'b' )
161 #define ATOM_SVQ1 VLC_FOURCC( 'S', 'V', 'Q', '1' )
162 #define ATOM_SVQ3 VLC_FOURCC( 'S', 'V', 'Q', '3' )
163 #define ATOM_ZyGo VLC_FOURCC( 'Z', 'y', 'G', 'o' )
164 #define ATOM_3IV1 VLC_FOURCC( '3', 'I', 'V', '1' )
165 #define ATOM_3iv1 VLC_FOURCC( '3', 'i', 'v', '1' )
166 #define ATOM_3IV2 VLC_FOURCC( '3', 'I', 'V', '2' )
167 #define ATOM_3iv2 VLC_FOURCC( '3', 'i', 'v', '2' )
168 #define ATOM_3IVD VLC_FOURCC( '3', 'I', 'V', 'D' )
169 #define ATOM_3ivd VLC_FOURCC( '3', 'i', 'v', 'd' )
170 #define ATOM_3VID VLC_FOURCC( '3', 'V', 'I', 'D' )
171 #define ATOM_3vid VLC_FOURCC( '3', 'v', 'i', 'd' )
172 #define ATOM_h263 VLC_FOURCC( 'h', '2', '6', '3' )
173 #define ATOM_s263 VLC_FOURCC( 's', '2', '6', '3' )
174 #define ATOM_DIVX VLC_FOURCC( 'D', 'I', 'V', 'X' )
175 #define ATOM_XVID VLC_FOURCC( 'X', 'V', 'I', 'D' )
176 #define ATOM_cvid VLC_FOURCC( 'c', 'v', 'i', 'd' )
177 #define ATOM_mjpa VLC_FOURCC( 'm', 'j', 'p', 'a' )
178 #define ATOM_mjpb VLC_FOURCC( 'm', 'j', 'q', 't' )
179 #define ATOM_mjqt VLC_FOURCC( 'm', 'j', 'h', 't' )
180 #define ATOM_mjht VLC_FOURCC( 'm', 'j', 'p', 'b' )
181 #define ATOM_VP31 VLC_FOURCC( 'V', 'P', '3', '1' )
182 #define ATOM_vp31 VLC_FOURCC( 'v', 'p', '3', '1' )
183 #define ATOM_h264 VLC_FOURCC( 'h', '2', '6', '4' )
184 #define ATOM_qdrw VLC_FOURCC( 'q', 'd', 'r', 'w' )
185 #define ATOM_WMV3 VLC_FOURCC( 'W', 'M', 'V', '3' )
186
187 #define ATOM_avc1 VLC_FOURCC( 'a', 'v', 'c', '1' )
188 #define ATOM_avcC VLC_FOURCC( 'a', 'v', 'c', 'C' )
189 #define ATOM_m4ds VLC_FOURCC( 'm', '4', 'd', 's' )
190
191 #define ATOM_hvcC VLC_FOURCC( 'h', 'v', 'c', 'C' )
192
193 #define ATOM_dvc  VLC_FOURCC( 'd', 'v', 'c', ' ' )
194 #define ATOM_dvp  VLC_FOURCC( 'd', 'v', 'p', ' ' )
195 #define ATOM_dv5n VLC_FOURCC( 'd', 'v', '5', 'n' )
196 #define ATOM_dv5p VLC_FOURCC( 'd', 'v', '5', 'p' )
197 #define ATOM_raw  VLC_FOURCC( 'r', 'a', 'w', ' ' )
198
199 #define ATOM_jpeg VLC_FOURCC( 'j', 'p', 'e', 'g' )
200
201 #define ATOM_yv12 VLC_FOURCC( 'y', 'v', '1', '2' )
202 #define ATOM_yuv2 VLC_FOURCC( 'y', 'u', 'v', '2' )
203
204 #define ATOM_rmra VLC_FOURCC( 'r', 'm', 'r', 'a' )
205 #define ATOM_rmda VLC_FOURCC( 'r', 'm', 'd', 'a' )
206 #define ATOM_rdrf VLC_FOURCC( 'r', 'd', 'r', 'f' )
207 #define ATOM_rmdr VLC_FOURCC( 'r', 'm', 'd', 'r' )
208 #define ATOM_rmvc VLC_FOURCC( 'r', 'm', 'v', 'c' )
209 #define ATOM_rmcd VLC_FOURCC( 'r', 'm', 'c', 'd' )
210 #define ATOM_rmqu VLC_FOURCC( 'r', 'm', 'q', 'u' )
211 #define ATOM_alis VLC_FOURCC( 'a', 'l', 'i', 's' )
212
213 #define ATOM_gmhd VLC_FOURCC( 'g', 'm', 'h', 'd' )
214 #define ATOM_wave VLC_FOURCC( 'w', 'a', 'v', 'e' )
215 #define ATOM_strf VLC_FOURCC( 's', 't', 'r', 'f' )
216
217 #define ATOM_drms VLC_FOURCC( 'd', 'r', 'm', 's' )
218 #define ATOM_sinf VLC_FOURCC( 's', 'i', 'n', 'f' )
219 #define ATOM_schi VLC_FOURCC( 's', 'c', 'h', 'i' )
220 #define ATOM_user VLC_FOURCC( 'u', 's', 'e', 'r' )
221 #define ATOM_key  VLC_FOURCC( 'k', 'e', 'y', ' ' )
222 #define ATOM_iviv VLC_FOURCC( 'i', 'v', 'i', 'v' )
223 #define ATOM_name VLC_FOURCC( 'n', 'a', 'm', 'e' )
224 #define ATOM_priv VLC_FOURCC( 'p', 'r', 'i', 'v' )
225 #define ATOM_drmi VLC_FOURCC( 'd', 'r', 'm', 'i' )
226 #define ATOM_frma VLC_FOURCC( 'f', 'r', 'm', 'a' )
227 #define ATOM_skcr VLC_FOURCC( 's', 'k', 'c', 'r' )
228 #define ATOM_ASF  VLC_FOURCC( 'A', 'S', 'F', ' ' )
229
230 #define ATOM_text VLC_FOURCC( 't', 'e', 'x', 't' )
231 #define ATOM_tx3g VLC_FOURCC( 't', 'x', '3', 'g' )
232 #define ATOM_subp VLC_FOURCC( 's', 'u', 'b', 'p' )
233 #define ATOM_sbtl VLC_FOURCC( 's', 'b', 't', 'l' )
234 #define ATOM_clcp VLC_FOURCC( 'c', 'l', 'c', 'p' )
235 #define ATOM_c608 VLC_FOURCC( 'c', '6', '0', '8' )
236 #define ATOM_c708 VLC_FOURCC( 'c', '7', '0', '8' )
237
238 #define ATOM_0xa9nam VLC_FOURCC( 0xa9, 'n', 'a', 'm' )
239 #define ATOM_0xa9aut VLC_FOURCC( 0xa9, 'a', 'u', 't' )
240 #define ATOM_0xa9cpy VLC_FOURCC( 0xa9, 'c', 'p', 'y' )
241 #define ATOM_0xa9inf VLC_FOURCC( 0xa9, 'i', 'n', 'f' )
242 #define ATOM_0xa9isr VLC_FOURCC( 0xa9, 'i', 's', 'r' )
243 #define ATOM_0xa9lab VLC_FOURCC( 0xa9, 'l', 'a', 'b' )
244 #define ATOM_0xa9lal VLC_FOURCC( 0xa9, 'l', 'a', 'l' )
245 #define ATOM_0xa9ART VLC_FOURCC( 0xa9, 'A', 'R', 'T' )
246 #define ATOM_0xa9des VLC_FOURCC( 0xa9, 'd', 'e', 's' )
247 #define ATOM_0xa9dir VLC_FOURCC( 0xa9, 'd', 'i', 'r' )
248 #define ATOM_0xa9cmt VLC_FOURCC( 0xa9, 'c', 'm', 't' )
249 #define ATOM_0xa9req VLC_FOURCC( 0xa9, 'r', 'e', 'q' )
250 #define ATOM_0xa9day VLC_FOURCC( 0xa9, 'd', 'a', 'y' )
251 #define ATOM_0xa9fmt VLC_FOURCC( 0xa9, 'f', 'm', 't' )
252 #define ATOM_0xa9prd VLC_FOURCC( 0xa9, 'p', 'r', 'd' )
253 #define ATOM_0xa9prf VLC_FOURCC( 0xa9, 'p', 'r', 'f' )
254 #define ATOM_0xa9src VLC_FOURCC( 0xa9, 's', 'r', 'c' )
255 #define ATOM_0xa9alb VLC_FOURCC( 0xa9, 'a', 'l', 'b' )
256 #define ATOM_0xa9dis VLC_FOURCC( 0xa9, 'd', 'i', 's' )
257 #define ATOM_0xa9enc VLC_FOURCC( 0xa9, 'e', 'n', 'c' )
258 #define ATOM_0xa9trk VLC_FOURCC( 0xa9, 't', 'r', 'k' )
259 #define ATOM_0xa9url VLC_FOURCC( 0xa9, 'u', 'r', 'l' )
260 #define ATOM_0xa9dsa VLC_FOURCC( 0xa9, 'd', 's', 'a' )
261 #define ATOM_0xa9hst VLC_FOURCC( 0xa9, 'h', 's', 't' )
262 #define ATOM_0xa9ope VLC_FOURCC( 0xa9, 'o', 'p', 'e' )
263 #define ATOM_0xa9wrt VLC_FOURCC( 0xa9, 'w', 'r', 't' )
264 #define ATOM_0xa9com VLC_FOURCC( 0xa9, 'c', 'o', 'm' )
265 #define ATOM_0xa9gen VLC_FOURCC( 0xa9, 'g', 'e', 'n' )
266 #define ATOM_0xa9too VLC_FOURCC( 0xa9, 't', 'o', 'o' )
267 #define ATOM_0xa9wrn VLC_FOURCC( 0xa9, 'w', 'r', 'n' )
268 #define ATOM_0xa9swr VLC_FOURCC( 0xa9, 's', 'w', 'r' )
269 #define ATOM_0xa9mak VLC_FOURCC( 0xa9, 'm', 'a', 'k' )
270 #define ATOM_0xa9mal VLC_FOURCC( 0xa9, 'm', 'a', 'l' )
271 #define ATOM_0xa9mod VLC_FOURCC( 0xa9, 'm', 'o', 'd' )
272 #define ATOM_0xa9PRD VLC_FOURCC( 0xa9, 'P', 'R', 'D' )
273 #define ATOM_0xa9grp VLC_FOURCC( 0xa9, 'g', 'r', 'p' )
274 #define ATOM_0xa9lyr VLC_FOURCC( 0xa9, 'l', 'y', 'r' )
275 #define ATOM_0xa9gen VLC_FOURCC( 0xa9, 'g', 'e', 'n' )
276 #define ATOM_0xa9st3 VLC_FOURCC( 0xa9, 's', 't', '3' )
277 #define ATOM_0xa9ard VLC_FOURCC( 0xa9, 'a', 'r', 'd' )
278 #define ATOM_0xa9arg VLC_FOURCC( 0xa9, 'a', 'r', 'g' )
279 #define ATOM_0xa9cak VLC_FOURCC( 0xa9, 'c', 'a', 'k' )
280 #define ATOM_0xa9con VLC_FOURCC( 0xa9, 'c', 'o', 'n' )
281 #define ATOM_0xa9des VLC_FOURCC( 0xa9, 'd', 'e', 's' )
282 #define ATOM_0xa9lnt VLC_FOURCC( 0xa9, 'l', 'n', 't' )
283 #define ATOM_0xa9phg VLC_FOURCC( 0xa9, 'p', 'h', 'g' )
284 #define ATOM_0xa9pub VLC_FOURCC( 0xa9, 'p', 'u', 'b' )
285 #define ATOM_0xa9sne VLC_FOURCC( 0xa9, 's', 'n', 'e' )
286 #define ATOM_0xa9snm VLC_FOURCC( 0xa9, 's', 'n', 'm' )
287 #define ATOM_0xa9sol VLC_FOURCC( 0xa9, 's', 'o', 'l' )
288 #define ATOM_0xa9thx VLC_FOURCC( 0xa9, 't', 'h', 'x' )
289 #define ATOM_0xa9xpd VLC_FOURCC( 0xa9, 'x', 'p', 'd' )
290 #define ATOM_0xa9xyz VLC_FOURCC( 0xa9, 'x', 'y', 'z' )
291 #define ATOM_aART VLC_FOURCC( 'a', 'A', 'R', 'T' )
292 #define ATOM_chpl VLC_FOURCC( 'c', 'h', 'p', 'l' )
293 #define ATOM_disk VLC_FOURCC( 'd', 'i', 's', 'k' )
294 #define ATOM_WLOC VLC_FOURCC( 'W', 'L', 'O', 'C' )
295
296 #define ATOM_meta VLC_FOURCC( 'm', 'e', 't', 'a' )
297 #define ATOM_atID VLC_FOURCC( 'a', 't', 'I', 'D' )
298 #define ATOM_ilst VLC_FOURCC( 'i', 'l', 's', 't' )
299 #define ATOM_cnID VLC_FOURCC( 'c', 'n', 'I', 'D' )
300 #define ATOM_covr VLC_FOURCC( 'c', 'o', 'v', 'r' )
301 #define ATOM_flvr VLC_FOURCC( 'f', 'l', 'v', 'r' )
302 #define ATOM_rtng VLC_FOURCC( 'r', 't', 'n', 'g' )
303 #define ATOM_tsel VLC_FOURCC( 't', 's', 'e', 'l' )
304 #define ATOM_xid_ VLC_FOURCC( 'x', 'i', 'd', ' ' )
305
306 #define ATOM_chap VLC_FOURCC( 'c', 'h', 'a', 'p' )
307 #define ATOM_SDLN VLC_FOURCC( 'S', 'D', 'L', 'N' )
308 #define ATOM_vndr VLC_FOURCC( 'v', 'n', 'd', 'r' )
309
310 #define HANDLER_mdta VLC_FOURCC('m', 'd', 't', 'a')
311 #define HANDLER_mdir VLC_FOURCC('m', 'd', 'i', 'r')
312
313 /* Do you want some debug information on all read boxes ? */
314 #ifndef NDEBUG
315 # define MP4_VERBOSE  1
316 //# define MP4_ULTRA_VERBOSE  1
317 #endif
318
319 struct MP4_Box_s;
320
321 #define MP4_MFRO_BOXSIZE 16
322
323 /* uuid Universal Unique IDentifiers */
324 typedef struct UUID_s
325 {
326     uint8_t b[16];
327 } UUID_t;
328
329 /* specific structure for all boxes */
330
331 typedef struct MP4_Box_data_tfxd_s
332 {
333     uint8_t  i_version;
334     uint32_t i_flags;
335
336     uint64_t i_fragment_duration;
337     uint64_t i_fragment_abs_time;
338
339 } MP4_Box_data_tfxd_t;
340
341 typedef struct TfrfBoxDataFields_s
342 {
343     uint64_t i_fragment_duration;
344     uint64_t i_fragment_abs_time;
345
346 } TfrfBoxDataFields_t;
347
348 typedef struct MP4_Box_data_tfrf_s
349 {
350     uint8_t  i_version;
351     uint8_t  i_fragment_count;
352     uint32_t i_flags;
353
354     TfrfBoxDataFields_t *p_tfrf_data_fields;
355
356 } MP4_Box_data_tfrf_t;
357
358 typedef struct MP4_Box_data_ftyp_s
359 {
360     uint32_t i_major_brand;
361     uint32_t i_minor_version;
362
363     uint32_t i_compatible_brands_count;
364     uint32_t *i_compatible_brands;
365
366 } MP4_Box_data_ftyp_t;
367
368 typedef struct MP4_Box_data_mvhd_s
369 {
370     uint8_t  i_version;
371     uint32_t i_flags;
372
373     uint64_t i_creation_time;
374     uint64_t i_modification_time;
375     uint32_t i_timescale;
376     uint64_t i_duration;
377
378     int32_t  i_rate;
379     int16_t  i_volume;
380     int16_t  i_reserved1;
381     uint32_t i_reserved2[2];
382     int32_t  i_matrix[9];
383     uint32_t i_predefined[6];
384     uint32_t i_next_track_id;
385
386 } MP4_Box_data_mvhd_t;
387
388 #define MP4_TRACK_ENABLED    0x000001
389 #define MP4_TRACK_IN_MOVIE   0x000002
390 #define MP4_TRACK_IN_PREVIEW 0x000004
391 typedef struct MP4_Box_data_tkhd_s
392 {
393     uint8_t  i_version;
394     uint32_t i_flags;
395
396     uint64_t i_creation_time;
397     uint64_t i_modification_time;
398     uint32_t i_track_ID;
399     uint32_t i_reserved;
400     uint64_t i_duration;
401
402     uint32_t i_reserved2[2];
403     int16_t  i_layer;
404     int16_t  i_predefined;
405
406     int16_t  i_volume;
407     uint16_t i_reserved3;
408     int32_t  i_matrix[9];
409     int32_t  i_width;
410     int32_t  i_height;
411     float    f_rotation;
412
413 } MP4_Box_data_tkhd_t;
414
415 typedef struct MP4_Box_data_mdhd_s
416 {
417     uint8_t  i_version;
418     uint32_t i_flags;
419
420     uint64_t i_creation_time;
421     uint64_t i_modification_time;
422     uint32_t i_timescale;
423     uint64_t i_duration;
424
425     char     rgs_language[3]; /* ISO-639-2/T or Mac lang table */
426     bool     b_mac_encoding;  /* media using mac encoding */
427
428     uint16_t i_quality;
429
430 } MP4_Box_data_mdhd_t;
431
432 typedef struct MP4_Box_data_hdlr_s
433 {
434     uint8_t  i_version;
435     uint32_t i_flags;
436
437     uint32_t i_predefined;
438     uint32_t i_handler_type; /* "vide" "soun" "hint" "odsm"
439                            "crsm" "sdsm" "m7sm" "ocsm"
440                            "ipsm" "mjsm" */
441
442     unsigned char *psz_name; /* in UTF-8 */
443
444 } MP4_Box_data_hdlr_t;
445
446 typedef struct MP4_Box_data_vmhd_s
447 {
448     uint8_t  i_version;
449     uint32_t i_flags;
450
451     int16_t  i_graphics_mode;
452     int16_t  i_opcolor[3];
453
454 } MP4_Box_data_vmhd_t;
455
456 typedef struct MP4_Box_data_smhd_s
457 {
458     uint8_t  i_version;
459     uint32_t i_flags;
460
461     int16_t  i_balance;
462     int16_t  i_reserved;
463
464 } MP4_Box_data_smhd_t;
465
466 typedef struct MP4_Box_data_hmhd_s
467 {
468     uint8_t  i_version;
469     uint32_t i_flags;
470
471     uint16_t i_max_PDU_size;
472     uint16_t i_avg_PDU_size;
473     uint32_t i_max_bitrate;
474     uint32_t i_avg_bitrate;
475     uint32_t i_reserved;
476
477 } MP4_Box_data_hmhd_t;
478
479 typedef struct MP4_Box_data_url_s
480 {
481     uint8_t  i_version;
482     uint32_t i_flags;
483
484     char *psz_location;
485
486 } MP4_Box_data_url_t;
487
488 typedef struct MP4_Box_data_urn_s
489 {
490     uint8_t  i_version;
491     uint32_t i_flags;
492
493     char *psz_name;
494     char *psz_location;
495
496 } MP4_Box_data_urn_t;
497
498 typedef struct MP4_Box_data_dref_s
499 {
500     uint8_t  i_version;
501     uint32_t i_flags;
502
503     uint32_t i_entry_count;
504 /* XXX it's also a container with i_entry_count entry */
505 } MP4_Box_data_dref_t;
506
507 typedef struct MP4_Box_data_stts_s
508 {
509     uint8_t  i_version;
510     uint32_t i_flags;
511
512     uint32_t i_entry_count;
513     uint32_t *pi_sample_count; /* these are array */
514     int32_t  *pi_sample_delta;
515
516 } MP4_Box_data_stts_t;
517
518 typedef struct MP4_Box_data_ctts_s
519 {
520     uint8_t  i_version;
521     uint32_t i_flags;
522
523     uint32_t i_entry_count;
524
525     uint32_t *pi_sample_count; /* these are array */
526     int32_t *pi_sample_offset;
527
528 } MP4_Box_data_ctts_t;
529
530
531 typedef struct MP4_Box_data_sample_soun_s
532 {
533     uint8_t  i_reserved1[6];
534     uint16_t i_data_reference_index;
535
536     //uint32_t i_reserved2[2];
537     uint16_t i_qt_version;
538     uint16_t i_qt_revision_level;
539     uint32_t i_qt_vendor;
540
541     uint16_t i_channelcount;
542     uint16_t i_samplesize;
543     uint16_t i_compressionid;
544     uint16_t i_reserved3;
545     uint16_t i_sampleratehi; /* timescale of track */
546     uint16_t i_sampleratelo;
547
548     /* for version 1 (i_reserved1[0] == 1) */
549     uint32_t i_sample_per_packet;
550     uint32_t i_bytes_per_packet;
551     uint32_t i_bytes_per_frame;
552     uint32_t i_bytes_per_sample;
553
554     /* v2 */
555     uint32_t i_constbitsperchannel; /* consts are nonzero only if constant */
556     uint32_t i_formatflags;
557     uint32_t i_constbytesperaudiopacket;
558     uint32_t i_constLPCMframesperaudiopacket;
559
560     /* XXX hack */
561     int     i_qt_description;
562     uint8_t *p_qt_description;
563
564 } MP4_Box_data_sample_soun_t;
565
566 typedef struct MP4_Box_data_sample_vide_s
567 {
568     uint8_t  i_reserved1[6];
569     uint16_t i_data_reference_index;
570
571     uint16_t i_qt_version;
572     uint16_t i_qt_revision_level;
573     uint32_t i_qt_vendor;
574
575     uint32_t i_qt_temporal_quality;
576     uint32_t i_qt_spatial_quality;
577
578     int16_t  i_width;
579     int16_t  i_height;
580
581     uint32_t i_horizresolution;
582     uint32_t i_vertresolution;
583
584     uint32_t i_qt_data_size;
585     uint16_t i_qt_frame_count;
586
587     uint8_t  i_compressorname[32];
588     int16_t  i_depth;
589
590     int16_t  i_qt_color_table;
591
592     /* XXX hack ImageDescription */
593     int     i_qt_image_description;
594     uint8_t *p_qt_image_description;
595
596 } MP4_Box_data_sample_vide_t;
597
598 #define MP4_TEXT_DISPLAY_FLAG_DONT_DISPLAY       (1<<0)
599 #define MP4_TEXT_DISPLAY_FLAG_AUTO_SCALE         (1<<1)
600 #define MP4_TEXT_DISPLAY_FLAG_CLIP_TO_TEXT_BOX   (1<<2)
601 #define MP4_TEXT_DISPLAY_FLAG_USE_MOVIE_BG_COLOR (1<<3)
602 #define MP4_TEXT_DISPLAY_FLAG_SHRINK_TEXT_BOX_TO_FIT (1<<4)
603 #define MP4_TEXT_DISPLAY_FLAG_SCROLL_IN          (1<<5)
604 #define MP4_TEXT_DISPLAY_FLAG_SCROLL_OUT         (1<<6)
605 #define MP4_TEXT_DISPLAY_FLAG_HORIZONTAL_SCROLL  (1<<7)
606 #define MP4_TEXT_DISPLAY_FLAG_REVERSE_SCROLL     (1<<8)
607 #define MP4_TEXT_DISPLAY_FLAG_CONTINUOUS_SCROLL  (1<<9)
608 #define MP4_TEXT_DISPLAY_FLAG_FLOW_HORIZONTAL    (1<<10)
609 #define MP4_TEXT_DISPLAY_FLAG_CONTINUOUS_KARAOKE (1<<11)
610 #define MP4_TEXT_DISPLAY_FLAG_DROP_SHADOW        (1<<12)
611 #define MP4_TEXT_DISPLAY_FLAG_ANTI_ALIAS         (1<<13)
612 #define MP4_TEXT_DISPLAY_FLAG_KEYED_TEXT         (1<<14)
613 #define MP4_TEXT_DISPLAY_FLAG_INVERSE_HILITE     (1<<15)
614 #define MP4_TEXT_DISPLAY_FLAG_COLOR_HILITE       (1<<16)
615 #define MP4_TEXT_DISPLAY_FLAG_WRITE_VERTICALLY   (1<<17)
616
617 typedef struct
618 {
619     uint32_t i_reserved1;
620     uint16_t i_reserved2;
621
622     uint16_t i_data_reference_index;
623
624     uint32_t i_display_flags;   // TextDescription and Tx3gDescription
625
626     int8_t i_justification_horizontal; // left(0), centered(1), right(-1)
627     int8_t i_justification_vertical;   // top(0), centered(1), bottom(-1)
628
629     uint16_t i_background_color[4];
630
631     uint16_t i_text_box_top;
632     uint16_t i_text_box_left;
633     uint16_t i_text_box_bottom;
634     uint16_t i_text_box_right;
635
636     uint32_t i_reserved3;
637
638     uint16_t i_font_id;
639     uint8_t  i_font_face;
640     uint8_t  i_font_size;
641     uint32_t i_font_color; //RGBA
642
643     // TODO to complete
644 } MP4_Box_data_sample_text_t;
645
646 typedef struct MP4_Box_data_sample_hint_s
647 {
648     uint8_t  i_reserved1[6];
649     uint16_t i_data_reference_index;
650
651     uint8_t *p_data;
652
653 } MP4_Box_data_sample_hint_t;
654
655 typedef struct MP4_Box_data_moviehintinformation_rtp_s
656 {
657     uint32_t i_description_format;
658     unsigned char *psz_text;
659
660 } MP4_Box_data_moviehintinformation_rtp_t;
661
662
663
664 typedef struct MP4_Box_data_stsd_s
665 {
666     uint8_t  i_version;
667     uint32_t i_flags;
668
669     uint32_t i_entry_count;
670
671     /* it contains SampleEntry handled as if it was Box */
672
673 } MP4_Box_data_stsd_t;
674
675
676 typedef struct MP4_Box_data_stsz_s
677 {
678     uint8_t  i_version;
679     uint32_t i_flags;
680
681     uint32_t i_sample_size;
682     uint32_t i_sample_count;
683
684     uint32_t *i_entry_size; /* array , empty if i_sample_size != 0 */
685
686 } MP4_Box_data_stsz_t;
687
688 typedef struct MP4_Box_data_stz2_s
689 {
690     uint8_t  i_version;
691     uint32_t i_flags;
692
693     uint32_t i_sample_size; /* 24 bits */
694     uint8_t  i_field_size;
695     uint32_t i_sample_count;
696
697     uint32_t *i_entry_size; /* array: unsigned int(i_field_size) entry_size */
698
699 } MP4_Box_data_stz2_t;
700
701 typedef struct MP4_Box_data_stsc_s
702 {
703     uint8_t  i_version;
704     uint32_t i_flags;
705
706     uint32_t i_entry_count;
707
708     uint32_t *i_first_chunk; /* theses are arrays */
709     uint32_t *i_samples_per_chunk;
710     uint32_t *i_sample_description_index;
711
712 } MP4_Box_data_stsc_t;
713
714
715 typedef struct MP4_Box_data_co64_s
716 {
717     uint8_t  i_version;
718     uint32_t i_flags;
719
720     uint32_t i_entry_count;
721
722     uint64_t *i_chunk_offset;
723
724 } MP4_Box_data_co64_t;
725
726
727 typedef struct MP4_Box_data_stss_s
728 {
729     uint8_t  i_version;
730     uint32_t i_flags;
731
732     uint32_t i_entry_count;
733
734     uint32_t *i_sample_number;
735
736 } MP4_Box_data_stss_t;
737
738 typedef struct MP4_Box_data_stsh_s
739 {
740     uint8_t  i_version;
741     uint32_t i_flags;
742
743     uint32_t i_entry_count;
744
745     uint32_t *i_shadowed_sample_number;
746     uint32_t *i_sync_sample_number;
747
748 } MP4_Box_data_stsh_t;
749
750 typedef struct MP4_Box_data_stdp_s
751 {
752     uint8_t  i_version;
753     uint32_t i_flags;
754
755     uint16_t *i_priority;
756
757 } MP4_Box_data_stdp_t;
758
759 typedef struct MP4_Box_data_padb_s
760 {
761     uint8_t  i_version;
762     uint32_t i_flags;
763
764     uint32_t i_sample_count;
765
766     uint16_t *i_reserved1;   /* 1bit  */
767     uint16_t *i_pad2;        /* 3bits */
768     uint16_t *i_reserved2;   /* 1bit  */
769     uint16_t *i_pad1;        /* 3bits */
770
771
772 } MP4_Box_data_padb_t;
773
774
775 typedef struct MP4_Box_data_elst_s
776 {
777     uint8_t  i_version;
778     uint32_t i_flags;
779
780     uint32_t i_entry_count;
781
782     uint64_t *i_segment_duration;
783     int64_t  *i_media_time;
784     uint16_t *i_media_rate_integer;
785     uint16_t *i_media_rate_fraction;
786
787
788 } MP4_Box_data_elst_t;
789
790 typedef struct MP4_Box_data_cprt_s
791 {
792     uint8_t  i_version;
793     uint32_t i_flags;
794
795     char     rgs_language[3]; /* ISO-639-2/T */
796
797     char *psz_notice;
798 } MP4_Box_data_cprt_t;
799
800
801 /* DecoderConfigDescriptor */
802 typedef struct MP4_descriptor_decoder_config_s
803 {
804     uint8_t i_objectProfileIndication;
805     uint8_t i_streamType;
806     int     b_upStream;
807     int     i_buffer_sizeDB;
808     int     i_max_bitrate;
809     int     i_avg_bitrate;
810
811     int     i_decoder_specific_info_len;
812     uint8_t *p_decoder_specific_info;
813     /* some other stuff */
814
815 } MP4_descriptor_decoder_config_t;
816
817 typedef struct MP4_descriptor_SL_config_s
818 {
819
820     int i_dummy; /* ANSI C forbids empty structures */
821
822 } MP4_descriptor_SL_config_t;
823
824
825 typedef struct MP4_descriptor_ES_s
826 {
827     uint16_t i_ES_ID;
828     int      b_stream_dependence;
829     int      b_url;
830     int      b_OCRstream;
831     int      i_stream_priority;
832
833     int      i_depend_on_ES_ID; /* if b_stream_dependence set */
834
835     unsigned char *psz_URL;
836
837     uint16_t i_OCR_ES_ID;       /* if b_OCRstream */
838     MP4_descriptor_decoder_config_t *p_decConfigDescr;
839
840     MP4_descriptor_SL_config_t *p_slConfigDescr;
841
842     /* some other stuff ... */
843
844 } MP4_descriptor_ES_t;
845
846 /* ES descriptor */
847 typedef struct MP4_Box_data_esds_s
848 {
849     uint8_t  i_version;
850     uint32_t i_flags;
851
852     MP4_descriptor_ES_t es_descriptor;
853
854 } MP4_Box_data_esds_t;
855
856
857 typedef struct MP4_Box_data_dcom_s
858 {
859     uint32_t i_algorithm; /* fourcc */
860
861 } MP4_Box_data_dcom_t;
862
863 typedef struct MP4_Box_data_cmvd_s
864 {
865     uint32_t i_uncompressed_size;
866     uint32_t i_compressed_size;
867
868     int     b_compressed; /* Set to 1 if compressed data, 0 if uncompressed */
869     uint8_t *p_data;
870
871 } MP4_Box_data_cmvd_t;
872
873 typedef struct MP4_Box_data_cmov_s
874 {
875     struct MP4_Box_s *p_moov; /* uncompressed moov */
876
877 } MP4_Box_data_cmov_t;
878
879 typedef struct
880 {
881     uint32_t i_type;
882 } MP4_Box_data_frma_t;
883
884 typedef struct
885 {
886     uint32_t i_init;
887     uint32_t i_encr;
888     uint32_t i_decr;
889 } MP4_Box_data_skcr_t;
890
891 typedef struct
892 {
893     uint8_t  i_version;
894     uint32_t i_flags;
895
896     uint32_t i_ref_type;
897     char     *psz_ref;
898
899 } MP4_Box_data_rdrf_t;
900
901 typedef struct
902 {
903     uint8_t  i_version;
904     uint32_t i_flags;
905
906     uint32_t i_rate;
907
908 } MP4_Box_data_rmdr_t;
909
910 typedef struct
911 {
912     uint8_t  i_version;
913     uint32_t i_flags;
914
915     uint32_t i_gestaltType;
916     uint32_t i_val1;
917     uint32_t i_val2;
918     uint16_t i_checkType;   /* 0: val1 is version min
919                                1: gestalt value & val2 == val1 */
920
921 } MP4_Box_data_rmvc_t;
922
923 typedef struct
924 {
925     uint8_t  i_version;
926     uint32_t i_flags;
927
928
929 } MP4_Box_data_rmcd_t;
930
931 typedef struct
932 {
933     uint32_t i_quality;
934
935 } MP4_Box_data_rmqu_t;
936
937 typedef struct MP4_Box_data_mfhd_s
938 {
939     uint8_t  i_version;
940     uint32_t i_flags;
941
942     uint32_t i_sequence_number;
943
944 } MP4_Box_data_mfhd_t;
945
946 typedef struct MP4_Box_sidx_item_s
947 {
948     bool     b_reference_type;
949     uint32_t i_referenced_size;
950     uint32_t i_subsegment_duration;
951     bool     b_starts_with_SAP;
952     uint8_t  i_SAP_type;
953     uint32_t i_SAP_delta_time;
954
955 } MP4_Box_sidx_item_t;
956
957 typedef struct MP4_Box_data_sidx_s
958 {
959     uint8_t  i_version;
960     uint32_t i_flags;
961
962     uint32_t i_reference_ID;
963     uint32_t i_timescale;
964     uint64_t i_earliest_presentation_time;
965     uint64_t i_first_offset;
966     uint16_t i_reference_count;
967
968     MP4_Box_sidx_item_t *p_items;
969
970 } MP4_Box_data_sidx_t;
971
972 #define MP4_TFHD_BASE_DATA_OFFSET     (1LL<<0)
973 #define MP4_TFHD_SAMPLE_DESC_INDEX    (1LL<<1)
974 #define MP4_TFHD_DFLT_SAMPLE_DURATION (1LL<<3)
975 #define MP4_TFHD_DFLT_SAMPLE_SIZE     (1LL<<4)
976 #define MP4_TFHD_DFLT_SAMPLE_FLAGS    (1LL<<5)
977 #define MP4_TFHD_DURATION_IS_EMPTY    (1LL<<16)
978 #define MP4_TFHD_DEFAULT_BASE_IS_MOOF (1LL<<17)
979 typedef struct MP4_Box_data_tfhd_s
980 {
981     uint8_t  i_version;
982     bool     b_empty;
983     uint32_t i_flags;
984     uint32_t i_track_ID;
985
986     /* optional fields */
987     uint64_t i_base_data_offset;
988     uint32_t i_sample_description_index;
989     uint32_t i_default_sample_duration;
990     uint32_t i_default_sample_size;
991     uint32_t i_default_sample_flags;
992
993 } MP4_Box_data_tfhd_t;
994
995 #define MP4_TRUN_DATA_OFFSET         (1<<0)
996 #define MP4_TRUN_FIRST_FLAGS         (1<<2)
997 #define MP4_TRUN_SAMPLE_DURATION     (1<<8)
998 #define MP4_TRUN_SAMPLE_SIZE         (1<<9)
999 #define MP4_TRUN_SAMPLE_FLAGS        (1<<10)
1000 #define MP4_TRUN_SAMPLE_TIME_OFFSET  (1<<11)
1001 typedef struct MP4_descriptor_trun_sample_t
1002 {
1003     uint32_t i_duration;
1004     uint32_t i_size;
1005     uint32_t i_flags;
1006     uint32_t i_composition_time_offset; /* version == 0 ? signed : unsigned */
1007 } MP4_descriptor_trun_sample_t;
1008
1009 typedef struct MP4_Box_data_trun_s
1010 {
1011     uint8_t  i_version;
1012     uint32_t i_flags;
1013     uint32_t i_sample_count;
1014
1015     /* optional fields */
1016     int32_t i_data_offset;
1017     uint32_t i_first_sample_flags;
1018
1019     MP4_descriptor_trun_sample_t *p_samples;
1020
1021 } MP4_Box_data_trun_t;
1022
1023
1024 typedef struct
1025 {
1026     char *psz_text;
1027
1028 } MP4_Box_data_0xa9xxx_t;
1029
1030 typedef struct
1031 {
1032     char *psz_text;
1033
1034 } MP4_Box_data_string_t;
1035
1036 typedef struct
1037 {
1038     uint32_t i_entry_count;
1039     uint32_t *i_track_ID;
1040
1041 } MP4_Box_data_tref_generic_t;
1042
1043 typedef struct
1044 {
1045     uint8_t  i_version;
1046     uint32_t i_flags;
1047
1048     uint8_t i_chapter;
1049     struct
1050     {
1051         char    *psz_name;
1052         int64_t  i_start;
1053     } chapter[256];
1054 } MP4_Box_data_chpl_t;
1055
1056 typedef struct
1057 {
1058     uint8_t i_version;
1059     uint8_t i_profile;
1060     uint8_t i_profile_compatibility;
1061     uint8_t i_level;
1062
1063     uint8_t i_reserved1;     /* 6 bits */
1064     uint8_t i_length_size;
1065
1066     uint8_t i_reserved2;    /* 3 bits */
1067     uint8_t  i_sps;
1068     uint16_t *i_sps_length;
1069     uint8_t  **sps;
1070
1071     uint8_t  i_pps;
1072     uint16_t *i_pps_length;
1073     uint8_t  **pps;
1074
1075     /* XXX: Hack raw avcC atom payload */
1076     int     i_avcC;
1077     uint8_t *p_avcC;
1078
1079 } MP4_Box_data_avcC_t;
1080
1081 typedef struct
1082 {
1083     WAVEFORMATEX Format;
1084     uint32_t i_extra;
1085     char    *p_extra;
1086 } MP4_Box_data_WMA2_t;
1087
1088 typedef struct
1089 {
1090     VLC_BITMAPINFOHEADER bmiHeader;
1091     uint32_t i_extra;
1092     char    *p_extra;
1093 } MP4_Box_data_strf_t;
1094
1095 typedef struct
1096 {
1097     uint8_t i_stream_number;
1098 } MP4_Box_data_ASF_t;
1099
1100 /* According to Apple's CoreAudio/CoreAudioTypes.h */
1101 #define MP4_CHAN_USE_CHANNELS_DESC           0
1102 #define MP4_CHAN_USE_CHANNELS_BITMAP         (1<<16)
1103
1104 #define MP4_CHAN_BITMAP_LEFT                 (1<<0)
1105 #define MP4_CHAN_BITMAP_RIGHT                (1<<1)
1106 #define MP4_CHAN_BITMAP_CENTER               (1<<2)
1107 #define MP4_CHAN_BITMAP_LFESCREEN            (1<<3)
1108 #define MP4_CHAN_BITMAP_BACKLEFT             (1<<4)
1109 #define MP4_CHAN_BITMAP_BACKRIGHT            (1<<5)
1110 #define MP4_CHAN_BITMAP_LEFTCENTER           (1<<6)
1111 #define MP4_CHAN_BITMAP_RIGHTCENTER          (1<<7)
1112 #define MP4_CHAN_BITMAP_BACKCENTER           (1<<8)
1113 #define MP4_CHAN_BITMAP_SIDELEFT             (1<<9)
1114 #define MP4_CHAN_BITMAP_SIDERIGHT            (1<<10)
1115 #define MP4_CHAN_BITMAP_TOPCENTER            (1<<11)
1116 #define MP4_CHAN_BITMAP_TOPFRONTLEFT         (1<<12)
1117 #define MP4_CHAN_BITMAP_TOPFRONTENTER        (1<<13)
1118 #define MP4_CHAN_BITMAP_TOPFRONTRIGHT        (1<<14)
1119 #define MP4_CHAN_BITMAP_TOPBACKLEFT          (1<<15)
1120 #define MP4_CHAN_BITMAP_TOPBACKCENTER        (1<<16)
1121 #define MP4_CHAN_BITMAP_TOPBACKRIGHT         (1<<17)
1122
1123 #define MP4_CHAN_BITMAP_MAPPING_COUNT 18
1124 static const struct
1125 {
1126     uint32_t i_bitmap;
1127     uint32_t i_vlc;
1128 } chan_bitmap_mapping[MP4_CHAN_BITMAP_MAPPING_COUNT] = {
1129     { MP4_CHAN_BITMAP_LEFT,         AOUT_CHAN_LEFT },
1130     { MP4_CHAN_BITMAP_RIGHT,        AOUT_CHAN_RIGHT },
1131     { MP4_CHAN_BITMAP_CENTER,       AOUT_CHAN_CENTER },
1132     { MP4_CHAN_BITMAP_LFESCREEN,    AOUT_CHAN_LFE },
1133     { MP4_CHAN_BITMAP_BACKLEFT,     AOUT_CHAN_REARLEFT },
1134     { MP4_CHAN_BITMAP_BACKRIGHT,    AOUT_CHAN_REARRIGHT },
1135     { MP4_CHAN_BITMAP_LEFTCENTER,   AOUT_CHAN_MIDDLELEFT },
1136     { MP4_CHAN_BITMAP_RIGHTCENTER,  AOUT_CHAN_MIDDLERIGHT },
1137     { MP4_CHAN_BITMAP_BACKCENTER,   AOUT_CHAN_REARCENTER },
1138     { MP4_CHAN_BITMAP_SIDELEFT,     AOUT_CHAN_LEFT },
1139     { MP4_CHAN_BITMAP_SIDERIGHT,    AOUT_CHAN_RIGHT },
1140     { MP4_CHAN_BITMAP_TOPCENTER,    AOUT_CHAN_CENTER },
1141     { MP4_CHAN_BITMAP_TOPFRONTLEFT, AOUT_CHAN_LEFT },
1142     { MP4_CHAN_BITMAP_TOPFRONTENTER,AOUT_CHAN_CENTER },
1143     { MP4_CHAN_BITMAP_TOPFRONTRIGHT,AOUT_CHAN_RIGHT },
1144     { MP4_CHAN_BITMAP_TOPBACKLEFT,  AOUT_CHAN_REARLEFT },
1145     { MP4_CHAN_BITMAP_TOPBACKCENTER,AOUT_CHAN_REARCENTER },
1146     { MP4_CHAN_BITMAP_TOPBACKRIGHT, AOUT_CHAN_REARRIGHT },
1147 };
1148
1149 typedef struct
1150 {
1151     uint8_t i_version;
1152     uint32_t i_channels_flags; /* 24 bits */
1153     struct
1154     {
1155         uint32_t i_channels_layout_tag;
1156         uint32_t i_channels_bitmap;
1157         uint32_t i_channels_description_count;
1158         struct
1159         {
1160             uint32_t i_channel_label;
1161             uint32_t i_channel_flags;
1162             float    f_coordinates[3];
1163         } *p_descriptions;
1164     } layout;
1165 } MP4_Box_data_chan_t;
1166
1167 typedef struct
1168 {
1169     uint16_t i_data_rate;
1170     uint8_t i_num_ind_sub;
1171     struct
1172     {
1173         uint8_t i_fscod;
1174         uint8_t i_bsid;
1175         uint8_t i_bsmod;
1176         uint8_t i_acmod;
1177         uint8_t i_lfeon;
1178         uint8_t i_num_dep_sub;
1179         uint16_t i_chan_loc;
1180     } stream[8];
1181
1182 } MP4_Box_data_dec3_t;
1183
1184 typedef struct
1185 {
1186     uint8_t i_fscod;
1187     uint8_t i_bsid;
1188     uint8_t i_bsmod;
1189     uint8_t i_acmod;
1190     uint8_t i_lfeon;
1191     uint8_t i_bitrate_code;
1192
1193 } MP4_Box_data_dac3_t;
1194
1195 typedef struct
1196 {
1197     uint8_t i_profile_level;
1198
1199     int i_vc1;
1200     uint8_t *p_vc1;
1201
1202 } MP4_Box_data_dvc1_t;
1203
1204 typedef struct
1205 {
1206     uint16_t i_little_endian;
1207
1208 } MP4_Box_data_enda_t;
1209
1210 typedef struct
1211 {
1212     uint32_t i_entry_count;
1213     struct
1214     {
1215         uint32_t i_namespace;
1216         char    *psz_value;
1217     } *p_entries;
1218 } MP4_Box_data_keys_t;
1219
1220 typedef struct
1221 {
1222     uint8_t  i_version;
1223     uint32_t i_flags;
1224
1225     uint16_t i_object_descriptor;
1226     uint8_t i_OD_profile_level;
1227     uint8_t i_scene_profile_level;
1228     uint8_t i_audio_profile_level;
1229     uint8_t i_visual_profile_level;
1230     uint8_t i_graphics_profile_level;
1231
1232 } MP4_Box_data_iods_t;
1233
1234 typedef struct
1235 {
1236     uint32_t i_horizontal_spacing;
1237     uint32_t i_vertical_spacing;
1238 } MP4_Box_data_pasp_t;
1239
1240 typedef struct
1241 {
1242     uint8_t  i_version;
1243     uint32_t i_flags;
1244
1245     uint64_t i_fragment_duration;
1246 } MP4_Box_data_mehd_t;
1247
1248 typedef struct
1249 {
1250     uint8_t  i_version;
1251     uint32_t i_flags;
1252
1253     uint32_t i_track_ID;
1254     uint32_t i_default_sample_description_index;
1255     uint32_t i_default_sample_duration;
1256     uint32_t i_default_sample_size;
1257     uint32_t i_default_sample_flags;
1258 } MP4_Box_data_trex_t;
1259
1260 typedef struct
1261 {
1262     uint8_t  i_version;
1263     uint32_t i_flags;
1264
1265     uint8_t *p_sample_table;
1266 } MP4_Box_data_sdtp_t;
1267
1268 typedef struct
1269 {
1270     uint32_t i_switch_group;
1271 } MP4_Box_data_tsel_t;
1272
1273 typedef struct
1274 {
1275     uint8_t  i_version;
1276     uint32_t i_flags;
1277
1278     uint32_t i_size;
1279 } MP4_Box_data_mfro_t;
1280
1281 typedef struct
1282 {
1283     uint8_t  i_version;
1284     uint32_t i_flags;
1285
1286     uint32_t i_track_ID;
1287     uint32_t i_number_of_entries;
1288
1289     uint8_t i_length_size_of_traf_num;
1290     uint8_t i_length_size_of_trun_num;
1291     uint8_t i_length_size_of_sample_num;
1292
1293     uint32_t *p_time;
1294     uint32_t *p_moof_offset;
1295     uint8_t *p_traf_number;
1296     uint8_t *p_trun_number;
1297     uint8_t *p_sample_number;
1298 } MP4_Box_data_tfra_t;
1299
1300 typedef struct
1301 {
1302     uint64_t i_duration;
1303     uint32_t i_timescale;
1304     uint16_t i_track_ID;
1305     uint8_t  i_es_cat;
1306
1307     uint32_t FourCC;
1308     uint32_t Bitrate;
1309     uint32_t MaxWidth;
1310     uint32_t MaxHeight;
1311     uint32_t SamplingRate;
1312     uint32_t Channels;
1313     uint32_t BitsPerSample;
1314     uint32_t AudioTag;
1315     uint16_t nBlockAlign;
1316     uint8_t  cpd_len;
1317     uint8_t  *CodecPrivateData;
1318 } MP4_Box_data_stra_t;
1319
1320 typedef struct
1321 {
1322     uint32_t i_hvcC;
1323     uint8_t *p_hvcC;
1324 } MP4_Box_data_hvcC_t;
1325
1326 typedef struct
1327 {
1328     enum
1329     {
1330         DATA_WKT_RESERVED = 0,
1331         DATA_WKT_UTF8 = 1,
1332         DATA_WKT_UTF16 = 2,
1333         DATA_WKT_SJIS = 3,
1334         DATA_WKT_UTF8_SORT = 4,
1335         DATA_WKT_UTF16_SORT = 5,
1336         DATA_WKT_JPEG = 13,
1337         DATA_WKT_PNG = 14,
1338         DATA_WKT_BE_SIGNED = 21,
1339         DATA_WKT_BE_UNSIGNED = 22,
1340         DATA_WKT_BE_FLOAT32 = 23,
1341         DATA_WKT_BE_FLOAT64 = 24,
1342         DATA_WKT_BMP = 27,
1343         DATA_WKT_QUICKTIME_METADATA_ATOM = 28,
1344     } e_wellknowntype;
1345     struct
1346     {
1347         uint16_t i_country;
1348         uint16_t i_language;
1349     } locale;
1350     uint8_t *p_blob;
1351     uint32_t i_blob;
1352 } MP4_Box_data_data_t;
1353
1354 /*
1355 typedef struct MP4_Box_data__s
1356 {
1357     uint8_t  i_version;
1358     uint32_t i_flags;
1359
1360 } MP4_Box_data__t;
1361
1362 */
1363
1364 typedef union MP4_Box_data_s
1365 {
1366     MP4_Box_data_ftyp_t *p_ftyp;
1367     MP4_Box_data_mvhd_t *p_mvhd;
1368     MP4_Box_data_mfhd_t *p_mfhd;
1369     MP4_Box_data_sidx_t *p_sidx;
1370     MP4_Box_data_tfhd_t *p_tfhd;
1371     MP4_Box_data_trun_t *p_trun;
1372     MP4_Box_data_tkhd_t *p_tkhd;
1373     MP4_Box_data_mdhd_t *p_mdhd;
1374     MP4_Box_data_hdlr_t *p_hdlr;
1375     MP4_Box_data_vmhd_t *p_vmhd;
1376     MP4_Box_data_smhd_t *p_smhd;
1377     MP4_Box_data_hmhd_t *p_hmhd;
1378     MP4_Box_data_url_t  *p_url;
1379     MP4_Box_data_urn_t  *p_urn;
1380     MP4_Box_data_dref_t *p_dref;
1381     MP4_Box_data_stts_t *p_stts;
1382     MP4_Box_data_ctts_t *p_ctts;
1383     MP4_Box_data_stsd_t *p_stsd;
1384     MP4_Box_data_sample_vide_t *p_sample_vide;
1385     MP4_Box_data_sample_soun_t *p_sample_soun;
1386     MP4_Box_data_sample_text_t *p_sample_text;
1387     MP4_Box_data_sample_hint_t *p_sample_hint;
1388
1389     MP4_Box_data_esds_t *p_esds;
1390     MP4_Box_data_avcC_t *p_avcC;
1391     MP4_Box_data_dac3_t *p_dac3;
1392     MP4_Box_data_dec3_t *p_dec3;
1393     MP4_Box_data_dvc1_t *p_dvc1;
1394     MP4_Box_data_chan_t *p_chan;
1395     MP4_Box_data_enda_t *p_enda;
1396     MP4_Box_data_keys_t *p_keys;
1397     MP4_Box_data_iods_t *p_iods;
1398     MP4_Box_data_pasp_t *p_pasp;
1399     MP4_Box_data_trex_t *p_trex;
1400     MP4_Box_data_mehd_t *p_mehd;
1401     MP4_Box_data_sdtp_t *p_sdtp;
1402     MP4_Box_data_tsel_t *p_tsel;
1403
1404     MP4_Box_data_tfra_t *p_tfra;
1405     MP4_Box_data_mfro_t *p_mfro;
1406     MP4_Box_data_stra_t *p_stra;
1407
1408     MP4_Box_data_stsz_t *p_stsz;
1409     MP4_Box_data_stz2_t *p_stz2;
1410     MP4_Box_data_stsc_t *p_stsc;
1411     MP4_Box_data_co64_t *p_co64;
1412     MP4_Box_data_stss_t *p_stss;
1413     MP4_Box_data_stsh_t *p_stsh;
1414     MP4_Box_data_stdp_t *p_stdp;
1415     MP4_Box_data_padb_t *p_padb;
1416     MP4_Box_data_elst_t *p_elst;
1417     MP4_Box_data_cprt_t *p_cprt;
1418
1419     MP4_Box_data_dcom_t *p_dcom;
1420     MP4_Box_data_cmvd_t *p_cmvd;
1421     MP4_Box_data_cmov_t *p_cmov;
1422
1423     MP4_Box_data_moviehintinformation_rtp_t p_moviehintinformation_rtp;
1424
1425     MP4_Box_data_frma_t *p_frma;
1426     MP4_Box_data_skcr_t *p_skcr;
1427
1428     MP4_Box_data_rdrf_t *p_rdrf;
1429     MP4_Box_data_rmdr_t *p_rmdr;
1430     MP4_Box_data_rmqu_t *p_rmqu;
1431     MP4_Box_data_rmvc_t *p_rmvc;
1432
1433     MP4_Box_data_chpl_t *p_chpl;
1434     MP4_Box_data_tref_generic_t *p_tref_generic;
1435
1436     MP4_Box_data_tfrf_t *p_tfrf;
1437     MP4_Box_data_tfxd_t *p_tfxd;
1438     MP4_Box_data_hvcC_t *p_hvcC;
1439     MP4_Box_data_WMA2_t *p_WMA2; /* flip4mac Little endian audio config */
1440     MP4_Box_data_strf_t *p_strf; /* flip4mac Little endian video config */
1441     MP4_Box_data_ASF_t  *p_asf;  /* flip4mac asf streams indicator */
1442
1443     /* for generic handlers */
1444     MP4_Box_data_string_t *p_string;
1445     MP4_Box_data_data_t *p_data;
1446
1447     void                *p_payload; /* for unknow type */
1448 } MP4_Box_data_t;
1449
1450 #define BOXDATA(type) type->data.type
1451
1452 typedef struct MP4_Box_s MP4_Box_t;
1453 /* the most basic structure */
1454 struct MP4_Box_s
1455 {
1456     off_t        i_pos;      /* absolute position */
1457
1458     uint32_t     i_type;
1459     uint32_t     i_shortsize;
1460     uint32_t     i_handler;  /**/
1461     uint32_t     i_index;    /* indexed list (ilst) */
1462
1463     enum
1464     {
1465         BOX_FLAG_NONE = 0,
1466         BOX_FLAG_INCOMPLETE,
1467     }            e_flags;
1468
1469     UUID_t       i_uuid;  /* Set if i_type == "uuid" */
1470
1471     uint64_t     i_size; /* always set so use it */
1472
1473     MP4_Box_t *p_father; /* pointer on the father Box */
1474     MP4_Box_t *p_first;  /* pointer on the first child Box */
1475     MP4_Box_t *p_last;
1476     MP4_Box_t *p_next;   /* pointer on the next boxes at the same level */
1477
1478     void (*pf_free)( MP4_Box_t *p_box ); /* pointer to free function for this box */
1479
1480     MP4_Box_data_t   data;   /* union of pointers on extended data depending
1481                                 on i_type (or i_usertype) */
1482 };
1483
1484 static inline size_t mp4_box_headersize( MP4_Box_t *p_box )
1485 {
1486     return 8
1487         + ( p_box->i_shortsize == 1 ? 8 : 0 )
1488         + ( p_box->i_type == ATOM_uuid ? 16 : 0 );
1489 }
1490
1491 #define MP4_GETX_PRIVATE(dst, code, size) do { \
1492     if( (i_read) >= (size) ) { dst = (code); p_peek += (size); } \
1493     else { dst = 0; }   \
1494     i_read -= (size);   \
1495   } while(0)
1496
1497 #define MP4_GET1BYTE( dst )  MP4_GETX_PRIVATE( dst, *p_peek, 1 )
1498 #define MP4_GET2BYTES( dst ) MP4_GETX_PRIVATE( dst, GetWBE(p_peek), 2 )
1499 #define MP4_GET3BYTES( dst ) MP4_GETX_PRIVATE( dst, Get24bBE(p_peek), 3 )
1500 #define MP4_GET4BYTES( dst ) MP4_GETX_PRIVATE( dst, GetDWBE(p_peek), 4 )
1501 #define MP4_GET8BYTES( dst ) MP4_GETX_PRIVATE( dst, GetQWBE(p_peek), 8 )
1502 #define MP4_GETFOURCC( dst ) MP4_GETX_PRIVATE( dst, \
1503                 VLC_FOURCC(p_peek[0],p_peek[1],p_peek[2],p_peek[3]), 4)
1504
1505 #define MP4_GET2BYTESLE( dst ) MP4_GETX_PRIVATE( dst, GetWLE(p_peek), 2 )
1506 #define MP4_GET4BYTESLE( dst ) MP4_GETX_PRIVATE( dst, GetDWLE(p_peek), 4 )
1507 #define MP4_GET8BYTESLE( dst ) MP4_GETX_PRIVATE( dst, GetQWLE(p_peek), 8 )
1508
1509 #define MP4_GETVERSIONFLAGS( p_void ) \
1510     MP4_GET1BYTE( p_void->i_version ); \
1511     MP4_GET3BYTES( p_void->i_flags )
1512
1513 #define MP4_GETSTRINGZ( p_str )         \
1514     if( (i_read > 0) && (p_peek[0]) )   \
1515     {       \
1516         const int __i_copy__ = strnlen( (char*)p_peek, i_read-1 );  \
1517         p_str = malloc( __i_copy__+1 );               \
1518         if( p_str ) \
1519         { \
1520              memcpy( p_str, p_peek, __i_copy__ ); \
1521              p_str[__i_copy__] = 0; \
1522         } \
1523         p_peek += __i_copy__ + 1;   \
1524         i_read -= __i_copy__ + 1;   \
1525     }       \
1526     else    \
1527     {       \
1528         p_str = NULL; \
1529     }
1530
1531 #define MP4_READBOX_ENTER( MP4_Box_data_TYPE_t ) \
1532     int64_t  i_read = p_box->i_size; \
1533     uint8_t *p_peek, *p_buff; \
1534     int i_actually_read; \
1535     if( !( p_peek = p_buff = malloc( i_read ) ) ) \
1536     { \
1537         return( 0 ); \
1538     } \
1539     i_actually_read = stream_Read( p_stream, p_peek, i_read ); \
1540     if( i_actually_read < 0 || (int64_t)i_actually_read < i_read )\
1541     { \
1542         msg_Warn( p_stream, "MP4_READBOX_ENTER: I got %i bytes, "\
1543         "but I requested %" PRId64, i_actually_read, i_read );\
1544         free( p_buff ); \
1545         return( 0 ); \
1546     } \
1547     p_peek += mp4_box_headersize( p_box ); \
1548     i_read -= mp4_box_headersize( p_box ); \
1549     if( !( p_box->data.p_payload = calloc( 1, sizeof( MP4_Box_data_TYPE_t ) ) ) ) \
1550     { \
1551         free( p_buff ); \
1552         return( 0 ); \
1553     }
1554
1555 #define MP4_READBOX_EXIT( i_code ) \
1556     do \
1557     { \
1558         free( p_buff ); \
1559         if( i_read < 0 ) \
1560             msg_Warn( p_stream, "Not enough data" ); \
1561         return( i_code ); \
1562     } while (0)
1563
1564
1565 /* This macro is used when we want to printf the box type
1566  * APPLE annotation box is :
1567  *  either 0xA9 + 24-bit ASCII text string (and 0xA9 isn't printable)
1568  *  either 32-bit ASCII text string
1569  */
1570 #define MP4_BOX_TYPE_ASCII() ( ((char*)&p_box->i_type)[0] != (char)0xA9 )
1571
1572 static inline uint32_t Get24bBE( const uint8_t *p )
1573 {
1574     return( ( p[0] <<16 ) + ( p[1] <<8 ) + p[2] );
1575 }
1576
1577 static inline void GetUUID( UUID_t *p_uuid, const uint8_t *p_buff )
1578 {
1579     memcpy( p_uuid, p_buff, 16 );
1580 }
1581
1582 static inline int CmpUUID( const UUID_t *u1, const UUID_t *u2 )
1583 {
1584     return memcmp( u1, u2, 16 );
1585 }
1586
1587 static inline void CreateUUID( UUID_t *p_uuid, uint32_t i_fourcc )
1588 {
1589     /* made by 0xXXXXXXXX-0011-0010-8000-00aa00389b71
1590             where XXXXXXXX is the fourcc */
1591     /* FIXME implement this */
1592     (void)p_uuid;
1593     (void)i_fourcc;
1594 }
1595
1596 static const UUID_t TfrfBoxUUID = {
1597                 { 0xd4, 0x80, 0x7e, 0xf2, 0xca, 0x39, 0x46, 0x95,
1598                   0x8e, 0x54, 0x26, 0xcb, 0x9e, 0x46, 0xa7, 0x9f } };
1599
1600 static const UUID_t TfxdBoxUUID = {
1601                 { 0x6d, 0x1d, 0x9b, 0x05, 0x42, 0xd5, 0x44, 0xe6,
1602                   0x80, 0xe2, 0x14, 0x1d, 0xaf, 0xf7, 0x57, 0xb2 } };
1603
1604 static const UUID_t SmooBoxUUID = {
1605                 { 0xe1, 0xda, 0x72, 0xba, 0x24, 0xd7, 0x43, 0xc3,
1606                   0xa6, 0xa5, 0x1b, 0x57, 0x59, 0xa1, 0xa9, 0x2c } };
1607
1608 static const UUID_t StraBoxUUID = {
1609                 { 0xb0, 0x3e, 0xf7, 0x70, 0x33, 0xbd, 0x4b, 0xac,
1610                   0x96, 0xc7, 0xbf, 0x25, 0xf9, 0x7e, 0x24, 0x47 } };
1611
1612 MP4_Box_t *MP4_BoxGetSmooBox( stream_t * );
1613
1614 /*****************************************************************************
1615  * MP4_BoxGetNextChunk : Parse the entire moof box.
1616  *****************************************************************************
1617  *  The first box is a virtual box "root" and is the father of the boxes
1618  *  'moof' and, possibly, 'sidx'.
1619  *****************************************************************************/
1620 MP4_Box_t *MP4_BoxGetNextChunk( stream_t * );
1621
1622 /*****************************************************************************
1623  * MP4_BoxGetRoot : Parse the entire file, and create all boxes in memory
1624  *****************************************************************************
1625  *  The first box is a virtual box "root" and is the father for all first
1626  *  level boxes
1627  *****************************************************************************/
1628 MP4_Box_t *MP4_BoxGetRoot( stream_t * );
1629
1630 /*****************************************************************************
1631  * MP4_FreeBox : free memory allocated after read with MP4_ReadBox
1632  *               or MP4_BoxGetRoot, this means also children boxes
1633  * XXX : all children have to be allocated by a malloc !! and
1634  *         p_box is freed
1635  *****************************************************************************/
1636 void MP4_BoxFree( stream_t *, MP4_Box_t *p_box );
1637
1638 /*****************************************************************************
1639  * MP4_DumpBoxStructure: print the structure of the p_box
1640  *****************************************************************************
1641  * Useful while debugging
1642  *****************************************************************************/
1643 void MP4_BoxDumpStructure( stream_t *p_input, MP4_Box_t *p_box );
1644
1645 /*****************************************************************************
1646  * MP4_BoxGet: find a box given a path relative to p_box
1647  *****************************************************************************
1648  * Path Format: . .. / as usual
1649  *              [number] to specifie box number ex: trak[12]
1650  *
1651  * ex: /moov/trak[12]
1652  *     ../mdia
1653  *****************************************************************************/
1654 MP4_Box_t *MP4_BoxGet( MP4_Box_t *p_box, const char *psz_fmt, ... );
1655
1656 /*****************************************************************************
1657  * MP4_BoxCount: find number of box given a path relative to p_box
1658  *****************************************************************************
1659  * Path Format: . .. / as usual
1660  *              [number] to specifie box number ex: trak[12]
1661  *
1662  * ex: /moov/trak
1663  *     ../mdia
1664  *****************************************************************************/
1665 int MP4_BoxCount( MP4_Box_t *p_box, const char *psz_fmt, ... );
1666
1667 /* Internal functions exposed for MKV demux */
1668 int MP4_ReadBoxCommon( stream_t *p_stream, MP4_Box_t *p_box );
1669 int MP4_ReadBoxContainerChildren( stream_t *p_stream, MP4_Box_t *p_container,
1670                                   uint32_t i_last_child );
1671 int MP4_ReadBox_sample_vide( stream_t *p_stream, MP4_Box_t *p_box );
1672 void MP4_FreeBox_sample_vide( MP4_Box_t *p_box );
1673
1674 #endif