]> git.sesse.net Git - vlc/commitdiff
* all: fix endian issue with new definition of VLC_FOURCC, but
authorLaurent Aimar <fenrir@videolan.org>
Wed, 18 Sep 2002 23:34:28 +0000 (23:34 +0000)
committerLaurent Aimar <fenrir@videolan.org>
Wed, 18 Sep 2002 23:34:28 +0000 (23:34 +0000)
untested. Meuuh, could you test it ?

modules/demux/avi/avi.c
modules/demux/avi/avi.h
modules/demux/avi/libioRIFF.c
modules/demux/avi/libioRIFF.h
modules/demux/mp4/libmp4.c

index c50ad775c8b6af74fdc92a9444a979ecb3378a0f..57734e9566296404d5343553bb709bb2bce51b94 100644 (file)
@@ -2,7 +2,7 @@
  * avi.c : AVI file Stream input module for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: avi.c,v 1.3 2002/08/08 22:28:22 sam Exp $
+ * $Id: avi.c,v 1.4 2002/09/18 23:34:28 fenrir Exp $
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  * 
  * This program is free software; you can redistribute it and/or modify
@@ -59,24 +59,23 @@ vlc_module_end();
  *****************************************************************************/
 static u16 GetWLE( byte_t *p_buff )
 {
-    u16 i;
-    i = (*p_buff) + ( *(p_buff + 1) <<8 );
-    return ( i );
+    return( p_buff[0] + ( p_buff[1] << 8 ) );
 }
 static u32 GetDWLE( byte_t *p_buff )
 {
-    u32 i;
-    i = (*p_buff) + ( *(p_buff + 1) <<8 ) + 
-            ( *(p_buff + 2) <<16 ) + ( *(p_buff + 3) <<24 );
-    return ( i );
+    return( p_buff[0] + ( p_buff[1] << 8 ) + 
+            ( p_buff[2] << 16 ) + ( p_buff[3] << 24 ) );
 }
 static u32 GetDWBE( byte_t *p_buff )
 {
-    u32 i;
-    i = ((*p_buff)<<24) + ( *(p_buff + 1) <<16 ) + 
-            ( *(p_buff + 2) <<8 ) + ( *(p_buff + 3) );
-    return ( i );
+    return( p_buff[3] + ( p_buff[2] << 8 ) + 
+            ( p_buff[1] << 16 ) + ( p_buff[0] << 24 ) );
 }
