diff options
author | Bill Spitzak <spitzak@gmail.com> | 2016-03-06 17:06:51 -0800 |
---|---|---|
committer | Søren Sandmann Pedersen <soren.sandmann@gmail.com> | 2016-03-11 00:00:46 -0500 |
commit | 7bea37b00537d5982a7f5dcf68a9750feb377bb1 (patch) | |
tree | e7f2c4653cf11dee079e2cfa7c4506706aeed7b2 | |
parent | f281960eb303225d652171dda63f7f6698a61602 (diff) |
pixman-filter: distribute normalization error over filter
This removes a high-frequency spike in the middle of some filters that is
caused by math errors all being in the same direction.
Signed-off-by: Bill Spitzak <spitzak@gmail.com>
-rw-r--r-- | pixman/pixman-filter.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/pixman/pixman-filter.c b/pixman/pixman-filter.c index 36dd8113..ab62e0af 100644 --- a/pixman/pixman-filter.c +++ b/pixman/pixman-filter.c @@ -282,8 +282,18 @@ create_1d_filter (int width, p[x] = t; } + /* Distribute any remaining error over all samples */ if (new_total != pixman_fixed_1) - p[width / 2] += (pixman_fixed_1 - new_total); + { + pixman_fixed_t delta = new_total - pixman_fixed_1; + pixman_fixed_t t = 0; + for (x = 0; x < width; ++x) + { + pixman_fixed_t new_t = delta * (x + 1) / width; + p[x] += new_t - t; + t = new_t; + } + } p += width; } |