]> git.sesse.net Git - vlc/blobdiff - modules/demux/avi/libavi.h
Make Zorglub less unhappy
[vlc] / modules / demux / avi / libavi.h
index 677eddba83f0a6c396e5f51e4191abb914a755fe..044e88811bdb4c35cc59e766d0dd8f81e2af022e 100644 (file)
@@ -1,15 +1,15 @@
 /*****************************************************************************
- * libavi.h : LibAVI library 
+ * libavi.h : LibAVI library
  ******************************************************************************
- * Copyright (C) 2001 VideoLAN
- * $Id: libavi.h,v 1.3 2002/11/05 23:48:46 gbazin Exp $
+ * Copyright (C) 2001-2003 the VideoLAN team
+ * $Id$
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
- * 
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
@@ -20,8 +20,6 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#include "codecs.h"                                      /* BITMAPINFOHEADER */
-
 /* flags for use in <dwFlags> in AVIFileHdr */
 #define AVIF_HASINDEX       0x00000010  /* Index at end of file? */
 #define AVIF_MUSTUSEINDEX   0x00000020
 #define AVIIF_NOTIME        0x00000100L /* this frame doesn't take any time */
 #define AVIIF_COMPUSE       0x0FFF0000L /* these bits are for compressor use */
 
-#define AVIIF_FIXKEYFRAME   0x00001000L /* invented; used to say that 
-                                           the keyframe flag isn't a true flag
-                                           but have to be verified */
+#define AVIIF_FIXKEYFRAME   0x00001000L /* invented; used to say that */
+                                        /* the keyframe flag isn't a true flag */
+                                        /* but have to be verified */
+
+#define AVI_CHUNK_COMMON            \
+    vlc_fourcc_t i_chunk_fourcc;    \
+    uint64_t i_chunk_size;          \
+    uint64_t i_chunk_pos;           \
+    union  avi_chunk_u *p_next;    \
+    union  avi_chunk_u *p_father;  \
+    union  avi_chunk_u *p_first;   \
+    union  avi_chunk_u *p_last;
+
+#define AVI_CHUNK( p_chk ) (avi_chunk_t*)(p_chk)
+
+typedef struct idx1_entry_s
+{
+    vlc_fourcc_t i_fourcc;
+    uint32_t i_flags;
+    uint32_t i_pos;
+    uint32_t i_length;
+
+} idx1_entry_t;
+typedef struct avi_chunk_common_s
+{
+    AVI_CHUNK_COMMON
+} avi_chunk_common_t;
+
+typedef struct avi_chunk_list_s
+{
+    AVI_CHUNK_COMMON
+    vlc_fourcc_t i_type;
+} avi_chunk_list_t;
+
+typedef struct avi_chunk_idx1_s
+{
+    AVI_CHUNK_COMMON
+    unsigned int i_entry_count;
+    unsigned int i_entry_max;
+    idx1_entry_t *entry;
+
+} avi_chunk_idx1_t;
+
+typedef struct avi_chunk_avih_s
+{
+    AVI_CHUNK_COMMON
+    uint32_t i_microsecperframe;
+    uint32_t i_maxbytespersec;
+    uint32_t i_reserved1; /* dwPaddingGranularity;    pad to multiples of this
+                             size; normally 2K */
+    uint32_t i_flags;
+    uint32_t i_totalframes;
+    uint32_t i_initialframes;
+    uint32_t i_streams;
+    uint32_t i_suggestedbuffersize;
+    uint32_t i_width;
+    uint32_t i_height;
+    uint32_t i_scale;
+    uint32_t i_rate;
+    uint32_t i_start;
+    uint32_t i_length;
+} avi_chunk_avih_t;
+
+typedef struct avi_chunk_strh_s
+{
+    AVI_CHUNK_COMMON
+    vlc_fourcc_t i_type;
+    uint32_t i_handler;
+    uint32_t i_flags;
+    uint32_t i_reserved1;    /* wPriority wLanguage */
+    uint32_t i_initialframes;
+    uint32_t i_scale;
+    uint32_t i_rate;
+    uint32_t i_start;
+    uint32_t i_length;       /* In units above... */
+    uint32_t i_suggestedbuffersize;
+    uint32_t i_quality;
+    uint32_t i_samplesize;
+} avi_chunk_strh_t;
+
+typedef struct avi_chunk_strf_auds_s
+{
+    AVI_CHUNK_COMMON
+    int             i_cat;
+    WAVEFORMATEX    *p_wf;
+} avi_chunk_strf_auds_t;
+
+typedef struct avi_chunk_strf_vids_s
+{
+    AVI_CHUNK_COMMON
+    int              i_cat;
+    BITMAPINFOHEADER *p_bih;
+} avi_chunk_strf_vids_t;
+
+typedef union avi_chunk_strf_u
+{
+    avi_chunk_strf_auds_t   auds;
+    avi_chunk_strf_vids_t   vids;
+    struct
+    {
+        AVI_CHUNK_COMMON
+        int i_cat;
+    }                       common;
+} avi_chunk_strf_t;
+
+typedef struct avi_chunk_strd_s
+{
+    AVI_CHUNK_COMMON
+    uint8_t  *p_data;
+} avi_chunk_strd_t;
+
+
+#define AVI_INDEX_OF_INDEXES    0x00
+#define AVI_INDEX_OF_CHUNKS     0x01
+#define AVI_INDEX_IS_DATA       0x80
+
+#define AVI_INDEX_2FIELD        0x01
+typedef struct
+{
+    uint32_t i_offset;
+    uint32_t i_size;
+} indx_std_entry_t;
+
+typedef struct
+{
+    uint32_t i_offset;
+    uint32_t i_size;
+    uint32_t i_offsetfield2;
+} indx_field_entry_t;
+
+typedef struct
+{
+    uint64_t i_offset;
+    uint32_t i_size;
+    uint32_t i_duration;
+} indx_super_entry_t;
+
+typedef struct avi_chunk_indx_s
+{
+    AVI_CHUNK_COMMON
+    int16_t i_longsperentry;
+    int8_t  i_indexsubtype;
+    int8_t  i_indextype;
+    int32_t i_entriesinuse;
+    vlc_fourcc_t i_id;
+
+    int64_t i_baseoffset;
+
+    union
+    {
+        indx_std_entry_t    *std;
+        indx_field_entry_t  *field;
+        indx_super_entry_t  *super;
+    } idx;
+} avi_chunk_indx_t;
+
+typedef struct avi_chunk_STRING_s
+{
+    AVI_CHUNK_COMMON
+    char *p_type;
+    char *p_str;
+} avi_chunk_STRING_t;
+
+typedef union avi_chunk_u
+{
+    avi_chunk_common_t  common;
+    avi_chunk_list_t    list;
+    avi_chunk_idx1_t    idx1;
+    avi_chunk_avih_t    avih;
+    avi_chunk_strh_t    strh;
+    avi_chunk_strf_t    strf;
+    avi_chunk_strd_t    strd;
+    avi_chunk_indx_t    indx;
+    avi_chunk_STRING_t  strz;
+} avi_chunk_t;
+
+/****************************************************************************
+ * Stream(input) access functions
+ ****************************************************************************/
+int     _AVI_ChunkRead( stream_t *,
+                        avi_chunk_t *p_chk,
+                        avi_chunk_t *p_father );
+
+int     _AVI_ChunkCount( avi_chunk_t *, vlc_fourcc_t );
+void   *_AVI_ChunkFind ( avi_chunk_t *, vlc_fourcc_t, int );
+
+int     AVI_ChunkReadRoot( stream_t *, avi_chunk_t *p_root );
+void    AVI_ChunkFreeRoot( stream_t *, avi_chunk_t  *p_chk );
+
+#define AVI_ChunkRead( s, p_chk, p_father ) \
+    _AVI_ChunkRead( s, p_chk, (avi_chunk_t*)p_father )
+#define AVI_ChunkCount( p_chk, i_fourcc ) \
+    _AVI_ChunkCount( (avi_chunk_t*)p_chk, i_fourcc )
+#define AVI_ChunkFind( p_chk, i_fourcc, i_number ) \
+    _AVI_ChunkFind( (avi_chunk_t*)p_chk, i_fourcc, i_number )
+
 
     /* *** avi stuff *** */
 
 #define AVIFOURCC_LIST         VLC_FOURCC('L','I','S','T')
 #define AVIFOURCC_JUNK         VLC_FOURCC('J','U','N','K')
 #define AVIFOURCC_AVI          VLC_FOURCC('A','V','I',' ')
