--- deliantra/server/utils/cfhq2xa.C 2007/04/01 00:36:35 1.1 +++ deliantra/server/utils/cfhq2xa.C 2010/03/26 00:59:22 1.9 @@ -1,22 +1,27 @@ -//hq2xa filter -//---------------------------------------------------------- -//Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) -//Copyright (C) 2006 Marc Lehmann -// converted to RGBA, cleaned up - -//This program is free software; you can redistribute it and/or -//modify it under the terms of the GNU Lesser General Public -//License as published by the Free Software Foundation; either -//version 2.1 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 -//Lesser General Public License for more details. -// -//You should have received a copy of the GNU Lesser General Public -//License along with this program; if not, write to the Free Software -//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +/* + * This file is part of Deliantra, the Roguelike Realtime MMORPG. + * + * Copyright (©) 2007 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 + */ + +// note: the original code was released under the LGPL version 2.1 #include #include @@ -63,7 +68,7 @@ return ((((c1 >> shift) & Cmask) * w1 + ((c2 >> shift) & Cmask) * w2 + ((c3 >> shift) & Cmask) * w3 + w / 2) / w) << shift; } -inline void lerp (unsigned char *pc, pixel c1, int w1, pixel c2, int w2, pixel c3 = 0, int w3 = 0) +static inline void lerp (unsigned char *pc, pixel c1, int w1, pixel c2, int w2, pixel c3 = 0, int w3 = 0) { *(pixel *)pc = lerp (c1, w1, c2, w2, c3, w3, Rshift) | lerp (c1, w1, c2, w2, c3, w3, Gshift) @@ -71,37 +76,37 @@ | lerp (c1, w1, c2, w2, c3, w3, Ashift); } -inline void Interp1 (unsigned char *pc, pixel c1, pixel c2) +static inline void Interp1 (unsigned char *pc, pixel c1, pixel c2) { lerp (pc, c1, 3, c2, 1); } -inline void Interp2 (unsigned char *pc, pixel c1, pixel c2, pixel c3) +static inline void Interp2 (unsigned char *pc, pixel c1, pixel c2, pixel c3) { lerp (pc, c1, 2, c2, 1, c3, 1); } -inline void Interp5 (unsigned char *pc, pixel c1, pixel c2) +static inline void Interp5 (unsigned char *pc, pixel c1, pixel c2) { lerp (pc, c1, 1, c2, 1); } -inline void Interp6 (unsigned char *pc, pixel c1, pixel c2, pixel c3) +static inline void Interp6 (unsigned char *pc, pixel c1, pixel c2, pixel c3) { lerp (pc, c1, 5, c2, 2, c3, 1); } -inline void Interp7 (unsigned char *pc, pixel c1, pixel c2, pixel c3) +static inline void Interp7 (unsigned char *pc, pixel c1, pixel c2, pixel c3) { lerp (pc, c1, 6, c2, 1, c3, 1); } -inline void Interp9 (unsigned char *pc, pixel c1, pixel c2, pixel c3) +static inline void Interp9 (unsigned char *pc, pixel c1, pixel c2, pixel c3) { lerp (pc, c1, 2, c2, 3, c2, 3); } -inline void Interp10 (unsigned char *pc, pixel c1, pixel c2, pixel c3) +static inline void Interp10 (unsigned char *pc, pixel c1, pixel c2, pixel c3) { lerp (pc, c1, 14, c2, 1, c3, 1); } @@ -155,7 +160,7 @@ #define PIXEL11_90 Interp9(pOut+BpL + sizeof (pixel), w[5], w[6], w[8]); #define PIXEL11_100 Interp10(pOut+BpL + sizeof (pixel), w[5], w[6], w[8]); -inline pixel RGBAtoYUVA (pixel w) +static inline pixel RGBAtoYUVA (pixel w) { int r = (w >> Rshift) & Cmask; int g = (w >> Gshift) & Cmask; @@ -172,7 +177,7 @@ | (a << Ashift); } -inline bool Diff (pixel w1, pixel w2) +static inline bool Diff (pixel w1, pixel w2) { pixel YUV1 = RGBAtoYUVA (w1); pixel YUV2 = RGBAtoYUVA (w2); @@ -183,23 +188,20 @@ (abs (((YUV1 >> Ashift) & Cmask) - ((YUV2 >> Ashift) & Cmask)) > trA) ); } -void +static void hq2x_32 (unsigned char *pIn, unsigned char *pOut, int Xres, int Yres, int BpL, bool wrap) { int i, j, k; int prevline, nextline; pixel w[10]; - // +----+----+----+ - // | | | | - // | w1 | w2 | w3 | - // +----+----+----+ - // | | | | - // | w4 | w5 | w6 | - // +----+----+----+ - // | | | | - // | w7 | w8 | w9 | - // +----+----+----+ + // +--+--+--+ + // |w1|w2|w3| + // +--+--+--+ + // |w4|w5|w6| + // +--+--+--+ + // |w7|w8|w9| + // +--+--+--+ for (j = 0; j < Yres; j++) {