Commit f7934b1c authored by Sam Hocevar's avatar Sam Hocevar

* ./modules/codec/faad/decoder.c: the AAC decoder is in sync with aout3.

  * ./modules/codec/a52old/a52old.c: the a52old decoder as well.
parent 3c2a9131
......@@ -2,7 +2,7 @@
* a52old.c: A52 decoder module main file
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: a52old.c,v 1.3 2002/08/21 09:27:40 sam Exp $
* $Id: a52old.c,v 1.4 2002/08/23 14:05:22 sam Exp $
*
* Authors: Michel Lespinasse <walken@zoy.org>
*
......@@ -95,9 +95,10 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
void * p_orig; /* pointer before memalign */
vlc_bool_t b_sync = 0;
mtime_t i_pts;
mtime_t i_pts = 0;
aout_buffer_t *p_aout_buffer;
audio_sample_format_t output_format;
audio_date_t end_date;
/* Allocate the memory needed to store the thread's structure */
p_a52dec = (a52dec_t *)vlc_memalign( &p_orig, 16, sizeof(a52dec_t) );
......@@ -172,6 +173,7 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
output_format.i_format = AOUT_FMT_S16_NE;
output_format.i_channels = 2; /* FIXME ! */
output_format.i_rate = sync_info.sample_rate;
aout_DateInit( &end_date, output_format.i_rate );
p_a52dec->p_aout_input = aout_InputNew( p_a52dec->p_fifo,
&p_a52dec->p_aout,
&output_format );
......@@ -184,6 +186,17 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
continue;
}
CurrentPTS( &p_a52dec->bit_stream, &i_pts, NULL );
if( i_pts != 0 && i_pts != aout_DateGet( &end_date ) )
{
aout_DateSet( &end_date, i_pts );
}
if( !aout_DateGet( &end_date ) )
{
continue;
}
p_aout_buffer = aout_BufferNew( p_a52dec->p_aout,
p_a52dec->p_aout_input,
A52DEC_FRAME_SIZE );
......@@ -194,15 +207,9 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
continue;
}
CurrentPTS( &p_a52dec->bit_stream, &i_pts, NULL );
if( i_pts > 0 )
{
p_a52dec->i_pts = i_pts;
}
p_aout_buffer->start_date = p_a52dec->i_pts;
p_a52dec->i_pts += (mtime_t)1000000 * (mtime_t)A52DEC_FRAME_SIZE
/ (mtime_t)output_format.i_rate;
p_aout_buffer->end_date = p_a52dec->i_pts;
p_aout_buffer->start_date = aout_DateGet( &end_date );
p_aout_buffer->end_date = aout_DateIncrement( &end_date,
A52DEC_FRAME_SIZE );
if (decode_frame (p_a52dec, (s16*)p_aout_buffer->p_buffer))
{
......@@ -318,7 +325,6 @@ static int InitThread( a52dec_t * p_a52dec )
*/
p_a52dec->p_aout = NULL;
p_a52dec->p_aout_input = NULL;
p_a52dec->i_pts = 0;
/*
* Bit stream
......
......@@ -2,7 +2,7 @@
* adec.h : A52 decoder interface
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: adec.h,v 1.3 2002/08/21 09:27:40 sam Exp $
* $Id: adec.h,v 1.4 2002/08/23 14:05:22 sam Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Renaud Dartus <reno@videolan.org>
......@@ -401,7 +401,6 @@ struct a52dec_s
*/
aout_instance_t * p_aout;
aout_input_t * p_aout_input;
mtime_t i_pts;
float * samples;
void * samples_orig; /* pointer before memalign */
......
......@@ -2,7 +2,7 @@
* decoder.c: AAC decoder using libfaad2
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: decoder.c,v 1.1 2002/08/10 20:05:21 fenrir Exp $
* $Id: decoder.c,v 1.2 2002/08/23 14:05:22 sam Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -206,9 +206,9 @@ static inline void __GetFrame( adec_thread_t *p_adec )
byte_t *p_buffer;
p_pes = __PES_GET( p_adec->p_fifo );
if( p_pes->i_pts > 0 )
if( p_pes->i_pts )
{
p_adec->i_pts = p_pes->i_pts;
p_adec->pts = p_pes->i_pts;
}
while( ( !p_pes->i_nb_data )||( !p_pes->i_pes_size ) )
......@@ -449,47 +449,48 @@ static void DecodeThread( adec_thread_t *p_adec )
/* **** Delete the old **** */
aout_InputDelete( p_adec->p_aout, p_adec->p_aout_input );
}
/* **** Create a new audio output **** */
p_adec->output_format.i_channels = faad_frame.channels;
aout_DateInit( &p_adec->date, p_adec->output_format.i_rate );
p_adec->p_aout_input = aout_InputNew( p_adec->p_fifo,
&p_adec->p_aout,
&p_adec->output_format );
&p_adec->p_aout,
&p_adec->output_format );
}
if( !p_adec->p_aout_input )
{
msg_Err( p_adec->p_fifo,
"cannot create aout" );
msg_Err( p_adec->p_fifo, "cannot create aout" );
return;
}
if( p_adec->pts != 0 && p_adec->pts != aout_DateGet( &p_adec->date ) )
{
aout_DateSet( &p_adec->date, p_adec->pts );
}
else if( !aout_DateGet( &p_adec->date ) )
{
return;
}
p_aout_buffer = aout_BufferNew( p_adec->p_aout,
p_adec->p_aout_input,
faad_frame.samples /
faad_frame.channels );
faad_frame.samples / faad_frame.channels );
if( !p_aout_buffer )
{
msg_Err( p_adec->p_fifo,
"cannot get aout buffer" );
msg_Err( p_adec->p_fifo, "cannot get aout buffer" );
p_adec->p_fifo->b_error = 1;
return;
}
p_aout_buffer->start_date = p_adec->i_pts;
p_adec->i_pts += (mtime_t)1000000 * (mtime_t)faad_frame.samples /
(mtime_t)p_adec->output_format.i_channels /
(mtime_t)p_adec->output_format.i_rate;
p_aout_buffer->end_date = p_adec->i_pts;
/*
* FIXME for FAAD_FMT_FLOAT *only*
* test if it works on big endian machine
* ( I don't know if float have endian issue )
*
*/
p_aout_buffer->start_date = aout_DateGet( &p_adec->date );
p_aout_buffer->end_date = aout_DateIncrement( &p_adec->date,
faad_frame.samples /
faad_frame.channels );
memcpy( p_aout_buffer->p_buffer,
p_faad_buffer,
faad_frame.samples * 4 ); /* FIXME for FAAD_FMT_FLOAT *only* */
aout_BufferPlay( p_adec->p_aout, p_adec->p_aout_input, p_aout_buffer );
p_aout_buffer->i_nb_bytes );
aout_BufferPlay( p_adec->p_aout, p_adec->p_aout_input, p_aout_buffer );
}
......
......@@ -3,7 +3,7 @@
*
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: decoder.h,v 1.1 2002/08/10 20:05:21 fenrir Exp $
* $Id: decoder.h,v 1.2 2002/08/23 14:05:22 sam Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -62,12 +62,13 @@ typedef struct adec_thread_s
/*
* Output properties
*/
mtime_t i_pts;
aout_instance_t * p_aout; /* opaque */
aout_input_t * p_aout_input; /* opaque */
audio_sample_format_t output_format;
audio_date_t date;
mtime_t pts;
} adec_thread_t;
......
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