libavi.h
上传用户:riyaled888
上传日期:2009-03-27
资源大小:7338k
文件大小:12k
源码类别:

多媒体

开发平台:

MultiPlatform

  1. /*****************************************************************************
  2.  * libavi.h : LibAVI library
  3.  ******************************************************************************
  4.  * Copyright (C) 2001-2003 VideoLAN
  5.  * $Id: libavi.h 9270 2004-11-10 13:05:27Z gbazin $
  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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  21.  *****************************************************************************/
  22. /* flags for use in <dwFlags> in AVIFileHdr */
  23. #define AVIF_HASINDEX       0x00000010  /* Index at end of file? */
  24. #define AVIF_MUSTUSEINDEX   0x00000020
  25. #define AVIF_ISINTERLEAVED  0x00000100
  26. #define AVIF_TRUSTCKTYPE    0x00000800  /* Use CKType to find key frames? */
  27. #define AVIF_WASCAPTUREFILE 0x00010000
  28. #define AVIF_COPYRIGHTED    0x00020000
  29. /* Flags for index */
  30. #define AVIIF_LIST          0x00000001L /* chunk is a 'LIST' */
  31. #define AVIIF_KEYFRAME      0x00000010L /* this frame is a key frame.*/
  32. #define AVIIF_NOTIME        0x00000100L /* this frame doesn't take any time */
  33. #define AVIIF_COMPUSE       0x0FFF0000L /* these bits are for compressor use */
  34. #define AVIIF_FIXKEYFRAME   0x00001000L /* invented; used to say that */
  35.                                         /* the keyframe flag isn't a true flag */
  36.                                         /* but have to be verified */
  37. #define AVI_CHUNK_COMMON            
  38.     vlc_fourcc_t i_chunk_fourcc;    
  39.     uint64_t i_chunk_size;          
  40.     uint64_t i_chunk_pos;           
  41.     union  avi_chunk_u *p_next;    
  42.     union  avi_chunk_u *p_father;  
  43.     union  avi_chunk_u *p_first;   
  44.     union  avi_chunk_u *p_last;
  45. #define AVI_CHUNK( p_chk ) (avi_chunk_t*)(p_chk)
  46. typedef struct idx1_entry_s
  47. {
  48.     vlc_fourcc_t i_fourcc;
  49.     uint32_t i_flags;
  50.     uint32_t i_pos;
  51.     uint32_t i_length;
  52. } idx1_entry_t;
  53. typedef struct avi_chunk_common_s
  54. {
  55.     AVI_CHUNK_COMMON
  56. } avi_chunk_common_t;
  57. typedef struct avi_chunk_list_s
  58. {
  59.     AVI_CHUNK_COMMON
  60.     vlc_fourcc_t i_type;
  61. } avi_chunk_list_t;
  62. typedef struct avi_chunk_idx1_s
  63. {
  64.     AVI_CHUNK_COMMON
  65.     unsigned int i_entry_count;
  66.     unsigned int i_entry_max;
  67.     idx1_entry_t *entry;
  68. } avi_chunk_idx1_t;
  69. typedef struct avi_chunk_avih_s
  70. {
  71.     AVI_CHUNK_COMMON
  72.     uint32_t i_microsecperframe;
  73.     uint32_t i_maxbytespersec;
  74.     uint32_t i_reserved1; /* dwPaddingGranularity;    pad to multiples of this
  75.                              size; normally 2K */
  76.     uint32_t i_flags;
  77.     uint32_t i_totalframes;
  78.     uint32_t i_initialframes;
  79.     uint32_t i_streams;
  80.     uint32_t i_suggestedbuffersize;
  81.     uint32_t i_width;
  82.     uint32_t i_height;
  83.     uint32_t i_scale;
  84.     uint32_t i_rate;
  85.     uint32_t i_start;
  86.     uint32_t i_length;
  87. } avi_chunk_avih_t;
  88. typedef struct avi_chunk_strh_s
  89. {
  90.     AVI_CHUNK_COMMON
  91.     vlc_fourcc_t i_type;
  92.     uint32_t i_handler;
  93.     uint32_t i_flags;
  94.     uint32_t i_reserved1;    /* wPriority wLanguage */
  95.     uint32_t i_initialframes;
  96.     uint32_t i_scale;
  97.     uint32_t i_rate;
  98.     uint32_t i_start;
  99.     uint32_t i_length;       /* In units above... */
  100.     uint32_t i_suggestedbuffersize;
  101.     uint32_t i_quality;
  102.     uint32_t i_samplesize;
  103. } avi_chunk_strh_t;
  104. typedef struct avi_chunk_strf_auds_s
  105. {
  106.     AVI_CHUNK_COMMON
  107.     int             i_cat;
  108.     WAVEFORMATEX    *p_wf;
  109. } avi_chunk_strf_auds_t;
  110. typedef struct avi_chunk_strf_vids_s
  111. {
  112.     AVI_CHUNK_COMMON
  113.     int              i_cat;
  114.     BITMAPINFOHEADER *p_bih;
  115. } avi_chunk_strf_vids_t;
  116. typedef union avi_chunk_strf_u
  117. {
  118.     avi_chunk_strf_auds_t   auds;
  119.     avi_chunk_strf_vids_t   vids;
  120.     struct
  121.     {
  122.         AVI_CHUNK_COMMON
  123.         int i_cat;
  124.     }                       common;
  125. } avi_chunk_strf_t;
  126. typedef struct avi_chunk_strd_s
  127. {
  128.     AVI_CHUNK_COMMON
  129.     uint8_t  *p_data;
  130. } avi_chunk_strd_t;
  131. #define AVI_INDEX_OF_INDEXES    0x00
  132. #define AVI_INDEX_OF_CHUNKS     0x01
  133. #define AVI_INDEX_IS_DATA       0x80
  134. #define AVI_INDEX_2FIELD        0x01
  135. typedef struct
  136. {
  137.     uint32_t i_offset;
  138.     uint32_t i_size;
  139. } indx_std_entry_t;
  140. typedef struct
  141. {
  142.     uint32_t i_offset;
  143.     uint32_t i_size;
  144.     uint32_t i_offsetfield2;
  145. } indx_field_entry_t;
  146. typedef struct
  147. {
  148.     uint64_t i_offset;
  149.     uint32_t i_size;
  150.     uint32_t i_duration;
  151. } indx_super_entry_t;
  152. typedef struct avi_chunk_indx_s
  153. {
  154.     AVI_CHUNK_COMMON
  155.     int16_t i_longsperentry;
  156.     int8_t  i_indexsubtype;
  157.     int8_t  i_indextype;
  158.     int32_t i_entriesinuse;
  159.     vlc_fourcc_t i_id;
  160.     int64_t i_baseoffset;
  161.     union
  162.     {
  163.         indx_std_entry_t    *std;
  164.         indx_field_entry_t  *field;
  165.         indx_super_entry_t  *super;
  166.     } idx;
  167. } avi_chunk_indx_t;
  168. typedef struct avi_chunk_STRING_s
  169. {
  170.     AVI_CHUNK_COMMON
  171.     char *p_type;
  172.     char *p_str;
  173. } avi_chunk_STRING_t;
  174. typedef union avi_chunk_u
  175. {
  176.     avi_chunk_common_t  common;
  177.     avi_chunk_list_t    list;
  178.     avi_chunk_idx1_t    idx1;
  179.     avi_chunk_avih_t    avih;
  180.     avi_chunk_strh_t    strh;
  181.     avi_chunk_strf_t    strf;
  182.     avi_chunk_strd_t    strd;
  183.     avi_chunk_indx_t    indx;
  184.     avi_chunk_STRING_t  strz;
  185. } avi_chunk_t;
  186. /****************************************************************************
  187.  * Stream(input) access functions
  188.  ****************************************************************************/
  189. int     _AVI_ChunkRead( stream_t *,
  190.                         avi_chunk_t *p_chk,
  191.                         avi_chunk_t *p_father );
  192. int     _AVI_ChunkCount( avi_chunk_t *, vlc_fourcc_t );
  193. void   *_AVI_ChunkFind ( avi_chunk_t *, vlc_fourcc_t, int );
  194. int     AVI_ChunkReadRoot( stream_t *, avi_chunk_t *p_root );
  195. void    AVI_ChunkFreeRoot( stream_t *, avi_chunk_t  *p_chk );
  196. #define AVI_ChunkRead( s, p_chk, p_father ) 
  197.     _AVI_ChunkRead( s, p_chk, (avi_chunk_t*)p_father )
  198. #define AVI_ChunkCount( p_chk, i_fourcc ) 
  199.     _AVI_ChunkCount( (avi_chunk_t*)p_chk, i_fourcc )
  200. #define AVI_ChunkFind( p_chk, i_fourcc, i_number ) 
  201.     _AVI_ChunkFind( (avi_chunk_t*)p_chk, i_fourcc, i_number )
  202.     /* *** avi stuff *** */
  203. #define AVIFOURCC_RIFF         VLC_FOURCC('R','I','F','F')
  204. #define AVIFOURCC_LIST         VLC_FOURCC('L','I','S','T')
  205. #define AVIFOURCC_JUNK         VLC_FOURCC('J','U','N','K')
  206. #define AVIFOURCC_AVI          VLC_FOURCC('A','V','I',' ')
  207. #define AVIFOURCC_AVIX         VLC_FOURCC('A','V','I','X')
  208. #define AVIFOURCC_WAVE         VLC_FOURCC('W','A','V','E')
  209. #define AVIFOURCC_INFO         VLC_FOURCC('I','N','F','O')
  210. #define AVIFOURCC_avih         VLC_FOURCC('a','v','i','h')
  211. #define AVIFOURCC_hdrl         VLC_FOURCC('h','d','r','l')
  212. #define AVIFOURCC_movi         VLC_FOURCC('m','o','v','i')
  213. #define AVIFOURCC_idx1         VLC_FOURCC('i','d','x','1')
  214. #define AVIFOURCC_strl         VLC_FOURCC('s','t','r','l')
  215. #define AVIFOURCC_strh         VLC_FOURCC('s','t','r','h')
  216. #define AVIFOURCC_strf         VLC_FOURCC('s','t','r','f')
  217. #define AVIFOURCC_strd         VLC_FOURCC('s','t','r','d')
  218. #define AVIFOURCC_strn         VLC_FOURCC('s','t','r','n')
  219. #define AVIFOURCC_indx         VLC_FOURCC('i','n','d','x')
  220. #define AVIFOURCC_rec          VLC_FOURCC('r','e','c',' ')
  221. #define AVIFOURCC_auds         VLC_FOURCC('a','u','d','s')
  222. #define AVIFOURCC_vids         VLC_FOURCC('v','i','d','s')
  223. #define AVIFOURCC_txts         VLC_FOURCC('t','x','t','s')
  224. #define AVIFOURCC_mids         VLC_FOURCC('m','i','d','s')
  225. #define AVIFOURCC_IARL         VLC_FOURCC('I','A','R','L')
  226. #define AVIFOURCC_IART         VLC_FOURCC('I','A','R','T')
  227. #define AVIFOURCC_ICMS         VLC_FOURCC('I','C','M','S')
  228. #define AVIFOURCC_ICMT         VLC_FOURCC('I','C','M','T')
  229. #define AVIFOURCC_ICOP         VLC_FOURCC('I','C','O','P')
  230. #define AVIFOURCC_ICRD         VLC_FOURCC('I','C','R','D')
  231. #define AVIFOURCC_ICRP         VLC_FOURCC('I','C','R','P')
  232. #define AVIFOURCC_IDIM         VLC_FOURCC('I','D','I','M')
  233. #define AVIFOURCC_IDPI         VLC_FOURCC('I','D','P','I')
  234. #define AVIFOURCC_IENG         VLC_FOURCC('I','E','N','G')
  235. #define AVIFOURCC_IGNR         VLC_FOURCC('I','G','N','R')
  236. #define AVIFOURCC_IKEY         VLC_FOURCC('I','K','E','Y')
  237. #define AVIFOURCC_ILGT         VLC_FOURCC('I','L','G','T')
  238. #define AVIFOURCC_IMED         VLC_FOURCC('I','M','E','D')
  239. #define AVIFOURCC_INAM         VLC_FOURCC('I','N','A','M')
  240. #define AVIFOURCC_IPLT         VLC_FOURCC('I','P','L','T')
  241. #define AVIFOURCC_IPRD         VLC_FOURCC('I','P','R','D')
  242. #define AVIFOURCC_ISBJ         VLC_FOURCC('I','S','B','J')
  243. #define AVIFOURCC_ISFT         VLC_FOURCC('I','S','F','T')
  244. #define AVIFOURCC_ISHP         VLC_FOURCC('I','S','H','P')
  245. #define AVIFOURCC_ISRC         VLC_FOURCC('I','S','R','C')
  246. #define AVIFOURCC_ISRF         VLC_FOURCC('I','S','R','F')
  247. #define AVIFOURCC_ITCH         VLC_FOURCC('I','T','C','H')
  248. #define AVIFOURCC_ISMP         VLC_FOURCC('I','S','M','P')
  249. #define AVIFOURCC_IDIT         VLC_FOURCC('I','D','I','T')
  250.     
  251. #define AVITWOCC_wb            VLC_TWOCC('w','b')
  252. #define AVITWOCC_db            VLC_TWOCC('d','b')
  253. #define AVITWOCC_dc            VLC_TWOCC('d','c')
  254. #define AVITWOCC_pc            VLC_TWOCC('p','c')
  255.     /* *** codex stuff ***  */
  256.     /* Microsoft RLE video */
  257. #define FOURCC_1            VLC_FOURCC( 1,  0,  0,  0 )
  258.     /* MPEG4 video */
  259. #define FOURCC_DIVX         VLC_FOURCC('D','I','V','X')
  260. #define FOURCC_divx         VLC_FOURCC('d','i','v','x')
  261. #define FOURCC_DIV1         VLC_FOURCC('D','I','V','1')
  262. #define FOURCC_div1         VLC_FOURCC('d','i','v','1')
  263. #define FOURCC_MP4S         VLC_FOURCC('M','P','4','S')
  264. #define FOURCC_mp4s         VLC_FOURCC('m','p','4','s')
  265. #define FOURCC_M4S2         VLC_FOURCC('M','4','S','2')
  266. #define FOURCC_m4s2         VLC_FOURCC('m','4','s','2')
  267. #define FOURCC_xvid         VLC_FOURCC('x','v','i','d')
  268. #define FOURCC_XVID         VLC_FOURCC('X','V','I','D')
  269. #define FOURCC_XviD         VLC_FOURCC('X','v','i','D')
  270. #define FOURCC_DX50         VLC_FOURCC('D','X','5','0')
  271. #define FOURCC_dx50         VLC_FOURCC('d','x','5','0')
  272. #define FOURCC_mp4v         VLC_FOURCC('m','p','4','v')
  273. #define FOURCC_4            VLC_FOURCC( 4,  0,  0,  0 )
  274.     /* MSMPEG4 v2 */
  275. #define FOURCC_MPG4         VLC_FOURCC('M','P','G','4')
  276. #define FOURCC_mpg4         VLC_FOURCC('m','p','g','4')
  277. #define FOURCC_DIV2         VLC_FOURCC('D','I','V','2')
  278. #define FOURCC_div2         VLC_FOURCC('d','i','v','2')
  279. #define FOURCC_MP42         VLC_FOURCC('M','P','4','2')
  280. #define FOURCC_mp42         VLC_FOURCC('m','p','4','2')
  281.     /* MSMPEG4 v3 / M$ mpeg4 v3 */
  282. #define FOURCC_MPG3         VLC_FOURCC('M','P','G','3')
  283. #define FOURCC_mpg3         VLC_FOURCC('m','p','g','3')
  284. #define FOURCC_div3         VLC_FOURCC('d','i','v','3')
  285. #define FOURCC_MP43         VLC_FOURCC('M','P','4','3')
  286. #define FOURCC_mp43         VLC_FOURCC('m','p','4','3')
  287.     /* DivX 3.20 */
  288. #define FOURCC_DIV3         VLC_FOURCC('D','I','V','3')
  289. #define FOURCC_DIV4         VLC_FOURCC('D','I','V','4')
  290. #define FOURCC_div4         VLC_FOURCC('d','i','v','4')
  291. #define FOURCC_DIV5         VLC_FOURCC('D','I','V','5')
  292. #define FOURCC_div5         VLC_FOURCC('d','i','v','5')
  293. #define FOURCC_DIV6         VLC_FOURCC('D','I','V','6')
  294. #define FOURCC_div6         VLC_FOURCC('d','i','v','6')
  295.     /* AngelPotion stuff */
  296. #define FOURCC_AP41         VLC_FOURCC('A','P','4','1')
  297.     /* 3IVX */
  298. #define FOURCC_3IV1         VLC_FOURCC('3','I','V','1')
  299. #define FOURCC_3iv1         VLC_FOURCC('2','i','v','1')
  300. #define FOURCC_3IV2         VLC_FOURCC('3','I','V','2')
  301. #define FOURCC_3iv2         VLC_FOURCC('3','i','v','2')
  302. #define FOURCC_3IVD         VLC_FOURCC('3','I','V','D')
  303. #define FOURCC_3ivd         VLC_FOURCC('3','i','v','d')
  304. #define FOURCC_3VID         VLC_FOURCC('3','V','I','D')
  305. #define FOURCC_3vid         VLC_FOURCC('3','v','i','d')
  306.     /* H263 and H263i */
  307. #define FOURCC_H263         VLC_FOURCC('H','2','6','3')
  308. #define FOURCC_h263         VLC_FOURCC('h','2','6','3')
  309. #define FOURCC_U263         VLC_FOURCC('U','2','6','3')
  310. #define FOURCC_I263         VLC_FOURCC('I','2','6','3')
  311. #define FOURCC_i263         VLC_FOURCC('i','2','6','3')
  312.     /* H264 */
  313. #define FOURCC_H264         VLC_FOURCC('H','2','6','4')
  314. #define FOURCC_h264         VLC_FOURCC('h','2','6','4')
  315. #define FOURCC_VSSH         VLC_FOURCC('V','S','S','H')