]> git.sesse.net Git - mlt/blobdiff - src/modules/core/producer_colour.c
fix null pointer check (coverity-709396)
[mlt] / src / modules / core / producer_colour.c
index e5188fa7c056df41c9e8ac7e33b4bee45ae02c13..23740a1821d528518bdd7a7ed4657fc3c12a7638 100644 (file)
@@ -48,7 +48,7 @@ mlt_producer producer_colour_init( mlt_profile profile, mlt_service_type type, c
                producer->close = ( mlt_destructor )producer_close;
 
                // Set the default properties
-               mlt_properties_set( properties, "resource", colour == NULL ? "0x000000ff" : colour );
+               mlt_properties_set( properties, "resource", ( !colour || !strcmp( colour, "" ) ) ? "0x000000ff" : colour );
                mlt_properties_set( properties, "_resource", "" );
                mlt_properties_set_double( properties, "aspect_ratio", mlt_profile_sar( profile ) );
                
@@ -80,6 +80,12 @@ rgba_color parse_color( char *color, unsigned int color_int )
                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;
@@ -125,6 +131,14 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
        }
        rgba_color color = parse_color( now, mlt_properties_get_int( producer_props, "resource" ) );
 
+       // Choose suitable out values if nothing specific requested
+       if ( *format == mlt_image_none )
+               *format = mlt_image_rgb24a;
+       if ( *width <= 0 )
+               *width = mlt_service_profile( MLT_PRODUCER_SERVICE(producer) )->width;
+       if ( *height <= 0 )
+               *height = mlt_service_profile( MLT_PRODUCER_SERVICE(producer) )->height;
+
        // See if we need to regenerate
        if ( strcmp( now, then ) || *width != current_width || *height != current_height || *format != current_format )
        {
@@ -181,8 +195,7 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
                                *p ++ = color.b;
                        }
                        break;
-               case mlt_image_rgb24a:
-               case mlt_image_opengl:
+               default:
                        while ( --i )
                        {
                                *p ++ = color.r;
@@ -191,8 +204,6 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
                                *p ++ = color.a;
                        }
                        break;
-               default:
-                       break;
                }
        }
        else
@@ -216,8 +227,8 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
        mlt_frame_set_image( frame, *buffer, size, mlt_pool_release );
        mlt_frame_set_alpha( frame, alpha, alpha_size, mlt_pool_release );
        mlt_properties_set_double( properties, "aspect_ratio", mlt_properties_get_double( producer_props, "aspect_ratio" ) );
-       mlt_properties_set_int( properties, "real_width", *width );
-       mlt_properties_set_int( properties, "real_height", *height );
+       mlt_properties_set_int( properties, "meta.media.width", *width );
+       mlt_properties_set_int( properties, "meta.media.height", *height );
 
 
        return 0;