X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmodules%2Fcore%2Fproducer_colour.c;h=725570b971db25e7dbf831f131e44a5c2fee211c;hb=ae867071f780e9c61a5013f6f7452850b4151e07;hp=c1fa1681e3d558814e2f944b5540194a93711ccf;hpb=9b6540065980faa29d412eadae56a461c80ad5c2;p=melted diff --git a/src/modules/core/producer_colour.c b/src/modules/core/producer_colour.c index c1fa168..725570b 100644 --- a/src/modules/core/producer_colour.c +++ b/src/modules/core/producer_colour.c @@ -49,6 +49,8 @@ mlt_producer producer_colour_init( char *colour ) // Set the default properties mlt_properties_set( properties, "resource", colour == NULL ? "0x000000ff" : colour ); + mlt_properties_set( properties, "_resource", "" ); + mlt_properties_set_double( properties, "aspect_ratio", 0 ); return producer; } @@ -117,20 +119,28 @@ 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 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 ) { // Color the image uint8_t y, u, v; - int i = 0; + int i = *height; + int j = 0; + int uneven = *width % 2; + int count = ( *width - uneven ) / 2; + uint8_t *p = NULL; // Allocate the image size = *width * *height * 2; @@ -138,27 +148,38 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form // 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 ); RGB2YUV( color.r, color.g, color.b, y, u, v ); - while ( i < size ) + p = image; + + while ( i -- ) { - image[ i ++ ] = y; - image[ i ++ ] = u; - image[ i ++ ] = y; - image[ i ++ ] = v; + j = count; + while ( j -- ) + { + *p ++ = y; + *p ++ = u; + *p ++ = y; + *p ++ = v; + } + if ( uneven ) + { + *p ++ = y; + *p ++ = u; + } } } // 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 ); @@ -177,6 +198,7 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form // 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 ); + mlt_properties_set_double( properties, "aspect_ratio", mlt_properties_get_double( producer_props, "aspect_ratio" ) ); } // Pass on the image @@ -199,9 +221,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 ); @@ -210,7 +229,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", mlt_properties_get_double( producer_props, "aspect_ratio" ) ); // colour is an alias for resource if ( mlt_properties_get( producer_props, "colour" ) != NULL )