Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

libmp4.h

00001 /*****************************************************************************
00002  * libmp4.h : LibMP4 library for mp4 module for vlc
00003  *****************************************************************************
00004  * Copyright (C) 2001-2004 the VideoLAN team
00005  * $Id: libmp4.h 12770 2005-10-06 19:12:22Z fenrir $
00006  * Authors: Laurent Aimar <[email protected]>
00007  *
00008  * This program is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00021  *****************************************************************************/
00022 #ifndef _VLC_MP4_H
00023 #define _VLC_MP4_H 1
00024 
00025 
00026 #define FOURCC_uuid VLC_FOURCC( 'u', 'u', 'i', 'd' )
00027 
00028 #define FOURCC_ftyp VLC_FOURCC( 'f', 't', 'y', 'p' )
00029 #define FOURCC_moov VLC_FOURCC( 'm', 'o', 'o', 'v' )
00030 #define FOURCC_foov VLC_FOURCC( 'f', 'o', 'o', 'v' )
00031 #define FOURCC_cmov VLC_FOURCC( 'c', 'm', 'o', 'v' )
00032 #define FOURCC_dcom VLC_FOURCC( 'd', 'c', 'o', 'm' )
00033 #define FOURCC_cmvd VLC_FOURCC( 'c', 'm', 'v', 'd' )
00034 
00035 #define FOURCC_moof VLC_FOURCC( 'm', 'o', 'o', 'f' )
00036 #define FOURCC_mdat VLC_FOURCC( 'm', 'd', 'a', 't' )
00037 #define FOURCC_skip VLC_FOURCC( 's', 'k', 'i', 'p' )
00038 #define FOURCC_free VLC_FOURCC( 'f', 'r', 'e', 'e' )
00039 #define FOURCC_udta VLC_FOURCC( 'u', 'd', 't', 'a' )
00040 #define FOURCC_wide VLC_FOURCC( 'w', 'i', 'd', 'e' )
00041 
00042 #define FOURCC_trak VLC_FOURCC( 't', 'r', 'a', 'k' )
00043 #define FOURCC_mvhd VLC_FOURCC( 'm', 'v', 'h', 'd' )
00044 #define FOURCC_tkhd VLC_FOURCC( 't', 'k', 'h', 'd' )
00045 #define FOURCC_tref VLC_FOURCC( 't', 'r', 'e', 'f' )
00046 #define FOURCC_mdia VLC_FOURCC( 'm', 'd', 'i', 'a' )
00047 #define FOURCC_mdhd VLC_FOURCC( 'm', 'd', 'h', 'd' )
00048 #define FOURCC_hdlr VLC_FOURCC( 'h', 'd', 'l', 'r' )
00049 #define FOURCC_minf VLC_FOURCC( 'm', 'i', 'n', 'f' )
00050 #define FOURCC_vmhd VLC_FOURCC( 'v', 'm', 'h', 'd' )
00051 #define FOURCC_smhd VLC_FOURCC( 's', 'm', 'h', 'd' )
00052 #define FOURCC_hmhd VLC_FOURCC( 'h', 'm', 'h', 'd' )
00053 #define FOURCC_dinf VLC_FOURCC( 'd', 'i', 'n', 'f' )
00054 #define FOURCC_url  VLC_FOURCC( 'u', 'r', 'l', ' ' )
00055 #define FOURCC_urn  VLC_FOURCC( 'u', 'r', 'n', ' ' )
00056 #define FOURCC_dref VLC_FOURCC( 'd', 'r', 'e', 'f' )
00057 #define FOURCC_stbl VLC_FOURCC( 's', 't', 'b', 'l' )
00058 #define FOURCC_stts VLC_FOURCC( 's', 't', 't', 's' )
00059 #define FOURCC_ctts VLC_FOURCC( 'c', 't', 't', 's' )
00060 #define FOURCC_stsd VLC_FOURCC( 's', 't', 's', 'd' )
00061 #define FOURCC_stsz VLC_FOURCC( 's', 't', 's', 'z' )
00062 #define FOURCC_stz2 VLC_FOURCC( 's', 't', 'z', '2' )
00063 #define FOURCC_stsc VLC_FOURCC( 's', 't', 's', 'c' )
00064 #define FOURCC_stco VLC_FOURCC( 's', 't', 'c', 'o' )
00065 #define FOURCC_co64 VLC_FOURCC( 'c', 'o', '6', '4' )
00066 #define FOURCC_stss VLC_FOURCC( 's', 't', 's', 's' )
00067 #define FOURCC_stsh VLC_FOURCC( 's', 't', 's', 'h' )
00068 #define FOURCC_stdp VLC_FOURCC( 's', 't', 'd', 'p' )
00069 #define FOURCC_padb VLC_FOURCC( 'p', 'a', 'd', 'b' )
00070 #define FOURCC_edts VLC_FOURCC( 'e', 'd', 't', 's' )
00071 #define FOURCC_elst VLC_FOURCC( 'e', 'l', 's', 't' )
00072 #define FOURCC_udta VLC_FOURCC( 'u', 'd', 't', 'a' )
00073 #define FOURCC_mvex VLC_FOURCC( 'm', 'v', 'e', 'x' )
00074 #define FOURCC_trex VLC_FOURCC( 't', 'r', 'e', 'x' )
00075 #define FOURCC_mfhd VLC_FOURCC( 'm', 'f', 'h', 'd' )
00076 #define FOURCC_traf VLC_FOURCC( 't', 'r', 'a', 'f' )
00077 #define FOURCC_tfhd VLC_FOURCC( 't', 'f', 'h', 'd' )
00078 #define FOURCC_trun VLC_FOURCC( 't', 'r', 'u', 'n' )
00079 #define FOURCC_cprt VLC_FOURCC( 'c', 'p', 'r', 't' )
00080 #define FOURCC_iods VLC_FOURCC( 'i', 'o', 'd', 's' )
00081 
00082 #define FOURCC_nmhd VLC_FOURCC( 'n', 'm', 'h', 'd' )
00083 #define FOURCC_mp2v VLC_FOURCC( 'm', 'p', '2', 'v' )
00084 #define FOURCC_mp4v VLC_FOURCC( 'm', 'p', '4', 'v' )
00085 #define FOURCC_mp4a VLC_FOURCC( 'm', 'p', '4', 'a' )
00086 #define FOURCC_mp4s VLC_FOURCC( 'm', 'p', '4', 's' )
00087 #define FOURCC_vide VLC_FOURCC( 'v', 'i', 'd', 'e' )
00088 #define FOURCC_soun VLC_FOURCC( 's', 'o', 'u', 'n' )
00089 #define FOURCC_hint VLC_FOURCC( 'h', 'i', 'n', 't' )
00090 #define FOURCC_hdv2 VLC_FOURCC( 'h', 'd', 'v', '2' )
00091 
00092 #define FOURCC_dpnd VLC_FOURCC( 'd', 'p', 'n', 'd' )
00093 #define FOURCC_ipir VLC_FOURCC( 'i', 'p', 'i', 'r' )
00094 #define FOURCC_mpod VLC_FOURCC( 'm', 'p', 'o', 'd' )
00095 #define FOURCC_hnti VLC_FOURCC( 'h', 'n', 't', 'i' )
00096 #define FOURCC_rtp  VLC_FOURCC( 'r', 't', 'p', ' ' )
00097 
00098 #define FOURCC_isom VLC_FOURCC( 'i', 's', 'o', 'm' )
00099 #define FOURCC_esds VLC_FOURCC( 'e', 's', 'd', 's' )
00100 
00101 #define FOURCC__mp3 VLC_FOURCC( '.', 'm', 'p', '3' )
00102 #define FOURCC_ms02 VLC_FOURCC( 'm', 's', 0x0, 0x02 )
00103 #define FOURCC_ms11 VLC_FOURCC( 'm', 's', 0x0, 0x11 )
00104 #define FOURCC_ms55 VLC_FOURCC( 'm', 's', 0x0, 0x55 )
00105 #define FOURCC_twos VLC_FOURCC( 't', 'w', 'o', 's' )
00106 #define FOURCC_sowt VLC_FOURCC( 's', 'o', 'w', 't' )
00107 #define FOURCC_QDMC VLC_FOURCC( 'Q', 'D', 'M', 'C' )
00108 #define FOURCC_QDM2 VLC_FOURCC( 'Q', 'D', 'M', '2' )
00109 #define FOURCC_ima4 VLC_FOURCC( 'i', 'm', 'a', '4' )
00110 #define FOURCC_IMA4 VLC_FOURCC( 'I', 'M', 'A', '4' )
00111 #define FOURCC_dvi  VLC_FOURCC( 'd', 'v', 'i', ' ' )
00112 #define FOURCC_MAC3 VLC_FOURCC( 'M', 'A', 'C', '3' )
00113 #define FOURCC_MAC6 VLC_FOURCC( 'M', 'A', 'C', '6' )
00114 #define FOURCC_alaw VLC_FOURCC( 'a', 'l', 'a', 'w' )
00115 #define FOURCC_ulaw VLC_FOURCC( 'u', 'l', 'a', 'w' )
00116 #define FOURCC_Qclp VLC_FOURCC( 'Q', 'c', 'l', 'p' )
00117 #define FOURCC_samr VLC_FOURCC( 's', 'a', 'm', 'r' )
00118 #define FOURCC_sawb VLC_FOURCC( 's', 'a', 'w', 'b' )
00119 #define FOURCC_OggS VLC_FOURCC( 'O', 'g', 'g', 'S' )
00120 #define FOURCC_alac VLC_FOURCC( 'a', 'l', 'a', 'c' )
00121 
00122 #define FOURCC_zlib VLC_FOURCC( 'z', 'l', 'i', 'b' )
00123 #define FOURCC_SVQ1 VLC_FOURCC( 'S', 'V', 'Q', '1' )
00124 #define FOURCC_SVQ3 VLC_FOURCC( 'S', 'V', 'Q', '3' )
00125 #define FOURCC_ZyGo VLC_FOURCC( 'Z', 'y', 'G', 'o' )
00126 #define FOURCC_3IV1 VLC_FOURCC( '3', 'I', 'V', '1' )
00127 #define FOURCC_3iv1 VLC_FOURCC( '3', 'i', 'v', '1' )
00128 #define FOURCC_3IV2 VLC_FOURCC( '3', 'I', 'V', '2' )
00129 #define FOURCC_3iv2 VLC_FOURCC( '3', 'i', 'v', '2' )
00130 #define FOURCC_3IVD VLC_FOURCC( '3', 'I', 'V', 'D' )
00131 #define FOURCC_3ivd VLC_FOURCC( '3', 'i', 'v', 'd' )
00132 #define FOURCC_3VID VLC_FOURCC( '3', 'V', 'I', 'D' )
00133 #define FOURCC_3vid VLC_FOURCC( '3', 'v', 'i', 'd' )
00134 #define FOURCC_h263 VLC_FOURCC( 'h', '2', '6', '3' )
00135 #define FOURCC_s263 VLC_FOURCC( 's', '2', '6', '3' )
00136 #define FOURCC_DIVX VLC_FOURCC( 'D', 'I', 'V', 'X' )
00137 #define FOURCC_XVID VLC_FOURCC( 'X', 'V', 'I', 'D' )
00138 #define FOURCC_cvid VLC_FOURCC( 'c', 'v', 'i', 'd' )
00139 #define FOURCC_mjpa VLC_FOURCC( 'm', 'j', 'p', 'a' )
00140 #define FOURCC_mjpb VLC_FOURCC( 'm', 'j', 'q', 't' )
00141 #define FOURCC_mjqt VLC_FOURCC( 'm', 'j', 'h', 't' )
00142 #define FOURCC_mjht VLC_FOURCC( 'm', 'j', 'p', 'b' )
00143 #define FOURCC_VP31 VLC_FOURCC( 'V', 'P', '3', '1' )
00144 #define FOURCC_vp31 VLC_FOURCC( 'v', 'p', '3', '1' )
00145 #define FOURCC_h264 VLC_FOURCC( 'h', '2', '6', '4' )
00146 #define FOURCC_qdrw VLC_FOURCC( 'q', 'd', 'r', 'w' )
00147 
00148 #define FOURCC_avc1 VLC_FOURCC( 'a', 'v', 'c', '1' )
00149 #define FOURCC_avcC VLC_FOURCC( 'a', 'v', 'c', 'C' )
00150 #define FOURCC_m4ds VLC_FOURCC( 'm', '4', 'd', 's' )
00151 
00152 #define FOURCC_dvc  VLC_FOURCC( 'd', 'v', 'c', ' ' )
00153 #define FOURCC_dvp  VLC_FOURCC( 'd', 'v', 'p', ' ' )
00154 #define FOURCC_raw  VLC_FOURCC( 'r', 'a', 'w', ' ' )
00155 
00156 #define FOURCC_jpeg VLC_FOURCC( 'j', 'p', 'e', 'g' )
00157 
00158 
00159 #define FOURCC_rmra VLC_FOURCC( 'r', 'm', 'r', 'a' )
00160 #define FOURCC_rmda VLC_FOURCC( 'r', 'm', 'd', 'a' )
00161 #define FOURCC_rdrf VLC_FOURCC( 'r', 'd', 'r', 'f' )
00162 #define FOURCC_rmdr VLC_FOURCC( 'r', 'm', 'd', 'r' )
00163 #define FOURCC_rmvc VLC_FOURCC( 'r', 'm', 'v', 'c' )
00164 #define FOURCC_rmcd VLC_FOURCC( 'r', 'm', 'c', 'd' )
00165 #define FOURCC_rmqu VLC_FOURCC( 'r', 'm', 'q', 'u' )
00166 #define FOURCC_alis VLC_FOURCC( 'a', 'l', 'i', 's' )
00167 
00168 #define FOURCC_gmhd VLC_FOURCC( 'g', 'm', 'h', 'd' )
00169 #define FOURCC_wave VLC_FOURCC( 'w', 'a', 'v', 'e' )
00170 
00171 #define FOURCC_drms VLC_FOURCC( 'd', 'r', 'm', 's' )
00172 #define FOURCC_sinf VLC_FOURCC( 's', 'i', 'n', 'f' )
00173 #define FOURCC_schi VLC_FOURCC( 's', 'c', 'h', 'i' )
00174 #define FOURCC_user VLC_FOURCC( 'u', 's', 'e', 'r' )
00175 #define FOURCC_key  VLC_FOURCC( 'k', 'e', 'y', ' ' )
00176 #define FOURCC_iviv VLC_FOURCC( 'i', 'v', 'i', 'v' )
00177 #define FOURCC_name VLC_FOURCC( 'n', 'a', 'm', 'e' )
00178 #define FOURCC_priv VLC_FOURCC( 'p', 'r', 'i', 'v' )
00179 
00180 #define FOURCC_text VLC_FOURCC( 't', 'e', 'x', 't' )
00181 #define FOURCC_tx3g VLC_FOURCC( 't', 'x', '3', 'g' )
00182 #define FOURCC_subp VLC_FOURCC( 's', 'u', 'b', 'p' )
00183 
00184 #define FOURCC_0xa9nam VLC_FOURCC( 0xa9, 'n', 'a', 'm' )
00185 #define FOURCC_0xa9aut VLC_FOURCC( 0xa9, 'a', 'u', 't' )
00186 #define FOURCC_0xa9swr VLC_FOURCC( 0xa9, 's', 'w', 'r' )
00187 #define FOURCC_0xa9cpy VLC_FOURCC( 0xa9, 'c', 'p', 'y' )
00188 #define FOURCC_0xa9inf VLC_FOURCC( 0xa9, 'i', 'n', 'f' )
00189 #define FOURCC_0xa9ART VLC_FOURCC( 0xa9, 'A', 'R', 'T' )
00190 #define FOURCC_0xa9des VLC_FOURCC( 0xa9, 'd', 'e', 's' )
00191 #define FOURCC_0xa9dir VLC_FOURCC( 0xa9, 'd', 'i', 'r' )
00192 #define FOURCC_0xa9cmt VLC_FOURCC( 0xa9, 'c', 'm', 't' )
00193 #define FOURCC_0xa9req VLC_FOURCC( 0xa9, 'r', 'e', 'q' )
00194 #define FOURCC_0xa9day VLC_FOURCC( 0xa9, 'd', 'a', 'y' )
00195 #define FOURCC_0xa9fmt VLC_FOURCC( 0xa9, 'f', 'm', 't' )
00196 #define FOURCC_0xa9prd VLC_FOURCC( 0xa9, 'p', 'r', 'd' )
00197 #define FOURCC_0xa9prf VLC_FOURCC( 0xa9, 'p', 'r', 'f' )
00198 #define FOURCC_0xa9src VLC_FOURCC( 0xa9, 's', 'r', 'c' )
00199 #define FOURCC_0xa9alb VLC_FOURCC( 0xa9, 'a', 'l', 'b' )
00200 #define FOURCC_0xa9dis VLC_FOURCC( 0xa9, 'd', 'i', 's' )
00201 #define FOURCC_0xa9enc VLC_FOURCC( 0xa9, 'e', 'n', 'c' )
00202 #define FOURCC_0xa9trk VLC_FOURCC( 0xa9, 't', 'r', 'k' )
00203 #define FOURCC_0xa9url VLC_FOURCC( 0xa9, 'u', 'r', 'l' )
00204 #define FOURCC_0xa9dsa VLC_FOURCC( 0xa9, 'd', 's', 'a' )
00205 #define FOURCC_0xa9hst VLC_FOURCC( 0xa9, 'h', 's', 't' )
00206 #define FOURCC_0xa9ope VLC_FOURCC( 0xa9, 'o', 'p', 'e' )
00207 #define FOURCC_0xa9wrt VLC_FOURCC( 0xa9, 'w', 'r', 't' )
00208 #define FOURCC_0xa9com VLC_FOURCC( 0xa9, 'c', 'o', 'm' )
00209 #define FOURCC_0xa9gen VLC_FOURCC( 0xa9, 'g', 'e', 'n' )
00210 #define FOURCC_WLOC VLC_FOURCC( 'W', 'L', 'O', 'C' )
00211 
00212 /* Do you want some debug information on all read boxes ? */
00213 #define MP4_VERBOSE  1
00214 
00215 
00216 struct MP4_Box_s;
00217 
00218 
00219 /* uuid Universal Unique IDentifiers */
00220 typedef struct UUID_s
00221 {
00222     uint8_t b[16];
00223 } UUID_t;
00224 
00225 /* specific structure for all boxes */
00226 
00227 typedef struct MP4_Box_data_ftyp_s
00228 {
00229     uint32_t i_major_brand;
00230     uint32_t i_minor_version;
00231 
00232     uint32_t i_compatible_brands_count;
00233     uint32_t *i_compatible_brands;
00234 
00235 } MP4_Box_data_ftyp_t;
00236 
00237 typedef struct MP4_Box_data_mvhd_s
00238 {
00239     uint8_t  i_version;
00240     uint32_t i_flags;
00241 
00242     uint64_t i_creation_time;
00243     uint64_t i_modification_time;
00244     uint32_t i_timescale;
00245     uint64_t i_duration;
00246 
00247     int32_t  i_rate;
00248     int16_t  i_volume;
00249     int16_t  i_reserved1;
00250     uint32_t i_reserved2[2];
00251     int32_t  i_matrix[9];
00252     uint32_t i_predefined[6];
00253     uint32_t i_next_track_id;
00254 
00255 } MP4_Box_data_mvhd_t;
00256 
00257 #define MP4_TRACK_ENABLED    0x000001
00258 #define MP4_TRACK_IN_MOVIE   0x000002
00259 #define MP4_TRACK_IN_PREVIEW 0x000004
00260 typedef struct MP4_Box_data_tkhd_s
00261 {
00262     uint8_t  i_version;
00263     uint32_t i_flags;
00264 
00265     uint64_t i_creation_time;
00266     uint64_t i_modification_time;
00267     uint32_t i_track_ID;
00268     uint32_t i_reserved;
00269     uint64_t i_duration;
00270 
00271     uint32_t i_reserved2[2];
00272     int16_t  i_layer;
00273     int16_t  i_predefined;
00274 
00275     int16_t  i_volume;
00276     uint16_t i_reserved3;
00277     int32_t  i_matrix[9];
00278     int32_t  i_width;
00279     int32_t  i_height;
00280 
00281 } MP4_Box_data_tkhd_t;
00282 
00283 typedef struct MP4_Box_data_mdhd_s
00284 {
00285     uint8_t  i_version;
00286     uint32_t i_flags;
00287 
00288     uint64_t i_creation_time;
00289     uint64_t i_modification_time;
00290     uint32_t i_timescale;
00291     uint64_t i_duration;
00292 
00293     /* one bit for pad */
00294     /* unsigned int(5)[3] language difference with 0x60*/
00295     unsigned char i_language[3];
00296     uint16_t i_predefined;
00297 
00298 } MP4_Box_data_mdhd_t;
00299 
00300 typedef struct MP4_Box_data_hdlr_s
00301 {
00302     uint8_t  i_version;
00303     uint32_t i_flags;
00304 
00305     uint32_t i_predefined;
00306     uint32_t i_handler_type; /* "vide" "soun" "hint" "odsm"
00307                            "crsm" "sdsm" "m7sm" "ocsm"
00308                            "ipsm" "mjsm" */
00309 
00310     unsigned char *psz_name; /* in UTF-8 */
00311 
00312 } MP4_Box_data_hdlr_t;
00313 
00314 typedef struct MP4_Box_data_vmhd_s
00315 {
00316     uint8_t  i_version;
00317     uint32_t i_flags;
00318 
00319     int16_t  i_graphics_mode;
00320     int16_t  i_opcolor[3];
00321 
00322 } MP4_Box_data_vmhd_t;
00323 
00324 typedef struct MP4_Box_data_smhd_s
00325 {
00326     uint8_t  i_version;
00327     uint32_t i_flags;
00328 
00329     int16_t  i_balance;
00330     int16_t  i_reserved;
00331 
00332 } MP4_Box_data_smhd_t;
00333 
00334 typedef struct MP4_Box_data_hmhd_s
00335 {
00336     uint8_t  i_version;
00337     uint32_t i_flags;
00338 
00339     uint16_t i_max_PDU_size;
00340     uint16_t i_avg_PDU_size;
00341     uint32_t i_max_bitrate;
00342     uint32_t i_avg_bitrate;
00343     uint32_t i_reserved;
00344 
00345 } MP4_Box_data_hmhd_t;
00346 
00347 typedef struct MP4_Box_data_url_s
00348 {
00349     uint8_t  i_version;
00350     uint32_t i_flags;
00351 
00352     unsigned char *psz_location;
00353 
00354 } MP4_Box_data_url_t;
00355 
00356 typedef struct MP4_Box_data_urn_s
00357 {
00358     uint8_t  i_version;
00359     uint32_t i_flags;
00360 
00361     unsigned char *psz_name;
00362     unsigned char *psz_location;
00363 
00364 } MP4_Box_data_urn_t;
00365 
00366 typedef struct MP4_Box_data_dref_s
00367 {
00368     uint8_t  i_version;
00369     uint32_t i_flags;
00370 
00371     uint32_t i_entry_count;
00372 /* XXX it's also a container with i_entry_count entry */
00373 } MP4_Box_data_dref_t;
00374 
00375 typedef struct MP4_Box_data_stts_s
00376 {
00377     uint8_t  i_version;
00378     uint32_t i_flags;
00379 
00380     uint32_t i_entry_count;
00381     uint32_t *i_sample_count; /* these are array */
00382     int32_t  *i_sample_delta;
00383 
00384 } MP4_Box_data_stts_t;
00385 
00386 typedef struct MP4_Box_data_ctts_s
00387 {
00388     uint8_t  i_version;
00389     uint32_t i_flags;
00390 
00391     uint32_t i_entry_count;
00392 
00393     uint32_t *i_sample_count; /* these are array */
00394     int32_t  *i_sample_offset;
00395 
00396 } MP4_Box_data_ctts_t;
00397 
00398 
00399 typedef struct MP4_Box_data_sample_soun_s
00400 {
00401     uint8_t  i_reserved1[6];
00402     uint16_t i_data_reference_index;
00403 
00404     //uint32_t i_reserved2[2];
00405     uint16_t i_qt_version;
00406     uint16_t i_qt_revision_level;
00407     uint32_t i_qt_vendor;
00408 
00409     uint16_t i_channelcount;
00410     uint16_t i_samplesize;
00411     uint16_t i_predefined;
00412     uint16_t i_reserved3;
00413     uint16_t i_sampleratehi; /* timescale of track */
00414     uint16_t i_sampleratelo;
00415 
00416     /* for version 1 (i_reserved1[0] == 1) */
00417     uint32_t i_sample_per_packet;
00418     uint32_t i_bytes_per_packet;
00419     uint32_t i_bytes_per_frame;
00420     uint32_t i_bytes_per_sample;
00421 
00422     /* XXX hack */
00423     int     i_qt_description;
00424     uint8_t *p_qt_description;
00425 
00426     void    *p_drms;
00427 
00428 } MP4_Box_data_sample_soun_t;
00429 
00430 typedef struct MP4_Box_data_sample_vide_s
00431 {
00432     uint8_t  i_reserved1[6];
00433     uint16_t i_data_reference_index;
00434 
00435     uint16_t i_qt_version;
00436     uint16_t i_qt_revision_level;
00437     uint32_t i_qt_vendor;
00438 
00439     uint32_t i_qt_temporal_quality;
00440     uint32_t i_qt_spatial_quality;
00441 
00442     int16_t  i_width;
00443     int16_t  i_height;
00444 
00445     uint32_t i_horizresolution;
00446     uint32_t i_vertresolution;
00447 
00448     uint32_t i_qt_data_size;
00449     uint16_t i_qt_frame_count;
00450 
00451     uint8_t  i_compressorname[32];
00452     int16_t  i_depth;
00453 
00454     int16_t  i_qt_color_table;
00455 
00456     /* XXX hack ImageDescription */
00457     int     i_qt_image_description;
00458     uint8_t *p_qt_image_description;
00459 
00460 } MP4_Box_data_sample_vide_t;
00461 
00462 #define MP4_TEXT_DISPLAY_FLAG_DONT_DISPLAY       (1<<0)
00463 #define MP4_TEXT_DISPLAY_FLAG_AUTO_SCALE         (1<<1)
00464 #define MP4_TEXT_DISPLAY_FLAG_CLIP_TO_TEXT_BOX   (1<<2)
00465 #define MP4_TEXT_DISPLAY_FLAG_USE_MOVIE_BG_COLOR (1<<3)
00466 #define MP4_TEXT_DISPLAY_FLAG_SHRINK_TEXT_BOX_TO_FIT (1<<4)
00467 #define MP4_TEXT_DISPLAY_FLAG_SCROLL_IN          (1<<5)
00468 #define MP4_TEXT_DISPLAY_FLAG_SCROLL_OUT         (1<<6)
00469 #define MP4_TEXT_DISPLAY_FLAG_HORIZONTAL_SCROLL  (1<<7)
00470 #define MP4_TEXT_DISPLAY_FLAG_REVERSE_SCROLL     (1<<8)
00471 #define MP4_TEXT_DISPLAY_FLAG_CONTINUOUS_SCROLL  (1<<9)
00472 #define MP4_TEXT_DISPLAY_FLAG_FLOW_HORIZONTAL    (1<<10)
00473 #define MP4_TEXT_DISPLAY_FLAG_CONTINUOUS_KARAOKE (1<<11)
00474 #define MP4_TEXT_DISPLAY_FLAG_DROP_SHADOW        (1<<12)
00475 #define MP4_TEXT_DISPLAY_FLAG_ANTI_ALIAS         (1<<13)
00476 #define MP4_TEXT_DISPLAY_FLAG_KEYED_TEXT         (1<<14)
00477 #define MP4_TEXT_DISPLAY_FLAG_INVERSE_HILITE     (1<<15)
00478 #define MP4_TEXT_DISPLAY_FLAG_COLOR_HILITE       (1<<16)
00479 #define MP4_TEXT_DISPLAY_FLAG_WRITE_VERTICALLY   (1<<17)
00480 
00481 typedef struct
00482 {
00483     uint32_t i_reserved1;
00484     uint16_t i_reserved2;
00485 
00486     uint16_t i_data_reference_index;
00487 
00488     uint32_t i_display_flags;   // TextDescription and Tx3gDescription
00489 
00490     int8_t i_justification_horizontal; // left(0), centered(1), right(-1)
00491     int8_t i_justification_vertical;   // top(0), centered(1), bottom(-1)
00492 
00493     uint16_t i_background_color[4];
00494 
00495     uint16_t i_text_box_top;
00496     uint16_t i_text_box_left;
00497     uint16_t i_text_box_bottom;
00498     uint16_t i_text_box_right;
00499 
00500     // TODO to complete
00501 } MP4_Box_data_sample_text_t;
00502 
00503 typedef struct MP4_Box_data_sample_hint_s
00504 {
00505     uint8_t  i_reserved1[6];
00506     uint16_t i_data_reference_index;
00507 
00508     uint8_t *p_data;
00509 
00510 } MP4_Box_data_sample_hint_t;
00511 
00512 typedef struct MP4_Box_data_moviehintinformation_rtp_s
00513 {
00514     uint32_t i_description_format;
00515     unsigned char *psz_text;
00516 
00517 } MP4_Box_data_moviehintinformation_rtp_t;
00518 
00519 
00520 
00521 typedef struct MP4_Box_data_stsd_s
00522 {
00523     uint8_t  i_version;
00524     uint32_t i_flags;
00525 
00526     uint32_t i_entry_count;
00527 
00528     /* it contains SampleEntry handled as if it was Box */
00529 
00530 } MP4_Box_data_stsd_t;
00531 
00532 
00533 typedef struct MP4_Box_data_stsz_s
00534 {
00535     uint8_t  i_version;
00536     uint32_t i_flags;
00537 
00538     uint32_t i_sample_size;
00539     uint32_t i_sample_count;
00540 
00541     uint32_t *i_entry_size; /* array , empty if i_sample_size != 0 */
00542 
00543 } MP4_Box_data_stsz_t;
00544 
00545 typedef struct MP4_Box_data_stz2_s
00546 {
00547     uint8_t  i_version;
00548     uint32_t i_flags;
00549 
00550     uint32_t i_sample_size; /* 24 bits */
00551     uint8_t  i_field_size;
00552     uint32_t i_sample_count;
00553 
00554     uint32_t *i_entry_size; /* array: unsigned int(i_field_size) entry_size */
00555 
00556 } MP4_Box_data_stz2_t;
00557 
00558 typedef struct MP4_Box_data_stsc_s
00559 {
00560     uint8_t  i_version;
00561     uint32_t i_flags;
00562 
00563     uint32_t i_entry_count;
00564 
00565     uint32_t *i_first_chunk; /* theses are arrays */
00566     uint32_t *i_samples_per_chunk;
00567     uint32_t *i_sample_description_index;
00568 
00569 } MP4_Box_data_stsc_t;
00570 
00571 
00572 typedef struct MP4_Box_data_co64_s
00573 {
00574     uint8_t  i_version;
00575     uint32_t i_flags;
00576 
00577     uint32_t i_entry_count;
00578 
00579     uint64_t *i_chunk_offset;
00580 
00581 } MP4_Box_data_co64_t;
00582 
00583 
00584 typedef struct MP4_Box_data_stss_s
00585 {
00586     uint8_t  i_version;
00587     uint32_t i_flags;
00588 
00589     uint32_t i_entry_count;
00590 
00591     uint32_t *i_sample_number;
00592 
00593 } MP4_Box_data_stss_t;
00594 
00595 typedef struct MP4_Box_data_stsh_s
00596 {
00597     uint8_t  i_version;
00598     uint32_t i_flags;
00599 
00600     uint32_t i_entry_count;
00601 
00602     uint32_t *i_shadowed_sample_number;
00603     uint32_t *i_sync_sample_number;
00604 
00605 } MP4_Box_data_stsh_t;
00606 
00607 typedef struct MP4_Box_data_stdp_s
00608 {
00609     uint8_t  i_version;
00610     uint32_t i_flags;
00611 
00612     uint16_t *i_priority;
00613 
00614 } MP4_Box_data_stdp_t;
00615 
00616 typedef struct MP4_Box_data_padb_s
00617 {
00618     uint8_t  i_version;
00619     uint32_t i_flags;
00620 
00621     uint32_t i_sample_count;
00622 
00623     uint16_t *i_reserved1;   /* 1bit  */
00624     uint16_t *i_pad2;        /* 3bits */
00625     uint16_t *i_reserved2;   /* 1bit  */
00626     uint16_t *i_pad1;        /* 3bits */
00627 
00628 
00629 } MP4_Box_data_padb_t;
00630 
00631 
00632 typedef struct MP4_Box_data_elst_s
00633 {
00634     uint8_t  i_version;
00635     uint32_t i_flags;
00636 
00637     uint32_t i_entry_count;
00638 
00639     uint64_t *i_segment_duration;
00640     int64_t  *i_media_time;
00641     uint16_t *i_media_rate_integer;
00642     uint16_t *i_media_rate_fraction;
00643 
00644 
00645 } MP4_Box_data_elst_t;
00646 
00647 typedef struct MP4_Box_data_cprt_s
00648 {
00649     uint8_t  i_version;
00650     uint32_t i_flags;
00651     /* 1 pad bit */
00652     unsigned char i_language[3];
00653 
00654     unsigned char *psz_notice;
00655 } MP4_Box_data_cprt_t;
00656 
00657 
00658 /* DecoderConfigDescriptor */
00659 typedef struct MP4_descriptor_decoder_config_s
00660 {
00661     uint8_t i_objectTypeIndication;
00662     uint8_t i_streamType;
00663     int     b_upStream;
00664     int     i_buffer_sizeDB;
00665     int     i_max_bitrate;
00666     int     i_avg_bitrate;
00667 
00668     int     i_decoder_specific_info_len;
00669     uint8_t *p_decoder_specific_info;
00670     /* some other stuff */
00671 
00672 } MP4_descriptor_decoder_config_t;
00673 
00674 typedef struct MP4_descriptor_SL_config_s
00675 {
00676 
00677     int i_dummy; /* ANSI C forbids empty structures */
00678 
00679 } MP4_descriptor_SL_config_t;
00680 
00681 
00682 typedef struct MP4_descriptor_ES_s
00683 {
00684     uint16_t i_ES_ID;
00685     int      b_stream_dependence;
00686     int      b_url;
00687     int      b_OCRstream;
00688     int      i_stream_priority;
00689 
00690     int      i_depend_on_ES_ID; /* if b_stream_dependence set */
00691 
00692     unsigned char *psz_URL;
00693 
00694     uint16_t i_OCR_ES_ID;       /* if b_OCRstream */
00695     MP4_descriptor_decoder_config_t *p_decConfigDescr;
00696 
00697     MP4_descriptor_SL_config_t *p_slConfigDescr;
00698 
00699     /* some other stuff ... */
00700 
00701 } MP4_descriptor_ES_t;
00702 
00703 /* ES descriptor */
00704 typedef struct MP4_Box_data_esds_s
00705 {
00706     uint8_t  i_version;
00707     uint32_t i_flags;
00708 
00709     MP4_descriptor_ES_t es_descriptor;
00710 
00711 } MP4_Box_data_esds_t;
00712 
00713 
00714 typedef struct MP4_Box_data_dcom_s
00715 {
00716     uint32_t i_algorithm; /* fourcc */
00717 
00718 } MP4_Box_data_dcom_t;
00719 
00720 typedef struct MP4_Box_data_cmvd_s
00721 {
00722     uint32_t i_uncompressed_size;
00723     uint32_t i_compressed_size;
00724 
00725     int     b_compressed; /* Set to 1 if compressed data, 0 if uncompressed */
00726     uint8_t *p_data;
00727 
00728 } MP4_Box_data_cmvd_t;
00729 
00730 typedef struct MP4_Box_data_cmov_s
00731 {
00732     struct MP4_Box_s *p_moov; /* uncompressed moov */
00733 
00734 } MP4_Box_data_cmov_t;
00735 
00736 typedef struct
00737 {
00738     uint8_t  i_version;
00739     uint32_t i_flags;
00740 
00741     uint32_t i_ref_type;
00742     char     *psz_ref;
00743 
00744 } MP4_Box_data_rdrf_t;
00745 
00746 typedef struct
00747 {
00748     uint8_t  i_version;
00749     uint32_t i_flags;
00750 
00751     uint32_t i_rate;
00752 
00753 } MP4_Box_data_rmdr_t;
00754 
00755 typedef struct
00756 {
00757     uint8_t  i_version;
00758     uint32_t i_flags;
00759 
00760     uint32_t i_gestaltType;
00761     uint32_t i_val1;
00762     uint32_t i_val2;
00763     uint16_t i_checkType;   /* 0: val1 is version min
00764                                1: gestalt value & val2 == val1 */
00765 
00766 } MP4_Box_data_rmvc_t;
00767 
00768 typedef struct
00769 {
00770     uint8_t  i_version;
00771     uint32_t i_flags;
00772 
00773 
00774 } MP4_Box_data_rmcd_t;
00775 
00776 typedef struct
00777 {
00778     uint32_t i_quality;
00779 
00780 } MP4_Box_data_rmqu_t;
00781 
00782 typedef struct
00783 {
00784     char *psz_text;
00785 
00786 } MP4_Box_data_0xa9xxx_t;
00787 
00788 typedef struct
00789 {
00790     uint8_t i_version;
00791     uint8_t i_profile;
00792     uint8_t i_profile_compatibility;
00793     uint8_t i_level;
00794 
00795     uint8_t i_reserved1;     /* 6 bits */
00796     uint8_t i_length_size;
00797 
00798     uint8_t i_reserved2;    /* 3 bits */
00799     uint8_t  i_sps;
00800     uint16_t *i_sps_length;
00801     uint8_t  **sps;
00802 
00803     uint8_t  i_pps;
00804     uint16_t *i_pps_length;
00805     uint8_t  **pps;
00806 
00807     /* XXX: Hack raw avcC atom payload */
00808     int     i_avcC;
00809     uint8_t *p_avcC;
00810 
00811 } MP4_Box_data_avcC_t;
00812 
00813 /*
00814 typedef struct MP4_Box_data__s
00815 {
00816     uint8_t  i_version;
00817     uint32_t i_flags;
00818 
00819 } MP4_Box_data__t;
00820 
00821 */
00822 
00823 typedef union MP4_Box_data_s
00824 {
00825     MP4_Box_data_ftyp_t *p_ftyp;
00826     MP4_Box_data_mvhd_t *p_mvhd;
00827     MP4_Box_data_tkhd_t *p_tkhd;
00828     MP4_Box_data_mdhd_t *p_mdhd;
00829     MP4_Box_data_hdlr_t *p_hdlr;
00830     MP4_Box_data_vmhd_t *p_vmhd;
00831     MP4_Box_data_smhd_t *p_smhd;
00832     MP4_Box_data_hmhd_t *p_hmhd;
00833     MP4_Box_data_url_t  *p_url;
00834     MP4_Box_data_urn_t  *p_urn;
00835     MP4_Box_data_dref_t *p_dref;
00836     MP4_Box_data_stts_t *p_stts;
00837     MP4_Box_data_ctts_t *p_ctts;
00838     MP4_Box_data_stsd_t *p_stsd;
00839         MP4_Box_data_sample_vide_t *p_sample_vide;
00840         MP4_Box_data_sample_soun_t *p_sample_soun;
00841         MP4_Box_data_sample_text_t *p_sample_text;
00842         MP4_Box_data_sample_hint_t *p_sample_hint;
00843 
00844         MP4_Box_data_esds_t *p_esds;
00845         MP4_Box_data_avcC_t *p_avcC;
00846 
00847     MP4_Box_data_stsz_t *p_stsz;
00848     MP4_Box_data_stz2_t *p_stz2;
00849     MP4_Box_data_stsc_t *p_stsc;
00850     MP4_Box_data_co64_t *p_co64;
00851     MP4_Box_data_stss_t *p_stss;
00852     MP4_Box_data_stsh_t *p_stsh;
00853     MP4_Box_data_stdp_t *p_stdp;
00854     MP4_Box_data_padb_t *p_padb;
00855     MP4_Box_data_elst_t *p_elst;
00856     MP4_Box_data_cprt_t *p_cprt;
00857 
00858     MP4_Box_data_dcom_t *p_dcom;
00859     MP4_Box_data_cmvd_t *p_cmvd;
00860     MP4_Box_data_cmov_t *p_cmov;
00861 
00862     MP4_Box_data_moviehintinformation_rtp_t p_moviehintinformation_rtp;
00863 
00864     MP4_Box_data_rdrf_t *p_rdrf;
00865     MP4_Box_data_rmdr_t *p_rmdr;
00866     MP4_Box_data_rmqu_t *p_rmqu;
00867     MP4_Box_data_rmvc_t *p_rmvc;
00868 
00869     MP4_Box_data_0xa9xxx_t *p_0xa9xxx;
00870 
00871     void                *p_data; /* for unknow type */
00872 } MP4_Box_data_t;
00873 
00874 
00875 
00876 /* the most basic structure */
00877 typedef struct MP4_Box_s
00878 {
00879     off_t        i_pos;      /* absolute position */
00880 
00881     uint32_t     i_type;
00882     uint32_t     i_shortsize;
00883 
00884     UUID_t       i_uuid;  /* Set if i_type == "uuid" */
00885 
00886     uint64_t     i_size; /* always set so use it */
00887 
00888     MP4_Box_data_t   data;   /* union of pointers on extended data depending
00889                                 on i_type (or i_usertype) */
00890 
00891     struct MP4_Box_s *p_father; /* pointer on the father Box */
00892 
00893     struct MP4_Box_s *p_first;  /* pointer on the first child Box */
00894     struct MP4_Box_s *p_last;
00895 
00896     struct MP4_Box_s *p_next;   /* pointer on the next boxes at the same level */
00897 
00898 } MP4_Box_t;
00899 
00900 
00901 
00902 /*****************************************************************************
00903  * MP4_BoxGetRoot : Parse the entire file, and create all boxes in memory
00904  *****************************************************************************
00905  *  The first box is a virtual box "root" and is the father for all first
00906  *  level boxes
00907  *****************************************************************************/
00908 MP4_Box_t *MP4_BoxGetRoot( stream_t * );
00909 
00910 /*****************************************************************************
00911  * MP4_FreeBox : free memory allocated after read with MP4_ReadBox
00912  *               or MP4_BoxGetRoot, this means also children boxes
00913  * XXX : all children have to be allocated by a malloc !! and
00914  *         p_box is freed
00915  *****************************************************************************/
00916 void MP4_BoxFree( stream_t *, MP4_Box_t *p_box );
00917 
00918 /*****************************************************************************
00919  * MP4_DumpBoxStructure: print the structure of the p_box
00920  *****************************************************************************
00921  * Usefull while debugging
00922  *****************************************************************************/
00923 void MP4_BoxDumpStructure( stream_t *p_input, MP4_Box_t *p_box );
00924 
00925 
00926 /*****************************************************************************
00927  * MP4_BoxGet: find a box given a path relative to p_box
00928  *****************************************************************************
00929  * Path Format: . .. / as usual
00930  *              [number] to specifie box number ex: trak[12]
00931  *
00932  * ex: /moov/trak[12]
00933  *     ../mdia
00934  *****************************************************************************/
00935 MP4_Box_t *MP4_BoxGet( MP4_Box_t *p_box, char *psz_fmt, ... );
00936 
00937 /*****************************************************************************
00938  * MP4_BoxCount: find number of box given a path relative to p_box
00939  *****************************************************************************
00940  * Path Format: . .. / as usual
00941  *              [number] to specifie box number ex: trak[12]
00942  *
00943  * ex: /moov/trak
00944  *     ../mdia
00945  *****************************************************************************/
00946 int MP4_BoxCount( MP4_Box_t *p_box, char *psz_fmt, ... );
00947 
00948 int MP4_ReadBoxCommon( stream_t *p_stream, MP4_Box_t *p_box );
00949 int MP4_ReadBox_sample_vide( stream_t *p_stream, MP4_Box_t *p_box );
00950 void MP4_FreeBox_sample_vide( MP4_Box_t *p_box );
00951 
00952 #endif

Generated on Tue Dec 20 10:14:34 2005 for vlc-0.8.4a by  doxygen 1.4.2