static int producer_collect_info( producer_libdv this )
{
int valid = 0;
- // IRRIGATE ME
- uint8_t *dv_data = malloc( frame_size_625_50 );
+
+ void *release = NULL;
+ uint8_t *dv_data = mlt_pool_allocate( frame_size_625_50, &release );
if ( dv_data != NULL )
{
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( release );
}
return valid;
if ( *format == mlt_image_yuv422 )
{
// Allocate an image
- // IRRIGATE ME
- uint8_t *image = malloc( *width * ( *height + 1 ) * 2 );
+ void *release = NULL;
+ uint8_t *image = mlt_pool_allocate( *width * ( *height + 1 ) * 2, &release );
// Pass to properties for clean up
- mlt_properties_set_data( properties, "image", image, *width * ( *height + 1 ) * 2, free, NULL );
+ mlt_properties_set_data( properties, "image_release", release, 0, ( mlt_destructor )mlt_pool_release, NULL );
+ mlt_properties_set_data( properties, "image", image, *width * ( *height + 1 ) * 2, NULL, NULL );
// Decode the image
pitches[ 0 ] = *width * 2;
else if ( *format == mlt_image_rgb24 )
{
// Allocate an image
- // IRRIGATE ME
- uint8_t *image = malloc( *width * ( *height + 1 ) * 3 );
+ void *release = NULL;
+ uint8_t *image = mlt_pool_allocate( *width * ( *height + 1 ) * 3, &release );
// Pass to properties for clean up
- mlt_properties_set_data( properties, "image", image, *width * ( *height + 1 ) * 3, free, NULL );
+ mlt_properties_set_data( properties, "image_release", release, 0, ( mlt_destructor )mlt_pool_release, NULL );
+ mlt_properties_set_data( properties, "image", image, *width * ( *height + 1 ) * 3, NULL, NULL );
// Decode the frame
pitches[ 0 ] = 720 * 3;
static int producer_get_audio( mlt_frame this, int16_t **buffer, mlt_audio_format *format, int *frequency, int *channels, int *samples )
{
+ void *release = NULL;
int16_t *p;
int i, j;
+ void *audio_release[ 4 ] = { NULL, NULL, NULL, NULL };
int16_t *audio_channels[ 4 ];
// Get the frames properties
// 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_allocate( DV_AUDIO_MAX_SAMPLES * sizeof( int16_t ), &audio_release[ i ] );
// Create a workspace for the result
- *buffer = malloc( *channels * DV_AUDIO_MAX_SAMPLES * sizeof( int16_t ) );
+ *buffer = mlt_pool_allocate( *channels * DV_AUDIO_MAX_SAMPLES * sizeof( int16_t ), &release );
// 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_release", release, 0, ( mlt_destructor )mlt_pool_release, NULL );
+ mlt_properties_set_data( properties, "audio", *buffer, *channels * DV_AUDIO_MAX_SAMPLES * sizeof( int16_t ), NULL, NULL );
// Decode the audio
dv_decode_full_audio( decoder, dv_data, audio_channels );
// Free the temporary work space
for ( i = 0; i < 4; i++ )
- free( audio_channels[ i ] );
+ mlt_pool_release( audio_release[ i ] );
return 0;
}
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 );
+ void *release = NULL;
+ uint8_t *data = mlt_pool_allocate( frame_size_625_50, &release );
// Obtain the current frame number
uint64_t position = mlt_producer_frame( producer );
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_release", release, 0, ( mlt_destructor )mlt_pool_release, NULL );
+ mlt_properties_set_data( properties, "dv_data", data, frame_size_625_50, NULL, NULL );
// Update other info on the frame
mlt_properties_set_int( properties, "width", 720 );
}
else
{
- free( data );
+ mlt_pool_release( release );
}
// Update timecode on the frame we're creating