Commit 8fce437b authored by Laurent Aimar's avatar Laurent Aimar

* ffmpeg: fixed memory leaks.

parent 22d851e1
......@@ -2,7 +2,7 @@
* decoder.c: AAC decoder using libfaad2
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: decoder.c,v 1.18 2003/01/08 10:43:27 fenrir Exp $
* $Id: decoder.c,v 1.19 2003/01/25 16:59:49 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -120,7 +120,7 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
return( 0 );
}
static int pi_channels_maps[6] =
static unsigned int pi_channels_maps[6] =
{
0,
AOUT_CHAN_CENTER, AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT,
......@@ -209,6 +209,7 @@ 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
{
......
......@@ -2,7 +2,7 @@
* audio.c: audio decoder using ffmpeg library
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: audio.c,v 1.12 2003/01/11 18:10:49 fenrir Exp $
* $Id: audio.c,v 1.13 2003/01/25 16:59:49 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -71,7 +71,7 @@ static unsigned int pi_channels_maps[6] =
/*****************************************************************************
* locales Functions
*****************************************************************************/
#if 0
static void ffmpeg_GetWaveFormatEx( waveformatex_t *p_wh,
u8 *p_data )
{
......@@ -93,7 +93,7 @@ static void ffmpeg_GetWaveFormatEx( waveformatex_t *p_wh,
p_wh->i_size );
}
}
#endif
/*****************************************************************************
*
......@@ -116,34 +116,31 @@ static void ffmpeg_GetWaveFormatEx( waveformatex_t *p_wh,
*****************************************************************************/
int E_( InitThread_Audio )( adec_thread_t *p_adec )
{
WAVEFORMATEX *p_wf;
WAVEFORMATEX wf, *p_wf;
if( ( p_wf = p_adec->p_fifo->p_waveformatex ) != NULL )
{
ffmpeg_GetWaveFormatEx( &p_adec->format,
(uint8_t*)p_wf );
}
else
if( ( p_wf = p_adec->p_fifo->p_waveformatex ) == NULL )
{
msg_Warn( p_adec->p_fifo, "audio informations missing" );
p_wf = &wf;
memset( p_wf, 0, sizeof( WAVEFORMATEX ) );
}
/* ***** Fill p_context with init values ***** */
p_adec->p_context->sample_rate = p_adec->format.i_samplespersec;
p_adec->p_context->channels = p_adec->format.i_nb_channels;
p_adec->p_context->sample_rate = p_wf->nSamplesPerSec;
p_adec->p_context->channels = p_wf->nChannels;
#if LIBAVCODEC_BUILD >= 4618
p_adec->p_context->block_align = p_adec->format.i_blockalign;
p_adec->p_context->block_align = p_wf->nBlockAlign;
#endif
p_adec->p_context->bit_rate = p_adec->format.i_avgbytespersec * 8;
p_adec->p_context->bit_rate = p_wf->nAvgBytesPerSec * 8;
if( ( p_adec->p_context->extradata_size = p_adec->format.i_size ) > 0 )
if( ( p_adec->p_context->extradata_size = p_wf->cbSize ) > 0 )
{
p_adec->p_context->extradata =
malloc( p_adec->format.i_size );
malloc( p_wf->cbSize );
memcpy( p_adec->p_context->extradata,
p_adec->format.p_data,
p_adec->format.i_size );
&p_wf[1],
p_wf->cbSize);
}
/* ***** Open the codec ***** */
......@@ -165,10 +162,10 @@ int E_( InitThread_Audio )( adec_thread_t *p_adec )
p_adec->output_format.i_format = AOUT_FMT_S16_NE;
p_adec->output_format.i_rate = p_adec->format.i_samplespersec;
p_adec->output_format.i_rate = p_wf->nSamplesPerSec;
p_adec->output_format.i_physical_channels
= p_adec->output_format.i_original_channels
= p_adec->format.i_nb_channels;
= p_wf->nChannels;
p_adec->p_aout = NULL;
p_adec->p_aout_input = NULL;
......@@ -355,7 +352,8 @@ usenextdata:
*****************************************************************************/
void E_( EndThread_Audio )( adec_thread_t *p_adec )
{
FREE( p_adec->format.p_data );
// FREE( p_adec->format.p_data );
FREE( p_adec->p_output );
if( p_adec->p_aout_input )
{
......
......@@ -2,7 +2,7 @@
* audio.h: video decoder using ffmpeg library
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: audio.h,v 1.2 2002/11/14 22:38:47 massiot Exp $
* $Id: audio.h,v 1.3 2003/01/25 16:59:49 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -40,13 +40,13 @@ typedef struct adec_thread_s
{
DECODER_THREAD_COMMON
waveformatex_t format;
// waveformatex_t format;
/*
* Output properties
*/
u8 * p_output;
uint8_t * p_output;
aout_instance_t * p_aout; /* opaque */
aout_input_t * p_aout_input; /* opaque */
......
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