]> git.sesse.net Git - vlc/commitdiff
* src/input/input_ext-dec.c, include/input_ext-dec.h, modules/codec/araw.c:
authorGildas Bazin <gbazin@videolan.org>
Thu, 24 Oct 2002 09:37:48 +0000 (09:37 +0000)
committerGildas Bazin <gbazin@videolan.org>
Thu, 24 Oct 2002 09:37:48 +0000 (09:37 +0000)
   renamed input_NextPES into input_ExtractPES and factorised its code.
* modules/codec/ffmpeg/ffmpeg.c, modules/codec/faad/decoder.c,
   modules/codec/cinepak/cinepak.c: make use of NextPES and GetPES from
   src/input/input_ext-dec.c.
* modules/codec/a52.c: fixed uninitialized variable.

include/input_ext-dec.h
modules/codec/a52.c
modules/codec/araw.c
modules/codec/cinepak/cinepak.c
modules/codec/faad/decoder.c
modules/codec/ffmpeg/ffmpeg.c
src/input/input_ext-dec.c

index 80336c84d39d3cb6c312c90c61264fa1b2ca590f..9e53c05f57d6cc24eb57b7e95fdf1ce45a521fd2 100644 (file)
@@ -2,7 +2,7 @@
  * input_ext-dec.h: structures exported to the VideoLAN decoders
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: input_ext-dec.h,v 1.73 2002/10/23 23:17:45 gbazin Exp $
+ * $Id: input_ext-dec.h,v 1.74 2002/10/24 09:37:48 gbazin Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *          Michel Kaempf <maxx@via.ecp.fr>
@@ -218,7 +218,7 @@ VLC_EXPORT( u32,  UnalignedGetBits,        ( bit_stream_t *, unsigned int ) );
 VLC_EXPORT( void, CurrentPTS,              ( bit_stream_t *, mtime_t *, mtime_t * ) );
 VLC_EXPORT( void, NextPTS,                 ( bit_stream_t *, mtime_t *, mtime_t * ) );
 
-VLC_EXPORT( int,  input_NextPES,           ( decoder_fifo_t *, pes_packet_t ** ) );
+VLC_EXPORT( int,  input_ExtractPES,        ( decoder_fifo_t *, pes_packet_t ** ) );
 
 /*****************************************************************************
  * AlignWord : fill in the bit buffer so that the byte pointer be aligned
index a0c8aa3038de2f56f7c5f1ec1c7a235a1a7c2b66..aad665eb02c19d96c951d4553b57d3278e08dedb 100644 (file)
@@ -2,7 +2,7 @@
  * a52.c: A/52 basic parser
  *****************************************************************************
  * Copyright (C) 2001-2002 VideoLAN
- * $Id: a52.c,v 1.14 2002/09/30 21:32:32 massiot Exp $
+ * $Id: a52.c,v 1.15 2002/10/24 09:37:48 gbazin Exp $
  *
  * Authors: Stéphane Borel <stef@via.ecp.fr>
  *          Christophe Massiot <massiot@via.ecp.fr>
@@ -127,6 +127,8 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
     p_dec->p_fifo = p_fifo;
     p_dec->output_format.i_format = VLC_FOURCC('a','5','2',' ');
 
+    aout_DateSet( &end_date, 0 );
+
     /* Init the bitstream */
     InitBitstream( &p_dec->bit_stream, p_dec->p_fifo,
                    NULL, NULL );
index 5299cea9d00bbf870c56090b4521008bb13a9598..15ae0dadca188a7daf1e794e3e92a9f61841c0e0 100644 (file)
@@ -2,7 +2,7 @@
  * araw.c: Pseudo audio decoder; for raw pcm data
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: araw.c,v 1.3 2002/10/21 10:46:34 fenrir Exp $
+ * $Id: araw.c,v 1.4 2002/10/24 09:37:48 gbazin Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *      
@@ -315,7 +315,7 @@ static void DecodeThread( adec_thread_t *p_adec )
     pes_packet_t    *p_pes;
 
     /* **** get samples count **** */
