* avi: use stream_*, some clean and reordering.
[vlc.git] / modules / demux / avi / libavi.h
index f6d3f60..efdc3ee 100644 (file)
@@ -1,15 +1,15 @@
 /*****************************************************************************
- * libavi.h : LibAVI library 
+ * libavi.h : LibAVI library
  ******************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: libavi.h,v 1.10 2003/04/27 13:55:51 fenrir Exp $
+ * $Id: libavi.h,v 1.11 2003/08/22 20:31:47 fenrir Exp $
  * 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
@@ -19,9 +19,6 @@
  * along with this program; if not, write to the Free Software
  * 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
                                            the keyframe flag isn't a true flag
                                            but have to be verified */
 
-    /* *** avi stuff *** */
-
-#define AVIFOURCC_RIFF         VLC_FOURCC('R','I','F','F')
-#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_avih         VLC_FOURCC('a','v','i','h')
-#define AVIFOURCC_hdrl         VLC_FOURCC('h','d','r','l')
-#define AVIFOURCC_movi         VLC_FOURCC('m','o','v','i')
-#define AVIFOURCC_idx1         VLC_FOURCC('i','d','x','1')
-
-#define AVIFOURCC_strl         VLC_FOURCC('s','t','r','l')
-#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_IARL         VLC_FOURCC('I','A','R','L')
-#define AVIFOURCC_IART         VLC_FOURCC('I','A','R','T')
-#define AVIFOURCC_ICMS         VLC_FOURCC('I','C','M','S')
-#define AVIFOURCC_ICMT         VLC_FOURCC('I','C','M','T')
-#define AVIFOURCC_ICOP         VLC_FOURCC('I','C','O','P')
-#define AVIFOURCC_ICRD         VLC_FOURCC('I','C','R','D')
-#define AVIFOURCC_ICRP         VLC_FOURCC('I','C','R','P')
-#define AVIFOURCC_IDIM         VLC_FOURCC('I','D','I','M')
-#define AVIFOURCC_IDPI         VLC_FOURCC('I','D','P','I')
-#define AVIFOURCC_IENG         VLC_FOURCC('I','E','N','G')
-#define AVIFOURCC_IGNR         VLC_FOURCC('I','G','N','R')
-#define AVIFOURCC_IKEY         VLC_FOURCC('I','K','E','Y')
-#define AVIFOURCC_ILGT         VLC_FOURCC('I','L','G','T')
-#define AVIFOURCC_IMED         VLC_FOURCC('I','M','E','D')
-#define AVIFOURCC_INAM         VLC_FOURCC('I','N','A','M')
-#define AVIFOURCC_IPLT         VLC_FOURCC('I','P','L','T')
-#define AVIFOURCC_IPRD         VLC_FOURCC('I','P','R','D')
-#define AVIFOURCC_ISBJ         VLC_FOURCC('I','S','B','J')
-#define AVIFOURCC_ISFT         VLC_FOURCC('I','S','F','T')
-#define AVIFOURCC_ISHP         VLC_FOURCC('I','S','H','P')
-#define AVIFOURCC_ISRC         VLC_FOURCC('I','S','R','C')
-#define AVIFOURCC_ISRF         VLC_FOURCC('I','S','R','F')
-#define AVIFOURCC_ITCH         VLC_FOURCC('I','T','C','H')
-#define AVIFOURCC_ISMP         VLC_FOURCC('I','S','M','P')
-#define AVIFOURCC_IDIT         VLC_FOURCC('I','D','I','T')
-
-    
-#define AVITWOCC_wb            VLC_TWOCC('w','b')
-#define AVITWOCC_db            VLC_TWOCC('d','b')
-#define AVITWOCC_dc            VLC_TWOCC('d','c')
-#define AVITWOCC_pc            VLC_TWOCC('p','c')
-    /* *** codex stuff ***  */
-
-    /* MPEG4 video */
-#define FOURCC_DIVX         VLC_FOURCC('D','I','V','X')
-#define FOURCC_divx         VLC_FOURCC('d','i','v','x')
-#define FOURCC_DIV1         VLC_FOURCC('D','I','V','1')
-#define FOURCC_div1         VLC_FOURCC('d','i','v','1')
-#define FOURCC_MP4S         VLC_FOURCC('M','P','4','S')
-#define FOURCC_mp4s         VLC_FOURCC('m','p','4','s')
-#define FOURCC_M4S2         VLC_FOURCC('M','4','S','2')
-#define FOURCC_m4s2         VLC_FOURCC('m','4','s','2')
-#define FOURCC_xvid         VLC_FOURCC('x','v','i','d')
-#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_mp4v         VLC_FOURCC('m','p','4','v')
-#define FOURCC_4            VLC_FOURCC( 4,  0,  0,  0 )
-
-    /* MSMPEG4 v2 */
-#define FOURCC_MPG4         VLC_FOURCC('M','P','G','4')
-#define FOURCC_mpg4         VLC_FOURCC('m','p','g','4')
-#define FOURCC_DIV2         VLC_FOURCC('D','I','V','2')
-#define FOURCC_div2         VLC_FOURCC('d','i','v','2')
-#define FOURCC_MP42         VLC_FOURCC('M','P','4','2')
-#define FOURCC_mp42         VLC_FOURCC('m','p','4','2')
-
-    /* MSMPEG4 v3 / M$ mpeg4 v3 */
-#define FOURCC_MPG3         VLC_FOURCC('M','P','G','3')
-#define FOURCC_mpg3         VLC_FOURCC('m','p','g','3')
-#define FOURCC_div3         VLC_FOURCC('d','i','v','3')
-#define FOURCC_MP43         VLC_FOURCC('M','P','4','3')
-#define FOURCC_mp43         VLC_FOURCC('m','p','4','3')
-
-    /* DivX 3.20 */
-#define FOURCC_DIV3         VLC_FOURCC('D','I','V','3')
-#define FOURCC_DIV4         VLC_FOURCC('D','I','V','4')
-#define FOURCC_div4         VLC_FOURCC('d','i','v','4')
-#define FOURCC_DIV5         VLC_FOURCC('D','I','V','5')
-#define FOURCC_div5         VLC_FOURCC('d','i','v','5')
-#define FOURCC_DIV6         VLC_FOURCC('D','I','V','6')
-#define FOURCC_div6         VLC_FOURCC('d','i','v','6')
-
-    /* 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_U263         VLC_FOURCC('U','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            \
     vlc_fourcc_t i_chunk_fourcc;    \
     uint64_t i_chunk_size;          \
@@ -341,52 +209,23 @@ typedef union avi_chunk_u
     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) access functions
  ****************************************************************************/
