X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmodules%2Fcore%2Fproducer_colour.c;h=2cc677905a2fe4b4772a7f23eda68c1aab1c3a23;hb=1da06dddd4f117c21c07b3682fab5abab014d995;hp=6ff180ff966cb08f972ac60c462e2f0b8613f020;hpb=6820dfa615e2f55eb4ef17327c2cd293605c3389;p=melted diff --git a/src/modules/core/producer_colour.c b/src/modules/core/producer_colour.c index 6ff180f..2cc6779 100644 --- a/src/modules/core/producer_colour.c +++ b/src/modules/core/producer_colour.c @@ -45,12 +45,10 @@ mlt_producer producer_colour_init( char *colour ) // 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 ); return producer; } @@ -62,6 +60,9 @@ rgba_color parse_color( char *color ) { rgba_color result = { 0xff, 0xff, 0xff, 0xff }; + if ( strchr( color, '/' ) ) + color = strrchr( color, '/' ) + 1; + if ( !strncmp( color, "0x", 2 ) ) { unsigned int temp = 0; @@ -124,7 +125,6 @@ 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 ) { - fprintf( stderr, "%dx%d\n", *width, *height ); // Allocate the image size = *width * *height * 2; image = mlt_pool_alloc( size ); @@ -137,14 +137,16 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form // Color the image rgba_color color = parse_color( mlt_properties_get( producer_props, "resource" ) ); uint8_t y, u, v; - int i; + int i = 0; 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 @@ -186,6 +188,9 @@ 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 ); @@ -194,6 +199,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 ? 128.0/117.0 : 72.0/79.0 ); // colour is an alias for resource if ( mlt_properties_get( producer_props, "colour" ) != NULL ) @@ -215,4 +221,3 @@ static void producer_close( mlt_producer producer ) mlt_producer_close( producer ); free( producer ); } -