+#define AVIFOURCC_AVIX         VLC_FOURCC('A','V','I','X')
 #define AVIFOURCC_WAVE         VLC_FOURCC('W','A','V','E')
 #define AVIFOURCC_INFO         VLC_FOURCC('I','N','F','O')
 
 #define AVIFOURCC_strh         VLC_FOURCC('s','t','r','h')
 #define AVIFOURCC_strf         VLC_FOURCC('s','t','r','f')
 #define AVIFOURCC_strd         VLC_FOURCC('s','t','r','d')
+#define AVIFOURCC_strn         VLC_FOURCC('s','t','r','n')
+#define AVIFOURCC_indx         VLC_FOURCC('i','n','d','x')
 
 #define AVIFOURCC_rec          VLC_FOURCC('r','e','c',' ')
 #define AVIFOURCC_auds         VLC_FOURCC('a','u','d','s')
 #define AVIFOURCC_vids         VLC_FOURCC('v','i','d','s')
+#define AVIFOURCC_txts         VLC_FOURCC('t','x','t','s')
+#define AVIFOURCC_mids         VLC_FOURCC('m','i','d','s')
 
 #define AVIFOURCC_IARL         VLC_FOURCC('I','A','R','L')
 #define AVIFOURCC_IART         VLC_FOURCC('I','A','R','T')
 #define AVITWOCC_pc            VLC_TWOCC('p','c')
     /* *** codex stuff ***  */
 
