1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2 * Mupen64plus - TextureFilters_hq2x.cpp *
3 * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
4 * Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
20 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24 /************************************************************************/
26 /************************************************************************/
28 /***************************************************************************/
31 /***************************************************************************/
34 static unsigned interp_bits_per_pixel;
36 #define INTERP_16_MASK_1_3(v) ((v)&0x0F0F)
37 #define INTERP_16_MASK_SHIFT_2_4(v) (((v)&0xF0F0)>>4)
38 #define INTERP_16_MASK_SHIFTBACK_2_4(v) ((INTERP_16_MASK_1_3(v))<<4)
40 static inline uint16 hq2x_interp_16_521(uint16 p1, uint16 p2, uint16 p3)
42 return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*5 + INTERP_16_MASK_1_3(p2)*2 + INTERP_16_MASK_1_3(p3)*1) / 8)
43 | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*5 + INTERP_16_MASK_SHIFT_2_4(p2)*2 + INTERP_16_MASK_SHIFT_2_4(p3)*1) / 8);
46 static inline uint16 hq2x_interp_16_332(uint16 p1, uint16 p2, uint16 p3)
48 return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*3 + INTERP_16_MASK_1_3(p2)*3 + INTERP_16_MASK_1_3(p3)*2) / 8)
49 | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*3 + INTERP_16_MASK_SHIFT_2_4(p2)*3 + INTERP_16_MASK_SHIFT_2_4(p3)*2) / 8);
52 static inline uint16 hq2x_interp_16_611(uint16 p1, uint16 p2, uint16 p3)
54 return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*6 + INTERP_16_MASK_1_3(p2) + INTERP_16_MASK_1_3(p3)) / 8)
55 | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*6 + INTERP_16_MASK_SHIFT_2_4(p2) + INTERP_16_MASK_SHIFT_2_4(p3)) / 8);
58 static inline uint16 hq2x_interp_16_71(uint16 p1, uint16 p2)
60 return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*7 + INTERP_16_MASK_1_3(p2)) / 8)
61 | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*7 + INTERP_16_MASK_SHIFT_2_4(p2)) / 8);
64 static inline uint16 hq2x_interp_16_211(uint16 p1, uint16 p2, uint16 p3)
66 return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*2 + INTERP_16_MASK_1_3(p2) + INTERP_16_MASK_1_3(p3)) / 4)
67 | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*2 + INTERP_16_MASK_SHIFT_2_4(p2) + INTERP_16_MASK_SHIFT_2_4(p3)) / 4);
70 static inline uint16 hq2x_interp_16_772(uint16 p1, uint16 p2, uint16 p3)
72 return INTERP_16_MASK_1_3(((INTERP_16_MASK_1_3(p1) + INTERP_16_MASK_1_3(p2))*7 + INTERP_16_MASK_1_3(p3)*2) / 16)
73 | INTERP_16_MASK_SHIFTBACK_2_4(((INTERP_16_MASK_SHIFT_2_4(p1) + INTERP_16_MASK_SHIFT_2_4(p2))*7 + INTERP_16_MASK_SHIFT_2_4(p3)*2) / 16);
76 static inline uint16 hq2x_interp_16_11(uint16 p1, uint16 p2)
78 return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1) + INTERP_16_MASK_1_3(p2)) / 2)
79 | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1) + INTERP_16_MASK_SHIFT_2_4(p2)) / 2);
82 static inline uint16 hq2x_interp_16_31(uint16 p1, uint16 p2)
84 return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*3 + INTERP_16_MASK_1_3(p2)) / 4)
85 | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*3 + INTERP_16_MASK_SHIFT_2_4(p2)) / 4);
88 static inline uint16 hq2x_interp_16_1411(uint16 p1, uint16 p2, uint16 p3)
90 return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*14 + INTERP_16_MASK_1_3(p2) + INTERP_16_MASK_1_3(p3)) / 16)
91 | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*14 + INTERP_16_MASK_SHIFT_2_4(p2) + INTERP_16_MASK_SHIFT_2_4(p3)) / 16);
94 static inline uint16 hq2x_interp_16_431(uint16 p1, uint16 p2, uint16 p3)
96 return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*4 + INTERP_16_MASK_1_3(p2)*3 + INTERP_16_MASK_1_3(p3)) / 8)
97 | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*4 + INTERP_16_MASK_SHIFT_2_4(p2)*3 + INTERP_16_MASK_SHIFT_2_4(p3)) / 8);
100 static inline uint16 hq2x_interp_16_53(uint16 p1, uint16 p2)
102 return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*5 + INTERP_16_MASK_1_3(p2)*3) / 8)
103 | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*5 + INTERP_16_MASK_SHIFT_2_4(p2)*3) / 8);
106 static inline uint16 hq2x_interp_16_151(uint16 p1, uint16 p2)
108 return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*15 + INTERP_16_MASK_1_3(p2)) / 16)
109 | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*15 + INTERP_16_MASK_SHIFT_2_4(p2)) / 16);
112 static inline uint16 hq2x_interp_16_97(uint16 p1, uint16 p2)
114 return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*9 + INTERP_16_MASK_1_3(p2)*7) / 16)
115 | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*9 + INTERP_16_MASK_SHIFT_2_4(p2)*7) / 16);
118 #define INTERP_32_MASK_1_3(v) ((v)&0x00FF00FF)
119 #define INTERP_32_MASK_SHIFT_2_4(v) (((v)&0xFF00FF00)>>8)
120 #define INTERP_32_MASK_SHIFTBACK_2_4(v) (((INTERP_32_MASK_1_3(v))<<8))
122 static inline uint32 hq2x_interp_32_521(uint32 p1, uint32 p2, uint32 p3)
124 return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*5 + INTERP_32_MASK_1_3(p2)*2 + INTERP_32_MASK_1_3(p3)*1) / 8)
125 | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*5 + INTERP_32_MASK_SHIFT_2_4(p2)*2 + INTERP_32_MASK_SHIFT_2_4(p3)*1) / 8);
128 static inline uint32 hq2x_interp_32_332(uint32 p1, uint32 p2, uint32 p3)
130 return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*3 + INTERP_32_MASK_1_3(p2)*3 + INTERP_32_MASK_1_3(p3)*2) / 8)
131 | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*3 + INTERP_32_MASK_SHIFT_2_4(p2)*3 + INTERP_32_MASK_SHIFT_2_4(p3)*2) / 8);
134 static inline uint32 hq2x_interp_32_211(uint32 p1, uint32 p2, uint32 p3)
136 return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*2 + INTERP_32_MASK_1_3(p2) + INTERP_32_MASK_1_3(p3)) / 4)
137 | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*2 + INTERP_32_MASK_SHIFT_2_4(p2) + INTERP_32_MASK_SHIFT_2_4(p3)) / 4);
140 static inline uint32 hq2x_interp_32_611(uint32 p1, uint32 p2, uint32 p3)
142 return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*6 + INTERP_32_MASK_1_3(p2) + INTERP_32_MASK_1_3(p3)) / 8)
143 | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*6 + INTERP_32_MASK_SHIFT_2_4(p2) + INTERP_32_MASK_SHIFT_2_4(p3)) / 8);
146 static inline uint32 hq2x_interp_32_71(uint32 p1, uint32 p2)
148 return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*7 + INTERP_32_MASK_1_3(p2)) / 8)
149 | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*7 + INTERP_32_MASK_SHIFT_2_4(p2)) / 8);
152 static inline uint32 hq2x_interp_32_772(uint32 p1, uint32 p2, uint32 p3)
154 return INTERP_32_MASK_1_3(((INTERP_32_MASK_1_3(p1) + INTERP_32_MASK_1_3(p2))*7 + INTERP_32_MASK_1_3(p3)*2) / 16)
155 | INTERP_32_MASK_SHIFTBACK_2_4(((INTERP_32_MASK_SHIFT_2_4(p1) + INTERP_32_MASK_SHIFT_2_4(p2))*7 + INTERP_32_MASK_SHIFT_2_4(p3)*2) / 16);
158 static inline uint32 hq2x_interp_32_11(uint32 p1, uint32 p2)
160 return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1) + INTERP_32_MASK_1_3(p2)) / 2)
161 | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1) + INTERP_32_MASK_SHIFT_2_4(p2)) / 2);
164 static inline uint32 hq2x_interp_32_31(uint32 p1, uint32 p2)
166 return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*3 + INTERP_32_MASK_1_3(p2)) / 4)
167 | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*3 + INTERP_32_MASK_SHIFT_2_4(p2)) / 4);
170 static inline uint32 hq2x_interp_32_1411(uint32 p1, uint32 p2, uint32 p3)
172 return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*14 + INTERP_32_MASK_1_3(p2) + INTERP_32_MASK_1_3(p3)) / 16)
173 | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*14 + INTERP_32_MASK_SHIFT_2_4(p2) + INTERP_32_MASK_SHIFT_2_4(p3)) / 16);
176 static inline uint32 hq2x_interp_32_431(uint32 p1, uint32 p2, uint32 p3)
178 return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*4 + INTERP_32_MASK_1_3(p2)*3 + INTERP_32_MASK_1_3(p3)) / 8)
179 | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*4 + INTERP_32_MASK_SHIFT_2_4(p2)*3 + INTERP_32_MASK_SHIFT_2_4(p3)) / 8);
182 static inline uint32 hq2x_interp_32_53(uint32 p1, uint32 p2)
184 return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*5 + INTERP_32_MASK_1_3(p2)*3) / 8)
185 | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*5 + INTERP_32_MASK_SHIFT_2_4(p2)*3) / 8);
188 static inline uint32 hq2x_interp_32_151(uint32 p1, uint32 p2)
190 return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*15 + INTERP_32_MASK_1_3(p2)) / 16)
191 | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*15 + INTERP_32_MASK_SHIFT_2_4(p2)) / 16);
194 static inline uint32 hq2x_interp_32_97(uint32 p1, uint32 p2)
196 return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*9 + INTERP_32_MASK_1_3(p2)*7) / 16)
197 | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*9 + INTERP_32_MASK_SHIFT_2_4(p2)*7) / 16);
200 /***************************************************************************/
203 #define INTERP_Y_LIMIT (0x30*4)
204 #define INTERP_U_LIMIT (0x07*4)
205 #define INTERP_V_LIMIT (0x06*8)
207 static int hq2x_interp_16_diff(uint16 p1, uint16 p2)
215 b = (int)((p1 & 0x000F) - (p2 & 0x000F));
216 g = (int)((p1 & 0x00F0) - (p2 & 0x00F0)) >> 4;
217 r = (int)((p1 & 0x0F00) - (p2 & 0x0F00)) >> 8;
223 if (y < -INTERP_Y_LIMIT || y > INTERP_Y_LIMIT)
226 if (u < -INTERP_U_LIMIT || u > INTERP_U_LIMIT)
229 if (v < -INTERP_V_LIMIT || v > INTERP_V_LIMIT)
235 static int hq2x_interp_32_diff(uint32 p1, uint32 p2)
240 if ((p1 & 0xF8F8F8) == (p2 & 0xF8F8F8))
243 b = (int)((p1 & 0xFF) - (p2 & 0xFF));
244 g = (int)((p1 & 0xFF00) - (p2 & 0xFF00)) >> 8;
245 r = (int)((p1 & 0xFF0000) - (p2 & 0xFF0000)) >> 16;
251 if (y < -INTERP_Y_LIMIT || y > INTERP_Y_LIMIT)
254 if (u < -INTERP_U_LIMIT || u > INTERP_U_LIMIT)
257 if (v < -INTERP_V_LIMIT || v > INTERP_V_LIMIT)
263 static void interp_set(unsigned bits_per_pixel)
265 interp_bits_per_pixel = bits_per_pixel;
269 static void hq2x_16_def(uint16* dst0, uint16* dst1, const uint16* src0, const uint16* src1, const uint16* src2, unsigned count)
273 for(i=0;i<count;++i) {
304 if (hq2x_interp_16_diff(c[0], c[4]))
306 if (hq2x_interp_16_diff(c[1], c[4]))
308 if (hq2x_interp_16_diff(c[2], c[4]))
310 if (hq2x_interp_16_diff(c[3], c[4]))
312 if (hq2x_interp_16_diff(c[5], c[4]))
314 if (hq2x_interp_16_diff(c[6], c[4]))
316 if (hq2x_interp_16_diff(c[7], c[4]))
318 if (hq2x_interp_16_diff(c[8], c[4]))
325 #define HQ2X_MUR hq2x_interp_16_diff(c[1], c[5])
326 #define HQ2X_MDR hq2x_interp_16_diff(c[5], c[7])
327 #define HQ2X_MDL hq2x_interp_16_diff(c[7], c[3])
328 #define HQ2X_MUL hq2x_interp_16_diff(c[3], c[1])
330 #define I11(p0,p1) hq2x_interp_16_11(c[p0], c[p1])
331 #define I211(p0,p1,p2) hq2x_interp_16_211(c[p0], c[p1], c[p2])
332 #define I31(p0,p1) hq2x_interp_16_31(c[p0], c[p1])
333 #define I332(p0,p1,p2) hq2x_interp_16_332(c[p0], c[p1], c[p2])
334 #define I431(p0,p1,p2) hq2x_interp_16_431(c[p0], c[p1], c[p2])
335 #define I521(p0,p1,p2) hq2x_interp_16_521(c[p0], c[p1], c[p2])
336 #define I53(p0,p1) hq2x_interp_16_53(c[p0], c[p1])
337 #define I611(p0,p1,p2) hq2x_interp_16_611(c[p0], c[p1], c[p2])
338 #define I71(p0,p1) hq2x_interp_16_71(c[p0], c[p1])
339 #define I772(p0,p1,p2) hq2x_interp_16_772(c[p0], c[p1], c[p2])
340 #define I97(p0,p1) hq2x_interp_16_97(c[p0], c[p1])
341 #define I1411(p0,p1,p2) hq2x_interp_16_1411(c[p0], c[p1], c[p2])
342 #define I151(p0,p1) hq2x_interp_16_151(c[p0], c[p1])
345 #include "TextureFilters_hq2x.h"
379 static void hq2x_32_def(uint32* dst0, uint32* dst1, const uint32* src0, const uint32* src1, const uint32* src2, unsigned count)
383 for(i=0;i<count;++i) {
414 if (hq2x_interp_32_diff(c[0], c[4]))
416 if (hq2x_interp_32_diff(c[1], c[4]))
418 if (hq2x_interp_32_diff(c[2], c[4]))
420 if (hq2x_interp_32_diff(c[3], c[4]))
422 if (hq2x_interp_32_diff(c[5], c[4]))
424 if (hq2x_interp_32_diff(c[6], c[4]))
426 if (hq2x_interp_32_diff(c[7], c[4]))
428 if (hq2x_interp_32_diff(c[8], c[4]))
435 #define HQ2X_MUR hq2x_interp_32_diff(c[1], c[5])
436 #define HQ2X_MDR hq2x_interp_32_diff(c[5], c[7])
437 #define HQ2X_MDL hq2x_interp_32_diff(c[7], c[3])
438 #define HQ2X_MUL hq2x_interp_32_diff(c[3], c[1])
440 #define I11(p0,p1) hq2x_interp_32_11(c[p0], c[p1])
441 #define I211(p0,p1,p2) hq2x_interp_32_211(c[p0], c[p1], c[p2])
442 #define I31(p0,p1) hq2x_interp_32_31(c[p0], c[p1])
443 #define I332(p0,p1,p2) hq2x_interp_32_332(c[p0], c[p1], c[p2])
444 #define I431(p0,p1,p2) hq2x_interp_32_431(c[p0], c[p1], c[p2])
445 #define I521(p0,p1,p2) hq2x_interp_32_521(c[p0], c[p1], c[p2])
446 #define I53(p0,p1) hq2x_interp_32_53(c[p0], c[p1])
447 #define I611(p0,p1,p2) hq2x_interp_32_611(c[p0], c[p1], c[p2])
448 #define I71(p0,p1) hq2x_interp_32_71(c[p0], c[p1])
449 #define I772(p0,p1,p2) hq2x_interp_32_772(c[p0], c[p1], c[p2])
450 #define I97(p0,p1) hq2x_interp_32_97(c[p0], c[p1])
451 #define I1411(p0,p1,p2) hq2x_interp_32_1411(c[p0], c[p1], c[p2])
452 #define I151(p0,p1) hq2x_interp_32_151(c[p0], c[p1])
455 #include "TextureFilters_hq2x.h"
489 /***************************************************************************/
490 /* LQ2x C implementation */
493 * This effect is derived from the hq2x effect made by Maxim Stepin
496 static void lq2x_16_def(uint16* dst0, uint16* dst1, const uint16* src0, const uint16* src1, const uint16* src2, unsigned count)
500 for(i=0;i<count;++i) {
552 #define HQ2X_MUR (c[1] != c[5])
553 #define HQ2X_MDR (c[5] != c[7])
554 #define HQ2X_MDL (c[7] != c[3])
555 #define HQ2X_MUL (c[3] != c[1])
557 #define I11(p0,p1) hq2x_interp_16_11(c[p0], c[p1])
558 #define I211(p0,p1,p2) hq2x_interp_16_211(c[p0], c[p1], c[p2])
559 #define I31(p0,p1) hq2x_interp_16_31(c[p0], c[p1])
560 #define I332(p0,p1,p2) hq2x_interp_16_332(c[p0], c[p1], c[p2])
561 #define I431(p0,p1,p2) hq2x_interp_16_431(c[p0], c[p1], c[p2])
562 #define I521(p0,p1,p2) hq2x_interp_16_521(c[p0], c[p1], c[p2])
563 #define I53(p0,p1) hq2x_interp_16_53(c[p0], c[p1])
564 #define I611(p0,p1,p2) hq2x_interp_16_611(c[p0], c[p1], c[p2])
565 #define I71(p0,p1) hq2x_interp_16_71(c[p0], c[p1])
566 #define I772(p0,p1,p2) hq2x_interp_16_772(c[p0], c[p1], c[p2])
567 #define I97(p0,p1) hq2x_interp_16_97(c[p0], c[p1])
568 #define I1411(p0,p1,p2) hq2x_interp_16_1411(c[p0], c[p1], c[p2])
569 #define I151(p0,p1) hq2x_interp_16_151(c[p0], c[p1])
572 #include "TextureFilters_lq2x.h"
606 static void lq2x_32_def(uint32* dst0, uint32* dst1, const uint32* src0, const uint32* src1, const uint32* src2, unsigned count)
610 for(i=0;i<count;++i) {
662 #define HQ2X_MUR (c[1] != c[5])
663 #define HQ2X_MDR (c[5] != c[7])
664 #define HQ2X_MDL (c[7] != c[3])
665 #define HQ2X_MUL (c[3] != c[1])
667 #define I11(p0,p1) hq2x_interp_32_11(c[p0], c[p1])
668 #define I211(p0,p1,p2) hq2x_interp_32_211(c[p0], c[p1], c[p2])
669 #define I31(p0,p1) hq2x_interp_32_31(c[p0], c[p1])
670 #define I332(p0,p1,p2) hq2x_interp_32_332(c[p0], c[p1], c[p2])
671 #define I431(p0,p1,p2) hq2x_interp_32_431(c[p0], c[p1], c[p2])
672 #define I521(p0,p1,p2) hq2x_interp_32_521(c[p0], c[p1], c[p2])
673 #define I53(p0,p1) hq2x_interp_32_53(c[p0], c[p1])
674 #define I611(p0,p1,p2) hq2x_interp_32_611(c[p0], c[p1], c[p2])
675 #define I71(p0,p1) hq2x_interp_32_71(c[p0], c[p1])
676 #define I772(p0,p1,p2) hq2x_interp_32_772(c[p0], c[p1], c[p2])
677 #define I97(p0,p1) hq2x_interp_32_97(c[p0], c[p1])
678 #define I1411(p0,p1,p2) hq2x_interp_32_1411(c[p0], c[p1], c[p2])
679 #define I151(p0,p1) hq2x_interp_32_151(c[p0], c[p1])
682 #include "TextureFilters_lq2x.h"
716 void hq2x_16(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height)
718 uint16 *dst0 = (uint16 *)dstPtr;
719 uint16 *dst1 = dst0 + (dstPitch >> 1);
721 uint16 *src0 = (uint16 *)srcPtr;
722 uint16 *src1 = src0 + (srcPitch >> 1);
723 uint16 *src2 = src1 + (srcPitch >> 1);
725 hq2x_16_def(dst0, dst1, src0, src0, src1, width);
726 if( height == 1 ) return;
734 hq2x_16_def(dst0, dst1, src0, src1, src2, width);
737 src2 += srcPitch >> 1;
742 hq2x_16_def(dst0, dst1, src0, src1, src1, width);
745 void hq2x_32(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height)
747 uint32 *dst0 = (uint32 *)dstPtr;
748 uint32 *dst1 = dst0 + (dstPitch >> 2);
750 uint32 *src0 = (uint32 *)srcPtr;
751 uint32 *src1 = src0 + (srcPitch >> 2);
752 uint32 *src2 = src1 + (srcPitch >> 2);
753 hq2x_32_def(dst0, dst1, src0, src0, src1, width);
754 if( height == 1 ) return;
760 dst0 += dstPitch >> 1;
761 dst1 += dstPitch >> 1;
762 hq2x_32_def(dst0, dst1, src0, src1, src2, width);
765 src2 += srcPitch >> 2;
768 dst0 += dstPitch >> 1;
769 dst1 += dstPitch >> 1;
770 hq2x_32_def(dst0, dst1, src0, src1, src1, width);
773 void lq2x_16(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height)
775 uint16 *dst0 = (uint16 *)dstPtr;
776 uint16 *dst1 = dst0 + (dstPitch >> 1);
778 uint16 *src0 = (uint16 *)srcPtr;
779 uint16 *src1 = src0 + (srcPitch >> 1);
780 uint16 *src2 = src1 + (srcPitch >> 1);
782 lq2x_16_def(dst0, dst1, src0, src0, src1, width);
783 if( height == 1 ) return;
791 hq2x_16_def(dst0, dst1, src0, src1, src2, width);
794 src2 += srcPitch >> 1;
799 lq2x_16_def(dst0, dst1, src0, src1, src1, width);
802 void lq2x_32(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height)
804 uint32 *dst0 = (uint32 *)dstPtr;
805 uint32 *dst1 = dst0 + (dstPitch >> 2);
807 uint32 *src0 = (uint32 *)srcPtr;
808 uint32 *src1 = src0 + (srcPitch >> 2);
809 uint32 *src2 = src1 + (srcPitch >> 2);
810 lq2x_32_def(dst0, dst1, src0, src0, src1, width);
811 if( height == 1 ) return;
817 dst0 += dstPitch >> 1;
818 dst1 += dstPitch >> 1;
819 hq2x_32_def(dst0, dst1, src0, src1, src2, width);
822 src2 += srcPitch >> 2;
825 dst0 += dstPitch >> 1;
826 dst1 += dstPitch >> 1;
827 lq2x_32_def(dst0, dst1, src0, src1, src1, width);
830 void hq2x_init(unsigned bits_per_pixel)
832 interp_set(bits_per_pixel);
835 /************************************************************************/
837 /************************************************************************/
839 /************************************************************************/
840 /* scale2x filters */
841 /************************************************************************/
843 /************************************************************************/
844 /* scale3x filters */
845 /************************************************************************/