Hi All,

I recently encountered a bug with image producers and affine transition.
Some corruption appears at the bottom of the composited image.

I tracked down the problem to the affine transition which in some cases 
tries to read pixels outside of the image.

The problem comes from line 575 in transition_affine.c, because we compare 
a float with an integer:

if ( dx >= 0 && dx < b_width && dy >=0 && dy < b_height )

Where dx and dy are floats representing the position inside the image,
and b_width, b_height are integer representing image dimensions.

Problem is that later in interp(), we use rounding of the dx and dy values, 
so for example if image width b_height is 600, and dy is 599.7, it will 
pass the test, but later be rounded to 600 and we read outside of image, 
because last line of the image is at 599.

Here are sample screenshot when trying to display a red square image 
against a black background using affine transition :

Before my patch (notice white line at bottom which is not in source image)
http://j-b-m.ch/images/corrupt.png

After my patch (image appears correctly)
http://j-b-m.ch/images/fixed.png


I can provide a full test case with MLT command line if needed. Patch is 
just below, comments welcome.

regards

Jean-Baptiste Mardelle




diff --git a/src/modules/plus/transition_affine.c 
b/src/modules/plus/transition_affine.c
index b5974a5..316d281 100644
--- a/src/modules/plus/transition_affine.c
+++ b/src/modules/plus/transition_affine.c
@@ -572,7 +572,7 @@ static int transition_get_image( mlt_frame a_frame, 
uint8_t **image, mlt_image_f
                        {
                                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 )
+                               if ( dx + 0.5 >= 0 && dx + 0.5 < b_width && 
dy + 0.5 >= 0 && dy + 0.5 < b_height )
                                        interp( b_image, b_width, b_height, 
dx, dy, result.mix/100.0, p, b_alpha );
                                p += 4;
                        }





------------------------------------------------------------------------------
_______________________________________________
Mlt-devel mailing list
Mlt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlt-devel

Reply via email to