-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, uint8_t *p_buff, int i_size );
-int     AVI_SkipBytes( input_thread_t *p_input, int64_t i_count );
-
-int     _AVI_ChunkRead( input_thread_t *p_input,
+int     _AVI_ChunkRead( stream_t *,
                         avi_chunk_t *p_chk,
-                        avi_chunk_t *p_father,
-                        vlc_bool_t 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 );
+                        avi_chunk_t *p_father );
 
 int     _AVI_ChunkCount( avi_chunk_t *, vlc_fourcc_t );
-avi_chunk_t *_AVI_ChunkFind( avi_chunk_t *, vlc_fourcc_t, int );
-
-int     AVI_ChunkReadRoot( input_thread_t *p_input,
-                           avi_chunk_t *p_root,
-                           vlc_bool_t 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 )
+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, \
+                    (avi_chunk_t*)p_chk, \
+                    (avi_chunk_t*)p_father )
 
 #define AVI_ChunkCount( p_chk, i_fourcc ) \
     _AVI_ChunkCount( (avi_chunk_t*)p_chk, i_fourcc )
@@ -394,4 +233,123 @@ void    AVI_ChunkFreeRoot( input_thread_t *p_input,
     _AVI_ChunkFind( (avi_chunk_t*)p_chk, i_fourcc, i_number )
 
 
+    /* *** avi stuff *** */
+
+#define AVIFOURCC_RIFF         VLC_FOURCC('R','I','F','F')
+#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_avih         VLC_FOURCC('a','v','i','h')
+#define AVIFOURCC_hdrl         VLC_FOURCC('h','d','r','l')
+#define AVIFOURCC_movi         VLC_FOURCC('m','o','v','i')
+#define AVIFOURCC_idx1         VLC_FOURCC('i','d','x','1')
+
+#define AVIFOURCC_strl         VLC_FOURCC('s','t','r','l')
+#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_IARL         VLC_FOURCC('I','A','R','L')
+#define AVIFOURCC_IART         VLC_FOURCC('I','A','R','T')
+#define AVIFOURCC_ICMS         VLC_FOURCC('I','C','M','S')
+#define AVIFOURCC_ICMT         VLC_FOURCC('I','C','M','T')
+#define AVIFOURCC_ICOP         VLC_FOURCC('I','C','O','P')
+#define AVIFOURCC_ICRD         VLC_FOURCC('I','C','R','D')
+#define AVIFOURCC_ICRP         VLC_FOURCC('I','C','R','P')
+#define AVIFOURCC_IDIM         VLC_FOURCC('I','D','I','M')
+#define AVIFOURCC_IDPI         VLC_FOURCC('I','D','P','I')
+#define AVIFOURCC_IENG         VLC_FOURCC('I','E','N','G')
+#define AVIFOURCC_IGNR         VLC_FOURCC('I','G','N','R')
+#define AVIFOURCC_IKEY         VLC_FOURCC('I','K','E','Y')
+#define AVIFOURCC_ILGT         VLC_FOURCC('I','L','G','T')
+#define AVIFOURCC_IMED         VLC_FOURCC('I','M','E','D')
+#define AVIFOURCC_INAM         VLC_FOURCC('I','N','A','M')
+#define AVIFOURCC_IPLT         VLC_FOURCC('I','P','L','T')
+#define AVIFOURCC_IPRD         VLC_FOURCC('I','P','R','D')
+#define AVIFOURCC_ISBJ         VLC_FOURCC('I','S','B','J')
+#define AVIFOURCC_ISFT         VLC_FOURCC('I','S','F','T')
+#define AVIFOURCC_ISHP         VLC_FOURCC('I','S','H','P')
+#define AVIFOURCC_ISRC         VLC_FOURCC('I','S','R','C')
+#define AVIFOURCC_ISRF         VLC_FOURCC('I','S','R','F')
+#define AVIFOURCC_ITCH         VLC_FOURCC('I','T','C','H')
+#define AVIFOURCC_ISMP         VLC_FOURCC('I','S','M','P')
+#define AVIFOURCC_IDIT         VLC_FOURCC('I','D','I','T')
+
+    
+#define AVITWOCC_wb            VLC_TWOCC('w','b')
+#define AVITWOCC_db            VLC_TWOCC('d','b')
+#define AVITWOCC_dc            VLC_TWOCC('d','c')
+#define AVITWOCC_pc            VLC_TWOCC('p','c')
+    /* *** codex stuff ***  */
+
+    /* MPEG4 video */
+#define FOURCC_DIVX         VLC_FOURCC('D','I','V','X')
+#define FOURCC_divx         VLC_FOURCC('d','i','v','x')
+#define FOURCC_DIV1         VLC_FOURCC('D','I','V','1')
+#define FOURCC_div1         VLC_FOURCC('d','i','v','1')
+#define FOURCC_MP4S         VLC_FOURCC('M','P','4','S')
+#define FOURCC_mp4s         VLC_FOURCC('m','p','4','s')
+#define FOURCC_M4S2         VLC_FOURCC('M','4','S','2')
+#define FOURCC_m4s2         VLC_FOURCC('m','4','s','2')
+#define FOURCC_xvid         VLC_FOURCC('x','v','i','d')
+#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_mp4v         VLC_FOURCC('m','p','4','v')
+#define FOURCC_4            VLC_FOURCC( 4,  0,  0,  0 )
+
+    /* MSMPEG4 v2 */
+#define FOURCC_MPG4         VLC_FOURCC('M','P','G','4')
+#define FOURCC_mpg4         VLC_FOURCC('m','p','g','4')
+#define FOURCC_DIV2         VLC_FOURCC('D','I','V','2')
+#define FOURCC_div2         VLC_FOURCC('d','i','v','2')
+#define FOURCC_MP42         VLC_FOURCC('M','P','4','2')
+#define FOURCC_mp42         VLC_FOURCC('m','p','4','2')
+
+    /* MSMPEG4 v3 / M$ mpeg4 v3 */
+#define FOURCC_MPG3         VLC_FOURCC('M','P','G','3')
+#define FOURCC_mpg3         VLC_FOURCC('m','p','g','3')
+#define FOURCC_div3         VLC_FOURCC('d','i','v','3')
+#define FOURCC_MP43         VLC_FOURCC('M','P','4','3')
+#define FOURCC_mp43         VLC_FOURCC('m','p','4','3')
+
+    /* DivX 3.20 */
+#define FOURCC_DIV3         VLC_FOURCC('D','I','V','3')
+#define FOURCC_DIV4         VLC_FOURCC('D','I','V','4')
+#define FOURCC_div4         VLC_FOURCC('d','i','v','4')
+#define FOURCC_DIV5         VLC_FOURCC('D','I','V','5')
+#define FOURCC_div5         VLC_FOURCC('d','i','v','5')
+#define FOURCC_DIV6         VLC_FOURCC('D','I','V','6')
+#define FOURCC_div6         VLC_FOURCC('d','i','v','6')
+
+    /* 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_U263         VLC_FOURCC('U','2','6','3')
+#define FOURCC_I263         VLC_FOURCC('I','2','6','3')
+#define FOURCC_i263         VLC_FOURCC('i','2','6','3')
+