--- cf.schmorp.de/server/utils/cfhq2xa.C 2016/11/16 23:42:03 1.14 +++ cf.schmorp.de/server/utils/cfhq2xa.C 2016/11/18 05:53:42 1.15 @@ -55,6 +55,13 @@ # define trV 0x10 # define trA 0x40 +static int32_t +udiff (uint32_t a, uint32_t b) +{ + return a > b ? a - b : b - a; + +} + static inline pixel lerp (pixel c1, int w1, pixel c2, int w2, pixel c3, int w3, int shift) { #if 0 @@ -182,10 +189,10 @@ pixel YUV1 = RGBAtoYUVA (w1); pixel YUV2 = RGBAtoYUVA (w2); - return ((abs (((YUV1 >> Rshift) & Cmask) - ((YUV2 >> Rshift) & Cmask)) > trY) || - (abs (((YUV1 >> Gshift) & Cmask) - ((YUV2 >> Gshift) & Cmask)) > trU) || - (abs (((YUV1 >> Bshift) & Cmask) - ((YUV2 >> Bshift) & Cmask)) > trV) || - (abs (((YUV1 >> Ashift) & Cmask) - ((YUV2 >> Ashift) & Cmask)) > trA) ); + return ((udiff ((YUV1 >> Rshift) & Cmask, (YUV2 >> Rshift) & Cmask) > trY) || + (udiff ((YUV1 >> Gshift) & Cmask, (YUV2 >> Gshift) & Cmask) > trU) || + (udiff ((YUV1 >> Bshift) & Cmask, (YUV2 >> Bshift) & Cmask) > trV) || + (udiff ((YUV1 >> Ashift) & Cmask, (YUV2 >> Ashift) & Cmask) > trA) ); } static void