diff --git a/pipi/filter/convolution_template.h b/pipi/filter/convolution_template.h index 976fd9b..595d1e7 100644 --- a/pipi/filter/convolution_template.h +++ b/pipi/filter/convolution_template.h @@ -57,13 +57,13 @@ static pipi_image_t *FUNC1(pipi_image_t *src, int m, int n, double mat[]) for(j = 0; j < n; j++) { y2 = y + j - n / 2; - if(y2 < 0) y2 = FLAG_WRAP ? (h - 1 - (-y2 - 1) % h) : 0; + if(y2 < 0) y2 = FLAG_WRAP ? h - 1 - ((-y2 - 1) % h) : 0; else if(y2 >= h) y2 = FLAG_WRAP ? y2 % h : h - 1; for(i = 0; i < m; i++) { x2 = x + i - m / 2; - if(x2 < 0) x2 = FLAG_WRAP ? (w - 1 - (-x2 - 1) % w) : 0; + if(x2 < 0) x2 = FLAG_WRAP ? w - 1 - ((-x2 - 1) % w) : 0; else if(x2 >= w) x2 = FLAG_WRAP ? x2 % w : w - 1; Y += mat[j * m + i] * srcdata[y2 * w + x2]; @@ -80,7 +80,7 @@ static pipi_image_t *FUNC1(pipi_image_t *src, int m, int n, double mat[]) for(j = 0; j < n; j++) { y2 = y + j - n / 2; - if(y2 < 0) y2 = FLAG_WRAP ? (h - 1 - (-y2 - 1) % h) : 0; + if(y2 < 0) y2 = FLAG_WRAP ? h - 1 - ((-y2 - 1) % h) : 0; else if(y2 >= h) y2 = FLAG_WRAP ? y2 % h : h - 1; for(i = 0; i < m; i++) @@ -88,7 +88,7 @@ static pipi_image_t *FUNC1(pipi_image_t *src, int m, int n, double mat[]) double f = mat[j * m + i]; x2 = x + i - m / 2; - if(x2 < 0) x2 = FLAG_WRAP ? (w - 1 - (-x2 - 1) % w) : 0; + if(x2 < 0) x2 = FLAG_WRAP ? w - 1 - ((-x2 - 1) % w) : 0; else if(x2 >= w) x2 = FLAG_WRAP ? x2 % w : w - 1; R += f * srcdata[(y2 * w + x2) * 4]; @@ -142,7 +142,7 @@ static pipi_image_t *FUNC2(pipi_image_t *src, for(i = 0; i < m; i++) { x2 = x + i - m / 2; - if(x2 < 0) x2 = FLAG_WRAP ? (w - 1 - (-x2 - 1) % w) : 0; + if(x2 < 0) x2 = FLAG_WRAP ? w - 1 - ((-x2 - 1) % w) : 0; else if(x2 >= w) x2 = FLAG_WRAP ? x2 % w : w - 1; Y += hvec[i] * srcdata[y * w + x2]; @@ -160,7 +160,7 @@ static pipi_image_t *FUNC2(pipi_image_t *src, double f = hvec[i]; x2 = x + i - m / 2; - if(x2 < 0) x2 = FLAG_WRAP ? (w - 1 - (-x2 - 1) % w) : 0; + if(x2 < 0) x2 = FLAG_WRAP ? w - 1 - ((-x2 - 1) % w) : 0; else if(x2 >= w) x2 = FLAG_WRAP ? x2 % w : w - 1; R += f * srcdata[(y * w + x2) * 4]; @@ -187,7 +187,7 @@ static pipi_image_t *FUNC2(pipi_image_t *src, for(j = 0; j < n; j++) { y2 = y + j - n / 2; - if(y2 < 0) y2 = FLAG_WRAP ? (h - 1 - (-y2 - 1) % h) : 0; + if(y2 < 0) y2 = FLAG_WRAP ? h - 1 - ((-y2 - 1) % h) : 0; else if(y2 >= h) y2 = FLAG_WRAP ? y2 % h : h - 1; Y += vvec[j] * buffer[y2 * w + x]; @@ -205,7 +205,7 @@ static pipi_image_t *FUNC2(pipi_image_t *src, double f = vvec[j]; y2 = y + j - n / 2; - if(y2 < 0) y2 = FLAG_WRAP ? (h - 1 - (-y2 - 1) % h) : 0; + if(y2 < 0) y2 = FLAG_WRAP ? h - 1 - ((-y2 - 1) % h) : 0; else if(y2 >= h) y2 = FLAG_WRAP ? y2 % h : h - 1; R += f * buffer[(y2 * w + x) * 4];