From b6a2f96c4bb16dcbb03d45f90a8b833f3c6dda8e Mon Sep 17 00:00:00 2001 From: lilo_booter Date: Sat, 21 Feb 2004 08:18:50 +0000 Subject: [PATCH] avformat whoops, pooling claridication and removal of dv leak git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@159 d19143bc-622f-0410-bfdd-b5b2a6649095 --- src/framework/mlt_pool.c | 6 +++--- src/modules/avformat/producer_avformat.c | 15 +++++++-------- src/modules/dv/producer_libdv.c | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/framework/mlt_pool.c b/src/framework/mlt_pool.c index 16d1e1d..5f891e9 100644 --- a/src/framework/mlt_pool.c +++ b/src/framework/mlt_pool.c @@ -220,15 +220,15 @@ void *mlt_pool_alloc( int size ) mlt_pool pool = NULL; // Determines the index of the pool to use - int index = 0; + int index = 8; // Minimum size pooled is 256 bytes - size = size >> 8; + size = size + 4; while ( ( 1 << index ) < size ) index ++; // Now get the pool at the index - pool = mlt_properties_get_data_at( pools, index + 1, NULL ); + pool = mlt_properties_get_data_at( pools, index - 8, NULL ); // Now get the real item return pool_fetch( pool ); diff --git a/src/modules/avformat/producer_avformat.c b/src/modules/avformat/producer_avformat.c index a02f7cb..b1631f6 100644 --- a/src/modules/avformat/producer_avformat.c +++ b/src/modules/avformat/producer_avformat.c @@ -384,8 +384,8 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form int got_picture = 0; AVFrame frame; - //memset( &pkt, 0, sizeof( pkt ) ); - //memset( &frame, 0, sizeof( frame ) ); + memset( &pkt, 0, sizeof( pkt ) ); + memset( &frame, 0, sizeof( frame ) ); while( ret >= 0 && !got_picture ) { @@ -718,7 +718,7 @@ static int producer_get_audio( mlt_frame frame, int16_t **buffer, mlt_audio_form int got_audio = 0; int16_t *temp = mlt_pool_alloc( sizeof( int16_t ) * AVCODEC_MAX_AUDIO_FRAME_SIZE ); - //memset( &pkt, 0, sizeof( pkt ) ); + memset( &pkt, 0, sizeof( pkt ) ); while( ret >= 0 && !got_audio ) { @@ -794,20 +794,19 @@ static int producer_get_audio( mlt_frame frame, int16_t **buffer, mlt_audio_form av_free_packet( &pkt ); } + *buffer = mlt_pool_alloc( *samples * *channels * sizeof( int16_t ) ); + mlt_properties_set_data( frame_properties, "audio", *buffer, 0, ( mlt_destructor )mlt_pool_release, NULL ); + // Now handle the audio if we have enough if ( audio_used >= *samples ) { - *buffer = mlt_pool_alloc( *samples * *channels * sizeof( int16_t ) ); memcpy( *buffer, audio_buffer, *samples * *channels * sizeof( int16_t ) ); audio_used -= *samples; memmove( audio_buffer, &audio_buffer[ *samples * *channels ], audio_used * *channels * sizeof( int16_t ) ); - mlt_properties_set_data( frame_properties, "audio", *buffer, 0, ( mlt_destructor )mlt_pool_release, NULL ); } else { - frame->get_audio = NULL; - mlt_frame_get_audio( frame, buffer, format, frequency, channels, samples ); - audio_used = 0; + memset( *buffer, 0, *samples * *channels * sizeof( int16_t ) ); } // Store the number of audio samples still available diff --git a/src/modules/dv/producer_libdv.c b/src/modules/dv/producer_libdv.c index b346b72..b277313 100644 --- a/src/modules/dv/producer_libdv.c +++ b/src/modules/dv/producer_libdv.c @@ -334,7 +334,7 @@ static void producer_close( mlt_producer parent ) producer_libdv this = parent->child; // Free the dv deconder - //dv_decoder_free( this->dv_decoder ); + dv_decoder_free( this->dv_decoder ); // Close the file if ( this->fd > 0 ) -- 1.7.4.4