]> git.sesse.net Git - vlc/commitdiff
* ffmpeg/audio : removed an old error (anyway it was harmless).
authorLaurent Aimar <fenrir@videolan.org>
Fri, 7 Feb 2003 01:22:55 +0000 (01:22 +0000)
committerLaurent Aimar <fenrir@videolan.org>
Fri, 7 Feb 2003 01:22:55 +0000 (01:22 +0000)
 * mp4 : removed a bad initialisation. Erased all ending spaces.
 * mpeg/audio : send i_rate to decoder (not yet usefull but ...)

modules/codec/ffmpeg/audio.c
modules/codec/ffmpeg/audio.h
modules/demux/mp4/libmp4.c
modules/demux/mp4/mp4.c
modules/demux/mpeg/audio.c

index dfea67986950ebaff00e0fa598c22af908413b33..58f7b7b718b7f4927b827903309a8a747d2c4d93 100644 (file)
@@ -2,7 +2,7 @@
  * audio.c: audio decoder using ffmpeg library
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: audio.c,v 1.13 2003/01/25 16:59:49 fenrir Exp $
+ * $Id: audio.c,v 1.14 2003/02/07 01:22:55 fenrir Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -10,7 +10,7 @@
  * 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
@@ -66,34 +66,11 @@ static unsigned int pi_channels_maps[6] =
     AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT,
     AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
      | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT
-};  
+};
 
 /*****************************************************************************
  * locales Functions
  *****************************************************************************/
