From afc592ad7b844fea06d9267c1f9ec69baf252403 Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 29 May 2017 13:46:32 +0300 Subject: [PATCH] replace the excluding of zero coefficients with math power --- libImaging/Resample.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/libImaging/Resample.c b/libImaging/Resample.c index d2847989a..0f6a9e9dd 100644 --- a/libImaging/Resample.c +++ b/libImaging/Resample.c @@ -168,10 +168,12 @@ precompute_coeffs(int inSize, int outSize, struct filter *filterp, center = (xx + 0.5) * scale; ww = 0.0; ss = 1.0 / filterscale; - xmin = (int) floor(center - support); + // Round the value + xmin = (int) (center - support + 0.5); if (xmin < 0) xmin = 0; - xmax = (int) ceil(center + support); + // Round the value + xmax = (int) (center + support + 0.5); if (xmax > inSize) xmax = inSize; xmax -= xmin; @@ -180,21 +182,6 @@ precompute_coeffs(int inSize, int outSize, struct filter *filterp, double w = filterp->filter((x + xmin - center + 0.5) * ss); k[x] = w; ww += w; - - // We can skip extreme coefficients if they are zeroes. - if (w == 0) { - // Skip from the start. - if (x == 0) { - // At next loop `x` will be 0. - x -= 1; - // But `w` will not be 0, because it based on `xmin`. - xmin += 1; - xmax -= 1; - } else if (x == xmax - 1) { - // Truncate the last coefficient for current `xx`. - xmax -= 1; - } - } } for (x = 0; x < xmax; x++) { if (ww != 0.0)