Commit d970994c authored by Christophe Massiot's avatar Christophe Massiot

* Decoders do not necessarily use bit stream (see mad plug-in)

* mad PTS should finally be accurate
* Some configure changes.
parent 1fce3cc9
...@@ -179,7 +179,7 @@ DEFINE_SYS := -DSYS_$(shell echo $(SYS) | sed -e 's/-.*//' | tr '[a-z].' '[A-Z]_ ...@@ -179,7 +179,7 @@ DEFINE_SYS := -DSYS_$(shell echo $(SYS) | sed -e 's/-.*//' | tr '[a-z].' '[A-Z]_
DEFINE += $(DEFINE_SYS) DEFINE += $(DEFINE_SYS)
# On Linux and Solaris, activate 64-bit off_t (by default under BSD) # On Linux and Solaris, activate 64-bit off_t (by default under BSD)
DEFINE += -D_FILE_OFFSET_BITS=64 -D__USE_UNIX98 DEFINE += -D_FILE_OFFSET_BITS=64 -D__USE_UNIX98 -D_LARGEFILE64_SOURCE
# Gettext support # Gettext support
DEFINE += -DLOCALEDIR=\"$(datadir)/locale\" DEFINE += -DLOCALEDIR=\"$(datadir)/locale\"
......
This diff is collapsed.
...@@ -61,9 +61,10 @@ AC_ARG_WITH(words, ...@@ -61,9 +61,10 @@ AC_ARG_WITH(words,
*) *)
dnl Try to guess endianness by matching patterns on a compiled dnl Try to guess endianness by matching patterns on a compiled
dnl binary, by looking for an ASCII or EBCDIC string dnl binary, by looking for an ASCII or EBCDIC string
ac_cv_c_bigendian=unknown AC_CACHE_CHECK([whether the byte order is big-endian],
AC_MSG_CHECKING(what the byte order looks to be)[ [ac_cv_c_bigendian],
cat >conftest.c <<EOF [ac_cv_c_bigendian=unknown
[cat >conftest.c <<EOF
short am[] = { 0x4249, 0x4765, 0x6e44, 0x6961, 0x6e53, 0x7953, 0 }; short am[] = { 0x4249, 0x4765, 0x6e44, 0x6961, 0x6e53, 0x7953, 0 };
short ai[] = { 0x694c, 0x5454, 0x656c, 0x6e45, 0x6944, 0x6e61, 0 }; short ai[] = { 0x694c, 0x5454, 0x656c, 0x6e45, 0x6944, 0x6e61, 0 };
void _a(void) { char*s = (char*)am; s = (char *)ai; } void _a(void) { char*s = (char*)am; s = (char *)ai; }
...@@ -72,37 +73,34 @@ AC_ARG_WITH(words, ...@@ -72,37 +73,34 @@ AC_ARG_WITH(words,
void _e(void) { char*s = (char*)em; s = (char*)ei; } void _e(void) { char*s = (char*)em; s = (char*)ei; }
int main(void) { _a(); _e(); return 0; } int main(void) { _a(); _e(); return 0; }
EOF EOF
] ]
if test -f conftest.c if test -f conftest.c
then then
if ${CC-cc} conftest.c -o conftest.o >config.log 2>&1 \ if ${CC-cc} conftest.c -o conftest.o >config.log 2>&1 \
&& test -f conftest.o && test -f conftest.o
then
if test `grep -l BIGenDianSyS conftest.o`
then then
AC_MSG_RESULT("big endian") if test `grep -l BIGenDianSyS conftest.o`
ac_cv_c_bigendian=yes then
fi ac_cv_c_bigendian=yes
if test `grep -l LiTTleEnDian conftest.o` fi
then if test `grep -l LiTTleEnDian conftest.o`
AC_MSG_RESULT("little endian") then
ac_cv_c_bigendian=no ac_cv_c_bigendian=no
fi
fi fi
fi fi
fi ])
if test $ac_cv_c_bigendian = xunknown if test $ac_cv_c_bigendian = xunknown
then then
AC_MSG_ERROR([Could not guess endianness, please use --with-words]) AC_MSG_ERROR([Could not guess endianness, please use --with-words])
fi fi
dnl Now we know what to use for endianness, just put it in the header
if test $ac_cv_c_bigendian = yes
then
cat >> confdefs.h <<\EOF
#define WORDS_BIGENDIAN 1
EOF
fi
;; ;;
esac esac
dnl Now we know what to use for endianness, just put it in the header
if test $ac_cv_c_bigendian = yes
then
AC_DEFINE(WORDS_BIGENDIAN, 1, big endian system)
fi
dnl Check for system libs needed dnl Check for system libs needed
AC_CHECK_FUNCS(gettimeofday select strerror strtod strtol isatty) AC_CHECK_FUNCS(gettimeofday select strerror strtod strtol isatty)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* Collection of useful common types and macros definitions * Collection of useful common types and macros definitions
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: common.h,v 1.69 2002/01/14 23:46:35 massiot Exp $ * $Id: common.h,v 1.70 2002/01/21 23:57:46 massiot Exp $
* *
* Authors: Samuel Hocevar <sam@via.ecp.fr> * Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr> * Vincent Seguin <seguin@via.ecp.fr>
...@@ -510,6 +510,9 @@ typedef struct module_symbols_s ...@@ -510,6 +510,9 @@ typedef struct module_symbols_s
void ( * ) ( struct bit_stream_s *, void ( * ) ( struct bit_stream_s *,
boolean_t ), boolean_t ),
void * ); void * );
void ( * BitstreamNextDataPacket )( struct bit_stream_s * );
boolean_t ( * NextDataPacket ) ( struct decoder_fifo_s *,
struct data_packet_s ** );
void ( * DecoderError ) ( struct decoder_fifo_s * p_fifo ); void ( * DecoderError ) ( struct decoder_fifo_s * p_fifo );
int ( * input_InitStream ) ( struct input_thread_s *, size_t ); int ( * input_InitStream ) ( struct input_thread_s *, size_t );
void ( * input_EndStream ) ( struct input_thread_s * ); void ( * input_EndStream ) ( struct input_thread_s * );
......
/* include/defs.h.in. Generated automatically from configure.in by autoheader 2.13. */ /* include/defs.h.in. Generated automatically from configure.in by autoheader. */
/* Define if using alloca.c. */ /* Define if using alloca.c. */
#undef C_ALLOCA #undef C_ALLOCA
...@@ -326,6 +326,9 @@ ...@@ -326,6 +326,9 @@
/* Define if the GNU gettext() function is already present or preinstalled. */ /* Define if the GNU gettext() function is already present or preinstalled. */
#undef HAVE_GETTEXT #undef HAVE_GETTEXT
/* big endian system */
#undef WORDS_BIGENDIAN
/* long getopt support */ /* long getopt support */
#undef HAVE_GETOPT_LONG #undef HAVE_GETOPT_LONG
......
...@@ -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.51 2002/01/14 23:46:35 massiot Exp $ * $Id: input_ext-dec.h,v 1.52 2002/01/21 23:57:46 massiot 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>
...@@ -158,9 +158,6 @@ typedef struct bit_stream_s ...@@ -158,9 +158,6 @@ typedef struct bit_stream_s
/* The decoder fifo contains the data of the PES stream */ /* The decoder fifo contains the data of the PES stream */
decoder_fifo_t * p_decoder_fifo; decoder_fifo_t * p_decoder_fifo;
/* Function to jump to the next data packet */
void (* pf_next_data_packet)( struct bit_stream_s * );
/* Callback to the decoder used when changing data packets ; set /* Callback to the decoder used when changing data packets ; set
* to NULL if your decoder doesn't need it. */ * to NULL if your decoder doesn't need it. */
void (* pf_bitstream_callback)( struct bit_stream_s *, void (* pf_bitstream_callback)( struct bit_stream_s *,
...@@ -218,11 +215,20 @@ typedef struct bit_stream_s ...@@ -218,11 +215,20 @@ typedef struct bit_stream_s
* Prototypes from input_ext-dec.c * Prototypes from input_ext-dec.c
*****************************************************************************/ *****************************************************************************/
#ifndef PLUGIN #ifndef PLUGIN
void InitBitstream ( struct bit_stream_s *, struct decoder_fifo_s *,
void (* pf_bitstream_callback)( struct bit_stream_s *,
boolean_t ),
void * p_callback_arg );
boolean_t NextDataPacket( struct decoder_fifo_s *, struct data_packet_s ** );
void BitstreamNextDataPacket( struct bit_stream_s * );
u32 UnalignedShowBits( struct bit_stream_s *, unsigned int ); u32 UnalignedShowBits( struct bit_stream_s *, unsigned int );
void UnalignedRemoveBits( struct bit_stream_s * ); void UnalignedRemoveBits( struct bit_stream_s * );
u32 UnalignedGetBits( struct bit_stream_s *, unsigned int ); u32 UnalignedGetBits( struct bit_stream_s *, unsigned int );
void CurrentPTS( struct bit_stream_s *, mtime_t *, mtime_t * ); void CurrentPTS( struct bit_stream_s *, mtime_t *, mtime_t * );
#else #else
# define InitBitstream p_symbols->InitBitstream
# define NextDataPacket p_symbols->NextDataPacket
# define BitstreamNextDataPacket p_symbols->BitstreamNextDataPacket
# define UnalignedShowBits p_symbols->UnalignedShowBits # define UnalignedShowBits p_symbols->UnalignedShowBits
# define UnalignedRemoveBits p_symbols->UnalignedRemoveBits # define UnalignedRemoveBits p_symbols->UnalignedRemoveBits
# define UnalignedGetBits p_symbols->UnalignedGetBits # define UnalignedGetBits p_symbols->UnalignedGetBits
...@@ -248,7 +254,7 @@ static __inline__ void AlignWord( bit_stream_t * p_bit_stream ) ...@@ -248,7 +254,7 @@ static __inline__ void AlignWord( bit_stream_t * p_bit_stream )
} }
else else
{ {
p_bit_stream->pf_next_data_packet( p_bit_stream ); BitstreamNextDataPacket( p_bit_stream );
p_bit_stream->fifo.buffer |= *(p_bit_stream->p_byte++) p_bit_stream->fifo.buffer |= *(p_bit_stream->p_byte++)
<< (8 * sizeof(WORD_TYPE) - 8 << (8 * sizeof(WORD_TYPE) - 8
- p_bit_stream->fifo.i_available); - p_bit_stream->fifo.i_available);
...@@ -499,7 +505,7 @@ static __inline__ void GetChunk( bit_stream_t * p_bit_stream, ...@@ -499,7 +505,7 @@ static __inline__ void GetChunk( bit_stream_t * p_bit_stream,
p_bit_stream->p_byte = p_bit_stream->p_end; p_bit_stream->p_byte = p_bit_stream->p_end;
p_buffer += i_available; p_buffer += i_available;
i_buf_len -= i_available; i_buf_len -= i_available;
p_bit_stream->pf_next_data_packet( p_bit_stream ); BitstreamNextDataPacket( p_bit_stream );
} }
while( (i_available = p_bit_stream->p_end - p_bit_stream->p_byte) while( (i_available = p_bit_stream->p_end - p_bit_stream->p_byte)
<= i_buf_len && !p_bit_stream->p_decoder_fifo->b_die ); <= i_buf_len && !p_bit_stream->p_decoder_fifo->b_die );
...@@ -534,11 +540,6 @@ typedef struct decoder_config_s ...@@ -534,11 +540,6 @@ typedef struct decoder_config_s
struct stream_ctrl_s * p_stream_ctrl; struct stream_ctrl_s * p_stream_ctrl;
struct decoder_fifo_s * p_decoder_fifo; struct decoder_fifo_s * p_decoder_fifo;
void (* pf_init_bit_stream)( struct bit_stream_s *,
struct decoder_fifo_s *,
void (* pf_bitstream_callback)( struct bit_stream_s *,
boolean_t ),
void * );
} decoder_config_t; } decoder_config_t;
/***************************************************************************** /*****************************************************************************
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* control the pace of reading. * control the pace of reading.
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: input_ext-intf.h,v 1.57 2002/01/09 02:01:14 sam Exp $ * $Id: input_ext-intf.h,v 1.58 2002/01/21 23:57:46 massiot Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -269,11 +269,6 @@ typedef struct input_thread_s ...@@ -269,11 +269,6 @@ typedef struct input_thread_s
void (* pf_open)( struct input_thread_s * ); void (* pf_open)( struct input_thread_s * );
void (* pf_close)( struct input_thread_s * ); void (* pf_close)( struct input_thread_s * );
void (* pf_end)( struct input_thread_s * ); void (* pf_end)( struct input_thread_s * );
void (* pf_init_bit_stream)( struct bit_stream_s *,
struct decoder_fifo_s *,
void (* pf_bitstream_callback)( struct bit_stream_s *,
boolean_t ),
void * );
/* Read & Demultiplex */ /* Read & Demultiplex */
int (* pf_read)( struct input_thread_s *, int (* pf_read)( struct input_thread_s *,
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* but exported to plug-ins * but exported to plug-ins
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: input_ext-plugins.h,v 1.15 2001/12/30 07:09:54 sam Exp $ * $Id: input_ext-plugins.h,v 1.16 2002/01/21 23:57:46 massiot Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -33,19 +33,6 @@ ...@@ -33,19 +33,6 @@
* escape a decoder. */ * escape a decoder. */
#define NO_SEEK -1 #define NO_SEEK -1
/*****************************************************************************
* Prototypes from input_ext-dec.c
*****************************************************************************/
#ifndef PLUGIN
void InitBitstream ( struct bit_stream_s *, struct decoder_fifo_s *,
void (* pf_bitstream_callback)( struct bit_stream_s *,
boolean_t ),
void * p_callback_arg );
void NextDataPacket ( struct bit_stream_s * );
#else
# define InitBitstream p_symbols->InitBitstream
#endif
/***************************************************************************** /*****************************************************************************
* Prototypes from input_programs.c * Prototypes from input_programs.c
*****************************************************************************/ *****************************************************************************/
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ac3_adec.c: ac3 decoder module main file * ac3_adec.c: ac3 decoder module main file
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: ac3_adec.c,v 1.14 2002/01/14 23:46:35 massiot Exp $ * $Id: ac3_adec.c,v 1.15 2002/01/21 23:57:46 massiot Exp $
* *
* Authors: Michel Lespinasse <walken@zoy.org> * Authors: Michel Lespinasse <walken@zoy.org>
* *
...@@ -200,8 +200,7 @@ static int InitThread( ac3dec_thread_t * p_ac3thread ) ...@@ -200,8 +200,7 @@ static int InitThread( ac3dec_thread_t * p_ac3thread )
/* /*
* Bit stream * Bit stream
*/ */
p_ac3thread->p_config->pf_init_bit_stream( InitBitstream(&p_ac3thread->ac3_decoder->bit_stream,
&p_ac3thread->ac3_decoder->bit_stream,
p_ac3thread->p_config->p_decoder_fifo, p_ac3thread->p_config->p_decoder_fifo,
BitstreamCallback, (void *) p_ac3thread ); BitstreamCallback, (void *) p_ac3thread );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ac3_spdif.c: ac3 pass-through to external decoder with enabled soundcard * ac3_spdif.c: ac3 pass-through to external decoder with enabled soundcard
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: ac3_spdif.c,v 1.10 2001/12/30 07:09:54 sam Exp $ * $Id: ac3_spdif.c,v 1.11 2002/01/21 23:57:46 massiot Exp $
* *
* Authors: Stphane Borel <stef@via.ecp.fr> * Authors: Stphane Borel <stef@via.ecp.fr>
* Juha Yrjola <jyrjola@cc.hut.fi> * Juha Yrjola <jyrjola@cc.hut.fi>
...@@ -229,10 +229,8 @@ static int InitThread( ac3_spdif_thread_t * p_spdif ) ...@@ -229,10 +229,8 @@ static int InitThread( ac3_spdif_thread_t * p_spdif )
*/ */
p_spdif->p_fifo = p_spdif->p_config->p_decoder_fifo; p_spdif->p_fifo = p_spdif->p_config->p_decoder_fifo;
p_spdif->p_config->pf_init_bit_stream( InitBitstream( &p_spdif->bit_stream, p_spdif->p_config->p_decoder_fifo,
&p_spdif->bit_stream, BitstreamCallback, (void*)p_spdif );
p_spdif->p_config->p_decoder_fifo,
BitstreamCallback, (void*)p_spdif );
/* Creating the audio output fifo */ /* Creating the audio output fifo */
p_spdif->p_aout_fifo = aout_CreateFifo( AOUT_ADEC_SPDIF_FIFO, 1, 48000, 0, p_spdif->p_aout_fifo = aout_CreateFifo( AOUT_ADEC_SPDIF_FIFO, 1, 48000, 0,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* lpcm_decoder_thread.c: lpcm decoder thread * lpcm_decoder_thread.c: lpcm decoder thread
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: lpcm_adec.c,v 1.9 2002/01/14 23:46:35 massiot Exp $ * $Id: lpcm_adec.c,v 1.10 2002/01/21 23:57:46 massiot Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* Henri Fallon <henri@videolan.org> * Henri Fallon <henri@videolan.org>
...@@ -146,10 +146,8 @@ static int InitThread (lpcmdec_thread_t * p_lpcmdec) ...@@ -146,10 +146,8 @@ static int InitThread (lpcmdec_thread_t * p_lpcmdec)
{ {
/* Init the BitStream */ /* Init the BitStream */
p_lpcmdec->p_config->pf_init_bit_stream( InitBitstream( &p_lpcmdec->bit_stream, p_lpcmdec->p_config->p_decoder_fifo,
&p_lpcmdec->bit_stream, NULL, NULL);
p_lpcmdec->p_config->p_decoder_fifo,
NULL, NULL);
/* Creating the audio output fifo */ /* Creating the audio output fifo */
p_lpcmdec->p_aout_fifo = aout_CreateFifo( AOUT_ADEC_STEREO_FIFO, 2, 48000, p_lpcmdec->p_aout_fifo = aout_CreateFifo( AOUT_ADEC_STEREO_FIFO, 2, 48000,
......
...@@ -132,14 +132,14 @@ static int decoder_Run ( decoder_config_t * p_config ) ...@@ -132,14 +132,14 @@ static int decoder_Run ( decoder_config_t * p_config )
/* mad decoder thread's main loop */ /* mad decoder thread's main loop */
while ((!p_mad_adec->p_fifo->b_die) && (!p_mad_adec->p_fifo->b_error)) while ((!p_mad_adec->p_fifo->b_die) && (!p_mad_adec->p_fifo->b_error))
{ {
intf_ErrMsg( "mad_adec: starting libmad decoder" ); intf_ErrMsg( "mad_adec: starting libmad decoder" );
if (mad_decoder_run(p_mad_adec->libmad_decoder, MAD_DECODER_MODE_SYNC)==-1) if (mad_decoder_run(p_mad_adec->libmad_decoder, MAD_DECODER_MODE_SYNC)==-1)
{ {
intf_ErrMsg( "mad_adec error: libmad decoder returns abnormally"); intf_ErrMsg( "mad_adec error: libmad decoder returns abnormally");
DecoderError( p_mad_adec->p_fifo ); DecoderError( p_mad_adec->p_fifo );
EndThread(p_mad_adec); EndThread(p_mad_adec);
return( -1 ); return( -1 );
} }
} }
/* If b_error is set, the mad decoder thread enters the error loop */ /* If b_error is set, the mad decoder thread enters the error loop */
...@@ -148,7 +148,7 @@ static int decoder_Run ( decoder_config_t * p_config ) ...@@ -148,7 +148,7 @@ static int decoder_Run ( decoder_config_t * p_config )
DecoderError( p_mad_adec->p_fifo ); DecoderError( p_mad_adec->p_fifo );
} }
/* End of the ac3 decoder thread */ /* End of the mad decoder thread */
EndThread (p_mad_adec); EndThread (p_mad_adec);
return( 0 ); return( 0 );
...@@ -159,42 +159,55 @@ static int decoder_Run ( decoder_config_t * p_config ) ...@@ -159,42 +159,55 @@ static int decoder_Run ( decoder_config_t * p_config )
*****************************************************************************/ *****************************************************************************/
static int InitThread( mad_adec_thread_t * p_mad_adec ) static int InitThread( mad_adec_thread_t * p_mad_adec )
{ {
decoder_fifo_t * p_fifo = p_mad_adec->p_fifo;
/* /*
* Properties of audio for libmad * Properties of audio for libmad
*/ */
/* Initialize the libmad decoder structures */ /* Initialize the libmad decoder structures */
p_mad_adec->libmad_decoder = (struct mad_decoder*) malloc(sizeof(struct mad_decoder)); p_mad_adec->libmad_decoder = (struct mad_decoder*) malloc(sizeof(struct mad_decoder));
if (p_mad_adec->libmad_decoder == NULL)
if (p_mad_adec->libmad_decoder == NULL) { {
intf_ErrMsg ( "mad_adec error: not enough memory " intf_ErrMsg ( "mad_adec error: not enough memory "
"for decoder_InitThread() to allocate p_mad_adec->libmad_decder" ); "for decoder_InitThread() to allocate p_mad_adec->libmad_decder" );
return -1; return -1;
} }
p_mad_adec->i_current_pts = p_mad_adec->i_next_pts = 0; p_mad_adec->i_current_pts = p_mad_adec->i_next_pts = 0;
/*
* Initialize bit stream
*/
p_mad_adec->p_config->pf_init_bit_stream( &p_mad_adec->bit_stream,
p_mad_adec->p_config->p_decoder_fifo,
NULL, /* pf_bitstream_callback */
NULL ); /* void **/
mad_decoder_init( p_mad_adec->libmad_decoder, mad_decoder_init( p_mad_adec->libmad_decoder,
p_mad_adec, /* vlc's thread structure and p_fifo playbuffer */ p_mad_adec, /* vlc's thread structure and p_fifo playbuffer */
libmad_input, /* input_func */ libmad_input, /* input_func */
0, /* header_func */ 0, /* header_func */
0, /* filter */ 0, /* filter */
libmad_output, /* output_func */ libmad_output, /* output_func */
0, /* error */ 0, /* error */
0); /* message */ 0); /* message */
mad_decoder_options(p_mad_adec->libmad_decoder, MAD_OPTION_IGNORECRC); mad_decoder_options(p_mad_adec->libmad_decoder, MAD_OPTION_IGNORECRC);
mad_timer_reset(&p_mad_adec->libmad_timer); mad_timer_reset(&p_mad_adec->libmad_timer);
/* output fifo will be created when needed */ /*
p_mad_adec->p_aout_fifo=NULL; * Initialize the output properties
*/
p_mad_adec->p_aout_fifo = NULL;
/*
* Initialize the input properties
*/
/* Get the first data packet. */
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( -1 );
}
vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock );
}
vlc_mutex_unlock( &p_fifo->data_lock );
p_mad_adec->p_data = p_fifo->p_first->p_first;
intf_ErrMsg("mad_adec debug: mad decoder thread %p initialized", p_mad_adec); intf_ErrMsg("mad_adec debug: mad decoder thread %p initialized", p_mad_adec);
......
...@@ -34,8 +34,8 @@ typedef struct mad_adec_thread_s ...@@ -34,8 +34,8 @@ typedef struct mad_adec_thread_s
* Decoder properties * Decoder properties
*/ */
struct mad_decoder *libmad_decoder; struct mad_decoder *libmad_decoder;
mad_timer_t libmad_timer; mad_timer_t libmad_timer;
byte_t buffer[MAD_BUFFER_SIZE]; byte_t buffer[MAD_BUFFER_SIZE];
/* /*
* Thread properties * Thread properties
...@@ -46,12 +46,11 @@ typedef struct mad_adec_thread_s ...@@ -46,12 +46,11 @@ 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 */
/* The bit stream structure handles the PES stream at the bit level */ data_packet_t * p_data;
bit_stream_t bit_stream;
decoder_config_t * p_config; decoder_config_t * p_config;
/* 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;
/* /*
* Output properties * Output properties
......
...@@ -56,7 +56,7 @@ enum mad_flow libmad_input(void *data, struct mad_stream *p_libmad_stream) ...@@ -56,7 +56,7 @@ enum mad_flow libmad_input(void *data, struct mad_stream *p_libmad_stream)
} }
if ( p_mad_adec->p_fifo->b_error == 1 ) { if ( p_mad_adec->p_fifo->b_error == 1 ) {
intf_ErrMsg( "mad_adec error: libmad_input ignoring current audio frame" ); intf_ErrMsg( "mad_adec error: libmad_input ignoring current audio frame" );
return MAD_FLOW_IGNORE; return MAD_FLOW_IGNORE;
} }
...@@ -65,63 +65,60 @@ enum mad_flow libmad_input(void *data, struct mad_stream *p_libmad_stream) ...@@ -65,63 +65,60 @@ enum mad_flow libmad_input(void *data, struct mad_stream *p_libmad_stream)
*/ */
if ((p_libmad_stream->buffer==NULL) || (p_libmad_stream->error==MAD_ERROR_BUFLEN)) if ((p_libmad_stream->buffer==NULL) || (p_libmad_stream->error==MAD_ERROR_BUFLEN))
{ {
/* libmad does not consume all the buffer it's given. Some /* libmad does not consume all the buffer it's given. Some
* datas, part of a truncated frame, is left unused at the * datas, part of a truncated frame, is left unused at the
* end of the buffer. Those datas must be put back at the * end of the buffer. Those datas must be put back at the
* beginning of the buffer and taken in account for * beginning of the buffer and taken in account for
* refilling the buffer. This means that the input buffer * refilling the buffer. This means that the input buffer
* must be large enough to hold a complete frame at the * must be large enough to hold a complete frame at the
* highest observable bit-rate (currently 448 kb/s). XXX=XXX * highest observable bit-rate (currently 448 kb/s). XXX=XXX
* Is 2016 bytes the size of the largest frame? * Is 2016 bytes the size of the largest frame?
* (448000*(1152/32000))/8 * (448000*(1152/32000))/8
*/ */
if (p_libmad_stream->next_frame!=NULL) if(p_libmad_stream->next_frame!=NULL)
{ {
Remaining=p_libmad_stream->bufend-p_libmad_stream->next_frame; Remaining=p_libmad_stream->bufend-p_libmad_stream->next_frame;
memmove(p_mad_adec->buffer,p_libmad_stream->next_frame,Remaining); if( p_mad_adec->buffer != p_libmad_stream->next_frame )
ReadStart=p_mad_adec->buffer+Remaining; {
ReadSize=(MAD_BUFFER_SIZE)-Remaining; FAST_MEMCPY( p_mad_adec->buffer, p_libmad_stream->next_frame,
Remaining );
}
ReadStart=p_mad_adec->buffer+Remaining;
ReadSize=(MAD_BUFFER_SIZE)-Remaining;
/* Store time stamp of next frame */ /* Store time stamp of next frame */
p_mad_adec->i_current_pts = p_mad_adec->i_next_pts; p_mad_adec->i_current_pts = p_mad_adec->i_next_pts;
CurrentPTS( &p_mad_adec->bit_stream, &p_mad_adec->i_next_pts, NULL ); p_mad_adec->i_next_pts = p_mad_adec->p_fifo->p_first->i_pts;
} }
else else
{ {
ReadSize=(MAD_BUFFER_SIZE); ReadSize=(MAD_BUFFER_SIZE);
ReadStart=p_mad_adec->buffer; ReadStart=p_mad_adec->buffer;
Remaining=0; Remaining=0;
p_mad_adec->i_next_pts = 0;
p_mad_adec->i_next_pts = 0; p_mad_adec->i_current_pts = p_mad_adec->p_fifo->p_first->i_pts;
CurrentPTS( &p_mad_adec->bit_stream, &p_mad_adec->i_current_pts, NULL ); }
}
//intf_ErrMsg( "mad_adec debug: buffer size remaining [%d] and readsize [%d] total [%d]",
// Remaining, ReadSize, ReadSize+Remaining);
/* Fill-in the buffer. If an error occurs print a message /* Fill-in the buffer. If an error occurs print a message
* and leave the decoding loop. If the end of stream is * and leave the decoding loop. If the end of stream is
* reached we also leave the loop but the return status is * reached we also leave the loop but the return status is
* left untouched. * left untouched.
*/ */
#if 0 if( ReadSize > p_mad_adec->p_data->p_payload_end
/* This is currently buggy --Meuuh */ - p_mad_adec->p_data->p_payload_start )
if( ReadSize > p_mad_adec->bit_stream.p_end
- p_mad_adec->bit_stream.p_byte )
{ {
FAST_MEMCPY( ReadStart, p_mad_adec->bit_stream.p_byte, ReadSize = p_mad_adec->p_data->p_payload_end
p_mad_adec->bit_stream.p_end - p_mad_adec->bit_stream.p_byte ); - p_mad_adec->p_data->p_payload_start;
p_mad_adec->bit_stream.pf_next_data_packet( &p_mad_adec->bit_stream ); FAST_MEMCPY( ReadStart, p_mad_adec->p_data->p_payload_start,
ReadSize );
NextDataPacket( p_mad_adec->p_fifo, &p_mad_adec->p_data );
} }
else else
{ {
FAST_MEMCPY( ReadStart, p_mad_adec->bit_stream.p_byte, FAST_MEMCPY( ReadStart, p_mad_adec->p_data->p_payload_start,
ReadSize ); ReadSize );
p_mad_adec->bit_stream.p_byte += ReadSize; p_mad_adec->p_data->p_payload_start += ReadSize;
} }
#else
/* This is PTS-inaccurate --Meuuh */
GetChunk( &p_mad_adec->bit_stream, ReadStart, ReadSize );
#endif
if ( p_mad_adec->p_fifo->b_die == 1 ) if ( p_mad_adec->p_fifo->b_die == 1 )
{ {
...@@ -135,12 +132,13 @@ enum mad_flow libmad_input(void *data, struct mad_stream *p_libmad_stream) ...@@ -135,12 +132,13 @@ enum mad_flow libmad_input(void *data, struct mad_stream *p_libmad_stream)
return MAD_FLOW_IGNORE; return MAD_FLOW_IGNORE;
} }
/* Pipe the new buffer content to libmad's stream decoder facility. /* Pipe the new buffer content to libmad's stream decoder facility.
* Libmad never copies the buffer, but just references it. So keep it in * Libmad never copies the buffer, but just references it. So keep it in
* mad_adec_thread_t structure. * mad_adec_thread_t structure.
*/ */
mad_stream_buffer(p_libmad_stream,(unsigned char*) &p_mad_adec->buffer,MAD_BUFFER_SIZE); mad_stream_buffer(p_libmad_stream,(unsigned char*) &p_mad_adec->buffer,
p_libmad_stream->error=0; Remaining + ReadSize);
p_libmad_stream->error=0;
} }
return MAD_FLOW_CONTINUE; return MAD_FLOW_CONTINUE;
...@@ -318,7 +316,6 @@ enum mad_flow libmad_output(void *data, struct mad_header const *p_libmad_header ...@@ -318,7 +316,6 @@ enum mad_flow libmad_output(void *data, struct mad_header const *p_libmad_header
intf_ErrMsg("mad_adec debug: in libmad_output aout fifo created"); intf_ErrMsg("mad_adec debug: in libmad_output aout fifo created");
} }
/* Set timestamp to synchronize audio and video decoder fifo's */
if (p_mad_adec->p_aout_fifo->l_rate != p_libmad_pcm->samplerate) if (p_mad_adec->p_aout_fifo->l_rate != p_libmad_pcm->samplerate)
{ {
intf_ErrMsg( "mad_adec: libmad_output samplerate is changing from [%d] Hz to [%d] Hz, sample size [%d], error_code [%0x]", intf_ErrMsg( "mad_adec: libmad_output samplerate is changing from [%d] Hz to [%d] Hz, sample size [%d], error_code [%0x]",
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* mpeg_adec.c: MPEG audio decoder thread * mpeg_adec.c: MPEG audio decoder thread
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: mpeg_adec.c,v 1.14 2002/01/14 23:46:35 massiot Exp $ * $Id: mpeg_adec.c,v 1.15 2002/01/21 23:57:46 massiot 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>
...@@ -123,8 +123,8 @@ static int decoder_Run ( decoder_config_t * p_config ) ...@@ -123,8 +123,8 @@ static int decoder_Run ( decoder_config_t * p_config )
/* /*
* Initialize bit stream * Initialize bit stream
*/ */
p_adec->p_config->pf_init_bit_stream( &p_adec->bit_stream, InitBitstream( &p_adec->bit_stream, p_adec->p_config->p_decoder_fifo,
p_adec->p_config->p_decoder_fifo, NULL, NULL ); NULL, NULL );
/* 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 */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* input_es.c: Elementary Stream demux and packet management * input_es.c: Elementary Stream demux and packet management
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: input_es.c,v 1.11 2001/12/30 07:09:55 sam Exp $ * $Id: input_es.c,v 1.12 2002/01/21 23:57:46 massiot Exp $
* *
* Author: Christophe Massiot <massiot@via.ecp.fr> * Author: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -68,12 +68,7 @@ static void ESEnd ( struct input_thread_s * ); ...@@ -68,12 +68,7 @@ static void ESEnd ( struct input_thread_s * );
static void ESSeek ( struct input_thread_s *, off_t ); static void ESSeek ( struct input_thread_s *, off_t );
static int ESSetProgram ( struct input_thread_s *, pgrm_descriptor_t * ); static int ESSetProgram ( struct input_thread_s *, pgrm_descriptor_t * );
static void ESDemux ( struct input_thread_s *, static void ESDemux ( struct input_thread_s *,
struct data_packet_s * ); struct data_packet_s * );
static void ESNextDataPacket( struct bit_stream_s * );
static void ESInitBitstream( struct bit_stream_s *, struct decoder_fifo_s *,
void (* pf_bitstream_callback)( struct bit_stream_s *,
boolean_t ),
void * );
/***************************************************************************** /*****************************************************************************
* Declare a buffer manager * Declare a buffer manager
...@@ -101,7 +96,6 @@ void _M( input_getfunctions )( function_list_t * p_function_list ) ...@@ -101,7 +96,6 @@ void _M( input_getfunctions )( function_list_t * p_function_list )
input.pf_open = NULL; input.pf_open = NULL;
input.pf_close = NULL; input.pf_close = NULL;
input.pf_end = ESEnd; input.pf_end = ESEnd;
input.pf_init_bit_stream = ESInitBitstream;
input.pf_set_area = NULL; input.pf_set_area = NULL;
input.pf_set_program = ESSetProgram; input.pf_set_program = ESSetProgram;
input.pf_read = ESRead; input.pf_read = ESRead;
...@@ -256,6 +250,14 @@ static void ESDemux( input_thread_t * p_input, data_packet_t * p_data ) ...@@ -256,6 +250,14 @@ static void ESDemux( input_thread_t * p_input, data_packet_t * p_data )
p_pes->p_first = p_pes->p_last = p_data; p_pes->p_first = p_pes->p_last = p_data;
p_pes->i_nb_data = 1; p_pes->i_nb_data = 1;
vlc_mutex_lock( &p_input->stream.stream_lock );
if( p_fifo->i_depth >= MAX_PACKETS_IN_FIFO )
{
/* Wait for the decoder. */
vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock );
}
vlc_mutex_unlock( &p_input->stream.stream_lock );
if( (p_input->stream.p_selected_program->i_synchro_state == SYNCHRO_REINIT) if( (p_input->stream.p_selected_program->i_synchro_state == SYNCHRO_REINIT)
| (input_ClockManageControl( p_input, | (input_ClockManageControl( p_input,
p_input->stream.p_selected_program, p_input->stream.p_selected_program,
...@@ -267,95 +269,5 @@ static void ESDemux( input_thread_t * p_input, data_packet_t * p_data ) ...@@ -267,95 +269,5 @@ static void ESDemux( input_thread_t * p_input, data_packet_t * p_data )
} }
input_DecodePES( p_fifo, p_pes ); input_DecodePES( p_fifo, p_pes );
vlc_mutex_lock( &p_fifo->data_lock );
if( p_fifo->i_depth >= MAX_PACKETS_IN_FIFO )
{
vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock );
}
vlc_mutex_unlock( &p_fifo->data_lock );
}
/*****************************************************************************
* ESNextDataPacket: signals the input thread if there isn't enough packets
* available
*****************************************************************************/
static void ESNextDataPacket( bit_stream_t * p_bit_stream )
{
decoder_fifo_t * p_fifo = p_bit_stream->p_decoder_fifo;
boolean_t b_new_pes;
/* We are looking for the next data packet that contains real data,
* and not just a PES header */
do
{
/* We were reading the last data packet of this PES packet... It's
* time to jump to the next PES packet */
if( p_bit_stream->p_data->p_next == NULL )
{
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,
p_fifo->p_first );
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;
/* Signal the input thread we're waiting. */
vlc_cond_signal( &p_fifo->data_wait );
/* 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 = p_fifo->p_first->p_first;
vlc_mutex_unlock( &p_fifo->data_lock );
b_new_pes = 1;
}
else
{
/* Perhaps the next data packet of the current PES packet contains
* real data (ie its payload's size is greater than 0). */
p_bit_stream->p_data = p_bit_stream->p_data->p_next;
b_new_pes = 0;
}
} while ( p_bit_stream->p_data->p_payload_start
== p_bit_stream->p_data->p_payload_end );
/* We've found a data packet which contains interesting data... */
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;
/* Call back the decoder. */
if( p_bit_stream->pf_bitstream_callback != NULL )
{
p_bit_stream->pf_bitstream_callback( p_bit_stream, b_new_pes );
}
} }
/*****************************************************************************
* ESInitBitstream: changes pf_next_data_packet
*****************************************************************************/
static void ESInitBitstream( bit_stream_t * p_bit_stream,
decoder_fifo_t * p_decoder_fifo,
void (* pf_bitstream_callback)( struct bit_stream_s *,
boolean_t ),
void * p_callback_arg )
{
InitBitstream( p_bit_stream, p_decoder_fifo, pf_bitstream_callback,
p_callback_arg );
p_bit_stream->pf_next_data_packet = ESNextDataPacket;
}
...@@ -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: video_parser.c,v 1.11 2002/01/14 23:46:35 massiot Exp $ * $Id: video_parser.c,v 1.12 2002/01/21 23:57:46 massiot 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>
...@@ -224,9 +224,8 @@ static int InitThread( vpar_thread_t *p_vpar ) ...@@ -224,9 +224,8 @@ static int InitThread( vpar_thread_t *p_vpar )
#undef f #undef f
/* Initialize input bitstream */ /* Initialize input bitstream */
p_vpar->p_config->pf_init_bit_stream( &p_vpar->bit_stream, InitBitstream( &p_vpar->bit_stream, p_vpar->p_config->p_decoder_fifo,
p_vpar->p_config->p_decoder_fifo, BitstreamCallback, BitstreamCallback, (void *)p_vpar );
(void *)p_vpar );
/* Initialize parsing data */ /* Initialize parsing data */
p_vpar->sequence.p_forward = NULL; p_vpar->sequence.p_forward = NULL;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* spu_decoder.c : spu decoder thread * spu_decoder.c : spu decoder thread
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2001 VideoLAN * Copyright (C) 2000-2001 VideoLAN
* $Id: spu_decoder.c,v 1.7 2002/01/04 14:01:34 sam Exp $ * $Id: spu_decoder.c,v 1.8 2002/01/21 23:57:46 massiot Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -195,9 +195,8 @@ static int InitThread( spudec_thread_t *p_spudec ) ...@@ -195,9 +195,8 @@ static int InitThread( spudec_thread_t *p_spudec )
/* Take the first video output FIXME: take the best one */ /* Take the first video output FIXME: take the best one */
p_spudec->p_vout = p_vout_bank->pp_vout[ 0 ]; p_spudec->p_vout = p_vout_bank->pp_vout[ 0 ];
vlc_mutex_unlock( &p_vout_bank->lock ); vlc_mutex_unlock( &p_vout_bank->lock );
p_spudec->p_config->pf_init_bit_stream( InitBitstream( &p_spudec->bit_stream,
&p_spudec->bit_stream, p_spudec->p_config->p_decoder_fifo, NULL, NULL );
p_spudec->p_config->p_decoder_fifo, NULL, NULL );
/* Mark thread as running and return */ /* Mark thread as running and return */
return( 0 ); return( 0 );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* aout_ext-dec.c : exported fifo management functions * aout_ext-dec.c : exported fifo management functions
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: aout_ext-dec.c,v 1.10 2002/01/14 12:15:10 asmax Exp $ * $Id: aout_ext-dec.c,v 1.11 2002/01/21 23:57:46 massiot Exp $
* *
* Authors: Michel Kaempf <maxx@via.ecp.fr> * Authors: Michel Kaempf <maxx@via.ecp.fr>
* Cyril Deguet <asmax@via.ecp.fr> * Cyril Deguet <asmax@via.ecp.fr>
...@@ -44,6 +44,9 @@ aout_fifo_t * aout_CreateFifo( int i_type, int i_channels, long l_rate, ...@@ -44,6 +44,9 @@ aout_fifo_t * aout_CreateFifo( int i_type, int i_channels, long l_rate,
aout_thread_t *p_aout; aout_thread_t *p_aout;
int i_fifo; int i_fifo;
intf_WarnMsg( 3, "aout_CreateFifo: type == %d, channels == %d, rate == %d, units == %d, frame_size == %d, buffer == %x",
i_type, i_channels, l_rate, l_units, l_frame_size, p_buffer );
/* Spawn an audio output if there is none */ /* Spawn an audio output if there is none */
vlc_mutex_lock( &p_aout_bank->lock ); vlc_mutex_lock( &p_aout_bank->lock );
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* decoders. * decoders.
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: input.c,v 1.172 2002/01/15 19:01:28 stef Exp $ * $Id: input.c,v 1.173 2002/01/21 23:57:46 massiot Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -465,7 +465,6 @@ static int InitThread( input_thread_t * p_input ) ...@@ -465,7 +465,6 @@ static int InitThread( input_thread_t * p_input )
#define f p_input->p_input_module->p_functions->input.functions.input #define f p_input->p_input_module->p_functions->input.functions.input
p_input->pf_init = f.pf_init; p_input->pf_init = f.pf_init;
p_input->pf_end = f.pf_end; p_input->pf_end = f.pf_end;
p_input->pf_init_bit_stream= f.pf_init_bit_stream;
p_input->pf_read = f.pf_read; p_input->pf_read = f.pf_read;
p_input->pf_set_area = f.pf_set_area; p_input->pf_set_area = f.pf_set_area;
p_input->pf_set_program = f.pf_set_program; p_input->pf_set_program = f.pf_set_program;
......
...@@ -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.23 2001/12/31 03:26:27 massiot Exp $ * $Id: input_dec.c,v 1.24 2002/01/21 23:57:46 massiot Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -245,8 +245,6 @@ static decoder_config_t * CreateDecoderConfig( input_thread_t * p_input, ...@@ -245,8 +245,6 @@ static decoder_config_t * CreateDecoderConfig( input_thread_t * p_input,
vlc_cond_init(&p_config->p_decoder_fifo->data_wait); vlc_cond_init(&p_config->p_decoder_fifo->data_wait);
p_es->p_decoder_fifo = p_config->p_decoder_fifo; p_es->p_decoder_fifo = p_config->p_decoder_fifo;
p_config->pf_init_bit_stream = p_input->pf_init_bit_stream;
p_config->i_id = p_es->i_id; p_config->i_id = p_es->i_id;
p_config->i_type = p_es->i_type; p_config->i_type = p_es->i_type;
p_config->p_stream_ctrl = &p_input->stream.control; p_config->p_stream_ctrl = &p_input->stream.control;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* input_ext-dec.c: services to the decoders * input_ext-dec.c: services to the decoders
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: input_ext-dec.c,v 1.28 2002/01/14 23:46:35 massiot Exp $ * $Id: input_ext-dec.c,v 1.29 2002/01/21 23:57:46 massiot Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -43,7 +43,6 @@ void InitBitstream( bit_stream_t * p_bit_stream, decoder_fifo_t * p_fifo, ...@@ -43,7 +43,6 @@ void InitBitstream( bit_stream_t * p_bit_stream, decoder_fifo_t * p_fifo,
void * p_callback_arg ) void * p_callback_arg )
{ {
p_bit_stream->p_decoder_fifo = p_fifo; p_bit_stream->p_decoder_fifo = p_fifo;
p_bit_stream->pf_next_data_packet = NextDataPacket;
p_bit_stream->pf_bitstream_callback = pf_bitstream_callback; p_bit_stream->pf_bitstream_callback = pf_bitstream_callback;
p_bit_stream->p_callback_arg = p_callback_arg; p_bit_stream->p_callback_arg = p_callback_arg;
...@@ -110,12 +109,13 @@ void DecoderError( decoder_fifo_t * p_fifo ) ...@@ -110,12 +109,13 @@ void DecoderError( decoder_fifo_t * p_fifo )
} }
/***************************************************************************** /*****************************************************************************
* NextDataPacket: go to the next data packet * NextDataPacket: go to the data packet after *pp_data, return 1 if we
* changed PES
*****************************************************************************/ *****************************************************************************/
void NextDataPacket( bit_stream_t * p_bit_stream ) static __inline__ boolean_t _NextDataPacket( decoder_fifo_t * p_fifo,
data_packet_t ** pp_data )
{ {
decoder_fifo_t * p_fifo = p_bit_stream->p_decoder_fifo; boolean_t b_new_pes;
boolean_t b_new_pes;
/* We are looking for the next data packet that contains real data, /* We are looking for the next data packet that contains real data,
* and not just a PES header */ * and not just a PES header */
...@@ -123,7 +123,7 @@ void NextDataPacket( bit_stream_t * p_bit_stream ) ...@@ -123,7 +123,7 @@ void NextDataPacket( bit_stream_t * p_bit_stream )
{ {
/* We were reading the last data packet of this PES packet... It's /* We were reading the last data packet of this PES packet... It's
* time to jump to the next PES packet */ * time to jump to the next PES packet */
if( p_bit_stream->p_data->p_next == NULL ) if( (*pp_data)->p_next == NULL )
{ {
pes_packet_t * p_next; pes_packet_t * p_next;
...@@ -142,12 +142,17 @@ void NextDataPacket( bit_stream_t * p_bit_stream ) ...@@ -142,12 +142,17 @@ void NextDataPacket( bit_stream_t * p_bit_stream )
/* No PES in the FIFO. p_last is no longer valid. */ /* No PES in the FIFO. p_last is no longer valid. */
p_fifo->pp_last = &p_fifo->p_first; p_fifo->pp_last = &p_fifo->p_first;
/* 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 receive a packet. */ /* Wait for the input to tell us when we receive a packet. */
vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock ); vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock );
} }
/* The next byte could be found in the next PES packet */ /* The next packet could be found in the next PES packet */
p_bit_stream->p_data = p_fifo->p_first->p_first; *pp_data = p_fifo->p_first->p_first;
vlc_mutex_unlock( &p_fifo->data_lock ); vlc_mutex_unlock( &p_fifo->data_lock );
...@@ -157,12 +162,30 @@ void NextDataPacket( bit_stream_t * p_bit_stream ) ...@@ -157,12 +162,30 @@ void NextDataPacket( bit_stream_t * p_bit_stream )
{ {
/* Perhaps the next data packet of the current PES packet contains /* Perhaps the next data packet of the current PES packet contains
* real data (ie its payload's size is greater than 0). */ * real data (ie its payload's size is greater than 0). */
p_bit_stream->p_data = p_bit_stream->p_data->p_next; *pp_data = (*pp_data)->p_next;
b_new_pes = 0; b_new_pes = 0;
} }
} while ( p_bit_stream->p_data->p_payload_start } while ( (*pp_data)->p_payload_start == (*pp_data)->p_payload_end );
== p_bit_stream->p_data->p_payload_end );
return( b_new_pes );
}
boolean_t NextDataPacket( decoder_fifo_t * p_fifo, data_packet_t ** pp_data )
{
return( _NextDataPacket( p_fifo, pp_data ) );
}
/*****************************************************************************
* BitstreamNextDataPacket: go to the next data packet, and update bitstream
* context
*****************************************************************************/
static __inline__ void _BitstreamNextDataPacket( bit_stream_t * p_bit_stream )
{
decoder_fifo_t * p_fifo = p_bit_stream->p_decoder_fifo;
boolean_t b_new_pes;
b_new_pes = _NextDataPacket( p_fifo, &p_bit_stream->p_data );
/* We've found a data packet which contains interesting data... */ /* We've found a data packet which contains interesting data... */
p_bit_stream->p_byte = p_bit_stream->p_data->p_payload_start; p_bit_stream->p_byte = p_bit_stream->p_data->p_payload_start;
...@@ -189,6 +212,11 @@ void NextDataPacket( bit_stream_t * p_bit_stream ) ...@@ -189,6 +212,11 @@ void NextDataPacket( bit_stream_t * p_bit_stream )
} }
} }
void BitstreamNextDataPacket( bit_stream_t * p_bit_stream )
{
_BitstreamNextDataPacket( p_bit_stream );
}
/***************************************************************************** /*****************************************************************************
* UnalignedShowBits : places i_bits bits into the bit buffer, even when * UnalignedShowBits : places i_bits bits into the bit buffer, even when
* not aligned on a word boundary * not aligned on a word boundary
...@@ -207,7 +235,7 @@ u32 UnalignedShowBits( bit_stream_t * p_bit_stream, unsigned int i_bits ) ...@@ -207,7 +235,7 @@ u32 UnalignedShowBits( bit_stream_t * p_bit_stream, unsigned int i_bits )
} }
else else
{ {
p_bit_stream->pf_next_data_packet( p_bit_stream ); _BitstreamNextDataPacket( p_bit_stream );
if( (ptrdiff_t)p_bit_stream->p_byte & (sizeof(WORD_TYPE) - 1) ) if( (ptrdiff_t)p_bit_stream->p_byte & (sizeof(WORD_TYPE) - 1) )
{ {
...@@ -232,7 +260,7 @@ u32 UnalignedShowBits( bit_stream_t * p_bit_stream, unsigned int i_bits ) ...@@ -232,7 +260,7 @@ u32 UnalignedShowBits( bit_stream_t * p_bit_stream, unsigned int i_bits )
if( p_bit_stream->p_byte >= p_bit_stream->p_end ) if( p_bit_stream->p_byte >= p_bit_stream->p_end )
{ {
j = i; j = i;
p_bit_stream->pf_next_data_packet( p_bit_stream ); _BitstreamNextDataPacket( p_bit_stream );
} }
((byte_t *)&p_bit_stream->i_showbits_buffer)[i] = ((byte_t *)&p_bit_stream->i_showbits_buffer)[i] =
* p_bit_stream->p_byte; * p_bit_stream->p_byte;
...@@ -289,7 +317,7 @@ u32 UnalignedGetBits( bit_stream_t * p_bit_stream, unsigned int i_bits ) ...@@ -289,7 +317,7 @@ u32 UnalignedGetBits( bit_stream_t * p_bit_stream, unsigned int i_bits )
} }
else else
{ {
p_bit_stream->pf_next_data_packet( p_bit_stream ); _BitstreamNextDataPacket( p_bit_stream );
i_result |= *(p_bit_stream->p_byte++) << (i_bits - 8); i_result |= *(p_bit_stream->p_byte++) << (i_bits - 8);
i_bits -= 8; i_bits -= 8;
} }
...@@ -309,7 +337,7 @@ u32 UnalignedGetBits( bit_stream_t * p_bit_stream, unsigned int i_bits ) ...@@ -309,7 +337,7 @@ u32 UnalignedGetBits( bit_stream_t * p_bit_stream, unsigned int i_bits )
} }
else else
{ {
p_bit_stream->pf_next_data_packet( p_bit_stream ); _BitstreamNextDataPacket( p_bit_stream );
i_result |= *p_bit_stream->p_byte >> i_tmp; i_result |= *p_bit_stream->p_byte >> i_tmp;
p_bit_stream->fifo.buffer = *(p_bit_stream->p_byte++) p_bit_stream->fifo.buffer = *(p_bit_stream->p_byte++)
<< ( sizeof(WORD_TYPE) * 8 - i_tmp ); << ( sizeof(WORD_TYPE) * 8 - i_tmp );
...@@ -351,7 +379,7 @@ void UnalignedRemoveBits( bit_stream_t * p_bit_stream ) ...@@ -351,7 +379,7 @@ void UnalignedRemoveBits( bit_stream_t * p_bit_stream )
} }
else else
{ {
p_bit_stream->pf_next_data_packet( p_bit_stream ); _BitstreamNextDataPacket( p_bit_stream );
p_bit_stream->p_byte++; p_bit_stream->p_byte++;
p_bit_stream->fifo.i_available += 8; p_bit_stream->fifo.i_available += 8;
} }
...@@ -369,7 +397,7 @@ void UnalignedRemoveBits( bit_stream_t * p_bit_stream ) ...@@ -369,7 +397,7 @@ void UnalignedRemoveBits( bit_stream_t * p_bit_stream )
} }
else else
{ {
p_bit_stream->pf_next_data_packet( p_bit_stream ); _BitstreamNextDataPacket( p_bit_stream );
p_bit_stream->fifo.buffer = *(p_bit_stream->p_byte++) p_bit_stream->fifo.buffer = *(p_bit_stream->p_byte++)
<< ( sizeof(WORD_TYPE) * 8 - 8 << ( sizeof(WORD_TYPE) * 8 - 8
- p_bit_stream->fifo.i_available ); - p_bit_stream->fifo.i_available );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* modules_plugin.h : Plugin management functions used by the core application. * modules_plugin.h : Plugin management functions used by the core application.
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: modules_plugin.h,v 1.5 2002/01/14 23:46:35 massiot Exp $ * $Id: modules_plugin.h,v 1.6 2002/01/21 23:57:46 massiot Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -197,6 +197,7 @@ module_error( void ) ...@@ -197,6 +197,7 @@ module_error( void )
(p_symbols)->input_AddArea = input_AddArea; \ (p_symbols)->input_AddArea = input_AddArea; \
(p_symbols)->input_DelArea = input_DelArea; \ (p_symbols)->input_DelArea = input_DelArea; \
(p_symbols)->InitBitstream = InitBitstream; \ (p_symbols)->InitBitstream = InitBitstream; \
(p_symbols)->NextDataPacket = NextDataPacket; \
(p_symbols)->DecoderError = DecoderError; \ (p_symbols)->DecoderError = DecoderError; \
(p_symbols)->input_InitStream = input_InitStream; \ (p_symbols)->input_InitStream = input_InitStream; \
(p_symbols)->input_EndStream = input_EndStream; \ (p_symbols)->input_EndStream = input_EndStream; \
......
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