Fix rounding for DIV_UNc()
authorSøren Sandmann Pedersen <ssp@redhat.com>
Tue, 20 Dec 2011 11:32:26 +0000 (06:32 -0500)
committerSøren Sandmann Pedersen <ssp@redhat.com>
Mon, 9 Jan 2012 10:40:34 +0000 (05:40 -0500)
We need to compute floor (a/b * 255 + 0.5), not floor (a / b * 255),
so add b/2 to the numerator in the DIV_UNc() macro.

pixman/pixman-combine.h.template
test/blitters-test.c

index 53afcd2..20f784b 100644 (file)
@@ -28,7 +28,7 @@
     ((t) = (a) * (comp2_t)(b) + ONE_HALF, ((((t) >> G_SHIFT ) + (t) ) >> G_SHIFT ))
 
 #define DIV_UNc(a, b)                                                  \
-    (((comp2_t) (a) * MASK) / (b))
+    (((comp2_t) (a) * MASK + ((b) / 2)) / (b))
 
 #define ADD_UNc(x, y, t)                                    \
     ((t) = (x) + (y),                                       \
index fd62c67..feea308 100644 (file)
@@ -424,6 +424,6 @@ main (int argc, const char *argv[])
     }
 
     return fuzzer_test_main("blitters", 2000000,
-                           0x3EDA4108,
+                           0xA364B5BF,
                            test_composite, argc, argv);
 }