if ( producer != NULL && mlt_producer_init( producer, NULL ) == 0 )
{
// Get the properties interface
- mlt_properties properties = mlt_producer_properties( producer );
+ mlt_properties properties = MLT_PRODUCER_PROPERTIES( producer );
// Callback registration
producer->get_frame = producer_get_frame;
- producer->close = producer_close;
+ producer->close = ( mlt_destructor )producer_close;
// Set the default properties
- if ( colour == NULL )
- colour = "0x000000ff";
- mlt_properties_set( properties, "resource", colour );
+ mlt_properties_set( properties, "resource", colour == NULL ? "0x000000ff" : colour );
+ mlt_properties_set( properties, "_resource", "" );
return producer;
}
{
rgba_color result = { 0xff, 0xff, 0xff, 0xff };
+ if ( strchr( color, '/' ) )
+ color = strrchr( color, '/' ) + 1;
+
if ( !strncmp( color, "0x", 2 ) )
{
unsigned int temp = 0;
int size = 0;
// Obtain properties of frame
- mlt_properties properties = mlt_frame_properties( frame );
+ mlt_properties properties = MLT_FRAME_PROPERTIES( frame );
// Obtain the producer for this frame
mlt_producer producer = mlt_properties_get_data( properties, "producer_colour", NULL );
// Obtain properties of producer
- mlt_properties producer_props = mlt_producer_properties( producer );
+ mlt_properties producer_props = MLT_PRODUCER_PROPERTIES( producer );
+
+ // Get the current and previous colour strings
+ char *now = mlt_properties_get( producer_props, "resource" );
+ char *then = mlt_properties_get( producer_props, "_resource" );
// Get the current image and dimensions cached in the producer
uint8_t *image = mlt_properties_get_data( producer_props, "image", &size );
- int current_width = mlt_properties_get_int( producer_props, "width" );
- int current_height = mlt_properties_get_int( producer_props, "height" );
+ int current_width = mlt_properties_get_int( producer_props, "_width" );
+ int current_height = mlt_properties_get_int( producer_props, "_height" );
+
+ // Parse the colour
+ rgba_color color = parse_color( now );
// See if we need to regenerate
- if ( *width != current_width || *height != current_height )
+ if ( strcmp( now, then ) || *width != current_width || *height != current_height )
{
- fprintf( stderr, "%dx%d\n", *width, *height );
+ // Color the image
+ uint8_t y, u, v;
+ int i = 0;
+
// Allocate the image
size = *width * *height * 2;
image = mlt_pool_alloc( size );
// Update the producer
mlt_properties_set_data( producer_props, "image", image, size, mlt_pool_release, NULL );
- mlt_properties_set_int( producer_props, "width", *width );
- mlt_properties_set_int( producer_props, "height", *height );
+ mlt_properties_set_int( producer_props, "_width", *width );
+ mlt_properties_set_int( producer_props, "_height", *height );
+ mlt_properties_set( producer_props, "_resource", now );
- // Color the image
- rgba_color color = parse_color( mlt_properties_get( producer_props, "resource" ) );
- uint8_t y, u, v;
- int i;
RGB2YUV( color.r, color.g, color.b, y, u, v );
- color.r = y;
- color.g = u;
- color.b = y;
- color.a = v;
- for ( i = 0; i < size; i += 4 )
- memcpy( &image[ i ], &color, 4 );
+
+ while ( i < size )
+ {
+ image[ i ++ ] = y;
+ image[ i ++ ] = u;
+ image[ i ++ ] = y;
+ image[ i ++ ] = v;
+ }
}
// Update the frame
- mlt_properties_set_data( properties, "image", image, size, NULL, NULL );
mlt_properties_set_int( properties, "width", *width );
mlt_properties_set_int( properties, "height", *height );
- // Clone if necessary
- if ( writable )
+ // Clone if necessary (deemed always necessary)
+ if ( 1 )
{
+ // Create the alpha channel
+ uint8_t *alpha = mlt_pool_alloc( size >> 1 );
+
// Clone our image
uint8_t *copy = mlt_pool_alloc( size );
memcpy( copy, image, size );
// We're going to pass the copy on
image = copy;
+ // Initialise the alpha
+ if ( alpha )
+ memset( alpha, color.a, size >> 1 );
+
// Now update properties so we free the copy after
mlt_properties_set_data( properties, "image", copy, size, mlt_pool_release, NULL );
+ mlt_properties_set_data( properties, "alpha", alpha, size >> 1, mlt_pool_release, NULL );
}
// Pass on the image
if ( *frame != NULL )
{
// Obtain properties of frame and producer
- mlt_properties properties = mlt_frame_properties( *frame );
+ mlt_properties properties = MLT_FRAME_PROPERTIES( *frame );
// Obtain properties of producer
- mlt_properties producer_props = mlt_producer_properties( producer );
+ mlt_properties producer_props = MLT_PRODUCER_PROPERTIES( producer );
// Set the producer on the frame properties
mlt_properties_set_data( properties, "producer_colour", producer, 0, NULL, NULL );
// Set producer-specific frame properties
mlt_properties_set_int( properties, "progressive", 1 );
+ mlt_properties_set_double( properties, "aspect_ratio", 0 );
// colour is an alias for resource
if ( mlt_properties_get( producer_props, "colour" ) != NULL )
mlt_producer_close( producer );
free( producer );
}
-