--- deliantra/server/utils/cfhq2xa.C 2010/03/26 00:59:22 1.9 +++ deliantra/server/utils/cfhq2xa.C 2016/11/18 05:53:42 1.15 @@ -1,23 +1,23 @@ /* * This file is part of Deliantra, the Roguelike Realtime MMORPG. - * - * Copyright (©) 2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team + * + * Copyright (©) 2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team * Copyright (©) 2003 MaxSt - * + * * Deliantra is free software: you can redistribute it and/or modify it under * the terms of the Affero GNU General Public License as published by the * Free Software Foundation, either version 3 of the License, or (at your * option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the Affero GNU General Public License * and the GNU General Public License along with this program. If not, see * . - * + * * The authors can be reached via e-mail to */ @@ -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