]> git.sesse.net Git - vlc/commitdiff
* mp4 : use same endian for fourcc than one used in vlc (video.h if I'm
authorLaurent Aimar <fenrir@videolan.org>
Sun, 21 Jul 2002 18:47:22 +0000 (18:47 +0000)
committerLaurent Aimar <fenrir@videolan.org>
Sun, 21 Jul 2002 18:47:22 +0000 (18:47 +0000)
right).
 * cinepak : take care of grayscale option.

plugins/cinepak/cinepak.c
plugins/cinepak/cinepak.h
plugins/mp4/libmp4.c
plugins/mp4/libmp4.h
plugins/mp4/mp4.c
plugins/mp4/mp4.h

index e9f5d06f8d72192150fdc8f729df601dd5d8b2ea..86ef91430ad2fd62135b33860be247a3137d5ab4 100644 (file)
@@ -2,7 +2,7 @@
  * cinepak.c: cinepak video decoder 
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: cinepak.c,v 1.1 2002/07/21 15:11:55 fenrir Exp $
+ * $Id: cinepak.c,v 1.2 2002/07/21 18:47:22 fenrir Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -342,7 +342,7 @@ static vout_thread_t *cinepak_CreateVout( videodec_thread_t *p_vdec,
 
 void cinepak_LoadCodebook( cinepak_codebook_t *p_codebook,
                            u8 *p_data,
-                           int b_12bits )
+                           int b_grayscale )
 {
     int i, i_y[4], i_u, i_v, i_Cb, i_Cr;
     int i_uv;
@@ -353,7 +353,7 @@ void cinepak_LoadCodebook( cinepak_codebook_t *p_codebook,
     {
         i_y[i] = (u8)( *(p_data++) );
     }
-    if( b_12bits )
+    if( b_grayscale )
     {
         i_u  = (s8)( *(p_data++) );
         i_v  = (s8)( *(p_data++) );
@@ -632,7 +632,8 @@ int cinepak_decode_frame( cinepak_context_t *p_context,
                     for( i = 0; i < i_count; i++ )
                     {
                         cinepak_LoadCodebook( &((*p_codebook)[i_strip][i]), 
-                                              p_data, i_mode );
+                                              p_data, 
+                                       i_mode&~p_context->b_grayscale );
                         p_data += i_mode ? 6 : 4;
                         i_chunk_size -= i_mode ? 6 : 4;
                     }
@@ -661,7 +662,9 @@ int cinepak_decode_frame( cinepak_context_t *p_context,
                             if( i_vector_flags&0x80000000UL )
                             {
                                 cinepak_LoadCodebook( &((*p_codebook)[i_strip][i_index]),
-                                                      p_data, i_mode );
+                                                      p_data, 
+                                            i_mode&~p_context->b_grayscale );
+
                                 p_data += i_mode ? 6 : 4;
                                 i_chunk_size -= i_mode ? 6 : 4;
                             }
@@ -843,6 +846,15 @@ static int InitThread( videodec_thread_t *p_vdec )
     }
     memset( p_vdec->p_context, 0, sizeof( cinepak_context_t ) );
 
+    if( config_GetInt( p_vdec->p_fifo, "grayscale" ) )
+    {
+        p_vdec->p_context->b_grayscale = 1;
+    }
+    else
+    {
+        p_vdec->p_context->b_grayscale = 0;
+    }
+    
     p_vdec->p_vout = NULL;
     msg_Dbg( p_vdec->p_fifo, "cinepak decoder started" );
     return( 0 );
index ce7de57f5460a672d1412adc0f7da66b264f4c3f..4ca809e48df98b12e1922d9eb9f75cc4f642e5e4 100644 (file)
@@ -2,7 +2,7 @@
  * cinepak.h: Cinepak video decoder
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: cinepak.h,v 1.1 2002/07/21 15:11:55 fenrir Exp $
+ * $Id: cinepak.h,v 1.2 2002/07/21 18:47:22 fenrir Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  * 
@@ -33,6 +33,8 @@ typedef struct cinepak_codebook_s
 
 typedef struct cinepak_context_s
 {
+    int b_grayscale; /* force to grayscale */
+    
     int i_width;
     int i_height;
 
index 4f347fcf7155de67b8df1926efbdc99707ef54c3..372ca64e59ddabdb8dd34d8c282cc707930b42c5 100644 (file)
@@ -2,7 +2,7 @@
  * libmp4.c : LibMP4 library for mp4 module for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: libmp4.c,v 1.2 2002/07/21 15:13:19 fenrir Exp $
+ * $Id: libmp4.c,v 1.3 2002/07/21 18:47:22 fenrir Exp $
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  * 
  * This program is free software; you can redistribute it and/or modify
@@ -55,6 +55,9 @@
 
 #define MP4_GET4BYTES( dst ) \
     dst = GetDWBE( p_peek ); p_peek += 4; i_read -= 4
+    
+#define MP4_GETFOURCC( dst ) \
+    dst = GetDWLE( p_peek ); p_peek += 4; i_read -= 4
 
 #define MP4_GET8BYTES( dst ) \
     dst = GetQWBE( p_peek ); p_peek += 8; i_read -= 8
@@ -435,7 +438,7 @@ int MP4_ReadBoxCommon( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     p_box->p_next   = NULL;
     
     MP4_GET4BYTES( p_box->i_shortsize );
-    MP4_GET4BYTES( p_box->i_type );
+    MP4_GETFOURCC( p_box->i_type );
 
     /* Now special case */
 
@@ -465,8 +468,8 @@ int MP4_ReadBoxCommon( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     if( p_box->i_size )
     {
         msg_Dbg( p_stream->p_input, "Found Box: %c%c%c%c size %d",
-                 (p_box->i_type>>24)&0xff, (p_box->i_type>>16)&0xff, 
-                     (p_box->i_type>>8)&0xff, (p_box->i_type)&0xff,
+                 (p_box->i_type)&0xff, (p_box->i_type>>8)&0xff, 
+                     (p_box->i_type>>16)&0xff, (p_box->i_type>>24)&0xff,
                  (u32)p_box->i_size );
     }
 #endif
@@ -589,10 +592,10 @@ int MP4_ReadBoxSkip( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     /* Nothing to do */
 #ifdef MP4_VERBOSE
     msg_Dbg( p_stream->p_input, "Skip box: \"%c%c%c%c\"", 
-            (p_box->i_type>>24)&0xff, 
-            (p_box->i_type>>16)&0xff,
-            (p_box->i_type>>8)&0xff, 
-            (p_box->i_type)&0xff );
+            (p_box->i_type)&0xff, 
+            (p_box->i_type>>8)&0xff,
+            (p_box->i_type>>16)&0xff, 
+            (p_box->i_type>>24)&0xff );
 #endif
     return( 1 );
 }
@@ -601,7 +604,7 @@ int MP4_ReadBox_ftyp( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     MP4_READBOX_ENTER( MP4_Box_data_ftyp_t );
     
-    MP4_GET4BYTES( p_box->data.p_ftyp->i_major_brand );
+    MP4_GETFOURCC( p_box->data.p_ftyp->i_major_brand );
     MP4_GET4BYTES( p_box->data.p_ftyp->i_minor_version );
     
     if( ( p_box->data.p_ftyp->i_compatible_brands_count = i_read / 4 ) )
@@ -612,7 +615,7 @@ int MP4_ReadBox_ftyp( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 
         for( i =0; i < p_box->data.p_ftyp->i_compatible_brands_count; i++ )
         {
-            MP4_GET4BYTES( p_box->data.p_ftyp->i_compatible_brands[i] );
+            MP4_GETFOURCC( p_box->data.p_ftyp->i_compatible_brands[i] );
         }
     }
     else
@@ -849,17 +852,17 @@ int MP4_ReadBox_hdlr( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     MP4_GETVERSIONFLAGS( p_box->data.p_hdlr );
  
     MP4_GET4BYTES( p_box->data.p_hdlr->i_predefined );
-    MP4_GET4BYTES( p_box->data.p_hdlr->i_handler_type );
+    MP4_GETFOURCC( p_box->data.p_hdlr->i_handler_type );
 
     p_box->data.p_hdlr->psz_name = calloc( sizeof( char ), i_read + 1 );
     memcpy( p_box->data.p_hdlr->psz_name, p_peek, i_read );
 
 #ifdef MP4_VERBOSE
     msg_Dbg( p_stream->p_input, "Read Box: \"hdlr\" hanler type %c%c%c%c name %s",
-                       ( p_box->data.p_hdlr->i_handler_type >> 24 )&0xff,
-                       ( p_box->data.p_hdlr->i_handler_type >> 16 )&0xff,
-                       ( p_box->data.p_hdlr->i_handler_type >>  8 )&0xff,
                        ( p_box->data.p_hdlr->i_handler_type )&0xff,
+                       ( p_box->data.p_hdlr->i_handler_type >>  8 )&0xff,
+                       ( p_box->data.p_hdlr->i_handler_type >> 16 )&0xff,
+                       ( p_box->data.p_hdlr->i_handler_type >> 24 )&0xff,
                        p_box->data.p_hdlr->psz_name );
 
 #endif
@@ -1291,7 +1294,9 @@ int MP4_ReadBox_sample_vide( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     MP4_GET2BYTES( p_box->data.p_sample_vide->i_depth );
     MP4_GET2BYTES( p_box->data.p_sample_vide->i_predefined4 );
     
-    
+    MP4_SeekStream( p_stream, p_box->i_pos + MP4_BOX_HEADERSIZE( p_box ) + 78);
+    MP4_ReadBoxContainerRaw( p_stream, p_box );
+   
 #ifdef MP4_VERBOSE
     msg_Dbg( p_stream->p_input, "Read Box: \"vide\" in stsd %dx%d depth %d",
                       p_box->data.p_sample_vide->i_width,
@@ -1302,6 +1307,7 @@ int MP4_ReadBox_sample_vide( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     MP4_READBOX_EXIT( 1 );
 }
 
+#if 0
 int MP4_ReadBox_sample_mp4v( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     int i;    
@@ -1353,7 +1359,7 @@ int MP4_ReadBox_sample_mp4v( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 #endif
     MP4_READBOX_EXIT( 1 );
 }
-
+#endif 
 
 
 int MP4_ReadBox_stsd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
@@ -1745,14 +1751,14 @@ int MP4_ReadBox_dcom( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     MP4_READBOX_ENTER( MP4_Box_data_dcom_t );
     
-    MP4_GET4BYTES( p_box->data.p_dcom->i_algorithm );
+    MP4_GETFOURCC( p_box->data.p_dcom->i_algorithm );
 #ifdef MP4_VERBOSE
     msg_Dbg( p_stream->p_input, 
              "Read Box: \"dcom\" compression algorithm : %c%c%c%c",
-                      ( p_box->data.p_dcom->i_algorithm >> 24 )&0xff,
+                      ( p_box->data.p_dcom->i_algorithm )&0xff,
+                      ( p_box->data.p_dcom->i_algorithm >> 8 )&0xff,
                       ( p_box->data.p_dcom->i_algorithm >> 16 )&0xff,
-                      ( p_box->data.p_dcom->i_algorithm >>  8 )&0xff,
-                      ( p_box->data.p_dcom->i_algorithm  )&0xff );
+                      ( p_box->data.p_dcom->i_algorithm >> 24 )&0xff );
 #endif 
     
     MP4_READBOX_EXIT( 1 );
@@ -1834,10 +1840,10 @@ int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     if( p_dcom->data.p_dcom->i_algorithm != FOURCC_zlib )
     {
         msg_Dbg( p_stream->p_input, "Read Box: \"cmov\" compression algorithm : %c%c%c%c not supported",
-                    ( p_dcom->data.p_dcom->i_algorithm >> 24 )&0xff,
+                    ( p_dcom->data.p_dcom->i_algorithm )&0xff,
+                    ( p_dcom->data.p_dcom->i_algorithm >> 8 )&0xff,
                     ( p_dcom->data.p_dcom->i_algorithm >> 16 )&0xff,
-                    ( p_dcom->data.p_dcom->i_algorithm >>  8 )&0xff,
-                    ( p_dcom->data.p_dcom->i_algorithm  )&0xff );
+                    ( p_dcom->data.p_dcom->i_algorithm >> 24 )&0xff );
         return( 1 );
     }
     
@@ -1988,12 +1994,18 @@ static struct
     { FOURCC_mp4a,  MP4_ReadBox_sample_mp4a,    MP4_FreeBox_Common },
 
     { FOURCC_vide,  MP4_ReadBox_sample_vide,    MP4_FreeBox_Common },
-    { FOURCC_mp4v,  MP4_ReadBox_sample_mp4v,    MP4_FreeBox_Common },
+    { FOURCC_mp4v,  MP4_ReadBox_sample_vide,    MP4_FreeBox_Common },
     { FOURCC_SVQ1,  MP4_ReadBox_sample_vide,    MP4_FreeBox_Common },
     { FOURCC_DIVX,  MP4_ReadBox_sample_vide,    MP4_FreeBox_Common },
     { FOURCC_h263,  MP4_ReadBox_sample_vide,    MP4_FreeBox_Common },
     { FOURCC_cvid,  MP4_ReadBox_sample_vide,    MP4_FreeBox_Common },
-    { FOURCC_3IV1,  NULL,                       MP4_FreeBox_Common },
+    { FOURCC_3IV1,  MP4_ReadBox_sample_vide,    MP4_FreeBox_Common },
+    { FOURCC_mjpa,  MP4_ReadBox_sample_vide,    MP4_FreeBox_Common },
+    { FOURCC_mjpb,  MP4_ReadBox_sample_vide,    MP4_FreeBox_Common },
+    { FOURCC_mjqt,  NULL,                       NULL }, /* found in mjpa/b */
+    { FOURCC_mjht,  NULL,                       NULL },
+    { FOURCC_jpeg,  MP4_ReadBox_sample_vide,    MP4_FreeBox_Common },
 
     { FOURCC_mp4s,  NULL,                       MP4_FreeBox_Common },
 
@@ -2049,10 +2061,10 @@ int MP4_ReadBox( MP4_Stream_t *p_stream, MP4_Box_t *p_box, MP4_Box_t *p_father )
     {
         msg_Warn( p_stream->p_input,
                   "Unknown box type %c%c%c%c (uncompletetly loaded)",
-                  (p_box->i_type>>24)&0xff, 
-                  (p_box->i_type>>16)&0xff,
+                  (p_box->i_type)&0xff, 
                   (p_box->i_type>>8)&0xff,
-                  (p_box->i_type)&0xff );
+                  (p_box->i_type>>16)&0xff,
+                  (p_box->i_type>>24)&0xff );
         return( 1 );
     }
     else
@@ -2109,10 +2121,10 @@ void MP4_FreeBox( input_thread_t *p_input, MP4_Box_t *p_box )
             /* Should not happen */
             msg_Warn( p_input, 
                       "cannot free box %c%c%c%c, type unknown",
-                      (p_box->i_type >> 24)&0xff,
+                      (p_box->i_type)&0xff,
+                      (p_box->i_type >> 8)&0xff, 
                       (p_box->i_type >> 16)&0xff, 
-                      (p_box->i_type >>  8)&0xff, 
-                      (p_box->i_type )&0xff );
+                      (p_box->i_type >> 24)&0xff );
         }
         else
         {
@@ -2197,10 +2209,10 @@ static void __MP4_DumpBoxStructure( input_thread_t *p_input,
     if( !i_level )
     {
         msg_Dbg( p_input, "Dumping root Box \"%c%c%c%c \"",
-                          (p_box->i_type>>24 ) &0xff,
-                          (p_box->i_type>>16 ) &0xff,
-                          (p_box->i_type>> 8 ) &0xff,
-                          (p_box->i_type ) &0xff );
+                          (p_box->i_type ) &0xff,
+                          (p_box->i_type >>8 ) &0xff,
+                          (p_box->i_type >>16 ) &0xff,
+                          (p_box->i_type >>24) &0xff );
     }
     else
     {
@@ -2212,10 +2224,10 @@ static void __MP4_DumpBoxStructure( input_thread_t *p_input,
             str[i*5] = '|';
         }
         sprintf( str + i_level * 5, "+ %c%c%c%c size %d",
-                      (p_box->i_type>>24 ) &0xff,
-                      (p_box->i_type>>16 ) &0xff,
-                      (p_box->i_type>> 8 ) &0xff,
                       (p_box->i_type ) &0xff,
+                      (p_box->i_type>>8 ) &0xff,
+                      (p_box->i_type>>16 ) &0xff,
+                      (p_box->i_type>>24 ) &0xff,
                       (u32)p_box->i_size );
         
         msg_Dbg( p_input, "%s", str );
index 5d9183081301952ed803c027b1727cf93acf94a6..936304f9e961fbda72fe2728919566165c9cf182 100644 (file)
@@ -2,7 +2,7 @@
  * libmp4.h : LibMP4 library for mp4 module for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: libmp4.h,v 1.2 2002/07/21 15:13:19 fenrir Exp $
+ * $Id: libmp4.h,v 1.3 2002/07/21 18:47:22 fenrir Exp $
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  * 
  * This program is free software; you can redistribute it and/or modify
 
 
 /* XXX It's not the same than VLC_FOURCC */
+#if 0
 #define MP4_FOURCC( a, b, c, d ) \
     ( ((u32)d) | ( ((u32)c) << 8 ) | ( ((u32)b) << 16 ) | ( ((u32)a) << 24 ) )
-        
+#endif         
 
+#define MP4_FOURCC( a, b, c, d ) \
+    ( ((u32)a) | ( ((u32)b) << 8 ) | ( ((u32)c) << 16 ) | ( ((u32)d) << 24 ) )
+    
 #define FOURCC_uuid MP4_FOURCC( 'u', 'u', 'i', 'd' )
 
 #define FOURCC_ftyp MP4_FOURCC( 'f', 't', 'y', 'p' )
 #define FOURCC_h263 MP4_FOURCC( 'h', '2', '6', '3' )
 #define FOURCC_DIVX MP4_FOURCC( 'D', 'I', 'V', 'X' )
 #define FOURCC_cvid MP4_FOURCC( 'c', 'v', 'i', 'd' )
-
-    
+#define FOURCC_mjpa MP4_FOURCC( 'm', 'j', 'p', 'a' )
+#define FOURCC_mjpb MP4_FOURCC( 'm', 'j', 'q', 't' )
+#define FOURCC_mjqt MP4_FOURCC( 'm', 'j', 'h', 't' )
+#define FOURCC_mjht MP4_FOURCC( 'm', 'j', 'p', 'b' )
+#define FOURCC_jpeg MP4_FOURCC( 'j', 'p', 'e', 'g' )
+   
 /*
 #define FOURCC_  MP4_FOURCC( '', '', '', '' )
 */    
@@ -367,6 +376,7 @@ typedef struct MP4_Box_data_sample_vide_s
     
 } MP4_Box_data_sample_vide_t;
 
+/*
 typedef struct MP4_Box_data_sample_mp4v_s
 {
     u8  i_reserved1[6];
@@ -392,7 +402,7 @@ typedef struct MP4_Box_data_sample_mp4v_s
     
 } MP4_Box_data_sample_mp4v_t;
 
-
+*/
 
 typedef struct MP4_Box_data_sample_hint_s
 {
index 1f378e17a9bde64e9fbc0db012bacfcf5c21631d..260757af25c9382f8d1cea2c05344e78f1c19610 100644 (file)
@@ -2,7 +2,7 @@
  * mp4.c : MP4 file input module for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: mp4.c,v 1.1 2002/07/17 21:37:27 fenrir Exp $
+ * $Id: mp4.c,v 1.2 2002/07/21 18:47:22 fenrir Exp $
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  * 
  * This program is free software; you can redistribute it and/or modify
@@ -137,8 +137,8 @@ static int MP4Init( input_thread_t *p_input )
         msg_Warn( p_input, "MP4 plugin discarded (cannot peek)" );
         return( -1 );
     }
-    i_type = ( p_peek[4] << 24 ) + ( p_peek[5] << 16 ) +
-                ( p_peek[6] << 8 ) + ( p_peek[7] );
+    i_type = ( p_peek[4] ) + ( p_peek[5] << 8 ) +
+                ( p_peek[6] << 16 ) + ( p_peek[7] << 24);
     switch( i_type )
     {
         case( FOURCC_ftyp ):
@@ -809,10 +809,10 @@ static void MP4_StartDecoder( input_thread_t *p_input,
     {
         msg_Warn( p_input, "%s (%c%c%c%c) unsupported", 
                   psz_name,
-                  (p_sample->i_type >> 24)&0xff,
-                  (p_sample->i_type >> 16)&0xff,
+                  (p_sample->i_type )&0xff,
                   (p_sample->i_type >> 8)&0xff,
-                  (p_sample->i_type )&0xff);
+                  (p_sample->i_type >> 16)&0xff,
+                  (p_sample->i_type >> 24)&0xff);
         p_demux_track->b_ok = 0;
         return;
     }
index 23487fd2e4eb0dd7d2c8f6beece34971049619b2..ee1f837cbf518e215396ed8a9dd1798ce3324cd2 100644 (file)
@@ -2,7 +2,7 @@
  * mp4.h : MP4 file input module for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: mp4.h,v 1.2 2002/07/21 15:13:19 fenrir Exp $
+ * $Id: mp4.h,v 1.3 2002/07/21 18:47:22 fenrir Exp $
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  * 
  * This program is free software; you can redistribute it and/or modify
@@ -214,6 +214,9 @@ static struct
     { FOURCC_mp4v,  MPEG4_VIDEO_ES, "MP4VisualSampleEntry (MPEG-4)" },
     { FOURCC_3IV1,  UNKNOWN_ES,     "3IV1 SampleEntry" },
     { FOURCC_cvid,  CINEPAK_VIDEO_ES,"cvid SampleEntry (Cinepak Video Codec)" },
+    { FOURCC_mjpa,  UNKNOWN_ES,     "MJPEG-A SampleEntry (Motion JPEG)" },
+    { FOURCC_mjpb,  UNKNOWN_ES,     "MJPEG-A SampleEntry (Motion JPEG)" },
+    { FOURCC_jpeg,  UNKNOWN_ES,     "JPEG (ISO) SampleEntry" },
 
     /* Audio codec */
     { FOURCC_soun,  UNKNOWN_ES,     "Generic AudioSampleEntry" },