X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmodules%2Fdv%2Fproducer_libdv.c;h=b2773135f48cb9b7c5c4a851c4be232896c44300;hb=b6a2f96c4bb16dcbb03d45f90a8b833f3c6dda8e;hp=5f9e9623933da885d76bddfd857535bd8b8050b1;hpb=6159bd78fa8e72c784747776a2c4c63d9c461ff5;p=melted diff --git a/src/modules/dv/producer_libdv.c b/src/modules/dv/producer_libdv.c index 5f9e962..b277313 100644 --- a/src/modules/dv/producer_libdv.c +++ b/src/modules/dv/producer_libdv.c @@ -111,7 +111,8 @@ static int read_frame( int fd, uint8_t* frame_buf, int *isPAL ) static int producer_collect_info( producer_libdv this ) { int valid = 0; - uint8_t *dv_data = malloc( frame_size_625_50 ); + + uint8_t *dv_data = mlt_pool_alloc( frame_size_625_50 ); if ( dv_data != NULL ) { @@ -155,7 +156,7 @@ static int producer_collect_info( producer_libdv this ) mlt_properties_set_double( properties, "aspect_ratio", dv_format_wide( this->dv_decoder ) ? 16.0/9.0 : 4.0/3.0 ); } - free( dv_data ); + mlt_pool_release( dv_data ); } return valid; @@ -186,10 +187,10 @@ static int producer_get_image( mlt_frame this, uint8_t **buffer, mlt_image_forma if ( *format == mlt_image_yuv422 ) { // Allocate an image - uint8_t *image = malloc( *width * *height * 2 ); + uint8_t *image = mlt_pool_alloc( *width * ( *height + 1 ) * 2 ); // Pass to properties for clean up - mlt_properties_set_data( properties, "image", image, *width * *height * 2, free, NULL ); + mlt_properties_set_data( properties, "image", image, *width * ( *height + 1 ) * 2, ( mlt_destructor )mlt_pool_release, NULL ); // Decode the image pitches[ 0 ] = *width * 2; @@ -202,10 +203,10 @@ static int producer_get_image( mlt_frame this, uint8_t **buffer, mlt_image_forma else if ( *format == mlt_image_rgb24 ) { // Allocate an image - uint8_t *image = malloc( *width * *height * 3 ); + uint8_t *image = mlt_pool_alloc( *width * ( *height + 1 ) * 3 ); // Pass to properties for clean up - mlt_properties_set_data( properties, "image", image, *width * *height * 3, free, NULL ); + mlt_properties_set_data( properties, "image", image, *width * ( *height + 1 ) * 3, ( mlt_destructor )mlt_pool_release, NULL ); // Decode the frame pitches[ 0 ] = 720 * 3; @@ -245,13 +246,13 @@ static int producer_get_audio( mlt_frame this, int16_t **buffer, mlt_audio_forma // Create a temporary workspace for ( i = 0; i < 4; i++ ) - audio_channels[ i ] = malloc( DV_AUDIO_MAX_SAMPLES * sizeof( int16_t ) ); + audio_channels[ i ] = mlt_pool_alloc( DV_AUDIO_MAX_SAMPLES * sizeof( int16_t ) ); // Create a workspace for the result - *buffer = malloc( *channels * DV_AUDIO_MAX_SAMPLES * sizeof( int16_t ) ); + *buffer = mlt_pool_alloc( *channels * DV_AUDIO_MAX_SAMPLES * sizeof( int16_t ) ); // Pass the allocated audio buffer as a property - mlt_properties_set_data( properties, "audio", *buffer, *channels * DV_AUDIO_MAX_SAMPLES * sizeof( int16_t ), free, NULL ); + mlt_properties_set_data( properties, "audio", *buffer, *channels * DV_AUDIO_MAX_SAMPLES * sizeof( int16_t ), ( mlt_destructor )mlt_pool_release, NULL ); // Decode the audio dv_decode_full_audio( decoder, dv_data, audio_channels ); @@ -264,7 +265,7 @@ static int producer_get_audio( mlt_frame this, int16_t **buffer, mlt_audio_forma // Free the temporary work space for ( i = 0; i < 4; i++ ) - free( audio_channels[ i ] ); + mlt_pool_release( audio_channels[ i ] ); return 0; } @@ -272,7 +273,7 @@ static int producer_get_audio( mlt_frame this, int16_t **buffer, mlt_audio_forma static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int index ) { producer_libdv this = producer->child; - uint8_t *data = malloc( frame_size_625_50 ); + uint8_t *data = mlt_pool_alloc( frame_size_625_50 ); // Obtain the current frame number uint64_t position = mlt_producer_frame( producer ); @@ -295,7 +296,7 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i mlt_properties_set_data( properties, "dv_decoder", this->dv_decoder, 0, NULL, NULL ); // Pass the dv data - mlt_properties_set_data( properties, "dv_data", data, frame_size_625_50, free, NULL ); + mlt_properties_set_data( properties, "dv_data", data, frame_size_625_50, ( mlt_destructor )mlt_pool_release, NULL ); // Update other info on the frame mlt_properties_set_int( properties, "width", 720 ); @@ -315,7 +316,7 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i } else { - free( data ); + mlt_pool_release( data ); } // Update timecode on the frame we're creating @@ -333,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 )