From 5998e04fc78baf161cb12bd0e62254ed570b6b2b Mon Sep 17 00:00:00 2001 From: lilo_booter Date: Mon, 27 Dec 2004 21:08:13 +0000 Subject: [PATCH] Composite distort, fill and titles rework git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@579 d19143bc-622f-0410-bfdd-b5b2a6649095 --- demo/mlt_bouncy_ball | 8 +++----- demo/mlt_my_name_is | 2 +- demo/mlt_title_over_gfx | 2 +- src/framework/mlt_tractor.c | 8 ++++---- src/modules/core/filter_rescale.c | 5 +++-- src/modules/core/filter_resize.c | 2 +- src/modules/core/filter_watermark.c | 6 +++--- src/modules/core/transition_composite.c | 21 +++++++++++++-------- src/modules/core/transition_region.c | 19 ++++++++++++------- src/modules/data_fx.properties | 4 ++-- src/modules/feeds/PAL/data_fx.properties | 4 ++-- src/modules/plus/filter_affine.c | 2 +- src/modules/plus/transition_affine.c | 4 ++-- 13 files changed, 48 insertions(+), 39 deletions(-) diff --git a/demo/mlt_bouncy_ball b/demo/mlt_bouncy_ball index ff61f6c..1aedb5c 100644 --- a/demo/mlt_bouncy_ball +++ b/demo/mlt_bouncy_ball @@ -3,12 +3,10 @@ clip3.dv \ -track \ clip1.dv \ -transition \ -region \ -composite.start=10%,10%:20%x20% \ -composite.key[33]=30%,70%:25%x25% \ -composite.key[66]=70%,30%:15%x15% \ -composite.end=70%,70%:20%x20% \ +region:circle \ +composite.geometry="10%,10%:20%x20%;33=30%,70%:25%x25%;66=70%,30%:15%x15%;-1=70%,70%:20%x20%" \ composite.out=100 \ +composite.softness=0.1 \ a_track=0 \ b_track=1 \ in=0 \ diff --git a/demo/mlt_my_name_is b/demo/mlt_my_name_is index a0ad96e..bd6bc3f 100644 --- a/demo/mlt_my_name_is +++ b/demo/mlt_my_name_is @@ -4,7 +4,7 @@ clip3.dv \ "+My name is Inigo Montoya.txt" out=99 -blank 49 "+Prepare to die!.txt" out=99 \ -track \ -blank 74 "+You killed my father.txt" out=74 \ --transition composite:50%,20%:5%x4% end=10%,20%:80%x12% fill=true halign=centre valign=centre in=0 out=99 a_track=0 b_track=1 \ +-transition composite:50%,20%:5%x4% end=10%,20%:80%x12% distort=1 halign=centre valign=centre in=0 out=99 a_track=0 b_track=1 \ -transition composite:0%,70%:100%x10% end=100%,70%:100%x10% in=75 out=149 a_track=0 b_track=2 \ -transition composite:25%,25%:50%x50%! in=150 out=249 a_track=0 b_track=1 \ $* diff --git a/demo/mlt_title_over_gfx b/demo/mlt_title_over_gfx index d9158a1..72168a9 100644 --- a/demo/mlt_title_over_gfx +++ b/demo/mlt_title_over_gfx @@ -10,7 +10,7 @@ inigo \ out=199 \ a_track=1 \ b_track=2 \ - fill=true \ + distort=1 \ -transition \ composite:0%,75%:100%x20%:0 \ in=50 \ diff --git a/src/framework/mlt_tractor.c b/src/framework/mlt_tractor.c index 968b518..979e39c 100644 --- a/src/framework/mlt_tractor.c +++ b/src/framework/mlt_tractor.c @@ -206,8 +206,8 @@ static int producer_get_image( mlt_frame this, uint8_t **buffer, mlt_image_forma mlt_properties_set_int( frame_properties, "width", mlt_properties_get_int( properties, "width" ) ); mlt_properties_set_int( frame_properties, "height", mlt_properties_get_int( properties, "height" ) ); mlt_properties_set( frame_properties, "rescale.interp", mlt_properties_get( properties, "rescale.interp" ) ); - if ( mlt_properties_get( properties, "distort" ) ) - mlt_properties_set( frame_properties, "distort", mlt_properties_get( properties, "distort" ) ); + if ( mlt_properties_get_int( properties, "distort" ) ) + mlt_properties_set_int( frame_properties, "distort", mlt_properties_get_int( properties, "distort" ) ); mlt_properties_set_double( frame_properties, "consumer_aspect_ratio", mlt_properties_get_double( properties, "consumer_aspect_ratio" ) ); mlt_properties_set_int( frame_properties, "consumer_deinterlace", mlt_properties_get_double( properties, "consumer_deinterlace" ) ); mlt_properties_set_int( frame_properties, "normalised_width", mlt_properties_get_double( properties, "normalised_width" ) ); @@ -218,8 +218,8 @@ static int producer_get_image( mlt_frame this, uint8_t **buffer, mlt_image_forma mlt_properties_set_int( properties, "height", *height ); mlt_properties_set_double( properties, "aspect_ratio", mlt_frame_get_aspect_ratio( frame ) ); mlt_properties_set_int( properties, "progressive", mlt_properties_get_int( frame_properties, "progressive" ) ); - if ( mlt_properties_get( frame_properties, "distort" ) ) - mlt_properties_set( properties, "distort", mlt_properties_get( frame_properties, "distort" ) ); + if ( mlt_properties_get_int( frame_properties, "distort" ) ) + mlt_properties_set_int( properties, "distort", mlt_properties_get_int( frame_properties, "distort" ) ); data = mlt_frame_get_alpha_mask( frame ); mlt_properties_set_data( properties, "alpha", data, 0, NULL, NULL ); return 0; diff --git a/src/modules/core/filter_rescale.c b/src/modules/core/filter_rescale.c index 164d9cd..672b2b6 100644 --- a/src/modules/core/filter_rescale.c +++ b/src/modules/core/filter_rescale.c @@ -110,9 +110,10 @@ static int filter_scale( mlt_frame this, uint8_t **image, mlt_image_format iform static void scale_alpha( mlt_frame this, int iwidth, int iheight, int owidth, int oheight ) { - uint8_t *input = mlt_frame_get_alpha_mask( this ); + int size = 0; + uint8_t *input = mlt_properties_get_data( MLT_FRAME_PROPERTIES( this ), "alpha", &size ); - if ( input != NULL ) + if ( input != NULL && ( size == iwidth * iheight ) || size == ( iwidth * ( iheight + 1 ) ) ) { uint8_t *output = mlt_pool_alloc( owidth * oheight ); diff --git a/src/modules/core/filter_resize.c b/src/modules/core/filter_resize.c index 2315f78..ba27859 100644 --- a/src/modules/core/filter_resize.c +++ b/src/modules/core/filter_resize.c @@ -48,7 +48,7 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * if ( rescale != NULL && !strcmp( rescale, "none" ) ) return mlt_frame_get_image( this, image, format, width, height, writable ); - if ( mlt_properties_get( properties, "distort" ) == NULL ) + if ( mlt_properties_get_int( properties, "distort" ) == 0 ) { // Normalise the input and out display aspect int normalised_width = mlt_properties_get_int( properties, "normalised_width" ); diff --git a/src/modules/core/filter_watermark.c b/src/modules/core/filter_watermark.c index f834c12..8bd237a 100644 --- a/src/modules/core/filter_watermark.c +++ b/src/modules/core/filter_watermark.c @@ -149,9 +149,9 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format if ( mlt_properties_get_int( properties, "distort" ) ) { - mlt_properties_set( MLT_TRANSITION_PROPERTIES( composite ), "distort", "true" ); - mlt_properties_set( a_props, "distort", "true" ); - mlt_properties_set( b_props, "distort", "true" ); + mlt_properties_set_int( MLT_TRANSITION_PROPERTIES( composite ), "distort", 1 ); + mlt_properties_set_int( a_props, "distort", 1 ); + mlt_properties_set_int( b_props, "distort", 1 ); } if ( mlt_properties_get_int( properties, "reverse" ) == 0 ) diff --git a/src/modules/core/transition_composite.c b/src/modules/core/transition_composite.c index dda6c65..bd224a2 100644 --- a/src/modules/core/transition_composite.c +++ b/src/modules/core/transition_composite.c @@ -689,12 +689,18 @@ static int get_b_frame_image( mlt_transition this, mlt_frame b_frame, uint8_t ** scaled_height = normalised_height; } - // Now apply the fill - // TODO: Should combine fill/distort in one property - if ( mlt_properties_get( properties, "fill" ) != NULL ) + if ( mlt_properties_get_int( properties, "fill" ) ) { - scaled_width = ( geometry->item.w / scaled_width ) * scaled_width; - scaled_height = ( geometry->item.h / scaled_height ) * scaled_height; + if ( scaled_height < normalised_height && scaled_width * normalised_height / scaled_height < normalised_width ) + { + scaled_width = scaled_width * normalised_height / scaled_height; + scaled_height = normalised_height; + } + else if ( scaled_width < normalised_width && scaled_height * normalised_width / scaled_width < normalised_height ) + { + scaled_height = scaled_height * normalised_width / scaled_width; + scaled_width = normalised_width; + } } // Save the new scaled dimensions @@ -708,7 +714,7 @@ static int get_b_frame_image( mlt_transition this, mlt_frame b_frame, uint8_t ** } // We want to ensure that we bypass resize now... - mlt_properties_set( b_props, "distort", "true" ); + mlt_properties_set_int( b_props, "distort", 1 ); // Take into consideration alignment for optimisation if ( !mlt_properties_get_int( properties, "titles" ) ) @@ -893,7 +899,7 @@ mlt_frame composite_copy_region( mlt_transition this, mlt_frame a_frame, mlt_pos // Assign this position to the b frame mlt_frame_set_position( b_frame, frame_position ); - mlt_properties_set( b_props, "distort", "true" ); + mlt_properties_set_int( b_props, "distort", 1 ); // Return the frame return b_frame; @@ -972,7 +978,6 @@ static int transition_get_image( mlt_frame a_frame, uint8_t **image, mlt_image_f { if ( mlt_properties_get( b_props, "rescale.interp" ) == NULL ) mlt_properties_set( b_props, "rescale.interp", "hyper" ); - mlt_properties_set( properties, "fill", NULL ); width_b = mlt_properties_get_int( a_props, "dest_width" ); height_b = mlt_properties_get_int( a_props, "dest_height" ); } diff --git a/src/modules/core/transition_region.c b/src/modules/core/transition_region.c index 688d51c..bfe4a4e 100644 --- a/src/modules/core/transition_region.c +++ b/src/modules/core/transition_region.c @@ -67,8 +67,8 @@ static int create_instance( mlt_transition this, char *name, char *value, int co sprintf( key, "%s.", name ); // Just in case, let's assume that the filter here has a composite - mlt_properties_set( MLT_FILTER_PROPERTIES( filter ), "composite.start", "0%,0%:100%x100%" ); - mlt_properties_set( MLT_FILTER_PROPERTIES( filter ), "composite.fill", "true" ); + //mlt_properties_set( MLT_FILTER_PROPERTIES( filter ), "composite.geometry", "0%,0%:100%x100%" ); + //mlt_properties_set_int( MLT_FILTER_PROPERTIES( filter ), "composite.fill", 1 ); // Pass all the key properties on the filter down mlt_properties_pass( MLT_FILTER_PROPERTIES( filter ), properties, key ); @@ -106,7 +106,7 @@ static uint8_t *filter_get_alpha_mask( mlt_frame this ) mlt_image_format format = mlt_image_yuv422; // Get the shape image to trigger alpha creation - mlt_properties_set( MLT_FRAME_PROPERTIES( shape_frame ), "distort", "true" ); + mlt_properties_set_int( MLT_FRAME_PROPERTIES( shape_frame ), "distort", 1 ); mlt_frame_get_image( shape_frame, &image, &format, ®ion_width, ®ion_height, 0 ); alpha = mlt_frame_get_alpha_mask( shape_frame ); @@ -122,9 +122,14 @@ static uint8_t *filter_get_alpha_mask( mlt_frame this ) *p ++ = *image ++; image ++; } - mlt_properties_set_data( MLT_FRAME_PROPERTIES( shape_frame ), "alpha", alpha, - region_width * region_height, mlt_pool_release, NULL ); + mlt_properties_set_data( MLT_FRAME_PROPERTIES( this ), "alpha", alpha, region_width * region_height, mlt_pool_release, NULL ); } + else + { + mlt_properties_set_data( MLT_FRAME_PROPERTIES( this ), "alpha", alpha, region_width * region_height, NULL, NULL ); + } + + this->get_alpha_mask = NULL; return alpha; } @@ -171,8 +176,8 @@ static int transition_get_image( mlt_frame frame, uint8_t **image, mlt_image_for mlt_properties composite_properties = MLT_TRANSITION_PROPERTIES( composite ); // We want to ensure that we don't get a wobble... - mlt_properties_set( composite_properties, "distort", "true" ); - mlt_properties_set( composite_properties, "progressive", "1" ); + mlt_properties_set_int( composite_properties, "distort", 1 ); + mlt_properties_set_int( composite_properties, "progressive", 1 ); // Pass all the composite. properties on the transition down mlt_properties_pass( composite_properties, properties, "composite." ); diff --git a/src/modules/data_fx.properties b/src/modules/data_fx.properties index 49368ab..f7dc2e9 100644 --- a/src/modules/data_fx.properties +++ b/src/modules/data_fx.properties @@ -157,8 +157,8 @@ file_shot=region .filter[1]=watermark .filter[1].resource=pango: .filter[1].producer.markup=File Shot -.filter[1].producer.font=San 20 -.filter[1].composite.geometry=1%,1%:99%x99%:15;25=1%,1%:99%x99%:100 +.filter[1].producer.font=San 18 +.filter[1].composite.geometry=0%,0%:100%x100%:15;25=0%,0%:100%x100%:100 .filter[1].composite.titles=0 .filter[1].composite.halign=centre .filter[1].composite.valign=centre diff --git a/src/modules/feeds/PAL/data_fx.properties b/src/modules/feeds/PAL/data_fx.properties index 5554702..bd55aa2 100644 --- a/src/modules/feeds/PAL/data_fx.properties +++ b/src/modules/feeds/PAL/data_fx.properties @@ -158,8 +158,8 @@ file_shot=region .filter[1].resource=pango: .filter[1].producer.markup=File Shot .filter[1].producer.font=San 20 -.filter[1].composite.geometry=1%,1%:99%x99%:15;25=1%,1%:99%x99%:100 -.filter[1].composite.titles=0 +.filter[1].composite.geometry=0%,0%:100%x100%:15;25=0%,0%:100%x100%:100 +.filter[1].composite.titles=1 .filter[1].composite.halign=centre .filter[1].composite.valign=centre diff --git a/src/modules/plus/filter_affine.c b/src/modules/plus/filter_affine.c index 81fde67..a0d39a4 100644 --- a/src/modules/plus/filter_affine.c +++ b/src/modules/plus/filter_affine.c @@ -71,7 +71,7 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * mlt_properties_pass( MLT_TRANSITION_PROPERTIES( transition ), properties, "transition." ); mlt_service_get_frame( MLT_PRODUCER_SERVICE( producer ), &a_frame, 0 ); mlt_properties_set( MLT_FRAME_PROPERTIES( a_frame ), "rescale.interp", "nearest" ); - mlt_properties_set( MLT_FRAME_PROPERTIES( a_frame ), "distort", "true" ); + mlt_properties_set_int( MLT_FRAME_PROPERTIES( a_frame ), "distort", 1 ); mlt_properties_set_double( MLT_FRAME_PROPERTIES( a_frame ), "consumer_aspect_ratio", mlt_properties_get_double( frame_properties, "consumer_aspect_ratio" ) ); mlt_transition_process( transition, a_frame, this ); diff --git a/src/modules/plus/transition_affine.c b/src/modules/plus/transition_affine.c index 1cfb64b..806b140 100644 --- a/src/modules/plus/transition_affine.c +++ b/src/modules/plus/transition_affine.c @@ -540,7 +540,7 @@ static int transition_get_image( mlt_frame a_frame, uint8_t **image, mlt_image_f mlt_properties_set_double( b_props, "consumer_aspect_ratio", mlt_properties_get_double( a_props, "consumer_aspect_ratio" ) ); } - mlt_properties_set( b_props, "distort", mlt_properties_get( properties, "distort" ) ); + mlt_properties_set_int( b_props, "distort", mlt_properties_get_int( properties, "distort" ) ); mlt_frame_get_image( b_frame, &b_image, &b_format, &b_width, &b_height, 0 ); result.w = b_width; result.h = b_height; @@ -698,7 +698,7 @@ mlt_transition transition_affine_init( char *arg ) { mlt_properties_set_int( MLT_TRANSITION_PROPERTIES( transition ), "sx", 1 ); mlt_properties_set_int( MLT_TRANSITION_PROPERTIES( transition ), "sy", 1 ); - mlt_properties_set( MLT_TRANSITION_PROPERTIES( transition ), "distort", NULL ); + mlt_properties_set_int( MLT_TRANSITION_PROPERTIES( transition ), "distort", 0 ); mlt_properties_set( MLT_TRANSITION_PROPERTIES( transition ), "start", "0,0:100%x100%" ); transition->process = transition_process; } -- 1.7.4.4