+static vlc_fourcc_t GetFOURCC( byte_t *p_buff )
+{
+    return( VLC_FOURCC( p_buff[0], p_buff[1], p_buff[2], p_buff[3] ) );
+}
+
 static inline off_t __EVEN( off_t i )
 {
     return( (i & 1) ? i+1 : i );
@@ -105,8 +104,8 @@ static void AVI_Parse_avih( MainAVIHeader_t *p_avih, byte_t *p_buff )
 }
 static void AVI_Parse_Header( AVIStreamHeader_t *p_strh, byte_t *p_buff )
 {
-    p_strh->i_type      = GetDWLE( p_buff );
-    p_strh->i_handler   = GetDWLE( p_buff + 4 );
+    p_strh->i_type      = GetFOURCC( p_buff );
+    p_strh->i_handler   = GetFOURCC( p_buff + 4 );
     p_strh->i_flags     = GetDWLE( p_buff + 8 );
     p_strh->i_reserved1 = GetDWLE( p_buff + 12);
     p_strh->i_initialframes = GetDWLE( p_buff + 16);
@@ -125,7 +124,7 @@ static void AVI_Parse_BitMapInfoHeader( bitmapinfoheader_t *h, byte_t *p_data )
     h->i_height        = GetDWLE( p_data + 8 );
     h->i_planes        = GetWLE( p_data + 12 );
     h->i_bitcount      = GetWLE( p_data + 14 );
-    h->i_compression   = GetDWLE( p_data + 16 );
+    h->i_compression   = GetFOURCC( p_data + 16 );
     h->i_sizeimage     = GetDWLE( p_data + 20 );
     h->i_xpelspermeter = GetDWLE( p_data + 24 );
     h->i_ypelspermeter = GetDWLE( p_data + 28 );
@@ -147,10 +146,10 @@ static inline int AVI_GetESTypeFromTwoCC( u16 i_type )
 {
     switch( i_type )
     {
-        case( TWOCC_wb ):
+        case( AVITWOCC_wb ):
             return( AUDIO_ES );
-         case( TWOCC_dc ):
-         case( TWOCC_db ):
+         case( AVITWOCC_dc ):
+         case( AVITWOCC_db ):
             return( VIDEO_ES );
          default:
             return( UNKNOWN_ES );
@@ -335,7 +334,7 @@ static void AVI_PESBuffer_Flush( input_buffers_t *p_method_data,
 static void AVI_ParseStreamHeader( u32 i_id, int *i_number, int *i_type )
 {
     int c1,c2;
-
+/* XXX i_id have to be read using MKFOURCC and NOT VLC_FOURCC */
     c1 = ( i_id ) & 0xFF;
     c2 = ( i_id >>  8 ) & 0xFF;
 
@@ -435,7 +434,7 @@ static void __AVI_GetIndex( input_thread_t *p_input )
     if( RIFF_FindAndGotoDataChunk( p_input,
                                    p_avi->p_riff, 
                                    &p_idx1, 
-                                   FOURCC_idx1)!=0 )
+                                   AVIFOURCC_idx1)!=0 )
     {
         msg_Warn( p_input, "cannot find index" );
         RIFF_GoToChunk( p_input, p_avi->p_hdrl );        
@@ -582,7 +581,7 @@ static int AVIInit( vlc_object_t * p_this )
         p_input->i_bufsize = INPUT_DEFAULT_BUFSIZE;
     }
 
-    if( RIFF_TestFileHeader( p_input, &p_riff, FOURCC_AVI ) != 0 )    
+    if( RIFF_TestFileHeader( p_input, &p_riff, AVIFOURCC_AVI ) != 0 )    
     {
         AVIEnd( p_input );
         msg_Warn( p_input, "RIFF-AVI module discarded" );
@@ -598,7 +597,7 @@ static int AVIInit( vlc_object_t * p_this )
     }
 
     /* it's a riff-avi file, so search for LIST-hdrl */
-    if( RIFF_FindListChunk(p_input ,&p_hdrl,p_riff, FOURCC_hdrl) != 0 )
+    if( RIFF_FindListChunk(p_input ,&p_hdrl,p_riff, AVIFOURCC_hdrl) != 0 )
     {
         AVIEnd( p_input );
         msg_Err( p_input, "cannot find \"LIST-hdrl\"" );
@@ -614,7 +613,7 @@ static int AVIInit( vlc_object_t * p_this )
     }
     /* in  LIST-hdrl search avih */
     if( RIFF_FindAndLoadChunk( p_input, p_hdrl, 
-                                    &p_avih, FOURCC_avih ) != 0 )
+                                    &p_avih, AVIFOURCC_avih ) != 0 )
     {
         AVIEnd( p_input );
         msg_Err( p_input, "cannot find \"avih\" chunk" );
@@ -667,7 +666,7 @@ static int AVIInit( vlc_object_t * p_this )
         memset( p_info, 0, sizeof( AVIStreamInfo_t ) );        
 
         if( ( RIFF_FindListChunk(p_input,
-                                &p_strl,p_hdrl, FOURCC_strl) != 0 )
+                                &p_strl,p_hdrl, AVIFOURCC_strl) != 0 )
                 ||( RIFF_DescendChunk(p_input) != 0 ))
         {
             AVIEnd( p_input );
@@ -677,7 +676,7 @@ static int AVIInit( vlc_object_t * p_this )
         
         /* in  LIST-strl search strh */
         if( RIFF_FindAndLoadChunk( p_input, p_hdrl, 
-                                &p_strh, FOURCC_strh ) != 0 )
+                                &p_strh, AVIFOURCC_strh ) != 0 )
         {
             RIFF_DeleteChunk( p_input, p_strl );
             AVIEnd( p_input );
@@ -690,7 +689,7 @@ static int AVIInit( vlc_object_t * p_this )
 
         /* in  LIST-strl search strf */
         if( RIFF_FindAndLoadChunk( p_input, p_hdrl, 
-                                &p_strf, FOURCC_strf ) != 0 )
+                                &p_strf, AVIFOURCC_strf ) != 0 )
         {
             RIFF_DeleteChunk( p_input, p_strl );
             AVIEnd( p_input );
@@ -717,7 +716,7 @@ static int AVIInit( vlc_object_t * p_this )
        
         switch( p_info->header.i_type )
         {
-            case( FOURCC_auds ):
+            case( AVIFOURCC_auds ):
                 p_es->i_cat = AUDIO_ES;
                 AVI_Parse_WaveFormatEx( &p_info->audio_format,
                                    p_strf->p_data->p_payload_start ); 
@@ -725,7 +724,7 @@ static int AVIInit( vlc_object_t * p_this )
                                      p_info->audio_format.i_formattag );
                 break;
                 
-            case( FOURCC_vids ):
+            case( AVIFOURCC_vids ):
                 p_es->i_cat = VIDEO_ES;
                 AVI_Parse_BitMapInfoHeader( &p_info->video_format,
                                    p_strf->p_data->p_payload_start ); 
@@ -762,7 +761,7 @@ static int AVIInit( vlc_object_t * p_this )
     }
 
     /* go to movi chunk to get it*/