-    if( input_NextPES( p_adec->p_fifo, &p_pes ) < 0 )
+    if( input_ExtractPES( p_adec->p_fifo, &p_pes ) < 0 )
     {
         p_adec->p_fifo->b_error = 1;
         return;
index 50456c9bd41db81c82bff06529f868c2b0fb0769..f4933b83145d5ddf7ba8e5506ac6986593d134e7 100644 (file)
@@ -2,7 +2,7 @@
  * cinepak.c: cinepak video decoder 
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: cinepak.c,v 1.4 2002/10/15 01:50:24 fenrir Exp $
+ * $Id: cinepak.c,v 1.5 2002/10/24 09:37:48 gbazin Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -155,56 +155,6 @@ static inline u32 GetDWBE( u8 *p_buff )
 #define FREE( p ) \
     if( p ) free( p )
 
-/* get the first pes from fifo */
-static pes_packet_t *__PES_GET( decoder_fifo_t *p_fifo )
-{
-    pes_packet_t *p_pes;
-
-    vlc_mutex_lock( &p_fifo->data_lock );
-
-    /* if fifo is emty wait */
-    while( !p_fifo->p_first )
-    {
-        if( p_fifo->b_die )
-        {
-            vlc_mutex_unlock( &p_fifo->data_lock );
-            return( NULL );
-        }
-        vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock );
-    }
-    p_pes = p_fifo->p_first;
-
-    vlc_mutex_unlock( &p_fifo->data_lock );
-
-    return( p_pes );
-}
-
-/* free the first pes and go to next */
-static void __PES_NEXT( decoder_fifo_t *p_fifo )
-{
-    pes_packet_t *p_next;
-
-    vlc_mutex_lock( &p_fifo->data_lock );
-    
-    p_next = p_fifo->p_first->p_next;
-    p_fifo->p_first->p_next = NULL;
-    input_DeletePES( p_fifo->p_packets_mgt, p_fifo->p_first );
-    p_fifo->p_first = p_next;
-    p_fifo->i_depth--;
-
-    if( !p_fifo->p_first )
-    {
-        /* No PES in the fifo */
-        /* pp_last no longer valid */
-        p_fifo->pp_last = &p_fifo->p_first;
-        while( !p_fifo->p_first )
-        {
-            vlc_cond_signal( &p_fifo->data_wait );
-            vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock );
-        }
-    }
-    vlc_mutex_unlock( &p_fifo->data_lock );
-}
 
 static inline void __GetFrame( videodec_thread_t *p_vdec )
 {
@@ -212,13 +162,12 @@ static inline void __GetFrame( videodec_thread_t *p_vdec )
     data_packet_t *p_data;
     byte_t        *p_buffer;
 
-    p_pes = __PES_GET( p_vdec->p_fifo );
+    p_pes = GetPES( p_vdec->p_fifo );
     p_vdec->i_pts = p_pes->i_pts;
 
     while( ( !p_pes->i_nb_data )||( !p_pes->i_pes_size ) )
     {
-        __PES_NEXT( p_vdec->p_fifo );
-        p_pes = __PES_GET( p_vdec->p_fifo );
+        p_pes = NextPES( p_vdec->p_fifo );
     }
     p_vdec->i_framesize = p_pes->i_pes_size;
     if( p_pes->i_nb_data == 1 )
@@ -242,12 +191,12 @@ static inline void __NextFrame( videodec_thread_t *p_vdec )
 {
     pes_packet_t  *p_pes;
 
-    p_pes = __PES_GET( p_vdec->p_fifo );
+    p_pes = GetPES( p_vdec->p_fifo );
     if( p_pes->i_nb_data != 1 )
     {
         free( p_vdec->p_framedata ); /* FIXME keep this buffer */
     }
-    __PES_NEXT( p_vdec->p_fifo );
+    NextPES( p_vdec->p_fifo );
 }
 
 static int cinepak_CheckVout( vout_thread_t *p_vout,
index e3cdfc6c1f6bfa3eccb9bb1acbffaf7a72338443..b7c1d7c000599d01a9ab2643536896e71a6e7fd5 100644 (file)
@@ -2,7 +2,7 @@
  * decoder.c: AAC decoder using libfaad2
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: decoder.c,v 1.6 2002/10/20 17:44:17 fenrir Exp $
+ * $Id: decoder.c,v 1.7 2002/10/24 09:37:47 gbazin Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *      
@@ -148,64 +148,13 @@ static void faac_GetWaveFormatEx( waveformatex_t *p_wh,
     }
 }
 
-/* get the first pes from fifo */
-static pes_packet_t *__PES_GET( decoder_fifo_t *p_fifo )
-{
-    pes_packet_t *p_pes;
-
-    vlc_mutex_lock( &p_fifo->data_lock );
-
-    /* if fifo is emty wait */
-    while( !p_fifo->p_first )
-    {
-        if( p_fifo->b_die )
-        {
-            vlc_mutex_unlock( &p_fifo->data_lock );
-            return( NULL );
-        }
-        vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock );
-    }
-    p_pes = p_fifo->p_first;
-
-    vlc_mutex_unlock( &p_fifo->data_lock );
-
-    return( p_pes );
-}
-
-/* free the first pes and go to next */
-static void __PES_NEXT( decoder_fifo_t *p_fifo )
-{
-    pes_packet_t *p_next;
-
-    vlc_mutex_lock( &p_fifo->data_lock );
-    
-    p_next = p_fifo->p_first->p_next;
-    p_fifo->p_first->p_next = NULL;
-    input_DeletePES( p_fifo->p_packets_mgt, p_fifo->p_first );
-    p_fifo->p_first = p_next;
-    p_fifo->i_depth--;
-
-    if( !p_fifo->p_first )
-    {
-        /* No PES in the fifo */
-        /* pp_last no longer valid */
-        p_fifo->pp_last = &p_fifo->p_first;
-        while( !p_fifo->p_first )
-        {
-            vlc_cond_signal( &p_fifo->data_wait );
-            vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock );
-        }
-    }
-    vlc_mutex_unlock( &p_fifo->data_lock );
-}
-
 static inline void __GetFrame( adec_thread_t *p_adec )
 {
     pes_packet_t  *p_pes;
     data_packet_t *p_data;
     byte_t        *p_buffer;
 
-    p_pes = __PES_GET( p_adec->p_fifo );
+    p_pes = GetPES( p_adec->p_fifo );
     if( p_pes->i_pts )
     {
         p_adec->pts = p_pes->i_pts;
@@ -213,8 +162,7 @@ static inline void __GetFrame( adec_thread_t *p_adec )
 
     while( ( !p_pes->i_nb_data )||( !p_pes->i_pes_size ) )
     {
-        __PES_NEXT( p_adec->p_fifo );
-        p_pes = __PES_GET( p_adec->p_fifo );
+        p_pes = NextPES( p_adec->p_fifo );
     }
     p_adec->i_framesize = p_pes->i_pes_size;
     if( p_pes->i_nb_data == 1 )
@@ -250,7 +198,7 @@ static inline void __GetFrame( adec_thread_t *p_adec )
 
 static inline void __NextFrame( adec_thread_t *p_adec )
 {
-    __PES_NEXT( p_adec->p_fifo );
+    NextPES( p_adec->p_fifo );
 }
 
 
index 1a03b47703ae7dc437bcbaab0bc299abe1227fe3..ebe736a4fc2a98955c30a31b2d22b72455da514f 100644 (file)
@@ -2,7 +2,7 @@
  * ffmpeg.c: video decoder using ffmpeg library
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: ffmpeg.c,v 1.8 2002/10/20 17:28:01 fenrir Exp $
+ * $Id: ffmpeg.c,v 1.9 2002/10/24 09:37:47 gbazin Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -237,56 +237,6 @@ static void ffmpeg_ParseBitMapInfoHeader( bitmapinfoheader_t *p_bh,
     } 
 
 }
-/* get the first pes from fifo */
-static pes_packet_t *__PES_GET( decoder_fifo_t *p_fifo )
-{
-    pes_packet_t *p_pes;
-
-    vlc_mutex_lock( &p_fifo->data_lock );
-
-    /* if fifo is emty wait */
-    while( !p_fifo->p_first )
-    {
-        if( p_fifo->b_die )
-        {
-            vlc_mutex_unlock( &p_fifo->data_lock );
-            return( NULL );
-        }
-        vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock );
-    }
-    p_pes = p_fifo->p_first;
-
-    vlc_mutex_unlock( &p_fifo->data_lock );
-
-    return( p_pes );
-}
-
-/* free the first pes and go to next */
-static void __PES_NEXT( decoder_fifo_t *p_fifo )
-{
-    pes_packet_t *p_next;
-
-    vlc_mutex_lock( &p_fifo->data_lock );
-    
-    p_next = p_fifo->p_first->p_next;
-    p_fifo->p_first->p_next = NULL;
-    input_DeletePES( p_fifo->p_packets_mgt, p_fifo->p_first );
-    p_fifo->p_first = p_next;
-    p_fifo->i_depth--;
-
-    if( !p_fifo->p_first )
-    {
-        /* No PES in the fifo */
-        /* pp_last no longer valid */
-        p_fifo->pp_last = &p_fifo->p_first;
-        while( !p_fifo->p_first )
-        {
-            vlc_cond_signal( &p_fifo->data_wait );
-            vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock );
-        }
-    }
-    vlc_mutex_unlock( &p_fifo->data_lock );
-}
 
 static void __GetFrame( videodec_thread_t *p_vdec )
 {
@@ -294,13 +244,12 @@ static void __GetFrame( videodec_thread_t *p_vdec )
     data_packet_t *p_data;
     byte_t        *p_buffer;
 
-    p_pes = __PES_GET( p_vdec->p_fifo );
+    p_pes = GetPES( p_vdec->p_fifo );
     p_vdec->i_pts = p_pes->i_pts;
 
     while( ( !p_pes->i_nb_data )||( !p_pes->i_pes_size ) )
     {
-        __PES_NEXT( p_vdec->p_fifo );
-        p_pes = __PES_GET( p_vdec->p_fifo );
+        p_pes = NextPES( p_vdec->p_fifo );
     }
     p_vdec->i_framesize = p_pes->i_pes_size;
     if( p_pes->i_nb_data == 1 )
@@ -336,7 +285,7 @@ static void __GetFrame( videodec_thread_t *p_vdec )
 
 static void __NextFrame( videodec_thread_t *p_vdec )
 {
-    __PES_NEXT( p_vdec->p_fifo );
+    NextPES( p_vdec->p_fifo );
 }
 
 
@@ -840,7 +789,7 @@ static void  DecodeThread( videodec_thread_t *p_vdec )
             /* too much late picture, won't decode 
                but break picture until a new I, and for mpeg4 ...*/
             p_vdec->i_frame_late--; /* needed else it will never be decrease */
-            __PES_NEXT( p_vdec->p_fifo );
+            NextPES( p_vdec->p_fifo );
             return;
         }
 #else
