affine silliness
[melted] / src / modules / plus / transition_affine.c
index 1cfb64b..42c03a2 100644 (file)
@@ -426,16 +426,16 @@ static inline double MapZ( float this[3][3], int x, int y )
 #define MAX( x, y ) x > y ? x : y
 #define MIN( x, y ) x < y ? x : y
 
-static void affine_max_output( float this[3][3], float *w, float *h )
+static void affine_max_output( float this[3][3], float *w, float *h, float dz )
 {
-       int tlx = MapX( this, -720, 576 );
-       int tly = MapY( this, -720, 576 );
-       int trx = MapX( this, 720, 576 );
-       int try = MapY( this, 720, 576 );
-       int blx = MapX( this, -720, -576 );
-       int bly = MapY( this, -720, -576 );
-       int brx = MapX( this, 720, -576 );
-       int bry = MapY( this, 720, -576 );
+       int tlx = MapX( this, -720, 576 ) / dz;
+       int tly = MapY( this, -720, 576 ) / dz;
+       int trx = MapX( this, 720, 576 ) / dz;
+       int try = MapY( this, 720, 576 ) / dz;
+       int blx = MapX( this, -720, -576 ) / dz;
+       int bly = MapY( this, -720, -576 ) / dz;
+       int brx = MapX( this, 720, -576 ) / dz;
+       int bry = MapY( this, 720, -576 ) / dz;
 
        int max_x;
        int max_y;
@@ -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;
@@ -602,12 +602,6 @@ static int transition_get_image( mlt_frame a_frame, uint8_t **image, mlt_image_f
                                          fix_shear_z + shear_z * ( position - in ) );
                affine_offset( affine.matrix, ox, oy );
 
-               if ( scale )
-               {
-                       affine_max_output( affine.matrix, &sw, &sh );
-                       affine_scale( affine.matrix, sw, sh );
-               }
-       
                lower_x -= ( lower_x & 1 );
                upper_x -= ( upper_x & 1 );
 
@@ -618,6 +612,15 @@ static int transition_get_image( mlt_frame a_frame, uint8_t **image, mlt_image_f
                if ( mask != NULL )
                        memset( mask, 0, b_width * b_height );
 
+               if ( ( int )abs( dz * 1000 ) < 25 )
+                       goto getout;
+
+               if ( scale )
+               {
+                       affine_max_output( affine.matrix, &sw, &sh, dz );
+                       affine_scale( affine.matrix, sw, sh );
+               }
+
                for ( y = lower_y; y < upper_y; y ++ )
                {
                        p = q;
@@ -657,6 +660,7 @@ static int transition_get_image( mlt_frame a_frame, uint8_t **image, mlt_image_f
                        q += a_stride;
                }
 
+getout:
                b_frame->get_alpha_mask = NULL;
                mlt_properties_set_data( b_props, "alpha", mask, 0, mlt_pool_release, NULL );
        }
@@ -698,8 +702,10 @@ 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%" );
+               // Inform apps and framework that this is a video only transition
+               mlt_properties_set_int( MLT_TRANSITION_PROPERTIES( transition ), "_transition_type", 1 );
                transition->process = transition_process;
        }
        return transition;