Correct max coefficient calulation

Minimal test case:
Image.new('RGB', (341, 60), 'pink').resize((170, 60), Image.LANCZOS).save('_out.png')
This commit is contained in:
Alexander 2019-04-03 01:31:30 +03:00
parent 17582f734c
commit c2a9bfb1af

View File

@ -284,11 +284,12 @@ normalize_coeffs_8bpc(int outSize, int ksize, double *prekk)
} }
} }
coefs_precision = 0; for (coefs_precision = 0; coefs_precision < PRECISION_BITS; coefs_precision += 1) {
while (maxkk < (1 << (MAX_COEFS_PRECISION-1)) && (coefs_precision < PRECISION_BITS)) { int next_value = (int) (0.5 + maxkk * (1 << (coefs_precision + 1)));
maxkk *= 2; // The next value will be outside of the range, so just stop
coefs_precision += 1; if (next_value >= (1 << MAX_COEFS_PRECISION))
}; break;
}
for (x = 0; x < outSize * ksize; x++) { for (x = 0; x < outSize * ksize; x++) {
if (prekk[x] < 0) { if (prekk[x] < 0) {