Commit 7d73d8fd authored by Michel Lespinasse's avatar Michel Lespinasse

Modification de decoder_fifo.h : le cas ou on passe d'un buffer a l'autre

lors de la lecture d'un octet n'est plus inline. Precedemment le code etait
inclus a chaque invocation de NeedBits ou GetBits...

Vu l'etat de la synchro je n'ai pas pu mesurer d'impact precis sur les fps
mais je ne m'attends pas a ce qu'il soit mesurable de toute facon : on troque
un apel de fonction contre un meilleur comportement du cache code...

Premier checkin de ma part, mais il devrait en venir d'autres.
parent 7b7bbbbe
......@@ -10,8 +10,8 @@
################################################################################
# Environment
#CC=gcc
#SHELL=/bin/sh
CC=egcc
SHELL=/bin/sh
# Audio output settings
AUDIO = dsp
......@@ -21,7 +21,8 @@ AUDIO = dsp
AUDIO += dummy
# Video output settings
VIDEO = x11 fb
VIDEO = x11
#VIDEO += fb
#VIDEO += ggi
#VIDEO += glide
# Not yet supported
......@@ -269,7 +270,8 @@ endif
misc_obj = misc/mtime.o \
misc/rsc_files.o \
misc/netutils.o
misc/netutils.o \
misc/decoder_fifo.o
C_OBJ = $(interface_obj) \
$(input_obj) \
......
......@@ -91,76 +91,20 @@ typedef struct bit_stream_s
} bit_stream_t;
void decoder_fifo_next( bit_stream_t * p_bit_stream );
/*****************************************************************************
* GetByte : reads the next byte in the input stream
*****************************************************************************/
static __inline__ byte_t GetByte( bit_stream_t * p_bit_stream )
{
/* Are there some bytes left in the current TS packet ? */
if ( p_bit_stream->i_byte < p_bit_stream->p_ts->i_payload_end )
if ( p_bit_stream->i_byte >= p_bit_stream->p_ts->i_payload_end )
{
return( p_bit_stream->p_ts->buffer[ p_bit_stream->i_byte++ ] );
/* no, switch to next TS packet */
decoder_fifo_next( p_bit_stream );
}
else
{
/* We are looking for the next TS packet that contains real data,
* and not just a PES header */
do
{
/* We were reading the last TS packet of this PES packet... It's
* time to jump to the next PES packet */
if ( p_bit_stream->p_ts->p_next_ts == 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 */
vlc_mutex_lock( &p_bit_stream->p_decoder_fifo->data_lock );
/* Is the input thread dying ? */
if ( p_bit_stream->p_input->b_die )
{
vlc_mutex_unlock( &(p_bit_stream->p_decoder_fifo->data_lock) );
return( 0 );
}
/* We should increase the start index of the decoder fifo, but
* if we do this now, the input thread could overwrite the
* pointer to the current PES packet, and we weren't able to
* give it back to the netlist. That's why we free the PES
* packet first. */
input_NetlistFreePES( p_bit_stream->p_input, DECODER_FIFO_START(*p_bit_stream->p_decoder_fifo) );
DECODER_FIFO_INCSTART( *p_bit_stream->p_decoder_fifo );
while ( DECODER_FIFO_ISEMPTY(*p_bit_stream->p_decoder_fifo) )
{
vlc_cond_wait( &p_bit_stream->p_decoder_fifo->data_wait, &p_bit_stream->p_decoder_fifo->data_lock );
if ( p_bit_stream->p_input->b_die )
{
vlc_mutex_unlock( &(p_bit_stream->p_decoder_fifo->data_lock) );
return( 0 );
}
}
/* The next byte could be found in the next PES packet */
p_bit_stream->p_ts = DECODER_FIFO_START( *p_bit_stream->p_decoder_fifo )->p_first_ts;
/* We can release the fifo's data lock */
vlc_mutex_unlock( &p_bit_stream->p_decoder_fifo->data_lock );
}
/* Perhaps the next TS packet of the current PES packet contains
* real data (ie its payload's size is greater than 0) */
else
{
p_bit_stream->p_ts = p_bit_stream->p_ts->p_next_ts;
}
} while ( p_bit_stream->p_ts->i_payload_start == p_bit_stream->p_ts->i_payload_end );
/* We've found a TS packet which contains interesting data... As we
* return the payload's first byte, we set i_byte to the following
* one */
p_bit_stream->i_byte = p_bit_stream->p_ts->i_payload_start;
return( p_bit_stream->p_ts->buffer[ p_bit_stream->i_byte++ ] );
}
return( p_bit_stream->p_ts->buffer[ p_bit_stream->i_byte++ ] );
}
/*****************************************************************************
......
/*****************************************************************************
* decoder_fifo.c: auxiliaries functions used in decoder_fifo.h
* (c)1998 VideoLAN
*****************************************************************************/
#include <sys/uio.h>
#include "config.h"
#include "common.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "debug.h" /* ?? temporaire, requis par netlist.h */
#include "input.h"
#include "input_netlist.h"
#include "decoder_fifo.h"
void decoder_fifo_next( bit_stream_t * p_bit_stream )
{
/* We are looking for the next TS packet that contains real data,
* and not just a PES header */
do
{
/* We were reading the last TS packet of this PES packet... It's
* time to jump to the next PES packet */
if ( p_bit_stream->p_ts->p_next_ts == 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 */
vlc_mutex_lock( &p_bit_stream->p_decoder_fifo->data_lock );
/* Is the input thread dying ? */
if ( p_bit_stream->p_input->b_die )
{
vlc_mutex_unlock( &(p_bit_stream->p_decoder_fifo->data_lock) );
return;
}
/* We should increase the start index of the decoder fifo, but
* if we do this now, the input thread could overwrite the
* pointer to the current PES packet, and we weren't able to
* give it back to the netlist. That's why we free the PES
* packet first. */
input_NetlistFreePES( p_bit_stream->p_input, DECODER_FIFO_START(*p_bit_stream->p_decoder_fifo) );
DECODER_FIFO_INCSTART( *p_bit_stream->p_decoder_fifo );
while ( DECODER_FIFO_ISEMPTY(*p_bit_stream->p_decoder_fifo) )
{
vlc_cond_wait( &p_bit_stream->p_decoder_fifo->data_wait, &p_bit_stream->p_decoder_fifo->data_lock );
if ( p_bit_stream->p_input->b_die )
{
vlc_mutex_unlock( &(p_bit_stream->p_decoder_fifo->data_lock) );
return;
}
}
/* The next byte could be found in the next PES packet */
p_bit_stream->p_ts = DECODER_FIFO_START( *p_bit_stream->p_decoder_fifo )->p_first_ts;
/* We can release the fifo's data lock */
vlc_mutex_unlock( &p_bit_stream->p_decoder_fifo->data_lock );
}
/* Perhaps the next TS packet of the current PES packet contains
* real data (ie its payload's size is greater than 0) */
else
{
p_bit_stream->p_ts = p_bit_stream->p_ts->p_next_ts;
}
} while ( p_bit_stream->p_ts->i_payload_start == p_bit_stream->p_ts->i_payload_end );
/* We've found a TS packet which contains interesting data... */
p_bit_stream->i_byte = p_bit_stream->p_ts->i_payload_start;
}
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