#define DTS_HEADER_SIZE 14
/****************************************************************************
* Local prototypes
****************************************************************************/
static int OpenCommon( vlc_object_t *, bool b_packetizer );
#define DTS_HEADER_SIZE 14
/****************************************************************************
* Local prototypes
****************************************************************************/
static int OpenCommon( vlc_object_t *, bool b_packetizer );
static inline int SyncCode( const uint8_t * );
static int SyncInfo( const uint8_t *, bool *, unsigned int *, unsigned int *,
unsigned int *, unsigned int *, unsigned int * );
static inline int SyncCode( const uint8_t * );
static int SyncInfo( const uint8_t *, bool *, unsigned int *, unsigned int *,
unsigned int *, unsigned int *, unsigned int * );
static int OpenDecoder( vlc_object_t *p_this )
{
/* HACK: Don't use this codec if we don't have an dts audio filter */
static int OpenDecoder( vlc_object_t *p_this )
{
/* HACK: Don't use this codec if we don't have an dts audio filter */
- p_dec->pf_decode_audio = (aout_buffer_t *(*)(decoder_t *, block_t **))
- DecodeBlock;
- p_dec->pf_packetize = (block_t *(*)(decoder_t *, block_t **))
- DecodeBlock;
+ p_dec->pf_decode_audio = DecodeBlock;
+ p_dec->pf_packetize = DecodeBlock;
/****************************************************************************
* DecodeBlock: the whole thing
****************************************************************************/
/****************************************************************************
* DecodeBlock: the whole thing
****************************************************************************/
{
/* We've just started the stream, wait for the first PTS. */
block_Release( *pp_block );
{
/* We've just started the stream, wait for the first PTS. */
block_Release( *pp_block );
case STATE_SYNC:
/* New frame, set the Presentation Time Stamp */
p_sys->i_pts = p_sys->bytestream.p_block->i_pts;
case STATE_SYNC:
/* New frame, set the Presentation Time Stamp */
p_sys->i_pts = p_sys->bytestream.p_block->i_pts;
if( SyncCode( p_header ) != VLC_SUCCESS )
{
msg_Dbg( p_dec, "emulated sync word "
if( SyncCode( p_header ) != VLC_SUCCESS )
{
msg_Dbg( p_dec, "emulated sync word "
/* Copy the whole frame into the buffer. When we reach this point
* we already know we have enough data available. */
/* Copy the whole frame into the buffer. When we reach this point
* we already know we have enough data available. */
- block_GetBytes( &p_sys->bytestream, p_buf, p_sys->i_frame_size );
+ block_GetBytes( &p_sys->bytestream,
+ p_buf, __MIN( p_sys->i_frame_size, p_out_buffer->i_buffer ) );
/* Make sure we don't reuse the same pts twice */
if( p_sys->i_pts == p_sys->bytestream.p_block->i_pts )
/* Make sure we don't reuse the same pts twice */
if( p_sys->i_pts == p_sys->bytestream.p_block->i_pts )
/*****************************************************************************
* GetOutBuffer:
*****************************************************************************/
/*****************************************************************************
* GetOutBuffer:
*****************************************************************************/
msg_Info( p_dec, "DTS channels:%d samplerate:%d bitrate:%d",
p_sys->i_channels, p_sys->i_rate, p_sys->i_bit_rate );
msg_Info( p_dec, "DTS channels:%d samplerate:%d bitrate:%d",
p_sys->i_channels, p_sys->i_rate, p_sys->i_bit_rate );
- aout_DateInit( &p_sys->end_date, p_sys->i_rate );
- aout_DateSet( &p_sys->end_date, p_sys->i_pts );
+ date_Init( &p_sys->end_date, p_sys->i_rate, 1 );
+ date_Set( &p_sys->end_date, p_sys->i_pts );
p_buf = decoder_NewAudioBuffer( p_dec, p_sys->i_frame_length * 4 );
if( p_buf == NULL ) return NULL;
p_buf->i_nb_samples = p_sys->i_frame_length;
p_buf = decoder_NewAudioBuffer( p_dec, p_sys->i_frame_length * 4 );
if( p_buf == NULL ) return NULL;
p_buf->i_nb_samples = p_sys->i_frame_length;
- p_buf->start_date = aout_DateGet( &p_sys->end_date );
- p_buf->end_date =
- aout_DateIncrement( &p_sys->end_date, p_sys->i_frame_length );
+ p_buf->i_pts = date_Get( &p_sys->end_date );
+ p_buf->i_length = date_Increment( &p_sys->end_date, p_sys->i_frame_length )
+ - p_buf->i_pts;
p_block = block_New( p_dec, p_sys->i_frame_size );
if( p_block == NULL ) return NULL;
p_block = block_New( p_dec, p_sys->i_frame_size );
if( p_block == NULL ) return NULL;