]> git.sesse.net Git - mlt/commitdiff
add mlt_image_none support to producers
authorDan Dennedy <dan@dennedy.org>
Sun, 11 Dec 2011 00:54:54 +0000 (16:54 -0800)
committerDan Dennedy <dan@dennedy.org>
Sun, 11 Dec 2011 00:54:54 +0000 (16:54 -0800)
src/modules/core/producer_colour.c
src/modules/core/producer_noise.c
src/modules/dv/producer_libdv.c
src/modules/frei0r/producer_frei0r.c
src/modules/gtk2/producer_pango.c
src/modules/gtk2/producer_pixbuf.c
src/modules/qimage/producer_qimage.c
src/modules/sdl/producer_sdl_image.c

index e5188fa7c056df41c9e8ac7e33b4bee45ae02c13..91c354b134d296433ed241dd400b85e60f589a27 100644 (file)
@@ -125,6 +125,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 +189,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 +198,6 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
                                *p ++ = color.a;
                        }
                        break;
-               default:
-                       break;
                }
        }
        else
index 655ff23caec45121501f4e3a5b28b40b893f04d0..4b9bf21f2e3dbad90a8c1d4482876fe539952ce5 100644 (file)
@@ -65,6 +65,12 @@ mlt_producer producer_noise_init( mlt_profile profile, mlt_service_type type, co
 
 static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_format *format, int *width, int *height, int writable )
 {
+       // Choose suitable out values if nothing specific requested
+       if ( *width <= 0 )
+               *width = mlt_service_profile( MLT_PRODUCER_SERVICE( mlt_frame_get_original_producer( frame ) ) )->width;
+       if ( *height <= 0 )
+               *height = mlt_service_profile( MLT_PRODUCER_SERVICE( mlt_frame_get_original_producer( frame ) ) )->height;
+
        // Calculate the size of the image
        int size = *width * *height * 2;
 
index eee02f9ab74123180fe851c19da31e02e5a035fb..5125d2e3d7505708533a1961cc80c863017d0f27 100644 (file)
@@ -335,7 +335,7 @@ static int producer_get_image( mlt_frame this, uint8_t **buffer, mlt_image_forma
        *height = dv_data[ 3 ] & 0x80 ? 576 : 480;
 
        // Extract an image of the format requested
-       if ( *format == mlt_image_yuv422 || *format == mlt_image_yuv420p )
+       if ( *format != mlt_image_rgb24 )
        {
                // Allocate an image
                uint8_t *image = mlt_pool_alloc( *width * ( *height + 1 ) * 2 );
index 26259f329c8ceed236e82b2f6b38f9ed5d62cca0..6a5abcd5741fc930b97220e2caffc33027becd85 100644 (file)
@@ -36,6 +36,12 @@ 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 );
 
+       // Choose suitable out values if nothing specific requested
+       if ( *width <= 0 )
+               *width = mlt_service_profile( MLT_PRODUCER_SERVICE(producer) )->width;
+       if ( *height <= 0 )
+               *height = mlt_service_profile( MLT_PRODUCER_SERVICE(producer) )->height;
+
        // Allocate the image
        int size = *width * ( *height + 1 ) * 4;
 
index d32827f0352bcd1099d3ff88eefacd8163172c5e..deb8bd27c354c3020833a9ea315a418dee9692f3 100644 (file)
@@ -508,6 +508,7 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
        // Get width and height
        *width = this->width;
        *height = this->height;
+       *format = mlt_image_rgb24a;
 
        // Always clone here to allow 'animated' text
        if ( this->pixbuf )
@@ -519,7 +520,6 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
 
                // Now update properties so we free the copy after
                mlt_frame_set_image( frame, *buffer, image_size, mlt_pool_release );
-               *format = mlt_image_rgb24a;
        }
        else
        {
index b12d7811b7412a8f12af802924d86fd5a9d02604..73694fbbb972152db20ff47962cd5d14ecb7c071 100644 (file)
@@ -472,6 +472,7 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
        // Get width and height (may have changed during the refresh)
        *width = this->width;
        *height = this->height;
+       *format = this->alpha ? mlt_image_rgb24a : mlt_image_rgb24;
 
        // NB: Cloning is necessary with this producer (due to processing of images ahead of use)
        // The fault is not in the design of mlt, but in the implementation of the pixbuf producer...
@@ -485,7 +486,6 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
                mlt_frame_set_image( frame, image_copy, image_size, mlt_pool_release );
                // We're going to pass the copy on
                *buffer = image_copy;
-               *format = this->alpha ? mlt_image_rgb24a : mlt_image_rgb24;
                mlt_log_debug( MLT_PRODUCER_SERVICE( &this->parent ), "%dx%d (%s)\n",
                        this->width, this->height, mlt_image_format_name( *format ) );
        }
index 7ad5a435e4b4462f54ec6f438e37d7398c07b04c..b65c8d956ad4bf71b9727c591c22d9f0eddc02c9 100644 (file)
@@ -169,6 +169,7 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
        // Get width and height (may have changed during the refresh)
        *width = mlt_properties_get_int( properties, "width" );
        *height = mlt_properties_get_int( properties, "height" );
+       *format = this->has_alpha ? mlt_image_rgb24a : mlt_image_rgb24;
 
        // NB: Cloning is necessary with this producer (due to processing of images ahead of use)
        // The fault is not in the design of mlt, but in the implementation of the qimage producer...
@@ -182,7 +183,6 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
                mlt_frame_set_image( frame, image_copy, image_size, mlt_pool_release );
                // We're going to pass the copy on
                *buffer = image_copy;
-               *format = this->has_alpha ? mlt_image_rgb24a : mlt_image_rgb24;
                mlt_log_debug( MLT_PRODUCER_SERVICE( &this->parent ), "%dx%d (%s)\n", 
                        this->current_width, this->current_height, mlt_image_format_name( *format ) );
        }
index bb7bdfba049c32a34251787b3d638ff70b675d6d..2890ad319acecfee100447dd95cd921d26838720 100644 (file)
@@ -65,15 +65,11 @@ static int producer_get_image( mlt_frame frame, uint8_t **image, mlt_image_forma
                        *image = mlt_pool_alloc( image_size );
                        memcpy( *image, surface->pixels, image_size );
                        break;
-               case 24:
+               default:
                        *format = mlt_image_rgb24;
                        *image = mlt_pool_alloc( image_size );
                        memcpy( *image, surface->pixels, image_size );
                        break;
-               default:
-                       *image = mlt_pool_alloc( image_size );
-                       memcpy( *image, converted->pixels, image_size );
-                       break;
        }
 
        if ( converted )