#include <unistd.h>
#include <dirent.h>
+typedef struct producer_pixbuf_s *producer_pixbuf;
+
+struct producer_pixbuf_s
+{
+ struct mlt_producer_s parent;
+
+ // File name list
+ char **filenames;
+ int count;
+ int image_idx;
+
+ int width;
+ int height;
+ void *image_release;
+ uint8_t *image;
+ void *alpha_release;
+ uint8_t *alpha;
+};
+
static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int index );
static void producer_close( mlt_producer parent );
if ( width != this->width || height != this->height )
{
pixbuf = mlt_properties_get_data( producer_props, "pixbuf", NULL );
- free( this->image );
- free( this->alpha );
+ mlt_pool_release( this->image_release );
+ mlt_pool_release( this->alpha_release );
+ this->image_release = NULL;
+ this->alpha_release = NULL;
this->image = NULL;
this->alpha = NULL;
}
}
else if ( this->image == NULL || image_idx != this->image_idx )
{
- free( this->image );
- free( this->alpha );
+ mlt_pool_release( this->image_release );
+ mlt_pool_release( this->alpha_release );
+ this->image_release = NULL;
+ this->alpha_release = NULL;
this->image = NULL;
this->alpha = NULL;
else if ( strcmp( interps, "hyper" ) == 0 )
interp = GDK_INTERP_HYPER;
-// fprintf( stderr, "SCALING PIXBUF from %dx%d to %dx%d was %dx%d\n", gdk_pixbuf_get_width( pixbuf ), gdk_pixbuf_get_height( pixbuf ), width, height, this->width, this->height );
-
// Note - the original pixbuf is already safe and ready for destruction
pixbuf = gdk_pixbuf_scale_simple( pixbuf, width, height, interp );
this->height = height;
// Allocate/define image
- // IRRIGATE ME
- uint8_t *image = malloc( width * ( height + 1 ) * 2 );
- uint8_t *alpha = NULL;
+ this->image = mlt_pool_allocate( width * ( height + 1 ) * 2, &this->image_release );
// Extract YUV422 and alpha
if ( gdk_pixbuf_get_has_alpha( pixbuf ) )
{
// Allocate the alpha mask
- alpha = malloc( this->width * this->height );
+ this->alpha = mlt_pool_allocate( this->width * this->height, &this->alpha_release );
// Convert the image
mlt_convert_rgb24a_to_yuv422( gdk_pixbuf_get_pixels( pixbuf ),
this->width, this->height,
gdk_pixbuf_get_rowstride( pixbuf ),
- image, alpha );
+ this->image, this->alpha );
}
else
{
mlt_convert_rgb24_to_yuv422( gdk_pixbuf_get_pixels( pixbuf ),
this->width, this->height,
gdk_pixbuf_get_rowstride( pixbuf ),
- image );
+ this->image );
}
// Finished with pixbuf now
g_object_unref( pixbuf );
-
- // Assign images to producer
- this->image = image;
- this->alpha = alpha;
}
// Set width/height of frame
//if ( writable )
{
// Clone our image
- // IRRIGATE ME
- uint8_t *copy = malloc( size );
+ void *release = NULL;
+ uint8_t *copy = mlt_pool_allocate( size, &release );
memcpy( copy, image, size );
// We're going to pass the copy on
image = copy;
// Now update properties so we free the copy after
- mlt_properties_set_data( properties, "image", copy, size, free, NULL );
+ mlt_properties_set_data( properties, "image_release", release, 0, mlt_pool_release, NULL );
+ mlt_properties_set_data( properties, "image", copy, size, NULL, NULL );
}
// Pass on the image