static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int index );
static void producer_close( mlt_producer parent );
-typedef enum
-{
- SIGNAL_FORMAT_PAL,
- SIGNAL_FORMAT_NTSC
-} mlt_signal_format;
-
static int filter_files( const struct dirent *de )
{
if ( de->d_name[ 0 ] != '.' )
return 0;
}
-
mlt_producer producer_pixbuf_init( char *filename )
{
producer_pixbuf this = calloc( sizeof( struct producer_pixbuf_s ), 1 );
{
mlt_producer producer = &this->parent;
- producer->get_frame = producer_get_frame;
- producer->close = producer_close;
-
// Get the properties interface
mlt_properties properties = mlt_producer_properties( &this->parent );
+ // Callback registration
+ producer->get_frame = producer_get_frame;
+ producer->close = producer_close;
+
// Set the default properties
mlt_properties_set( properties, "resource", filename );
mlt_properties_set_int( properties, "ttl", 25 );
gap ++;
}
}
- mlt_properties_set_position( properties, "out", this->count * 25 );
+ mlt_properties_set_position( properties, "out", this->count * 250 );
}
else if ( strstr( filename, "/.all." ) != NULL )
{
{
this->filenames = realloc( this->filenames, sizeof( char * ) * ( this->count + 1 ) );
this->filenames[ this->count ++ ] = strdup( filename );
- mlt_properties_set_position( properties, "out", 25 );
+ mlt_properties_set_position( properties, "out", 250 );
}
// Initialise gobject types
// Obtain properties of frame
mlt_properties properties = mlt_frame_properties( frame );
- // Obtain the producer pango for this frame
+ // Obtain the producer for this frame
producer_pixbuf this = mlt_properties_get_data( properties, "producer_pixbuf", NULL );
// Obtain the producer
mlt_frame_set_position( frame, mlt_producer_position( producer ) );
// optimization for subsequent iterations on single picture
- if ( this->image != NULL && image_idx == this->image_idx )
+ if ( width != 0 && this->image != NULL && image_idx == this->image_idx )
{
if ( width != this->width || height != this->height )
{
pixbuf = mlt_properties_get_data( producer_props, "pixbuf", NULL );
+ free( this->image );
+ free( this->alpha );
+ this->image = NULL;
+ this->alpha = NULL;
}
}
- else
+ else if ( this->image == NULL || image_idx != this->image_idx )
{
free( this->image );
- this->image = NULL;
free( this->alpha );
+ this->image = NULL;
this->alpha = NULL;
+
this->image_idx = image_idx;
pixbuf = gdk_pixbuf_new_from_file( this->filenames[ image_idx ], &error );
// If we have a pixbuf
if ( pixbuf && width > 0 )
{
- // Note - the original pixbuf is already safe and ready for destruction
- pixbuf = gdk_pixbuf_scale_simple( pixbuf, width, height, GDK_INTERP_HYPER );
+ char *interps = mlt_properties_get( properties, "rescale.interp" );
+ int interp = GDK_INTERP_BILINEAR;
- // Store width and height
- this->width = gdk_pixbuf_get_width( pixbuf );
- this->height = gdk_pixbuf_get_height( pixbuf );
+ if ( strcmp( interps, "nearest" ) == 0 )
+ interp = GDK_INTERP_NEAREST;
+ else if ( strcmp( interps, "tiles" ) == 0 )
+ interp = GDK_INTERP_TILES;
+ else if ( strcmp( interps, "hyper" ) == 0 )
+ interp = GDK_INTERP_HYPER;
- // Allocate/define image and alpha
- uint8_t *image = malloc( this->width * this->height * 2 );
+// 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 );
+
+ // Store width and height
+ this->width = width;
+ this->height = height;
+
+ // Allocate/define image
+ // IRRIGATE ME
+ uint8_t *image = malloc( width * ( height + 1 ) * 2 );
uint8_t *alpha = NULL;
// Extract YUV422 and alpha
// Finished with pixbuf now
g_object_unref( pixbuf );
- // Pass alpha and image on properties with or without destructor
+ // Assign images to producer
this->image = image;
this->alpha = alpha;
}
mlt_properties_set_int( properties, "real_width", mlt_properties_get_int( producer_props, "real_width" ) );
mlt_properties_set_int( properties, "real_height", mlt_properties_get_int( producer_props, "real_height" ) );
- // pass the image and alpha data without destructor
- mlt_properties_set_data( properties, "image", this->image, this->width * this->height * 2, NULL, NULL );
+ // pass the image data without destructor
+ mlt_properties_set_data( properties, "image", this->image, this->width * ( this->height + 1 ) * 2, NULL, NULL );
mlt_properties_set_data( properties, "alpha", this->alpha, this->width * this->height, NULL, NULL );
}
// Obtain properties of frame
mlt_properties properties = mlt_frame_properties( frame );
+ *width = mlt_properties_get_int( properties, "rescale_width" );
+ *height = mlt_properties_get_int( properties, "rescale_height" );
+
// Refresh the image
refresh_image( frame, *width, *height );
+ // Determine format
+ //mlt_producer this = mlt_properties_get_data( properties, "producer_pixbuf", NULL );
+ //*format = ( mlt_properties_get_int( mlt_producer_properties( this ), "bpp" ) == 4 ) ? mlt_image_rgb24a : mlt_image_rgb24;
+
// May need to know the size of the image to clone it
int size = 0;
// The fault is not in the design of mlt, but in the implementation of pixbuf...
//if ( writable )
{
- size = *width * *height * 2;
-
// Clone our image
+ // IRRIGATE ME
uint8_t *copy = malloc( size );
memcpy( copy, image, size );
// Set the producer on the frame properties
mlt_properties_set_data( properties, "producer_pixbuf", this, 0, NULL, NULL );
- // Refresh the pango image
+ // Refresh the image
refresh_image( *frame, 0, 0 );
+ // Set producer-specific frame properties
+ mlt_properties_set_int( properties, "progressive", 1 );
+ mlt_properties_set_double( properties, "aspect_ratio", mlt_properties_get_double( properties, "real_width" ) / mlt_properties_get_double( properties, "real_height" ) );
+
// Set alpha call back
( *frame )->get_alpha_mask = producer_get_alpha_mask;
{
producer_pixbuf this = parent->child;
free( this->image );
- free( this->alpha );
parent->close = NULL;
mlt_producer_close( parent );
free( this );