}
// Shear by a given value
-static void affine_shear( float this[3][3], float shear_x, float shear_y )
+static void affine_shear( float this[3][3], float shear_x, float shear_y, float shear_z )
{
float affine[3][3];
affine[0][0] = 1;
affine[0][2] = 0;
affine[1][0] = tan( shear_y * M_PI / 180 );
affine[1][1] = 1;
- affine[1][2] = 0;
+ affine[1][2] = tan( shear_z * M_PI / 180 );
affine[2][0] = 0;
affine[2][1] = 0;
affine[2][2] = 1;
}
// Obtain the mapped x coordinate of the input
-static inline int MapX( float this[3][3], int x, int y )
+static inline double MapX( float this[3][3], int x, int y )
{
return this[0][0] * x + this[0][1] * y + this[0][2];
}
// Obtain the mapped y coordinate of the input
-static inline int MapY( float this[3][3], int x, int y )
+static inline double MapY( float this[3][3], int x, int y )
{
return this[1][0] * x + this[1][1] * y + this[1][2];
}
-static inline float MapZ( float this[3][3], int x, int y )
+static inline double MapZ( float this[3][3], int x, int y )
{
return this[2][0] * x + this[2][1] * y + this[2][2];
}
mlt_frame_get_image( a_frame, image, format, width, height, 1 );
// Calculate the region now
- composite_calculate( &result, this, a_frame, ( float )position / ( out - in + 1 ) );
+ composite_calculate( &result, this, a_frame, ( float )( position ) / ( out - in + 1 ) );
// Fetch the b frame image
result.w = ( int )( result.w * *width / result.nw );
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_frame_get_image( b_frame, &b_image, &b_format, &b_width, &b_height, 0 );
result.w = b_width;
result.h = b_height;
{
register int x, y;
register int dx, dy;
+ double dz;
float sw, sh;
// Get values from the transition
- float rotate_x = mlt_properties_get_double( properties, "rotate" );
+ float fix_rotate_x = mlt_properties_get_double( properties, "fix_rotate_x" );
+ float fix_rotate_y = mlt_properties_get_double( properties, "fix_rotate_y" );
+ float fix_rotate_z = mlt_properties_get_double( properties, "fix_rotate_z" );
+ float rotate_x = mlt_properties_get_double( properties, "rotate_x" );
float rotate_y = mlt_properties_get_double( properties, "rotate_y" );
float rotate_z = mlt_properties_get_double( properties, "rotate_z" );
float fix_shear_x = mlt_properties_get_double( properties, "fix_shear_x" );
float fix_shear_y = mlt_properties_get_double( properties, "fix_shear_y" );
+ float fix_shear_z = mlt_properties_get_double( properties, "fix_shear_z" );
float shear_x = mlt_properties_get_double( properties, "shear_x" );
float shear_y = mlt_properties_get_double( properties, "shear_y" );
+ float shear_z = mlt_properties_get_double( properties, "shear_z" );
float ox = mlt_properties_get_double( properties, "ox" );
float oy = mlt_properties_get_double( properties, "oy" );
int scale = mlt_properties_get_int( properties, "scale" );
int x_offset = ( int )result.w >> 1;
int y_offset = ( int )result.h >> 1;
+ uint8_t *alpha = mlt_frame_get_alpha_mask( b_frame );
+ uint8_t *mask = mlt_pool_alloc( b_width * b_height );
+ uint8_t *pmask = mask;
+ float mix;
+
affine_t affine;
affine_init( affine.matrix );
- affine_rotate( affine.matrix, rotate_x * ( position - in ) );
- affine_rotate_y( affine.matrix, rotate_y * ( position - in ) );
- affine_rotate_z( affine.matrix, rotate_z * ( position - in ) );
- affine_shear( affine.matrix, fix_shear_x + shear_x * ( position - in ), fix_shear_y + shear_y * ( position - in ) );
+ affine_rotate( affine.matrix, fix_rotate_x + rotate_x * ( position - in ) );
+ affine_rotate_y( affine.matrix, fix_rotate_y + rotate_y * ( position - in ) );
+ affine_rotate_z( affine.matrix, fix_rotate_z + rotate_z * ( position - in ) );
+ affine_shear( affine.matrix,
+ fix_shear_x + shear_x * ( position - in ),
+ fix_shear_y + shear_y * ( position - in ),
+ fix_shear_z + shear_z * ( position - in ) );
affine_offset( affine.matrix, ox, oy );
- affine_max_output( affine.matrix, &sw, &sh );
-
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 );
q = *image;
+ dz = MapZ( affine.matrix, 0, 0 );
+
+ if ( mask != NULL )
+ memset( mask, 0, b_width * b_height );
+
for ( y = lower_y; y < upper_y; y ++ )
{
p = q;
for ( x = lower_x; x < upper_x; x ++ )
{
- dx = MapX( affine.matrix, x, y ) + x_offset;
- dy = MapY( affine.matrix, x, y ) + y_offset;
+ dx = MapX( affine.matrix, x, y ) / dz + x_offset;
+ dy = MapY( affine.matrix, x, y ) / dz + y_offset;
if ( dx >= 0 && dx < b_width && dy >=0 && dy < b_height )
{
- dx -= dx & 1;
- *p ++ = *( b_image + dy * b_stride + ( dx << 1 ) );
- *p ++ = *( b_image + dy * b_stride + ( dx << 1 ) + ( ( x & 1 ) << 1 ) + 1 );
+ if ( alpha == NULL )
+ {
+ *pmask ++ = 255;
+ dx += dx & 1;
+ *p ++ = *( b_image + dy * b_stride + ( dx << 1 ) );
+ *p ++ = *( b_image + dy * b_stride + ( dx << 1 ) + ( ( x & 1 ) << 1 ) + 1 );
+ }
+ else
+ {
+ *pmask ++ = *( alpha + dy * b_width + dx );
+ mix = ( float )*( alpha + dy * b_width + dx ) / 255.0;
+ dx += dx & 1;
+ *p = *p * ( 1 - mix ) + mix * *( b_image + dy * b_stride + ( dx << 1 ) );
+ p ++;
+ *p = *p * ( 1 - mix ) + mix * *( b_image + dy * b_stride + ( dx << 1 ) + ( ( x & 1 ) << 1 ) + 1 );
+ p ++;
+ }
}
else
{
p += 2;
+ pmask ++;
}
}
q += a_stride;
}
+
+ b_frame->get_alpha_mask = NULL;
+ mlt_properties_set_data( b_props, "alpha", mask, 0, mlt_pool_release, NULL );
}
return 0;
// Push the transition method
mlt_frame_push_get_image( a_frame, transition_get_image );
-
return a_frame;
}
{
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( mlt_transition_properties( transition ), "start", "0,0:100%x100%" );
transition->process = transition_process;
}