Commit b7ee1eea authored by Christophe Massiot's avatar Christophe Massiot

* Fixed an alignment issue in the ac3 decoder.

parent d970994c
......@@ -2,7 +2,7 @@
* ac3_adec.c: ac3 decoder module main file
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: ac3_adec.c,v 1.15 2002/01/21 23:57:46 massiot Exp $
* $Id: ac3_adec.c,v 1.16 2002/01/22 23:14:26 massiot Exp $
*
* Authors: Michel Lespinasse <walken@zoy.org>
*
......@@ -215,7 +215,7 @@ static int InitThread( ac3dec_thread_t * p_ac3thread )
static int decoder_Run ( decoder_config_t * p_config )
{
ac3dec_thread_t * p_ac3thread;
int sync;
boolean_t b_sync = 0;
intf_DbgMsg( "ac3_adec debug: ac3_adec thread launched, initializing" );
......@@ -242,39 +242,36 @@ static int decoder_Run ( decoder_config_t * p_config )
return( -1 );
}
sync = 0;
p_ac3thread->sync_ptr = 0;
/* ac3 decoder thread's main loop */
/* FIXME : do we have enough room to store the decoded frames ?? */
while ((!p_ac3thread->p_fifo->b_die) && (!p_ac3thread->p_fifo->b_error))
{
s16 * buffer;
ac3_sync_info_t sync_info;
int ptr;
if (!sync) {
do {
GetBits(&p_ac3thread->ac3_decoder->bit_stream,8);
} while ((!p_ac3thread->sync_ptr) && (!p_ac3thread->p_fifo->b_die)
&& (!p_ac3thread->p_fifo->b_error));
ptr = p_ac3thread->sync_ptr;
while(ptr-- && (!p_ac3thread->p_fifo->b_die)
&& (!p_ac3thread->p_fifo->b_error))
if( !b_sync )
{
p_ac3thread->ac3_decoder->bit_stream.p_byte++;
}
/* we are in sync now */
sync = 1;
int i_sync_ptr;
#define p_bit_stream (&p_ac3thread->ac3_decoder->bit_stream)
/* Go to the next data packet and jump to sync_ptr */
BitstreamNextDataPacket( p_bit_stream );
i_sync_ptr = *(p_bit_stream->p_byte - 2) << 8
| *(p_bit_stream->p_byte - 1);
p_bit_stream->p_byte += i_sync_ptr;
/* Empty the bit FIFO and realign the bit stream */
p_bit_stream->fifo.buffer = 0;
p_bit_stream->fifo.i_available = 0;
AlignWord( p_bit_stream );
b_sync = 1;
#undef p_bit_stream
}
if (ac3_sync_frame (p_ac3thread->ac3_decoder, &sync_info))
{
sync = 0;
goto bad_frame;
b_sync = 0;
continue;
}
/* Creating the audio output fifo if not created yet */
......@@ -331,8 +328,8 @@ static int decoder_Run ( decoder_config_t * p_config )
if (ac3_decode_frame (p_ac3thread->ac3_decoder, buffer))
{
sync = 0;
goto bad_frame;
b_sync = 0;
continue;
}
vlc_mutex_lock (&p_ac3thread->p_aout_fifo->data_lock);
......@@ -341,7 +338,6 @@ static int decoder_Run ( decoder_config_t * p_config )
vlc_cond_signal (&p_ac3thread->p_aout_fifo->data_wait);
vlc_mutex_unlock (&p_ac3thread->p_aout_fifo->data_lock);
bad_frame:
RealignBits(&p_ac3thread->ac3_decoder->bit_stream);
}
......@@ -420,19 +416,11 @@ static void EndThread (ac3dec_thread_t * p_ac3thread)
* This function is called by input's NextDataPacket.
*****************************************************************************/
static void BitstreamCallback ( bit_stream_t * p_bit_stream,
boolean_t b_new_pes)
boolean_t b_new_pes )
{
ac3dec_thread_t *p_ac3thread=(ac3dec_thread_t *)p_bit_stream->p_callback_arg;
if( b_new_pes )
{
int ptr;
ptr = *(p_bit_stream->p_byte + 1);
ptr <<= 8;
ptr |= *(p_bit_stream->p_byte + 2);
p_ac3thread->sync_ptr = ptr;
/* Drop special AC3 header */
p_bit_stream->p_byte += 3;
}
}
......
......@@ -2,7 +2,7 @@
* ac3_adec.h : ac3 decoder thread interface
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: ac3_adec.h,v 1.1 2001/11/13 12:09:17 henri Exp $
* $Id: ac3_adec.h,v 1.2 2002/01/22 23:14:26 massiot Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
*
......@@ -41,7 +41,6 @@ typedef struct ac3dec_thread_s
* Input properties
*/
decoder_fifo_t * p_fifo; /* stores the PES stream data */
int sync_ptr; /* sync ptr from ac3 magic header */
decoder_config_t * p_config;
/*
......
......@@ -2,7 +2,7 @@
* mpeg_adec.c: MPEG audio decoder thread
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: mpeg_adec.c,v 1.15 2002/01/21 23:57:46 massiot Exp $
* $Id: mpeg_adec.c,v 1.16 2002/01/22 23:14:26 massiot Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Michel Lespinasse <walken@via.ecp.fr>
......@@ -198,8 +198,6 @@ static void DecodeThread( adec_thread_t * p_adec )
p_adec->i_sync = 1;
// p_adec->p_aout_fifo->l_rate = sync_info.sample_rate;
buffer = ((s16 *)p_adec->p_aout_fifo->buffer)
+ (p_adec->p_aout_fifo->l_end_frame * ADEC_FRAME_SIZE);
......
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