diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2012-04-05 00:52:21 -0400 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2012-04-20 10:17:13 -0400 |
commit | e24c1c849d29f43dc6e50e1f15102709059b40f8 (patch) | |
tree | dc79f51ee0fe3d76868cb82a8bfa9f4478fb1feb /pixman/pixman-bits-image.c | |
parent | 4d2fee14063b960c6b81b55dd3aa94b956d23eeb (diff) |
bits_image_fetch_pixel_convolution(): Make sure channels are signed
In the computation:
srtot += RED_8 (pixel) * f
RED_8 (pixel) is an unsigned quantity, which means the signed filter
coefficient f gets converted to an unsigned integer before the
multiplication. We get away with this because when the 32 bit unsigned
result is converted to int32_t, the correct sign is produced. But if
srtot had been an int64_t, the result would have been a very large
positive number.
Fix this by explicitly casting the channels to int.
Diffstat (limited to 'pixman/pixman-bits-image.c')
-rw-r--r-- | pixman/pixman-bits-image.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/pixman/pixman-bits-image.c b/pixman/pixman-bits-image.c index d105d2f..1f6897c 100644 --- a/pixman/pixman-bits-image.c +++ b/pixman/pixman-bits-image.c @@ -381,11 +381,11 @@ bits_image_fetch_pixel_convolution (bits_image_t *image, int y_off = (params[1] - pixman_fixed_1) >> 1; int32_t cwidth = pixman_fixed_to_int (params[0]); int32_t cheight = pixman_fixed_to_int (params[1]); - int32_t srtot, sgtot, sbtot, satot; int32_t i, j, x1, x2, y1, y2; pixman_repeat_t repeat_mode = image->common.repeat; int width = image->width; int height = image->height; + int srtot, sgtot, sbtot, satot; params += 2; @@ -421,10 +421,10 @@ bits_image_fetch_pixel_convolution (bits_image_t *image, pixel = get_pixel (image, rx, ry, TRUE); } - srtot += RED_8 (pixel) * f; - sgtot += GREEN_8 (pixel) * f; - sbtot += BLUE_8 (pixel) * f; - satot += ALPHA_8 (pixel) * f; + srtot += (int)RED_8 (pixel) * f; + sgtot += (int)GREEN_8 (pixel) * f; + sbtot += (int)BLUE_8 (pixel) * f; + satot += (int)ALPHA_8 (pixel) * f; } params++; |