From: Bill Spitzak <[email protected]>

This removes some confusion and at least one bug: the error on a 1-wide filter 
is now
added to the sample, rather than after the end of the filter.

Signed-off-by: Bill Spitzak <[email protected]>
---
 pixman/pixman-filter.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/pixman/pixman-filter.c b/pixman/pixman-filter.c
index 8dfb49b..36dd811 100644
--- a/pixman/pixman-filter.c
+++ b/pixman/pixman-filter.c
@@ -238,13 +238,11 @@ create_1d_filter (int              width,
                  int              n_phases,
                  pixman_fixed_t *p)
 {
-    double step;
+    double step = 1.0 / n_phases;
     double rwidth2 = filters[reconstruct].width / 2.0;
     double swidth2 = size * filters[sample].width / 2.0;
     int i;
 
-    step = 1.0 / n_phases;
-
     for (i = 0; i < n_phases; ++i)
     {
        double frac = step / 2.0 + i * step;
@@ -271,23 +269,23 @@ create_1d_filter (int              width,
                                 sample, 1.0 / size, pos,
                                 ilow, ihigh);
            total += c;
-           *p++ = (pixman_fixed_t)(c * 65536.0 + 0.5);
+           p[x] = (pixman_fixed_t)(c * 65536.0 + 0.5);
        }
 
        /* Normalize */
-       p -= width;
-        total = 1 / total;
-        new_total = 0;
+       total = 1 / total;
+       new_total = 0;
        for (x = 0; x < width; ++x)
        {
-           pixman_fixed_t t = (*p) * total + 0.5;
-
+           pixman_fixed_t t = p[x] * total + 0.5;
            new_total += t;
-           *p++ = t;
+           p[x] = t;
        }
 
        if (new_total != pixman_fixed_1)
-           *(p - width / 2) += (pixman_fixed_1 - new_total);
+           p[width / 2] += (pixman_fixed_1 - new_total);
+
+       p += width;
     }
 }
 
-- 
1.9.1

_______________________________________________
Pixman mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/pixman

Reply via email to