-    if( RIFF_FindListChunk(p_input ,&p_movi,p_riff, FOURCC_movi) != 0 )
+    if( RIFF_FindListChunk(p_input ,&p_movi,p_riff, AVIFOURCC_movi) != 0 )
     {
         msg_Err( p_input, "cannot find \"LIST-movi\"" );
         AVIEnd( p_input );
@@ -1275,7 +1274,7 @@ static int __AVI_GetChunk( input_thread_t  *p_input,
         }
 /*        msg_Dbg( p_input, "ck: %4.4s len %d", &p_ck->i_id, p_ck->i_size ); */
         /* special case for LIST-rec chunk */
-        if( ( p_ck->i_id == FOURCC_LIST )&&( p_ck->i_type == FOURCC_rec ) )
+        if( ( p_ck->i_id == AVIFOURCC_LIST )&&( p_ck->i_type == AVIFOURCC_rec ) )
         {
             RIFF_DescendChunk( p_input );
             RIFF_DeleteChunk( p_input, p_ck );
@@ -1879,12 +1878,12 @@ static int __AVIDemux_ChunkAction( int i_streams_max,
 
     switch( p_ck->i_id )
     {
-        case( FOURCC_JUNK ):
+        case( AVIFOURCC_JUNK ):
             return( 1 );
-        case( FOURCC_idx1 ):
+        case( AVIFOURCC_idx1 ):
             return( 3 );
-        case( FOURCC_LIST ):
-            if( p_ck->i_type == FOURCC_rec )
+        case( AVIFOURCC_LIST ):
+            if( p_ck->i_type == AVIFOURCC_rec )
             {
                 return( 2 );
             }
@@ -1897,7 +1896,7 @@ static int __AVIDemux_ChunkAction( int i_streams_max,
     } 
     /* test for ix?? */
 
-    if( ( p_ck->i_id & 0xFFFF ) == VLC_TWOCC( 'i','x' ) )
+    if( ( p_ck->i_id & 0xFFFF ) == MKTWOCC( 'i','x' ) )
     {
         return( 1 );
     }
@@ -1921,9 +1920,9 @@ static int AVI_NotSeekableRecover( input_thread_t *p_input )
         i_id = GetDWLE( p_id );
         switch( i_id )
         {
-            case( FOURCC_idx1 ):
-            case( FOURCC_JUNK ):
-            case( FOURCC_LIST ):
+            case( AVIFOURCC_idx1 ):
+            case( AVIFOURCC_JUNK ):
+            case( AVIFOURCC_LIST ):
                 return( 1 );
             default:
                 AVI_ParseStreamHeader( i_id, &i_number, &i_type );
@@ -1931,10 +1930,10 @@ static int AVI_NotSeekableRecover( input_thread_t *p_input )
                 {
                     switch( i_type )
                     {
-                        case( TWOCC_wb ):
-                        case( TWOCC_db ):
-                        case( TWOCC_dc ):
-                        case( TWOCC_pc ):
+                        case( AVITWOCC_wb ):
+                        case( AVITWOCC_db ):
+                        case( AVITWOCC_dc ):
+                        case( AVITWOCC_pc ):
                             return( 1 );
                     }
                 }
index 376e6909c2d75d5f4d13bc47a234cf273e4ad024..564cfb17484c986a0e20d7b59402b4d5020a12cb 100644 (file)
@@ -2,7 +2,7 @@
  * avi.h : AVI file Stream input module for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: avi.h,v 1.2 2002/08/07 00:29:36 sam Exp $
+ * $Id: avi.h,v 1.3 2002/09/18 23:34:28 fenrir Exp $
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  * 
  * This program is free software; you can redistribute it and/or modify
                                            the keyframe flag isn't a true flag
                                            but have to be verified */
 
-/* AVI stuff */
-#define FOURCC_RIFF         VLC_FOURCC('R','I','F','F')
-#define FOURCC_LIST         VLC_FOURCC('L','I','S','T')
-#define FOURCC_JUNK         VLC_FOURCC('J','U','N','K')
-#define FOURCC_AVI          VLC_FOURCC('A','V','I',' ')
-#define FOURCC_WAVE         VLC_FOURCC('W','A','V','E')
+#define MKTWOCC( a, b ) \
+    ( (u16)(a) | ( (u16)(b) << 8 ) )
 
-#define FOURCC_avih         VLC_FOURCC('a','v','i','h')
-#define FOURCC_hdrl         VLC_FOURCC('h','d','r','l')
-#define FOURCC_movi         VLC_FOURCC('m','o','v','i')
-#define FOURCC_idx1         VLC_FOURCC('i','d','x','1')
+/* *** avi stuff *** */
 
-#define FOURCC_strl         VLC_FOURCC('s','t','r','l')
-#define FOURCC_strh         VLC_FOURCC('s','t','r','h')
-#define FOURCC_strf         VLC_FOURCC('s','t','r','f')
-#define FOURCC_strd         VLC_FOURCC('s','t','r','d')
+#define AVIFOURCC_RIFF         MKFOURCC('R','I','F','F')
+#define AVIFOURCC_LIST         MKFOURCC('L','I','S','T')
+#define AVIFOURCC_JUNK         MKFOURCC('J','U','N','K')
+#define AVIFOURCC_AVI          MKFOURCC('A','V','I',' ')
+#define AVIFOURCC_WAVE         MKFOURCC('W','A','V','E')
 
-#define FOURCC_rec          VLC_FOURCC('r','e','c',' ')
-#define FOURCC_auds         VLC_FOURCC('a','u','d','s')
-#define FOURCC_vids         VLC_FOURCC('v','i','d','s')
+#define AVIFOURCC_avih         MKFOURCC('a','v','i','h')
+#define AVIFOURCC_hdrl         MKFOURCC('h','d','r','l')
+#define AVIFOURCC_movi         MKFOURCC('m','o','v','i')
+#define AVIFOURCC_idx1         MKFOURCC('i','d','x','1')
 
-#define TWOCC_wb            VLC_TWOCC('w','b')
-#define TWOCC_db            VLC_TWOCC('d','b')
-#define TWOCC_dc            VLC_TWOCC('d','c')
-#define TWOCC_pc            VLC_TWOCC('p','c')
+#define AVIFOURCC_strl         MKFOURCC('s','t','r','l')
+#define AVIFOURCC_strh         MKFOURCC('s','t','r','h')
+#define AVIFOURCC_strf         MKFOURCC('s','t','r','f')
+#define AVIFOURCC_strd         MKFOURCC('s','t','r','d')
+
+#define AVIFOURCC_rec          MKFOURCC('r','e','c',' ')
+#define AVIFOURCC_auds         MKFOURCC('a','u','d','s')
+#define AVIFOURCC_vids         MKFOURCC('v','i','d','s')
+
+#define AVITWOCC_wb            MKTWOCC('w','b')
+#define AVITWOCC_db            MKTWOCC('d','b')
+#define AVITWOCC_dc            MKTWOCC('d','c')
+#define AVITWOCC_pc            MKTWOCC('p','c')
+/* *** codex stuff ***  */
 
 /* MPEG4 video */
 #define FOURCC_DIVX         VLC_FOURCC('D','I','V','X')
@@ -142,12 +147,12 @@ typedef struct bitmapinfoheader_s
 
 typedef struct waveformatex_s
 {
-    u16 i_formattag;
-    u16 i_channels;
-    u32 i_samplespersec;
-    u32 i_avgbytespersec;
-    u16 i_blockalign;
-    u16 i_bitspersample;
+    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 */
 } waveformatex_t;
 
@@ -210,15 +215,12 @@ typedef struct AVIESBuffer_s
 
 typedef struct AVIStreamInfo_s
 {
+    int i_cat;           /* AUDIO_ES, VIDEO_ES */
+    vlc_fourcc_t    i_fourcc;
+    vlc_fourcc_t    i_codec;
 
-    riffchunk_t *p_strl;
-    riffchunk_t *p_strh;
-    riffchunk_t *p_strf;
-    riffchunk_t *p_strd; /* not used */
-    
     AVIStreamHeader_t header;
     
-    u8 i_cat;           /* AUDIO_ES, VIDEO_ES */
     bitmapinfoheader_t  video_format;
     waveformatex_t      audio_format;
     es_descriptor_t     *p_es;   
index bc23680c783b951f1a543e4a1ed81f95320aabc6..d41ec3981b47d2a1d0c7712e823e5b2e0aa76b00 100644 (file)
@@ -2,7 +2,7 @@
  * libioRIFF.c : AVI file Stream input module for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: libioRIFF.c,v 1.1 2002/08/04 17:23:42 sam Exp $
+ * $Id: libioRIFF.c,v 1.2 2002/09/18 23:34:28 fenrir Exp $
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  * 
  * This program is free software; you can redistribute it and/or modify
@@ -31,7 +31,6 @@
 #include "video.h"
 
 #include "libioRIFF.h"
-
 static inline u16 __GetWLE( byte_t *p_buff )
 {
     return( (*p_buff) + ( *(p_buff+1) <<8 ) );
@@ -47,7 +46,7 @@ static inline u32 __EVEN( u32 i )
 {
     return( (i & 1) ? ++i : i );
 }
-        
+
 int __RIFF_TellPos( input_thread_t *p_input, u32 *pos )
 { 
     vlc_mutex_lock( &p_input->stream.stream_lock );
@@ -355,7 +354,7 @@ int   RIFF_TestFileHeader( input_thread_t * p_input, riffchunk_t ** pp_riff, u32
     {
         return( -1 );
     }
-    if( (*pp_riff)->i_id != VLC_FOURCC('R','I','F','F')
+    if( (*pp_riff)->i_id != MKFOURCC('R','I','F','F')
          || (*pp_riff)->i_type != i_type )
     {
         free( *pp_riff );
@@ -416,7 +415,7 @@ int   RIFF_FindListChunk( input_thread_t *p_input, riffchunk_t **pp_riff, riffch
             free( *pp_riff );
         }
         if( RIFF_FindChunk( p_input,
-                            VLC_FOURCC('L','I','S','T'), p_rifffather ) != 0 )
+                            MKFOURCC('L','I','S','T'), p_rifffather ) != 0 )
         {
             return( -1 );
         }
index 6f096679be71a9b36a87c765dc121f7c434986b8..b2de064017a6b1be0ee1c838418188403a47e8a2 100644 (file)
@@ -2,7 +2,7 @@
  * libioRIFF.h : AVI file Stream input module for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: libioRIFF.h,v 1.1 2002/08/04 17:23:42 sam Exp $
+ * $Id: libioRIFF.h,v 1.2 2002/09/18 23:34:28 fenrir Exp $
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  * 
  * This program is free software; you can redistribute it and/or modify
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
-
+#define MKFOURCC( a, b, c, d ) \
+    ( ((u32)a) | ( ((u32)b) << 8 ) | ( ((u32)c) << 16 ) | ( ((u32)d) << 24 ) )
 typedef struct riffchunk_s
 {
-    u32 i_id;
+    vlc_fourcc_t i_id;
     u32 i_size;
-    u32 i_type;
+    vlc_fourcc_t i_type;
     u32 i_pos;
     data_packet_t *p_data;
     u64 i_8bytes; /* it's the first 8 bytes after header 
index 0f77df7d3569b6b10671335bf1c938b6347241c0..68ab9ff80bed18e5658a189c5b9de7fa61c8e7e9 100644 (file)
@@ -2,7 +2,7 @@
  * libmp4.c : LibMP4 library for mp4 module for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: libmp4.c,v 1.5 2002/09/17 11:57:38 fenrir Exp $
+ * $Id: libmp4.c,v 1.6 2002/09/18 23:34:28 fenrir Exp $
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  * 
  * This program is free software; you can redistribute it and/or modify
@@ -61,7 +61,8 @@
     dst = GetDWBE( p_peek ); p_peek += 4; i_read -= 4
     
 #define MP4_GETFOURCC( dst ) \
-    dst = GetDWLE( p_peek ); p_peek += 4; i_read -= 4
+    dst = VLC_FOURCC( p_peek[0], p_peek[1], p_peek[2], p_peek[3] ); \
+    p_peek += 4; i_read -= 4
 
 #define MP4_GET8BYTES( dst ) \
     dst = GetQWBE( p_peek ); p_peek += 8; i_read -= 8