Some fixes for alpha masks
[melted] / src / modules / core / transition_composite.c
index de2c464..88d6b57 100644 (file)
@@ -296,7 +296,7 @@ static int alignment_parse( char* align )
 static void alignment_calculate( struct geometry_s *geometry )
 {
        geometry->x += ( geometry->w - geometry->sw ) * geometry->halign / 2;
-       geometry->y += ( geometry->h - geometry->sh ) * geometry->valign;
+       geometry->y += ( geometry->h - geometry->sh ) * geometry->valign / 2;
 }
 
 /** Calculate the position for this frame.
@@ -786,7 +786,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 && geometry->distort == 0 )
+       if ( mlt_properties_get( properties, "distort" ) == NULL && mlt_properties_get( b_props, "distort" ) == NULL && geometry->distort == 0 )
        {
                // Adjust b_frame pixel aspect
                int normalised_width = geometry->w;
@@ -980,6 +980,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" );
 
        // Return the frame
        return b_frame;
@@ -1022,27 +1023,52 @@ static int transition_get_image( mlt_frame a_frame, uint8_t **image, mlt_image_f
 
                // Do the calculation
                struct geometry_s *start = composite_calculate( &result, this, a_frame, position );
-               
+
+               // Get the image from the b frame
+               uint8_t *image_b = NULL;
+               int width_b = *width;
+               int height_b = *height;
+       
                // Optimisation - no compositing required
                if ( result.mix == 0 || ( result.w == 0 && result.h == 0 ) )
                        return 0;
 
+               // Need to keep the width/height of the a_frame on the b_frame for titling
+               if ( mlt_properties_get( a_props, "dest_width" ) == NULL )
+               {
+                       mlt_properties_set_int( a_props, "dest_width", *width );
+                       mlt_properties_set_int( a_props, "dest_height", *height );
+                       mlt_properties_set_int( b_props, "dest_width", *width );
+                       mlt_properties_set_int( b_props, "dest_height", *height );
+               }
+               else
+               {
+                       mlt_properties_set_int( b_props, "dest_width", mlt_properties_get_int( a_props, "dest_width" ) );
+                       mlt_properties_set_int( b_props, "dest_height", mlt_properties_get_int( a_props, "dest_height" ) );
+               }
+
                // Since we are the consumer of the b_frame, we must pass along these
                // consumer properties from the a_frame
+               mlt_properties_set_double( b_props, "consumer_deinterlace", mlt_properties_get_double( a_props, "consumer_deinterlace" ) );
                mlt_properties_set_double( b_props, "consumer_aspect_ratio", mlt_properties_get_double( a_props, "consumer_aspect_ratio" ) );
 
-               // Get the image from the b frame
-               uint8_t *image_b = NULL;
-               int width_b = *width;
-               int height_b = *height;
-               
+               // Special case for titling...
+               if ( mlt_properties_get_int( properties, "titles" ) )
+               {
+                       if ( mlt_properties_get( b_props, "rescale.interp" ) == NULL )
+                               mlt_properties_set( b_props, "rescale.interp", "nearest" );
+                       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" );
+               }
+
                if ( get_b_frame_image( this, b_frame, &image_b, &width_b, &height_b, &result ) == 0 )
                {
                        uint8_t *dest = *image;
                        uint8_t *src = image_b;
                        uint8_t *alpha = mlt_frame_get_alpha_mask( b_frame );
                        int progressive = 
-                                       mlt_properties_get_int( a_props, "consumer_progressive" ) ||
+                                       mlt_properties_get_int( a_props, "consumer_deinterlace" ) ||
                                        mlt_properties_get_int( properties, "progressive" );
                        int field;