diff --git a/libImaging/AlphaComposite.c b/libImaging/AlphaComposite.c index 7e99c59ce..00d28f956 100644 --- a/libImaging/AlphaComposite.c +++ b/libImaging/AlphaComposite.c @@ -77,9 +77,6 @@ ImagingAlphaComposite(Imaging imDst, Imaging imSrc) UINT16 coef1 = src->a * 255 * 255 * 128 / outa255; UINT16 coef2 = 255 * 128 - coef1; - #define SHIFTFORDIV255(a)\ - ((((a) >> 8) + a) >> 8) - tmpr = src->r * coef1 + dst->r * coef2 + (0x80 << 7); out->r = SHIFTFORDIV255(tmpr) >> 7; tmpg = src->g * coef1 + dst->g * coef2 + (0x80 << 7); diff --git a/libImaging/Convert.c b/libImaging/Convert.c index f4253bda4..f820b1f6d 100644 --- a/libImaging/Convert.c +++ b/libImaging/Convert.c @@ -41,10 +41,6 @@ #define CLIP(v) ((v) <= 0 ? 0 : (v) >= 255 ? 255 : (v)) #define CLIP16(v) ((v) <= -32768 ? -32768 : (v) >= 32767 ? 32767 : (v)) -/* like (a * b + 127) / 255), but much faster on most platforms */ -#define MULDIV255(a, b, tmp)\ - (tmp = (a) * (b) + 128, ((((tmp) >> 8) + (tmp)) >> 8)) - /* ITU-R Recommendation 601-2 (assuming nonlinear RGB) */ #define L(rgb)\ ((INT32) (rgb)[0]*299 + (INT32) (rgb)[1]*587 + (INT32) (rgb)[2]*114) diff --git a/libImaging/Draw.c b/libImaging/Draw.c index 65ab34a66..a4d24133c 100644 --- a/libImaging/Draw.c +++ b/libImaging/Draw.c @@ -42,10 +42,6 @@ #define INK8(ink) (*(UINT8*)ink) #define INK32(ink) (*(INT32*)ink) -/* like (a * b + 127) / 255), but much faster on most platforms */ -#define MULDIV255(a, b, tmp)\ - (tmp = (a) * (b) + 128, ((((tmp) >> 8) + (tmp)) >> 8)) - #define BLEND(mask, in1, in2, tmp1, tmp2)\ (MULDIV255(in1, 255 - mask, tmp1) + MULDIV255(in2, mask, tmp2)) diff --git a/libImaging/ImagingUtils.h b/libImaging/ImagingUtils.h index d2a8f98a6..bb4ada311 100644 --- a/libImaging/ImagingUtils.h +++ b/libImaging/ImagingUtils.h @@ -10,4 +10,12 @@ #define MASK_UINT32_CHANNEL_1 0x0000ff00 #define MASK_UINT32_CHANNEL_2 0x00ff0000 #define MASK_UINT32_CHANNEL_3 0xff000000 -#endif \ No newline at end of file +#endif + + +#define SHIFTFORDIV255(a)\ + ((((a) >> 8) + a) >> 8) + +/* like (a * b + 127) / 255), but much faster on most platforms */ +#define MULDIV255(a, b, tmp)\ + (tmp = (a) * (b) + 128, SHIFTFORDIV255(tmp)) diff --git a/libImaging/Pack.c b/libImaging/Pack.c index b624f1956..47086e091 100644 --- a/libImaging/Pack.c +++ b/libImaging/Pack.c @@ -72,9 +72,6 @@ #define C64L C64N #endif -/* like (a * b + 127) / 255), but much faster on most platforms */ -#define MULDIV255(a, b, tmp)\ - (tmp = (a) * (b) + 128, ((((tmp) >> 8) + (tmp)) >> 8)) static void pack1(UINT8* out, const UINT8* in, int pixels) diff --git a/libImaging/Paste.c b/libImaging/Paste.c index a18e5d6f2..402beff92 100644 --- a/libImaging/Paste.c +++ b/libImaging/Paste.c @@ -23,20 +23,11 @@ #include "Imaging.h" -/* like (a * b + 127) / 255), but much faster on most platforms */ -#define MULDIV255NEW(a, tmp)\ - (tmp = (a) + 128, ((((tmp) >> 8) + (tmp)) >> 8)) - -#define MULDIV255OLD(a, tmp)\ - (((a) + 127) / 255) - -#define MULDIV255 MULDIV255NEW - #define BLEND(mask, in1, in2, tmp1)\ - MULDIV255(in1 * (255 - mask) + in2 * mask, tmp1) + (MULDIV255(in1, 255 - mask, tmp1) + MULDIV255(in2, mask, tmp1)) #define PREBLEND(mask, in1, in2, tmp1)\ - (MULDIV255(in1 * (255 - mask), tmp1) + in2) + (MULDIV255(in1, (255 - mask), tmp1) + in2) static inline void paste(Imaging imOut, Imaging imIn, int dx, int dy, int sx, int sy,