-#if 0
-static void ffmpeg_GetWaveFormatEx( waveformatex_t *p_wh,
-                                    u8 *p_data )
-{
-    WAVEFORMATEX *p_wfdata = (WAVEFORMATEX*)p_data;
-    
-    p_wh->i_formattag     = p_wfdata->wFormatTag;
-    p_wh->i_nb_channels   = p_wfdata->nChannels;
-    p_wh->i_samplespersec = p_wfdata->nSamplesPerSec;
-    p_wh->i_avgbytespersec= p_wfdata->nAvgBytesPerSec;
-    p_wh->i_blockalign    = p_wfdata->nBlockAlign;
-    p_wh->i_bitspersample = p_wfdata->wBitsPerSample;
-    p_wh->i_size          = p_wfdata->cbSize;
-
-    if( p_wh->i_size )
-    {
-        p_wh->p_data = malloc( p_wh->i_size );
-        memcpy( p_wh->p_data, 
-                p_data + sizeof(WAVEFORMATEX) , 
-                p_wh->i_size );
-    }
-}
-#endif
 
 /*****************************************************************************
  *
@@ -108,8 +85,8 @@ static void ffmpeg_GetWaveFormatEx( waveformatex_t *p_wh,
 /*****************************************************************************
  * InitThread: initialize vdec output thread
  *****************************************************************************
- * This function is called from decoder_Run and performs the second step 
- * of the initialization. It returns 0 on success. Note that the thread's 
+ * This function is called from decoder_Run and performs the second step
+ * of the initialization. It returns 0 on success. Note that the thread's
  * flag are not modified inside this function.
  *
  * ffmpeg codec will be open, some memory allocated.
@@ -158,14 +135,14 @@ int E_( InitThread_Audio )( adec_thread_t *p_adec )
                  p_adec->psz_namecodec );
     }
 
-    p_adec->p_output = malloc( AVCODEC_MAX_AUDIO_FRAME_SIZE );
+    p_adec->p_output = malloc( 3 * AVCODEC_MAX_AUDIO_FRAME_SIZE );
 
 
     p_adec->output_format.i_format = AOUT_FMT_S16_NE;
     p_adec->output_format.i_rate = p_wf->nSamplesPerSec;
     p_adec->output_format.i_physical_channels
         = p_adec->output_format.i_original_channels
-        = p_wf->nChannels;
+        = pi_channels_maps[p_wf->nChannels];
 
     p_adec->p_aout = NULL;
     p_adec->p_aout_input = NULL;
@@ -268,7 +245,7 @@ usenextdata:
                   i_output_size );
     }
 
-    if( p_adec->p_context->channels <= 0 || 
+    if( p_adec->p_context->channels <= 0 ||
         p_adec->p_context->channels > 5 )
     {
         msg_Warn( p_adec->p_fifo,
@@ -281,7 +258,7 @@ usenextdata:
                            / aout_FormatNbChannels( &p_adec->output_format );
     /* **** First check if we have a valid output **** */
     if( ( p_adec->p_aout_input == NULL )||
-        ( p_adec->output_format.i_original_channels != 
+        ( p_adec->output_format.i_original_channels !=
                     pi_channels_maps[p_adec->p_context->channels] ) )
     {
         if( p_adec->p_aout_input != NULL )
@@ -291,8 +268,8 @@ usenextdata:
         }
 
         /* **** Create a new audio output **** */
-        p_adec->output_format.i_physical_channels = 
-            p_adec->output_format.i_original_channels = 
+        p_adec->output_format.i_physical_channels =
+            p_adec->output_format.i_original_channels =
                 pi_channels_maps[p_adec->p_context->channels];
 
         aout_DateInit( &p_adec->date, p_adec->output_format.i_rate );
index 8c13a194a27891fdb9f7414af5d6b5ed33452761..59258e0e0a89d12f4fd15d55ca5d91b3f6982fda 100644 (file)
@@ -2,7 +2,7 @@
  * audio.h: video decoder using ffmpeg library
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: audio.h,v 1.3 2003/01/25 16:59:49 fenrir Exp $
+ * $Id: audio.h,v 1.4 2003/02/07 01:22:55 fenrir Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -10,7 +10,7 @@
  * 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
  *****************************************************************************/
 
 
-/* for an audio stream */
-typedef struct waveformatex_s
-{
-    u16 i_formattag;
-    u16 i_nb_channels;
-    u32 i_samplespersec;
-    u32 i_avgbytespersec;
-    u16 i_blockalign;
-    u16 i_bitspersample;
-    u16 i_size; /* the extra size in bytes */
-
-    u8  *p_data; /* The extra data */
-} waveformatex_t;
-
 typedef struct adec_thread_s
 {
     DECODER_THREAD_COMMON
index 07b17f21864dfbdd1861b3a612dfe5d8b82515f1..14df17311cea35dc6512e005814af221e0a1f24f 100644 (file)
@@ -2,7 +2,7 @@
  * libmp4.c : LibMP4 library for mp4 module for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: libmp4.c,v 1.13 2003/01/25 16:58:34 fenrir Exp $
+ * $Id: libmp4.c,v 1.14 2003/02/07 01:22:55 fenrir Exp $
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -162,14 +162,14 @@ static uint64_t GetQWBE( uint8_t *p_buff )
 
 static void GetUUID( UUID_t *p_uuid, uint8_t *p_buff )
 {
-    memcpy( p_uuid, 
+    memcpy( p_uuid,
             p_buff,
             16 );
 }
 
 static void CreateUUID( UUID_t *p_uuid, uint32_t i_fourcc )
 {
-    /* made by 0xXXXXXXXX-0011-0010-8000-00aa00389b71 
+    /* made by 0xXXXXXXXX-0011-0010-8000-00aa00389b71
             where XXXXXXXX is the fourcc */
     /* FIXME implement this */
 }
@@ -299,7 +299,7 @@ MP4_Stream_t *MP4_InputStream( input_thread_t *p_input )
 
 /****************************************************************************
  * MP4_MemoryStream create a memory stream
- * if p_buffer == NULL, will allocate a buffer of i_size, else 
+ * if p_buffer == NULL, will allocate a buffer of i_size, else
  *     it uses p_buffer XXX you have to unallocate it yourself !
  *
  ****************************************************************************/
@@ -343,7 +343,7 @@ int MP4_ReadStream( MP4_Stream_t *p_stream, uint8_t *p_buff, int i_size )
         {
             return( 0 );
         }
-        memcpy( p_buff, 
+        memcpy( p_buff,
                 p_stream->p_buffer + p_stream->i_start,
                 i_size );
         p_stream->i_start += i_size;
@@ -470,19 +470,18 @@ int MP4_ReadBoxCommon( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     /* FIXME how to write uint64_t ??? */
     if( p_box->i_size )
     {
-        msg_Dbg( p_stream->p_input, "Found Box: %c%c%c%c size %d",
-                 (p_box->i_type)&0xff, (p_box->i_type>>8)&0xff, 
-                     (p_box->i_type>>16)&0xff, (p_box->i_type>>24)&0xff,
+        msg_Dbg( p_stream->p_input, "Found Box: %4.4s size %d",
+                 (char*)&p_box->i_type,
                  (uint32_t)p_box->i_size );
     }
 #endif
 
-    return( 1 ); 
+    return( 1 );
 }
 
 
 /*****************************************************************************
- * MP4_MP4_NextBox : Go to the next box 
+ * MP4_MP4_NextBox : Go to the next box
  *****************************************************************************
  * if p_box == NULL, go to the next box in witch we are( at the begining ).
  *****************************************************************************/
@@ -504,7 +503,7 @@ int MP4_NextBox( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     if( p_box->p_father )
     {
         /* check if it's within p-father */
-        if( p_box->i_size + p_box->i_pos >= 
+        if( p_box->i_size + p_box->i_pos >=
                     p_box->p_father->i_size + p_box->p_father->i_pos )
         {
             return( 0 ); /* out of bound */
@@ -533,7 +532,7 @@ int MP4_ReadBoxContainerRaw( MP4_Stream_t *p_stream, MP4_Box_t *p_container )
 {
     MP4_Box_t *p_box;
 
-    if( MP4_TellStream( p_stream ) + 8 > 
+    if( MP4_TellStream( p_stream ) + 8 >
                  (off_t)(p_container->i_pos + p_container->i_size) )
     {
         /* there is no box to load */
@@ -594,11 +593,8 @@ 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)&0xff, 
-            (p_box->i_type>>8)&0xff,
-            (p_box->i_type>>16)&0xff, 
-            (p_box->i_type>>24)&0xff );
+    msg_Dbg( p_stream->p_input, "Skip box: \"%4.4s\"",
+            (char*)&p_box->i_type );
 #endif
     return( 1 );
 }
@@ -661,11 +657,11 @@ int MP4_ReadBox_mvhd(  MP4_Stream_t *p_stream, MP4_Box_t *p_box )
         MP4_GET4BYTES( p_box->data.p_mvhd->i_timescale );
         MP4_GET4BYTES( p_box->data.p_mvhd->i_duration );
     }
-    MP4_GET4BYTES( p_box->data.p_mvhd->i_rate ); 
-    MP4_GET2BYTES( p_box->data.p_mvhd->i_volume ); 
+    MP4_GET4BYTES( p_box->data.p_mvhd->i_rate );
+    MP4_GET2BYTES( p_box->data.p_mvhd->i_volume );
     MP4_GET2BYTES( p_box->data.p_mvhd->i_reserved1 );
 
-  
+
     for( i = 0; i < 2; i++ )
     {
         MP4_GET4BYTES( p_box->data.p_mvhd->i_reserved2[i] );
@@ -678,23 +674,23 @@ int MP4_ReadBox_mvhd(  MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     {
         MP4_GET4BYTES( p_box->data.p_mvhd->i_predefined[i] );
     }
-    
+
     MP4_GET4BYTES( p_box->data.p_mvhd->i_next_track_id );
-    
-            
+
+
 #ifdef MP4_VERBOSE
     MP4_ConvertDate2Str( s_creation_time, p_box->data.p_mvhd->i_creation_time );
-    MP4_ConvertDate2Str( s_modification_time, 
+    MP4_ConvertDate2Str( s_modification_time,
                          p_box->data.p_mvhd->i_modification_time );
     if( p_box->data.p_mvhd->i_rate )
     {
-        MP4_ConvertDate2Str( s_duration, 
+        MP4_ConvertDate2Str( s_duration,
                  p_box->data.p_mvhd->i_duration / p_box->data.p_mvhd->i_rate );
     }
     else
     {
         s_duration[0] = 0;
-    }    
+    }
     msg_Dbg( p_stream->p_input, "Read Box: \"mvhd\" creation %s modification %s time scale %d duration %s rate %f volume %f next track id %d",
                   s_creation_time,
                   s_modification_time,
@@ -716,7 +712,7 @@ int MP4_ReadBox_tkhd(  MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     char s_duration[128];
 #endif
     MP4_READBOX_ENTER( MP4_Box_data_tkhd_t );
-    
+
     MP4_GETVERSIONFLAGS( p_box->data.p_tkhd );
 
     if( p_box->data.p_tkhd->i_version )
@@ -735,7 +731,7 @@ int MP4_ReadBox_tkhd(  MP4_Stream_t *p_stream, MP4_Box_t *p_box )
         MP4_GET4BYTES( p_box->data.p_tkhd->i_reserved );
         MP4_GET4BYTES( p_box->data.p_tkhd->i_duration );
     }
-    
+
     for( i = 0; i < 2; i++ )
     {
         MP4_GET4BYTES( p_box->data.p_tkhd->i_reserved2[i] );
@@ -751,12 +747,12 @@ int MP4_ReadBox_tkhd(  MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     }
     MP4_GET4BYTES( p_box->data.p_tkhd->i_width );
     MP4_GET4BYTES( p_box->data.p_tkhd->i_height );
-            
+
 #ifdef MP4_VERBOSE
     MP4_ConvertDate2Str( s_creation_time, p_box->data.p_mvhd->i_creation_time );
     MP4_ConvertDate2Str( s_modification_time, p_box->data.p_mvhd->i_modification_time );
     MP4_ConvertDate2Str( s_duration, p_box->data.p_mvhd->i_duration );
-    
+
     msg_Dbg( p_stream->p_input, "Read Box: \"tkhd\" creation %s modification %s duration %s track ID %d layer %d volume %f width %f height %f",
                   s_creation_time,
                   s_modification_time,
@@ -778,7 +774,7 @@ int MP4_ReadBox_tref( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
         /* container is empty, 8 stand for the first header in this box */
         return( 1 );
     }
-   
+
     if( !MP4_SeekStream( p_stream, p_box->i_pos + MP4_BOX_HEADERSIZE( p_box ) ) )
     {
         return( 0 );
@@ -822,15 +818,15 @@ int MP4_ReadBox_mdhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
         MP4_GET4BYTES( p_box->data.p_mdhd->i_timescale );
         MP4_GET4BYTES( p_box->data.p_mdhd->i_duration );
     }
-    i_language = GetWBE( p_peek ); 
+    i_language = GetWBE( p_peek );
     for( i = 0; i < 3; i++ )
     {
-        p_box->data.p_mdhd->i_language[i] = 
+        p_box->data.p_mdhd->i_language[i] =
                     ( ( i_language >> ( (2-i)*5 ) )&0x1f ) + 0x60;
     }
 
     MP4_GET2BYTES( p_box->data.p_mdhd->i_predefined );
-  
+
 #ifdef MP4_VERBOSE
     MP4_ConvertDate2Str( s_creation_time, p_box->data.p_mdhd->i_creation_time );
     MP4_ConvertDate2Str( s_modification_time, p_box->data.p_mdhd->i_modification_time );
@@ -850,10 +846,10 @@ int MP4_ReadBox_mdhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 
 int MP4_ReadBox_hdlr( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
-    MP4_READBOX_ENTER( MP4_Box_data_hdlr_t ); 
+    MP4_READBOX_ENTER( MP4_Box_data_hdlr_t );
 
     MP4_GETVERSIONFLAGS( p_box->data.p_hdlr );
+
     MP4_GET4BYTES( p_box->data.p_hdlr->i_predefined );
     MP4_GETFOURCC( p_box->data.p_hdlr->i_handler_type );
 
@@ -861,11 +857,8 @@ int MP4_ReadBox_hdlr( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     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 )&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,
+    msg_Dbg( p_stream->p_input, "Read Box: \"hdlr\" hanler type %4.4s name %s",
+                       (char*)&p_box->data.p_hdlr->i_handler_type,
                        p_box->data.p_hdlr->psz_name );
 
 #endif
@@ -880,31 +873,30 @@ void MP4_FreeBox_hdlr( input_thread_t *p_input, MP4_Box_t *p_box )
 int MP4_ReadBox_vmhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     unsigned int i;
-   
-    MP4_READBOX_ENTER( MP4_Box_data_vmhd_t ); 
+
+    MP4_READBOX_ENTER( MP4_Box_data_vmhd_t );
 
     MP4_GETVERSIONFLAGS( p_box->data.p_vmhd );
-    
+
     MP4_GET2BYTES( p_box->data.p_vmhd->i_graphics_mode );
     for( i = 0; i < 3; i++ )
     {
         MP4_GET2BYTES( p_box->data.p_vmhd->i_opcolor[i] );
     }
-    
+
 #ifdef MP4_VERBOSE
     msg_Dbg( p_stream->p_input, "Read Box: \"vmhd\" graphics-mode %d opcolor (%d, %d, %d)",
                       p_box->data.p_vmhd->i_graphics_mode,
                       p_box->data.p_vmhd->i_opcolor[0],
                       p_box->data.p_vmhd->i_opcolor[1],
                       p_box->data.p_vmhd->i_opcolor[2] );
-                      
 #endif
     MP4_READBOX_EXIT( 1 );
 }
 
 int MP4_ReadBox_smhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
-    MP4_READBOX_ENTER( MP4_Box_data_smhd_t ); 
+    MP4_READBOX_ENTER( MP4_Box_data_smhd_t );
 
     MP4_GETVERSIONFLAGS( p_box->data.p_smhd );
 
@@ -913,11 +905,10 @@ int MP4_ReadBox_smhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     MP4_GET2BYTES( p_box->data.p_smhd->i_balance );
 
     MP4_GET2BYTES( p_box->data.p_smhd->i_reserved );
-    
+
 #ifdef MP4_VERBOSE
     msg_Dbg( p_stream->p_input, "Read Box: \"smhd\" balance %f",
                       (float)p_box->data.p_smhd->i_balance / 256 );
-                      
 #endif
     MP4_READBOX_EXIT( 1 );
 }
@@ -925,7 +916,7 @@ int MP4_ReadBox_smhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 
 int MP4_ReadBox_hmhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
-    MP4_READBOX_ENTER( MP4_Box_data_hmhd_t ); 
+    MP4_READBOX_ENTER( MP4_Box_data_hmhd_t );
 
     MP4_GETVERSIONFLAGS( p_box->data.p_hmhd );
 
@@ -943,14 +934,13 @@ int MP4_ReadBox_hmhd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
                       p_box->data.p_hmhd->i_avg_PDU_size,
                       p_box->data.p_hmhd->i_max_bitrate,
                       p_box->data.p_hmhd->i_avg_bitrate );
-                      
 #endif
     MP4_READBOX_EXIT( 1 );
 }
 
 int MP4_ReadBox_url( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
-    MP4_READBOX_ENTER( MP4_Box_data_url_t ); 
+    MP4_READBOX_ENTER( MP4_Box_data_url_t );
 
     MP4_GETVERSIONFLAGS( p_box->data.p_url );
     MP4_GETSTRINGZ( p_box->data.p_url->psz_location );
@@ -976,8 +966,8 @@ int MP4_ReadBox_urn( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     MP4_GETVERSIONFLAGS( p_box->data.p_urn );
 
     MP4_GETSTRINGZ( p_box->data.p_urn->psz_name );
-    MP4_GETSTRINGZ( p_box->data.p_urn->psz_location ); 
-   
+    MP4_GETSTRINGZ( p_box->data.p_urn->psz_location );
+
 #ifdef MP4_VERBOSE
     msg_Dbg( p_stream->p_input, "Read Box: \"urn\" name %s location %s",
                       p_box->data.p_urn->psz_name,
@@ -995,11 +985,11 @@ void MP4_FreeBox_urn( input_thread_t *p_input, MP4_Box_t *p_box )
 int MP4_ReadBox_dref( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     MP4_READBOX_ENTER( MP4_Box_data_dref_t );
-    
+
     MP4_GETVERSIONFLAGS( p_box->data.p_dref );
 
     MP4_GET4BYTES( p_box->data.p_dref->i_entry_count );
-   
+
     MP4_SeekStream( p_stream, p_box->i_pos + MP4_BOX_HEADERSIZE( p_box ) + 8 );
     MP4_ReadBoxContainerRaw( p_stream, p_box );
 
@@ -1015,23 +1005,22 @@ int MP4_ReadBox_dref( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 int MP4_ReadBox_stts( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     unsigned int i;
-    MP4_READBOX_ENTER( MP4_Box_data_stts_t ); 
+    MP4_READBOX_ENTER( MP4_Box_data_stts_t );
 
     MP4_GETVERSIONFLAGS( p_box->data.p_stts );
     MP4_GET4BYTES( p_box->data.p_stts->i_entry_count );
 
-    p_box->data.p_stts->i_sample_count = 
+    p_box->data.p_stts->i_sample_count =
         calloc( sizeof( uint32_t ), p_box->data.p_stts->i_entry_count );
     p_box->data.p_stts->i_sample_delta =
         calloc( sizeof( uint32_t ), p_box->data.p_stts->i_entry_count );
-    
+
     for( i = 0; (i < p_box->data.p_stts->i_entry_count )&&( i_read >=8 ); i++ )
     {
         MP4_GET4BYTES( p_box->data.p_stts->i_sample_count[i] );
         MP4_GET4BYTES( p_box->data.p_stts->i_sample_delta[i] );
     }
-    
-    
+
 #ifdef MP4_VERBOSE
     msg_Dbg( p_stream->p_input, "Read Box: \"stts\" entry-count %d",
                       p_box->data.p_stts->i_entry_count );
@@ -1044,30 +1033,28 @@ void MP4_FreeBox_stts( input_thread_t *p_input, MP4_Box_t *p_box )
 {
     FREE( p_box->data.p_stts->i_sample_count );
     FREE( p_box->data.p_stts->i_sample_delta );
-            
 }
 
 int MP4_ReadBox_ctts( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     unsigned int i;
     MP4_READBOX_ENTER( MP4_Box_data_ctts_t );
-    
+
     MP4_GETVERSIONFLAGS( p_box->data.p_ctts );
+
     MP4_GET4BYTES( p_box->data.p_ctts->i_entry_count );
 
-    p_box->data.p_ctts->i_sample_count = 
+    p_box->data.p_ctts->i_sample_count =
         calloc( sizeof( uint32_t ), p_box->data.p_ctts->i_entry_count );
     p_box->data.p_ctts->i_sample_offset =
         calloc( sizeof( uint32_t ), p_box->data.p_ctts->i_entry_count );
-    
+
     for( i = 0; (i < p_box->data.p_ctts->i_entry_count )&&( i_read >=8 ); i++ )
     {
         MP4_GET4BYTES( p_box->data.p_ctts->i_sample_count[i] );
         MP4_GET4BYTES( p_box->data.p_ctts->i_sample_offset[i] );
     }
-    
-    
+
 #ifdef MP4_VERBOSE
     msg_Dbg( p_stream->p_input, "Read Box: \"ctts\" entry-count %d",
                       p_box->data.p_ctts->i_entry_count );
@@ -1094,7 +1081,7 @@ static int MP4_ReadLengthDescriptor( uint8_t **pp_peek, int64_t  *i_read )
         (*i_read)--;
         i_len = ( i_len << 7 ) + ( i_b&0x7f );
     } while( i_b&0x80 );
-    return( i_len );    
+    return( i_len );
 }
 
 int MP4_ReadBox_esds( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
@@ -1128,7 +1115,7 @@ int MP4_ReadBox_esds( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
         if( es_descriptor.b_url )
         {
             unsigned int i_len;
-        
+
             MP4_GET1BYTE( i_len );
             es_descriptor.psz_URL = calloc( sizeof(char), i_len + 1 );
             memcpy( es_descriptor.psz_URL, p_peek, i_len );
@@ -1153,7 +1140,7 @@ int MP4_ReadBox_esds( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     }
 
     i_len = MP4_ReadLengthDescriptor( &p_peek, &i_read );
-    es_descriptor.p_decConfigDescr = 
+    es_descriptor.p_decConfigDescr =
             malloc( sizeof( MP4_descriptor_decoder_config_t ));
 
     MP4_GET1BYTE( es_descriptor.p_decConfigDescr->i_objectTypeIndication );
@@ -1172,7 +1159,7 @@ int MP4_ReadBox_esds( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     i_len = MP4_ReadLengthDescriptor( &p_peek, &i_read );
     es_descriptor.p_decConfigDescr->i_decoder_specific_info_len = i_len;
     es_descriptor.p_decConfigDescr->p_decoder_specific_info = malloc( i_len );
-    memcpy( es_descriptor.p_decConfigDescr->p_decoder_specific_info, 
+    memcpy( es_descriptor.p_decConfigDescr->p_decoder_specific_info,
             p_peek, i_len );
 
     MP4_READBOX_EXIT( 1 );
@@ -1222,7 +1209,7 @@ int MP4_ReadBox_sample_soun( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     msg_Dbg( p_stream->p_input, "Read Box: \"soun\" in stsd channel %d sample size %d sampl rate %f",
                       p_box->data.p_sample_soun->i_channelcount,
                       p_box->data.p_sample_soun->i_samplesize,
-                      (float)p_box->data.p_sample_soun->i_sampleratehi + 
+                      (float)p_box->data.p_sample_soun->i_sampleratehi +
                     (float)p_box->data.p_sample_soun->i_sampleratelo / 65536 );
 
 #endif
@@ -1232,7 +1219,7 @@ int MP4_ReadBox_sample_soun( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 #if 0
 int MP4_ReadBox_sample_mp4a( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
-    unsigned int i;    
+    unsigned int i;
 
     MP4_READBOX_ENTER( MP4_Box_data_sample_mp4a_t );
 
@@ -1254,7 +1241,7 @@ int MP4_ReadBox_sample_mp4a( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     MP4_GET2BYTES( p_box->data.p_sample_mp4a->i_reserved3 );
     MP4_GET2BYTES( p_box->data.p_sample_mp4a->i_sampleratehi );
     MP4_GET2BYTES( p_box->data.p_sample_mp4a->i_sampleratelo );
-    
+
     MP4_SeekStream( p_stream, p_box->i_pos + MP4_BOX_HEADERSIZE( p_box ) + 28 );
     MP4_ReadBoxContainerRaw( p_stream, p_box ); /* esds */
 
@@ -1262,7 +1249,7 @@ int MP4_ReadBox_sample_mp4a( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     msg_Dbg( p_stream->p_input, "Read Box: \"mp4a\" in stsd channel %d sample size %d sampl rate %f",
                       p_box->data.p_sample_mp4a->i_channelcount,
                       p_box->data.p_sample_mp4a->i_samplesize,
-                      (float)p_box->data.p_sample_mp4a->i_sampleratehi + 
+                      (float)p_box->data.p_sample_mp4a->i_sampleratehi +
                         (float)p_box->data.p_sample_mp4a->i_sampleratelo / 65536 );
 
 #endif
@@ -1272,7 +1259,7 @@ int MP4_ReadBox_sample_mp4a( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 
 int MP4_ReadBox_sample_vide( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
-    unsigned int i;    
+    unsigned int i;
 
     MP4_READBOX_ENTER( MP4_Box_data_sample_vide_t );
 
@@ -1293,7 +1280,7 @@ int MP4_ReadBox_sample_vide( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 
     MP4_GET2BYTES( p_box->data.p_sample_vide->i_width );
     MP4_GET2BYTES( p_box->data.p_sample_vide->i_height );
-    
+
     MP4_GET4BYTES( p_box->data.p_sample_vide->i_horizresolution );
     MP4_GET4BYTES( p_box->data.p_sample_vide->i_vertresolution );
 
@@ -1305,10 +1292,10 @@ 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,
@@ -1329,7 +1316,7 @@ int MP4_ReadBox_stsd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 
     MP4_GET4BYTES( p_box->data.p_stsd->i_entry_count );
 
-    MP4_SeekStream( p_stream, p_box->i_pos + MP4_BOX_HEADERSIZE( p_box ) + 8 ); 
+    MP4_SeekStream( p_stream, p_box->i_pos + MP4_BOX_HEADERSIZE( p_box ) + 8 );
 
     MP4_ReadBoxContainerRaw( p_stream, p_box );
 
@@ -1347,16 +1334,16 @@ int MP4_ReadBox_stsz( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     unsigned int i;
 
     MP4_READBOX_ENTER( MP4_Box_data_stsz_t );
-    
+
     MP4_GETVERSIONFLAGS( p_box->data.p_stsz );
-    
+
     MP4_GET4BYTES( p_box->data.p_stsz->i_sample_size );
 
     MP4_GET4BYTES( p_box->data.p_stsz->i_sample_count );
 
-    p_box->data.p_stsz->i_entry_size = 
+    p_box->data.p_stsz->i_entry_size =
         calloc( sizeof( uint32_t ), p_box->data.p_stsz->i_sample_count );
-    
+
     if( !p_box->data.p_stsz->i_sample_size )
     {
         for( i=0; (i<p_box->data.p_stsz->i_sample_count)&&(i_read >= 4 ); i++ )
@@ -1364,9 +1351,8 @@ int MP4_ReadBox_stsz( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
             MP4_GET4BYTES( p_box->data.p_stsz->i_entry_size[i] );
         }
     }
-    
-    
-#ifdef MP4_VERBOSE 
+
+#ifdef MP4_VERBOSE
     msg_Dbg( p_stream->p_input, "Read Box: \"stsz\" sample-size %d sample-count %d",
                       p_box->data.p_stsz->i_sample_size,
                       p_box->data.p_stsz->i_sample_count );
@@ -1383,18 +1369,18 @@ void MP4_FreeBox_stsz( input_thread_t *p_input, MP4_Box_t *p_box )
 int MP4_ReadBox_stsc( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     unsigned int i;
-    
+
     MP4_READBOX_ENTER( MP4_Box_data_stsc_t );
 
     MP4_GETVERSIONFLAGS( p_box->data.p_stsc );
-    
+
     MP4_GET4BYTES( p_box->data.p_stsc->i_entry_count );
 
-    p_box->data.p_stsc->i_first_chunk = 
+    p_box->data.p_stsc->i_first_chunk =
         calloc( sizeof( uint32_t ), p_box->data.p_stsc->i_entry_count );
-    p_box->data.p_stsc->i_samples_per_chunk = 
+    p_box->data.p_stsc->i_samples_per_chunk =
         calloc( sizeof( uint32_t ), p_box->data.p_stsc->i_entry_count );
-    p_box->data.p_stsc->i_sample_description_index = 
+    p_box->data.p_stsc->i_sample_description_index =
         calloc( sizeof( uint32_t ), p_box->data.p_stsc->i_entry_count );
 
     for( i = 0; (i < p_box->data.p_stsc->i_entry_count )&&( i_read >= 12 );i++ )
@@ -1403,9 +1389,8 @@ int MP4_ReadBox_stsc( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
         MP4_GET4BYTES( p_box->data.p_stsc->i_samples_per_chunk[i] );
         MP4_GET4BYTES( p_box->data.p_stsc->i_sample_description_index[i] );
     }
-    
-    
-#ifdef MP4_VERBOSE 
+
+#ifdef MP4_VERBOSE
     msg_Dbg( p_stream->p_input, "Read Box: \"stsc\" entry-count %d",
                       p_box->data.p_stsc->i_entry_count );
 
@@ -1423,14 +1408,14 @@ void MP4_FreeBox_stsc( input_thread_t *p_input, MP4_Box_t *p_box )
 int MP4_ReadBox_stco_co64( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     unsigned int i;
-    
+
     MP4_READBOX_ENTER( MP4_Box_data_co64_t );
 
     MP4_GETVERSIONFLAGS( p_box->data.p_co64 );
 
     MP4_GET4BYTES( p_box->data.p_co64->i_entry_count );
 
-    p_box->data.p_co64->i_chunk_offset = 
+    p_box->data.p_co64->i_chunk_offset =
         calloc( sizeof( uint64_t ), p_box->data.p_co64->i_entry_count );
 
     for( i = 0; i < p_box->data.p_co64->i_entry_count; i++ )
@@ -1452,9 +1437,8 @@ int MP4_ReadBox_stco_co64( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
             MP4_GET8BYTES( p_box->data.p_co64->i_chunk_offset[i] );
         }
     }
-    
-    
-#ifdef MP4_VERBOSE 
+
+#ifdef MP4_VERBOSE
     msg_Dbg( p_stream->p_input, "Read Box: \"co64\" entry-count %d",
                       p_box->data.p_co64->i_entry_count );
 
@@ -1470,14 +1454,14 @@ void MP4_FreeBox_stco_co64( input_thread_t *p_input, MP4_Box_t *p_box )
 int MP4_ReadBox_stss( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     unsigned int i;
-    
-    MP4_READBOX_ENTER( MP4_Box_data_stss_t ); 
+
+    MP4_READBOX_ENTER( MP4_Box_data_stss_t );
 
     MP4_GETVERSIONFLAGS( p_box->data.p_stss );
 
     MP4_GET4BYTES( p_box->data.p_stss->i_entry_count );
 
-    p_box->data.p_stss->i_sample_number = 
+    p_box->data.p_stss->i_sample_number =
         calloc( sizeof( uint32_t ), p_box->data.p_stss->i_entry_count );
 
     for( i = 0; (i < p_box->data.p_stss->i_entry_count )&&( i_read >= 4 ); i++ )
@@ -1487,9 +1471,8 @@ int MP4_ReadBox_stss( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
         /* XXX in libmp4 sample begin at 0 */
         p_box->data.p_stss->i_sample_number[i]--;
     }
-    
-    
-#ifdef MP4_VERBOSE 
+
+#ifdef MP4_VERBOSE
     msg_Dbg( p_stream->p_input, "Read Box: \"stss\" entry-count %d",
                       p_box->data.p_stss->i_entry_count );
 
@@ -1505,7 +1488,7 @@ void MP4_FreeBox_stss( input_thread_t *p_input, MP4_Box_t *p_box )
 int MP4_ReadBox_stsh( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     unsigned int i;
-    
+
     MP4_READBOX_ENTER( MP4_Box_data_stsh_t );
 
     MP4_GETVERSIONFLAGS( p_box->data.p_stsh );
@@ -1513,10 +1496,10 @@ int MP4_ReadBox_stsh( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 
     MP4_GET4BYTES( p_box->data.p_stsh->i_entry_count );
 
-    p_box->data.p_stsh->i_shadowed_sample_number = 
+    p_box->data.p_stsh->i_shadowed_sample_number =
         calloc( sizeof( uint32_t ), p_box->data.p_stsh->i_entry_count );
 
-    p_box->data.p_stsh->i_sync_sample_number = 
+    p_box->data.p_stsh->i_sync_sample_number =
         calloc( sizeof( uint32_t ), p_box->data.p_stsh->i_entry_count );
 
 
@@ -1526,9 +1509,8 @@ int MP4_ReadBox_stsh( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
         MP4_GET4BYTES( p_box->data.p_stsh->i_shadowed_sample_number[i] );
         MP4_GET4BYTES( p_box->data.p_stsh->i_sync_sample_number[i] );
     }
-    
-    
-#ifdef MP4_VERBOSE 
+
+#ifdef MP4_VERBOSE
     msg_Dbg( p_stream->p_input, "Read Box: \"stsh\" entry-count %d",
                       p_box->data.p_stsh->i_entry_count );
 #endif
@@ -1545,12 +1527,12 @@ void MP4_FreeBox_stsh( input_thread_t *p_input, MP4_Box_t *p_box )
 int MP4_ReadBox_stdp( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     unsigned int i;
-   
-    MP4_READBOX_ENTER( MP4_Box_data_stdp_t ); 
+
+    MP4_READBOX_ENTER( MP4_Box_data_stdp_t );
 
     MP4_GETVERSIONFLAGS( p_box->data.p_stdp );
 
-    p_box->data.p_stdp->i_priority = 
+    p_box->data.p_stdp->i_priority =
         calloc( sizeof( uint16_t ), i_read / 2 );
 
     for( i = 0; i < i_read / 2 ; i++ )
@@ -1558,9 +1540,8 @@ int MP4_ReadBox_stdp( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 
         MP4_GET2BYTES( p_box->data.p_stdp->i_priority[i] );
     }
-    
-    
-#ifdef MP4_VERBOSE 
+
+#ifdef MP4_VERBOSE
     msg_Dbg( p_stream->p_input, "Read Box: \"stdp\" entry-count "I64Fd,
                       i_read / 2 );
 
@@ -1576,7 +1557,7 @@ void MP4_FreeBox_stdp( input_thread_t *p_input, MP4_Box_t *p_box )
 int MP4_ReadBox_padb( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     unsigned int i;
-    
+
     MP4_READBOX_ENTER( MP4_Box_data_padb_t );
 
     MP4_GETVERSIONFLAGS( p_box->data.p_padb );
@@ -1584,13 +1565,13 @@ int MP4_ReadBox_padb( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 
     MP4_GET4BYTES( p_box->data.p_padb->i_sample_count );
 
-    p_box->data.p_padb->i_reserved1 = 
+    p_box->data.p_padb->i_reserved1 =
         calloc( sizeof( uint16_t ), ( p_box->data.p_padb->i_sample_count + 1 ) / 2 );
-    p_box->data.p_padb->i_pad2 = 
+    p_box->data.p_padb->i_pad2 =
         calloc( sizeof( uint16_t ), ( p_box->data.p_padb->i_sample_count + 1 ) / 2 );
-    p_box->data.p_padb->i_reserved2 = 
+    p_box->data.p_padb->i_reserved2 =
         calloc( sizeof( uint16_t ), ( p_box->data.p_padb->i_sample_count + 1 ) / 2 );
-    p_box->data.p_padb->i_pad1 = 
+    p_box->data.p_padb->i_pad1 =
         calloc( sizeof( uint16_t ), ( p_box->data.p_padb->i_sample_count + 1 ) / 2 );
 
 
@@ -1603,9 +1584,8 @@ int MP4_ReadBox_padb( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 
         p_peek += 1; i_read -= 1;
     }
-    
-    
-#ifdef MP4_VERBOSE 
+
+#ifdef MP4_VERBOSE
     msg_Dbg( p_stream->p_input, "Read Box: \"stdp\" entry-count "I64Fd,
                       i_read / 2 );
 
@@ -1624,7 +1604,7 @@ void MP4_FreeBox_padb( input_thread_t *p_input, MP4_Box_t *p_box )
 int MP4_ReadBox_elst( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     unsigned int i;
-    
+
     MP4_READBOX_ENTER( MP4_Box_data_padb_t );
 
     MP4_GETVERSIONFLAGS( p_box->data.p_elst );
@@ -1638,7 +1618,7 @@ int MP4_ReadBox_elst( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
         calloc( sizeof( uint64_t ), p_box->data.p_elst->i_entry_count );
     p_box->data.p_elst->i_media_rate_integer =
         calloc( sizeof( uint16_t ), p_box->data.p_elst->i_entry_count );
-    p_box->data.p_elst->i_media_rate_fraction= 
+    p_box->data.p_elst->i_media_rate_fraction=
         calloc( sizeof( uint16_t ), p_box->data.p_elst->i_entry_count );
 
 
@@ -1662,9 +1642,8 @@ int MP4_ReadBox_elst( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
         MP4_GET2BYTES( p_box->data.p_elst->i_media_rate_integer[i] );
         MP4_GET2BYTES( p_box->data.p_elst->i_media_rate_fraction[i] );
     }
-    
-    
-#ifdef MP4_VERBOSE 
+
+#ifdef MP4_VERBOSE
     msg_Dbg( p_stream->p_input, "Read Box: \"elst\" entry-count "I64Fd,
                       i_read / 2 );
 
@@ -1684,18 +1663,18 @@ int MP4_ReadBox_cprt( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     unsigned int i_language;
     unsigned int i;
-    
+
     MP4_READBOX_ENTER( MP4_Box_data_cprt_t );
 
     MP4_GETVERSIONFLAGS( p_box->data.p_cprt );
 
-    i_language = GetWBE( p_peek ); 
+    i_language = GetWBE( p_peek );
     for( i = 0; i < 3; i++ )
     {
-        p_box->data.p_cprt->i_language[i] = 
+        p_box->data.p_cprt->i_language[i] =
             ( ( i_language >> ( (2-i)*5 ) )&0x1f ) + 0x60;
     }
-    p_peek += 2; i_read -= 2;  
+    p_peek += 2; i_read -= 2;
     MP4_GETSTRINGZ( p_box->data.p_cprt->psz_notice );
 
 #ifdef MP4_VERBOSE
@@ -1718,17 +1697,13 @@ void MP4_FreeBox_cprt( input_thread_t *p_input, MP4_Box_t *p_box )
 int MP4_ReadBox_dcom( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     MP4_READBOX_ENTER( MP4_Box_data_dcom_t );
-    
+
     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 )&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 >> 24 )&0xff );
-#endif 
-    
+    msg_Dbg( p_stream->p_input,
+             "Read Box: \"dcom\" compression algorithm : %4.4s",
+                      (char*)&p_box->data.p_dcom->i_algorithm );
+#endif
     MP4_READBOX_EXIT( 1 );
 }
 
@@ -1736,29 +1711,28 @@ int MP4_ReadBox_cmvd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     MP4_READBOX_ENTER( MP4_Box_data_cmvd_t );
 
-    
     MP4_GET4BYTES( p_box->data.p_cmvd->i_uncompressed_size );
 
     p_box->data.p_cmvd->i_compressed_size = i_read;
-    
+
     if( !( p_box->data.p_cmvd->p_data = malloc( i_read ) ) )
     {
         msg_Dbg( p_stream->p_input, "Read Box: \"cmvd\" not enough memory to load data" );
         return( 1 );
     }
-    
+
     /* now copy compressed data */
     memcpy( p_box->data.p_cmvd->p_data,
             p_peek,
             i_read);
-    
+
     p_box->data.p_cmvd->b_compressed = 1;
-     
+
 #ifdef MP4_VERBOSE
     msg_Dbg( p_stream->p_input, "Read Box: \"cmvd\" compressed data size %d",
                       p_box->data.p_cmvd->i_compressed_size );
-#endif 
-    
+#endif
+
     MP4_READBOX_EXIT( 1 );
 }
 void MP4_FreeBox_cmvd( input_thread_t *p_input, MP4_Box_t *p_box )
@@ -1771,14 +1745,14 @@ int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 {
     MP4_Stream_t *p_stream_memory;
     MP4_Box_t *p_umov;
-    
+
     MP4_Box_t *p_dcom;
     MP4_Box_t *p_cmvd;
 #ifdef HAVE_ZLIB_H
     z_stream  z_data;
 #endif
     uint8_t *p_data;
-    
+
     int i_result;
 
     if( !( p_box->data.p_cmov = malloc( sizeof( MP4_Box_data_cmov_t ) ) ) )
@@ -1787,7 +1761,7 @@ int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
         return( 0 );
     }
     memset( p_box->data.p_cmov, 0, sizeof( MP4_Box_data_cmov_t ) );
-    
+
     if( !( p_box->p_father )||
         ( p_box->p_father->i_type != FOURCC_moov ) )
     {
@@ -1799,7 +1773,7 @@ int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     {
         return( 0 );
     }
-    
+
     if( !( p_dcom = MP4_FindBox( p_box, FOURCC_dcom ) )||
         !( p_cmvd = MP4_FindBox( p_box, FOURCC_cmvd ) )||
         !( p_cmvd->data.p_cmvd->p_data ) )
@@ -1810,11 +1784,8 @@ 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 )&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 >> 24 )&0xff );
+        msg_Dbg( p_stream->p_input, "Read Box: \"cmov\" compression algorithm : %4.4s not supported",
+                    (char*)&p_dcom->data.p_dcom->i_algorithm );
         return( 1 );
     }
 
@@ -1822,12 +1793,12 @@ int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     msg_Dbg( p_stream->p_input,
              "Read Box: \"cmov\" zlib unsupported" );
     return( 1 );
-#else 
+#else
     /* decompress data */
     /* allocate a new buffer */
     if( !( p_data = malloc( p_cmvd->data.p_cmvd->i_uncompressed_size ) ) )
     {
-        msg_Err( p_stream->p_input, 
+        msg_Err( p_stream->p_input,
                  "Read Box: \"cmov\" not enough memory to uncompress data" );
         return( 1 );
     }
@@ -1843,7 +1814,7 @@ int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     /* init zlib */
     if( ( i_result = inflateInit( &z_data ) ) != Z_OK )
     {
-        msg_Err( p_stream->p_input, 
+        msg_Err( p_stream->p_input,
                  "Read Box: \"cmov\" error while uncompressing data" );
         free( p_data );
         return( 1 );
@@ -1853,7 +1824,7 @@ int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     i_result = inflate( &z_data, Z_NO_FLUSH );
     if( ( i_result != Z_OK )&&( i_result != Z_STREAM_END ) )
     {
-        msg_Err( p_stream->p_input, 
+        msg_Err( p_stream->p_input,
                  "Read Box: \"cmov\" error while uncompressing data" );
         free( p_data );
         return( 1 );
@@ -1861,16 +1832,16 @@ int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 
     if( p_cmvd->data.p_cmvd->i_uncompressed_size != z_data.total_out )
     {
-        msg_Warn( p_stream->p_input, 
+        msg_Warn( p_stream->p_input,
                   "Read Box: \"cmov\" uncompressing data size mismatch" );
     }
     p_cmvd->data.p_cmvd->i_uncompressed_size = z_data.total_out;
 
-    /* close zlib */ 
+    /* close zlib */
     i_result = inflateEnd( &z_data );
     if( i_result != Z_OK )
     {
-        msg_Warn( p_stream->p_input, 
+        msg_Warn( p_stream->p_input,
            "Read Box: \"cmov\" error while uncompressing data (ignored)" );
     }
 
@@ -1879,24 +1850,24 @@ int MP4_ReadBox_cmov( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
     p_cmvd->data.p_cmvd->p_data = p_data;
     p_cmvd->data.p_cmvd->b_compressed = 0;
 
-    msg_Dbg( p_stream->p_input, 
+    msg_Dbg( p_stream->p_input,
              "Read Box: \"cmov\" box succesfully uncompressed" );
 
     /* now create a memory stream */
-    p_stream_memory = MP4_MemoryStream( p_stream->p_input, 
+    p_stream_memory = MP4_MemoryStream( p_stream->p_input,
                                         p_cmvd->data.p_cmvd->i_uncompressed_size,
                                         p_cmvd->data.p_cmvd->p_data );
 
     /* and read uncompressd moov */
     p_umov = malloc( sizeof( MP4_Box_t ) );
-    
+
     i_result = MP4_ReadBox( p_stream_memory, p_umov, NULL );
-  
+
     p_box->data.p_cmov->p_moov = p_umov;
     free( p_stream_memory );
 
 #ifdef MP4_VERBOSE
-    msg_Dbg( p_stream->p_input, 
+    msg_Dbg( p_stream->p_input,
              "Read Box: \"cmov\" compressed movie header completed" );
 #endif
     return( i_result );
@@ -1928,9 +1899,8 @@ int MP4_ReadBox_rdrf( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 
 #ifdef MP4_VERBOSE
     msg_Dbg( p_stream->p_input,
-             "Read Box: \"rdrf\" type:%c%c%c%c ref %s",
-             p_box->data.p_rdrf->i_ref_type&0xff, (p_box->data.p_rdrf->i_ref_type>>8)&0xff,
-             (p_box->data.p_rdrf->i_ref_type>>16)&0xff, (p_box->data.p_rdrf->i_ref_type>>24)&0xff,
+             "Read Box: \"rdrf\" type:%4.4s ref %s",
+             (char*)&p_box->data.p_rdrf->i_ref_type,
              p_box->data.p_rdrf->psz_ref );
 
 #endif
@@ -1984,9 +1954,8 @@ int MP4_ReadBox_rmvc( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 
 #ifdef MP4_VERBOSE
     msg_Dbg( p_stream->p_input,
-             "Read Box: \"rmvc\" gestaltType:%c%c%c%c val1:0x%x val2:0x%x checkType:0x%x",
-             p_box->data.p_rmvc->i_gestaltType&0xff, (p_box->data.p_rmvc->i_gestaltType>>8)&0xff,
-             (p_box->data.p_rmvc->i_gestaltType>>16)&0xff,(p_box->data.p_rmvc->i_gestaltType>>24)&0xff,
+             "Read Box: \"rmvc\" gestaltType:%4.4s val1:0x%x val2:0x%x checkType:0x%x",
+             (char*)&p_box->data.p_rmvc->i_gestaltType,
              p_box->data.p_rmvc->i_val1,p_box->data.p_rmvc->i_val2,
              p_box->data.p_rmvc->i_checkType );
 #endif
@@ -2001,7 +1970,7 @@ int MP4_ReadBox_rmvc( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
 static struct
 {
     uint32_t i_type;
-    int  (*MP4_ReadBox_function )( MP4_Stream_t *p_stream, MP4_Box_t *p_box ); 
+    int  (*MP4_ReadBox_function )( MP4_Stream_t *p_stream, MP4_Box_t *p_box );
     void (*MP4_FreeBox_function )( input_thread_t *p_input, MP4_Box_t *p_box );
 } MP4_Box_Function [] =
 {
@@ -2075,7 +2044,7 @@ static struct
     { 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 },
@@ -2104,14 +2073,14 @@ static struct
 
 
 /*****************************************************************************
- * MP4_ReadBox : parse the actual box and the children 
+ * MP4_ReadBox : parse the actual box and the children
  *  XXX : Do not go to the next box
  *****************************************************************************/
 int MP4_ReadBox( MP4_Stream_t *p_stream, MP4_Box_t *p_box, MP4_Box_t *p_father )
 {
     int i_result;
     unsigned int i_index;
-    
+
     if( !MP4_ReadBoxCommon( p_stream, p_box ) )
     {
         msg_Warn( p_stream->p_input, "Cannot read one box" );
@@ -2136,16 +2105,13 @@ int MP4_ReadBox( MP4_Stream_t *p_stream, MP4_Box_t *p_box, MP4_Box_t *p_father )
     if( MP4_Box_Function[i_index].MP4_ReadBox_function == NULL )
     {
         msg_Warn( p_stream->p_input,
-                  "Unknown box type %c%c%c%c (uncompletetly loaded)",
-                  (p_box->i_type)&0xff, 
-                  (p_box->i_type>>8)&0xff,
-                  (p_box->i_type>>16)&0xff,
-                  (p_box->i_type>>24)&0xff );
+                  "Unknown box type %4.4s (uncompletetly loaded)",
+                  (char*)&p_box->i_type );
         return( 1 );
     }
     else
     {
-        i_result = 
+        i_result =
            (MP4_Box_Function[i_index].MP4_ReadBox_function)( p_stream, p_box );
     }
 
@@ -2157,14 +2123,14 @@ int MP4_ReadBox( MP4_Stream_t *p_stream, MP4_Box_t *p_box, MP4_Box_t *p_father )
 }
 #if 0
 /*****************************************************************************
- * MP4_CountBox: given a box, count how many child have the requested type 
- * FIXME : support GUUID 
+ * MP4_CountBox: given a box, count how many child have the requested type
+ * FIXME : support GUUID
  *****************************************************************************/
 int MP4_CountBox( MP4_Box_t *p_box, uint32_t i_type )
 {
     unsigned int i_count;
     MP4_Box_t *p_child;
-    
+
     if( !p_box )
     {
         return( 0 );
@@ -2175,12 +2141,12 @@ int MP4_CountBox( MP4_Box_t *p_box, uint32_t i_type )
     while( p_child )
     {
         if( p_child->i_type == i_type )
-        {   
+        {
             i_count++;
         }
         p_child = p_child->p_next;
     }
-    
+
     return( i_count );
 }
 #endif
@@ -2193,7 +2159,7 @@ int MP4_CountBox( MP4_Box_t *p_box, uint32_t i_type )
 MP4_Box_t *MP4_FindBox( MP4_Box_t *p_box, uint32_t i_type )
 {
     MP4_Box_t *p_child;
-    
+
     if( !p_box )
     {
         return( NULL );
@@ -2203,25 +2169,25 @@ MP4_Box_t *MP4_FindBox( MP4_Box_t *p_box, uint32_t i_type )
     while( p_child )
     {
         if( p_child->i_type == i_type )
-        {   
+        {
             return( p_child );
         }
         p_child = p_child->p_next;
     }
-    
+
     return( NULL );
 }
 
 
 #if 0
 /*****************************************************************************
- * MP4_FindNextBox:  find next box with thesame type and at the same level 
+ * MP4_FindNextBox:  find next box with thesame type and at the same level
  *                  than p_box
  *****************************************************************************/
 MP4_Box_t *MP4_FindNextBox( MP4_Box_t *p_box )
 {
     MP4_Box_t *p_next;
-    
+
     if( !p_box )
     {
         return( NULL );
@@ -2244,7 +2210,7 @@ MP4_Box_t *MP4_FindNextBox( MP4_Box_t *p_box )
 MP4_Box_t *MP4_FindNbBox( MP4_Box_t *p_box, uint32_t i_number )
 {
     MP4_Box_t *p_child = p_box->p_first;
-    
+
     if( !p_child )
     {
         return( NULL );
@@ -2263,7 +2229,7 @@ MP4_Box_t *MP4_FindNbBox( MP4_Box_t *p_box, uint32_t i_number )
 #endif
 
 /*****************************************************************************
- * MP4_FreeBox : free memory after read with MP4_ReadBox and all 
+ * MP4_FreeBox : free memory after read with MP4_ReadBox and all
  * the children
  *****************************************************************************/
 void MP4_BoxFree( input_thread_t *p_input, MP4_Box_t *p_box )
@@ -2284,7 +2250,7 @@ void MP4_BoxFree( input_thread_t *p_input, MP4_Box_t *p_box )
         MP4_BoxFree( p_input, p_child );
         /* MP4_FreeBoxChildren have free all data expect p_child itself */
         free( p_child );
-        p_child = p_next; 
+        p_child = p_next;
     }
 
     /* Now search function to call */
@@ -2301,12 +2267,9 @@ void MP4_BoxFree( input_thread_t *p_input, MP4_Box_t *p_box )
         if( MP4_Box_Function[i_index].MP4_FreeBox_function == NULL )
         {
             /* Should not happen */
-            msg_Warn( p_input, 
-                      "cannot free box %c%c%c%c, type unknown",
-                      (p_box->i_type)&0xff,
-                      (p_box->i_type >> 8)&0xff, 
-                      (p_box->i_type >> 16)&0xff, 
-                      (p_box->i_type >> 24)&0xff );
+            msg_Warn( p_input,
+                      "cannot free box %4.4s, type unknown",
+                      (char*)&p_box->i_type );
         }
         else
         {
@@ -2319,21 +2282,20 @@ void MP4_BoxFree( input_thread_t *p_input, MP4_Box_t *p_box )
 
     p_box->p_first = NULL;
     p_box->p_last = NULL;
-    
+
 }
 
 /*****************************************************************************
  * MP4_BoxGetRoot : Parse the entire file, and create all boxes in memory
  *****************************************************************************
- *  The first box is a virtual box "root" and is the father for all first 
+ *  The first box is a virtual box "root" and is the father for all first
  *  level boxes for the file, a sort of virtual contener
  *****************************************************************************/
 int MP4_BoxGetRoot( input_thread_t *p_input, MP4_Box_t *p_root )
 {
-    
     MP4_Stream_t *p_stream;
     int i_result;
-    
+
     MP4_SeekAbsolute( p_input, 0 );     /* Go to the begining */
     p_root->i_pos = 0;
     p_root->i_type = VLC_FOURCC( 'r', 'o', 'o', 't' );
@@ -2346,27 +2308,27 @@ int MP4_BoxGetRoot( input_thread_t *p_input, MP4_Box_t *p_root )
     p_root->p_first  = NULL;
     p_root->p_last  = NULL;
     p_root->p_next   = NULL;
-    
+
     p_stream = MP4_InputStream( p_input );
-    
+
     i_result = MP4_ReadBoxContainerRaw( p_stream, p_root );
 
     free( p_stream );
-    
+
     if( i_result )
     {
-        MP4_Box_t *p_child; 
+        MP4_Box_t *p_child;
         MP4_Box_t *p_moov;
         MP4_Box_t *p_cmov;
 
-        /* check if there is a cmov, if so replace 
+        /* check if there is a cmov, if so replace
           compressed moov by  uncompressed one */
         if( ( p_moov = MP4_FindBox( p_root, FOURCC_moov ) )&&
             ( p_cmov = MP4_FindBox( p_moov, FOURCC_cmov ) ) )
         {
             /* rename the compressed moov as a box to skip */
             p_moov->i_type = FOURCC_skip;
-                
+
             /* get uncompressed p_moov */
             p_moov = p_cmov->data.p_cmov->p_moov;
             p_cmov->data.p_cmov->p_moov = NULL;
@@ -2390,11 +2352,8 @@ static void __MP4_BoxDumpStructure( input_thread_t *p_input,
 
     if( !i_level )
     {
-        msg_Dbg( p_input, "Dumping root Box \"%c%c%c%c \"",
-                          (p_box->i_type ) &0xff,
-                          (p_box->i_type >>8 ) &0xff,
-                          (p_box->i_type >>16 ) &0xff,
-                          (p_box->i_type >>24) &0xff );
+        msg_Dbg( p_input, "Dumping root Box \"%4.4s\"",
+                          (char*)&p_box->i_type );
     }
     else
     {
@@ -2405,13 +2364,10 @@ static void __MP4_BoxDumpStructure( input_thread_t *p_input,
         {
             str[i*5] = '|';
         }
-        sprintf( str + i_level * 5, "+ %c%c%c%c size %d",
-                      (p_box->i_type ) &0xff,
-                      (p_box->i_type>>8 ) &0xff,
-                      (p_box->i_type>>16 ) &0xff,
-                      (p_box->i_type>>24 ) &0xff,
+        sprintf( str + i_level * 5, "+ %4.4s size %d",
+                      (char*)&p_box->i_type,
                       (uint32_t)p_box->i_size );
-        
+
         msg_Dbg( p_input, "%s", str );
     }
     p_child = p_box->p_first;
@@ -2420,7 +2376,6 @@ static void __MP4_BoxDumpStructure( input_thread_t *p_input,
         __MP4_BoxDumpStructure( p_input, p_child, i_level + 1 );
         p_child = p_child->p_next;
     }
-    
 }
 
 void MP4_BoxDumpStructure( input_thread_t *p_input, MP4_Box_t *p_box )
@@ -2447,7 +2402,7 @@ static void __get_token( char **ppsz_path, char **ppsz_token, int *pi_number )
         return;
     }
     i_len = 0;
-    while(  (*ppsz_path)[i_len] && 
+    while(  (*ppsz_path)[i_len] &&
             (*ppsz_path)[i_len] != '/' && (*ppsz_path)[i_len] != '[' )
     {
         i_len++;
@@ -2457,13 +2412,13 @@ static void __get_token( char **ppsz_path, char **ppsz_token, int *pi_number )
         i_len = 1;
     }
     *ppsz_token = malloc( i_len + 1 );
-        
+
     memcpy( *ppsz_token, *ppsz_path, i_len );
 
     (*ppsz_token)[i_len] = '\0';
 
     *ppsz_path += i_len;
-        
+
     if( **ppsz_path == '[' )
     {
         (*ppsz_path)++;
@@ -2495,7 +2450,6 @@ static void __MP4_BoxGet( MP4_Box_t **pp_result,
     size_t  i_size;
 #endif
 
-    
     if( !p_box )
     {
         *pp_result = NULL;
@@ -2526,7 +2480,7 @@ static void __MP4_BoxGet( MP4_Box_t **pp_result,
         int i_number;
 
         __get_token( &psz_path, &psz_token, &i_number );
-//        fprintf( stderr, "path:'%s', token:'%s' n:%d\n", 
+//        fprintf( stderr, "path:'%s', token:'%s' n:%d\n",
 //                 psz_path,psz_token,i_number );
         if( !psz_token )
         {
@@ -2624,10 +2578,9 @@ static void __MP4_BoxGet( MP4_Box_t **pp_result,
             *pp_result = NULL;
             return;
         }
-        
+
         free( psz_token );
     }
-    
 }
 
 /*****************************************************************************
@@ -2635,7 +2588,7 @@ static void __MP4_BoxGet( MP4_Box_t **pp_result,
  *****************************************************************************
  * Path Format: . .. / as usual
  *              [number] to specifie box number ex: trak[12]
- *              
+ *
  * ex: /moov/trak[12]
  *     ../mdia
  *****************************************************************************/
@@ -2644,7 +2597,7 @@ MP4_Box_t *MP4_BoxGet( MP4_Box_t *p_box, char *psz_fmt, ... )
     va_list args;
     MP4_Box_t *p_result;
 
-    va_start( args, psz_fmt ); 
+    va_start( args, psz_fmt );
     __MP4_BoxGet( &p_result, p_box, psz_fmt, args );
     va_end( args );
 
@@ -2656,7 +2609,7 @@ MP4_Box_t *MP4_BoxGet( MP4_Box_t *p_box, char *psz_fmt, ... )
  *****************************************************************************
  * Path Format: . .. / as usual
  *              [number] to specifie box number ex: trak[12]
- *              
+ *
  * ex: /moov/trak[12]
  *     ../mdia
  *****************************************************************************/
@@ -2666,14 +2619,14 @@ int MP4_BoxCount( MP4_Box_t *p_box, char *psz_fmt, ... )
     int     i_count;
     MP4_Box_t *p_result, *p_next;
 
-    va_start( args, psz_fmt ); 
+    va_start( args, psz_fmt );
     __MP4_BoxGet( &p_result, p_box, psz_fmt, args );
     va_end( args );
     if( !p_result )
     {
         return( 0 );
     }
-    
+
     i_count = 1;
     for( p_next = p_result->p_next; p_next != NULL; p_next = p_next->p_next)
     {
index 874f827168d42f1c33a255f0ac16625cfd89f2e4..6c8593c2fa4c29892c4ea1f3987d7133268f918c 100644 (file)
@@ -2,7 +2,7 @@
  * mp4.c : MP4 file input module for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: mp4.c,v 1.16 2003/01/28 16:57:28 sam Exp $
+ * $Id: mp4.c,v 1.17 2003/02/07 01:22:55 fenrir Exp $
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -82,7 +82,7 @@ static int  MP4_DecodeSample();
     *((uint8_t*)p) = ( (dw)&0xff ); \
     *((uint8_t*)p+1) = ( ((dw)>> 8)&0xff )
 
-    
+
 /*****************************************************************************
  * MP4Init: check file and initializes MP4 structures
  *****************************************************************************/
@@ -165,17 +165,14 @@ static int MP4Init( vlc_object_t * p_this )
         switch( p_ftyp->data.p_ftyp->i_major_brand )
         {
             case( FOURCC_isom ):
-                msg_Dbg( p_input, 
+                msg_Dbg( p_input,
                          "ISO Media file (isom) version %d.",
                          p_ftyp->data.p_ftyp->i_minor_version );
                 break;
             default:
                 msg_Dbg( p_input,
-                         "unrecognized major file specification (%c%c%c%c).",
-                          p_ftyp->data.p_ftyp->i_major_brand&0xff,
-                          ( p_ftyp->data.p_ftyp->i_major_brand >>  8)&0xff,
-                          ( p_ftyp->data.p_ftyp->i_major_brand >> 16 )&0xff,
-                          ( p_ftyp->data.p_ftyp->i_major_brand >> 24 )&0xff );
+                         "unrecognized major file specification (%4.4s).",
+                          (char*)&p_ftyp->data.p_ftyp->i_major_brand );
                 break;
         }
     }
@@ -187,7 +184,7 @@ static int MP4Init( vlc_object_t * p_this )
     /* the file need to have one moov box */
     if( MP4_BoxCount( &p_demux->box_root, "/moov" ) != 1 )
     {
-        msg_Err( p_input, 
+        msg_Err( p_input,
                  "MP4 plugin discarded (%d moov boxes)",
                  MP4_BoxCount( &p_demux->box_root, "/moov" ) );
 //        MP4End( p_input );
@@ -206,7 +203,7 @@ static int MP4Init( vlc_object_t * p_this )
         p_demux->i_duration = p_mvhd->data.p_mvhd->i_duration;
     }
 
-    if( !( p_demux->i_tracks = 
+    if( !( p_demux->i_tracks =
                 MP4_BoxCount( &p_demux->box_root, "/moov/trak" ) ) )
     {
         msg_Err( p_input, "cannot find any /moov/trak" );
@@ -247,7 +244,7 @@ static int MP4Init( vlc_object_t * p_this )
                             psz_cat,
                             p_demux->track[i].b_enable ? "enable":"disable",
                             p_demux->track[i].i_language[0],
-                            p_demux->track[i].i_language[1], 
+                            p_demux->track[i].i_language[1],
                             p_demux->track[i].i_language[2] );
         }
         else
@@ -315,24 +312,24 @@ static int MP4Demux( input_thread_t *p_input )
     demux_sys_t *p_demux = p_input->p_demux_data;
     unsigned int i_track;
 
-    /* XXX beurk, beuRK and BEURK, 
+    /* XXX beurk, beuRK and BEURK,
        but only way I've found to detect seek from interface */
     if( p_input->stream.p_selected_program->i_synchro_state == SYNCHRO_REINIT )
     {
         mtime_t i_date;
-        
+
         /* first wait for empty buffer, arbitrary time FIXME */
         msleep( DEFAULT_PTS_DELAY );
         /* *** calculate new date *** */
 
-        i_date = (mtime_t)1000000 * 
+        i_date = (mtime_t)1000000 *
                  (mtime_t)p_demux->i_duration /
-                 (mtime_t)p_demux->i_timescale * 
+                 (mtime_t)p_demux->i_timescale *
                  (mtime_t)MP4_TellAbsolute( p_input ) /
                  (mtime_t)p_input->stream.p_selected_area->i_size;
         MP4Seek( p_input, i_date );
     }
-    
+
     /* first wait for the good time to read a packet */
     input_ClockManageRef( p_input,
                           p_input->stream.p_selected_program,
@@ -341,11 +338,11 @@ static int MP4Demux( input_thread_t *p_input )
 
     /* update pcr XXX in mpeg scale so in 90000 unit/s */
     p_demux->i_pcr = MP4_GetMoviePTS( p_demux ) * 9 / 100;
-    
+
 
     /* we will read 100ms for each stream so ...*/
     p_demux->i_time += __MAX( p_demux->i_timescale / 10 , 1 );
-    
+
 
     for( i_track = 0; i_track < p_demux->i_tracks; i_track++ )
     {
@@ -371,7 +368,7 @@ static int MP4Demux( input_thread_t *p_input )
                 break;
             }
 
-            /* send it to decoder and update time of this track 
+            /* send it to decoder and update time of this track
                  it also launch a new decoder if needed */
             MP4_DecodeSample( p_input ,
                               &p_demux->track[i_track],
@@ -379,9 +376,9 @@ static int MP4Demux( input_thread_t *p_input )
         }
 
     }
-    
+
     /* now check if all tracks are finished or unhandled*/
-    
+
     for( i_track = 0; i_track < p_demux->i_tracks; i_track++ )
     {
         if( ( p_demux->track[i_track].b_ok )&&
@@ -406,8 +403,8 @@ static int   MP4Seek     ( input_thread_t *p_input, mtime_t i_date )
     /* First update update global time */
     p_demux->i_time = i_date * p_demux->i_timescale / 1000000;
     p_demux->i_pcr = __MAX( MP4_GetMoviePTS( p_demux ) - DEFAULT_PTS_DELAY,
-                            0 ) * 9 / 100; 
-    
+                            0 ) * 9 / 100;
+
     /* Now for each stream try to go to this time */
     for( i_track = 0; i_track < p_demux->i_tracks; i_track++ )
     {
@@ -460,7 +457,7 @@ static void __MP4End ( vlc_object_t * p_this )
  ****************************************************************************/
 
 /****************************************************************************
- * MP4_TrackSynchro : synchronize a track with movie time after seek or 
+ * MP4_TrackSynchro : synchronize a track with movie time after seek or
  *                    for newly selected track
  *****************************************************************************
  * TODO add support of Edit List (edts/elts) and Shadow Sync Sample(stsh)
@@ -484,7 +481,7 @@ static int MP4_TrackSynchro( input_thread_t *p_input, track_data_mp4_t *p_track
     {
         if( p_track->i_sample >= p_track->i_sample_count )
         {
-            msg_Warn( p_input, 
+            msg_Warn( p_input,
                         "track[Id 0x%x] will be disabled (seeking too far)",
                         p_track->i_track_ID );
             MP4_StopDecoder( p_input, p_track );
@@ -501,7 +498,6 @@ static int MP4_TrackSynchro( input_thread_t *p_input, track_data_mp4_t *p_track
         {
             p_track->i_chunk++;
         }
-        
     }
     if( p_track->i_sample >= p_track->i_sample_count )
     {
@@ -521,12 +517,12 @@ static int MP4_TrackSynchro( input_thread_t *p_input, track_data_mp4_t *p_track
             {
                 if( i_index > 0 )
                 {
-                    msg_Dbg( p_input, "stts gives %d --> %d (sample number)", 
-                            p_track->i_sample, 
+                    msg_Dbg( p_input, "stts gives %d --> %d (sample number)",
+                            p_track->i_sample,
                             p_stss->data.p_stss->i_sample_number[i_index-1] );
                     p_track->i_sample = p_stss->data.p_stss->i_sample_number[i_index-1];
                     /* new track.i_sample is less than old so i_chunk can only decreased */
-                    while( p_track->i_chunk > 0 && 
+                    while( p_track->i_chunk > 0 &&
                             p_track->i_sample < p_track->chunk[p_track->i_chunk].i_sample_first )
                     {
                         p_track->i_chunk--;
@@ -534,8 +530,8 @@ static int MP4_TrackSynchro( input_thread_t *p_input, track_data_mp4_t *p_track
                 }
                 else
                 {
-                    msg_Dbg( p_input, "stts gives %d --> %d (sample number)", 
-                            p_track->i_sample, 
+                    msg_Dbg( p_input, "stts gives %d --> %d (sample number)",
+                            p_track->i_sample,
                             p_stss->data.p_stss->i_sample_number[i_index-1] );
                     p_track->i_sample = p_stss->data.p_stss->i_sample_number[i_index];
                     /* new track.i_sample is more than old so i_chunk can only increased */
@@ -552,8 +548,8 @@ static int MP4_TrackSynchro( input_thread_t *p_input, track_data_mp4_t *p_track
     }
     else
     {
-        msg_Dbg( p_input, 
-                    "track[Id 0x%x] does not provide Sync Sample Box (stss)", 
+        msg_Dbg( p_input,
+                    "track[Id 0x%x] does not provide Sync Sample Box (stss)",
                     p_track->i_track_ID );
     }
 
@@ -587,7 +583,7 @@ static void MP4_ParseTrack( input_thread_t *p_input,
     MP4_Box_t *p_hdlr;
 
     MP4_Box_t *p_vmhd;
-    MP4_Box_t *p_smhd; 
+    MP4_Box_t *p_smhd;
 
     /* hint track unsuported */
 
@@ -596,20 +592,20 @@ static void MP4_ParseTrack( input_thread_t *p_input,
 
     /* by default, we don't known the categorie */
     p_demux_track->i_cat = UNKNOWN_ES;
-    
+
     if( !p_tkhd )
     {
         return;
     }
 
     /* do we launch this track by default ? */
-    p_demux_track->b_enable = 
+    p_demux_track->b_enable =
         ( ( p_tkhd->data.p_tkhd->i_flags&MP4_TRACK_ENABLED ) != 0 );
 
     p_demux_track->i_track_ID = p_tkhd->data.p_tkhd->i_track_ID;
     p_demux_track->i_width = p_tkhd->data.p_tkhd->i_width / 65536;
     p_demux_track->i_height = p_tkhd->data.p_tkhd->i_height / 65536;
-    
+
     if( ( p_elst = MP4_BoxGet( p_trak, "edts/elst" ) ) )
     {
 /*        msg_Warn( p_input, "unhandled box: edts --> FIXME" ); */
@@ -618,11 +614,11 @@ static void MP4_ParseTrack( input_thread_t *p_input,
     if( p_tref )
     {
 /*        msg_Warn( p_input, "unhandled box: tref --> FIXME" ); */
-    } 
+    }
 
     p_mdhd = MP4_BoxGet( p_trak, "mdia/mdhd" );
     p_hdlr = MP4_BoxGet( p_trak, "mdia/hdlr" );
-    
+
     if( ( !p_mdhd )||( !p_hdlr ) )
     {
         return;
@@ -630,12 +626,12 @@ static void MP4_ParseTrack( input_thread_t *p_input,
 
     p_demux_track->i_timescale = p_mdhd->data.p_mdhd->i_timescale;
 
-    for( i = 0; i < 3; i++ ) 
+    for( i = 0; i < 3; i++ )
     {
         p_demux_track->i_language[i] = p_mdhd->data.p_mdhd->i_language[i];
     }
     p_mdhd->data.p_mdhd->i_language[3] = 0;
-    
+
     switch( p_hdlr->data.p_hdlr->i_handler_type )
     {
         case( FOURCC_soun ):
@@ -653,7 +649,7 @@ static void MP4_ParseTrack( input_thread_t *p_input,
             }
             p_demux_track->i_cat = VIDEO_ES;
             break;
-            
+
         default:
             return;
     }
@@ -665,27 +661,26 @@ static void MP4_ParseTrack( input_thread_t *p_input,
     {
         return;
     }
-    
+
     if( !( p_demux_track->p_stsd = MP4_BoxGet( p_trak,"mdia/minf/stbl/stsd") ) )
     {
         return;
     }
-    
+
     /* Create chunk  index table */
     if( !MP4_CreateChunksIndex( p_input,p_demux_track  ) )
     {
         return; /* cannot create chunks index */
     }
-    
+
     /* create sample index table needed for reading and seeking */
     if( !MP4_CreateSamplesIndex( p_input, p_demux_track ) )
     {
         return; /* cannot create samples index */
     }
-     
-    p_demux_track->b_ok = 1;        
+
+    p_demux_track->b_ok = 1;
 }
-                     
 
 
 /* now create basic chunk data, the rest will be filled by MP4_CreateSamplesIndex */
@@ -697,33 +692,32 @@ static int MP4_CreateChunksIndex( input_thread_t *p_input,
 
     unsigned int i_chunk;
     unsigned int i_index, i_last;
-   
 
     if( ( !(p_co64 = MP4_BoxGet( p_demux_track->p_stbl, "stco" ) )&&
-          !(p_co64 = MP4_BoxGet( p_demux_track->p_stbl, "co64" ) ) )|| 
+          !(p_co64 = MP4_BoxGet( p_demux_track->p_stbl, "co64" ) ) )||
         ( !(p_stsc = MP4_BoxGet( p_demux_track->p_stbl, "stsc" ) ) ))
     {
         return( 0 );
     }
-     
+
     p_demux_track->i_chunk_count = p_co64->data.p_co64->i_entry_count;
     if( !p_demux_track->i_chunk_count )
     {
         msg_Warn( p_input, "no chunk defined" );
         return( 0 );
     }
-    p_demux_track->chunk = calloc( p_demux_track->i_chunk_count, 
+    p_demux_track->chunk = calloc( p_demux_track->i_chunk_count,
                                    sizeof( chunk_data_mp4_t ) );
 
     /* first we read chunk offset */
     for( i_chunk = 0; i_chunk < p_demux_track->i_chunk_count; i_chunk++ )
     {
-        p_demux_track->chunk[i_chunk].i_offset = 
+        p_demux_track->chunk[i_chunk].i_offset =
                 p_co64->data.p_co64->i_chunk_offset[i_chunk];
     }
 
-    /* now we read index for SampleEntry( soun vide mp4a mp4v ...) 
-        to be used for the sample XXX begin to 1 
+    /* now we read index for SampleEntry( soun vide mp4a mp4v ...)
+        to be used for the sample XXX begin to 1
         We construct it begining at the end */
     i_last = p_demux_track->i_chunk_count; /* last chunk proceded */
     i_index = p_stsc->data.p_stsc->i_entry_count;
@@ -739,7 +733,7 @@ static int MP4_CreateChunksIndex( input_thread_t *p_input,
         for( i_chunk = p_stsc->data.p_stsc->i_first_chunk[i_index] - 1;
                 i_chunk < i_last; i_chunk++ )
         {
-            p_demux_track->chunk[i_chunk].i_sample_description_index = 
+            p_demux_track->chunk[i_chunk].i_sample_description_index =
                     p_stsc->data.p_stsc->i_sample_description_index[i_index];
             p_demux_track->chunk[i_chunk].i_sample_count =
                     p_stsc->data.p_stsc->i_samples_per_chunk[i_index];
@@ -747,16 +741,15 @@ static int MP4_CreateChunksIndex( input_thread_t *p_input,
         i_last = p_stsc->data.p_stsc->i_first_chunk[i_index] - 1;
     }
 
-    p_demux_track->chunk[i_chunk].i_sample_first = 0;
+    p_demux_track->chunk[0].i_sample_first = 0;
     for( i_chunk = 1; i_chunk < p_demux_track->i_chunk_count; i_chunk++ )
     {
         p_demux_track->chunk[i_chunk].i_sample_first =
-            p_demux_track->chunk[i_chunk-1].i_sample_first + 
+            p_demux_track->chunk[i_chunk-1].i_sample_first +
                 p_demux_track->chunk[i_chunk-1].i_sample_count;
-        
     }
-    
-    msg_Dbg( p_input, 
+
+    msg_Dbg( p_input,
              "track[Id 0x%x] read %d chunk",
              p_demux_track->i_track_ID,
             p_demux_track->i_chunk_count );
@@ -770,10 +763,10 @@ static int MP4_CreateSamplesIndex( input_thread_t *p_input,
                                    track_data_mp4_t *p_demux_track )
 {
     MP4_Box_t *p_stts; /* makes mapping between sample and decoding time,
-                          ctts make same mapping but for composition time, 
+                          ctts make same mapping but for composition time,
                           not yet used and probably not usefull */
-    MP4_Box_t *p_stsz; /* gives sample size of each samples, there is also stz2 
-                          that uses a compressed form FIXME make them in libmp4 
+    MP4_Box_t *p_stsz; /* gives sample size of each samples, there is also stz2
+                          that uses a compressed form FIXME make them in libmp4
                           as a unique type */
     /* TODO use also stss and stsh table for seeking */
     /* FIXME use edit table */
@@ -783,18 +776,17 @@ static int MP4_CreateSamplesIndex( input_thread_t *p_input,
     int64_t i_index;
     int64_t i_index_sample_used;
 
-    int64_t i_last_dts; 
-    
+    int64_t i_last_dts;
+
     p_stts = MP4_BoxGet( p_demux_track->p_stbl, "stts" );
     p_stsz = MP4_BoxGet( p_demux_track->p_stbl, "stsz" ); /* FIXME and stz2 */
 
-    
     if( ( !p_stts )||( !p_stsz ) )
     {
         msg_Warn( p_input, "cannot read sample table" );
-        return( 0 ); 
+        return( 0 );
     }
-        
+
     p_demux_track->i_sample_count = p_stsz->data.p_stsz->i_sample_count;
 
 
@@ -809,12 +801,12 @@ static int MP4_CreateSamplesIndex( input_thread_t *p_input,
     {
         /* 2: each sample can have a different size */
         p_demux_track->i_sample_size = 0;
-        p_demux_track->p_sample_size = 
+        p_demux_track->p_sample_size =
             calloc( p_demux_track->i_sample_count, sizeof( uint32_t ) );
-        
+
         for( i_sample = 0; i_sample < p_demux_track->i_sample_count; i_sample++ )
         {
-            p_demux_track->p_sample_size[i_sample] = 
+            p_demux_track->p_sample_size[i_sample] =
                     p_stsz->data.p_stsz->i_entry_size[i_sample];
         }
     }
@@ -822,9 +814,9 @@ static int MP4_CreateSamplesIndex( input_thread_t *p_input,
         now use stts */
 
     /* if we don't want to waste too much memory, we can't expand
-       the box !, so each chunk will contain an "extract" of this table 
+       the box !, so each chunk will contain an "extract" of this table
        for fast research */
-        
+
     i_last_dts = 0;
     i_index = 0; i_index_sample_used =0;
 
@@ -835,7 +827,7 @@ static int MP4_CreateSamplesIndex( input_thread_t *p_input,
         int64_t i_entry, i_sample_count, i;
         /* save last dts */
         p_demux_track->chunk[i_chunk].i_first_dts = i_last_dts;
-    /* count how many entries needed for this chunk 
+    /* count how many entries needed for this chunk
        for p_sample_delta_dts and p_sample_count_dts */
 
         i_sample_count = p_demux_track->chunk[i_chunk].i_sample_count;
@@ -846,14 +838,14 @@ static int MP4_CreateSamplesIndex( input_thread_t *p_input,
             i_sample_count -= p_stts->data.p_stts->i_sample_count[i_index+i_entry];
             if( i_entry == 0 )
             {
-                i_sample_count += i_index_sample_used; /* don't count already used sample 
+                i_sample_count += i_index_sample_used; /* don't count already used sample
                                                    int this entry */
             }
             i_entry++;
         }
 
         /* allocate them */
-        p_demux_track->chunk[i_chunk].p_sample_count_dts = 
+        p_demux_track->chunk[i_chunk].p_sample_count_dts =
             calloc( i_entry, sizeof( uint32_t ) );
         p_demux_track->chunk[i_chunk].p_sample_delta_dts =
             calloc( i_entry, sizeof( uint32_t ) );
@@ -864,7 +856,7 @@ static int MP4_CreateSamplesIndex( input_thread_t *p_input,
         {
             int64_t i_used;
             int64_t i_rest;
-            
+
             i_rest = p_stts->data.p_stts->i_sample_count[i_index] - i_index_sample_used;
 
             i_used = __MIN( i_rest, i_sample_count );
@@ -876,8 +868,8 @@ static int MP4_CreateSamplesIndex( input_thread_t *p_input,
 
             p_demux_track->chunk[i_chunk].p_sample_delta_dts[i] =
                         p_stts->data.p_stts->i_sample_delta[i_index];
-            
-            i_last_dts += i_used * 
+
+            i_last_dts += i_used *
                     p_demux_track->chunk[i_chunk].p_sample_delta_dts[i];
 
             if( i_index_sample_used >=
@@ -888,11 +880,11 @@ static int MP4_CreateSamplesIndex( input_thread_t *p_input,
                 i_index_sample_used = 0;
             }
         }
-        
+
     }
 
-    msg_Dbg( p_input, 
-             "track[Id 0x%x] read %d samples length:"I64Fd"s", 
+    msg_Dbg( p_input,
+             "track[Id 0x%x] read %d samples length:"I64Fd"s",
              p_demux_track->i_track_ID,
              p_demux_track->i_sample_count,
              i_last_dts / p_demux_track->i_timescale );
@@ -931,18 +923,18 @@ static void MP4_StartDecoder( input_thread_t *p_input,
 
     if( !p_demux_track->chunk[i_chunk].i_sample_description_index )
     {
-        msg_Warn( p_input, 
+        msg_Warn( p_input,
                   "invalid SampleEntry index (track[Id 0x%x])",
                   p_demux_track->i_track_ID );
         return;
-    } 
-    p_sample = MP4_BoxGet(  p_demux_track->p_stsd, 
-                            "[%d]", 
+    }
+    p_sample = MP4_BoxGet(  p_demux_track->p_stsd,
+                            "[%d]",
                 p_demux_track->chunk[i_chunk].i_sample_description_index - 1 );
 
     if( ( !p_sample )||( !p_sample->data.p_data ) )
     {
-        msg_Warn( p_input, 
+        msg_Warn( p_input,
                   "cannot find SampleEntry (track[Id 0x%x])",
                   p_demux_track->i_track_ID );
         return;
@@ -950,7 +942,7 @@ static void MP4_StartDecoder( input_thread_t *p_input,
 
     vlc_mutex_lock( &p_input->stream.stream_lock );
     p_demux_track->p_es = input_AddES( p_input,
-                                       p_input->stream.p_selected_program, 
+                                       p_input->stream.p_selected_program,
                                        p_demux_track->i_track_ID,
                                        0 );
     vlc_mutex_unlock( &p_input->stream.stream_lock );
@@ -981,7 +973,7 @@ static void MP4_StartDecoder( input_thread_t *p_input,
     p_decoder_specific_info = NULL;
     p_pes_init = NULL;
 
-    /* now see if esds is present and if so create a data packet 
+    /* now see if esds is present and if so create a data packet
         with decoder_specific_info  */
 #define p_decconfig p_esds->data.p_esds->es_descriptor.p_decConfigDescr
     if( ( p_esds = MP4_BoxGet( p_sample, "esds" ) )&&
@@ -1012,7 +1004,7 @@ static void MP4_StartDecoder( input_thread_t *p_input,
                 p_demux_track->p_es->i_fourcc = VLC_FOURCC( 'm','p','4','a' );
                 break;
             /* true MPEG 2 audio */
-            case( 0x69): 
+            case( 0x69):
                 p_demux_track->p_es->i_fourcc = VLC_FOURCC( 'm','p','g','a' );
                 break;
             case( 0x6a): /* MPEG1 video */
@@ -1026,30 +1018,30 @@ static void MP4_StartDecoder( input_thread_t *p_input,
                 break;
             default:
                 /* Unknown entry, but don't touch i_fourcc */
-                msg_Warn( p_input, 
+                msg_Warn( p_input,
                           "unknown objectTypeIndication(0x%x) (Track[ID 0x%x])",
                           p_decconfig->i_objectTypeIndication,
                           p_demux_track->i_track_ID );
                 break;
         }
-        i_decoder_specific_info_len = 
+        i_decoder_specific_info_len =
                 p_decconfig->i_decoder_specific_info_len;
-        p_decoder_specific_info = 
+        p_decoder_specific_info =
                 p_decconfig->p_decoder_specific_info;
     }
 
 #undef p_decconfig
 
     /* some last initialisation */
-    /* XXX I create a bitmapinfoheader_t or 
-       waveformatex_t for each stream, up to now it's the best thing 
-       I've found but it could exist a better solution :) as something 
+    /* XXX I create a bitmapinfoheader_t or
+       waveformatex_t for each stream, up to now it's the best thing
+       I've found but it could exist a better solution :) as something
        like adding some new fields in p_es ...
 
        XXX I don't set all values, only thoses that are interesting or known
-        --> bitmapinfoheader_t : width and height 
+        --> bitmapinfoheader_t : width and height
         --> waveformatex_t : channels, samplerate, bitspersample
-        and at the end I add p_decoder_specific_info 
+        and at the end I add p_decoder_specific_info
 
         TODO set more values
 
@@ -1057,8 +1049,8 @@ static void MP4_StartDecoder( input_thread_t *p_input,
 
     switch( p_demux_track->i_cat )
     {
-        case( VIDEO_ES ):    
-            /* now create a bitmapinfoheader_t for decoder and 
+        case( VIDEO_ES ):
+            /* now create a bitmapinfoheader_t for decoder and
                add information found in p_esds */
             /* XXX XXX + 16 are for avoid segfault when ffmpeg access beyong the data */
             p_init = malloc( sizeof( BITMAPINFOHEADER ) + i_decoder_specific_info_len + 16 );
@@ -1091,7 +1083,7 @@ static void MP4_StartDecoder( input_thread_t *p_input,
             {
                 data_packet_t   *p_data;
 
-                memcpy( p_init + sizeof( BITMAPINFOHEADER ), 
+                memcpy( p_init + sizeof( BITMAPINFOHEADER ),
                         p_decoder_specific_info,
                         i_decoder_specific_info_len);
 
@@ -1206,8 +1198,8 @@ static int  MP4_ReadSample( input_thread_t *p_input,
         return( 0 );
     }
     /* caculate size and position for this sample */
-    i_size = p_demux_track->i_sample_size ? 
-                    p_demux_track->i_sample_size : 
+    i_size = p_demux_track->i_sample_size ?
+                    p_demux_track->i_sample_size :
                     p_demux_track->p_sample_size[p_demux_track->i_sample];
 
     i_pos  = MP4_GetTrackPos( p_demux_track );
@@ -1230,7 +1222,7 @@ static int  MP4_ReadSample( input_thread_t *p_input,
         *pp_pes = NULL;
         return( 0 );
     }
-    
+
     /* initialisation of all the field */
     (*pp_pes)->i_dts =
         (*pp_pes)->i_pts = MP4_GetTrackPTS( p_demux_track );
@@ -1238,11 +1230,11 @@ static int  MP4_ReadSample( input_thread_t *p_input,
     (*pp_pes)->i_nb_data = 1;
     (*pp_pes)->i_pes_size = i_size;
 
-    if( !i_size )    
+    if( !i_size )
     {
         return( 1 );
     }
-    
+
 /*    msg_Dbg( p_input, "will read %d bytes", i_size ); */
     if( !MP4_ReadData( p_input, p_data->p_payload_start, i_size ) )
     {
@@ -1250,7 +1242,7 @@ static int  MP4_ReadSample( input_thread_t *p_input,
         return( 0 );
     }
 
-       return( 1 );
+    return( 1 );
 }
 
 
@@ -1265,16 +1257,16 @@ static int  MP4_DecodeSample( input_thread_t *p_input,
     }
 
     /* don't forget to convert in mpeg clock */
-    /* FIXME correct ffmpeg to use dts instead of pts that it incorrect 
+    /* FIXME correct ffmpeg to use dts instead of pts that it incorrect
        and, set it here ( and correct avi demux ) */
     p_pes->i_dts =
         p_pes->i_pts = input_ClockGetTS( p_input,
                                          p_input->stream.p_selected_program,
                                          p_pes->i_pts * 9/100);
 
-    
+
     input_DecodePES( p_demux_track->p_es->p_decoder_fifo, p_pes );
-    
+
     /* now update sample position */
     p_demux_track->i_sample++; /* easy ;) */
     if( p_demux_track->i_sample >= p_demux_track->i_sample_count )
@@ -1288,23 +1280,22 @@ static int  MP4_DecodeSample( input_thread_t *p_input,
             p_demux_track->chunk[p_demux_track->i_chunk].i_sample_first +
                 p_demux_track->chunk[p_demux_track->i_chunk].i_sample_count )
     {
-        /* we haven't reached the end of the track, so see if we 
-           have to change the decoder for the next frame because 
+        /* we haven't reached the end of the track, so see if we
+           have to change the decoder for the next frame because
            i_sample_description_index has changed */
 
         p_demux_track->i_chunk++;
-        if( p_demux_track->chunk[p_demux_track->i_chunk-1].i_sample_description_index 
+        if( p_demux_track->chunk[p_demux_track->i_chunk-1].i_sample_description_index
               != p_demux_track->chunk[p_demux_track->i_chunk].i_sample_description_index  )
         {
             /* FIXME */
-            msg_Warn( p_input, 
+            msg_Warn( p_input,
                       "SampleEntry has changed, starting a new decoder" );
             MP4_StopDecoder( p_input, p_demux_track );
             MP4_StartDecoder( p_input, p_demux_track );
         }
     }
 
-    
     return( 1 );
 }
 
index 17cee67cb6021ae93a98121d558aac2ecabd055f..94b971e81c380fbf859317dfbbb59cf4696c908f 100644 (file)
@@ -2,7 +2,7 @@
  * audio.c : mpeg audio Stream input module for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: audio.c,v 1.10 2003/01/20 13:06:34 fenrir Exp $
+ * $Id: audio.c,v 1.11 2003/02/07 01:22:55 fenrir Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  * 
@@ -693,7 +693,8 @@ static int Demux( input_thread_t * p_input )
                 "cannot read data" );
         return( -1 );
     }
-    
+
+    p_pes->i_rate = p_input->stream.control.i_rate;
     p_pes->i_dts =
         p_pes->i_pts = input_ClockGetTS( p_input,
                                          p_input->stream.p_selected_program,