{
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->x = rint( in->x + ( out->x - in->x ) * position + 0.5 );
+ output->y = rint( in->y + ( out->y - in->y ) * position + 0.5 );
+ output->w = rint( in->w + ( out->w - in->w ) * position + 0.5 );
+ output->h = rint( in->h + ( out->h - in->h ) * position + 0.5 );
output->mix = in->mix + ( out->mix - in->mix ) * position;
output->distort = in->distort;
}
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
- //output->x = ( int )floor( output->x ) & 0xfffffffe;
- //output->w = ( int )floor( output->w ) & 0xfffffffe;
- //output->sw &= 0xfffffffe;
}
-void transition_destroy_keys( void *arg )
+static void transition_destroy_keys( void *arg )
{
struct geometry_s *ptr = arg;
struct geometry_s *next = NULL;
else
end->position = 1;
- // Assign to properties to ensure we get destroyed
- mlt_properties_set_data( properties, "geometries", start, 0, transition_destroy_keys, NULL );
-
return start;
}
// Adjust to consumer scale
int x = geometry.x * width_dest / geometry.nw;
int y = geometry.y * height_dest / geometry.nh;
-
- // Align x to a full YUYV group
- x &= 0xfffffffe;
- width_src &= 0xfffffffe;
+ int uneven = ( x & 1 );
// optimization points - no work to do
if ( width_src <= 0 || height_src <= 0 )
{
y_src = -y;
height_src -= y_src;
+ y = 0;
}
// crop overlay below bottom edge of frame
stride_dest *= step;
int alpha_stride = stride_src / bpp;
- if ( line_fn == NULL )
- line_fn = composite_line_yuv;
+ if ( uneven )
+ p_src -= 2;
// 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;
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;
*width = geometry->sw * *width / geometry->nw;
*height = geometry->sh * *height / geometry->nh;
- x &= 0xfffffffe;
+ //x = ( x | 1 ) ^ 1;
// optimization points - no work to do
if ( *width < 1 || *height < 1 )
}
-struct geometry_s *composite_calculate( struct geometry_s *result, mlt_transition this, mlt_frame a_frame, float position )
+static struct geometry_s *composite_calculate( struct geometry_s *result, mlt_transition this, mlt_frame a_frame, float position )
{
// Get the properties from the transition
mlt_properties properties = mlt_transition_properties( this );
// Structures for geometry
struct geometry_s *start = mlt_properties_get_data( properties, "geometries", NULL );
+ // Obtain the normalised width and height from the a_frame
+ int normalised_width = mlt_properties_get_int( a_props, "normalised_width" );
+ int normalised_height = mlt_properties_get_int( a_props, "normalised_height" );
+
// Now parse the geometries
- if ( start == NULL )
+ if ( start == NULL || mlt_properties_get_int( properties, "refresh" ) || start->nw != normalised_width || start->nh != normalised_height )
{
- // Obtain the normalised width and height from the a_frame
- int normalised_width = mlt_properties_get_int( a_props, "normalised_width" );
- int normalised_height = mlt_properties_get_int( a_props, "normalised_height" );
-
// Parse the transitions properties
start = transition_parse_keys( this, normalised_width, normalised_height );
+
+ // Assign to properties to ensure we get destroyed
+ mlt_properties_set_data( properties, "geometries", start, 0, transition_destroy_keys, NULL );
+ mlt_properties_set_int( properties, "refresh", 0 );
}
// Do the calculation
return start;
}
+static inline void inline_memcpy( uint8_t *dest, uint8_t *src, int length )
+{
+ uint8_t *end = src + length;
+ while ( src < end )
+ {
+ *dest ++ = *src ++;
+ *dest ++ = *src ++;
+ }
+}
+
mlt_frame composite_copy_region( mlt_transition this, mlt_frame a_frame, mlt_position frame_position )
{
// Create a frame to return
w = result.w * width / result.nw;
h = result.h * height / result.nh;
- x &= 0xfffffffe;
- //w &= 0xfffffffe;
+ if ( y < 0 )
+ {
+ h = h + y;
+ y = 0;
+ }
+
+ if ( y + h > height )
+ h = height - y;
+
+ x = ( x | 1 ) ^ 1;
+ w = ( w | 1 ) ^ 1;
// Now we need to create a new destination image
dest = mlt_pool_alloc( w * h * 2 );
while ( q < r )
{
- memcpy( q, p, w * 2 );
+ inline_memcpy( q, p, w * 2 );
q += w * 2;
p += width * 2;
}
// 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;
// Get the image from the a frame
mlt_frame_get_image( a_frame, image, format, width, height, 1 );
+ // Get the properties from the transition
+ mlt_properties properties = mlt_transition_properties( this );
+
if ( b_frame != NULL )
{
// Get the properties of the a frame
// Get the properties of the b frame
mlt_properties b_props = mlt_frame_properties( b_frame );
- // Get the properties from the transition
- mlt_properties properties = mlt_transition_properties( this );
-
// Structures for geometry
struct geometry_s result;
// 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" ) );
+ mlt_properties_set_int( b_props, "normalised_width", mlt_properties_get_double( a_props, "normalised_width" ) );
+ mlt_properties_set_int( b_props, "normalised_height", mlt_properties_get_double( a_props, "normalised_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" );
+ }
- // Get the image from the b frame
- uint8_t *image_b = NULL;
- int width_b = *width;
- int height_b = *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;
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;
+ composite_line_fn line_fn = NULL;
for ( field = 0; field < ( progressive ? 1 : 2 ); field++ )
{