From: lilo_booter Date: Tue, 24 Feb 2004 08:41:24 +0000 (+0000) Subject: Filter optimisations and cleanup part 1 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=efe08354d45db7bf5478ffa17c35330a3e0d415c;p=mlt Filter optimisations and cleanup part 1 git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@165 d19143bc-622f-0410-bfdd-b5b2a6649095 --- diff --git a/src/framework/mlt_consumer.c b/src/framework/mlt_consumer.c index 7165ae9b..99a3856c 100644 --- a/src/framework/mlt_consumer.c +++ b/src/framework/mlt_consumer.c @@ -164,7 +164,7 @@ mlt_frame mlt_consumer_get_frame( mlt_consumer this ) if ( mlt_properties_get( properties, "rescale" ) != NULL ) mlt_properties_set( frame_properties, "rescale.interp", mlt_properties_get( properties, "rescale" ) ); - // TODO: Aspect ratio and other jiggery pokery + // Aspect ratio and other jiggery pokery mlt_properties_set_double( frame_properties, "consumer_aspect_ratio", mlt_properties_get_double( properties, "aspect_ratio" ) ); mlt_properties_set_int( frame_properties, "consumer_progressive", mlt_properties_get_int( properties, "progressive" ) ); diff --git a/src/framework/mlt_filter.c b/src/framework/mlt_filter.c index 90dea22c..d83e42fb 100644 --- a/src/framework/mlt_filter.c +++ b/src/framework/mlt_filter.c @@ -48,13 +48,23 @@ int mlt_filter_init( mlt_filter this, void *child ) mlt_properties_set_position( properties, "in", 0 ); mlt_properties_set_position( properties, "out", 0 ); mlt_properties_set_int( properties, "track", 0 ); - mlt_properties_set( properties, "resource", "" ); return 0; } return 1; } +/** Create a new filter. +*/ + +mlt_filter mlt_filter_new( ) +{ + mlt_filter this = calloc( 1, sizeof( struct mlt_filter_s ) ); + if ( this != NULL ) + mlt_filter_init( this, NULL ); + return this; +} + /** Get the service associated to this filter */ diff --git a/src/framework/mlt_filter.h b/src/framework/mlt_filter.h index d107b339..158f28a9 100644 --- a/src/framework/mlt_filter.h +++ b/src/framework/mlt_filter.h @@ -48,6 +48,7 @@ struct mlt_filter_s */ extern int mlt_filter_init( mlt_filter this, void *child ); +extern mlt_filter mlt_filter_new( ); extern mlt_service mlt_filter_service( mlt_filter this ); extern mlt_properties mlt_filter_properties( mlt_filter this ); extern mlt_frame mlt_filter_process( mlt_filter this, mlt_frame that ); diff --git a/src/framework/mlt_frame.c b/src/framework/mlt_frame.c index 409d3687..6c367e93 100644 --- a/src/framework/mlt_frame.c +++ b/src/framework/mlt_frame.c @@ -65,8 +65,11 @@ mlt_frame mlt_frame_init( ) mlt_properties_set_data( properties, "audio", NULL, 0, NULL, NULL ); mlt_properties_set_data( properties, "alpha", NULL, 0, NULL, NULL ); - + // Construct stacks for frames and methods + this->stack_get_image = mlt_deque_init( ); + this->stack_frame = mlt_deque_init( ); } + return this; } @@ -131,10 +134,7 @@ int mlt_frame_set_position( mlt_frame this, mlt_position value ) int mlt_frame_push_get_image( mlt_frame this, mlt_get_image get_image ) { - int ret = this->stack_get_image_size >= 10; - if ( ret == 0 ) - this->stack_get_image[ this->stack_get_image_size ++ ] = get_image; - return ret; + return mlt_deque_push_back( this->stack_get_image, get_image ); } /** Pop a get_image callback. @@ -142,10 +142,7 @@ int mlt_frame_push_get_image( mlt_frame this, mlt_get_image get_image ) mlt_get_image mlt_frame_pop_get_image( mlt_frame this ) { - mlt_get_image result = NULL; - if ( this->stack_get_image_size > 0 ) - result = this->stack_get_image[ -- this->stack_get_image_size ]; - return result; + return mlt_deque_pop_back( this->stack_get_image ); } /** Push a frame. @@ -153,10 +150,7 @@ mlt_get_image mlt_frame_pop_get_image( mlt_frame this ) int mlt_frame_push_frame( mlt_frame this, mlt_frame that ) { - int ret = this->stack_frame_size >= 10; - if ( ret == 0 ) - this->stack_frame[ this->stack_frame_size ++ ] = that; - return ret; + return mlt_deque_push_back( this->stack_frame, that ); } /** Pop a frame. @@ -164,10 +158,7 @@ int mlt_frame_push_frame( mlt_frame this, mlt_frame that ) mlt_frame mlt_frame_pop_frame( mlt_frame this ) { - mlt_frame result = NULL; - if ( this->stack_frame_size > 0 ) - result = this->stack_frame[ -- this->stack_frame_size ]; - return result; + return mlt_deque_pop_back( this->stack_frame ); } int mlt_frame_get_image( mlt_frame this, uint8_t **buffer, mlt_image_format *format, int *width, int *height, int writable ) @@ -302,6 +293,8 @@ int mlt_frame_get_audio( mlt_frame this, int16_t **buffer, mlt_audio_format *for void mlt_frame_close( mlt_frame this ) { + mlt_deque_close( this->stack_get_image ); + mlt_deque_close( this->stack_frame ); mlt_properties_close( &this->parent ); free( this ); } diff --git a/src/framework/mlt_frame.h b/src/framework/mlt_frame.h index ee11626a..1af60688 100644 --- a/src/framework/mlt_frame.h +++ b/src/framework/mlt_frame.h @@ -22,6 +22,7 @@ #define _MLT_FRAME_H_ #include "mlt_properties.h" +#include "mlt_deque.h" typedef enum { @@ -59,10 +60,8 @@ struct mlt_frame_s uint8_t * ( *get_alpha_mask )( mlt_frame this ); // Private properties - mlt_get_image stack_get_image[ 10 ]; - int stack_get_image_size; - mlt_frame stack_frame[ 10 ]; - int stack_frame_size; + mlt_deque stack_get_image; + mlt_deque stack_frame; }; extern mlt_frame mlt_frame_init( ); diff --git a/src/modules/core/filter_brightness.c b/src/modules/core/filter_brightness.c index d4b02af0..6850d528 100644 --- a/src/modules/core/filter_brightness.c +++ b/src/modules/core/filter_brightness.c @@ -31,21 +31,33 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable ) { - mlt_frame_get_image( this, image, format, width, height, 1 ); - uint8_t *p = *image; - uint8_t *q = *image + *width * *height * 2; + // Get the image + int error = mlt_frame_get_image( this, image, format, width, height, 1 ); - // Get the brightness level - double level = mlt_properties_get_double( mlt_frame_properties( this ), "brightness.level" ); - - while ( p != q ) + // Only process if we have no error and a valid colour space + if ( error == 0 && *format == mlt_image_yuv422 ) { - float x = (float) *p * level; - *p = x < 16 ? 16 : x > 235 ? 235 : x; - p += 2; + // Get the brightness level + double level = mlt_properties_get_double( mlt_frame_properties( this ), "brightness" ); + + // Only process if level is something other than 1 + if ( level != 1.0 ) + { + uint8_t *p = *image; + uint8_t *q = *image + *width * *height * 2; + int32_t x = 0; + int32_t m = level * ( 1 << 16 ); + + while ( p != q ) + { + x = ( *p * m ) >> 16; + *p = x < 16 ? 16 : x > 235 ? 235 : x; + p += 2; + } + } } - return 0; + return error; } /** Filter processing. @@ -53,6 +65,7 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * static mlt_frame filter_process( mlt_filter this, mlt_frame frame ) { + // Get the starting brightness level double level = fabs( mlt_properties_get_double( mlt_filter_properties( this ), "start" ) ); // If there is an end adjust gain to the range @@ -66,8 +79,11 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame ) double end = fabs( mlt_properties_get_double( mlt_filter_properties( this ), "end" ) ); level += ( end - level ) * position; } + + // Push the frame filter + mlt_properties_set_double( mlt_frame_properties( frame ), "brightness", level ); mlt_frame_push_get_image( frame, filter_get_image ); - mlt_properties_set_double( mlt_frame_properties( frame ), "brightness.level", level ); + return frame; } @@ -76,13 +92,11 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame ) mlt_filter filter_brightness_init( char *arg ) { - mlt_filter this = calloc( sizeof( struct mlt_filter_s ), 1 ); + mlt_filter this = mlt_filter_new( ); if ( this != NULL ) { - mlt_filter_init( this, NULL ); this->process = filter_process; - if ( arg != NULL ) - mlt_properties_set_double( mlt_filter_properties( this ), "start", atof( arg ) ); + mlt_properties_set( mlt_filter_properties( this ), "start", arg == NULL ? "1" : arg ); } return this; } diff --git a/src/modules/core/filter_deinterlace.c b/src/modules/core/filter_deinterlace.c index 3b4598a3..59257f16 100644 --- a/src/modules/core/filter_deinterlace.c +++ b/src/modules/core/filter_deinterlace.c @@ -25,15 +25,6 @@ #include #include -/** Deinterlace class. -*/ - -typedef struct -{ - struct mlt_filter_s parent; -} -filter_deinterlace; - /* Linear Blend filter - C version contributed by Rogerio Brito. This algorithm has the same interface as the other functions. @@ -55,27 +46,27 @@ static void deinterlace_yuv( uint8_t *pdst, uint8_t *psrc, int width, int height register int x, y; register uint8_t *l0, *l1, *l2, *l3; - l0 = pdst; /* target line */ - l1 = psrc; /* 1st source line */ - l2 = l1 + width; /* 2nd source line = line that follows l1 */ - l3 = l2 + width; /* 3rd source line = line that follows l2 */ + l0 = pdst; // target line + l1 = psrc; // 1st source line + l2 = l1 + width; // 2nd source line = line that follows l1 + l3 = l2 + width; // 3rd source line = line that follows l2 - /* Copy the first line */ + // Copy the first line memcpy(l0, l1, width); l0 += width; for (y = 1; y < height-1; ++y) { - /* computes avg of: l1 + 2*l2 + l3 */ + // computes avg of: l1 + 2*l2 + l3 for (x = 0; x < width; ++x) l0[x] = (l1[x] + (l2[x]<<1) + l3[x]) >> 2; - /* updates the line pointers */ + // updates the line pointers l1 = l2; l2 = l3; l3 += width; l0 += width; } - /* Copy the last line */ + // Copy the last line memcpy(l0, l1, width); } @@ -84,10 +75,25 @@ static void deinterlace_yuv( uint8_t *pdst, uint8_t *psrc, int width, int height static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable ) { - mlt_frame_get_image( this, image, format, width, height, 1 ); - deinterlace_yuv( *image, *image, *width * 2, *height ); - mlt_properties_set_int( mlt_frame_properties( this ), "progressive", 1 ); - return 0; + // Get the input image + int error = mlt_frame_get_image( this, image, format, width, height, 1 ); + + // Only continue if we have no error and the right colour space + if ( error == 0 && *format == mlt_image_yuv422 ) + { + // Check that we want progressive and we aren't already progressive + if ( !mlt_properties_get_int( mlt_frame_properties( this ), "progressive" ) && + mlt_properties_get_int( mlt_frame_properties( this ), "consumer_progressive" ) ) + { + // Deinterlace the image + deinterlace_yuv( *image, *image, *width * 2, *height ); + + // Make sure that others know the frame is deinterlaced + mlt_properties_set_int( mlt_frame_properties( this ), "progressive", 1 ); + } + } + + return error; } /** Deinterlace filter processing - this should be lazy evaluation here... @@ -104,14 +110,9 @@ static mlt_frame deinterlace_process( mlt_filter this, mlt_frame frame ) mlt_filter filter_deinterlace_init( void *arg ) { - filter_deinterlace *this = calloc( sizeof( filter_deinterlace ), 1 ); + mlt_filter this = mlt_filter_new( ); if ( this != NULL ) - { - mlt_filter filter = &this->parent; - mlt_filter_init( filter, this ); - filter->process = deinterlace_process; - return &this->parent; - } - return NULL; + this->process = deinterlace_process; + return this; } diff --git a/src/modules/core/filter_gamma.c b/src/modules/core/filter_gamma.c index 33875616..213bc3ad 100644 --- a/src/modules/core/filter_gamma.c +++ b/src/modules/core/filter_gamma.c @@ -31,25 +31,32 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable ) { - mlt_frame_get_image( this, image, format, width, height, 1 ); - uint8_t *p = *image; - uint8_t *q = *image + *width * *height * 2; + int error = mlt_frame_get_image( this, image, format, width, height, 1 ); - // Get the gamma value - double gamma = mlt_properties_get_double( mlt_frame_properties( this ), "gamma" ); + if ( error != 0 && *format == mlt_image_yuv422 ) + { + // Get the gamma value + double gamma = mlt_properties_get_double( mlt_frame_properties( this ), "gamma" ); - // Calculate the look up table - double exp = 1 / gamma; - uint8_t lookup[ 256 ]; - int i; + if ( gamma != 1.0 ) + { + uint8_t *p = *image; + uint8_t *q = *image + *width * *height * 2; - for( i = 0; i < 256; i ++ ) - lookup[ i ] = ( uint8_t )( pow( ( double )i / 255.0, exp ) * 255 ); + // Calculate the look up table + double exp = 1 / gamma; + uint8_t lookup[ 256 ]; + int i; - while ( p != q ) - { - *p = lookup[ *p ]; - p += 2; + for( i = 0; i < 256; i ++ ) + lookup[ i ] = ( uint8_t )( pow( ( double )i / 255.0, exp ) * 255 ); + + while ( p != q ) + { + *p = lookup[ *p ]; + p += 2; + } + } } return 0; @@ -61,9 +68,9 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * static mlt_frame filter_process( mlt_filter this, mlt_frame frame ) { double gamma = mlt_properties_get_double( mlt_filter_properties( this ), "gamma" ); - gamma = gamma <= 0 ? 2 : gamma; - mlt_frame_push_get_image( frame, filter_get_image ); + gamma = gamma <= 0 ? 1 : gamma; mlt_properties_set_double( mlt_frame_properties( frame ), "gamma", gamma ); + mlt_frame_push_get_image( frame, filter_get_image ); return frame; } @@ -72,13 +79,11 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame ) mlt_filter filter_gamma_init( char *arg ) { - mlt_filter this = calloc( sizeof( struct mlt_filter_s ), 1 ); + mlt_filter this = mlt_filter_new( ); if ( this != NULL ) { - mlt_filter_init( this, NULL ); this->process = filter_process; - if ( arg != NULL ) - mlt_properties_set_double( mlt_filter_properties( this ), "gamma", atof( arg ) ); + mlt_properties_set( mlt_filter_properties( this ), "gamma", arg == NULL ? "1" : arg ); } return this; } diff --git a/src/modules/core/filter_greyscale.c b/src/modules/core/filter_greyscale.c index 170ff4f5..8373161c 100644 --- a/src/modules/core/filter_greyscale.c +++ b/src/modules/core/filter_greyscale.c @@ -25,26 +25,20 @@ #include #include -/** Greyscale class. -*/ - -typedef struct -{ - struct mlt_filter_s parent; -} -filter_greyscale; - /** Do it :-). */ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable ) { - mlt_frame_get_image( this, image, format, width, height, 1 ); - uint8_t *p = *image; - uint8_t *q = *image + *width * *height * 2; - while ( p ++ != q ) - *p ++ = 128; - return 0; + int error = mlt_frame_get_image( this, image, format, width, height, 1 ); + if ( error == 0 && *format == mlt_image_yuv422 ) + { + uint8_t *p = *image; + uint8_t *q = *image + *width * *height * 2; + while ( p ++ != q ) + *p ++ = 128; + } + return error; } /** Filter processing. @@ -61,13 +55,9 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame ) mlt_filter filter_greyscale_init( void *arg ) { - filter_greyscale *this = calloc( sizeof( filter_greyscale ), 1 ); + mlt_filter this = mlt_filter_new( ); if ( this != NULL ) - { - mlt_filter filter = &this->parent; - mlt_filter_init( filter, this ); - filter->process = filter_process; - } - return ( mlt_filter )this; + this->process = filter_process; + return this; } diff --git a/src/modules/core/filter_obscure.c b/src/modules/core/filter_obscure.c index 7324293f..b3c16229 100644 --- a/src/modules/core/filter_obscure.c +++ b/src/modules/core/filter_obscure.c @@ -148,17 +148,18 @@ static float position_calculate( mlt_filter this, mlt_frame frame ) /** The averaging function... */ -void obscure_average( uint8_t *start, int width, int height, int stride, uint8_t *alpha ) +void obscure_average( uint8_t *start, int width, int height, int stride ) { int y; int x; - int Y = ( *start + *( start + 2 ) ) / 2; - int U = *( start + 1 ); - int V = *( start + 3 ); + register int Y = ( *start + *( start + 2 ) ) / 2; + register int U = *( start + 1 ); + register int V = *( start + 3 ); + register uint8_t *p; for ( y = 0; y < height; y ++ ) { - uint8_t *p = start + y * stride; + p = start + y * stride; for ( x = 0; x < width / 2; x ++ ) { Y = ( Y + *p ++ ) / 2; @@ -170,34 +171,14 @@ void obscure_average( uint8_t *start, int width, int height, int stride, uint8_t for ( y = 0; y < height; y ++ ) { - uint8_t *p = start + y * stride; - uint8_t *z = alpha; - - if ( z != NULL ) - z += y * stride / 2; + p = start + y * stride; for ( x = 0; x < width / 2; x ++ ) { - if ( z == NULL || ( z != NULL && *z++ > 127 ) ) - { - *p ++ = Y; - *p ++ = U; - } - else - { - p += 2; - } - - if ( z == NULL || ( z != NULL && *z++ > 127 ) ) - { - - *p ++ = Y; - *p ++ = V; - } - else - { - p += 2; - } + *p ++ = Y; + *p ++ = U; + *p ++ = Y; + *p ++ = V; } } } @@ -206,7 +187,7 @@ void obscure_average( uint8_t *start, int width, int height, int stride, uint8_t /** The obscurer rendering function... */ -static void obscure_render( uint8_t *image, int width, int height, struct geometry_s result, uint8_t *alpha ) +static void obscure_render( uint8_t *image, int width, int height, struct geometry_s result ) { int area_x = result.x; int area_y = result.y; @@ -217,21 +198,19 @@ static void obscure_render( uint8_t *image, int width, int height, struct geomet int mh = result.mask_h; int w; int h; + int aw; + int ah; uint8_t *p = image + area_y * width * 2 + area_x * 2; - uint8_t *z = alpha; - if ( z != NULL ) - z += area_y * width + area_x; for ( w = 0; w < area_w; w += mw ) { for ( h = 0; h < area_h; h += mh ) { - int aw = w + mw > area_w ? mw - ( w + mw - area_w ) : mw; - int ah = h + mh > area_h ? mh - ( h + mh - area_h ) : mh; + aw = w + mw > area_w ? mw - ( w + mw - area_w ) : mw; + ah = h + mh > area_h ? mh - ( h + mh - area_h ) : mh; if ( aw > 1 && ah > 1 ) - obscure_average( p + h * width * 2 + w * 2, aw, ah, width * 2, - ( z == NULL ? z : z + h * width + w ) ); + obscure_average( p + h * width * 2 + w * 2, aw, ah, width * 2 ); } } } @@ -278,7 +257,7 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format geometry_calculate( &result, &start, &end, position, *width, *height ); // Now actually render it - obscure_render( *image, *width, *height, result, mlt_frame_get_alpha_mask( frame ) ); + obscure_render( *image, *width, *height, result ); } } @@ -320,12 +299,14 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame ) mlt_filter filter_obscure_init( void *arg ) { - mlt_filter this = calloc( 1, sizeof( struct mlt_filter_s ) ); - mlt_properties properties = mlt_filter_properties( this ); - mlt_filter_init( this, NULL ); - this->process = filter_process; - mlt_properties_set( properties, "start", arg != NULL ? arg : "0%,0%:100%x100%" ); - mlt_properties_set( properties, "end", "" ); + mlt_filter this = mlt_filter_new( ); + if ( this != NULL ) + { + mlt_properties properties = mlt_filter_properties( this ); + this->process = filter_process; + mlt_properties_set( properties, "start", arg != NULL ? arg : "0%,0%:100%x100%" ); + mlt_properties_set( properties, "end", "" ); + } return this; } diff --git a/src/modules/core/filter_resize.c b/src/modules/core/filter_resize.c index 7e7fac3a..60a28872 100644 --- a/src/modules/core/filter_resize.c +++ b/src/modules/core/filter_resize.c @@ -39,6 +39,8 @@ static int get_value( mlt_properties properties, char *preferred, char *fallback static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable ) { + int error = 0; + // Get the properties from the frame mlt_properties properties = mlt_frame_properties( this ); @@ -69,19 +71,6 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * scaled_width = input_ar / output_ar * normalised_width; scaled_height = normalised_height; } - //fprintf( stderr, "resize: %dx%d from %dx%d input aspect %f output aspect %f\n", - // scaled_width, scaled_height, normalised_width, normalised_height, input_ar, output_ar ); - -#if 0 - int real_width = get_value( properties, "real_height", "height" ); - int real_height = get_value( properties, "real_height", "height" ); - // DRD> Why? - if ( ( real_height * 2 ) == normalised_height ) - { - scaled_width = normalised_width; - scaled_height = normalised_height; - } -#endif // Now calculate the actual image size that we want owidth = scaled_width * owidth / normalised_width; @@ -96,38 +85,47 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * mlt_properties_set_int( properties, "resize_height", *height ); // Now get the image - mlt_frame_get_image( this, image, format, &owidth, &oheight, writable ); - - // Correct field order if needed - if ( mlt_properties_get_int( properties, "top_field_first" ) == 1 ) + error = mlt_frame_get_image( this, image, format, &owidth, &oheight, writable ); + + // We only know how to process yuv422 at the moment + if ( error == 0 && *format == mlt_image_yuv422 ) { - // Get the input image, width and height - int size; - uint8_t *image = mlt_properties_get_data( properties, "image", &size ); + // Correct field order if needed + if ( mlt_properties_get_int( properties, "top_field_first" ) == 1 ) + { + // Get the input image, width and height + int size; + uint8_t *image = mlt_properties_get_data( properties, "image", &size ); - // Keep the original image around to be destroyed on frame close - mlt_properties_rename( properties, "image", "original_image" ); + // Keep the original image around to be destroyed on frame close + mlt_properties_rename( properties, "image", "original_image" ); - // Offset the image pointer by one line - image += owidth * 2; - size -= owidth * 2; + // Offset the image pointer by one line + image += owidth * 2; + size -= owidth * 2; - // Set the new image pointer with no destructor - mlt_properties_set_data( properties, "image", image, size, NULL, NULL ); + // Set the new image pointer with no destructor + mlt_properties_set_data( properties, "image", image, size, NULL, NULL ); - // Set the normalised field order - mlt_properties_set_int( properties, "top_field_first", 0 ); - } + // Set the normalised field order + mlt_properties_set_int( properties, "top_field_first", 0 ); + } - if ( !strcmp( mlt_properties_get( properties, "resize.scale" ), "affine" ) ) - *image = mlt_frame_rescale_yuv422( this, *width, *height ); - else if ( strcmp( mlt_properties_get( properties, "resize.scale" ), "none" ) != 0 ) - *image = mlt_frame_resize_yuv422( this, *width, *height ); - else - { - *width = owidth; - *height = oheight; + if ( !strcmp( mlt_properties_get( properties, "resize.scale" ), "affine" ) ) + { + *image = mlt_frame_rescale_yuv422( this, *width, *height ); + } + else if ( strcmp( mlt_properties_get( properties, "resize.scale" ), "none" ) != 0 ) + { + *image = mlt_frame_resize_yuv422( this, *width, *height ); + } + else + { + *width = owidth; + *height = oheight; + } } + return 0; } diff --git a/src/modules/core/transition_composite.c b/src/modules/core/transition_composite.c index 1499db1a..ad0c792f 100644 --- a/src/modules/core/transition_composite.c +++ b/src/modules/core/transition_composite.c @@ -360,13 +360,6 @@ static int get_b_frame_image( mlt_frame b_frame, uint8_t **image, int *width, in scaled_height = normalised_height; } -#if 0 - // DRD> Why? - // Special case - if ( scaled_height == normalised_height ) - scaled_width = normalised_width; -#endif - // Now we need to align to the geometry if ( scaled_width <= geometry->w && scaled_height <= geometry->h ) { diff --git a/src/modules/fezzik/producer_fezzik.c b/src/modules/fezzik/producer_fezzik.c index 20ab7ea4..31475127 100644 --- a/src/modules/fezzik/producer_fezzik.c +++ b/src/modules/fezzik/producer_fezzik.c @@ -132,6 +132,7 @@ mlt_producer producer_fezzik_init( char *arg ) mlt_properties_set_data( properties, "producer", producer, 0, ( mlt_destructor )mlt_producer_close, NULL ); // Now attach normalising filters + last = create_filter( tractor, last, "deinterlace" ); last = create_filter( tractor, last, "rescale" ); last = create_filter( tractor, last, "resize" ); last = create_filter( tractor, last, "resample" ); diff --git a/src/modules/gtk2/producer_pixbuf.c b/src/modules/gtk2/producer_pixbuf.c index b73d64b1..7ee7b1cf 100644 --- a/src/modules/gtk2/producer_pixbuf.c +++ b/src/modules/gtk2/producer_pixbuf.c @@ -168,10 +168,7 @@ static void refresh_image( mlt_frame frame, int width, int height ) double ttl = mlt_properties_get_int( producer_props, "ttl" ); // Image index - int image_idx = ( int )floor( mlt_producer_position( producer ) / ttl ) % this->count; - - // Update timecode on the frame we're creating - mlt_frame_set_position( frame, mlt_producer_position( producer ) ); + int image_idx = ( int )floor( mlt_frame_get_position( frame ) / ttl ) % this->count; // optimization for subsequent iterations on single picture if ( width != 0 && this->image != NULL && image_idx == this->image_idx ) @@ -338,6 +335,9 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i // Set the producer on the frame properties mlt_properties_set_data( properties, "producer_pixbuf", this, 0, NULL, NULL ); + // Update timecode on the frame we're creating + mlt_frame_set_position( *frame, mlt_producer_position( producer ) ); + // Refresh the image refresh_image( *frame, 0, 0 ); diff --git a/src/modules/sdl/consumer_sdl.c b/src/modules/sdl/consumer_sdl.c index d35e4a78..64cf9d9a 100644 --- a/src/modules/sdl/consumer_sdl.c +++ b/src/modules/sdl/consumer_sdl.c @@ -103,7 +103,7 @@ mlt_consumer consumer_sdl_init( char *arg ) mlt_properties_set( this->properties, "rescale", "nearest" ); // Default progressive true - mlt_properties_set_int( this->properties, "progressive", 1 ); + mlt_properties_set_int( this->properties, "progressive", 0 ); // Get aspect ratio this->aspect_ratio = mlt_properties_get_double( this->properties, "aspect_ratio" );