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
{
......@@ -253,7 +254,7 @@ static int InitThread( adec_thread_t * p_adec )
p_adec->p_buffer = malloc( i_frame_size + 16 );
p_adec->i_buffer = i_frame_size + 16;
}
GetPESData( p_adec->p_buffer, p_adec->i_buffer, p_pes );
}
else
......@@ -295,7 +296,7 @@ static int InitThread( adec_thread_t * p_adec )
p_faad_config = faacDecGetCurrentConfiguration( p_adec->p_handle );
p_faad_config->outputFormat = FAAD_FMT_FLOAT;
faacDecSetConfiguration( p_adec->p_handle, p_faad_config );
/* Initialize the thread properties */
p_adec->output_format.i_format = VLC_FOURCC('f','l','3','2');
......@@ -307,7 +308,7 @@ static int InitThread( adec_thread_t * p_adec )
p_adec->p_aout_input = NULL;
p_adec->pts = 0;
return( 0 );
}
......@@ -350,12 +351,12 @@ static void DecodeThread( adec_thread_t *p_adec )
p_adec->p_buffer = malloc( i_frame_size + 16 );
p_adec->i_buffer = i_frame_size + 16;
}
GetPESData( p_adec->p_buffer, p_adec->i_buffer, p_pes );
}
input_DeletePES( p_adec->p_fifo->p_packets_mgt, p_pes );
} while( i_frame_size <= 0 );
/* **** decode this frame **** */
p_faad_buffer = faacDecDecode( p_adec->p_handle,
&faad_frame,
......@@ -392,7 +393,7 @@ static void DecodeThread( adec_thread_t *p_adec )
#endif
/* **** Now we can output these samples **** */
/* **** First check if we have a valid output **** */
if( ( !p_adec->p_aout_input )||
( p_adec->output_format.i_original_channels !=
......@@ -470,7 +471,7 @@ static void EndThread (adec_thread_t *p_adec)
FREE( p_adec->p_buffer );
msg_Dbg( p_adec->p_fifo, "faad decoder closed" );
free( p_adec );
}
......@@ -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,37 +116,34 @@ 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 );
p_adec->p_context->extradata =
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 ***** */
/* ***** Open the codec ***** */
if (avcodec_open(p_adec->p_context, p_adec->p_codec) < 0)
{
msg_Err( p_adec->p_fifo,
......@@ -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,12 +352,13 @@ 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 )
{
aout_DecDelete( p_adec->p_aout, 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,19 +40,19 @@ typedef struct adec_thread_s
{
DECODER_THREAD_COMMON
waveformatex_t format;
// waveformatex_t format;
/*
* Output properties
*/
u8 * p_output;
aout_instance_t * p_aout; /* opaque */
aout_input_t * p_aout_input; /* opaque */
uint8_t * p_output;
aout_instance_t * p_aout; /* opaque */
aout_input_t * p_aout_input; /* opaque */
audio_sample_format_t output_format;
audio_date_t date;
audio_date_t date;
} 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