+    /* Microsoft RLE video */
+#define FOURCC_1            VLC_FOURCC( 1,  0,  0,  0 )
+
     /* MPEG4 video */
 #define FOURCC_DIVX         VLC_FOURCC('D','I','V','X')
 #define FOURCC_divx         VLC_FOURCC('d','i','v','x')
 #define FOURCC_XVID         VLC_FOURCC('X','V','I','D')
 #define FOURCC_XviD         VLC_FOURCC('X','v','i','D')
 #define FOURCC_DX50         VLC_FOURCC('D','X','5','0')
+#define FOURCC_dx50         VLC_FOURCC('d','x','5','0')
 #define FOURCC_mp4v         VLC_FOURCC('m','p','4','v')
 #define FOURCC_4            VLC_FOURCC( 4,  0,  0,  0 )
 
     /* AngelPotion stuff */
 #define FOURCC_AP41         VLC_FOURCC('A','P','4','1')
 
-    /* ?? */
+    /* 3IVX */
 #define FOURCC_3IV1         VLC_FOURCC('3','I','V','1')
+#define FOURCC_3iv1         VLC_FOURCC('2','i','v','1')
+#define FOURCC_3IV2         VLC_FOURCC('3','I','V','2')
+#define FOURCC_3iv2         VLC_FOURCC('3','i','v','2')
+#define FOURCC_3IVD         VLC_FOURCC('3','I','V','D')
+#define FOURCC_3ivd         VLC_FOURCC('3','i','v','d')
+#define FOURCC_3VID         VLC_FOURCC('3','V','I','D')
+#define FOURCC_3vid         VLC_FOURCC('3','v','i','d')
+
     /* H263 and H263i */
 #define FOURCC_H263         VLC_FOURCC('H','2','6','3')
 #define FOURCC_h263         VLC_FOURCC('h','2','6','3')
 #define FOURCC_I263         VLC_FOURCC('I','2','6','3')
 #define FOURCC_i263         VLC_FOURCC('i','2','6','3')
 
