From a075a870fd7e1fa70ae176d5089c695011667388 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=B8ren=20Sandmann=20Pedersen?= Date: Thu, 6 Aug 2009 22:42:25 -0400 Subject: [PATCH] Make pix_add_mul() in pixman-mmx.c produce exact results. Previously this routine would compute (x * a + y * b) / 255. Now it computes (x * a) / 255 + (y * b) / 255, so that the results are bitwise equivalent to the non-mmx versions. --- pixman/pixman-mmx.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/pixman/pixman-mmx.c b/pixman/pixman-mmx.c index 60b2b11..de672e6 100644 --- a/pixman/pixman-mmx.c +++ b/pixman/pixman-mmx.c @@ -400,25 +400,18 @@ pack_565 (__m64 pixel, __m64 target, int pos) static force_inline __m64 pix_add_mul (__m64 x, __m64 a, __m64 y, __m64 b) { - x = _mm_mullo_pi16 (x, a); - y = _mm_mullo_pi16 (y, b); - x = _mm_adds_pu16 (x, MC (4x0080)); - x = _mm_adds_pu16 (x, y); - x = _mm_adds_pu16 (x, _mm_srli_pi16 (x, 8)); - x = _mm_srli_pi16 (x, 8); + x = pix_multiply (x, a); + y = pix_multiply (y, b); - return x; + return pix_add (x, y); } #else #define pix_add_mul(x, a, y, b) \ - ( x = _mm_mullo_pi16 (x, a), \ - y = _mm_mullo_pi16 (y, b), \ - x = _mm_adds_pu16 (x, MC (4x0080)), \ - x = _mm_adds_pu16 (x, y), \ - x = _mm_adds_pu16 (x, _mm_srli_pi16 (x, 8)), \ - _mm_srli_pi16 (x, 8) ) + ( x = pix_multiply (x, a), \ + y = pix_multiply (y, a), \ + pix_add (x, y) ) #endif -- 2.7.4