]> git.sesse.net Git - mlt/commitdiff
filter_resize,c, filter_composite.c: bugfix redundant rounding.
authorddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
Sun, 1 Jun 2008 23:34:07 +0000 (23:34 +0000)
committerddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
Sun, 1 Jun 2008 23:34:07 +0000 (23:34 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@1132 d19143bc-622f-0410-bfdd-b5b2a6649095

src/modules/core/filter_resize.c
src/modules/core/transition_composite.c

index e7e7fbe2ec3c44c4ecc3de70ad5ad109a5a1cca9..68244bfc652426d95a0b3a99876e72528337428c 100644 (file)
@@ -89,22 +89,23 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
                double input_ar = aspect_ratio * real_width / real_height;
                double output_ar = mlt_properties_get_double( properties, "consumer_aspect_ratio" ) * owidth / oheight;
                
-               //fprintf( stderr, "normalised %dx%d output %dx%d %f %f\n", normalised_width, normalised_height, owidth, oheight, ( float )output_ar, ( float )mlt_properties_get_double( properties, "consumer_aspect_ratio" ) * owidth / oheight );
+//             fprintf( stderr, "real %dx%d normalised %dx%d output %dx%d sar %f in-dar %f out-dar %f\n",
+//             real_width, real_height, normalised_width, normalised_height, owidth, oheight, aspect_ratio, input_ar, output_ar);
 
                // Optimised for the input_ar > output_ar case (e.g. widescreen on standard)
-               int scaled_width = rint( 0.5 + ( input_ar * normalised_width ) / output_ar );
+               int scaled_width = rint( ( input_ar * normalised_width ) / output_ar );
                int scaled_height = normalised_height;
 
                // Now ensure that our images fit in the output frame
                if ( scaled_width > normalised_width )
                {
                        scaled_width = normalised_width;
-                       scaled_height = rint( 0.5 + ( output_ar * normalised_height ) / input_ar );
+                       scaled_height = rint( ( output_ar * normalised_height ) / input_ar );
                }
 
                // Now calculate the actual image size that we want
-               owidth = rint( 0.5 + scaled_width * owidth / normalised_width );
-               oheight = rint( 0.5 + scaled_height * oheight / normalised_height );
+               owidth = rint( scaled_width * owidth / normalised_width );
+               oheight = rint( scaled_height * oheight / normalised_height );
 
                // Tell frame we have conformed the aspect to the consumer
                mlt_frame_set_aspect_ratio( this, mlt_properties_get_double( properties, "consumer_aspect_ratio" ) );
index 9104073b9f52ce3092b3b3029c9112e01dc390b9..87d013e9b6ec86fd89956aebbe41daf99e821797 100644 (file)
@@ -459,8 +459,8 @@ static int composite_yuv( uint8_t *p_dest, int width_dest, int height_dest, uint
        int stride_dest = width_dest * bpp;
        
        // Adjust to consumer scale
-       int x = rint( 0.5 + geometry.item.x * width_dest / geometry.nw );
-       int y = rint( 0.5 + geometry.item.y * height_dest / geometry.nh );
+       int x = rint( geometry.item.x * width_dest / geometry.nw );
+       int y = rint( geometry.item.y * height_dest / geometry.nh );
        int uneven_x = ( x % 2 );
 
        // optimization points - no work to do
@@ -729,18 +729,21 @@ static int get_b_frame_image( mlt_transition this, mlt_frame b_frame, uint8_t **
                double consumer_ar = mlt_properties_get_double( b_props, "consumer_aspect_ratio" );
                double background_ar = mlt_properties_get_double( b_props, "output_ratio" );
                double output_ar = background_ar != 0.0 ? background_ar : consumer_ar;
-               int scaled_width = rint( 0.5 + ( input_ar == 0.0 ? output_ar : input_ar ) / output_ar * real_width );
+               int scaled_width = rint( ( input_ar == 0.0 ? output_ar : input_ar ) / output_ar * real_width );
                int scaled_height = real_height;
+// fprintf(stderr, "%s: scaled %dx%d norm %dx%d real %dx%d output_ar %f => %f\n", __FILE__,
+// scaled_width, scaled_height, normalised_width, normalised_height, real_width, real_height,
+// background_ar, output_ar);
 
                // Now ensure that our images fit in the normalised frame
                if ( scaled_width > normalised_width )
                {
-                       scaled_height = rint( 0.5 + scaled_height * normalised_width / scaled_width );
+                       scaled_height = rint( scaled_height * normalised_width / scaled_width );
                        scaled_width = normalised_width;
                }
                if ( scaled_height > normalised_height )
                {
-                       scaled_width = rint( 0.5 + scaled_width * normalised_height / scaled_height );
+                       scaled_width = rint( scaled_width * normalised_height / scaled_height );
                        scaled_height = normalised_height;
                }
 
@@ -750,12 +753,12 @@ static int get_b_frame_image( mlt_transition this, mlt_frame b_frame, uint8_t **
                {
                        if ( scaled_height < normalised_height && scaled_width * normalised_height / scaled_height <= normalised_width )
                        {
-                               scaled_width = rint( 0.5 + scaled_width * normalised_height / scaled_height );
+                               scaled_width = rint( scaled_width * normalised_height / scaled_height );
                                scaled_height = normalised_height;
                        }
                        else if ( scaled_width < normalised_width && scaled_height * normalised_width / scaled_width < normalised_height )
                        {
-                               scaled_height = rint( 0.5 + scaled_height * normalised_width / scaled_width );
+                               scaled_height = rint( scaled_height * normalised_width / scaled_width );
                                scaled_width = normalised_width;
                        }
                }
@@ -783,8 +786,10 @@ static int get_b_frame_image( mlt_transition this, mlt_frame b_frame, uint8_t **
                alignment_calculate( geometry );
 
        // Adjust to consumer scale
-       *width = rint( 0.5 + geometry->sw * *width / geometry->nw );
-       *height = rint( 0.5 + geometry->sh * *height / geometry->nh );
+       *width = rint( geometry->sw * *width / geometry->nw );
+       *height = rint( geometry->sh * *height / geometry->nh );
+// fprintf(stderr, "%s: scaled %dx%d norm %dx%d resize %dx%d\n", __FILE__,
+// geometry->sw, geometry->sh, geometry->nw, geometry->nh, *width, *height);
 
        ret = mlt_frame_get_image( b_frame, image, &format, width, height, 1 );
 
@@ -901,10 +906,10 @@ mlt_frame composite_copy_region( mlt_transition this, mlt_frame a_frame, mlt_pos
        composite_calculate( this, &result, a_frame, position );
 
        // Need to scale down to actual dimensions
-       x = rint( 0.5 + result.item.x * width / result.nw );
-       y = rint( 0.5 + result.item.y * height / result.nh );
-       w = rint( 0.5 + result.item.w * width / result.nw );
-       h = rint( 0.5 + result.item.h * height / result.nh );
+       x = rint( result.item.x * width / result.nw );
+       y = rint( result.item.y * height / result.nh );
+       w = rint( result.item.w * width / result.nw );
+       h = rint( result.item.h * height / result.nh );
 
        if ( x % 2 )
        {
@@ -1138,9 +1143,9 @@ static int transition_get_image( mlt_frame a_frame, uint8_t **image, mlt_image_f
 
                                if ( mlt_properties_get_int( properties, "titles" ) )
                                {
-                                       result.item.w = rint( 0.5 + *width * ( result.item.w / result.nw ) );
+                                       result.item.w = rint( *width * ( result.item.w / result.nw ) );
                                        result.nw = result.item.w;
-                                       result.item.h = rint( 0.5 + *height * ( result.item.h / result.nh ) );
+                                       result.item.h = rint( *height * ( result.item.h / result.nh ) );
                                        result.nh = *height;
                                        result.sw = width_b;
                                        result.sh = height_b;