@@ -853,7 +802,7 @@ static void  DecodeThread( videodec_thread_t *p_vdec )
             /* too much late picture, won't decode 
                but break picture until a new I, and for mpeg4 ...*/
             p_vdec->i_frame_late--; /* needed else it will never be decrease */
-            __PES_NEXT( p_vdec->p_fifo );
+            NextPES( p_vdec->p_fifo );
             return;
         }
 #endif
index 0a0cbb6108ca0bc30eedebbde2ff853c9dadc547..491d67fadad6eeca5a6b2d0cd9eebe8ed7bb940b 100644 (file)
@@ -2,7 +2,7 @@
  * input_ext-dec.c: services to the decoders
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id: input_ext-dec.c,v 1.36 2002/10/23 23:17:44 gbazin Exp $
+ * $Id: input_ext-dec.c,v 1.37 2002/10/24 09:37:47 gbazin Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -131,7 +131,7 @@ static inline pes_packet_t *_GetPES( decoder_fifo_t * p_fifo )
         }
 
         /* Signal the input thread we're waiting. This is only
-         * needed in case of slave clock (ES plug-in)  but it won't
+         * needed in case of slave clock (ES plug-in) but it won't
          * harm. */
         vlc_cond_signal( &p_fifo->data_wait );
 
@@ -167,6 +167,12 @@ static inline pes_packet_t * _NextPES( decoder_fifo_t * p_fifo )
     p_fifo->p_first = p_next;
     p_fifo->i_depth--;
 
