Commit abde4bbf authored by Christophe Massiot's avatar Christophe Massiot

* Changed the way decoder_fifo_t works ;

* Minor optimizations in the Next Generation Buffer Manager.
parent ea6f82b8
......@@ -118,7 +118,7 @@ PLUGINS_TARGETS := ac3_adec/ac3_adec \
# C Objects
#
INTERFACE := main interface intf_msg intf_playlist
INPUT := input input_ext-dec input_ext-intf input_dec input_programs input_netlist input_clock mpeg_system
INPUT := input input_ext-dec input_ext-intf input_dec input_programs input_clock mpeg_system
VIDEO_OUTPUT := video_output video_text vout_pictures vout_subpictures
AUDIO_OUTPUT := audio_output aout_ext-dec aout_u8 aout_s8 aout_u16 aout_s16 aout_spdif
MISC := mtime tests modules netutils iso_lang
......
......@@ -3,7 +3,7 @@
* Collection of useful common types and macros definitions
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: common.h,v 1.60 2001/12/19 03:50:22 sam Exp $
* $Id: common.h,v 1.61 2001/12/27 01:49:34 massiot Exp $
*
* Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr>
......@@ -525,18 +525,6 @@ typedef struct module_symbols_s
struct pgrm_descriptor_s *,
mtime_t );
int ( * input_NetlistInit ) ( struct input_thread_s *,
int, int, int, size_t, int );
struct iovec * ( * input_NetlistGetiovec ) ( void * p_method_data );
void ( * input_NetlistMviovec ) ( void * , int,
struct data_packet_s **);
struct data_packet_s * ( * input_NetlistNewPacket ) ( void *, size_t );
struct data_packet_s * ( * input_NetlistNewPtr ) ( void * );
struct pes_packet_s * ( * input_NetlistNewPES ) ( void * );
void ( * input_NetlistDeletePacket ) ( void *, struct data_packet_s * );
void ( * input_NetlistDeletePES ) ( void *, struct pes_packet_s * );
void ( * input_NetlistEnd ) ( struct input_thread_s * );
struct aout_fifo_s * ( * aout_CreateFifo )
( int, int, long, long, long, void * );
void ( * aout_DestroyFifo ) ( struct aout_fifo_s * );
......
/*****************************************************************************
* input_ext-dec.h: structures exported to the VideoLAN decoders
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: input_ext-dec.h,v 1.45 2001/12/19 10:00:00 massiot Exp $
* Copyright (C) 1999-2000 VideoLAN
* $Id: input_ext-dec.h,v 1.46 2001/12/27 01:49:34 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Michel Kaempf <maxx@via.ecp.fr>
......@@ -42,9 +42,6 @@
*****************************************************************************/
typedef struct data_packet_s
{
/* Nothing before this line, the code relies on that */
byte_t * p_buffer; /* raw data packet */
/* Decoders information */
byte_t * p_demux_start; /* start of the PS or TS packet */
byte_t * p_payload_start;
......@@ -52,12 +49,12 @@ typedef struct data_packet_s
byte_t * p_payload_end; /* guess ? :-) */
boolean_t b_discard_payload; /* is the packet messed up ? */
int * pi_refcount;
unsigned int i_size; /* buffer size */
long l_size; /* buffer size */
/* Used to chain the TS packets that carry data for a same PES or PSI */
struct data_packet_s * p_next;
/* Buffer manager information */
byte_t * p_buffer; /* raw data packet */
unsigned int i_size; /* buffer size */
} data_packet_t;
/*****************************************************************************
......@@ -81,13 +78,13 @@ typedef struct pes_packet_s
int i_pes_size; /* size of the current PES packet */
/* Pointers to packets (packets are then linked by the p_prev and
p_next fields of the data_packet_t struct) */
/* Chained list to packets */
data_packet_t * p_first; /* The first packet contained by this
* PES (used by decoders). */
data_packet_t * p_last; /* The last packet contained by this
PES (used by the buffer allocator) */
int i_nb_data;
int i_nb_data; /* Number of data packets in the chained
list */
/* Chained list used by the input buffers manager */
struct pes_packet_s * p_next;
......@@ -105,9 +102,9 @@ typedef struct decoder_fifo_s
vlc_cond_t data_wait; /* fifo data conditional variable */
/* Data */
pes_packet_t * buffer[FIFO_SIZE + 1];
int i_start;
int i_end;
pes_packet_t * p_first;
pes_packet_t ** pp_last;
int i_depth; /* number of PES packets in the stack */
/* Communication interface between input and decoders */
boolean_t b_die; /* the decoder should return now */
......@@ -118,18 +115,6 @@ typedef struct decoder_fifo_s
/* function to use when releasing a PES */
} decoder_fifo_t;
/* Macros to manage a decoder_fifo_t structure. Please remember to take
* data_lock before using them. */
#define DECODER_FIFO_ISEMPTY( fifo ) ( (fifo).i_start == (fifo).i_end )
#define DECODER_FIFO_ISFULL( fifo ) ( ( ((fifo).i_end + 1 - (fifo).i_start)\
& FIFO_SIZE ) == 0 )
#define DECODER_FIFO_START( fifo ) ( (fifo).buffer[ (fifo).i_start ] )
#define DECODER_FIFO_INCSTART( fifo ) ( (fifo).i_start = ((fifo).i_start + 1)\
& FIFO_SIZE )
#define DECODER_FIFO_END( fifo ) ( (fifo).buffer[ (fifo).i_end ] )
#define DECODER_FIFO_INCEND( fifo ) ( (fifo).i_end = ((fifo).i_end + 1) \
& FIFO_SIZE )
/*****************************************************************************
* bit_fifo_t : bit fifo descriptor
*****************************************************************************
......
This diff is collapsed.
......@@ -75,15 +75,6 @@
(p_symbols)->input_DemuxTS = input_DemuxTS; \
(p_symbols)->input_DemuxPSI = input_DemuxPSI; \
(p_symbols)->input_ClockManageControl = input_ClockManageControl; \
(p_symbols)->input_NetlistInit = input_NetlistInit; \
(p_symbols)->input_NetlistGetiovec = input_NetlistGetiovec; \
(p_symbols)->input_NetlistMviovec = input_NetlistMviovec; \
(p_symbols)->input_NetlistNewPacket = input_NetlistNewPacket; \
(p_symbols)->input_NetlistNewPtr = input_NetlistNewPtr; \
(p_symbols)->input_NetlistNewPES = input_NetlistNewPES; \
(p_symbols)->input_NetlistDeletePacket = input_NetlistDeletePacket; \
(p_symbols)->input_NetlistDeletePES = input_NetlistDeletePES; \
(p_symbols)->input_NetlistEnd = input_NetlistEnd; \
(p_symbols)->aout_CreateFifo = aout_CreateFifo; \
(p_symbols)->aout_DestroyFifo = aout_DestroyFifo; \
(p_symbols)->vout_CreateThread = vout_CreateThread; \
......@@ -185,16 +176,6 @@
# define input_ClockManageControl p_symbols->input_ClockManageControl
# define input_NetlistInit p_symbols->input_NetlistInit
# define input_NetlistGetiovec p_symbols->input_NetlistGetiovec
# define input_NetlistMviovec p_symbols->input_NetlistMviovec
# define input_NetlistNewPacket p_symbols->input_NetlistNewPacket
# define input_NetlistNewPtr p_symbols->input_NetlistNewPtr
# define input_NetlistNewPES p_symbols->input_NetlistNewPES
# define input_NetlistDeletePacket p_symbols->input_NetlistDeletePacket
# define input_NetlistDeletePES p_symbols->input_NetlistDeletePES
# define input_NetlistEnd p_symbols->input_NetlistEnd
# define aout_CreateFifo p_symbols->aout_CreateFifo
# define aout_DestroyFifo p_symbols->aout_DestroyFifo
......
......@@ -2,7 +2,7 @@
* ac3_adec.c: ac3 decoder module main file
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: ac3_adec.c,v 1.8 2001/12/16 16:18:36 sam Exp $
* $Id: ac3_adec.c,v 1.9 2001/12/27 01:49:34 massiot Exp $
*
* Authors: Michel Lespinasse <walken@zoy.org>
*
......@@ -169,12 +169,12 @@ static int ac3_adec_Run ( decoder_config_t * p_config )
sync = 1;
}
if (DECODER_FIFO_START(*p_ac3thread->p_fifo)->i_pts)
if (p_ac3thread->p_fifo->p_first->i_pts)
{
p_ac3thread->p_aout_fifo->date[
p_ac3thread->p_aout_fifo->l_end_frame] =
DECODER_FIFO_START(*p_ac3thread->p_fifo)->i_pts;
DECODER_FIFO_START(*p_ac3thread->p_fifo)->i_pts = 0;
p_ac3thread->p_fifo->p_first->i_pts;
p_ac3thread->p_fifo->p_first->i_pts = 0;
} else {
p_ac3thread->p_aout_fifo->date[
p_ac3thread->p_aout_fifo->l_end_frame] =
......@@ -384,13 +384,9 @@ static void ac3_adec_ErrorThread (ac3dec_thread_t * p_ac3thread)
while (!p_ac3thread->p_fifo->b_die)
{
/* Trash all received PES packets */
while (!DECODER_FIFO_ISEMPTY(*p_ac3thread->p_fifo))
{
p_ac3thread->p_fifo->pf_delete_pes(
p_ac3thread->p_fifo->p_packets_mgt,
DECODER_FIFO_START(*p_ac3thread->p_fifo));
DECODER_FIFO_INCSTART (*p_ac3thread->p_fifo);
}
p_ac3thread->p_fifo->p_first );
/* Waiting for the input thread to put new PES packets in the fifo */
vlc_cond_wait (&p_ac3thread->p_fifo->data_wait,
......
......@@ -2,7 +2,7 @@
* ac3_spdif.c: ac3 pass-through to external decoder with enabled soundcard
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: ac3_spdif.c,v 1.7 2001/12/10 04:53:10 sam Exp $
* $Id: ac3_spdif.c,v 1.8 2001/12/27 01:49:34 massiot Exp $
*
* Authors: Stphane Borel <stef@via.ecp.fr>
* Juha Yrjola <jyrjola@cc.hut.fi>
......@@ -315,12 +315,9 @@ static void ac3_spdif_ErrorThread( ac3_spdif_thread_t * p_spdif )
while( !p_spdif->p_fifo->b_die )
{
/* Trash all received PES packets */
while( !DECODER_FIFO_ISEMPTY( *p_spdif->p_fifo ) )
{
p_spdif->p_fifo->pf_delete_pes(p_spdif->p_fifo->p_packets_mgt,
DECODER_FIFO_START( *p_spdif->p_fifo ) );
DECODER_FIFO_INCSTART( *p_spdif->p_fifo );
}
p_spdif->p_fifo->pf_delete_pes(
p_spdif->p_fifo->p_packets_mgt,
p_spdif->p_fifo->p_first );
/* Waiting for the input thread to put new PES packets in the fifo */
vlc_cond_wait( &p_spdif->p_fifo->data_wait,
......@@ -374,7 +371,7 @@ static void BitstreamCallback ( bit_stream_t * p_bit_stream,
p_bit_stream->p_byte += 3;
p_spdif->i_pts =
DECODER_FIFO_START( *p_bit_stream->p_decoder_fifo )->i_pts;
DECODER_FIFO_START( *p_bit_stream->p_decoder_fifo )->i_pts = 0;
p_bit_stream->p_decoder_fifo->p_first->i_pts;
p_bit_stream->p_decoder_fifo->p_first->i_pts = 0;
}
}
......@@ -9,7 +9,7 @@
* -dvd_udf to find files
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: input_dvd.c,v 1.109 2001/12/19 23:19:20 sam Exp $
* $Id: input_dvd.c,v 1.110 2001/12/27 01:49:34 massiot Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -126,7 +126,7 @@ DECLARE_BUFFERS_END_SHARED( FLAGS, NB_LIFO );
DECLARE_BUFFERS_NEWPACKET_SHARED( FLAGS, NB_LIFO );
DECLARE_BUFFERS_DELETEPACKET_SHARED( FLAGS, NB_LIFO, 150 );
DECLARE_BUFFERS_NEWPES( FLAGS, NB_LIFO );
DECLARE_BUFFERS_DELETEPES( FLAGS, NB_LIFO, 150 );
DECLARE_BUFFERS_DELETEPES_SHARED( FLAGS, NB_LIFO, 150, 150 );
DECLARE_BUFFERS_TOIO( FLAGS, DVD_LB_SIZE );
DECLARE_BUFFERS_SHAREBUFFER( FLAGS );
......@@ -981,12 +981,7 @@ intf_WarnMsg( 2, "Sector: 0x%x Read: %d Chapter: %d", p_dvd->i_sector, i_block_o
pp_packets[i_packet] = NULL;
while( p_data != NULL )
{
data_packet_t * p_next = p_data->p_next;
p_input->pf_delete_packet( p_input->p_method_data, p_data );
p_data = p_next;
}
vlc_mutex_lock( &p_input->stream.stream_lock );
......
......@@ -6,7 +6,7 @@
* It depends on: libdvdread for ifo files and block reading.
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: input_dvdread.c,v 1.5 2001/12/20 23:53:49 massiot Exp $
* $Id: input_dvdread.c,v 1.6 2001/12/27 01:49:34 massiot Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -116,7 +116,7 @@ DECLARE_BUFFERS_END_SHARED( FLAGS, NB_LIFO );
DECLARE_BUFFERS_NEWPACKET_SHARED( FLAGS, NB_LIFO );
DECLARE_BUFFERS_DELETEPACKET_SHARED( FLAGS, NB_LIFO, 150 );
DECLARE_BUFFERS_NEWPES( FLAGS, NB_LIFO );
DECLARE_BUFFERS_DELETEPES( FLAGS, NB_LIFO, 150 );
DECLARE_BUFFERS_DELETEPES_SHARED( FLAGS, NB_LIFO, 150, 150 );
DECLARE_BUFFERS_TOIO( FLAGS, DVD_LB_SIZE );
DECLARE_BUFFERS_SHAREBUFFER( FLAGS );
......@@ -922,12 +922,7 @@ static int DvdReadRead( input_thread_t * p_input,
pp_packets[i_packet] = NULL;
while( p_data_p != NULL )
{
data_packet_t * p_next = p_data_p->p_next;
p_input->pf_delete_packet( p_input->p_method_data, p_data_p );
p_data_p = p_next;
}
vlc_mutex_lock( &p_input->stream.stream_lock );
......
......@@ -2,7 +2,7 @@
* lpcm_decoder_thread.c: lpcm decoder thread
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: lpcm_adec.c,v 1.5 2001/12/10 04:53:11 sam Exp $
* $Id: lpcm_adec.c,v 1.6 2001/12/27 01:49:34 massiot Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Henri Fallon <henri@videolan.org>
......@@ -184,11 +184,11 @@ void lpcm_adec_DecodeFrame( lpcmdec_thread_t * p_lpcmdec )
int i_loop;
byte_t byte1, byte2;
if( DECODER_FIFO_START(*p_lpcmdec->p_fifo)->i_pts )
if( p_lpcmdec->p_fifo->p_first->i_pts )
{
p_lpcmdec->p_aout_fifo->date[p_lpcmdec->p_aout_fifo->l_end_frame] =
DECODER_FIFO_START(*p_lpcmdec->p_fifo)->i_pts;
DECODER_FIFO_START(*p_lpcmdec->p_fifo)->i_pts = 0;
p_lpcmdec->p_fifo->p_first->i_pts;
p_lpcmdec->p_fifo->p_first->i_pts = 0;
}
else
{
......@@ -246,12 +246,9 @@ static void lpcm_adec_ErrorThread( lpcmdec_thread_t * p_lpcmdec )
while( !p_lpcmdec->p_fifo->b_die )
{
/* Trash all received PES packets */
while( !DECODER_FIFO_ISEMPTY(*p_lpcmdec->p_fifo) )
{
p_lpcmdec->p_fifo->pf_delete_pes( p_lpcmdec->p_fifo->p_packets_mgt,
DECODER_FIFO_START(*p_lpcmdec->p_fifo ));
DECODER_FIFO_INCSTART( *p_lpcmdec->p_fifo );
}
p_lpcmdec->p_fifo->pf_delete_pes(
p_lpcmdec->p_fifo->p_packets_mgt,
p_lpcmdec->p_fifo->p_first );
/* Waiting for the input thread to put new PES packets in the fifo */
vlc_cond_wait ( &p_lpcmdec->p_fifo->data_wait,
......
......@@ -237,13 +237,9 @@ static void mad_adec_ErrorThread (mad_adec_thread_t * p_mad_adec)
while (!p_mad_adec->p_fifo->b_die)
{
/* Trash all received PES packets */
while (!DECODER_FIFO_ISEMPTY(*p_mad_adec->p_fifo))
{
p_mad_adec->p_fifo->pf_delete_pes(
p_mad_adec->p_fifo->p_packets_mgt,
DECODER_FIFO_START(*p_mad_adec->p_fifo));
DECODER_FIFO_INCSTART (*p_mad_adec->p_fifo);
}
p_mad_adec->p_fifo->p_first );
/* Waiting for the input thread to put new PES packets in the fifo */
vlc_cond_wait (&p_mad_adec->p_fifo->data_wait,
......
......@@ -61,9 +61,9 @@ enum mad_flow libmad_input(void *data, struct mad_stream *p_libmad_stream)
byte_t buffer[ADEC_FRAME_SIZE];
/* Store time stamp of current frame */
if ( DECODER_FIFO_START(*p_mad_adec->p_fifo)->i_pts ) {
p_mad_adec->i_pts_save = DECODER_FIFO_START(*p_mad_adec->p_fifo)->i_pts;
DECODER_FIFO_START(*p_mad_adec->p_fifo)->i_pts = 0;
if ( p_mad_adec->p_fifo->p_first->i_pts ) {
p_mad_adec->i_pts_save = p_mad_adec->p_fifo->p_first->i_pts;
p_mad_adec->p_fifo->p_first->i_pts = 0;
}
else {
p_mad_adec->i_pts_save = LAST_MDATE;
......
......@@ -2,7 +2,7 @@
* mpeg_adec.c: MPEG audio decoder thread
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: mpeg_adec.c,v 1.7 2001/12/10 04:53:11 sam Exp $
* $Id: mpeg_adec.c,v 1.8 2001/12/27 01:49:34 massiot Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Michel Lespinasse <walken@via.ecp.fr>
......@@ -202,11 +202,11 @@ static void adec_Decode( adec_thread_t * p_adec )
buffer = ((s16 *)p_adec->p_aout_fifo->buffer)
+ (p_adec->p_aout_fifo->l_end_frame * ADEC_FRAME_SIZE);
if( DECODER_FIFO_START( *p_adec->p_fifo)->i_pts )
if( p_adec->p_fifo->p_first->i_pts )
{
p_adec->p_aout_fifo->date[p_adec->p_aout_fifo->l_end_frame] =
DECODER_FIFO_START( *p_adec->p_fifo )->i_pts;
DECODER_FIFO_START(*p_adec->p_fifo)->i_pts = 0;
p_adec->p_fifo->p_first->i_pts;
p_adec->p_fifo->p_first->i_pts = 0;
}
else
{
......@@ -248,12 +248,9 @@ static void adec_ErrorThread ( adec_thread_t *p_adec )
while ( !p_adec->p_fifo->b_die )
{
/* Trash all received PES packets */
while ( !DECODER_FIFO_ISEMPTY(*p_adec->p_fifo) )
{
p_adec->p_fifo->pf_delete_pes ( p_adec->p_fifo->p_packets_mgt,
DECODER_FIFO_START(*p_adec->p_fifo) );
DECODER_FIFO_INCSTART ( *p_adec->p_fifo );
}
p_adec->p_fifo->pf_delete_pes(
p_adec->p_fifo->p_packets_mgt,
p_adec->p_fifo->p_first );
/* Waiting for the input thread to put new PES packets in the fifo */
vlc_cond_wait ( &p_adec->p_fifo->data_wait, &p_adec->p_fifo->data_lock );
......
......@@ -2,7 +2,7 @@
* input_es.c: Elementary Stream demux and packet management
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: input_es.c,v 1.6 2001/12/19 10:00:00 massiot Exp $
* $Id: input_es.c,v 1.7 2001/12/27 01:49:34 massiot Exp $
*
* Author: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -99,7 +99,7 @@ DECLARE_BUFFERS_END( FLAGS, NB_LIFO );
DECLARE_BUFFERS_NEWPACKET( FLAGS, NB_LIFO );
DECLARE_BUFFERS_DELETEPACKET( FLAGS, NB_LIFO, 150 );
DECLARE_BUFFERS_NEWPES( FLAGS, NB_LIFO );
DECLARE_BUFFERS_DELETEPES( FLAGS, NB_LIFO, 150 );
DECLARE_BUFFERS_DELETEPES( FLAGS, NB_LIFO, 150, 150 );
DECLARE_BUFFERS_TOIO( FLAGS, ES_PACKET_SIZE );
/*****************************************************************************
......@@ -222,11 +222,10 @@ static int ESRead( input_thread_t * p_input,
p_data = p_data->p_next;
pp_packets[i_loop]->p_next = NULL;
}
/* Delete remaining packets */
input_DeletePacket( p_input->p_method_data, p_data );
for( ; i_loop < INPUT_READ_ONCE ; i_loop++ )
{
data_packet_t * p_next = p_data->p_next;
input_DeletePacket( p_input->p_method_data, p_data );
p_data = p_next;
pp_packets[i_loop] = NULL;
}
......@@ -293,8 +292,7 @@ static void ESDemux( input_thread_t * p_input, data_packet_t * p_data )
input_DecodePES( p_fifo, p_pes );
vlc_mutex_lock( &p_fifo->data_lock );
if( ( (DECODER_FIFO_END( *p_fifo ) - DECODER_FIFO_START( *p_fifo ))
& FIFO_SIZE ) >= MAX_PACKETS_IN_FIFO )
if( p_fifo->i_depth >= MAX_PACKETS_IN_FIFO )
{
vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock );
}
......@@ -318,18 +316,23 @@ static void ESNextDataPacket( bit_stream_t * p_bit_stream )
* time to jump to the next PES packet */
if( p_bit_stream->p_data->p_next == NULL )
{
/* We are going to read/write the start and end indexes of the
* decoder fifo and to use the fifo's conditional variable,
* that's why we need to take the lock before. */
pes_packet_t * p_next;
vlc_mutex_lock( &p_fifo->data_lock );
/* Free the previous PES packet. */
p_next = p_fifo->p_first->p_next;
p_fifo->p_first->p_next = NULL;
p_fifo->pf_delete_pes( p_fifo->p_packets_mgt,
DECODER_FIFO_START( *p_fifo ) );
DECODER_FIFO_INCSTART( *p_fifo );
p_fifo->p_first );
p_fifo->p_first = p_next;
p_fifo->i_depth--;
if( DECODER_FIFO_ISEMPTY( *p_fifo ) )
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;
/* Signal the input thread we're waiting. */
vlc_cond_signal( &p_fifo->data_wait );
......@@ -338,7 +341,7 @@ static void ESNextDataPacket( bit_stream_t * p_bit_stream )
}
/* The next byte could be found in the next PES packet */
p_bit_stream->p_data = DECODER_FIFO_START( *p_fifo )->p_first;
p_bit_stream->p_data = p_fifo->p_first->p_first;
vlc_mutex_unlock( &p_fifo->data_lock );
......
......@@ -2,7 +2,7 @@
* input_ps.c: PS demux and packet management
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: input_ps.c,v 1.6 2001/12/19 10:00:00 massiot Exp $
* $Id: input_ps.c,v 1.7 2001/12/27 01:49:34 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Cyril Deguet <asmax@via.ecp.fr>
......@@ -103,7 +103,7 @@ DECLARE_BUFFERS_END( FLAGS, NB_LIFO );
DECLARE_BUFFERS_NEWPACKET( FLAGS, NB_LIFO );
DECLARE_BUFFERS_DELETEPACKET( FLAGS, NB_LIFO, 150 );
DECLARE_BUFFERS_NEWPES( FLAGS, NB_LIFO );
DECLARE_BUFFERS_DELETEPES( FLAGS, NB_LIFO, 150 );
DECLARE_BUFFERS_DELETEPES( FLAGS, NB_LIFO, 150, 150 );
/*****************************************************************************
......
......@@ -2,7 +2,7 @@
* input_ts.c: TS demux and netlist management
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: input_ts.c,v 1.5 2001/12/19 10:00:00 massiot Exp $
* $Id: input_ts.c,v 1.6 2001/12/27 01:49:34 massiot Exp $
*
* Authors: Henri Fallon <henri@videolan.org>
*
......@@ -102,7 +102,7 @@ DECLARE_BUFFERS_END( FLAGS, NB_LIFO );
DECLARE_BUFFERS_NEWPACKET( FLAGS, NB_LIFO );
DECLARE_BUFFERS_DELETEPACKET( FLAGS, NB_LIFO, 1000 );
DECLARE_BUFFERS_NEWPES( FLAGS, NB_LIFO );
DECLARE_BUFFERS_DELETEPES( FLAGS, NB_LIFO, 150 );
DECLARE_BUFFERS_DELETEPES( FLAGS, NB_LIFO, 1000, 150 );
DECLARE_BUFFERS_TOIO( FLAGS, TS_PACKET_SIZE );
/*****************************************************************************
......@@ -331,11 +331,10 @@ static int TSRead( input_thread_t * p_input,
"0x%.2x, should be 0x47)",
pp_packets[i_loop]->p_demux_start[0] );
}
/* Delete remaining packets */
input_DeletePacket( p_input->p_method_data, p_data );
for( ; i_loop < INPUT_READ_ONCE ; i_loop++ )
{
data_packet_t * p_next = p_data->p_next;
input_DeletePacket( p_input->p_method_data, p_data );
p_data = p_next;
pp_packets[i_loop] = NULL;
}
......
......@@ -2,7 +2,7 @@
* video_parser.c : video parser thread
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: video_parser.c,v 1.7 2001/12/10 04:53:11 sam Exp $
* $Id: video_parser.c,v 1.8 2001/12/27 01:49:34 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr>
......@@ -298,12 +298,9 @@ static void mpeg_vdec_ErrorThread( vpar_thread_t *p_vpar )
while( !p_vpar->p_fifo->b_die )
{
/* Trash all received PES packets */
while( !DECODER_FIFO_ISEMPTY(*p_vpar->p_fifo) )
{
p_vpar->p_fifo->pf_delete_pes( p_vpar->p_fifo->p_packets_mgt,
DECODER_FIFO_START(*p_vpar->p_fifo) );
DECODER_FIFO_INCSTART( *p_vpar->p_fifo );
}
p_vpar->p_fifo->pf_delete_pes(
p_vpar->p_fifo->p_packets_mgt,
p_vpar->p_fifo->p_first );
/* Waiting for the input thread to put new PES packets in the fifo */
vlc_cond_wait( &p_vpar->p_fifo->data_wait, &p_vpar->p_fifo->data_lock );
......@@ -428,13 +425,13 @@ static void BitstreamCallback ( bit_stream_t * p_bit_stream,
if( b_new_pes )
{
p_vpar->sequence.next_pts =
DECODER_FIFO_START( *p_bit_stream->p_decoder_fifo )->i_pts;
p_bit_stream->p_decoder_fifo->p_first->i_pts;
p_vpar->sequence.next_dts =
DECODER_FIFO_START( *p_bit_stream->p_decoder_fifo )->i_dts;
p_bit_stream->p_decoder_fifo->p_first->i_dts;
p_vpar->sequence.i_current_rate =
DECODER_FIFO_START( *p_bit_stream->p_decoder_fifo )->i_rate;
p_bit_stream->p_decoder_fifo->p_first->i_rate;
if( DECODER_FIFO_START( *p_bit_stream->p_decoder_fifo )->b_discontinuity )
if( p_bit_stream->p_decoder_fifo->p_first->b_discontinuity )
{
#ifdef TRACE_VPAR
intf_DbgMsg( "Discontinuity in BitstreamCallback" );
......
......@@ -2,7 +2,7 @@
* spu_decoder.c : spu decoder thread
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
* $Id: spu_decoder.c,v 1.3 2001/12/16 16:18:36 sam Exp $
* $Id: spu_decoder.c,v 1.4 2001/12/27 01:49:34 massiot Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -236,12 +236,9 @@ static void spudec_ErrorThread( spudec_thread_t *p_spudec )
while( !p_spudec->p_fifo->b_die )
{
/* Trash all received PES packets */
while( !DECODER_FIFO_ISEMPTY(*p_spudec->p_fifo) )
{
p_spudec->p_fifo->pf_delete_pes( p_spudec->p_fifo->p_packets_mgt,
DECODER_FIFO_START(*p_spudec->p_fifo) );
DECODER_FIFO_INCSTART( *p_spudec->p_fifo );
}
p_spudec->p_fifo->pf_delete_pes(
p_spudec->p_fifo->p_packets_mgt,
p_spudec->p_fifo->p_first );
/* Waiting for the input thread to put new PES packets in the fifo */
vlc_cond_wait( &p_spudec->p_fifo->data_wait,
......@@ -308,7 +305,7 @@ static void ParsePacket( spudec_thread_t *p_spudec )
p_spudec->i_spu_size );
/* We cannot display a subpicture with no date */
if( DECODER_FIFO_START(*p_spudec->p_fifo)->i_pts == 0 )
if( p_spudec->p_fifo->p_first->i_pts == 0 )
{
intf_WarnMsg( 3, "spudec error: subtitle without a date" );
return;
......@@ -328,7 +325,7 @@ static void ParsePacket( spudec_thread_t *p_spudec )
}
/* Get display time now. If we do it later, we may miss the PTS. */
p_spudec->i_pts = DECODER_FIFO_START(*p_spudec->p_fifo)->i_pts;
p_spudec->i_pts = p_spudec->p_fifo->p_first->i_pts;
/* Allocate the temporary buffer we will parse */
p_src = malloc( p_spudec->i_rle_size );
......
......@@ -104,7 +104,7 @@ DECLARE_BUFFERS_END( FLAGS, NB_LIFO );
DECLARE_BUFFERS_NEWPACKET( FLAGS, NB_LIFO );
DECLARE_BUFFERS_DELETEPACKET( FLAGS, NB_LIFO, 150 );
DECLARE_BUFFERS_NEWPES( FLAGS, NB_LIFO );
DECLARE_BUFFERS_DELETEPES( FLAGS, NB_LIFO, 150 );
DECLARE_BUFFERS_DELETEPES( FLAGS, NB_LIFO, 150, 150 );
/*****************************************************************************
......
......@@ -2,7 +2,7 @@
* input_dec.c: Functions for the management of decoders
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: input_dec.c,v 1.20 2001/12/09 17:01:37 sam Exp $
* $Id: input_dec.c,v 1.21 2001/12/27 01:49:34 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -143,21 +143,13 @@ void input_DecodePES( decoder_fifo_t * p_decoder_fifo, pes_packet_t * p_pes )
{
vlc_mutex_lock( &p_decoder_fifo->data_lock );
if( !DECODER_FIFO_ISFULL( *p_decoder_fifo ) )
{
p_decoder_fifo->buffer[p_decoder_fifo->i_end] = p_pes;
DECODER_FIFO_INCEND( *p_decoder_fifo );
p_pes->p_next = NULL;
*p_decoder_fifo->pp_last = p_pes;
p_decoder_fifo->pp_last = &p_pes->p_next;
p_decoder_fifo->i_depth++;
/* Warn the decoder that it's got work to do. */
vlc_cond_signal( &p_decoder_fifo->data_wait );
}
else
{
/* The FIFO is full !!! This should not happen. */
p_decoder_fifo->pf_delete_pes( p_decoder_fifo->p_packets_mgt,
p_pes );
intf_ErrMsg( "PES trashed - decoder fifo full !" );
}
vlc_mutex_unlock( &p_decoder_fifo->data_lock );
}
......@@ -260,7 +252,9 @@ static decoder_config_t * CreateDecoderConfig( input_thread_t * p_input,
p_config->i_type = p_es->i_type;
p_config->p_stream_ctrl = &p_input->stream.control;
p_config->p_decoder_fifo->i_start = p_config->p_decoder_fifo->i_end = 0;
p_config->p_decoder_fifo->p_first = NULL;
p_config->p_decoder_fifo->pp_last = &p_config->p_decoder_fifo->p_first;
p_config->p_decoder_fifo->i_depth = 0;
p_config->p_decoder_fifo->b_die = p_config->p_decoder_fifo->b_error = 0;
p_config->p_decoder_fifo->p_packets_mgt = p_input->p_method_data;
p_config->p_decoder_fifo->pf_delete_pes = p_input->pf_delete_pes;
......@@ -273,14 +267,13 @@ static decoder_config_t * CreateDecoderConfig( input_thread_t * p_input,
*****************************************************************************/
static void DeleteDecoderConfig( decoder_config_t * p_config )
{
intf_StatMsg( "input stats: killing decoder for 0x%x, type 0x%x, %d PES in FIFO",
p_config->i_id, p_config->i_type,
p_config->p_decoder_fifo->i_depth );
/* Free all packets still in the decoder fifo. */
while( !DECODER_FIFO_ISEMPTY( *p_config->p_decoder_fifo ) )
{
p_config->p_decoder_fifo->pf_delete_pes(
p_config->p_decoder_fifo->p_packets_mgt,
DECODER_FIFO_START( *p_config->p_decoder_fifo ) );
DECODER_FIFO_INCSTART( *p_config->p_decoder_fifo );
}
p_config->p_decoder_fifo->p_first );
/* Destroy the lock and cond */
vlc_cond_destroy( &p_config->p_decoder_fifo->data_wait );
......
......@@ -2,7 +2,7 @@
* input_ext-dec.c: services to the decoders
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: input_ext-dec.c,v 1.22 2001/12/09 17:01:37 sam Exp $
* $Id: input_ext-dec.c,v 1.23 2001/12/27 01:49:34 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -54,7 +54,7 @@ void InitBitstream( bit_stream_t * p_bit_stream, decoder_fifo_t * p_fifo,
/* Get the first data packet. */
vlc_mutex_lock( &p_fifo->data_lock );
while ( DECODER_FIFO_ISEMPTY( *p_fifo ) )
while ( p_fifo->p_first == NULL )
{
if ( p_fifo->b_die )
{
......@@ -63,7 +63,7 @@ void InitBitstream( bit_stream_t * p_bit_stream, decoder_fifo_t * p_fifo,
}
vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock );
}
p_bit_stream->p_data = DECODER_FIFO_START( *p_fifo )->p_first;
p_bit_stream->p_data = p_fifo->p_first->p_first;
p_bit_stream->p_byte = p_bit_stream->p_data->p_payload_start;
p_bit_stream->p_end = p_bit_stream->p_data->p_payload_end;
p_bit_stream->fifo.buffer = 0;
......@@ -102,24 +102,29 @@ void NextDataPacket( bit_stream_t * p_bit_stream )
* time to jump to the next PES packet */
if( p_bit_stream->p_data->p_next == NULL )
{
/* We are going to read/write the start and end indexes of the
* decoder fifo and to use the fifo's conditional variable,
* that's why we need to take the lock before. */
pes_packet_t * p_next;
vlc_mutex_lock( &p_fifo->data_lock );
/* Free the previous PES packet. */
p_next = p_fifo->p_first->p_next;
p_fifo->p_first->p_next = NULL;
p_fifo->pf_delete_pes( p_fifo->p_packets_mgt,
DECODER_FIFO_START( *p_fifo ) );
DECODER_FIFO_INCSTART( *p_fifo );
p_fifo->p_first );
p_fifo->p_first = p_next;
p_fifo->i_depth--;
if( DECODER_FIFO_ISEMPTY( *p_fifo ) )
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;
/* Wait for the input to tell us when we receive a packet. */
vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock );
}
/* The next byte could be found in the next PES packet */
p_bit_stream->p_data = DECODER_FIFO_START( *p_fifo )->p_first;
p_bit_stream->p_data = p_fifo->p_first->p_first;
vlc_mutex_unlock( &p_fifo->data_lock );
......
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