From 6cb69d693e97026b4d9f42b38b2b8c77e452287e Mon Sep 17 00:00:00 2001 From: ddennedy Date: Sat, 27 Dec 2008 05:53:38 +0000 Subject: [PATCH] filter_luma.c: prevent the first application of the nested luma transition from being applied to a test card image. This makes slideshows start without a transition at the beginning, which is nicer and more expected. git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@1291 d19143bc-622f-0410-bfdd-b5b2a6649095 --- src/modules/core/filter_luma.c | 31 ++++++++++++++++++++++++++----- 1 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/modules/core/filter_luma.c b/src/modules/core/filter_luma.c index f2e1156..f05d6c4 100644 --- a/src/modules/core/filter_luma.c +++ b/src/modules/core/filter_luma.c @@ -44,6 +44,12 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * if ( out == 0 ) out = 24; + if ( b_frame == NULL || mlt_properties_get_int( b_frame_props, "width" ) != *width || mlt_properties_get_int( b_frame_props, "height" ) != *height ) + { + b_frame = mlt_frame_init( MLT_FILTER_SERVICE( filter ) ); + mlt_properties_set_data( properties, "frame", b_frame, 0, ( mlt_destructor )mlt_frame_close, NULL ); + } + if ( luma == NULL ) { char *resource = mlt_properties_get( properties, "resource" ); @@ -57,12 +63,27 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * mlt_properties_set_int( luma_properties, "reverse", 1 ); mlt_properties_set_data( properties, "luma", luma, 0, ( mlt_destructor )mlt_transition_close, NULL ); } - } - if ( b_frame == NULL || mlt_properties_get_int( b_frame_props, "width" ) != *width || mlt_properties_get_int( b_frame_props, "height" ) != *height ) - { - b_frame = mlt_frame_init( MLT_FILTER_SERVICE( filter ) ); - mlt_properties_set_data( properties, "frame", b_frame, 0, ( mlt_destructor )mlt_frame_close, NULL ); + // Prime the filter with the first image to prevent a transition from the white + // of a test card. + error = mlt_frame_get_image( this, image, format, width, height, 1 ); + if ( error == 0 ) + { + mlt_properties a_props = MLT_FRAME_PROPERTIES( this ); + int size = 0; + uint8_t *src = mlt_properties_get_data( a_props, "image", &size ); + uint8_t *dst = mlt_pool_alloc( size ); + + if ( dst != NULL ) + { + mlt_properties b_props = MLT_FRAME_PROPERTIES( b_frame ); + memcpy( dst, src, size ); + mlt_properties_set_data( b_props, "image", dst, size, mlt_pool_release, NULL ); + mlt_properties_set_int( b_props, "width", *width ); + mlt_properties_set_int( b_props, "height", *height ); + mlt_properties_set_int( b_props, "format", *format ); + } + } } if ( luma != NULL && -- 1.7.4.4