+    if( p_fifo->p_first == NULL )
+    {
+        /* No PES in the FIFO. p_last is no longer valid. */
+        p_fifo->pp_last = &p_fifo->p_first;
+    }
+
     vlc_mutex_unlock( &p_fifo->data_lock );
 
     return _GetPES( p_fifo );
@@ -512,37 +518,19 @@ void NextPTS( bit_stream_t * p_bit_stream, mtime_t * pi_pts,
 }
 
 /****************************************************************************
- * input_NextPES : extract a PES from the fifo. If pp_pes is NULL then this 
+ * input_ExtractPES : extract a PES from the fifo. If pp_pes is NULL then this
  * PES is deleted, else pp_pes will be set to this PES
  ****************************************************************************/
-int input_NextPES( decoder_fifo_t *p_fifo, pes_packet_t **pp_pes )
+int input_ExtractPES( decoder_fifo_t *p_fifo, pes_packet_t **pp_pes )
 {
-    pes_packet_t *p_pes, *p_next;
+    pes_packet_t *p_pes;
 
-    vlc_mutex_lock( &p_fifo->data_lock );
+    p_pes = _GetPES( p_fifo );
 
-    /* if fifo is emty wait */
-    while( !p_fifo->p_first )
-    {
-        if( p_fifo->b_die )
-        {
-            vlc_mutex_unlock( &p_fifo->data_lock );
-            if( pp_pes )
-            {
-                *pp_pes = NULL;
-            }
-            return( -1 );
-        }
-        vlc_cond_signal( &p_fifo->data_wait );
-        vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock );
-    }
-    p_pes = p_fifo->p_first;
+    vlc_mutex_lock( &p_fifo->data_lock );
 
-    p_next = p_pes->p_next;
+    p_fifo->p_first = p_pes->p_next;
     p_pes->p_next = NULL;
-
-
-    p_fifo->p_first = p_next;
     p_fifo->i_depth--;
 
     if( !p_fifo->p_first )
@@ -551,6 +539,7 @@ int input_NextPES( decoder_fifo_t *p_fifo, pes_packet_t **pp_pes )
         /* pp_last no longer valid */
         p_fifo->pp_last = &p_fifo->p_first;
     }
+
     vlc_mutex_unlock( &p_fifo->data_lock );
 
     if( pp_pes )
@@ -563,4 +552,3 @@ int input_NextPES( decoder_fifo_t *p_fifo, pes_packet_t **pp_pes )
     }
     return( 0 );
 }
-