* ./modules/codec/a52old/a52old.c: the a52old decoder as well.
* 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>
*
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) );
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 );
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 );
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))
{
*/
p_a52dec->p_aout = NULL;
p_a52dec->p_aout_input = NULL;
- p_a52dec->i_pts = 0;
/*
* Bit stream
* 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>
*/
aout_instance_t * p_aout;
aout_input_t * p_aout_input;
- mtime_t i_pts;
float * samples;
void * samples_orig; /* pointer before memalign */
* 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>
*
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 ) )
/* **** 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 );
}
*
*****************************************************************************
* 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>
*
/*
* 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;