-/* Sound formats */
-#define WAVE_FORMAT_UNKNOWN         0x0000
-#define WAVE_FORMAT_PCM             0x0001
-#define WAVE_FORMAT_MPEG            0x0050
-#define WAVE_FORMAT_MPEGLAYER3      0x0055
-#define WAVE_FORMAT_A52             0x2000
-#define WAVE_FORMAT_WMA1            0x0160
-#define WAVE_FORMAT_WMA2            0x0161
-
-
-#define AVI_CHUNK_COMMON            \
-    u32     i_chunk_fourcc;         \
-    u64     i_chunk_size;           \
-    u64     i_chunk_pos;            \
-    union  avi_chunk_u *p_next;    \
-    union  avi_chunk_u *p_father;  \
-    union  avi_chunk_u *p_first;   \
-    union  avi_chunk_u *p_last;
-
-#define AVI_CHUNK( p_chk ) (avi_chunk_t*)(p_chk)
-
-typedef struct idx1_entry_s
-{
-    vlc_fourcc_t i_fourcc;
-    u32 i_flags;
-    u32 i_pos;
-    u32 i_length;
-
-} idx1_entry_t;
-typedef struct avi_chunk_common_s
-{
-    AVI_CHUNK_COMMON
-} avi_chunk_common_t;
-
-typedef struct avi_chunk_list_s
-{
-    AVI_CHUNK_COMMON
-    u32 i_type;
-} avi_chunk_list_t;
-
-typedef struct avi_chunk_idx1_s
-{
-    AVI_CHUNK_COMMON
-    int i_entry_count;
-    int i_entry_max;
-    idx1_entry_t *entry;
-
-} avi_chunk_idx1_t;
-
-typedef struct avi_chunk_avih_s
-{
-    AVI_CHUNK_COMMON
-    u32 i_microsecperframe;
-    u32 i_maxbytespersec;
-    u32 i_reserved1; /* dwPaddingGranularity;    pad to multiples of this
-                         size; normally 2K */
-    u32 i_flags;
-    u32 i_totalframes;
-    u32 i_initialframes;
-    u32 i_streams;
-    u32 i_suggestedbuffersize;
-    u32 i_width;
-    u32 i_height;
-    u32 i_scale;
-    u32 i_rate;
-    u32 i_start;
-    u32 i_length;
-} avi_chunk_avih_t;
-
-typedef struct avi_chunk_strh_s
-{
-    AVI_CHUNK_COMMON
-    u32 i_type;
-    u32 i_handler;
-    u32 i_flags;
-    u32 i_reserved1;    /* wPriority wLanguage */
-    u32 i_initialframes;
-    u32 i_scale;
-    u32 i_rate;
-    u32 i_start;
-    u32 i_length;       /* In units above... */
-    u32 i_suggestedbuffersize;
-    u32 i_quality;
-    u32 i_samplesize;
-} avi_chunk_strh_t;
-
-typedef struct avi_chunk_strf_auds_s
-{
-    AVI_CHUNK_COMMON
-    void *p_wfx;    //  waveformatex_t loaded from file
-
-    u16 i_formattag;        // + 0x00
-    u16 i_channels;         // + 0x02
-    u32 i_samplespersec;    // + 0x04
-    u32 i_avgbytespersec;   // + 0x08
-    u16 i_blockalign;       // + 0x0c
-    u16 i_bitspersample;    // + 0x0e
-    u16 i_size; /* the extra size in bytes */
-    u8  *p_data;
-} avi_chunk_strf_auds_t;
-
-typedef struct avi_chunk_strf_vids_s
-{
-    AVI_CHUNK_COMMON
-    BITMAPINFOHEADER *p_bih;
-} avi_chunk_strf_vids_t;
-
-typedef union avi_chunk_strf_u
-{
-    avi_chunk_strf_auds_t   auds;
-    avi_chunk_strf_vids_t   vids;
-} avi_chunk_strf_t;
-
-typedef struct avi_chunk_strd_s
-{
-    AVI_CHUNK_COMMON
-    u8  *p_data;
-} avi_chunk_strd_t;
-
-typedef struct avi_chunk_STRING_s
-{
-    AVI_CHUNK_COMMON
-    char *p_type;
-    char *p_str;
-} avi_chunk_STRING_t;
-
-typedef union avi_chunk_u
-{
-    avi_chunk_common_t  common;
-    avi_chunk_list_t    list;
-    avi_chunk_idx1_t    idx1;
-    avi_chunk_avih_t    avih;
-    avi_chunk_strh_t    strh;
-    avi_chunk_strf_t    strf;
-    avi_chunk_strd_t    strd;
-    avi_chunk_STRING_t  strz;
-} avi_chunk_t;
-
-/****************************************************************************
- * AVI_TestFile : test file header to see if it's an avi file
- ****************************************************************************/
-int     AVI_TestFile( input_thread_t *p_input );
-
-/****************************************************************************
- * Stream(input) acces function
- ****************************************************************************/
-off_t   AVI_TellAbsolute( input_thread_t *p_input );
-int     AVI_SeekAbsolute( input_thread_t *p_input, off_t i_pos);
-int     AVI_ReadData( input_thread_t *p_input, u8 *p_buff, int i_size );
-int     AVI_SkipBytes( input_thread_t *p_input, int i_count );
-
-int     _AVI_ChunkRead( input_thread_t *p_input,
-                        avi_chunk_t *p_chk,
-                        avi_chunk_t *p_father,
-                        int b_seekable );
-void    _AVI_ChunkFree( input_thread_t *p_input,
-                         avi_chunk_t *p_chk );
-int     _AVI_ChunkGoto( input_thread_t *p_input,
-                        avi_chunk_t *p_chk );
-void    _AVI_ChunkDumpDebug( input_thread_t *p_input,
-                             avi_chunk_t  *p_chk );
-
-int     _AVI_ChunkCount( avi_chunk_t *p_chk, u32 i_fourcc );
-avi_chunk_t *_AVI_ChunkFind( avi_chunk_t *p_chk, u32 i_fourcc, int i_number );
-
-int     AVI_ChunkReadRoot( input_thread_t *p_input,
-                           avi_chunk_t *p_root,
-                           int b_seekable );
-void    AVI_ChunkFreeRoot( input_thread_t *p_input,
-                           avi_chunk_t  *p_chk );
-#define AVI_ChunkRead( p_input, p_chk, p_father, b_seekable ) \
-    _AVI_ChunkRead( p_input, \
-                    (avi_chunk_t*)p_chk, \
-                    (avi_chunk_t*)p_father, \
-                    b_seekable )
-#define AVI_ChunkFree( p_input, p_chk ) \
-    _AVI_ChunkFree( p_input, (avi_chunk_t*)p_chk )
-    
-#define AVI_ChunkGoto( p_input, p_chk ) \
-    _AVI_ChunkGoto( p_input, (avi_chunk_t*)p_chk )
-    
-#define AVI_ChunkDumpDebug( p_input, p_chk ) \
-    _AVI_ChunkDumpDebug( p_input, (avi_chunk_t*)p_chk )
-
-
-#define AVI_ChunkCount( p_chk, i_fourcc ) \
-    _AVI_ChunkCount( (avi_chunk_t*)p_chk, i_fourcc )
-#define AVI_ChunkFind( p_chk, i_fourcc, i_number ) \
-    _AVI_ChunkFind( (avi_chunk_t*)p_chk, i_fourcc, i_number )
-
-
-
+    /* H264 */
+#define FOURCC_H264         VLC_FOURCC('H','2','6','4')
+#define FOURCC_h264         VLC_FOURCC('h','2','6','4')
+#define FOURCC_VSSH         VLC_FOURCC('V','S','S','H')