Commit 28e3d5e9 authored by Laurent Aimar's avatar Laurent Aimar

* faad : clean up.

parent 9137b014
......@@ -2,7 +2,7 @@
* decoder.c: AAC decoder using libfaad2
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: decoder.c,v 1.19 2003/01/25 16:59:49 fenrir Exp $
* $Id: decoder.c,v 1.20 2003/01/25 18:09:30 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -132,35 +132,14 @@ static unsigned int pi_channels_maps[6] =
#define FREE( p ) if( p != NULL ) free( p ); p = NULL
#define GetWLE( p ) \
( *(u8*)(p) + ( *((u8*)(p)+1) << 8 ) )
( *(uint8_t*)(p) + ( *((uint8_t*)(p)+1) << 8 ) )
#define GetDWLE( p ) \
( *(u8*)(p) + ( *((u8*)(p)+1) << 8 ) + \
( *((u8*)(p)+2) << 16 ) + ( *((u8*)(p)+3) << 24 ) )
( *(uint8_t*)(p) + ( *((uint8_t*)(p)+1) << 8 ) + \
( *((uint8_t*)(p)+2) << 16 ) + ( *((uint8_t*)(p)+3) << 24 ) )
static void faac_GetWaveFormatEx( waveformatex_t *p_wh,
u8 *p_data )
{
WAVEFORMATEX *p_wfdata = (WAVEFORMATEX*)p_data;
p_wh->i_formattag = p_wfdata->wFormatTag;
p_wh->i_nb_channels = p_wfdata->nChannels;
p_wh->i_samplespersec = p_wfdata->nSamplesPerSec;
p_wh->i_avgbytespersec= p_wfdata->nAvgBytesPerSec;
p_wh->i_blockalign = p_wfdata->nBlockAlign;
p_wh->i_bitspersample = p_wfdata->wBitsPerSample;
p_wh->i_size = p_wfdata->cbSize;
if( p_wh->i_size )
{
p_wh->p_data = malloc( p_wh->i_size );
memcpy( p_wh->p_data,
p_data + sizeof(WAVEFORMATEX) ,
p_wh->i_size );
}
}
static void GetPESData( u8 *p_buf, int i_max, pes_packet_t *p_pes )
static void GetPESData( uint8_t *p_buf, int i_max, pes_packet_t *p_pes )
{
int i_copy;
int i_count;
......@@ -198,7 +177,7 @@ static void GetPESData( u8 *p_buf, int i_max, pes_packet_t *p_pes )
*****************************************************************************/
static int InitThread( adec_thread_t * p_adec )
{
WAVEFORMATEX *p_wf;
WAVEFORMATEX wf, *p_wf;
int i_status;
unsigned long i_rate;
unsigned char i_nb_channels;
......@@ -209,12 +188,8 @@ static int InitThread( adec_thread_t * p_adec )
{
msg_Warn( p_adec->p_fifo,
"cannot load stream informations" );
memset( &p_adec->format, 0, sizeof( waveformatex_t ) );
}
else
{
faac_GetWaveFormatEx( &p_adec->format,
(uint8_t*)p_wf );
p_wf = &wf;
memset( p_wf, 0, sizeof( WAVEFORMATEX ) );
}
p_adec->p_buffer = NULL;
......@@ -225,11 +200,10 @@ static int InitThread( adec_thread_t * p_adec )
{
msg_Err( p_adec->p_fifo,
"cannot initialize faad" );
FREE( p_adec->format.p_data );
return( -1 );
}
if( p_adec->format.p_data == NULL )
if( p_wf->cbSize <= 0 )
{
int i_frame_size;
pes_packet_t *p_pes;
......@@ -273,8 +247,8 @@ static int InitThread( adec_thread_t * p_adec )
else
{
i_status = faacDecInit2( p_adec->p_handle,
p_adec->format.p_data,
p_adec->format.i_size,
(uint8_t*)&p_wf[1],
p_wf->cbSize,
&i_rate,
&i_nb_channels );
}
......@@ -467,7 +441,6 @@ static void EndThread (adec_thread_t *p_adec)
faacDecClose( p_adec->p_handle );
}
FREE( p_adec->format.p_data );
FREE( p_adec->p_buffer );
msg_Dbg( p_adec->p_fifo, "faad decoder closed" );
......
......@@ -3,7 +3,7 @@
*
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: decoder.h,v 1.5 2002/11/14 22:38:47 massiot Exp $
* $Id: decoder.h,v 1.6 2003/01/25 18:09:30 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -24,23 +24,9 @@
#define AAC_MAXCHANNELS 64
typedef struct waveformatex_s
{
u16 i_formattag;
u16 i_nb_channels;
u32 i_samplespersec;
u32 i_avgbytespersec;
u16 i_blockalign;
u16 i_bitspersample;
u16 i_size; /* the extra size in bytes */
u8 *p_data; /* The extra data */
} waveformatex_t;
typedef struct adec_thread_s
{
waveformatex_t format;
/*
* faad decoder session
*/
......@@ -55,7 +41,7 @@ typedef struct adec_thread_s
*/
decoder_fifo_t *p_fifo;
u8 *p_buffer;
uint8_t *p_buffer;
int i_buffer;
/*
......
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