root/modules/demux/mp4/libmp4.h

Revision 856ba664f03bef9c502952ab1125e3ba0cc29e82, 27.3 kB (checked in by Laurent Aimar <fenrir@videolan.org>, 4 months ago)

Fixed #1220 (mp4 subtitle in mac encoding)

  • Property mode set to 100644
Line 
1 /*****************************************************************************
2  * libmp4.h : LibMP4 library for mp4 module for vlc
3  *****************************************************************************
4  * Copyright (C) 2001-2004 the VideoLAN team
5  * $Id$
6  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
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 General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21  *****************************************************************************/
22 #ifndef _VLC_MP4_H
23 #define _VLC_MP4_H 1
24
25
26 #define FOURCC_uuid VLC_FOURCC( 'u', 'u', 'i', 'd' )
27
28 #define FOURCC_ftyp VLC_FOURCC( 'f', 't', 'y', 'p' )
29 #define FOURCC_moov VLC_FOURCC( 'm', 'o', 'o', 'v' )
30 #define FOURCC_foov VLC_FOURCC( 'f', 'o', 'o', 'v' )
31 #define FOURCC_cmov VLC_FOURCC( 'c', 'm', 'o', 'v' )
32 #define FOURCC_dcom VLC_FOURCC( 'd', 'c', 'o', 'm' )
33 #define FOURCC_cmvd VLC_FOURCC( 'c', 'm', 'v', 'd' )
34
35 #define FOURCC_moof VLC_FOURCC( 'm', 'o', 'o', 'f' )
36 #define FOURCC_mdat VLC_FOURCC( 'm', 'd', 'a', 't' )
37 #define FOURCC_skip VLC_FOURCC( 's', 'k', 'i', 'p' )
38 #define FOURCC_free VLC_FOURCC( 'f', 'r', 'e', 'e' )
39 #define FOURCC_udta VLC_FOURCC( 'u', 'd', 't', 'a' )
40 #define FOURCC_wide VLC_FOURCC( 'w', 'i', 'd', 'e' )
41
42 #define FOURCC_trak VLC_FOURCC( 't', 'r', 'a', 'k' )
43 #define FOURCC_mvhd VLC_FOURCC( 'm', 'v', 'h', 'd' )
44 #define FOURCC_tkhd VLC_FOURCC( 't', 'k', 'h', 'd' )
45 #define FOURCC_tref VLC_FOURCC( 't', 'r', 'e', 'f' )
46 #define FOURCC_mdia VLC_FOURCC( 'm', 'd', 'i', 'a' )
47 #define FOURCC_mdhd VLC_FOURCC( 'm', 'd', 'h', 'd' )
48 #define FOURCC_hdlr VLC_FOURCC( 'h', 'd', 'l', 'r' )
49 #define FOURCC_minf VLC_FOURCC( 'm', 'i', 'n', 'f' )
50 #define FOURCC_vmhd VLC_FOURCC( 'v', 'm', 'h', 'd' )
51 #define FOURCC_smhd VLC_FOURCC( 's', 'm', 'h', 'd' )
52 #define FOURCC_hmhd VLC_FOURCC( 'h', 'm', 'h', 'd' )
53 #define FOURCC_dinf VLC_FOURCC( 'd', 'i', 'n', 'f' )
54 #define FOURCC_url  VLC_FOURCC( 'u', 'r', 'l', ' ' )
55 #define FOURCC_urn  VLC_FOURCC( 'u', 'r', 'n', ' ' )
56 #define FOURCC_dref VLC_FOURCC( 'd', 'r', 'e', 'f' )
57 #define FOURCC_stbl VLC_FOURCC( 's', 't', 'b', 'l' )
58 #define FOURCC_stts VLC_FOURCC( 's', 't', 't', 's' )
59 #define FOURCC_ctts VLC_FOURCC( 'c', 't', 't', 's' )
60 #define FOURCC_stsd VLC_FOURCC( 's', 't', 's', 'd' )
61 #define FOURCC_stsz VLC_FOURCC( 's', 't', 's', 'z' )
62 #define FOURCC_stz2 VLC_FOURCC( 's', 't', 'z', '2' )
63 #define FOURCC_stsc VLC_FOURCC( 's', 't', 's', 'c' )
64 #define FOURCC_stco VLC_FOURCC( 's', 't', 'c', 'o' )
65 #define FOURCC_co64 VLC_FOURCC( 'c', 'o', '6', '4' )
66 #define FOURCC_stss VLC_FOURCC( 's', 't', 's', 's' )
67 #define FOURCC_stsh VLC_FOURCC( 's', 't', 's', 'h' )
68 #define FOURCC_stdp VLC_FOURCC( 's', 't', 'd', 'p' )
69 #define FOURCC_padb VLC_FOURCC( 'p', 'a', 'd', 'b' )
70 #define FOURCC_edts VLC_FOURCC( 'e', 'd', 't', 's' )
71 #define FOURCC_elst VLC_FOURCC( 'e', 'l', 's', 't' )
72 #define FOURCC_udta VLC_FOURCC( 'u', 'd', 't', 'a' )
73 #define FOURCC_mvex VLC_FOURCC( 'm', 'v', 'e', 'x' )
74 #define FOURCC_trex VLC_FOURCC( 't', 'r', 'e', 'x' )
75 #define FOURCC_mfhd VLC_FOURCC( 'm', 'f', 'h', 'd' )
76 #define FOURCC_traf VLC_FOURCC( 't', 'r', 'a', 'f' )
77 #define FOURCC_tfhd VLC_FOURCC( 't', 'f', 'h', 'd' )
78 #define FOURCC_trun VLC_FOURCC( 't', 'r', 'u', 'n' )
79 #define FOURCC_cprt VLC_FOURCC( 'c', 'p', 'r', 't' )
80 #define FOURCC_iods VLC_FOURCC( 'i', 'o', 'd', 's' )
81
82 #define FOURCC_nmhd VLC_FOURCC( 'n', 'm', 'h', 'd' )
83 #define FOURCC_mp2v VLC_FOURCC( 'm', 'p', '2', 'v' )
84 #define FOURCC_mp4v VLC_FOURCC( 'm', 'p', '4', 'v' )
85 #define FOURCC_mp4a VLC_FOURCC( 'm', 'p', '4', 'a' )
86 #define FOURCC_mp4s VLC_FOURCC( 'm', 'p', '4', 's' )
87 #define FOURCC_vide VLC_FOURCC( 'v', 'i', 'd', 'e' )
88 #define FOURCC_soun VLC_FOURCC( 's', 'o', 'u', 'n' )
89 #define FOURCC_hint VLC_FOURCC( 'h', 'i', 'n', 't' )
90 #define FOURCC_hdv2 VLC_FOURCC( 'h', 'd', 'v', '2' )
91
92 #define FOURCC_dpnd VLC_FOURCC( 'd', 'p', 'n', 'd' )
93 #define FOURCC_ipir VLC_FOURCC( 'i', 'p', 'i', 'r' )
94 #define FOURCC_mpod VLC_FOURCC( 'm', 'p', 'o', 'd' )
95 #define FOURCC_hnti VLC_FOURCC( 'h', 'n', 't', 'i' )
96 #define FOURCC_rtp  VLC_FOURCC( 'r', 't', 'p', ' ' )
97
98 #define FOURCC_isom VLC_FOURCC( 'i', 's', 'o', 'm' )
99 #define FOURCC_esds VLC_FOURCC( 'e', 's', 'd', 's' )
100
101 #define FOURCC__mp3 VLC_FOURCC( '.', 'm', 'p', '3' )
102 #define FOURCC_ms02 VLC_FOURCC( 'm', 's', 0x0, 0x02 )
103 #define FOURCC_ms11 VLC_FOURCC( 'm', 's', 0x0, 0x11 )
104 #define FOURCC_ms55 VLC_FOURCC( 'm', 's', 0x0, 0x55 )
105 #define FOURCC_twos VLC_FOURCC( 't', 'w', 'o', 's' )
106 #define FOURCC_sowt VLC_FOURCC( 's', 'o', 'w', 't' )
107 #define FOURCC_QDMC VLC_FOURCC( 'Q', 'D', 'M', 'C' )
108 #define FOURCC_QDM2 VLC_FOURCC( 'Q', 'D', 'M', '2' )
109 #define FOURCC_ima4 VLC_FOURCC( 'i', 'm', 'a', '4' )
110 #define FOURCC_IMA4 VLC_FOURCC( 'I', 'M', 'A', '4' )
111 #define FOURCC_dvi  VLC_FOURCC( 'd', 'v', 'i', ' ' )
112 #define FOURCC_MAC3 VLC_FOURCC( 'M', 'A', 'C', '3' )
113 #define FOURCC_MAC6 VLC_FOURCC( 'M', 'A', 'C', '6' )
114 #define FOURCC_alaw VLC_FOURCC( 'a', 'l', 'a', 'w' )
115 #define FOURCC_ulaw VLC_FOURCC( 'u', 'l', 'a', 'w' )
116 #define FOURCC_Qclp VLC_FOURCC( 'Q', 'c', 'l', 'p' )
117 #define FOURCC_samr VLC_FOURCC( 's', 'a', 'm', 'r' )
118 #define FOURCC_sawb VLC_FOURCC( 's', 'a', 'w', 'b' )
119 #define FOURCC_OggS VLC_FOURCC( 'O', 'g', 'g', 'S' )
120 #define FOURCC_alac VLC_FOURCC( 'a', 'l', 'a', 'c' )
121
122 #define FOURCC_zlib VLC_FOURCC( 'z', 'l', 'i', 'b' )
123 #define FOURCC_SVQ1 VLC_FOURCC( 'S', 'V', 'Q', '1' )
124 #define FOURCC_SVQ3 VLC_FOURCC( 'S', 'V', 'Q', '3' )
125 #define FOURCC_ZyGo VLC_FOURCC( 'Z', 'y', 'G', 'o' )
126 #define FOURCC_3IV1 VLC_FOURCC( '3', 'I', 'V', '1' )
127 #define FOURCC_3iv1 VLC_FOURCC( '3', 'i', 'v', '1' )
128 #define FOURCC_3IV2 VLC_FOURCC( '3', 'I', 'V', '2' )
129 #define FOURCC_3iv2 VLC_FOURCC( '3', 'i', 'v', '2' )
130 #define FOURCC_3IVD VLC_FOURCC( '3', 'I', 'V', 'D' )
131 #define FOURCC_3ivd VLC_FOURCC( '3', 'i', 'v', 'd' )
132 #define FOURCC_3VID VLC_FOURCC( '3', 'V', 'I', 'D' )
133 #define FOURCC_3vid VLC_FOURCC( '3', 'v', 'i', 'd' )
134 #define FOURCC_h263 VLC_FOURCC( 'h', '2', '6', '3' )
135 #define FOURCC_s263 VLC_FOURCC( 's', '2', '6', '3' )
136 #define FOURCC_DIVX VLC_FOURCC( 'D', 'I', 'V', 'X' )
137 #define FOURCC_XVID VLC_FOURCC( 'X', 'V', 'I', 'D' )
138 #define FOURCC_cvid VLC_FOURCC( 'c', 'v', 'i', 'd' )
139 #define FOURCC_mjpa VLC_FOURCC( 'm', 'j', 'p', 'a' )
140 #define FOURCC_mjpb VLC_FOURCC( 'm', 'j', 'q', 't' )
141 #define FOURCC_mjqt VLC_FOURCC( 'm', 'j', 'h', 't' )
142 #define FOURCC_mjht VLC_FOURCC( 'm', 'j', 'p', 'b' )
143 #define FOURCC_VP31 VLC_FOURCC( 'V', 'P', '3', '1' )
144 #define FOURCC_vp31 VLC_FOURCC( 'v', 'p', '3', '1' )
145 #define FOURCC_h264 VLC_FOURCC( 'h', '2', '6', '4' )
146 #define FOURCC_qdrw VLC_FOURCC( 'q', 'd', 'r', 'w' )
147
148 #define FOURCC_avc1 VLC_FOURCC( 'a', 'v', 'c', '1' )
149 #define FOURCC_avcC VLC_FOURCC( 'a', 'v', 'c', 'C' )
150 #define FOURCC_m4ds VLC_FOURCC( 'm', '4', 'd', 's' )
151
152 #define FOURCC_dvc  VLC_FOURCC( 'd', 'v', 'c', ' ' )
153 #define FOURCC_dvp  VLC_FOURCC( 'd', 'v', 'p', ' ' )
154 #define FOURCC_dv5n VLC_FOURCC( 'd', 'v', '5', 'n' )
155 #define FOURCC_dv5p VLC_FOURCC( 'd', 'v', '5', 'p' )
156 #define FOURCC_raw  VLC_FOURCC( 'r', 'a', 'w', ' ' )
157
158 #define FOURCC_jpeg VLC_FOURCC( 'j', 'p', 'e', 'g' )
159
160 #define FOURCC_yv12 VLC_FOURCC( 'y', 'v', '1', '2' )
161 #define FOURCC_yuv2 VLC_FOURCC( 'y', 'u', 'v', '2' )
162
163 #define FOURCC_rmra VLC_FOURCC( 'r', 'm', 'r', 'a' )
164 #define FOURCC_rmda VLC_FOURCC( 'r', 'm', 'd', 'a' )
165 #define FOURCC_rdrf VLC_FOURCC( 'r', 'd', 'r', 'f' )
166 #define FOURCC_rmdr VLC_FOURCC( 'r', 'm', 'd', 'r' )
167 #define FOURCC_rmvc VLC_FOURCC( 'r', 'm', 'v', 'c' )
168 #define FOURCC_rmcd VLC_FOURCC( 'r', 'm', 'c', 'd' )
169 #define FOURCC_rmqu VLC_FOURCC( 'r', 'm', 'q', 'u' )
170 #define FOURCC_alis VLC_FOURCC( 'a', 'l', 'i', 's' )
171
172 #define FOURCC_gmhd VLC_FOURCC( 'g', 'm', 'h', 'd' )
173 #define FOURCC_wave VLC_FOURCC( 'w', 'a', 'v', 'e' )
174
175 #define FOURCC_drms VLC_FOURCC( 'd', 'r', 'm', 's' )
176 #define FOURCC_sinf VLC_FOURCC( 's', 'i', 'n', 'f' )
177 #define FOURCC_schi VLC_FOURCC( 's', 'c', 'h', 'i' )
178 #define FOURCC_user VLC_FOURCC( 'u', 's', 'e', 'r' )
179 #define FOURCC_key  VLC_FOURCC( 'k', 'e', 'y', ' ' )
180 #define FOURCC_iviv VLC_FOURCC( 'i', 'v', 'i', 'v' )
181 #define FOURCC_name VLC_FOURCC( 'n', 'a', 'm', 'e' )
182 #define FOURCC_priv VLC_FOURCC( 'p', 'r', 'i', 'v' )
183
184 #define FOURCC_text VLC_FOURCC( 't', 'e', 'x', 't' )
185 #define FOURCC_tx3g VLC_FOURCC( 't', 'x', '3', 'g' )
186 #define FOURCC_subp VLC_FOURCC( 's', 'u', 'b', 'p' )
187
188 #define FOURCC_0xa9nam VLC_FOURCC( 0xa9, 'n', 'a', 'm' )
189 #define FOURCC_0xa9aut VLC_FOURCC( 0xa9, 'a', 'u', 't' )
190 #define FOURCC_0xa9swr VLC_FOURCC( 0xa9, 's', 'w', 'r' )
191 #define FOURCC_0xa9cpy VLC_FOURCC( 0xa9, 'c', 'p', 'y' )
192 #define FOURCC_0xa9inf VLC_FOURCC( 0xa9, 'i', 'n', 'f' )
193 #define FOURCC_0xa9ART VLC_FOURCC( 0xa9, 'A', 'R', 'T' )
194 #define FOURCC_0xa9des VLC_FOURCC( 0xa9, 'd', 'e', 's' )
195 #define FOURCC_0xa9dir VLC_FOURCC( 0xa9, 'd', 'i', 'r' )
196 #define FOURCC_0xa9cmt VLC_FOURCC( 0xa9, 'c', 'm', 't' )
197 #define FOURCC_0xa9req VLC_FOURCC( 0xa9, 'r', 'e', 'q' )
198 #define FOURCC_0xa9day VLC_FOURCC( 0xa9, 'd', 'a', 'y' )
199 #define FOURCC_0xa9fmt VLC_FOURCC( 0xa9, 'f', 'm', 't' )
200 #define FOURCC_0xa9prd VLC_FOURCC( 0xa9, 'p', 'r', 'd' )
201 #define FOURCC_0xa9prf VLC_FOURCC( 0xa9, 'p', 'r', 'f' )
202 #define FOURCC_0xa9src VLC_FOURCC( 0xa9, 's', 'r', 'c' )
203 #define FOURCC_0xa9alb VLC_FOURCC( 0xa9, 'a', 'l', 'b' )
204 #define FOURCC_0xa9dis VLC_FOURCC( 0xa9, 'd', 'i', 's' )
205 #define FOURCC_0xa9enc VLC_FOURCC( 0xa9, 'e', 'n', 'c' )
206 #define FOURCC_0xa9trk VLC_FOURCC( 0xa9, 't', 'r', 'k' )
207 #define FOURCC_0xa9url VLC_FOURCC( 0xa9, 'u', 'r', 'l' )
208 #define FOURCC_0xa9dsa VLC_FOURCC( 0xa9, 'd', 's', 'a' )
209 #define FOURCC_0xa9hst VLC_FOURCC( 0xa9, 'h', 's', 't' )
210 #define FOURCC_0xa9ope VLC_FOURCC( 0xa9, 'o', 'p', 'e' )
211 #define FOURCC_0xa9wrt VLC_FOURCC( 0xa9, 'w', 'r', 't' )
212 #define FOURCC_0xa9com VLC_FOURCC( 0xa9, 'c', 'o', 'm' )
213 #define FOURCC_0xa9gen VLC_FOURCC( 0xa9, 'g', 'e', 'n' )
214 #define FOURCC_chpl VLC_FOURCC( 'c', 'h', 'p', 'l' )
215 #define FOURCC_WLOC VLC_FOURCC( 'W', 'L', 'O', 'C' )
216
217 #define FOURCC_meta VLC_FOURCC( 'm', 'e', 't', 'a' )
218 #define FOURCC_ilst VLC_FOURCC( 'i', 'l', 's', 't' )
219
220 #define FOURCC_chap VLC_FOURCC( 'c', 'h', 'a', 'p' )
221
222 /* Do you want some debug information on all read boxes ? */
223 #define MP4_VERBOSE  1
224
225
226 struct MP4_Box_s;
227
228
229 /* uuid Universal Unique IDentifiers */
230 typedef struct UUID_s
231 {
232     uint8_t b[16];
233 } UUID_t;
234
235 /* specific structure for all boxes */
236
237 typedef struct MP4_Box_data_ftyp_s
238 {
239     uint32_t i_major_brand;
240     uint32_t i_minor_version;
241
242     uint32_t i_compatible_brands_count;
243     uint32_t *i_compatible_brands;
244
245 } MP4_Box_data_ftyp_t;
246
247 typedef struct MP4_Box_data_mvhd_s
248 {
249     uint8_t  i_version;
250     uint32_t i_flags;
251
252     uint64_t i_creation_time;
253     uint64_t i_modification_time;
254     uint32_t i_timescale;
255     uint64_t i_duration;
256
257     int32_t  i_rate;
258     int16_t  i_volume;
259     int16_t  i_reserved1;
260     uint32_t i_reserved2[2];
261     int32_t  i_matrix[9];
262     uint32_t i_predefined[6];
263     uint32_t i_next_track_id;
264
265 } MP4_Box_data_mvhd_t;
266
267 #define MP4_TRACK_ENABLED    0x000001
268 #define MP4_TRACK_IN_MOVIE   0x000002
269 #define MP4_TRACK_IN_PREVIEW 0x000004
270 typedef struct MP4_Box_data_tkhd_s
271 {
272     uint8_t  i_version;
273     uint32_t i_flags;
274
275     uint64_t i_creation_time;
276     uint64_t i_modification_time;
277     uint32_t i_track_ID;
278     uint32_t i_reserved;
279     uint64_t i_duration;
280
281     uint32_t i_reserved2[2];
282     int16_t  i_layer;
283     int16_t  i_predefined;
284
285     int16_t  i_volume;
286     uint16_t i_reserved3;
287     int32_t  i_matrix[9];
288     int32_t  i_width;
289     int32_t  i_height;
290
291 } MP4_Box_data_tkhd_t;
292
293 typedef struct MP4_Box_data_mdhd_s
294 {
295     uint8_t  i_version;
296     uint32_t i_flags;
297
298     uint64_t i_creation_time;
299     uint64_t i_modification_time;
300     uint32_t i_timescale;
301     uint64_t i_duration;
302
303     /* one bit for pad */
304     uint16_t      i_language_code;
305     /* unsigned int(5)[3] language difference with 0x60*/
306     unsigned char i_language[3];
307     uint16_t i_predefined;
308
309 } MP4_Box_data_mdhd_t;
310
311 typedef struct MP4_Box_data_hdlr_s
312 {
313     uint8_t  i_version;
314     uint32_t i_flags;
315
316     uint32_t i_predefined;
317     uint32_t i_handler_type; /* "vide" "soun" "hint" "odsm"
318                            "crsm" "sdsm" "m7sm" "ocsm"
319                            "ipsm" "mjsm" */
320
321     unsigned char *psz_name; /* in UTF-8 */
322
323 } MP4_Box_data_hdlr_t;
324
325 typedef struct MP4_Box_data_vmhd_s
326 {
327     uint8_t  i_version;
328     uint32_t i_flags;
329
330     int16_t  i_graphics_mode;
331     int16_t  i_opcolor[3];
332
333 } MP4_Box_data_vmhd_t;
334
335 typedef struct MP4_Box_data_smhd_s
336 {
337     uint8_t  i_version;
338     uint32_t i_flags;
339
340     int16_t  i_balance;
341     int16_t  i_reserved;
342
343 } MP4_Box_data_smhd_t;
344
345 typedef struct MP4_Box_data_hmhd_s
346 {
347     uint8_t  i_version;
348     uint32_t i_flags;
349
350     uint16_t i_max_PDU_size;
351     uint16_t i_avg_PDU_size;
352     uint32_t i_max_bitrate;
353     uint32_t i_avg_bitrate;
354     uint32_t i_reserved;
355
356 } MP4_Box_data_hmhd_t;
357
358 typedef struct MP4_Box_data_url_s
359 {
360     uint8_t  i_version;
361     uint32_t i_flags;
362
363     char *psz_location;
364
365 } MP4_Box_data_url_t;
366
367 typedef struct MP4_Box_data_urn_s
368 {
369     uint8_t  i_version;
370     uint32_t i_flags;
371
372     char *psz_name;
373     char *psz_location;
374
375 } MP4_Box_data_urn_t;
376
377 typedef struct MP4_Box_data_dref_s
378 {
379     uint8_t  i_version;
380     uint32_t i_flags;
381
382     uint32_t i_entry_count;
383 /* XXX it's also a container with i_entry_count entry */
384 } MP4_Box_data_dref_t;
385
386 typedef struct MP4_Box_data_stts_s
387 {
388     uint8_t  i_version;
389     uint32_t i_flags;
390
391     uint32_t i_entry_count;
392     uint32_t *i_sample_count; /* these are array */
393     int32_t  *i_sample_delta;
394
395 } MP4_Box_data_stts_t;
396
397 typedef struct MP4_Box_data_ctts_s
398 {
399     uint8_t  i_version;
400     uint32_t i_flags;
401
402     uint32_t i_entry_count;
403
404     uint32_t *i_sample_count; /* these are array */
405     int32_t  *i_sample_offset;
406
407 } MP4_Box_data_ctts_t;
408
409
410 typedef struct MP4_Box_data_sample_soun_s
411 {
412     uint8_t  i_reserved1[6];
413     uint16_t i_data_reference_index;
414
415     //uint32_t i_reserved2[2];
416     uint16_t i_qt_version;
417     uint16_t i_qt_revision_level;
418     uint32_t i_qt_vendor;
419
420     uint16_t i_channelcount;
421     uint16_t i_samplesize;
422     uint16_t i_predefined;
423     uint16_t i_reserved3;
424     uint16_t i_sampleratehi; /* timescale of track */
425     uint16_t i_sampleratelo;
426
427     /* for version 1 (i_reserved1[0] == 1) */
428     uint32_t i_sample_per_packet;
429     uint32_t i_bytes_per_packet;
430     uint32_t i_bytes_per_frame;
431     uint32_t i_bytes_per_sample;
432
433     /* XXX hack */
434     int     i_qt_description;
435     uint8_t *p_qt_description;
436
437     void    *p_drms;
438
439 } MP4_Box_data_sample_soun_t;
440
441 typedef struct MP4_Box_data_sample_vide_s
442 {
443     uint8_t  i_reserved1[6];
444     uint16_t i_data_reference_index;
445
446     uint16_t i_qt_version;
447     uint16_t i_qt_revision_level;
448     uint32_t i_qt_vendor;
449
450     uint32_t i_qt_temporal_quality;
451     uint32_t i_qt_spatial_quality;
452
453     int16_t  i_width;
454     int16_t  i_height;
455
456     uint32_t i_horizresolution;
457     uint32_t i_vertresolution;
458
459     uint32_t i_qt_data_size;
460     uint16_t i_qt_frame_count;
461
462     uint8_t  i_compressorname[32];
463     int16_t  i_depth;
464
465     int16_t  i_qt_color_table;
466
467     /* XXX hack ImageDescription */
468     int     i_qt_image_description;
469     uint8_t *p_qt_image_description;
470
471 } MP4_Box_data_sample_vide_t;
472
473 #define MP4_TEXT_DISPLAY_FLAG_DONT_DISPLAY       (1<<0)
474 #define MP4_TEXT_DISPLAY_FLAG_AUTO_SCALE         (1<<1)
475 #define MP4_TEXT_DISPLAY_FLAG_CLIP_TO_TEXT_BOX   (1<<2)
476 #define MP4_TEXT_DISPLAY_FLAG_USE_MOVIE_BG_COLOR (1<<3)
477 #define MP4_TEXT_DISPLAY_FLAG_SHRINK_TEXT_BOX_TO_FIT (1<<4)
478 #define MP4_TEXT_DISPLAY_FLAG_SCROLL_IN          (1<<5)
479 #define MP4_TEXT_DISPLAY_FLAG_SCROLL_OUT         (1<<6)
480 #define MP4_TEXT_DISPLAY_FLAG_HORIZONTAL_SCROLL  (1<<7)
481 #define MP4_TEXT_DISPLAY_FLAG_REVERSE_SCROLL     (1<<8)
482 #define MP4_TEXT_DISPLAY_FLAG_CONTINUOUS_SCROLL  (1<<9)
483 #define MP4_TEXT_DISPLAY_FLAG_FLOW_HORIZONTAL    (1<<10)
484 #define MP4_TEXT_DISPLAY_FLAG_CONTINUOUS_KARAOKE (1<<11)
485 #define MP4_TEXT_DISPLAY_FLAG_DROP_SHADOW        (1<<12)
486 #define MP4_TEXT_DISPLAY_FLAG_ANTI_ALIAS         (1<<13)
487 #define MP4_TEXT_DISPLAY_FLAG_KEYED_TEXT         (1<<14)
488 #define MP4_TEXT_DISPLAY_FLAG_INVERSE_HILITE     (1<<15)
489 #define MP4_TEXT_DISPLAY_FLAG_COLOR_HILITE       (1<<16)
490 #define MP4_TEXT_DISPLAY_FLAG_WRITE_VERTICALLY   (1<<17)
491
492 typedef struct
493 {
494     uint32_t i_reserved1;
495     uint16_t i_reserved2;
496
497     uint16_t i_data_reference_index;
498
499     uint32_t i_display_flags;   // TextDescription and Tx3gDescription
500
501     int8_t i_justification_horizontal; // left(0), centered(1), right(-1)
502     int8_t i_justification_vertical;   // top(0), centered(1), bottom(-1)
503
504     uint16_t i_background_color[4];
505
506     uint16_t i_text_box_top;
507     uint16_t i_text_box_left;
508     uint16_t i_text_box_bottom;
509     uint16_t i_text_box_right;
510
511     // TODO to complete
512 } MP4_Box_data_sample_text_t;
513
514 typedef struct MP4_Box_data_sample_hint_s
515 {
516     uint8_t  i_reserved1[6];
517     uint16_t i_data_reference_index;
518
519     uint8_t *p_data;
520
521 } MP4_Box_data_sample_hint_t;
522
523 typedef struct MP4_Box_data_moviehintinformation_rtp_s
524 {
525     uint32_t i_description_format;
526     unsigned char *psz_text;
527
528 } MP4_Box_data_moviehintinformation_rtp_t;
529
530
531
532 typedef struct MP4_Box_data_stsd_s
533 {
534     uint8_t  i_version;
535     uint32_t i_flags;
536
537     uint32_t i_entry_count;
538
539     /* it contains SampleEntry handled as if it was Box */
540
541 } MP4_Box_data_stsd_t;
542
543
544 typedef struct MP4_Box_data_stsz_s
545 {
546     uint8_t  i_version;
547     uint32_t i_flags;
548
549     uint32_t i_sample_size;
550     uint32_t i_sample_count;
551
552     uint32_t *i_entry_size; /* array , empty if i_sample_size != 0 */
553
554 } MP4_Box_data_stsz_t;
555
556 typedef struct MP4_Box_data_stz2_s
557 {
558     uint8_t  i_version;
559     uint32_t i_flags;
560
561     uint32_t i_sample_size; /* 24 bits */
562     uint8_t  i_field_size;
563     uint32_t i_sample_count;
564
565     uint32_t *i_entry_size; /* array: unsigned int(i_field_size) entry_size */
566
567 } MP4_Box_data_stz2_t;
568
569 typedef struct MP4_Box_data_stsc_s
570 {
571     uint8_t  i_version;
572     uint32_t i_flags;
573
574     uint32_t i_entry_count;
575
576     uint32_t *i_first_chunk; /* theses are arrays */
577     uint32_t *i_samples_per_chunk;
578     uint32_t *i_sample_description_index;
579
580 } MP4_Box_data_stsc_t;
581
582
583 typedef struct MP4_Box_data_co64_s
584 {
585     uint8_t  i_version;
586     uint32_t i_flags;
587
588     uint32_t i_entry_count;
589
590     uint64_t *i_chunk_offset;
591
592 } MP4_Box_data_co64_t;
593
594
595 typedef struct MP4_Box_data_stss_s
596 {
597     uint8_t  i_version;
598     uint32_t i_flags;
599
600     uint32_t i_entry_count;
601
602     uint32_t *i_sample_number;
603
604 } MP4_Box_data_stss_t;
605
606 typedef struct MP4_Box_data_stsh_s
607 {
608     uint8_t  i_version;
609     uint32_t i_flags;
610
611     uint32_t i_entry_count;
612
613     uint32_t *i_shadowed_sample_number;
614     uint32_t *i_sync_sample_number;
615
616 } MP4_Box_data_stsh_t;
617
618 typedef struct MP4_Box_data_stdp_s
619 {
620     uint8_t  i_version;
621     uint32_t i_flags;
622
623     uint16_t *i_priority;
624
625 } MP4_Box_data_stdp_t;
626
627 typedef struct MP4_Box_data_padb_s
628 {
629     uint8_t  i_version;
630     uint32_t i_flags;
631
632     uint32_t i_sample_count;
633
634     uint16_t *i_reserved1;   /* 1bit  */
635     uint16_t *i_pad2;        /* 3bits */
636     uint16_t *i_reserved2;   /* 1bit  */
637     uint16_t *i_pad1;        /* 3bits */
638
639
640 } MP4_Box_data_padb_t;
641
642
643 typedef struct MP4_Box_data_elst_s
644 {
645     uint8_t  i_version;
646     uint32_t i_flags;
647
648     uint32_t i_entry_count;
649
650     uint64_t *i_segment_duration;
651     int64_t  *i_media_time;
652     uint16_t *i_media_rate_integer;
653     uint16_t *i_media_rate_fraction;
654
655
656 } MP4_Box_data_elst_t;
657
658 typedef struct MP4_Box_data_cprt_s
659 {
660     uint8_t  i_version;
661     uint32_t i_flags;
662     /* 1 pad bit */
663     unsigned char i_language[3];
664
665     char *psz_notice;
666 } MP4_Box_data_cprt_t;
667
668
669 /* DecoderConfigDescriptor */
670 typedef struct MP4_descriptor_decoder_config_s
671 {
672     uint8_t i_objectTypeIndication;
673     uint8_t i_streamType;
674     int     b_upStream;
675     int     i_buffer_sizeDB;
676     int     i_max_bitrate;
677     int     i_avg_bitrate;
678
679     int     i_decoder_specific_info_len;
680     uint8_t *p_decoder_specific_info;
681     /* some other stuff */
682
683 } MP4_descriptor_decoder_config_t;
684
685 typedef struct MP4_descriptor_SL_config_s
686 {
687
688     int i_dummy; /* ANSI C forbids empty structures */
689
690 } MP4_descriptor_SL_config_t;
691
692
693 typedef struct MP4_descriptor_ES_s
694 {
695     uint16_t i_ES_ID;
696     int      b_stream_dependence;
697     int      b_url;
698     int      b_OCRstream;
699     int      i_stream_priority;
700
701     int      i_depend_on_ES_ID; /* if b_stream_dependence set */
702
703     unsigned char *psz_URL;
704
705     uint16_t i_OCR_ES_ID;       /* if b_OCRstream */
706     MP4_descriptor_decoder_config_t *p_decConfigDescr;
707
708     MP4_descriptor_SL_config_t *p_slConfigDescr;
709
710     /* some other stuff ... */
711
712 } MP4_descriptor_ES_t;
713
714 /* ES descriptor */
715 typedef struct MP4_Box_data_esds_s
716 {
717     uint8_t  i_version;
718     uint32_t i_flags;
719
720     MP4_descriptor_ES_t es_descriptor;
721
722 } MP4_Box_data_esds_t;
723
724
725 typedef struct MP4_Box_data_dcom_s
726 {
727     uint32_t i_algorithm; /* fourcc */
728
729 } MP4_Box_data_dcom_t;
730
731 typedef struct MP4_Box_data_cmvd_s
732 {
733     uint32_t i_uncompressed_size;
734     uint32_t i_compressed_size;
735
736     int     b_compressed; /* Set to 1 if compressed data, 0 if uncompressed */
737     uint8_t *p_data;
738
739 } MP4_Box_data_cmvd_t;
740
741 typedef struct MP4_Box_data_cmov_s
742 {
743     struct MP4_Box_s *p_moov; /* uncompressed moov */
744
745 } MP4_Box_data_cmov_t;
746
747 typedef struct
748 {
749     uint8_t  i_version;
750     uint32_t i_flags;
751
752     uint32_t i_ref_type;
753     char     *psz_ref;
754
755 } MP4_Box_data_rdrf_t;
756
757 typedef struct
758 {
759     uint8_t  i_version;
760     uint32_t i_flags;
761
762     uint32_t i_rate;
763
764 } MP4_Box_data_rmdr_t;
765
766 typedef struct
767 {
768     uint8_t  i_version;
769     uint32_t i_flags;
770
771     uint32_t i_gestaltType;
772     uint32_t i_val1;
773     uint32_t i_val2;
774     uint16_t i_checkType;   /* 0: val1 is version min
775                                1: gestalt value & val2 == val1 */
776
777 } MP4_Box_data_rmvc_t;
778
779 typedef struct
780 {
781     uint8_t  i_version;
782     uint32_t i_flags;
783
784
785 } MP4_Box_data_rmcd_t;
786
787 typedef struct
788 {
789     uint32_t i_quality;
790
791 } MP4_Box_data_rmqu_t;
792
793 typedef struct
794 {
795     char *psz_text;
796
797 } MP4_Box_data_0xa9xxx_t;
798
799 typedef struct
800 {
801     uint32_t i_entry_count;
802     uint32_t *i_track_ID;
803
804 } MP4_Box_data_tref_generic_t;