]> git.sesse.net Git - mlt/commitdiff
Refactor producer color to use mlt_properties_get_color().
authorDan Dennedy <dan@dennedy.org>
Sat, 15 Feb 2014 19:28:25 +0000 (11:28 -0800)
committerDan Dennedy <dan@dennedy.org>
Sat, 15 Feb 2014 19:28:25 +0000 (11:28 -0800)
src/modules/core/producer_colour.c

index 0121689ec1b57c86c7080681b8d4d91f66f3478c..bb9427cc40d2783f8983739c601facce6f15fd83 100644 (file)
 #include <string.h>
 
 
-typedef struct
-{
-       uint8_t r, g, b, a;
-} rgba_color;
-
 static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int index );
 static void producer_close( mlt_producer parent );
 
@@ -58,45 +53,6 @@ mlt_producer producer_colour_init( mlt_profile profile, mlt_service_type type, c
        return NULL;
 }
 
-rgba_color parse_color( char *color, unsigned int color_int )
-{
-       rgba_color result = { 0xff, 0xff, 0xff, 0xff };
-
-       if ( !strcmp( color, "red" ) )
-       {
-               result.r = 0xff;
-               result.g = 0x00;
-               result.b = 0x00;
-       }
-       else if ( !strcmp( color, "green" ) )
-       {
-               result.r = 0x00;
-               result.g = 0xff;
-               result.b = 0x00;
-       }
-       else if ( !strcmp( color, "blue" ) )
-       {
-               result.r = 0x00;
-               result.g = 0x00;
-               result.b = 0xff;
-       }
-       else if ( !strcmp( color, "black" ) )
-       {
-               result.r = 0x00;
-               result.g = 0x00;
-               result.b = 0x00;
-       }
-       else if ( strcmp( color, "white" ) )
-       {
-               result.r = ( color_int >> 24 ) & 0xff;
-               result.g = ( color_int >> 16 ) & 0xff;
-               result.b = ( color_int >> 8 ) & 0xff;
-               result.a = ( color_int ) & 0xff;
-       }
-
-       return result;
-}
-
 static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_format *format, int *width, int *height, int writable )
 {
        // Obtain properties of frame
@@ -129,7 +85,7 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
                free( now );
                now = mlt_properties_get( producer_props, "resource" );
        }
-       rgba_color color = parse_color( now, mlt_properties_get_int( producer_props, "resource" ) );
+       mlt_color color = mlt_properties_get_color( producer_props, "resource" );
 
        // Choose suitable out values if nothing specific requested
        if ( *format == mlt_image_none )