X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmodules%2Fcore%2Fproducer_colour.c;h=c2f645bcd0b236a73fd2f37ce655fe8e2b39ece1;hb=1f6faabf5ef11e6321d186772d88fb6958cdd057;hp=0c40f99b0ff17c68f2153fd9de015343555c564e;hpb=f00476101550ec7d8e863f6516aa83bc1b524570;p=melted diff --git a/src/modules/core/producer_colour.c b/src/modules/core/producer_colour.c index 0c40f99..c2f645b 100644 --- a/src/modules/core/producer_colour.c +++ b/src/modules/core/producer_colour.c @@ -117,6 +117,9 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form // Obtain properties of producer mlt_properties producer_props = MLT_PRODUCER_PROPERTIES( producer ); + // Parse the colour + rgba_color color = parse_color( 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" ); @@ -125,6 +128,10 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form // See if we need to regenerate if ( *width != current_width || *height != current_height ) { + // Color the image + uint8_t y, u, v; + int i = 0; + // Allocate the image size = *width * *height * 2; image = mlt_pool_alloc( size ); @@ -134,10 +141,6 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form mlt_properties_set_int( producer_props, "width", *width ); mlt_properties_set_int( producer_props, "height", *height ); - // Color the image - rgba_color color = parse_color( mlt_properties_get( producer_props, "resource" ) ); - uint8_t y, u, v; - int i = 0; RGB2YUV( color.r, color.g, color.b, y, u, v ); while ( i < size ) @@ -157,6 +160,9 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form // Clone if necessary if ( writable ) { + // 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 ); @@ -164,8 +170,13 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form // 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 @@ -188,9 +199,6 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i // Obtain properties of producer mlt_properties producer_props = MLT_PRODUCER_PROPERTIES( producer ); - // Determine if we're producing PAL or NTSC - int is_pal = mlt_properties_get_double( producer_props, "fps" ) == 25.0; - // Set the producer on the frame properties mlt_properties_set_data( properties, "producer_colour", producer, 0, NULL, NULL ); @@ -199,7 +207,7 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i // Set producer-specific frame properties mlt_properties_set_int( properties, "progressive", 1 ); - mlt_properties_set_double( properties, "aspect_ratio", is_pal ? 59.0/54.0 : 10.0/11.0 ); + mlt_properties_set_double( properties, "aspect_ratio", 0 ); // colour is an alias for resource if ( mlt_properties_get( producer_props, "colour" ) != NULL )