]> git.sesse.net Git - mlt/blobdiff - src/modules/core/transition_composite.c
Sundry minor updates
[mlt] / src / modules / core / transition_composite.c
index 6cc1055b85b297f558b52a5dc9310cdff7a9e161..ed2436fa50ee5a062e537048f38d19ecfaa346d0 100644 (file)
@@ -103,12 +103,17 @@ static mlt_geometry transition_parse_keys( mlt_transition this, int normalised_w
        // Get the in and out position
        mlt_position in = mlt_transition_get_in( this );
        mlt_position out = mlt_transition_get_out( this );
+       int length = out - in + 1;
 
        // Get the new style geometry string
        char *property = mlt_properties_get( properties, "geometry" );
 
+       // Allow a geometry repeat cycle
+       if ( mlt_properties_get_int( properties, "cycle" ) )
+               length = mlt_properties_get_int( properties, "cycle" );
+
        // Parse the geometry if we have one
-       mlt_geometry_parse( geometry, property, out - in + 1, normalised_width, normalised_height );
+       mlt_geometry_parse( geometry, property, length, normalised_width, normalised_height );
 
        // Check if we're using the old style geometry
        if ( property == NULL )
@@ -458,7 +463,6 @@ static int composite_yuv( uint8_t *p_dest, int width_dest, int height_dest, uint
        // field 1 = upper field and y should be even.
        if ( ( field > -1 ) && ( y % 2 == field ) )
        {
-               //fprintf( stderr, "field %d y %d\n", field, y );
                if ( ( field == 1 && y < height_dest - 1 ) || ( field == 0 && y == 0 ) )
                        p_dest += stride_dest;
                else
@@ -556,7 +560,7 @@ static uint16_t* get_luma( mlt_properties properties, int width, int height )
 
        char temp[ 512 ];
 
-       if ( strchr( resource, '%' ) )
+       if ( resource != NULL && strchr( resource, '%' ) )
        {
                sprintf( temp, "%s/lumas/%s/%s", mlt_factory_prefix( ), mlt_environment( "MLT_NORMALISATION" ), strchr( resource, '%' ) + 1 );
                resource = temp;
@@ -665,7 +669,7 @@ static int get_b_frame_image( mlt_transition this, mlt_frame b_frame, uint8_t **
        mlt_properties b_props = MLT_FRAME_PROPERTIES( b_frame );
        mlt_properties properties = MLT_TRANSITION_PROPERTIES( this );
 
-       if ( mlt_properties_get( properties, "distort" ) == NULL && mlt_properties_get( b_props, "distort" ) == NULL && geometry->item.distort == 0 )
+       if ( mlt_properties_get_int( properties, "distort" ) == 0 && mlt_properties_get_int( b_props, "distort" ) == 0 && geometry->item.distort == 0 )
        {
                // Adjust b_frame pixel aspect
                int normalised_width = geometry->item.w;
@@ -689,12 +693,20 @@ 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 )
+               // Honour the fill request - this will scale the image to fill width or height while maintaining a/r
+               // ????: Shouln't this be the default behaviour?
+               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 +720,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" ) )
@@ -762,6 +774,8 @@ static mlt_geometry composite_calculate( mlt_transition this, struct geometry_s
        else
        {
                int length = mlt_transition_get_out( this ) - mlt_transition_get_in( this ) + 1;
+               if ( mlt_properties_get_int( properties, "cycle" ) )
+                       length = mlt_properties_get_int( properties, "cycle" );
                mlt_geometry_refresh( start, mlt_properties_get( properties, "geometry" ), length, normalised_width, normalised_height );
        }
 
@@ -878,19 +892,22 @@ mlt_frame composite_copy_region( mlt_transition this, mlt_frame a_frame, mlt_pos
                x = 0;
        }
 
-       // Copy the region of the image
-       p = image + y * ss + x * 2;
-
-       while ( h -- )
+       if ( w > 0 && h > 0 )
        {
-               inline_memcpy( dest, p, w * 2 );
-               dest += ds;
-               p += ss;
+               // Copy the region of the image
+               p = image + y * ss + x * 2;
+
+               while ( h -- )
+               {
+                       inline_memcpy( dest, p, w * 2 );
+                       dest += ds;
+                       p += ss;
+               }
        }
 
        // 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;
@@ -969,7 +986,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" );
                }