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