minor mods
[melted] / src / modules / core / transition_composite.c
index 1af94df..88c1222 100644 (file)
@@ -40,6 +40,7 @@ typedef void ( *composite_line_fn )( uint8_t *dest, uint8_t *src, int width_src,
 
 struct geometry_s
 {
+       int frame;
        float position;
        float mix;
        int nw; // normalised width
@@ -154,14 +155,28 @@ static void geometry_calculate( struct geometry_s *output, struct geometry_s *in
        position = ( position - in->position ) / ( out->position - in->position );
 
        // Calculate this frames geometry
-       output->nw = in->nw;
-       output->nh = in->nh;
-       output->x = in->x + ( out->x - in->x ) * position;
-       output->y = in->y + ( out->y - in->y ) * position;
-       output->w = in->w + ( out->w - in->w ) * position;
-       output->h = in->h + ( out->h - in->h ) * position;
-       output->mix = in->mix + ( out->mix - in->mix ) * position;
-       output->distort = in->distort;
+       if ( in->frame != out->frame - 1 )
+       {
+               output->nw = in->nw;
+               output->nh = in->nh;
+               output->x = in->x + ( out->x - in->x ) * position;
+               output->y = in->y + ( out->y - in->y ) * position;
+               output->w = in->w + ( out->w - in->w ) * position;
+               output->h = in->h + ( out->h - in->h ) * position;
+               output->mix = in->mix + ( out->mix - in->mix ) * position;
+               output->distort = in->distort;
+       }
+       else
+       {
+               output->nw = out->nw;
+               output->nh = out->nh;
+               output->x = out->x;
+               output->y = out->y;
+               output->w = out->w;
+               output->h = out->h;
+               output->mix = out->mix;
+               output->distort = out->distort;
+       }
 
        // DRD> These break on negative values. I do not think they are needed
        // since yuv_composite takes care of YUYV group alignment
@@ -239,7 +254,8 @@ static struct geometry_s *transition_parse_keys( mlt_transition this,  int norma
                                // Parse and add to the list
                                geometry_parse( temp, ptr, value, normalised_width, normalised_height );
 
-                               // Assign the position
+                               // Assign the position and frame
+                               temp->frame = frame;
                                temp->position = position;
 
                                // Allow the next to be appended after this one
@@ -606,20 +622,34 @@ static int composite_yuv( uint8_t *p_dest, int width_dest, int height_dest, uint
        stride_dest *= step;
        int alpha_stride = stride_src / bpp;
 
-       if ( line_fn == NULL )
-               line_fn = composite_line_yuv;
-
        // now do the compositing only to cropped extents
-       for ( i = 0; i < height_src; i += step )
+       if ( line_fn != NULL )
        {
-               line_fn( p_dest, p_src, width_src, p_alpha, weight, p_luma, softness );
-
-               p_src += stride_src;
-               p_dest += stride_dest;
-               if ( p_alpha )
-                       p_alpha += alpha_stride;
-               if ( p_luma )
-                       p_luma += alpha_stride;
+               for ( i = 0; i < height_src; i += step )
+               {
+                       line_fn( p_dest, p_src, width_src, p_alpha, weight, p_luma, softness );
+       
+                       p_src += stride_src;
+                       p_dest += stride_dest;
+                       if ( p_alpha )
+                               p_alpha += alpha_stride;
+                       if ( p_luma )
+                               p_luma += alpha_stride;
+               }
+       }
+       else
+       {
+               for ( i = 0; i < height_src; i += step )
+               {
+                       composite_line_yuv( p_dest, p_src, width_src, p_alpha, weight, p_luma, softness );
+       
+                       p_src += stride_src;
+                       p_dest += stride_dest;
+                       if ( p_alpha )
+                               p_alpha += alpha_stride;
+                       if ( p_luma )
+                               p_luma += alpha_stride;
+               }
        }
 
        return ret;
@@ -1003,7 +1033,7 @@ static int transition_get_image( mlt_frame a_frame, uint8_t **image, mlt_image_f
                        
                        int32_t luma_softness = mlt_properties_get_double( properties, "softness" ) * ( 1 << 16 );
                        uint16_t *luma_bitmap = get_luma( properties, width_b, height_b );
-                       composite_line_fn line_fn = mlt_properties_get_int( properties, "_MMX" ) ? composite_line_yuv_mmx : composite_line_yuv;
+                       composite_line_fn line_fn = mlt_properties_get_int( properties, "_MMX" ) ? composite_line_yuv_mmx : NULL;
 
                        for ( field = 0; field < ( progressive ? 1 : 2 ); field++ )
                        {