diff --git a/src/libImaging/Resample.c b/src/libImaging/Resample.c index 89deef5ec..0f399cdc6 100644 --- a/src/libImaging/Resample.c +++ b/src/libImaging/Resample.c @@ -82,33 +82,43 @@ lanczos_filter(double x) { static inline double mks_2013_filter(double x) { /* https://johncostella.com/magic/ */ - if (x < 0.0) + if (x < 0) { x = -x; - if (x < 0.5) - return 17.0 / 16.0 - 7.0 / 4.0 * pow(x, 2.0); - if (x < 1.5) + } + if (x < 0.5) { + return 17.0 / 16.0 - 7.0 / 4.0 * pow(x, 2); + } + if (x < 1.5) { return (1.0 - x) * (7.0 / 4.0 - x); - if (x < 2.5) - return -1.0 / 8.0 * pow(x - 5.0 / 2.0, 2.0); - return (0.0); + } + if (x < 2.5) { + return -1.0 / 8.0 * pow(x - 5.0 / 2.0, 2); + } + return 0; } static inline double mks_2021_filter(double x) { /* https://johncostella.com/magic/ */ - if (x < 0.0) + if (x < 0) { x = -x; - if (x < 0.5) - return 577.0 / 576.0 - 239.0 / 144.0 * pow(x, 2.0); - if (x < 1.5) + } + if (x < 0.5) { + return 577.0 / 576.0 - 239.0 / 144.0 * pow(x, 2); + } + if (x < 1.5) { return 35.0 / 36.0 * (x - 1.0) * (x - 239.0 / 140.0); - if (x < 2.5) + } + if (x < 2.5) { return 1.0 / 6.0 * (x - 2.0) * (65.0 / 24.0 - x); - if (x < 3.5) + } + if (x < 3.5) { return 1.0 / 36.0 * (x - 3.0) * (x - 15.0 / 4.0); - if (x < 4.5) - return -1.0 / 288.0 * pow(x - 9.0 / 2.0, 2.0); - return (0.0); + } + if (x < 4.5) { + return -1.0 / 288.0 * pow(x - 9.0 / 2.0, 2); + } + return 0; } static struct filter BOX = {box_filter, 0.5};