From: Laurent Aimar Date: Mon, 24 Nov 2003 00:39:02 +0000 (+0000) Subject: * all: removed decoder_fifo_t. X-Git-Tag: 0.7.0~382 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=3439df81011c06ba3c10b6aaf649732298f94622;p=vlc * all: removed decoder_fifo_t. --- diff --git a/Makefile.am b/Makefile.am index 338cd268ab..11c34fb39f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -321,8 +321,7 @@ SOURCES_libvlc_common = \ src/input/stream.c \ src/input/demux.c \ src/input/subtitles.c \ - src/input/input_ext-plugins.c \ - src/input/input_ext-dec.c \ + src/input/input_ext-plugins.c \ src/input/input_ext-intf.c \ src/input/input_dec.c \ src/input/input_programs.c \ diff --git a/include/input_ext-dec.h b/include/input_ext-dec.h index be67559c92..e2acfa5878 100644 --- a/include/input_ext-dec.h +++ b/include/input_ext-dec.h @@ -2,7 +2,7 @@ * input_ext-dec.h: structures exported to the VideoLAN decoders ***************************************************************************** * Copyright (C) 1999-2001 VideoLAN - * $Id: input_ext-dec.h,v 1.82 2003/11/06 16:36:41 nitrox Exp $ + * $Id: input_ext-dec.h,v 1.83 2003/11/24 00:39:00 fenrir Exp $ * * Authors: Christophe Massiot * Michel Kaempf @@ -80,455 +80,9 @@ struct pes_packet_t unsigned int i_nb_data; /* Number of data packets in the chained list */ }; -/***************************************************************************** - * decoder_fifo_t - ***************************************************************************** - * This rotative FIFO contains PES packets that are to be decoded. - *****************************************************************************/ -struct decoder_fifo_t -{ - VLC_COMMON_MEMBERS - - /* Thread structures */ - vlc_mutex_t data_lock; /* fifo data lock */ - vlc_cond_t data_wait; /* fifo data conditional variable */ - - /* Data */ - 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 */ - input_buffers_t *p_packets_mgt; /* packets management services data */ - - /* Standard pointers given to the decoders as a toolbox. */ - uint16_t i_id; - vlc_fourcc_t i_fourcc; - es_sys_t * p_demux_data; - stream_ctrl_t * p_stream_ctrl; - sout_instance_t * p_sout; - void * p_waveformatex; - void * p_bitmapinfoheader; - void * p_spuinfo; - - decoder_t * p_dec; -}; - -/***************************************************************************** - * bit_fifo_t : bit fifo descriptor - ***************************************************************************** - * This type describes a bit fifo used to store bits while working with the - * input stream at the bit level. - *****************************************************************************/ -typedef uint32_t WORD_TYPE; - -typedef struct bit_fifo_t -{ - /* This unsigned integer allows us to work at the bit level. This buffer - * can contain 32 bits, and the used space can be found on the MSb's side - * and the available space on the LSb's side. */ - WORD_TYPE buffer; - - /* Number of bits available in the bit buffer */ - int i_available; - -} bit_fifo_t; - -/***************************************************************************** - * bit_stream_t : bit stream descriptor - ***************************************************************************** - * This type, based on a PES stream, includes all the structures needed to - * handle the input stream like a bit stream. - *****************************************************************************/ -struct bit_stream_t -{ - /* - * Bit structures - */ - bit_fifo_t fifo; - - /* - * Input structures - */ - /* The decoder fifo contains the data of the PES stream */ - decoder_fifo_t * p_decoder_fifo; - - /* Callback to the decoder used when changing data packets ; set - * to NULL if your decoder doesn't need it. */ - void (* pf_bitstream_callback)( bit_stream_t *, vlc_bool_t ); - /* Optional argument to the callback */ - void * p_callback_arg; - - /* - * PTS retrieval - */ - mtime_t i_pts, i_dts; - byte_t * p_pts_validity; - - /* - * Byte structures - */ - /* 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; - /* Pointer to the next byte that is to be read (in the current packet) */ - byte_t * p_byte; - /* Pointer to the last byte that is to be read (in the current packet */ - byte_t * p_end; - /* Temporary buffer in case we're not aligned when changing data packets */ - WORD_TYPE i_showbits_buffer; - data_packet_t showbits_data; -}; - -/***************************************************************************** - * Inline functions used by the decoders to read bit_stream_t - *****************************************************************************/ - -/* - * DISCUSSION : How to use the bit_stream structures - * - * sizeof(WORD_TYPE) (usually 32) bits are read at the same time, thus - * minimizing the number of p_byte changes. - * Bits are read via GetBits() or ShowBits. - * - * XXX : Be aware that if, in the forthcoming functions, i_bits > 24, - * the data have to be already aligned on an 8-bit boundary, or wrong - * results will be returned. Use RealignBits() if unsure. - */ - -#if (WORD_TYPE == uint32_t) -# define WORD_AT U32_AT -# define WORD_SIGNED int32_t -#elif (WORD_TYPE == uint64_t) -# define WORD_AT U64_AT -# define WORD_SIGNED int64_t -#else -# error Unsupported WORD_TYPE -#endif - /***************************************************************************** * Prototypes from input_ext-dec.c *****************************************************************************/ -VLC_EXPORT( void, input_ExtractPES, ( decoder_fifo_t *, pes_packet_t ** ) ); VLC_EXPORT( void, input_DeletePES, ( input_buffers_t *, pes_packet_t * ) ); -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 *, bit_stream_t * ) ); -VLC_EXPORT( void, BitstreamNextDataPacket, ( bit_stream_t * ) ); -VLC_EXPORT( uint32_t, UnalignedShowBits, ( bit_stream_t *, unsigned int ) ); -VLC_EXPORT( void, UnalignedRemoveBits, ( bit_stream_t * ) ); -VLC_EXPORT( uint32_t, 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, NextPTS, ( bit_stream_t *, mtime_t *, mtime_t * ) ); - -/***************************************************************************** - * 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 - * empty bytes in the bit buffer) - *****************************************************************************/ -static inline void AlignWord( bit_stream_t * p_bit_stream ) -{ - while( (ptrdiff_t)p_bit_stream->p_byte - & (sizeof(WORD_TYPE) - 1) ) - { - if( p_bit_stream->p_byte < p_bit_stream->p_end ) - { - p_bit_stream->fifo.buffer |= *(p_bit_stream->p_byte++) - << (8 * sizeof(WORD_TYPE) - 8 - - p_bit_stream->fifo.i_available); - p_bit_stream->fifo.i_available += 8; - } - else - { - BitstreamNextDataPacket( p_bit_stream ); - p_bit_stream->fifo.buffer |= *(p_bit_stream->p_byte++) - << (8 * sizeof(WORD_TYPE) - 8 - - p_bit_stream->fifo.i_available); - p_bit_stream->fifo.i_available += 8; - } - } -} - -/***************************************************************************** - * ShowBits : return i_bits bits from the bit stream - *****************************************************************************/ -static inline uint32_t ShowBits( bit_stream_t * p_bit_stream, - unsigned int i_bits ) -{ - if( (unsigned int)p_bit_stream->fifo.i_available >= i_bits ) - { - return( p_bit_stream->fifo.buffer >> (8 * sizeof(WORD_TYPE) - i_bits) ); - } - - if( p_bit_stream->p_byte <= p_bit_stream->p_end - sizeof(WORD_TYPE) ) - { - return( (p_bit_stream->fifo.buffer | - (WORD_AT( p_bit_stream->p_byte ) - >> p_bit_stream->fifo.i_available)) - >> (8 * sizeof(WORD_TYPE) - i_bits) ); - } - - return( UnalignedShowBits( p_bit_stream, i_bits ) ); -} - -/***************************************************************************** - * ShowSignedBits : return i_bits bits from the bit stream, using signed - * arithmetic - *****************************************************************************/ -static inline int32_t ShowSignedBits( bit_stream_t * p_bit_stream, - unsigned int i_bits ) -{ - if( (unsigned int)p_bit_stream->fifo.i_available >= i_bits ) - { - return( (WORD_SIGNED)p_bit_stream->fifo.buffer - >> (8 * sizeof(WORD_TYPE) - i_bits) ); - } - - /* You can probably do something a little faster, but now I'm tired. */ - return( (WORD_SIGNED)(ShowBits( p_bit_stream, i_bits ) << (32 - i_bits)) - >> (32 - i_bits) ); -} - -/***************************************************************************** - * RemoveBits : removes i_bits bits from the bit buffer - * XXX: do not use for 32 bits, see RemoveBits32 - *****************************************************************************/ -static inline void RemoveBits( bit_stream_t * p_bit_stream, - unsigned int i_bits ) -{ - p_bit_stream->fifo.i_available -= i_bits; - - if( p_bit_stream->fifo.i_available >= 0 ) - { - p_bit_stream->fifo.buffer <<= i_bits; - return; - } - - if( p_bit_stream->p_byte <= p_bit_stream->p_end - sizeof(WORD_TYPE) ) - { - p_bit_stream->fifo.buffer = WORD_AT( p_bit_stream->p_byte ) - << ( -p_bit_stream->fifo.i_available ); - p_bit_stream->p_byte = - (byte_t *) ( ((WORD_TYPE *)p_bit_stream->p_byte) + 1 ); - p_bit_stream->fifo.i_available += sizeof(WORD_TYPE) * 8; - return; - } - - UnalignedRemoveBits( p_bit_stream ); -} - -/***************************************************************************** - * RemoveBits32 : removes 32 bits from the bit buffer (and as a side effect, - * refill it) - *****************************************************************************/ -#if (WORD_TYPE == uint32_t) -static inline void RemoveBits32( bit_stream_t * p_bit_stream ) -{ - if( p_bit_stream->p_byte <= p_bit_stream->p_end - sizeof(WORD_TYPE) ) - { - if( p_bit_stream->fifo.i_available ) - { - p_bit_stream->fifo.buffer = WORD_AT( p_bit_stream->p_byte ) - << (32 - p_bit_stream->fifo.i_available); - p_bit_stream->p_byte = - (byte_t *) ( ((WORD_TYPE *)p_bit_stream->p_byte) + 1 ); - return; - } - - p_bit_stream->p_byte = - (byte_t *) ( ((WORD_TYPE *)p_bit_stream->p_byte) + 1 ); - return; - } - - p_bit_stream->fifo.i_available -= 32; - UnalignedRemoveBits( p_bit_stream ); -} -#else -# define RemoveBits32( p_bit_stream ) RemoveBits( p_bit_stream, 32 ) -#endif - -/***************************************************************************** - * GetBits : returns i_bits bits from the bit stream and removes them - * XXX: do not use for 32 bits, see GetBits32 - *****************************************************************************/ -static inline uint32_t GetBits( bit_stream_t * p_bit_stream, - unsigned int i_bits ) -{ - uint32_t i_result; - - p_bit_stream->fifo.i_available -= i_bits; - - if( p_bit_stream->fifo.i_available >= 0 ) - { - i_result = p_bit_stream->fifo.buffer - >> (8 * sizeof(WORD_TYPE) - i_bits); - p_bit_stream->fifo.buffer <<= i_bits; - return( i_result ); - } - - if( p_bit_stream->p_byte <= p_bit_stream->p_end - sizeof(WORD_TYPE) ) - { - i_result = p_bit_stream->fifo.buffer - >> (8 * sizeof(WORD_TYPE) - i_bits); - p_bit_stream->fifo.buffer = WORD_AT( p_bit_stream->p_byte ); - p_bit_stream->p_byte = - (byte_t *) ( ((WORD_TYPE *)p_bit_stream->p_byte) + 1 ); - i_result |= p_bit_stream->fifo.buffer - >> (8 * sizeof(WORD_TYPE) - + p_bit_stream->fifo.i_available); - p_bit_stream->fifo.buffer <<= ( -p_bit_stream->fifo.i_available ); - p_bit_stream->fifo.i_available += sizeof(WORD_TYPE) * 8; - return( i_result ); - } - - return UnalignedGetBits( p_bit_stream, i_bits ); -} - -/***************************************************************************** - * GetSignedBits : returns i_bits bits from the bit stream and removes them, - * using signed arithmetic - * XXX: do not use for 32 bits - *****************************************************************************/ -static inline int32_t GetSignedBits( bit_stream_t * p_bit_stream, - unsigned int i_bits ) -{ - if( (unsigned int)p_bit_stream->fifo.i_available >= i_bits ) - { - int32_t i_result; - - p_bit_stream->fifo.i_available -= i_bits; - i_result = (WORD_SIGNED)p_bit_stream->fifo.buffer - >> (8 * sizeof(WORD_TYPE) - i_bits); - p_bit_stream->fifo.buffer <<= i_bits; - return( i_result ); - } - - /* You can probably do something a little faster, but now I'm tired. */ - return( (WORD_SIGNED)(GetBits( p_bit_stream, i_bits ) << (32 - i_bits)) - >> (32 - i_bits) ); -} - -/***************************************************************************** - * GetBits32 : returns 32 bits from the bit stream and removes them - *****************************************************************************/ -#if (WORD_TYPE == uint32_t) -static inline uint32_t GetBits32( bit_stream_t * p_bit_stream ) -{ - uint32_t i_result; - - if( p_bit_stream->fifo.i_available == 32 ) - { - p_bit_stream->fifo.i_available = 0; - i_result = p_bit_stream->fifo.buffer; - p_bit_stream->fifo.buffer = 0; - return( i_result ); - } - - if( p_bit_stream->p_byte <= p_bit_stream->p_end - sizeof(WORD_TYPE) ) - { - if( p_bit_stream->fifo.i_available ) - { - i_result = p_bit_stream->fifo.buffer; - p_bit_stream->fifo.buffer = WORD_AT( p_bit_stream->p_byte ); - p_bit_stream->p_byte = - (byte_t *) ( ((WORD_TYPE *)p_bit_stream->p_byte) + 1 ); - i_result |= p_bit_stream->fifo.buffer - >> (p_bit_stream->fifo.i_available); - p_bit_stream->fifo.buffer <<= (32 - p_bit_stream->fifo.i_available); - return( i_result ); - } - - i_result = WORD_AT( p_bit_stream->p_byte ); - p_bit_stream->p_byte = - (byte_t *) ( ((WORD_TYPE *)p_bit_stream->p_byte) + 1 ); - return( i_result ); - } - - p_bit_stream->fifo.i_available -= 32; - return UnalignedGetBits( p_bit_stream, 32 ); -} -#else -# define GetBits32( p_bit_stream ) GetBits( p_bit_stream, 32 ) -#endif - -/***************************************************************************** - * RealignBits : realigns the bit buffer on an 8-bit boundary - *****************************************************************************/ -static inline void RealignBits( bit_stream_t * p_bit_stream ) -{ - p_bit_stream->fifo.buffer <<= (p_bit_stream->fifo.i_available & 0x7); - p_bit_stream->fifo.i_available &= ~0x7; -} - - -/***************************************************************************** - * GetChunk : reads a large chunk of data - ***************************************************************************** - * The position in the stream must be byte-aligned, if unsure call - * RealignBits(). p_buffer must point to a buffer at least as big as i_buf_len - * otherwise your code will crash. - *****************************************************************************/ -static inline void GetChunk( bit_stream_t * p_bit_stream, - byte_t * p_buffer, size_t i_buf_len ) -{ - ptrdiff_t i_available; - - /* We need to take care because i_buf_len may be < 4. */ - while( p_bit_stream->fifo.i_available > 0 && i_buf_len ) - { - *p_buffer = p_bit_stream->fifo.buffer >> (8 * sizeof(WORD_TYPE) - 8); - p_buffer++; - i_buf_len--; - p_bit_stream->fifo.buffer <<= 8; - p_bit_stream->fifo.i_available -= 8; - } - - i_available = p_bit_stream->p_end - p_bit_stream->p_byte; - if( i_available >= (ptrdiff_t)i_buf_len ) - { - p_bit_stream->p_decoder_fifo->p_vlc->pf_memcpy( p_buffer, - p_bit_stream->p_byte, i_buf_len ); - p_bit_stream->p_byte += i_buf_len; - } - else - { - do - { - p_bit_stream->p_decoder_fifo->p_vlc->pf_memcpy( p_buffer, - p_bit_stream->p_byte, i_available ); - p_bit_stream->p_byte = p_bit_stream->p_end; - p_buffer += i_available; - i_buf_len -= i_available; - BitstreamNextDataPacket( p_bit_stream ); - if( p_bit_stream->p_decoder_fifo->b_die ) - return; - } - while( (i_available = p_bit_stream->p_end - p_bit_stream->p_byte) - <= (ptrdiff_t)i_buf_len ); - - if( i_buf_len ) - { - p_bit_stream->p_decoder_fifo->p_vlc->pf_memcpy( p_buffer, - p_bit_stream->p_byte, i_buf_len ); - p_bit_stream->p_byte += i_buf_len; - } - } - - if( p_bit_stream->p_byte <= p_bit_stream->p_end - sizeof(WORD_TYPE) ) - { - AlignWord( p_bit_stream ); - } -} - - -/* - * Communication interface between input and decoders - */ - -/***************************************************************************** - * Prototypes from input_dec.c - *****************************************************************************/ -VLC_EXPORT( void, DecoderError, ( decoder_fifo_t * p_fifo ) ); #endif /* "input_ext-dec.h" */ diff --git a/include/input_ext-intf.h b/include/input_ext-intf.h index 6a046b0543..e11908f198 100644 --- a/include/input_ext-intf.h +++ b/include/input_ext-intf.h @@ -4,7 +4,7 @@ * control the pace of reading. ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN - * $Id: input_ext-intf.h,v 1.99 2003/11/22 18:04:10 gbazin Exp $ + * $Id: input_ext-intf.h,v 1.100 2003/11/24 00:39:00 fenrir Exp $ * * Authors: Christophe Massiot * @@ -68,10 +68,11 @@ struct es_descriptor_t /* Decoder information */ es_format_t fmt; - decoder_fifo_t * p_decoder_fifo; void * p_waveformatex; void * p_bitmapinfoheader; void * p_spuinfo; + /* Decoder */ + decoder_t * p_dec; count_t c_packets; /* total packets read */ count_t c_invalid_packets; /* invalid packets read */ diff --git a/include/input_ext-plugins.h b/include/input_ext-plugins.h index e84a44ddde..96c738c0bb 100644 --- a/include/input_ext-plugins.h +++ b/include/input_ext-plugins.h @@ -3,7 +3,7 @@ * but exported to plug-ins ***************************************************************************** * Copyright (C) 1999-2002 VideoLAN - * $Id: input_ext-plugins.h,v 1.42 2003/05/05 22:23:31 gbazin Exp $ + * $Id: input_ext-plugins.h,v 1.43 2003/11/24 00:39:00 fenrir Exp $ * * Authors: Christophe Massiot * @@ -55,9 +55,12 @@ VLC_EXPORT( int, input_UnselectES,( input_thread_t *, es_descriptor_t * ) ); /***************************************************************************** * Prototypes from input_dec.c *****************************************************************************/ -decoder_fifo_t * input_RunDecoder( input_thread_t *, es_descriptor_t * ); +decoder_t * input_RunDecoder( 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_t *, pes_packet_t * ) ); +void input_DecodeBlock( decoder_t *, block_t * ); + void input_EscapeDiscontinuity( input_thread_t * ); void input_EscapeAudioDiscontinuity( input_thread_t * ); VLC_EXPORT( void, input_NullPacket, ( input_thread_t *, es_descriptor_t * ) ); diff --git a/include/vlc_codec.h b/include/vlc_codec.h index 180538a09b..0907186385 100644 --- a/include/vlc_codec.h +++ b/include/vlc_codec.h @@ -2,7 +2,7 @@ * vlc_codec.h: codec related structures ***************************************************************************** * Copyright (C) 1999-2003 VideoLAN - * $Id: vlc_codec.h,v 1.4 2003/11/16 21:07:30 gbazin Exp $ + * $Id: vlc_codec.h,v 1.5 2003/11/24 00:39:00 fenrir Exp $ * * Authors: Gildas Bazin * @@ -48,12 +48,6 @@ struct decoder_t module_t * p_module; decoder_sys_t * p_sys; - /* Deprecated */ - int ( * pf_decode )( decoder_t *, block_t * ); - decoder_fifo_t * p_fifo; - int ( * pf_run ) ( decoder_fifo_t * ); - /* End deprecated */ - picture_t * ( * pf_decode_video )( decoder_t *, block_t ** ); aout_buffer_t * ( * pf_decode_audio )( decoder_t *, block_t ** ); void ( * pf_decode_sub) ( decoder_t *, block_t ** ); diff --git a/include/vlc_common.h b/include/vlc_common.h index d2290971ef..ac1b75de00 100644 --- a/include/vlc_common.h +++ b/include/vlc_common.h @@ -3,7 +3,7 @@ * Collection of useful common types and macros definitions ***************************************************************************** * Copyright (C) 1998, 1999, 2000 VideoLAN - * $Id: vlc_common.h,v 1.89 2003/11/22 13:56:21 ipkiss Exp $ + * $Id: vlc_common.h,v 1.90 2003/11/24 00:39:00 fenrir Exp $ * * Authors: Samuel Hocevar * Vincent Seguin @@ -270,7 +270,6 @@ typedef struct sout_cfg_t sout_cfg_t; typedef struct slp_session_t slp_session_t;*/ /* Decoders */ -typedef struct decoder_fifo_t decoder_fifo_t; typedef struct decoder_t decoder_t; typedef struct decoder_sys_t decoder_sys_t; @@ -284,7 +283,6 @@ typedef struct data_buffer_t data_buffer_t; typedef struct stream_position_t stream_position_t; typedef struct stream_ctrl_t stream_ctrl_t; typedef struct pes_packet_t pes_packet_t; -typedef struct bit_stream_t bit_stream_t; typedef struct network_socket_t network_socket_t; typedef struct iso639_lang_t iso639_lang_t; diff --git a/include/vlc_es.h b/include/vlc_es.h index f836db887f..b204c07612 100644 --- a/include/vlc_es.h +++ b/include/vlc_es.h @@ -2,7 +2,7 @@ * vlc_es.h ***************************************************************************** * Copyright (C) 1999-2001 VideoLAN - * $Id: vlc_es.h,v 1.3 2003/11/22 18:04:10 gbazin Exp $ + * $Id: vlc_es.h,v 1.4 2003/11/24 00:39:00 fenrir Exp $ * * Authors: Laurent Aimar * @@ -87,6 +87,11 @@ struct subs_format_t { char *psz_encoding; + struct + { + /* FIXME */ + uint32_t palette[16+1]; + } spu; }; /** diff --git a/include/vlc_objects.h b/include/vlc_objects.h index 5ced55bffa..ec74cd0890 100644 --- a/include/vlc_objects.h +++ b/include/vlc_objects.h @@ -2,7 +2,7 @@ * vlc_objects.h: vlc_object_t definition. ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: vlc_objects.h,v 1.20 2003/10/14 22:41:41 gbazin Exp $ + * $Id: vlc_objects.h,v 1.21 2003/11/24 00:39:00 fenrir Exp $ * * Authors: Samuel Hocevar * @@ -40,8 +40,6 @@ #define VLC_OBJECT_ITEM (-6) #define VLC_OBJECT_INPUT (-7) #define VLC_OBJECT_DECODER (-8) -/* tmp for backward compat */ -#define VLC_OBJECT_DECODER_FIFO (-999) #define VLC_OBJECT_VOUT (-9) #define VLC_OBJECT_AOUT (-10) #define VLC_OBJECT_SOUT (-11) diff --git a/modules/access/cdda.c b/modules/access/cdda.c index e3c6cf26f4..a32144f5c7 100644 --- a/modules/access/cdda.c +++ b/modules/access/cdda.c @@ -2,7 +2,7 @@ * cdda.c : CD digital audio input module for vlc ***************************************************************************** * Copyright (C) 2000 VideoLAN - * $Id: cdda.c,v 1.6 2003/09/07 22:49:05 fenrir Exp $ + * $Id: cdda.c,v 1.7 2003/11/24 00:39:01 fenrir Exp $ * * Authors: Laurent Aimar * Gildas Bazin @@ -492,9 +492,9 @@ static int CDDADemux( input_thread_t * p_input ) p_input->stream.p_selected_program, p_demux->i_pts ); - if( p_demux->p_es->p_decoder_fifo ) + if( p_demux->p_es->p_dec ) { - input_DecodePES( p_demux->p_es->p_decoder_fifo, p_pes ); + input_DecodePES( p_demux->p_es->p_dec, p_pes ); } else { diff --git a/modules/access/cddax.c b/modules/access/cddax.c index 366ffd8b38..ee32689480 100644 --- a/modules/access/cddax.c +++ b/modules/access/cddax.c @@ -2,7 +2,7 @@ * cddax.c : CD digital audio input module for vlc using libcdio ***************************************************************************** * Copyright (C) 2000 VideoLAN - * $Id: cddax.c,v 1.4 2003/11/23 14:34:19 rocky Exp $ + * $Id: cddax.c,v 1.5 2003/11/24 00:39:01 fenrir Exp $ * * Authors: Laurent Aimar * Gildas Bazin @@ -629,9 +629,9 @@ static int CDDADemux( input_thread_t * p_input ) p_input->stream.p_selected_program, p_demux->i_pts ); - if( p_demux->p_es->p_decoder_fifo ) + if( p_demux->p_es->p_dec ) { - input_DecodePES( p_demux->p_es->p_decoder_fifo, p_pes ); + input_DecodePES( p_demux->p_es->p_dec, p_pes ); } else { diff --git a/modules/access/dshow/dshow.cpp b/modules/access/dshow/dshow.cpp index 96dd2a1a78..2ca6e82ba6 100644 --- a/modules/access/dshow/dshow.cpp +++ b/modules/access/dshow/dshow.cpp @@ -2,7 +2,7 @@ * dshow.cpp : DirectShow access module for vlc ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: dshow.cpp,v 1.13 2003/11/05 02:43:55 gbazin Exp $ + * $Id: dshow.cpp,v 1.14 2003/11/24 00:39:01 fenrir Exp $ * * Author: Gildas Bazin * @@ -1331,7 +1331,7 @@ static int Demux( input_thread_t *p_input ) p_pes->p_first->p_payload_start += 16; p_pes->i_pes_size -= 16; - if( p_es && p_es->p_decoder_fifo ) + if( p_es && p_es->p_dec ) { /* Call the pace control. */ input_ClockManageRef( p_input, p_input->stream.p_selected_program, @@ -1341,7 +1341,7 @@ static int Demux( input_thread_t *p_input ) input_ClockGetTS( p_input, p_input->stream.p_selected_program, i_pcr ); - input_DecodePES( p_es->p_decoder_fifo, p_pes ); + input_DecodePES( p_es->p_dec, p_pes ); } else { diff --git a/modules/access/dvb/access.c b/modules/access/dvb/access.c index 22b447279d..e5d2e553dc 100644 --- a/modules/access/dvb/access.c +++ b/modules/access/dvb/access.c @@ -554,7 +554,7 @@ void E_(Close) ( vlc_object_t *p_this ) i_es_index ++ ) { #define p_es p_input->stream.p_selected_program->pp_es[i_es_index] - if ( p_es->p_decoder_fifo ) + if ( p_es->p_dec ) { ioctl_UnsetDMXFilter(p_input, p_es->i_demux_fd ); } @@ -641,7 +641,7 @@ int SatelliteSetProgram( input_thread_t * p_input, i_es_index ++ ) { #define p_es p_input->stream.p_selected_program->pp_es[i_es_index] - if ( p_es->p_decoder_fifo ) + if ( p_es->p_dec ) { input_UnselectES( p_input , p_es ); } diff --git a/modules/access/satellite/access.c b/modules/access/satellite/access.c index 55200f669c..00e696fba7 100644 --- a/modules/access/satellite/access.c +++ b/modules/access/satellite/access.c @@ -331,7 +331,7 @@ void E_(Close) ( vlc_object_t *p_this ) i_es_index ++ ) { #define p_es p_input->stream.p_selected_program->pp_es[i_es_index] - if ( p_es->p_decoder_fifo ) + if ( p_es->p_dec ) { ioctl_UnsetDMXFilter( p_es->i_demux_fd ); } @@ -420,7 +420,7 @@ int SatelliteSetProgram( input_thread_t * p_input, i_es_index ++ ) { #define p_es p_input->stream.p_selected_program->pp_es[i_es_index] - if ( p_es->p_decoder_fifo ) + if ( p_es->p_dec ) { input_UnselectES( p_input , p_es ); } diff --git a/modules/access/v4l/v4l.c b/modules/access/v4l/v4l.c index 813845f337..9832bb1392 100644 --- a/modules/access/v4l/v4l.c +++ b/modules/access/v4l/v4l.c @@ -2,7 +2,7 @@ * v4l.c : Video4Linux input module for vlc ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: v4l.c,v 1.31 2003/11/23 18:31:54 alexis Exp $ + * $Id: v4l.c,v 1.32 2003/11/24 00:39:01 fenrir Exp $ * * Author: Laurent Aimar * Paul Forgey @@ -1657,19 +1657,12 @@ static int Demux( input_thread_t *p_input ) p_pes->p_first->p_payload_start += 16; p_pes->i_pes_size -= 16; - if( p_es && p_es->p_decoder_fifo ) + if( p_es && p_es->p_dec ) { - vlc_mutex_lock( &p_es->p_decoder_fifo->data_lock ); - if( p_es->p_decoder_fifo->i_depth >= MAX_PACKETS_IN_FIFO ) - { - /* Wait for the decoder. */ - vlc_cond_wait( &p_es->p_decoder_fifo->data_wait, - &p_es->p_decoder_fifo->data_lock ); - } - vlc_mutex_unlock( &p_es->p_decoder_fifo->data_lock ); - p_pes->i_pts = p_pes->i_dts = i_pts + p_input->i_pts_delay; + p_pes->i_pts = + p_pes->i_dts = i_pts + p_input->i_pts_delay; - input_DecodePES( p_es->p_decoder_fifo, p_pes ); + input_DecodePES( p_es->p_dec, p_pes ); } else { diff --git a/modules/codec/dvbsub.c b/modules/codec/dvbsub.c index c8b2104c1e..1b8ff2bc65 100644 --- a/modules/codec/dvbsub.c +++ b/modules/codec/dvbsub.c @@ -2,7 +2,8 @@ * dvbsub.c : DVB subtitles decoder thread ***************************************************************************** * Copyright (C) 2003 ANEVIA - * $Id: dvbsub.c,v 1.4 2003/11/22 23:39:14 fenrir Exp $ + * Copyright (C) 2003 VideoLAN + * $Id: dvbsub.c,v 1.5 2003/11/24 00:39:01 fenrir Exp $ * * Authors: Damien LUCAS * @@ -27,7 +28,21 @@ #include #include -#include "codecs.h" +#include "vlc_bits.h" + +/***************************************************************************** + * Module descriptor. + *****************************************************************************/ +static int Open ( vlc_object_t *p_this ); +static void Close( vlc_object_t *p_this ); + +vlc_module_begin(); + add_category_hint( N_("subtitles"), NULL, VLC_TRUE ); + set_description( _("subtitles decoder") ); + set_capability( "decoder", 50 ); + set_callbacks( Open, Close ); +vlc_module_end(); + // Wow, that's ugly but very usefull for a memory leak track // so I just keep it @@ -175,16 +190,7 @@ typedef struct dvbsub_object_t* p_objects; subpicture_t* p_spu[16]; } dvbsub_all_t; -typedef struct -{ - /* Thread properties and locks */ - vlc_thread_t thread_id; /* Id for thread functions */ - /* Input properties */ - decoder_fifo_t* p_fifo; /* Stores the PES stream data */ - bit_stream_t bit_stream; /* PES data at the bit level */ - /* Output properties */ - vout_thread_t* p_vout; /* Needed to create the subpictures */ -} dvbsub_thread_t; + struct subpicture_sys_t { mtime_t i_pts; @@ -192,6 +198,16 @@ struct subpicture_sys_t vlc_object_t* p_input; /* Link to the input */ vlc_bool_t b_obsolete; }; + +struct decoder_sys_t +{ + vout_thread_t *p_vout; + mtime_t i_pts; + + bs_t bs; +}; + + // List of different SEGMENT TYPES // According to EN 300-743, table 2 #define DVBSUB_ST_PAGE_COMPOSITION 0x10 @@ -218,11 +234,10 @@ struct subpicture_sys_t /***************************************************************************** * Local prototypes *****************************************************************************/ -static int OpenDecoder ( vlc_object_t * ); -static int RunDecoder ( decoder_fifo_t * ); -static int InitThread ( dvbsub_thread_t * ); -static void EndThread ( dvbsub_thread_t *i, dvbsub_all_t*); -static vout_thread_t *FindVout( dvbsub_thread_t * ); +static void Decode ( decoder_t *, block_t ** ); + +static vout_thread_t *FindVout( decoder_t * ); + static void RenderI42x( vout_thread_t *, picture_t *, const subpicture_t *, vlc_bool_t ); static void RenderYUY2( vout_thread_t *, picture_t *, const subpicture_t *, @@ -256,30 +271,59 @@ static void free_all ( dvbsub_all_t* p_a ); /***************************************************************************** - * Module descriptor. - *****************************************************************************/ -vlc_module_begin(); - add_category_hint( N_("subtitles"), NULL, VLC_TRUE ); - set_description( _("subtitles decoder") ); - set_capability( "decoder", 50 ); - set_callbacks( OpenDecoder, NULL ); -vlc_module_end(); -/***************************************************************************** - * OpenDecoder: probe the decoder and return score + * Open: probe the decoder and return score ***************************************************************************** * Tries to launch a decoder and return score so that the interface is able * to chose. *****************************************************************************/ -static int OpenDecoder( vlc_object_t *p_this ) +static int Open( vlc_object_t *p_this ) { - decoder_t *p_dec = (decoder_t*) p_this; + decoder_t *p_dec = (decoder_t*) p_this; + decoder_sys_t *p_sys; + if( p_dec->fmt_in.i_codec != VLC_FOURCC('d','v','b','s') ) { return VLC_EGENERIC; } - p_dec->pf_run = RunDecoder; + + p_dec->pf_decode_subs = Decode; + p_sys = p_dec->p_sys = malloc( sizeof( decoder_sys_t ) ); + + p_sys->p_vout = NULL; + p_sys->i_pts = 0; + + es_format_Init( &p_dec->fmt_out, SPU_ES, VLC_FOURCC( 'd','v','b','s' ) ); + return VLC_SUCCESS; } + +/***************************************************************************** + * Close: + *****************************************************************************/ +static void Close( vlc_object_t *p_this ) +{ + decoder_t *p_dec = (decoder_t*) p_this; + decoder_sys_t *p_sys = p_dec->p_sys; + + if( p_sys->p_vout && p_sys->p_vout->p_subpicture != NULL ) + { + subpicture_t * p_subpic; + int i_subpic; + for( i_subpic = 0; i_subpic < VOUT_MAX_SUBPICTURES; i_subpic++ ) + { + p_subpic = &p_sys->p_vout->p_subpicture[i_subpic]; + if( p_subpic != NULL && + ( ( p_subpic->i_status == RESERVED_SUBPICTURE ) + || ( p_subpic->i_status == READY_SUBPICTURE ) ) ) + { + vout_DestroySubPicture( p_sys->p_vout, p_subpic ); + } + } + } + + trox_call(); +} + /***************************************************************************** * RunDecoder: this function is called just after the thread is created *****************************************************************************/ @@ -350,56 +394,30 @@ static int RunDecoder( decoder_fifo_t * p_fifo ) free_all(&dvbsub); return 0; } + /* following functions are local */ -/***************************************************************************** - * InitThread: initialize dvbsub decoder thread - ***************************************************************************** - * This function is called from RunThread and performs the second step of the - * initialization. It returns 0 on success. Note that the thread's flag are not - * modified inside this function. - *****************************************************************************/ -static int InitThread( dvbsub_thread_t *p_dvbsubdec ) -{ - int i_ret; - /* Call InitBitstream anyway so p_spudec->bit_stream is in a known - * state before calling CloseBitstream */ - i_ret = InitBitstream( &p_dvbsubdec->bit_stream, p_dvbsubdec->p_fifo, - NULL, NULL ); - /* Check for a video output */ - p_dvbsubdec->p_vout = FindVout( p_dvbsubdec ); - if( !p_dvbsubdec->p_vout ) - { - return -1; - } - /* It was just a check */ - vlc_object_release( p_dvbsubdec->p_vout ); - p_dvbsubdec->p_vout = NULL; - return i_ret; -} /***************************************************************************** * FindVout: Find a vout or wait for one to be created. *****************************************************************************/ -static vout_thread_t *FindVout( dvbsub_thread_t *p_spudec ) +static vout_thread_t *FindVout( decoder_t *p_dec ) { - vout_thread_t *p_vout = NULL; - /* Find an available video output */ - do + for( ;; ) { - if( p_spudec->p_fifo->b_die || p_spudec->p_fifo->b_error ) + vout_thread_t *p_vout; + + if( p_dec->b_die || p_dec->b_error ) { - break; + return NULL; } - p_vout = vlc_object_find( p_spudec->p_fifo, VLC_OBJECT_VOUT, - FIND_ANYWHERE ); + p_vout = vlc_object_find( p_dec, VLC_OBJECT_VOUT, FIND_ANYWHERE ); if( p_vout ) { - break; + return p_vout; } msleep( VOUT_OUTMEM_SLEEP ); } - while( 1 ); - return p_vout; } + /***************************************************************************** * EndThread: thread destruction ***************************************************************************** diff --git a/modules/codec/ffmpeg/audio.c b/modules/codec/ffmpeg/audio.c index 6842ee26fa..8e870f613a 100644 --- a/modules/codec/ffmpeg/audio.c +++ b/modules/codec/ffmpeg/audio.c @@ -2,7 +2,7 @@ * audio.c: audio decoder using ffmpeg library ***************************************************************************** * Copyright (C) 1999-2003 VideoLAN - * $Id: audio.c,v 1.25 2003/11/22 23:39:14 fenrir Exp $ + * $Id: audio.c,v 1.26 2003/11/24 00:39:01 fenrir Exp $ * * Authors: Laurent Aimar * Gildas Bazin @@ -79,6 +79,9 @@ int E_(InitAudioDec)( decoder_t *p_dec, AVCodecContext *p_context, AVCodec *p_codec, int i_codec_id, char *psz_namecodec ) { decoder_sys_t *p_sys; + vlc_value_t lockval; + + var_Get( p_dec->p_libvlc, "avcodec", &lockval ); /* Allocate the memory needed to store the decoder's structure */ if( ( p_dec->p_sys = p_sys = @@ -110,15 +113,16 @@ int E_(InitAudioDec)( decoder_t *p_dec, AVCodecContext *p_context, } /* ***** Open the codec ***** */ + vlc_mutex_lock( lockval.p_address ); if (avcodec_open( p_sys->p_context, p_sys->p_codec ) < 0) { + vlc_mutex_unlock( lockval.p_address ); msg_Err( p_dec, "cannot open codec (%s)", p_sys->psz_namecodec ); return VLC_EGENERIC; } - else - { - msg_Dbg( p_dec, "ffmpeg codec (%s) started", p_sys->psz_namecodec ); - } + vlc_mutex_unlock( lockval.p_address ); + + msg_Dbg( p_dec, "ffmpeg codec (%s) started", p_sys->psz_namecodec ); p_sys->p_output = malloc( 3 * AVCODEC_MAX_AUDIO_FRAME_SIZE ); diff --git a/modules/codec/ffmpeg/video.c b/modules/codec/ffmpeg/video.c index 56b71d0882..ab7744ee77 100644 --- a/modules/codec/ffmpeg/video.c +++ b/modules/codec/ffmpeg/video.c @@ -2,7 +2,7 @@ * video.c: video decoder using the ffmpeg library ***************************************************************************** * Copyright (C) 1999-2001 VideoLAN - * $Id: video.c,v 1.51 2003/11/23 20:37:04 gbazin Exp $ + * $Id: video.c,v 1.52 2003/11/24 00:39:01 fenrir Exp $ * * Authors: Laurent Aimar * Gildas Bazin @@ -184,9 +184,13 @@ int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context, AVCodec *p_codec, int i_codec_id, char *psz_namecodec ) { decoder_sys_t *p_sys; + vlc_value_t lockval; vlc_value_t val; int i_tmp; + + var_Get( p_dec->p_libvlc, "avcodec", &lockval ); + /* Allocate the memory needed to store the decoder's structure */ if( ( p_dec->p_sys = p_sys = (decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL ) @@ -224,15 +228,15 @@ int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context, #endif /* ***** Open the codec ***** */ + vlc_mutex_lock( lockval.p_address ); if( avcodec_open( p_sys->p_context, p_sys->p_codec ) < 0 ) { + vlc_mutex_unlock( lockval.p_address ); msg_Err( p_dec, "cannot open codec (%s)", p_sys->psz_namecodec ); return VLC_EGENERIC; } - else - { - msg_Dbg( p_dec, "ffmpeg codec (%s) started", p_sys->psz_namecodec ); - } + vlc_mutex_unlock( lockval.p_address ); + msg_Dbg( p_dec, "ffmpeg codec (%s) started", p_sys->psz_namecodec ); /* ***** ffmpeg frame skipping ***** */ var_Create( p_dec, "ffmpeg-hurry-up", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); diff --git a/modules/codec/spudec/parse.c b/modules/codec/spudec/parse.c index 9ffccb387f..a67623dbb5 100644 --- a/modules/codec/spudec/parse.c +++ b/modules/codec/spudec/parse.c @@ -2,7 +2,7 @@ * parse.c: SPU parser ***************************************************************************** * Copyright (C) 2000-2001 VideoLAN - * $Id: parse.c,v 1.15 2003/11/22 23:39:14 fenrir Exp $ + * $Id: parse.c,v 1.16 2003/11/24 00:39:01 fenrir Exp $ * * Authors: Samuel Hocevar * Laurent Aimar @@ -225,8 +225,7 @@ static int ParseControlSeq( decoder_t *p_dec, subpicture_t * p_spu ) case SPU_CMD_SET_PALETTE: /* 03xxxx (palette) */ - if( p_dec->p_fifo->p_demux_data - && *(int*)p_dec->p_fifo->p_demux_data == 0xBeeF ) + if( p_dec->fmt_in.subs.spu.palette[0] == 0xBeeF ) { unsigned int idx[4]; @@ -239,9 +238,7 @@ static int ParseControlSeq( decoder_t *p_dec, subpicture_t * p_spu ) for( i = 0; i < 4 ; i++ ) { - uint32_t i_color; - i_color = ((uint32_t*)((char*)p_dec->p_fifo->p_demux_data + - sizeof(int)))[idx[i]]; + uint32_t i_color = p_dec->fmt_in.subs.spu.palette[1+idx[i]]; /* FIXME: this job should be done sooner */ p_spu->p_sys->pi_yuv[3-i][0] = (i_color>>16) & 0xff; diff --git a/modules/demux/flac.c b/modules/demux/flac.c index 9809dfc37d..fabf8712ce 100644 --- a/modules/demux/flac.c +++ b/modules/demux/flac.c @@ -2,7 +2,7 @@ * flac.c : FLAC demux module for vlc ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: flac.c,v 1.8 2003/11/21 20:49:13 gbazin Exp $ + * $Id: flac.c,v 1.9 2003/11/24 00:39:01 fenrir Exp $ * * Authors: Gildas Bazin * @@ -117,12 +117,10 @@ static int Open( vlc_object_t * p_this ) * Load the FLAC packetizer */ p_sys->p_packetizer = vlc_object_create( p_input, VLC_OBJECT_DECODER ); - p_sys->p_packetizer->pf_decode = 0; p_sys->p_packetizer->pf_decode_audio = 0; p_sys->p_packetizer->pf_decode_video = 0; p_sys->p_packetizer->pf_decode_sub = 0; p_sys->p_packetizer->pf_packetize = 0; - p_sys->p_packetizer->pf_run = 0; /* Initialization of decoder structure */ es_format_Init( &p_sys->p_packetizer->fmt_in, AUDIO_ES, diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c index 98909f158f..378adc8e60 100644 --- a/modules/demux/mp4/mp4.c +++ b/modules/demux/mp4/mp4.c @@ -2,7 +2,7 @@ * mp4.c : MP4 file input module for vlc ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: mp4.c,v 1.41 2003/11/23 13:15:27 gbazin Exp $ + * $Id: mp4.c,v 1.42 2003/11/24 00:39:01 fenrir Exp $ * Authors: Laurent Aimar * * This program is free software; you can redistribute it and/or modify @@ -425,11 +425,11 @@ static int Demux( input_thread_t *p_input ) } else if( track.b_ok ) { - if( track.b_selected && track.p_es->p_decoder_fifo == NULL ) + if( track.b_selected && track.p_es->p_dec == NULL ) { MP4_TrackUnselect( p_input, &track ); } - else if( !track.b_selected && track.p_es->p_decoder_fifo != NULL ) + else if( !track.b_selected && track.p_es->p_dec != NULL ) { MP4_TrackSelect( p_input, &track, MP4_GetMoviePTS( p_demux ) ); } @@ -532,11 +532,11 @@ static int Demux( input_thread_t *p_input ) p_pes->i_pts = 0; } - if( track.p_es->p_decoder_fifo ) + if( track.p_es->p_dec ) { p_pes->i_rate = p_input->stream.control.i_rate; - input_DecodePES( track.p_es->p_decoder_fifo, p_pes ); + input_DecodePES( track.p_es->p_dec, p_pes ); } else { @@ -1372,19 +1372,19 @@ static int TrackGotoChunkSample( input_thread_t *p_input, } /* select again the new decoder */ - if( p_track->b_selected && p_track->p_es && p_track->p_es->p_decoder_fifo == NULL ) + if( p_track->b_selected && p_track->p_es && p_track->p_es->p_dec == NULL ) { vlc_mutex_lock( &p_input->stream.stream_lock ); input_SelectES( p_input, p_track->p_es ); vlc_mutex_unlock( &p_input->stream.stream_lock ); - if( p_track->p_es->p_decoder_fifo ) + if( p_track->p_es->p_dec ) { if( p_track->p_pes_init != NULL ) { p_track->p_pes_init->i_rate = p_input->stream.control.i_rate; - input_DecodePES( p_track->p_es->p_decoder_fifo, + input_DecodePES( p_track->p_es->p_dec, p_track->p_pes_init ); p_track->p_pes_init = NULL; } @@ -1663,7 +1663,7 @@ static void MP4_TrackUnselect(input_thread_t *p_input, return; } - if( p_track->p_es->p_decoder_fifo ) + if( p_track->p_es->p_dec ) { vlc_mutex_lock( &p_input->stream.stream_lock ); input_UnselectES( p_input, p_track->p_es ); diff --git a/modules/demux/mpeg/m4v.c b/modules/demux/mpeg/m4v.c index 0646c3fbf3..b40aa19778 100644 --- a/modules/demux/mpeg/m4v.c +++ b/modules/demux/mpeg/m4v.c @@ -2,7 +2,7 @@ * m4v.c : MPEG-4 video Stream input module for vlc ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: m4v.c,v 1.8 2003/09/10 11:51:00 fenrir Exp $ + * $Id: m4v.c,v 1.9 2003/11/24 00:39:01 fenrir Exp $ * * Authors: Laurent Aimar * @@ -275,7 +275,7 @@ static int Demux( input_thread_t * p_input ) p_input->stream.p_selected_program, p_demux->i_dts ); - if( !p_demux->p_es->p_decoder_fifo ) + if( !p_demux->p_es->p_dec ) { msg_Err( p_input, "no video decoder" ); input_DeletePES( p_input->p_method_data, p_pes ); @@ -283,7 +283,7 @@ static int Demux( input_thread_t * p_input ) } else { - input_DecodePES( p_demux->p_es->p_decoder_fifo, p_pes ); + input_DecodePES( p_demux->p_es->p_dec, p_pes ); } /* FIXME FIXME FIXME FIXME */ p_demux->i_dts += (mtime_t)90000 / 25; diff --git a/modules/demux/mpeg/mpgv.c b/modules/demux/mpeg/mpgv.c index 276d1b97c0..84da166acb 100644 --- a/modules/demux/mpeg/mpgv.c +++ b/modules/demux/mpeg/mpgv.c @@ -2,7 +2,7 @@ * mpgv.c : MPEG-I/II Video demuxer ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: mpgv.c,v 1.1 2003/11/22 17:03:57 fenrir Exp $ + * $Id: mpgv.c,v 1.2 2003/11/24 00:39:01 fenrir Exp $ * * Authors: Laurent Aimar * @@ -130,12 +130,10 @@ static int Open( vlc_object_t * p_this ) * Load the mpegvideo packetizer */ p_sys->p_packetizer = vlc_object_create( p_input, VLC_OBJECT_PACKETIZER ); - p_sys->p_packetizer->pf_decode = NULL; p_sys->p_packetizer->pf_decode_audio = NULL; p_sys->p_packetizer->pf_decode_video = NULL; p_sys->p_packetizer->pf_decode_sub = NULL; p_sys->p_packetizer->pf_packetize = NULL; - p_sys->p_packetizer->pf_run = NULL; es_format_Init( &p_sys->p_packetizer->fmt_in, VIDEO_ES, VLC_FOURCC( 'm', 'p', 'g', 'v' ) ); es_format_Init( &p_sys->p_packetizer->fmt_out, UNKNOWN_ES, 0 ); p_sys->p_packetizer->p_module = diff --git a/modules/demux/mpeg/system.c b/modules/demux/mpeg/system.c index 6ca75b49b1..5408f0269b 100644 --- a/modules/demux/mpeg/system.c +++ b/modules/demux/mpeg/system.c @@ -2,7 +2,7 @@ * system.c: helper module for TS, PS and PES management ***************************************************************************** * Copyright (C) 1998-2002 VideoLAN - * $Id: system.c,v 1.19 2003/11/06 16:36:41 nitrox Exp $ + * $Id: system.c,v 1.20 2003/11/24 00:39:01 fenrir Exp $ * * Authors: Christophe Massiot * Michel Lespinasse @@ -414,11 +414,11 @@ static void ParsePES( input_thread_t * p_input, es_descriptor_t * p_es ) /* Now we can eventually put the PES packet in the decoder's * PES fifo */ - if( p_es->p_decoder_fifo != NULL ) + if( p_es->p_dec != NULL ) { - input_DecodePES( p_es->p_decoder_fifo, p_pes ); + input_DecodePES( p_es->p_dec, p_pes ); } - else if ( p_es->p_decoder_fifo == NULL && + else if ( p_es->p_dec == NULL && ((es_ts_data_t*)p_es->p_demux_data)->b_dvbsub) { es_descriptor_t* p_dvbsub; @@ -430,9 +430,9 @@ static void ParsePES( input_thread_t * p_input, es_descriptor_t * p_es ) for(i = 0; i < i_count; i++) { p_dvbsub = ((es_ts_data_t*)p_es->p_demux_data)->p_dvbsub_es[i]; - if(p_dvbsub->p_decoder_fifo!=NULL) + if(p_dvbsub->p_dec !=NULL) { - input_DecodePES ( p_dvbsub->p_decoder_fifo, p_pes ); + input_DecodePES ( p_dvbsub->p_dec, p_pes ); break; } } @@ -1112,7 +1112,7 @@ static void DemuxPS( input_thread_t * p_input, data_packet_t * p_data ) p_es = ParsePS( p_input, p_data ); vlc_mutex_lock( &p_input->stream.control.control_lock ); - if( p_es != NULL && p_es->p_decoder_fifo != NULL + if( p_es != NULL && p_es->p_dec != NULL && (p_es->i_cat != AUDIO_ES || !p_input->stream.control.b_mute) ) { vlc_mutex_unlock( &p_input->stream.control.control_lock ); @@ -1271,7 +1271,7 @@ static void DemuxTS( input_thread_t * p_input, data_packet_t * p_data, /* Not selected. Just read the adaptation field for a PCR. */ b_trash = 1; } - else if( p_es->p_decoder_fifo == NULL && !b_psi && !b_dvbsub ) + else if( p_es->p_dec == NULL && !b_psi && !b_dvbsub ) { b_trash = 1; } @@ -1284,7 +1284,7 @@ static void DemuxTS( input_thread_t * p_input, data_packet_t * p_data, * may still be null. Who said it was ugly ? * I have written worse. --Meuuh */ if( ( p_es ) && - ((p_es->p_decoder_fifo != NULL) || b_psi || b_pcr || b_dvbsub) ) + ((p_es->p_dec != NULL) || b_psi || b_pcr || b_dvbsub) ) { p_es->c_packets++; diff --git a/modules/demux/rawdv.c b/modules/demux/rawdv.c index 1386ddcb10..c02c7bd648 100644 --- a/modules/demux/rawdv.c +++ b/modules/demux/rawdv.c @@ -2,7 +2,7 @@ * rawdv.c : raw dv input module for vlc ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: rawdv.c,v 1.10 2003/09/07 22:48:29 fenrir Exp $ + * $Id: rawdv.c,v 1.11 2003/11/24 00:39:01 fenrir Exp $ * * Authors: Gildas Bazin * @@ -374,7 +374,7 @@ static int Demux( input_thread_t * p_input ) } /* Build video PES packet */ - if( p_rawdv->p_video_es->p_decoder_fifo ) + if( p_rawdv->p_video_es->p_dec ) { p_pes = input_NewPES( p_input->p_method_data ); if( p_pes == NULL ) @@ -394,7 +394,7 @@ static int Demux( input_thread_t * p_input ) } /* Do the same for audio */ - if( p_rawdv->p_audio_es->p_decoder_fifo ) + if( p_rawdv->p_audio_es->p_dec ) { p_audio_pes = input_NewPES( p_input->p_method_data ); if( p_audio_pes == NULL ) @@ -405,7 +405,7 @@ static int Demux( input_thread_t * p_input ) } p_audio_pes->i_rate = p_input->stream.control.i_rate; - if( p_rawdv->p_video_es->p_decoder_fifo ) + if( p_rawdv->p_video_es->p_dec ) p_audio_pes->p_first = p_audio_pes->p_last = input_ShareBuffer( p_input->p_method_data, p_data->p_buffer ); else @@ -422,15 +422,15 @@ static int Demux( input_thread_t * p_input ) } /* Decode PES packets if stream is selected */ - if( p_rawdv->p_video_es->p_decoder_fifo ) - input_DecodePES( p_rawdv->p_video_es->p_decoder_fifo, p_pes ); - if( p_rawdv->p_audio_es->p_decoder_fifo ) - input_DecodePES( p_rawdv->p_audio_es->p_decoder_fifo, p_audio_pes ); + if( p_rawdv->p_video_es->p_dec ) + input_DecodePES( p_rawdv->p_video_es->p_dec, p_pes ); + if( p_rawdv->p_audio_es->p_dec ) + input_DecodePES( p_rawdv->p_audio_es->p_dec, p_audio_pes ); p_rawdv->i_pcr += ( 90000 / p_rawdv->f_rate ); - if( !p_rawdv->p_video_es->p_decoder_fifo && - !p_rawdv->p_audio_es->p_decoder_fifo ) + if( !p_rawdv->p_video_es->p_dec && + !p_rawdv->p_audio_es->p_dec ) input_DeletePacket( p_input->p_method_data, p_data ); return 1; diff --git a/modules/gui/beos/VlcWrapper.cpp b/modules/gui/beos/VlcWrapper.cpp index d7ec6d1cb0..bcfb212cfb 100644 --- a/modules/gui/beos/VlcWrapper.cpp +++ b/modules/gui/beos/VlcWrapper.cpp @@ -2,7 +2,7 @@ * VlcWrapper.cpp: BeOS plugin for vlc (derived from MacOS X port) ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: VlcWrapper.cpp,v 1.38 2003/10/21 01:48:02 titer Exp $ + * $Id: VlcWrapper.cpp,v 1.39 2003/11/24 00:39:01 fenrir Exp $ * * Authors: Florian G. Pflug * Jon Lech Johansen @@ -1005,7 +1005,7 @@ void VlcWrapper::FilterChange() for( unsigned int i = 0; i < p_input->stream.i_es_number; i++ ) { if( ( p_input->stream.pp_es[i]->i_cat == VIDEO_ES ) && - ( p_input->stream.pp_es[i]->p_decoder_fifo != NULL ) ) + ( p_input->stream.pp_es[i]->p_dec != NULL ) ) { input_UnselectES( p_input, p_input->stream.pp_es[i] ); input_SelectES( p_input, p_input->stream.pp_es[i] ); diff --git a/modules/gui/gtk/menu.c b/modules/gui/gtk/menu.c index 3ff6e52dab..5fdd69fd42 100644 --- a/modules/gui/gtk/menu.c +++ b/modules/gui/gtk/menu.c @@ -2,7 +2,7 @@ * menu.c : functions to handle menu items. ***************************************************************************** * Copyright (C) 2000, 2001 VideoLAN - * $Id: menu.c,v 1.11 2003/08/04 12:34:20 jpsaman Exp $ + * $Id: menu.c,v 1.12 2003/11/24 00:39:01 fenrir Exp $ * * Authors: Samuel Hocevar * Stéphane Borel @@ -398,7 +398,7 @@ static void GtkDeinterlaceUpdate( intf_thread_t *p_intf, char *psz_mode ) for( i = 0 ; i < p_intf->p_sys->p_input->stream.i_es_number ; i++ ) { if( ( ES->i_cat == VIDEO_ES ) && - ES->p_decoder_fifo != NULL ) + ES->p_dec != NULL ) { input_UnselectES( p_intf->p_sys->p_input, ES ); input_SelectES( p_intf->p_sys->p_input, ES ); diff --git a/modules/stream_out/display.c b/modules/stream_out/display.c index 9656e0048f..a99159643d 100644 --- a/modules/stream_out/display.c +++ b/modules/stream_out/display.c @@ -2,7 +2,7 @@ * display.c ***************************************************************************** * Copyright (C) 2001, 2002 VideoLAN - * $Id: display.c,v 1.7 2003/11/21 15:32:08 fenrir Exp $ + * $Id: display.c,v 1.8 2003/11/24 00:39:01 fenrir Exp $ * * Authors: Laurent Aimar * @@ -271,9 +271,9 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id, p_buffer->p_buffer, p_buffer->i_size ); - if( id->p_es->p_decoder_fifo ) + if( id->p_es->p_dec ) { - input_DecodePES( id->p_es->p_decoder_fifo, p_pes ); + input_DecodePES( id->p_es->p_dec, p_pes ); } else { diff --git a/src/input/input.c b/src/input/input.c index 7da006403b..67d08d0c9c 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -4,7 +4,7 @@ * decoders. ***************************************************************************** * Copyright (C) 1998-2002 VideoLAN - * $Id: input.c,v 1.260 2003/11/22 13:19:30 gbazin Exp $ + * $Id: input.c,v 1.261 2003/11/24 00:39:01 fenrir Exp $ * * Authors: Christophe Massiot * @@ -30,6 +30,7 @@ #include #include +#include #include #ifdef HAVE_SYS_TIMES_H @@ -1134,7 +1135,7 @@ static es_out_id_t *EsOutAdd( es_out_t *out, es_format_t *fmt ) msg_Err( p_input, "FIXME unselect es in es_out_Add" ); } input_SelectES( p_input, id->p_es ); - if( id->p_es->p_decoder_fifo ) + if( id->p_es->p_dec ) { out->p_sys->i_audio = fmt->i_priority; } @@ -1146,7 +1147,7 @@ static es_out_id_t *EsOutAdd( es_out_t *out, es_format_t *fmt ) msg_Err( p_input, "FIXME unselect es in es_out_Add" ); } input_SelectES( p_input, id->p_es ); - if( id->p_es->p_decoder_fifo ) + if( id->p_es->p_dec ) { out->p_sys->i_video = fmt->i_priority; } @@ -1220,31 +1221,9 @@ static es_out_id_t *EsOutAdd( es_out_t *out, es_format_t *fmt ) static int EsOutSend( es_out_t *out, es_out_id_t *id, block_t *p_block ) { - if( id->p_es->p_decoder_fifo ) + if( id->p_es->p_dec ) { - pes_packet_t *p_pes; - - if( !(p_pes = input_NewPES( out->p_sys->p_input->p_method_data ) ) ) - { - return VLC_SUCCESS; - } - - p_pes->p_first = p_pes->p_last = - input_NewPacket( out->p_sys->p_input->p_method_data, - p_block->i_buffer ); - - p_pes->i_nb_data = 1; - p_pes->i_pts = p_block->i_pts; - p_pes->i_dts = p_block->i_dts; - - p_pes->p_first->p_payload_end = - p_pes->p_first->p_payload_start + p_block->i_buffer; - memcpy( p_pes->p_first->p_payload_start, - p_block->p_buffer, p_block->i_buffer ); - - block_Release( p_block ); - - input_DecodePES( id->p_es->p_decoder_fifo, p_pes ); + input_DecodeBlock( id->p_es->p_dec, p_block ); } else { @@ -1255,9 +1234,9 @@ static int EsOutSend( es_out_t *out, es_out_id_t *id, block_t *p_block ) static int EsOutSendPES( es_out_t *out, es_out_id_t *id, pes_packet_t *p_pes ) { - if( id->p_es->p_decoder_fifo ) + if( id->p_es->p_dec ) { - input_DecodePES( id->p_es->p_decoder_fifo, p_pes ); + input_DecodePES( id->p_es->p_dec, p_pes ); } else { @@ -1273,7 +1252,7 @@ static void EsOutDel( es_out_t *out, es_out_id_t *id ) TAB_REMOVE( p_sys->i_id, p_sys->id, id ); vlc_mutex_lock( &p_sys->p_input->stream.stream_lock ); - if( id->p_es->p_decoder_fifo ) + if( id->p_es->p_dec ) { input_UnselectES( p_sys->p_input, id->p_es ); } @@ -1304,13 +1283,13 @@ static int EsOutControl( es_out_t *out, int i_query, va_list args ) vlc_mutex_lock( &p_sys->p_input->stream.stream_lock ); id = (es_out_id_t*) va_arg( args, es_out_id_t * ); b = (vlc_bool_t) va_arg( args, vlc_bool_t ); - if( b && id->p_es->p_decoder_fifo == NULL ) + if( b && id->p_es->p_dec == NULL ) { input_SelectES( p_sys->p_input, id->p_es ); vlc_mutex_unlock( &p_sys->p_input->stream.stream_lock ); - return id->p_es->p_decoder_fifo ? VLC_SUCCESS : VLC_EGENERIC; + return id->p_es->p_dec ? VLC_SUCCESS : VLC_EGENERIC; } - else if( !b && id->p_es->p_decoder_fifo ) + else if( !b && id->p_es->p_dec ) { input_UnselectES( p_sys->p_input, id->p_es ); vlc_mutex_unlock( &p_sys->p_input->stream.stream_lock ); @@ -1320,7 +1299,7 @@ static int EsOutControl( es_out_t *out, int i_query, va_list args ) id = (es_out_id_t*) va_arg( args, es_out_id_t * ); pb = (vlc_bool_t*) va_arg( args, vlc_bool_t * ); - *pb = id->p_es->p_decoder_fifo ? VLC_TRUE : VLC_FALSE; + *pb = id->p_es->p_dec ? VLC_TRUE : VLC_FALSE; return VLC_SUCCESS; default: diff --git a/src/input/input_dec.c b/src/input/input_dec.c index ead9d8bb1b..6cea6ab5fd 100644 --- a/src/input/input_dec.c +++ b/src/input/input_dec.c @@ -2,7 +2,7 @@ * input_dec.c: Functions for the management of decoders ***************************************************************************** * Copyright (C) 1999-2001 VideoLAN - * $Id: input_dec.c,v 1.75 2003/11/23 18:21:48 gbazin Exp $ + * $Id: input_dec.c,v 1.76 2003/11/24 00:39:02 fenrir Exp $ * * Authors: Christophe Massiot * Gildas Bazin @@ -52,14 +52,32 @@ static void vout_del_buffer( decoder_t *, picture_t * ); static es_format_t null_es_format = {0}; +struct decoder_owner_sys_t +{ + aout_instance_t *p_aout; + aout_input_t *p_aout_input; + + vout_thread_t *p_vout; + + sout_packetizer_input_t *p_sout; + + /* Current format in use by the output */ + video_format_t video; + audio_format_t audio; + es_format_t sout; + + /* fifo */ + block_fifo_t *p_fifo; +}; + + /***************************************************************************** * input_RunDecoder: spawns a new decoder thread *****************************************************************************/ -decoder_fifo_t * input_RunDecoder( input_thread_t * p_input, - es_descriptor_t * p_es ) +decoder_t * input_RunDecoder( input_thread_t * p_input, es_descriptor_t * p_es ) { - vlc_value_t val; decoder_t *p_dec = NULL; + vlc_value_t val; int i_priority; /* If we are in sout mode, search for packetizer module */ @@ -112,7 +130,7 @@ decoder_fifo_t * input_RunDecoder( input_thread_t * p_input, { msg_Err( p_dec, "no suitable decoder module for fourcc `%4.4s'.\n" "VLC probably does not support this sound or video format.", - (char*)&p_dec->p_fifo->i_fourcc ); + (char*)&p_dec->fmt_in.i_codec ); DeleteDecoder( p_dec ); vlc_object_destroy( p_dec ); @@ -142,7 +160,7 @@ decoder_fifo_t * input_RunDecoder( input_thread_t * p_input, p_input->stream.b_changed = 1; - return p_dec->p_fifo; + return p_dec; } /***************************************************************************** @@ -150,11 +168,10 @@ decoder_fifo_t * input_RunDecoder( input_thread_t * p_input, *****************************************************************************/ void input_EndDecoder( input_thread_t * p_input, es_descriptor_t * p_es ) { + decoder_t *p_dec = p_es->p_dec; int i_dummy; - decoder_t *p_dec = p_es->p_decoder_fifo->p_dec; - p_es->p_decoder_fifo->b_die = 1; - p_es->p_decoder_fifo->p_dec->b_die = 1; + p_dec->b_die = VLC_TRUE; /* Make sure the thread leaves the NextDataPacket() function by * sending it a few null packets. */ @@ -165,7 +182,7 @@ void input_EndDecoder( input_thread_t * p_input, es_descriptor_t * p_es ) if( p_es->p_pes != NULL ) { - input_DecodePES( p_es->p_decoder_fifo, p_es->p_pes ); + input_DecodePES( p_es->p_dec, p_es->p_pes ); } /* Waiting for the thread to exit */ @@ -189,7 +206,7 @@ void input_EndDecoder( input_thread_t * p_input, es_descriptor_t * p_es ) vlc_object_destroy( p_dec ); /* Tell the input there is no more decoder */ - p_es->p_decoder_fifo = NULL; + p_es->p_dec = NULL; p_input->stream.b_changed = 1; } @@ -199,18 +216,46 @@ void input_EndDecoder( input_thread_t * p_input, es_descriptor_t * p_es ) ***************************************************************************** * Put a PES in the decoder's fifo. *****************************************************************************/ -void input_DecodePES( decoder_fifo_t * p_decoder_fifo, pes_packet_t * p_pes ) +void input_DecodePES( decoder_t * p_dec, pes_packet_t * p_pes ) { - vlc_mutex_lock( &p_decoder_fifo->data_lock ); + data_packet_t *p_data; + int i_size = 0; - 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++; + for( p_data = p_pes->p_first; p_data != NULL; p_data = p_data->p_next ) + { + i_size += p_data->p_payload_end - p_data->p_payload_start; + } + if( i_size > 0 ) + { + block_t *p_block = block_New( p_dec, i_size ); + if( p_block ) + { + uint8_t *p_buffer = p_block->p_buffer; + + for( p_data = p_pes->p_first; p_data != NULL; p_data = p_data->p_next ) + { + int i_copy = p_data->p_payload_end - p_data->p_payload_start; + + memcpy( p_buffer, p_data->p_payload_start, i_copy ); - /* Warn the decoder that it's got work to do. */ - vlc_cond_signal( &p_decoder_fifo->data_wait ); - vlc_mutex_unlock( &p_decoder_fifo->data_lock ); + p_buffer += i_copy; + } + p_block->i_pts = p_pes->i_pts; + p_block->i_dts = p_pes->i_dts; + p_block->b_discontinuity = p_pes->b_discontinuity; + + block_FifoPut( p_dec->p_owner->p_fifo, p_block ); + } + } +} +/***************************************************************************** + * input_DecodeBlock + ***************************************************************************** + * Put a block_t in the decoder's fifo. + *****************************************************************************/ +void input_DecodeBlock( decoder_t * p_dec, block_t *p_block ) +{ + block_FifoPut( p_dec->p_owner->p_fifo, p_block ); } /***************************************************************************** @@ -254,7 +299,7 @@ void input_NullPacket( input_thread_t * p_input, p_pes->p_first = p_pes->p_last = p_pad_data; p_pes->i_nb_data = 1; p_pes->b_discontinuity = 1; - input_DecodePES( p_es->p_decoder_fifo, p_pes ); + input_DecodePES( p_es->p_dec, p_pes ); } } @@ -269,7 +314,7 @@ void input_EscapeDiscontinuity( input_thread_t * p_input ) { es_descriptor_t * p_es = p_input->stream.pp_selected_es[i_es]; - if( p_es->p_decoder_fifo != NULL ) + if( p_es->p_dec != NULL ) { for( i = 0; i < PADDING_PACKET_NUMBER; i++ ) { @@ -290,7 +335,7 @@ void input_EscapeAudioDiscontinuity( input_thread_t * p_input ) { es_descriptor_t * p_es = p_input->stream.pp_selected_es[i_es]; - if( p_es->p_decoder_fifo != NULL && p_es->i_cat == AUDIO_ES ) + if( p_es->p_dec != NULL && p_es->i_cat == AUDIO_ES ) { for( i = 0; i < PADDING_PACKET_NUMBER; i++ ) { @@ -300,21 +345,6 @@ void input_EscapeAudioDiscontinuity( input_thread_t * p_input ) } } -struct decoder_owner_sys_t -{ - aout_instance_t *p_aout; - aout_input_t *p_aout_input; - - vout_thread_t *p_vout; - - sout_packetizer_input_t *p_sout; - - /* Current format in use by the output */ - video_format_t video; - audio_format_t audio; - es_format_t sout; -}; - /***************************************************************************** * CreateDecoder: create a decoder object *****************************************************************************/ @@ -330,12 +360,10 @@ static decoder_t * CreateDecoder( input_thread_t * p_input, return NULL; } - p_dec->pf_decode = 0; p_dec->pf_decode_audio = 0; p_dec->pf_decode_video = 0; p_dec->pf_decode_sub = 0; p_dec->pf_packetize = 0; - p_dec->pf_run = 0; /* Select a new ES */ INSERT_ELEM( p_input->stream.pp_selected_es, @@ -343,14 +371,6 @@ static decoder_t * CreateDecoder( input_thread_t * p_input, p_input->stream.i_selected_es_number, p_es ); - /* Allocate the memory needed to store the decoder's fifo */ - p_dec->p_fifo = vlc_object_create( p_input, VLC_OBJECT_DECODER_FIFO ); - if( p_dec->p_fifo == NULL ) - { - msg_Err( p_input, "out of memory" ); - return NULL; - } - /* Initialize the decoder fifo */ p_dec->p_module = NULL; @@ -387,6 +407,18 @@ static decoder_t * CreateDecoder( input_thread_t * p_input, p_dec->fmt_in.video.i_width = p_bih->biWidth; p_dec->fmt_in.video.i_height = p_bih->biHeight; } + /* FIXME + * - 1: beurk + * - 2: I'm not sure there isn't any endian problem here ... */ + if( p_es->i_cat == SPU_ES && + ( p_es->i_fourcc == VLC_FOURCC( 's', 'p', 'u', ' ' ) || + p_es->i_fourcc == VLC_FOURCC( 's', 'p', 'u', 'b' ) ) && + p_es->p_demux_data && + *((uint32_t*)p_es->p_demux_data) == 0xBeef ) + { + memcpy( p_dec->fmt_in.subs.spu.palette, + p_es->p_demux_data, 17 * 4 ); + } p_dec->fmt_in.i_cat = p_es->i_cat; p_dec->fmt_in.i_codec = p_es->i_fourcc; @@ -404,6 +436,12 @@ static decoder_t * CreateDecoder( input_thread_t * p_input, p_dec->p_owner->p_aout_input = NULL; p_dec->p_owner->p_vout = NULL; p_dec->p_owner->p_sout = NULL; + /* decoder fifo */ + if( ( p_dec->p_owner->p_fifo = block_FifoNew( p_dec ) ) == NULL ) + { + msg_Err( p_dec, "out of memory" ); + return NULL; + } /* Set buffers allocation callbacks for the decoders */ p_dec->pf_aout_buffer_new = aout_new_buffer; @@ -411,26 +449,6 @@ static decoder_t * CreateDecoder( input_thread_t * p_input, p_dec->pf_vout_buffer_new = vout_new_buffer; p_dec->pf_vout_buffer_del = vout_del_buffer; - /* For old decoders only */ - vlc_mutex_init( p_input, &p_dec->p_fifo->data_lock ); - vlc_cond_init( p_input, &p_dec->p_fifo->data_wait ); - p_es->p_decoder_fifo = p_dec->p_fifo; - p_dec->p_fifo->i_id = p_es->i_id; - p_dec->p_fifo->i_fourcc = p_es->i_fourcc; - p_dec->p_fifo->p_demux_data = p_es->p_demux_data; - p_dec->p_fifo->p_waveformatex = p_es->p_waveformatex; - p_dec->p_fifo->p_bitmapinfoheader = p_es->p_bitmapinfoheader; - p_dec->p_fifo->p_spuinfo = p_es->p_spuinfo; - p_dec->p_fifo->p_stream_ctrl = &p_input->stream.control; - p_dec->p_fifo->p_sout = p_input->stream.p_sout; - p_dec->p_fifo->p_first = NULL; - p_dec->p_fifo->pp_last = &p_dec->p_fifo->p_first; - p_dec->p_fifo->i_depth = 0; - p_dec->p_fifo->b_die = p_dec->p_fifo->b_error = 0; - p_dec->p_fifo->p_packets_mgt = p_input->p_method_data; - p_dec->p_fifo->p_dec = p_dec; - vlc_object_attach( p_dec->p_fifo, p_input ); - vlc_object_attach( p_dec, p_input ); return p_dec; @@ -441,50 +459,19 @@ static decoder_t * CreateDecoder( input_thread_t * p_input, *****************************************************************************/ static int DecoderThread( decoder_t * p_dec ) { - pes_packet_t *p_pes; - data_packet_t *p_data; block_t *p_block; - /* Temporary wrapper to keep old decoder api functional */ - if( p_dec->pf_run ) - { - p_dec->pf_run( p_dec->p_fifo ); - return 0; - } - /* The decoder's main loop */ - while( !p_dec->p_fifo->b_die && !p_dec->p_fifo->b_error && - !p_dec->b_die && !p_dec->b_error ) + while( !p_dec->b_die && !p_dec->b_error ) { int i_size; - input_ExtractPES( p_dec->p_fifo, &p_pes ); - if( !p_pes ) + if( ( p_block = block_FifoGet( p_dec->p_owner->p_fifo ) ) == NULL ) { - p_dec->p_fifo->b_error = 1; + p_dec->b_error = 1; break; } - for( i_size = 0, p_data = p_pes->p_first; - p_data != NULL; p_data = p_data->p_next ) - { - i_size += p_data->p_payload_end - p_data->p_payload_start; - } - p_block = block_New( p_dec, i_size ); - for( i_size = 0, p_data = p_pes->p_first; - p_data != NULL; p_data = p_data->p_next ) - { - if( p_data->p_payload_end == p_data->p_payload_start ) - continue; - memcpy( p_block->p_buffer + i_size, p_data->p_payload_start, - p_data->p_payload_end - p_data->p_payload_start ); - i_size += p_data->p_payload_end - p_data->p_payload_start; - } - - p_block->i_pts = p_pes->i_pts; - p_block->i_dts = p_pes->i_dts; - p_block->b_discontinuity = p_pes->b_discontinuity; - if( p_dec->i_object_type == VLC_OBJECT_PACKETIZER ) { block_t *p_sout_block; @@ -572,14 +559,16 @@ static int DecoderThread( decoder_t * p_dec ) p_dec->b_error = 1; break; } - - input_DeletePES( p_dec->p_fifo->p_packets_mgt, p_pes ); } - while( !p_dec->p_fifo->b_die && !p_dec->b_die ) + while( !p_dec->b_die ) { /* Trash all received PES packets */ - input_ExtractPES( p_dec->p_fifo, NULL ); + p_block = block_FifoGet( p_dec->p_owner->p_fifo ); + if( p_block ) + { + block_Release( p_block ); + } } /* XXX We do it here because of dll loader that want close in the @@ -596,25 +585,17 @@ static int DecoderThread( decoder_t * p_dec ) static void DeleteDecoder( decoder_t * p_dec ) { vlc_object_detach( p_dec ); - vlc_object_detach( p_dec->p_fifo ); msg_Dbg( p_dec, - "killing decoder for 0x%x, fourcc `%4.4s', %d PES in FIFO", - p_dec->p_fifo->i_id, (char*)&p_dec->p_fifo->i_fourcc, - p_dec->p_fifo->i_depth ); + "killing decoder fourcc `%4.4s', %d PES in FIFO", + (char*)&p_dec->fmt_in.i_codec, + p_dec->p_owner->p_fifo->i_depth ); /* Free all packets still in the decoder fifo. */ - input_DeletePES( p_dec->p_fifo->p_packets_mgt, - p_dec->p_fifo->p_first ); - - /* Destroy the lock and cond */ - vlc_cond_destroy( &p_dec->p_fifo->data_wait ); - vlc_mutex_destroy( &p_dec->p_fifo->data_lock ); + block_FifoEmpty( p_dec->p_owner->p_fifo ); + block_FifoRelease( p_dec->p_owner->p_fifo ); - /* Free fifo */ - vlc_object_destroy( p_dec->p_fifo ); - - /* Cleanup */ + /* Cleanup */ if( p_dec->p_owner->p_aout_input ) aout_DecDelete( p_dec->p_owner->p_aout, p_dec->p_owner->p_aout_input ); @@ -644,7 +625,6 @@ static void DeleteDecoder( decoder_t * p_dec ) sout_InputDelete( p_dec->p_owner->p_sout ); free( p_dec->p_owner ); - } /***************************************************************************** diff --git a/src/input/input_ext-intf.c b/src/input/input_ext-intf.c index 927a2b481a..3356087a47 100644 --- a/src/input/input_ext-intf.c +++ b/src/input/input_ext-intf.c @@ -2,7 +2,7 @@ * input_ext-intf.c: services to the interface ***************************************************************************** * Copyright (C) 1998-2001 VideoLAN - * $Id: input_ext-intf.c,v 1.51 2003/07/13 19:58:41 massiot Exp $ + * $Id: input_ext-intf.c,v 1.52 2003/11/24 00:39:02 fenrir Exp $ * * Authors: Christophe Massiot * @@ -360,7 +360,7 @@ void input_DumpStream( input_thread_t * p_input ) msg_Dbg( p_input, "ES 0x%x, " "stream 0x%x, fourcc `%4.4s', %s [OK:%ld/ERR:%ld]", ES->i_id, ES->i_stream_id, (char*)&ES->i_fourcc, - ES->p_decoder_fifo != NULL ? "selected" : "not selected", + ES->p_dec != NULL ? "selected" : "not selected", ES->c_packets, ES->c_invalid_packets ); #undef ES } diff --git a/src/input/input_programs.c b/src/input/input_programs.c index bb260f4546..acd3f4f163 100644 --- a/src/input/input_programs.c +++ b/src/input/input_programs.c @@ -2,7 +2,7 @@ * input_programs.c: es_descriptor_t, pgrm_descriptor_t management ***************************************************************************** * Copyright (C) 1999-2002 VideoLAN - * $Id: input_programs.c,v 1.121 2003/11/16 21:07:31 gbazin Exp $ + * $Id: input_programs.c,v 1.122 2003/11/24 00:39:02 fenrir Exp $ * * Authors: Christophe Massiot * @@ -425,7 +425,7 @@ int input_SetProgram( input_thread_t * p_input, pgrm_descriptor_t * p_new_prg ) i_es_index ++ ) { #define p_es p_input->stream.p_selected_program->pp_es[i_es_index] - if ( p_es->p_decoder_fifo ) /* if the ES was selected */ + if ( p_es->p_dec ) /* if the ES was selected */ { input_UnselectES( p_input , p_es ); } @@ -614,7 +614,7 @@ es_descriptor_t * input_AddES( input_thread_t * p_input, /* Init its values */ p_es->i_id = i_es_id; p_es->p_pes = NULL; - p_es->p_decoder_fifo = NULL; + p_es->p_dec = NULL; p_es->i_cat = i_category; p_es->i_demux_fd = 0; p_es->c_packets = 0; @@ -756,7 +756,7 @@ void input_DelES( input_thread_t * p_input, es_descriptor_t * p_es ) } /* Kill associated decoder, if any. */ - if( p_es->p_decoder_fifo != NULL ) + if( p_es->p_dec != NULL ) { input_UnselectES( p_input, p_es ); } @@ -860,7 +860,7 @@ int input_SelectES( input_thread_t * p_input, es_descriptor_t * p_es ) msg_Dbg( p_input, "selecting ES 0x%x", p_es->i_id ); - if( p_es->p_decoder_fifo != NULL ) + if( p_es->p_dec != NULL ) { msg_Err( p_input, "ES 0x%x is already selected", p_es->i_id ); return -1; @@ -869,10 +869,10 @@ int input_SelectES( input_thread_t * p_input, es_descriptor_t * p_es ) /* Release the lock, not to block the input thread during * the creation of the thread. */ vlc_mutex_unlock( &p_input->stream.stream_lock ); - p_es->p_decoder_fifo = input_RunDecoder( p_input, p_es ); + p_es->p_dec = input_RunDecoder( p_input, p_es ); vlc_mutex_lock( &p_input->stream.stream_lock ); - if( p_es->p_decoder_fifo == NULL ) + if( p_es->p_dec == NULL ) { return -1; } @@ -917,7 +917,7 @@ int input_UnselectES( input_thread_t * p_input, es_descriptor_t * p_es ) msg_Dbg( p_input, "unselecting ES 0x%x", p_es->i_id ); - if( p_es->p_decoder_fifo == NULL ) + if( p_es->p_dec == NULL ) { msg_Err( p_input, "ES 0x%x is not selected", p_es->i_id ); return( -1 ); @@ -947,7 +947,7 @@ int input_UnselectES( input_thread_t * p_input, es_descriptor_t * p_es ) input_EndDecoder( p_input, p_es ); p_es->p_pes = NULL; - if( ( p_es->p_decoder_fifo == NULL ) && + if( ( p_es->p_dec == NULL ) && ( p_input->stream.i_selected_es_number > 0 ) ) { while( ( i_index < p_input->stream.i_selected_es_number - 1 ) && @@ -1140,7 +1140,7 @@ static int ESCallback( vlc_object_t *p_this, char const *psz_cmd, for( i = 0 ; i < p_input->stream.i_es_number ; i++ ) { if( p_input->stream.pp_es[i]->i_id == oldval.i_int && - p_input->stream.pp_es[i]->p_decoder_fifo != NULL ) + p_input->stream.pp_es[i]->p_dec != NULL ) { input_UnselectES( p_input, p_input->stream.pp_es[i] ); } @@ -1150,7 +1150,7 @@ static int ESCallback( vlc_object_t *p_this, char const *psz_cmd, for( i = 0 ; i < p_input->stream.i_es_number ; i++ ) { if( p_input->stream.pp_es[i]->i_id == newval.i_int && - p_input->stream.pp_es[i]->p_decoder_fifo == NULL ) + p_input->stream.pp_es[i]->p_dec == NULL ) { input_SelectES( p_input, p_input->stream.pp_es[i] ); } diff --git a/src/misc/objects.c b/src/misc/objects.c index 68593f9d3e..3a67800203 100644 --- a/src/misc/objects.c +++ b/src/misc/objects.c @@ -2,7 +2,7 @@ * objects.c: vlc_object_t handling ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: objects.c,v 1.42 2003/10/14 22:41:41 gbazin Exp $ + * $Id: objects.c,v 1.43 2003/11/24 00:39:02 fenrir Exp $ * * Authors: Samuel Hocevar * @@ -131,10 +131,6 @@ void * __vlc_object_create( vlc_object_t *p_this, int i_type ) i_size = sizeof(decoder_t); psz_type = "decoder"; break; - case VLC_OBJECT_DECODER_FIFO: /* tmp for backward compat */ - i_size = sizeof(decoder_fifo_t); - psz_type = "decoder"; - break; case VLC_OBJECT_PACKETIZER: i_size = sizeof(decoder_t); psz_type = "packetizer"; diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c index c93d4eb16d..2a55269503 100644 --- a/src/video_output/video_output.c +++ b/src/video_output/video_output.c @@ -5,7 +5,7 @@ * thread, and destroy a previously oppened video output thread. ***************************************************************************** * Copyright (C) 2000-2001 VideoLAN - * $Id: video_output.c,v 1.239 2003/10/26 13:10:05 sigmunau Exp $ + * $Id: video_output.c,v 1.240 2003/11/24 00:39:02 fenrir Exp $ * * Authors: Vincent Seguin * @@ -1360,7 +1360,7 @@ static int DeinterlaceCallback( vlc_object_t *p_this, char const *psz_cmd, for( i = 0 ; i < p_input->stream.i_es_number ; i++ ) { - if( ( ES->i_cat == VIDEO_ES ) && ES->p_decoder_fifo != NULL ) + if( ( ES->i_cat == VIDEO_ES ) && ES->p_dec != NULL ) { input_UnselectES( p_input, ES ); input_SelectES( p_input, ES ); @@ -1401,7 +1401,7 @@ static int FilterCallback( vlc_object_t *p_this, char const *psz_cmd, for( i = 0 ; i < p_input->stream.i_es_number ; i++ ) { - if( ( ES->i_cat == VIDEO_ES ) && ES->p_decoder_fifo != NULL ) + if( ( ES->i_cat == VIDEO_ES ) && ES->p_dec != NULL ) { input_UnselectES( p_input, ES ); input_SelectES( p_input, ES );