Commit 6d6601ea authored by Gildas Bazin's avatar Gildas Bazin

* ALL: removed GetPES and NextPES, we now use input_ExtractPES everywhere instead
   of these. The bitstream facility has also been changed to use input_ExtractPES
   and now stores the current PES in its structure.
   Introduced input_FlushPESFifo() and CloseBitstream().
parent cdf8646f
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* input_ext-dec.h: structures exported to the VideoLAN decoders * input_ext-dec.h: structures exported to the VideoLAN decoders
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: input_ext-dec.h,v 1.74 2002/10/24 09:37:48 gbazin Exp $ * $Id: input_ext-dec.h,v 1.75 2002/10/27 16:58:14 gbazin Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* Michel Kaempf <maxx@via.ecp.fr> * Michel Kaempf <maxx@via.ecp.fr>
...@@ -167,7 +167,9 @@ struct bit_stream_t ...@@ -167,7 +167,9 @@ struct bit_stream_t
/* /*
* Byte structures * Byte structures
*/ */
/* Current data packet (in the current PES packet of the PES stream) */ /* Current PES packet (extracted from the PES stream) */
pes_packet_t * p_pes;
/* Current data packet (in the current PES packet) */
data_packet_t * p_data; data_packet_t * p_data;
/* Pointer to the next byte that is to be read (in the current packet) */ /* Pointer to the next byte that is to be read (in the current packet) */
byte_t * p_byte; byte_t * p_byte;
...@@ -207,19 +209,16 @@ struct bit_stream_t ...@@ -207,19 +209,16 @@ struct bit_stream_t
/***************************************************************************** /*****************************************************************************
* Prototypes from input_ext-dec.c * Prototypes from input_ext-dec.c
*****************************************************************************/ *****************************************************************************/
VLC_EXPORT( void, InitBitstream, ( bit_stream_t *, decoder_fifo_t *, void ( * )( bit_stream_t *, vlc_bool_t ), void * p_callback_arg ) ); VLC_EXPORT( int, InitBitstream, ( bit_stream_t *, decoder_fifo_t *, void ( * )( bit_stream_t *, vlc_bool_t ), void * p_callback_arg ) );
VLC_EXPORT( vlc_bool_t, NextDataPacket, ( decoder_fifo_t *, data_packet_t ** ) ); VLC_EXPORT( vlc_bool_t, NextDataPacket, ( decoder_fifo_t *, bit_stream_t * ) );
VLC_EXPORT( pes_packet_t *, GetPES, ( decoder_fifo_t * ) );
VLC_EXPORT( pes_packet_t *, NextPES, ( decoder_fifo_t * ) );
VLC_EXPORT( void, BitstreamNextDataPacket, ( bit_stream_t * ) ); VLC_EXPORT( void, BitstreamNextDataPacket, ( bit_stream_t * ) );
VLC_EXPORT( u32, UnalignedShowBits, ( bit_stream_t *, unsigned int ) ); VLC_EXPORT( u32, UnalignedShowBits, ( bit_stream_t *, unsigned int ) );
VLC_EXPORT( void, UnalignedRemoveBits, ( bit_stream_t * ) ); VLC_EXPORT( void, UnalignedRemoveBits, ( bit_stream_t * ) );
VLC_EXPORT( u32, UnalignedGetBits, ( bit_stream_t *, unsigned int ) ); VLC_EXPORT( u32, UnalignedGetBits, ( bit_stream_t *, unsigned int ) );
VLC_EXPORT( void, CloseBitstream, ( bit_stream_t * ) );
VLC_EXPORT( void, CurrentPTS, ( bit_stream_t *, mtime_t *, mtime_t * ) ); VLC_EXPORT( void, CurrentPTS, ( bit_stream_t *, mtime_t *, mtime_t * ) );
VLC_EXPORT( void, NextPTS, ( bit_stream_t *, mtime_t *, mtime_t * ) ); VLC_EXPORT( void, NextPTS, ( bit_stream_t *, mtime_t *, mtime_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 * AlignWord : fill in the bit buffer so that the byte pointer be aligned
* on a word boundary (XXX: there must be at least sizeof(WORD_TYPE) - 1 * on a word boundary (XXX: there must be at least sizeof(WORD_TYPE) - 1
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* but exported to plug-ins * but exported to plug-ins
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2002 VideoLAN * Copyright (C) 1999-2002 VideoLAN
* $Id: input_ext-plugins.h,v 1.35 2002/08/08 00:35:10 sam Exp $ * $Id: input_ext-plugins.h,v 1.36 2002/10/27 16:58:14 gbazin Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -58,6 +58,8 @@ VLC_EXPORT( int, input_UnselectES,( input_thread_t *, es_descriptor_t * ) ); ...@@ -58,6 +58,8 @@ VLC_EXPORT( int, input_UnselectES,( input_thread_t *, es_descriptor_t * ) );
decoder_fifo_t * input_RunDecoder( input_thread_t *, es_descriptor_t * ); decoder_fifo_t * input_RunDecoder( input_thread_t *, es_descriptor_t * );
void input_EndDecoder( input_thread_t *, es_descriptor_t * ); void input_EndDecoder( input_thread_t *, es_descriptor_t * );
VLC_EXPORT( void, input_DecodePES, ( decoder_fifo_t *, pes_packet_t * ) ); VLC_EXPORT( void, input_DecodePES, ( decoder_fifo_t *, pes_packet_t * ) );
VLC_EXPORT( void, input_ExtractPES, ( decoder_fifo_t *, pes_packet_t ** ) );
VLC_EXPORT( void, input_FlushPESFifo, ( decoder_fifo_t * ) );
void input_EscapeDiscontinuity( input_thread_t * ); void input_EscapeDiscontinuity( input_thread_t * );
void input_EscapeAudioDiscontinuity( input_thread_t * ); void input_EscapeAudioDiscontinuity( input_thread_t * );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* a52.c: A/52 basic parser * a52.c: A/52 basic parser
***************************************************************************** *****************************************************************************
* Copyright (C) 2001-2002 VideoLAN * Copyright (C) 2001-2002 VideoLAN
* $Id: a52.c,v 1.15 2002/10/24 09:37:48 gbazin Exp $ * $Id: a52.c,v 1.16 2002/10/27 16:58:14 gbazin Exp $
* *
* Authors: Stphane Borel <stef@via.ecp.fr> * Authors: Stphane Borel <stef@via.ecp.fr>
* Christophe Massiot <massiot@via.ecp.fr> * Christophe Massiot <massiot@via.ecp.fr>
...@@ -120,7 +120,7 @@ static int RunDecoder( decoder_fifo_t *p_fifo ) ...@@ -120,7 +120,7 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
DecoderError( p_fifo ); DecoderError( p_fifo );
return -1; return -1;
} }
/* Initialize the thread properties */ /* Initialize the thread properties */
p_dec->p_aout = NULL; p_dec->p_aout = NULL;
p_dec->p_aout_input = NULL; p_dec->p_aout_input = NULL;
...@@ -130,8 +130,14 @@ static int RunDecoder( decoder_fifo_t *p_fifo ) ...@@ -130,8 +130,14 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
aout_DateSet( &end_date, 0 ); aout_DateSet( &end_date, 0 );
/* Init the bitstream */ /* Init the bitstream */
InitBitstream( &p_dec->bit_stream, p_dec->p_fifo, if( InitBitstream( &p_dec->bit_stream, p_dec->p_fifo,
NULL, NULL ); NULL, NULL ) != VLC_SUCCESS )
{
msg_Err( p_fifo, "cannot initialize bitstream" );
DecoderError( p_fifo );
free( p_dec );
return -1;
}
/* decoder thread's main loop */ /* decoder thread's main loop */
while ( !p_dec->p_fifo->b_die && !p_dec->p_fifo->b_error ) while ( !p_dec->p_fifo->b_die && !p_dec->p_fifo->b_error )
...@@ -252,6 +258,7 @@ static void EndThread( dec_thread_t * p_dec ) ...@@ -252,6 +258,7 @@ static void EndThread( dec_thread_t * p_dec )
aout_DecDelete( p_dec->p_aout, p_dec->p_aout_input ); aout_DecDelete( p_dec->p_aout, p_dec->p_aout_input );
} }
CloseBitstream( &p_dec->bit_stream );
free( p_dec ); free( p_dec );
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* a52old.c: A52 decoder module main file * a52old.c: A52 decoder module main file
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: a52old.c,v 1.7 2002/09/26 22:40:20 massiot Exp $ * $Id: a52old.c,v 1.8 2002/10/27 16:58:14 gbazin Exp $
* *
* Authors: Michel Lespinasse <walken@zoy.org> * Authors: Michel Lespinasse <walken@zoy.org>
* *
...@@ -76,10 +76,10 @@ vlc_module_end(); ...@@ -76,10 +76,10 @@ vlc_module_end();
static int OpenDecoder( vlc_object_t *p_this ) static int OpenDecoder( vlc_object_t *p_this )
{ {
decoder_fifo_t *p_fifo = (decoder_fifo_t*) p_this; decoder_fifo_t *p_fifo = (decoder_fifo_t*) p_this;
if( p_fifo->i_fourcc != VLC_FOURCC('a','5','2',' ') if( p_fifo->i_fourcc != VLC_FOURCC('a','5','2',' ')
&& p_fifo->i_fourcc != VLC_FOURCC('a','5','2','b') ) && p_fifo->i_fourcc != VLC_FOURCC('a','5','2','b') )
{ {
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -330,10 +330,8 @@ static int InitThread( a52dec_t * p_a52dec ) ...@@ -330,10 +330,8 @@ static int InitThread( a52dec_t * p_a52dec )
/* /*
* Bit stream * Bit stream
*/ */
InitBitstream( &p_a52dec->bit_stream, p_a52dec->p_fifo, return( InitBitstream( &p_a52dec->bit_stream, p_a52dec->p_fifo,
BitstreamCallback, (void *) p_a52dec ); BitstreamCallback, (void *) p_a52dec ) );
return( 0 );
} }
/***************************************************************************** /*****************************************************************************
...@@ -377,6 +375,7 @@ static void EndThread (a52dec_t * p_a52dec) ...@@ -377,6 +375,7 @@ static void EndThread (a52dec_t * p_a52dec)
/* Free what's left of the decoder */ /* Free what's left of the decoder */
free( p_a52dec->imdct_orig ); free( p_a52dec->imdct_orig );
CloseBitstream( p_a52dec->bit_stream );
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* araw.c: Pseudo audio decoder; for raw pcm data * araw.c: Pseudo audio decoder; for raw pcm data
***************************************************************************** *****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN * Copyright (C) 2001, 2002 VideoLAN
* $Id: araw.c,v 1.4 2002/10/24 09:37:48 gbazin Exp $ * $Id: araw.c,v 1.5 2002/10/27 16:58:14 gbazin Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -315,7 +315,8 @@ static void DecodeThread( adec_thread_t *p_adec ) ...@@ -315,7 +315,8 @@ static void DecodeThread( adec_thread_t *p_adec )
pes_packet_t *p_pes; pes_packet_t *p_pes;
/* **** get samples count **** */ /* **** get samples count **** */
if( input_ExtractPES( p_adec->p_fifo, &p_pes ) < 0 ) input_ExtractPES( p_adec->p_fifo, &p_pes );
if( !p_pes )
{ {
p_adec->p_fifo->b_error = 1; p_adec->p_fifo->b_error = 1;
return; return;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* cinepak.c: cinepak video decoder * cinepak.c: cinepak video decoder
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: cinepak.c,v 1.5 2002/10/24 09:37:48 gbazin Exp $ * $Id: cinepak.c,v 1.6 2002/10/27 16:58:14 gbazin Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -162,12 +162,24 @@ static inline void __GetFrame( videodec_thread_t *p_vdec ) ...@@ -162,12 +162,24 @@ static inline void __GetFrame( videodec_thread_t *p_vdec )
data_packet_t *p_data; data_packet_t *p_data;
byte_t *p_buffer; byte_t *p_buffer;
p_pes = GetPES( p_vdec->p_fifo ); input_ExtractPES( p_vdec->p_fifo, &p_pes );
if( !p_pes )
{
p_vdec->p_framedata = NULL;
return;
}
p_vdec->i_pts = p_pes->i_pts; p_vdec->i_pts = p_pes->i_pts;
while( ( !p_pes->i_nb_data )||( !p_pes->i_pes_size ) ) while( ( !p_pes->i_nb_data )||( !p_pes->i_pes_size ) )
{ {
p_pes = NextPES( p_vdec->p_fifo ); input_DeletePES( p_vdec->p_fifo->p_packets_mgt, p_pes );
input_ExtractPES( p_vdec->p_fifo, &p_pes );
if( !p_pes )
{
p_vdec->p_framedata = NULL;
return;
}
} }
p_vdec->i_framesize = p_pes->i_pes_size; p_vdec->i_framesize = p_pes->i_pes_size;
if( p_pes->i_nb_data == 1 ) if( p_pes->i_nb_data == 1 )
...@@ -185,18 +197,19 @@ static inline void __GetFrame( videodec_thread_t *p_vdec ) ...@@ -185,18 +197,19 @@ static inline void __GetFrame( videodec_thread_t *p_vdec )
p_buffer += p_data->p_payload_end - p_data->p_payload_start; p_buffer += p_data->p_payload_end - p_data->p_payload_start;
p_data = p_data->p_next; p_data = p_data->p_next;
} while( p_data ); } while( p_data );
input_DeletePES( p_vdec->p_fifo->p_packets_mgt, p_pes );
} }
static inline void __NextFrame( videodec_thread_t *p_vdec ) static inline void __NextFrame( videodec_thread_t *p_vdec )
{ {
pes_packet_t *p_pes; pes_packet_t *p_pes;
p_pes = GetPES( p_vdec->p_fifo ); input_ExtractPES( p_vdec->p_fifo, &p_pes );
if( p_pes->i_nb_data != 1 ) if( p_pes && (p_pes->i_nb_data != 1) )
{ {
free( p_vdec->p_framedata ); /* FIXME keep this buffer */ free( p_vdec->p_framedata ); /* FIXME keep this buffer */
} }
NextPES( p_vdec->p_fifo ); input_DeletePES( p_vdec->p_fifo->p_packets_mgt, p_pes );
} }
static int cinepak_CheckVout( vout_thread_t *p_vout, static int cinepak_CheckVout( vout_thread_t *p_vout,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* dv.c: a decoder for DV video * dv.c: a decoder for DV video
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: dv.c,v 1.2 2002/08/12 09:34:15 sam Exp $ * $Id: dv.c,v 1.3 2002/10/27 16:58:13 gbazin Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -99,7 +99,14 @@ static int RunDecoder ( decoder_fifo_t *p_fifo ) ...@@ -99,7 +99,14 @@ static int RunDecoder ( decoder_fifo_t *p_fifo )
return -1; return -1;
} }
InitBitstream( &bit_stream, p_fifo, NULL, NULL ); if( InitBitstream( &bit_stream, p_fifo, NULL, NULL ) != VLC_SUCCESS )
{
msg_Err( p_fifo, "cannot initialise bitstream" );
free( p_buffer );
p_fifo->b_error = 1;
DecoderError( p_fifo );
return -1;
}
/* Fill the buffer */ /* Fill the buffer */
GetChunk( &bit_stream, p_buffer, i_data ); GetChunk( &bit_stream, p_buffer, i_data );
...@@ -260,6 +267,7 @@ static int RunDecoder ( decoder_fifo_t *p_fifo ) ...@@ -260,6 +267,7 @@ static int RunDecoder ( decoder_fifo_t *p_fifo )
} }
free( p_buffer ); free( p_buffer );
CloseBitstream( bit_stream );
if( p_fifo->b_error ) if( p_fifo->b_error )
{ {
...@@ -303,4 +311,3 @@ static pes_packet_t *GetFirstPES( decoder_fifo_t *p_fifo ) ...@@ -303,4 +311,3 @@ static pes_packet_t *GetFirstPES( decoder_fifo_t *p_fifo )
return p_pes; return p_pes;
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* decoder.c: AAC decoder using libfaad2 * decoder.c: AAC decoder using libfaad2
***************************************************************************** *****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN * Copyright (C) 2001, 2002 VideoLAN
* $Id: decoder.c,v 1.7 2002/10/24 09:37:47 gbazin Exp $ * $Id: decoder.c,v 1.8 2002/10/27 16:58:13 gbazin Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -154,7 +154,13 @@ static inline void __GetFrame( adec_thread_t *p_adec ) ...@@ -154,7 +154,13 @@ static inline void __GetFrame( adec_thread_t *p_adec )
data_packet_t *p_data; data_packet_t *p_data;
byte_t *p_buffer; byte_t *p_buffer;
p_pes = GetPES( p_adec->p_fifo ); input_ExtractPES( p_adec->p_fifo, &p_pes );
if( !p_pes )
{
p_adec->p_framedata = NULL;
return;
}
if( p_pes->i_pts ) if( p_pes->i_pts )
{ {
p_adec->pts = p_pes->i_pts; p_adec->pts = p_pes->i_pts;
...@@ -162,7 +168,13 @@ static inline void __GetFrame( adec_thread_t *p_adec ) ...@@ -162,7 +168,13 @@ static inline void __GetFrame( adec_thread_t *p_adec )
while( ( !p_pes->i_nb_data )||( !p_pes->i_pes_size ) ) while( ( !p_pes->i_nb_data )||( !p_pes->i_pes_size ) )
{ {
p_pes = NextPES( p_adec->p_fifo ); input_DeletePES( p_adec->p_fifo->p_packets_mgt, p_pes );
input_ExtractPES( p_adec->p_fifo, &p_pes );
if( !p_pes )
{
p_vdec->p_framedata = NULL;
return;
}
} }
p_adec->i_framesize = p_pes->i_pes_size; p_adec->i_framesize = p_pes->i_pes_size;
if( p_pes->i_nb_data == 1 ) if( p_pes->i_nb_data == 1 )
...@@ -194,11 +206,13 @@ static inline void __GetFrame( adec_thread_t *p_adec ) ...@@ -194,11 +206,13 @@ static inline void __GetFrame( adec_thread_t *p_adec )
p_buffer += p_data->p_payload_end - p_data->p_payload_start; p_buffer += p_data->p_payload_end - p_data->p_payload_start;
p_data = p_data->p_next; p_data = p_data->p_next;
} while( p_data ); } while( p_data );
input_DeletePES( p_adec->p_fifo->p_packets_mgt, p_pes );
} }
static inline void __NextFrame( adec_thread_t *p_adec ) static inline void __NextFrame( adec_thread_t *p_adec )
{ {
NextPES( p_adec->p_fifo ); input_ExtractPES( p_vdec->p_fifo, NULL );
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ffmpeg.c: video decoder using ffmpeg library * ffmpeg.c: video decoder using ffmpeg library
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: ffmpeg.c,v 1.10 2002/10/24 10:33:09 fenrir Exp $ * $Id: ffmpeg.c,v 1.11 2002/10/27 16:58:13 gbazin Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -795,7 +795,7 @@ static void DecodeThread( videodec_thread_t *p_vdec ) ...@@ -795,7 +795,7 @@ static void DecodeThread( videodec_thread_t *p_vdec )
/* too much late picture, won't decode /* too much late picture, won't decode
but break picture until a new I, and for mpeg4 ...*/ but break picture until a new I, and for mpeg4 ...*/
p_vdec->i_frame_late--; /* needed else it will never be decrease */ p_vdec->i_frame_late--; /* needed else it will never be decrease */
NextPES( p_vdec->p_fifo ); input_ExtractPES( p_vdec->p_fifo, NULL );
return; return;
} }
#else #else
...@@ -808,7 +808,7 @@ static void DecodeThread( videodec_thread_t *p_vdec ) ...@@ -808,7 +808,7 @@ static void DecodeThread( videodec_thread_t *p_vdec )
/* too much late picture, won't decode /* too much late picture, won't decode
but break picture until a new I, and for mpeg4 ...*/ but break picture until a new I, and for mpeg4 ...*/
p_vdec->i_frame_late--; /* needed else it will never be decrease */ p_vdec->i_frame_late--; /* needed else it will never be decrease */
NextPES( p_vdec->p_fifo ); input_ExtractPES( p_vdec->p_fifo, NULL );
return; return;
} }
#endif #endif
...@@ -823,7 +823,8 @@ static void DecodeThread( videodec_thread_t *p_vdec ) ...@@ -823,7 +823,8 @@ static void DecodeThread( videodec_thread_t *p_vdec )
do do
{ {
if( !( p_pes = GetPES( p_vdec->p_fifo ) ) ) input_ExtractPES( p_vdec->p_fifo, &p_pes );
if( !p_pes )
{ {
p_vdec->p_fifo->b_error = 1; p_vdec->p_fifo->b_error = 1;
return; return;
...@@ -842,7 +843,7 @@ static void DecodeThread( videodec_thread_t *p_vdec ) ...@@ -842,7 +843,7 @@ static void DecodeThread( videodec_thread_t *p_vdec )
GetPESData( p_vdec->p_buffer, p_vdec->i_buffer, p_pes ); GetPESData( p_vdec->p_buffer, p_vdec->i_buffer, p_pes );
} }
NextPES( p_vdec->p_fifo ); input_DeletePES( p_vdec->p_fifo->p_packets_mgt, p_pes );
} while( i_frame_size <= 0 ); } while( i_frame_size <= 0 );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* lpcm.c: lpcm decoder module * lpcm.c: lpcm decoder module
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: lpcm.c,v 1.5 2002/10/15 23:10:54 massiot Exp $ * $Id: lpcm.c,v 1.6 2002/10/27 16:58:14 gbazin Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* Henri Fallon <henri@videolan.org> * Henri Fallon <henri@videolan.org>
...@@ -121,8 +121,14 @@ static int RunDecoder( decoder_fifo_t * p_fifo ) ...@@ -121,8 +121,14 @@ static int RunDecoder( decoder_fifo_t * p_fifo )
p_dec->p_fifo = p_fifo; p_dec->p_fifo = p_fifo;
/* Init the bitstream */ /* Init the bitstream */
InitBitstream( &p_dec->bit_stream, p_dec->p_fifo, if( InitBitstream( &p_dec->bit_stream, p_dec->p_fifo,
NULL, NULL ); NULL, NULL ) != VLC_SUCCESS )
{
msg_Err( p_fifo, "cannot initialize bitstream" );
DecoderError( p_fifo );
EndThread( p_dec );
return -1;
}
/* FIXME : I suppose the number of channel and sampling rate /* FIXME : I suppose the number of channel and sampling rate
* are somewhere in the headers */ * are somewhere in the headers */
...@@ -140,6 +146,7 @@ static int RunDecoder( decoder_fifo_t * p_fifo ) ...@@ -140,6 +146,7 @@ static int RunDecoder( decoder_fifo_t * p_fifo )
{ {
msg_Err( p_dec->p_fifo, "failed to create aout fifo" ); msg_Err( p_dec->p_fifo, "failed to create aout fifo" );
p_dec->p_fifo->b_error = 1; p_dec->p_fifo->b_error = 1;
EndThread( p_dec );
return( -1 ); return( -1 );
} }
...@@ -220,5 +227,6 @@ static void EndThread( dec_thread_t * p_dec ) ...@@ -220,5 +227,6 @@ static void EndThread( dec_thread_t * p_dec )
aout_DecDelete( p_dec->p_aout, p_dec->p_aout_input ); aout_DecDelete( p_dec->p_aout, p_dec->p_aout_input );
} }
CloseBitstream( &p_dec->bit_stream );
free( p_dec ); free( p_dec );
} }
...@@ -136,8 +136,6 @@ static int RunDecoder( decoder_fifo_t *p_fifo ) ...@@ -136,8 +136,6 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
*****************************************************************************/ *****************************************************************************/
static int InitThread( mad_adec_thread_t * p_dec ) static int InitThread( mad_adec_thread_t * p_dec )
{ {
decoder_fifo_t * p_fifo = p_dec->p_fifo;
/* Initialize the thread properties */ /* Initialize the thread properties */
p_dec->p_aout = NULL; p_dec->p_aout = NULL;
p_dec->p_aout_input = NULL; p_dec->p_aout_input = NULL;
...@@ -165,21 +163,7 @@ static int InitThread( mad_adec_thread_t * p_dec ) ...@@ -165,21 +163,7 @@ static int InitThread( mad_adec_thread_t * p_dec )
* Initialize the input properties * Initialize the input properties
*/ */
/* Get the first data packet. */ return InitBitstream( &p_dec->bit_stream, p_dec->p_fifo, NULL, NULL );
vlc_mutex_lock( &p_fifo->data_lock );
while ( p_fifo->p_first == NULL )
{
if ( p_fifo->b_die )
{
vlc_mutex_unlock( &p_fifo->data_lock );
return VLC_EGENERIC;
}
vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock );
}
vlc_mutex_unlock( &p_fifo->data_lock );
p_dec->p_data = p_fifo->p_first->p_first;
return VLC_SUCCESS;
} }
/***************************************************************************** /*****************************************************************************
...@@ -196,6 +180,6 @@ static void EndThread (mad_adec_thread_t * p_dec) ...@@ -196,6 +180,6 @@ static void EndThread (mad_adec_thread_t * p_dec)
/* mad_decoder_finish releases the memory allocated inside the struct */ /* mad_decoder_finish releases the memory allocated inside the struct */
mad_decoder_finish( &p_dec->libmad_decoder ); mad_decoder_finish( &p_dec->libmad_decoder );
CloseBitstream( &p_dec->bit_stream );
free( p_dec ); free( p_dec );
} }
...@@ -42,7 +42,7 @@ typedef struct mad_adec_thread_s ...@@ -42,7 +42,7 @@ typedef struct mad_adec_thread_s
* Input properties * Input properties
*/ */
decoder_fifo_t * p_fifo; /* stores the PES stream data */ decoder_fifo_t * p_fifo; /* stores the PES stream data */
data_packet_t * p_data; bit_stream_t bit_stream; /* handle PES stream at the bit level */
/* Store i_pts for syncing audio frames */ /* Store i_pts for syncing audio frames */
mtime_t i_current_pts, i_next_pts; mtime_t i_current_pts, i_next_pts;
......
...@@ -81,7 +81,7 @@ enum mad_flow libmad_input( void *p_data, struct mad_stream *p_stream ) ...@@ -81,7 +81,7 @@ enum mad_flow libmad_input( void *p_data, struct mad_stream *p_stream )
i_wanted = MAD_BUFFER_MDLEN - i_left; i_wanted = MAD_BUFFER_MDLEN - i_left;
/* Store timestamp for next frame */ /* Store timestamp for next frame */
p_dec->i_next_pts = p_dec->p_fifo->p_first->i_pts; p_dec->i_next_pts = p_dec->bit_stream.p_pes->i_pts;
} }
else else
{ {
...@@ -89,27 +89,28 @@ enum mad_flow libmad_input( void *p_data, struct mad_stream *p_stream ) ...@@ -89,27 +89,28 @@ enum mad_flow libmad_input( void *p_data, struct mad_stream *p_stream )
i_left = 0; i_left = 0;
/* Store timestamp for this frame */ /* Store timestamp for this frame */
p_dec->i_current_pts = p_dec->p_fifo->p_first->i_pts; p_dec->i_current_pts = p_dec->bit_stream.p_pes->i_pts;
} }
p_dec->p_fifo->p_first->i_pts = 0;
/* Fill-in the buffer. If an error occurs print a message and leave /* Fill-in the buffer. If an error occurs print a message and leave
* the decoding loop. If the end of stream is reached we also leave * the decoding loop. If the end of stream is reached we also leave
* the loop but the return status is left untouched. */ * the loop but the return status is left untouched. */
if( i_wanted > p_dec->p_data->p_payload_end if( i_wanted > p_dec->bit_stream.p_data->p_payload_end
- p_dec->p_data->p_payload_start ) - p_dec->bit_stream.p_data->p_payload_start )
{ {
i_wanted = p_dec->p_data->p_payload_end i_wanted = p_dec->bit_stream.p_data->p_payload_end
- p_dec->p_data->p_payload_start; - p_dec->bit_stream.p_data->p_payload_start;
memcpy( p_dec->buffer + i_left, memcpy( p_dec->buffer + i_left,
p_dec->p_data->p_payload_start, i_wanted ); p_dec->bit_stream.p_data->p_payload_start, i_wanted );
NextDataPacket( p_dec->p_fifo, &p_dec->p_data ); NextDataPacket( p_dec->p_fifo, &p_dec->bit_stream );
/* No need to check that p_dec->bit_stream->p_data is valid
* since we check later on for b_die and b_error */
} }
else else
{ {
memcpy( p_dec->buffer + i_left, memcpy( p_dec->buffer + i_left,
p_dec->p_data->p_payload_start, i_wanted ); p_dec->bit_stream.p_data->p_payload_start, i_wanted );
p_dec->p_data->p_payload_start += i_wanted; p_dec->bit_stream.p_data->p_payload_start += i_wanted;
} }
if ( p_dec->p_fifo->b_die ) if ( p_dec->p_fifo->b_die )
...@@ -354,7 +355,7 @@ enum mad_flow libmad_error( void *data, struct mad_stream *p_libmad_stream, ...@@ -354,7 +355,7 @@ enum mad_flow libmad_error( void *data, struct mad_stream *p_libmad_stream,
/**************************************************************************** /****************************************************************************
* Print human readable informations about an audio MPEG frame. * * Print human readable informations about an audio MPEG frame.
****************************************************************************/ ****************************************************************************/
static void PrintFrameInfo(struct mad_header *Header) static void PrintFrameInfo(struct mad_header *Header)
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* decoder.c: MPEG audio decoder thread * decoder.c: MPEG audio decoder thread
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: decoder.c,v 1.6 2002/10/15 23:10:54 massiot Exp $ * $Id: decoder.c,v 1.7 2002/10/27 16:58:13 gbazin Exp $
* *
* Authors: Michel Kaempf <maxx@via.ecp.fr> * Authors: Michel Kaempf <maxx@via.ecp.fr>
* Michel Lespinasse <walken@via.ecp.fr> * Michel Lespinasse <walken@via.ecp.fr>
...@@ -109,7 +109,13 @@ static int RunDecoder( decoder_fifo_t *p_fifo ) ...@@ -109,7 +109,13 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
/* /*
* Initialize bit stream * Initialize bit stream
*/ */
InitBitstream( &p_dec->bit_stream, p_dec->p_fifo, NULL, NULL ); if( InitBitstream( &p_dec->bit_stream, p_dec->p_fifo, NULL, NULL )
!= VLC_SUCCESS )
{
msg_Err( p_fifo, "cannot initialize bitstream" );
DecoderError( p_fifo );
return 0;
}
/* We do not create the audio output fifo now, but /* We do not create the audio output fifo now, but
it will be created when the first frame is received */ it will be created when the first frame is received */
...@@ -242,6 +248,8 @@ static void EndThread ( adec_thread_t *p_dec ) ...@@ -242,6 +248,8 @@ static void EndThread ( adec_thread_t *p_dec )
} }
CloseBitstream( &p_dec->bit_stream );
/* Destroy descriptor */ /* Destroy descriptor */
free( p_dec ); free( p_dec );
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* video_parser.c : video parser thread * video_parser.c : video parser thread
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: parser.c,v 1.4 2002/08/12 09:34:15 sam Exp $ * $Id: parser.c,v 1.5 2002/10/27 16:58:13 gbazin Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr> * Samuel Hocevar <sam@via.ecp.fr>
...@@ -231,8 +231,14 @@ static int InitThread( vpar_thread_t *p_vpar ) ...@@ -231,8 +231,14 @@ static int InitThread( vpar_thread_t *p_vpar )
p_vpar->pf_idct_copy = ((void**)p_vpar->p_fifo->p_private)[5]; p_vpar->pf_idct_copy = ((void**)p_vpar->p_fifo->p_private)[5];
/* Initialize input bitstream */ /* Initialize input bitstream */
InitBitstream( &p_vpar->bit_stream, p_vpar->p_fifo, if( InitBitstream( &p_vpar->bit_stream, p_vpar->p_fifo,
BitstreamCallback, (void *)p_vpar ); BitstreamCallback, (void *)p_vpar ) != VLC_SUCCESS )
{
msg_Err( p_vpar->p_fifo, "cannot initialize bitstream" );
module_Unneed( p_vpar->p_fifo, p_vpar->p_motion );
free( p_vpar );
return( -1 );
}
/* Initialize parsing data */ /* Initialize parsing data */
p_vpar->sequence.p_forward = NULL; p_vpar->sequence.p_forward = NULL;
...@@ -383,6 +389,7 @@ static void EndThread( vpar_thread_t *p_vpar ) ...@@ -383,6 +389,7 @@ static void EndThread( vpar_thread_t *p_vpar )
module_Unneed( p_vpar->p_fifo, p_vpar->p_idct ); module_Unneed( p_vpar->p_fifo, p_vpar->p_idct );
module_Unneed( p_vpar->p_fifo, p_vpar->p_motion ); module_Unneed( p_vpar->p_fifo, p_vpar->p_motion );
CloseBitstream( &p_vpar->bit_stream );
free( p_vpar ); free( p_vpar );
} }
...@@ -399,9 +406,9 @@ static void BitstreamCallback ( bit_stream_t * p_bit_stream, ...@@ -399,9 +406,9 @@ static void BitstreamCallback ( bit_stream_t * p_bit_stream,
if( b_new_pes ) if( b_new_pes )
{ {
p_vpar->sequence.i_current_rate = p_vpar->sequence.i_current_rate =
p_bit_stream->p_decoder_fifo->p_first->i_rate; p_bit_stream->p_pes->i_rate;
if( p_bit_stream->p_decoder_fifo->p_first->b_discontinuity ) if( p_bit_stream->p_pes->b_discontinuity )
{ {
/* Escape the current picture and reset the picture predictors. */ /* Escape the current picture and reset the picture predictors. */
p_vpar->sequence.b_expect_discontinuity = 1; p_vpar->sequence.b_expect_discontinuity = 1;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* spudec.c : SPU decoder thread * spudec.c : SPU decoder thread
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2001 VideoLAN * Copyright (C) 2000-2001 VideoLAN
* $Id: spudec.c,v 1.4 2002/09/14 20:50:24 stef Exp $ * $Id: spudec.c,v 1.5 2002/10/27 16:58:13 gbazin Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -166,10 +166,8 @@ static int InitThread( spudec_thread_t *p_spudec ) ...@@ -166,10 +166,8 @@ static int InitThread( spudec_thread_t *p_spudec )
} }
while( 1 ); while( 1 );
InitBitstream( &p_spudec->bit_stream, p_spudec->p_fifo, NULL, NULL ); return InitBitstream( &p_spudec->bit_stream, p_spudec->p_fifo,
NULL, NULL );
/* Mark thread as running and return */
return 0;
} }
/***************************************************************************** /*****************************************************************************
...@@ -201,6 +199,7 @@ static void EndThread( spudec_thread_t *p_spudec ) ...@@ -201,6 +199,7 @@ static void EndThread( spudec_thread_t *p_spudec )
vlc_object_release( p_spudec->p_vout ); vlc_object_release( p_spudec->p_vout );
} }
CloseBitstream( &p_spudec->bit_stream );
free( p_spudec ); free( p_spudec );
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vorbis.c: vorbis decoder module making use of libvorbis. * vorbis.c: vorbis decoder module making use of libvorbis.
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: vorbis.c,v 1.1 2002/10/24 09:30:47 gbazin Exp $ * $Id: vorbis.c,v 1.2 2002/10/27 16:58:14 gbazin Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -61,7 +61,8 @@ typedef struct dec_thread_t ...@@ -61,7 +61,8 @@ typedef struct dec_thread_t
/* /*
* Input properties * Input properties
*/ */
decoder_fifo_t * p_fifo; /* stores the PES stream data */ decoder_fifo_t *p_fifo; /* stores the PES stream data */
pes_packet_t *p_pes; /* current PES we are decoding */
/* /*
* Output properties * Output properties
...@@ -81,7 +82,7 @@ static int RunDecoder ( decoder_fifo_t * ); ...@@ -81,7 +82,7 @@ static int RunDecoder ( decoder_fifo_t * );
static void CloseDecoder ( dec_thread_t * ); static void CloseDecoder ( dec_thread_t * );
static void DecodePacket ( dec_thread_t * ); static void DecodePacket ( dec_thread_t * );
static int GetOggPacket ( dec_thread_t *, ogg_packet *, mtime_t *, int ); static int GetOggPacket ( dec_thread_t *, ogg_packet *, mtime_t * );
static void Interleave ( float *, const float **, int, int ); static void Interleave ( float *, const float **, int, int );
...@@ -129,12 +130,13 @@ static int RunDecoder( decoder_fifo_t * p_fifo ) ...@@ -129,12 +130,13 @@ static int RunDecoder( decoder_fifo_t * p_fifo )
/* Initialize the thread properties */ /* Initialize the thread properties */
p_dec->p_fifo = p_fifo; p_dec->p_fifo = p_fifo;
p_dec->p_pes = NULL;
/* Take care of the initial Vorbis header */ /* Take care of the initial Vorbis header */
vorbis_info_init( &p_dec->vi ); vorbis_info_init( &p_dec->vi );
vorbis_comment_init( &p_dec->vc ); vorbis_comment_init( &p_dec->vc );
if( GetOggPacket( p_dec, &oggpacket, &i_pts, 0 ) != VLC_SUCCESS ) if( GetOggPacket( p_dec, &oggpacket, &i_pts ) != VLC_SUCCESS )
goto error; goto error;
oggpacket.b_o_s = 1; /* yes this actually is a b_o_s packet :) */ oggpacket.b_o_s = 1; /* yes this actually is a b_o_s packet :) */
...@@ -148,7 +150,7 @@ static int RunDecoder( decoder_fifo_t * p_fifo ) ...@@ -148,7 +150,7 @@ static int RunDecoder( decoder_fifo_t * p_fifo )
/* The next two packets in order are the comment and codebook headers. /* The next two packets in order are the comment and codebook headers.
We need to watch out that these packets are not missing as a We need to watch out that these packets are not missing as a
missing or corrupted header is fatal. */ missing or corrupted header is fatal. */
if( GetOggPacket( p_dec, &oggpacket, &i_pts, 1 ) != VLC_SUCCESS ) if( GetOggPacket( p_dec, &oggpacket, &i_pts ) != VLC_SUCCESS )
goto error; goto error;
if( vorbis_synthesis_headerin( &p_dec->vi, &p_dec->vc, &oggpacket ) < 0 ) if( vorbis_synthesis_headerin( &p_dec->vi, &p_dec->vc, &oggpacket ) < 0 )
...@@ -157,7 +159,7 @@ static int RunDecoder( decoder_fifo_t * p_fifo ) ...@@ -157,7 +159,7 @@ static int RunDecoder( decoder_fifo_t * p_fifo )
goto error; goto error;
} }
if( GetOggPacket( p_dec, &oggpacket, &i_pts, 1 ) != VLC_SUCCESS ) if( GetOggPacket( p_dec, &oggpacket, &i_pts ) != VLC_SUCCESS )
goto error; goto error;
if( vorbis_synthesis_headerin( &p_dec->vi, &p_dec->vc, &oggpacket ) < 0 ) if( vorbis_synthesis_headerin( &p_dec->vi, &p_dec->vc, &oggpacket ) < 0 )
...@@ -235,7 +237,7 @@ static void DecodePacket( dec_thread_t *p_dec ) ...@@ -235,7 +237,7 @@ static void DecodePacket( dec_thread_t *p_dec )
int i_samples; int i_samples;
mtime_t i_pts; mtime_t i_pts;
if( GetOggPacket( p_dec, &oggpacket, &i_pts, 1 ) != VLC_SUCCESS ) if( GetOggPacket( p_dec, &oggpacket, &i_pts ) != VLC_SUCCESS )
{ {
/* This should mean an eos */ /* This should mean an eos */
return; return;
...@@ -297,23 +299,24 @@ static void DecodePacket( dec_thread_t *p_dec ) ...@@ -297,23 +299,24 @@ static void DecodePacket( dec_thread_t *p_dec )
* Returns VLC_EGENERIC in case of eof. * Returns VLC_EGENERIC in case of eof.
*****************************************************************************/ *****************************************************************************/
static int GetOggPacket( dec_thread_t *p_dec, ogg_packet *p_oggpacket, static int GetOggPacket( dec_thread_t *p_dec, ogg_packet *p_oggpacket,
mtime_t *p_pts, int b_next ) mtime_t *p_pts )
{ {
pes_packet_t *p_pes; if( p_dec->p_pes ) input_DeletePES( p_dec->p_fifo->p_packets_mgt,
p_dec->p_pes );
if( b_next ) NextPES( p_dec->p_fifo ); input_ExtractPES( p_dec->p_fifo, &p_dec->p_pes );
p_pes = GetPES( p_dec->p_fifo ); if( !p_dec->p_pes ) return VLC_EGENERIC;
p_oggpacket->packet = p_pes->p_first->p_payload_start; p_oggpacket->packet = p_dec->p_pes->p_first->p_payload_start;
p_oggpacket->bytes = p_pes->i_pes_size; p_oggpacket->bytes = p_dec->p_pes->i_pes_size;
p_oggpacket->granulepos = p_pes->i_dts; p_oggpacket->granulepos = p_dec->p_pes->i_dts;
p_oggpacket->b_o_s = 0; p_oggpacket->b_o_s = 0;
p_oggpacket->e_o_s = 0; p_oggpacket->e_o_s = 0;
p_oggpacket->packetno = 0; p_oggpacket->packetno = 0;
*p_pts = p_pes->i_pts; *p_pts = p_dec->p_pes->i_pts;
return p_pes ? VLC_SUCCESS : VLC_EGENERIC; return VLC_SUCCESS;
} }
/***************************************************************************** /*****************************************************************************
...@@ -345,6 +348,8 @@ static void CloseDecoder( dec_thread_t * p_dec ) ...@@ -345,6 +348,8 @@ static void CloseDecoder( dec_thread_t * p_dec )
if( p_dec ) if( p_dec )
{ {
if( p_dec->p_pes )
input_DeletePES( p_dec->p_fifo->p_packets_mgt, p_dec->p_pes );
vorbis_block_clear( &p_dec->vb ); vorbis_block_clear( &p_dec->vb );
vorbis_dsp_clear( &p_dec->vd ); vorbis_dsp_clear( &p_dec->vd );
vorbis_comment_clear( &p_dec->vc ); vorbis_comment_clear( &p_dec->vc );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* dec_dummy.c: dummy decoder plugin for vlc. * dec_dummy.c: dummy decoder plugin for vlc.
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: decoder.c,v 1.2 2002/08/04 17:40:49 sam Exp $ * $Id: decoder.c,v 1.3 2002/10/27 16:58:13 gbazin Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -81,7 +81,14 @@ static int Run ( decoder_fifo_t *p_fifo ) ...@@ -81,7 +81,14 @@ static int Run ( decoder_fifo_t *p_fifo )
msg_Dbg( p_fifo, "dumping stream to file `%s'", psz_file ); msg_Dbg( p_fifo, "dumping stream to file `%s'", psz_file );
InitBitstream( &bit_stream, p_fifo, NULL, NULL ); if( InitBitstream( &bit_stream, p_fifo, NULL, NULL ) != VLC_SUCCESS )
{
msg_Err( p_fifo, "cannot initialize bitstream" );
p_fifo->b_error = 1;
DecoderError( p_fifo );
close( i_fd );
return -1;
}
while( !p_fifo->b_die && !p_fifo->b_error ) while( !p_fifo->b_die && !p_fifo->b_error )
{ {
...@@ -107,6 +114,7 @@ static int Run ( decoder_fifo_t *p_fifo ) ...@@ -107,6 +114,7 @@ static int Run ( decoder_fifo_t *p_fifo )
} }
close( i_fd ); close( i_fd );
CloseBitstream( &bit_stream );
if( p_fifo->b_error ) if( p_fifo->b_error )
{ {
...@@ -116,4 +124,3 @@ static int Run ( decoder_fifo_t *p_fifo ) ...@@ -116,4 +124,3 @@ static int Run ( decoder_fifo_t *p_fifo )
return 0; return 0;
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* input_dec.c: Functions for the management of decoders * input_dec.c: Functions for the management of decoders
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: input_dec.c,v 1.47 2002/09/01 21:20:29 massiot Exp $ * $Id: input_dec.c,v 1.48 2002/10/27 16:58:12 gbazin Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -155,6 +155,76 @@ void input_DecodePES( decoder_fifo_t * p_decoder_fifo, pes_packet_t * p_pes ) ...@@ -155,6 +155,76 @@ void input_DecodePES( decoder_fifo_t * p_decoder_fifo, pes_packet_t * p_pes )
vlc_mutex_unlock( &p_decoder_fifo->data_lock ); vlc_mutex_unlock( &p_decoder_fifo->data_lock );
} }
/****************************************************************************
* input_ExtractPES
*****************************************************************************
* Extract a PES from the fifo. If pp_pes is NULL then the PES is just
* deleted, otherwise *pp_pes will point to this PES.
****************************************************************************/
void input_ExtractPES( decoder_fifo_t *p_fifo, pes_packet_t **pp_pes )
{
pes_packet_t *p_pes;
vlc_mutex_lock( &p_fifo->data_lock );
if( p_fifo->p_first == NULL )
{
if( p_fifo->b_die )
{
vlc_mutex_unlock( &p_fifo->data_lock );
if( pp_pes ) *pp_pes = NULL;
return;
}
/* Signal the input thread we're waiting. This is only
* needed in case of slave clock (ES plug-in) but it won't
* harm. */
vlc_cond_signal( &p_fifo->data_wait );
/* Wait for the input to tell us when we received a packet. */
vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock );
}
p_pes = p_fifo->p_first;
p_fifo->p_first = p_pes->p_next;
p_pes->p_next = NULL;
p_fifo->i_depth--;
if( !p_fifo->p_first )
{
/* 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 );
if( pp_pes )
*pp_pes = p_pes;
else
input_DeletePES( p_fifo->p_packets_mgt, p_pes );
}
/****************************************************************************
* input_FlushPESFifo
*****************************************************************************
* Empties the PES fifo of the decoder.
****************************************************************************/
void input_FlushPESFifo( decoder_fifo_t *p_fifo )
{
pes_packet_t * p_pes;
vlc_mutex_lock( &p_fifo->data_lock );
while( p_fifo->p_first )
{
p_pes = p_fifo->p_first;
p_fifo->p_first = p_fifo->p_first->p_next;
input_DeletePES( p_fifo->p_packets_mgt, p_pes );
}
/* 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 );
}
/***************************************************************************** /*****************************************************************************
* input_EscapeDiscontinuity: send a NULL packet to the decoders * input_EscapeDiscontinuity: send a NULL packet to the decoders
*****************************************************************************/ *****************************************************************************/
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment