From 367fcf2b4515ec1c187de0c0c673382344ba73e6 Mon Sep 17 00:00:00 2001 From: Dan Dennedy Date: Sat, 10 Dec 2011 16:54:54 -0800 Subject: [PATCH 1/1] add mlt_image_none support to producers --- src/modules/core/producer_colour.c | 13 +++++++++---- src/modules/core/producer_noise.c | 6 ++++++ src/modules/dv/producer_libdv.c | 2 +- src/modules/frei0r/producer_frei0r.c | 6 ++++++ src/modules/gtk2/producer_pango.c | 2 +- src/modules/gtk2/producer_pixbuf.c | 2 +- src/modules/qimage/producer_qimage.c | 2 +- src/modules/sdl/producer_sdl_image.c | 6 +----- 8 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/modules/core/producer_colour.c b/src/modules/core/producer_colour.c index e5188fa7..91c354b1 100644 --- a/src/modules/core/producer_colour.c +++ b/src/modules/core/producer_colour.c @@ -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 diff --git a/src/modules/core/producer_noise.c b/src/modules/core/producer_noise.c index 655ff23c..4b9bf21f 100644 --- a/src/modules/core/producer_noise.c +++ b/src/modules/core/producer_noise.c @@ -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; diff --git a/src/modules/dv/producer_libdv.c b/src/modules/dv/producer_libdv.c index eee02f9a..5125d2e3 100644 --- a/src/modules/dv/producer_libdv.c +++ b/src/modules/dv/producer_libdv.c @@ -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 ); diff --git a/src/modules/frei0r/producer_frei0r.c b/src/modules/frei0r/producer_frei0r.c index 26259f32..6a5abcd5 100644 --- a/src/modules/frei0r/producer_frei0r.c +++ b/src/modules/frei0r/producer_frei0r.c @@ -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; diff --git a/src/modules/gtk2/producer_pango.c b/src/modules/gtk2/producer_pango.c index d32827f0..deb8bd27 100644 --- a/src/modules/gtk2/producer_pango.c +++ b/src/modules/gtk2/producer_pango.c @@ -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 { diff --git a/src/modules/gtk2/producer_pixbuf.c b/src/modules/gtk2/producer_pixbuf.c index b12d7811..73694fbb 100644 --- a/src/modules/gtk2/producer_pixbuf.c +++ b/src/modules/gtk2/producer_pixbuf.c @@ -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 ) ); } diff --git a/src/modules/qimage/producer_qimage.c b/src/modules/qimage/producer_qimage.c index 7ad5a435..b65c8d95 100644 --- a/src/modules/qimage/producer_qimage.c +++ b/src/modules/qimage/producer_qimage.c @@ -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 ) ); } diff --git a/src/modules/sdl/producer_sdl_image.c b/src/modules/sdl/producer_sdl_image.c index bb7bdfba..2890ad31 100644 --- a/src/modules/sdl/producer_sdl_image.c +++ b/src/modules/sdl/producer_sdl_image.c @@ -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 ) -- 2.39.2