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.
* 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>
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
* 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>
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 );
* 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>
*
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;
* 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>
*
#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 )
{
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 )
{
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,
* 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>
*
}
}
-/* 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;
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 )
static inline void __NextFrame( adec_thread_t *p_adec )
{
- __PES_NEXT( p_adec->p_fifo );
+ NextPES( p_adec->p_fifo );
}
* 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>
*
}
}
-/* 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 )
{
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 )
static void __NextFrame( videodec_thread_t *p_vdec )
{
- __PES_NEXT( p_vdec->p_fifo );
+ NextPES( p_vdec->p_fifo );
}
/* 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
/* 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
* 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>
*
}
/* 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 );
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 );
}
/****************************************************************************
- * 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 )
/* pp_last no longer valid */
p_fifo->pp_last = &p_fifo->p_first;
}
+
vlc_mutex_unlock( &p_fifo->data_lock );
if( pp_pes )
}
return( 0 );
}
-