2
* OpenTyrian: A modern cross-platform port of Tyrian
3
* Copyright (C) 2007-2010 The OpenTyrian Development Team
6
* Copyright (C) 2003 MaxSt ( maxst@hiend3d.com )
8
* This program is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU General Public License
10
* as published by the Free Software Foundation; either version 2
11
* of the License, or (at your option) any later version.
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program; if not, write to the Free Software
20
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26
void interp1(Uint32 *pc, Uint32 c1, Uint32 c2);
27
void interp2(Uint32 *pc, Uint32 c1, Uint32 c2, Uint32 c3);
28
void interp3(Uint32 *pc, Uint32 c1, Uint32 c2);
29
void interp4(Uint32 *pc, Uint32 c1, Uint32 c2, Uint32 c3);
30
void interp5(Uint32 *pc, Uint32 c1, Uint32 c2);
31
void interp6(Uint32 *pc, Uint32 c1, Uint32 c2, Uint32 c3);
32
void interp7(Uint32 *pc, Uint32 c1, Uint32 c2, Uint32 c3);
33
void interp8(Uint32 *pc, Uint32 c1, Uint32 c2);
34
void interp9(Uint32 *pc, Uint32 c1, Uint32 c2, Uint32 c3);
35
void interp10(Uint32 *pc, Uint32 c1, Uint32 c2, Uint32 c3);
36
bool diff(unsigned int w1, unsigned int w2);
38
void hq2x_32( SDL_Surface *src_surface, SDL_Surface *dst_surface );
39
void hq3x_32( SDL_Surface *src_surface, SDL_Surface *dst_surface );
40
void hq4x_32( SDL_Surface *src_surface, SDL_Surface *dst_surface );
42
static int YUV1, YUV2;
43
const int Ymask = 0x00FF0000;
44
const int Umask = 0x0000FF00;
45
const int Vmask = 0x000000FF;
46
const int trY = 0x00300000;
47
const int trU = 0x00000700;
48
const int trV = 0x00000006;
50
inline void interp1(Uint32 *pc, Uint32 c1, Uint32 c2)
55
inline void interp2(Uint32 *pc, Uint32 c1, Uint32 c2, Uint32 c3)
57
*pc = (c1*2+c2+c3) >> 2;
60
inline void interp3(Uint32 *pc, Uint32 c1, Uint32 c2)
62
//*((int*)pc) = (c1*7+c2)/8;
64
*((int*)pc) = ((((c1 & 0x00FF00)*7 + (c2 & 0x00FF00) ) & 0x0007F800) +
65
(((c1 & 0xFF00FF)*7 + (c2 & 0xFF00FF) ) & 0x07F807F8)) >> 3;
68
inline void interp4(Uint32 *pc, Uint32 c1, Uint32 c2, Uint32 c3)
70
//*((int*)pc) = (c1*2+(c2+c3)*7)/16;
72
*((int*)pc) = ((((c1 & 0x00FF00)*2 + ((c2 & 0x00FF00) + (c3 & 0x00FF00))*7 ) & 0x000FF000) +
73
(((c1 & 0xFF00FF)*2 + ((c2 & 0xFF00FF) + (c3 & 0xFF00FF))*7 ) & 0x0FF00FF0)) >> 4;
76
inline void interp5(Uint32 *pc, Uint32 c1, Uint32 c2)
81
inline void interp6(Uint32 *pc, Uint32 c1, Uint32 c2, Uint32 c3)
83
//*pc = (c1*5+c2*2+c3)/8;
85
*pc = ((((c1 & 0x00FF00)*5 + (c2 & 0x00FF00)*2 + (c3 & 0x00FF00) ) & 0x0007F800) +
86
(((c1 & 0xFF00FF)*5 + (c2 & 0xFF00FF)*2 + (c3 & 0xFF00FF) ) & 0x07F807F8)) >> 3;
89
inline void interp7(Uint32 *pc, Uint32 c1, Uint32 c2, Uint32 c3)
91
//*pc = (c1*6+c2+c3)/8;
93
*pc = ((((c1 & 0x00FF00)*6 + (c2 & 0x00FF00) + (c3 & 0x00FF00) ) & 0x0007F800) +
94
(((c1 & 0xFF00FF)*6 + (c2 & 0xFF00FF) + (c3 & 0xFF00FF) ) & 0x07F807F8)) >> 3;
97
inline void interp8(Uint32 *pc, Uint32 c1, Uint32 c2)
99
//*pc = (c1*5+c2*3)/8;
101
*pc = ((((c1 & 0x00FF00)*5 + (c2 & 0x00FF00)*3 ) & 0x0007F800) +
102
(((c1 & 0xFF00FF)*5 + (c2 & 0xFF00FF)*3 ) & 0x07F807F8)) >> 3;
105
inline void interp9(Uint32 *pc, Uint32 c1, Uint32 c2, Uint32 c3)
107
//*pc = (c1*2+(c2+c3)*3)/8;
109
*pc = ((((c1 & 0x00FF00)*2 + ((c2 & 0x00FF00) + (c3 & 0x00FF00))*3 ) & 0x0007F800) +
110
(((c1 & 0xFF00FF)*2 + ((c2 & 0xFF00FF) + (c3 & 0xFF00FF))*3 ) & 0x07F807F8)) >> 3;
113
inline void interp10(Uint32 *pc, Uint32 c1, Uint32 c2, Uint32 c3)
115
//*pc = (c1*14+c2+c3)/16;
117
*pc = ((((c1 & 0x00FF00)*14 + (c2 & 0x00FF00) + (c3 & 0x00FF00) ) & 0x000FF000) +
118
(((c1 & 0xFF00FF)*14 + (c2 & 0xFF00FF) + (c3 & 0xFF00FF) ) & 0x0FF00FF0)) >> 4;
121
inline bool diff(unsigned int w1, unsigned int w2)
123
Uint32 YUV1 = yuv_palette[w1];
124
Uint32 YUV2 = yuv_palette[w2];
125
return ( ( abs((YUV1 & Ymask) - (YUV2 & Ymask)) > trY ) ||
126
( abs((YUV1 & Umask) - (YUV2 & Umask)) > trU ) ||
127
( abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV ) );
131
#define PIXEL00_0 *(Uint32 *)dst = c[5];
132
#define PIXEL00_10 interp1((Uint32 *)dst, c[5], c[1]);
133
#define PIXEL00_11 interp1((Uint32 *)dst, c[5], c[4]);
134
#define PIXEL00_12 interp1((Uint32 *)dst, c[5], c[2]);
135
#define PIXEL00_20 interp2((Uint32 *)dst, c[5], c[4], c[2]);
136
#define PIXEL00_21 interp2((Uint32 *)dst, c[5], c[1], c[2]);
137
#define PIXEL00_22 interp2((Uint32 *)dst, c[5], c[1], c[4]);
138
#define PIXEL00_60 interp6((Uint32 *)dst, c[5], c[2], c[4]);
139
#define PIXEL00_61 interp6((Uint32 *)dst, c[5], c[4], c[2]);
140
#define PIXEL00_70 interp7((Uint32 *)dst, c[5], c[4], c[2]);
141
#define PIXEL00_90 interp9((Uint32 *)dst, c[5], c[4], c[2]);
142
#define PIXEL00_100 interp10((Uint32 *)dst, c[5], c[4], c[2]);
143
#define PIXEL01_0 *(Uint32 *)(dst + dst_Bpp) = c[5];
144
#define PIXEL01_10 interp1((Uint32 *)(dst + dst_Bpp), c[5], c[3]);
145
#define PIXEL01_11 interp1((Uint32 *)(dst + dst_Bpp), c[5], c[2]);
146
#define PIXEL01_12 interp1((Uint32 *)(dst + dst_Bpp), c[5], c[6]);
147
#define PIXEL01_20 interp2((Uint32 *)(dst + dst_Bpp), c[5], c[2], c[6]);
148
#define PIXEL01_21 interp2((Uint32 *)(dst + dst_Bpp), c[5], c[3], c[6]);
149
#define PIXEL01_22 interp2((Uint32 *)(dst + dst_Bpp), c[5], c[3], c[2]);
150
#define PIXEL01_60 interp6((Uint32 *)(dst + dst_Bpp), c[5], c[6], c[2]);
151
#define PIXEL01_61 interp6((Uint32 *)(dst + dst_Bpp), c[5], c[2], c[6]);
152
#define PIXEL01_70 interp7((Uint32 *)(dst + dst_Bpp), c[5], c[2], c[6]);
153
#define PIXEL01_90 interp9((Uint32 *)(dst + dst_Bpp), c[5], c[2], c[6]);
154
#define PIXEL01_100 interp10((Uint32 *)(dst + dst_Bpp), c[5], c[2], c[6]);
155
#define PIXEL10_0 *(Uint32 *)(dst + dst_pitch) = c[5];
156
#define PIXEL10_10 interp1((Uint32 *)(dst + dst_pitch), c[5], c[7]);
157
#define PIXEL10_11 interp1((Uint32 *)(dst + dst_pitch), c[5], c[8]);
158
#define PIXEL10_12 interp1((Uint32 *)(dst + dst_pitch), c[5], c[4]);
159
#define PIXEL10_20 interp2((Uint32 *)(dst + dst_pitch), c[5], c[8], c[4]);
160
#define PIXEL10_21 interp2((Uint32 *)(dst + dst_pitch), c[5], c[7], c[4]);
161
#define PIXEL10_22 interp2((Uint32 *)(dst + dst_pitch), c[5], c[7], c[8]);
162
#define PIXEL10_60 interp6((Uint32 *)(dst + dst_pitch), c[5], c[4], c[8]);
163
#define PIXEL10_61 interp6((Uint32 *)(dst + dst_pitch), c[5], c[8], c[4]);
164
#define PIXEL10_70 interp7((Uint32 *)(dst + dst_pitch), c[5], c[8], c[4]);
165
#define PIXEL10_90 interp9((Uint32 *)(dst + dst_pitch), c[5], c[8], c[4]);
166
#define PIXEL10_100 interp10((Uint32 *)(dst + dst_pitch), c[5], c[8], c[4]);
167
#define PIXEL11_0 *(Uint32 *)(dst + dst_pitch + dst_Bpp) = c[5];
168
#define PIXEL11_10 interp1((Uint32 *)(dst + dst_pitch + dst_Bpp), c[5], c[9]);
169
#define PIXEL11_11 interp1((Uint32 *)(dst + dst_pitch + dst_Bpp), c[5], c[6]);
170
#define PIXEL11_12 interp1((Uint32 *)(dst + dst_pitch + dst_Bpp), c[5], c[8]);
171
#define PIXEL11_20 interp2((Uint32 *)(dst + dst_pitch + dst_Bpp), c[5], c[6], c[8]);
172
#define PIXEL11_21 interp2((Uint32 *)(dst + dst_pitch + dst_Bpp), c[5], c[9], c[8]);
173
#define PIXEL11_22 interp2((Uint32 *)(dst + dst_pitch + dst_Bpp), c[5], c[9], c[6]);
174
#define PIXEL11_60 interp6((Uint32 *)(dst + dst_pitch + dst_Bpp), c[5], c[8], c[6]);
175
#define PIXEL11_61 interp6((Uint32 *)(dst + dst_pitch + dst_Bpp), c[5], c[6], c[8]);
176
#define PIXEL11_70 interp7((Uint32 *)(dst + dst_pitch + dst_Bpp), c[5], c[6], c[8]);
177
#define PIXEL11_90 interp9((Uint32 *)(dst + dst_pitch + dst_Bpp), c[5], c[6], c[8]);
178
#define PIXEL11_100 interp10((Uint32 *)(dst + dst_pitch + dst_Bpp), c[5], c[6], c[8]);
180
void hq2x_32( SDL_Surface *src_surface, SDL_Surface *dst_surface )
182
Uint8 *src = src_surface->pixels, *src_temp,
183
*dst = dst_surface->pixels, *dst_temp;
184
int src_pitch = src_surface->pitch,
185
dst_pitch = dst_surface->pitch;
186
const int dst_Bpp = 4; // dst_surface->format->BytesPerPixel
188
const int height = vga_height, // src_surface->h
189
width = vga_width; // src_surface->w
191
int prevline, nextline;
207
for (int j = 0; j < height; j++)
212
prevline = (j > 0) ? -width : 0;
213
nextline = (j < height - 1) ? width : 0;
215
for (int i = 0; i < width; i++)
217
w[2] = *(src + prevline);
219
w[8] = *(src + nextline);
223
w[1] = *(src + prevline - 1);
225
w[7] = *(src + nextline - 1);
234
w[3] = *(src + prevline + 1);
236
w[9] = *(src + nextline + 1);
246
YUV1 = yuv_palette[w[5]];
248
for (int k=1; k<=9; k++)
254
YUV2 = yuv_palette[w[k]];
255
if ( ( abs((YUV1 & Ymask) - (YUV2 & Ymask)) > trY ) ||
256
( abs((YUV1 & Umask) - (YUV2 & Umask)) > trU ) ||
257
( abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV ) )
263
for (int k=1; k<=9; k++)
264
c[k] = rgb_palette[w[k]] & 0xfcfcfcfc; // hq2x has a nasty inability to accept more than 6 bits for each component
427
if (diff(w[2], w[6]))
445
if (diff(w[6], w[8]))
460
if (diff(w[8], w[4]))
474
if (diff(w[4], w[2]))
547
if (diff(w[2], w[6]))
565
if (diff(w[6], w[8]))
580
if (diff(w[8], w[4]))
594
if (diff(w[4], w[2]))
610
if (diff(w[2], w[6]))
628
if (diff(w[2], w[6]))
645
if (diff(w[6], w[8]))
663
if (diff(w[6], w[8]))
680
if (diff(w[8], w[4]))
695
if (diff(w[8], w[4]))
712
if (diff(w[4], w[2]))
729
if (diff(w[4], w[2]))
810
if (diff(w[4], w[2]))
818
if (diff(w[2], w[6]))
834
if (diff(w[2], w[6]))
843
if (diff(w[6], w[8]))
858
if (diff(w[8], w[4]))
866
if (diff(w[6], w[8]))
879
if (diff(w[4], w[2]))
888
if (diff(w[8], w[4]))
901
if (diff(w[4], w[2]))
917
if (diff(w[2], w[6]))
934
if (diff(w[6], w[8]))
948
if (diff(w[8], w[4]))
962
if (diff(w[2], w[6]))
979
if (diff(w[6], w[8]))
993
if (diff(w[8], w[4]))
1006
if (diff(w[4], w[2]))
1117
if (diff(w[4], w[2]))
1125
if (diff(w[2], w[6]))
1140
if (diff(w[2], w[6]))
1149
if (diff(w[6], w[8]))
1163
if (diff(w[8], w[4]))
1171
if (diff(w[6], w[8]))
1183
if (diff(w[4], w[2]))
1192
if (diff(w[8], w[4]))
1205
if (diff(w[4], w[2]))
1214
if (diff(w[8], w[4]))
1227
if (diff(w[4], w[2]))
1235
if (diff(w[2], w[6]))
1250
if (diff(w[2], w[6]))
1259
if (diff(w[6], w[8]))
1273
if (diff(w[8], w[4]))
1281
if (diff(w[6], w[8]))
1293
if (diff(w[4], w[2]))
1301
if (diff(w[2], w[6]))
1309
if (diff(w[8], w[4]))
1317
if (diff(w[6], w[8]))
1330
if (diff(w[2], w[6]))
1348
if (diff(w[2], w[6]))
1365
if (diff(w[6], w[8]))
1383
if (diff(w[6], w[8]))
1400
if (diff(w[8], w[4]))
1415
if (diff(w[8], w[4]))
1432
if (diff(w[4], w[2]))
1449
if (diff(w[4], w[2]))
1467
if (diff(w[8], w[4]))
1480
if (diff(w[4], w[2]))
1496
if (diff(w[2], w[6]))
1513
if (diff(w[6], w[8]))
1526
if (diff(w[2], w[6]))
1543
if (diff(w[6], w[8]))
1557
if (diff(w[8], w[4]))
1570
if (diff(w[4], w[2]))
1651
if (diff(w[8], w[4]))
1659
if (diff(w[6], w[8]))
1671
if (diff(w[4], w[2]))
1679
if (diff(w[2], w[6]))
1693
if (diff(w[4], w[2]))
1702
if (diff(w[8], w[4]))
1716
if (diff(w[2], w[6]))
1725
if (diff(w[6], w[8]))
1737
if (diff(w[4], w[2]))
1745
if (diff(w[2], w[6]))
1761
if (diff(w[8], w[4]))
1769
if (diff(w[6], w[8]))
1782
if (diff(w[2], w[6]))
1791
if (diff(w[6], w[8]))
1803
if (diff(w[4], w[2]))
1812
if (diff(w[8], w[4]))
1825
if (diff(w[4], w[2]))
1833
if (diff(w[2], w[6]))
1841
if (diff(w[8], w[4]))
1849
if (diff(w[6], w[8]))
1861
if (diff(w[4], w[2]))
1869
if (diff(w[2], w[6]))
1877
if (diff(w[8], w[4]))
1885
if (diff(w[6], w[8]))
1897
if (diff(w[4], w[2]))
1905
if (diff(w[2], w[6]))
1913
if (diff(w[8], w[4]))
1921
if (diff(w[6], w[8]))
1933
if (diff(w[4], w[2]))
1941
if (diff(w[2], w[6]))
1949
if (diff(w[8], w[4]))
1957
if (diff(w[6], w[8]))
2001
if (diff(w[4], w[2]))
2009
if (diff(w[2], w[6]))
2024
if (diff(w[2], w[6]))
2033
if (diff(w[6], w[8]))
2047
if (diff(w[8], w[4]))
2055
if (diff(w[6], w[8]))
2067
if (diff(w[4], w[2]))
2076
if (diff(w[8], w[4]))
2092
if (diff(w[8], w[4]))
2106
if (diff(w[4], w[2]))
2123
if (diff(w[2], w[6]))
2141
if (diff(w[6], w[8]))
2170
if (diff(w[2], w[6]))
2178
if (diff(w[8], w[4]))
2191
if (diff(w[4], w[2]))
2201
if (diff(w[6], w[8]))
2213
if (diff(w[8], w[4]))
2230
if (diff(w[6], w[8]))
2245
if (diff(w[4], w[2]))
2263
if (diff(w[8], w[4]))
2278
if (diff(w[2], w[6]))
2293
if (diff(w[4], w[2]))
2311
if (diff(w[6], w[8]))
2325
if (diff(w[2], w[6]))
2344
if (diff(w[8], w[4]))
2358
if (diff(w[4], w[2]))
2375
if (diff(w[2], w[6]))
2393
if (diff(w[6], w[8]))
2407
if (diff(w[8], w[4]))
2415
if (diff(w[6], w[8]))
2427
if (diff(w[4], w[2]))
2436
if (diff(w[8], w[4]))
2449
if (diff(w[4], w[2]))
2457
if (diff(w[2], w[6]))
2472
if (diff(w[2], w[6]))
2481
if (diff(w[6], w[8]))
2495
if (diff(w[8], w[4]))
2503
if (diff(w[6], w[8]))
2517
if (diff(w[8], w[4]))
2525
if (diff(w[6], w[8]))
2537
if (diff(w[4], w[2]))
2546
if (diff(w[8], w[4]))
2559
if (diff(w[4], w[2]))
2568
if (diff(w[8], w[4]))
2581
if (diff(w[4], w[2]))
2589
if (diff(w[2], w[6]))
2603
if (diff(w[4], w[2]))
2611
if (diff(w[2], w[6]))
2626
if (diff(w[2], w[6]))
2635
if (diff(w[6], w[8]))
2648
if (diff(w[2], w[6]))
2657
if (diff(w[6], w[8]))
2670
if (diff(w[2], w[6]))
2678
if (diff(w[8], w[4]))
2686
if (diff(w[6], w[8]))
2700
if (diff(w[8], w[4]))
2708
if (diff(w[6], w[8]))
2720
if (diff(w[4], w[2]))
2729
if (diff(w[8], w[4]))
2737
if (diff(w[6], w[8]))
2749
if (diff(w[4], w[2]))
2758
if (diff(w[8], w[4]))
2771
if (diff(w[4], w[2]))
2779
if (diff(w[2], w[6]))
2787
if (diff(w[8], w[4]))
2800
if (diff(w[4], w[2]))
2808
if (diff(w[2], w[6]))
2822
if (diff(w[4], w[2]))
2830
if (diff(w[2], w[6]))
2839
if (diff(w[6], w[8]))
2852
if (diff(w[2], w[6]))
2861
if (diff(w[6], w[8]))
2873
if (diff(w[4], w[2]))
2881
if (diff(w[2], w[6]))
2889
if (diff(w[8], w[4]))
2897
if (diff(w[6], w[8]))
2913
src = src_temp + src_pitch;
2914
dst = dst_temp + 2 * dst_pitch;
2919
#define PIXEL00_1M interp1((Uint32 *)dst, c[5], c[1]);
2920
#define PIXEL00_1U interp1((Uint32 *)dst, c[5], c[2]);
2921
#define PIXEL00_1L interp1((Uint32 *)dst, c[5], c[4]);
2922
#define PIXEL00_2 interp2((Uint32 *)dst, c[5], c[4], c[2]);
2923
#define PIXEL00_4 interp4((Uint32 *)dst, c[5], c[4], c[2]);
2924
#define PIXEL00_5 interp5((Uint32 *)dst, c[4], c[2]);
2925
#define PIXEL00_C *(Uint32 *)dst = c[5];
2927
#define PIXEL01_1 interp1((Uint32 *)(dst + dst_Bpp), c[5], c[2]);
2928
#define PIXEL01_3 interp3((Uint32 *)(dst + dst_Bpp), c[5], c[2]);
2929
#define PIXEL01_6 interp1((Uint32 *)(dst + dst_Bpp), c[2], c[5]);
2930
#define PIXEL01_C *(Uint32 *)(dst + dst_Bpp) = c[5];
2932
#define PIXEL02_1M interp1((Uint32 *)(dst + 2 * dst_Bpp), c[5], c[3]);
2933
#define PIXEL02_1U interp1((Uint32 *)(dst + 2 * dst_Bpp), c[5], c[2]);
2934
#define PIXEL02_1R interp1((Uint32 *)(dst + 2 * dst_Bpp), c[5], c[6]);
2935
#define PIXEL02_2 interp2((Uint32 *)(dst + 2 * dst_Bpp), c[5], c[2], c[6]);
2936
#define PIXEL02_4 interp4((Uint32 *)(dst + 2 * dst_Bpp), c[5], c[2], c[6]);
2937
#define PIXEL02_5 interp5((Uint32 *)(dst + 2 * dst_Bpp), c[2], c[6]);
2938
#define PIXEL02_C *(Uint32 *)(dst + 2 * dst_Bpp) = c[5];
2940
#define PIXEL10_1 interp1((Uint32 *)(dst + dst_pitch), c[5], c[4]);
2941
#define PIXEL10_3 interp3((Uint32 *)(dst + dst_pitch), c[5], c[4]);
2942
#define PIXEL10_6 interp1((Uint32 *)(dst + dst_pitch), c[4], c[5]);
2943
#define PIXEL10_C *(Uint32 *)(dst + dst_pitch) = c[5];
2945
#define PIXEL11 *(Uint32 *)(dst + dst_pitch + dst_Bpp) = c[5];
2947
#define PIXEL12_1 interp1((Uint32 *)(dst + dst_pitch + 2 * dst_Bpp), c[5], c[6]);
2948
#define PIXEL12_3 interp3((Uint32 *)(dst + dst_pitch + 2 * dst_Bpp), c[5], c[6]);
2949
#define PIXEL12_6 interp1((Uint32 *)(dst + dst_pitch + 2 * dst_Bpp), c[6], c[5]);
2950
#define PIXEL12_C *(Uint32 *)(dst + dst_pitch + 2 * dst_Bpp) = c[5];
2952
#define PIXEL20_1M interp1((Uint32 *)(dst + 2 * dst_pitch), c[5], c[7]);
2953
#define PIXEL20_1D interp1((Uint32 *)(dst + 2 * dst_pitch), c[5], c[8]);
2954
#define PIXEL20_1L interp1((Uint32 *)(dst + 2 * dst_pitch), c[5], c[4]);
2955
#define PIXEL20_2 interp2((Uint32 *)(dst + 2 * dst_pitch), c[5], c[8], c[4]);
2956
#define PIXEL20_4 interp4((Uint32 *)(dst + 2 * dst_pitch), c[5], c[8], c[4]);
2957
#define PIXEL20_5 interp5((Uint32 *)(dst + 2 * dst_pitch), c[8], c[4]);
2958
#define PIXEL20_C *(Uint32 *)(dst + 2 * dst_pitch) = c[5];
2960
#define PIXEL21_1 interp1((Uint32 *)(dst + 2 * dst_pitch + dst_Bpp), c[5], c[8]);
2961
#define PIXEL21_3 interp3((Uint32 *)(dst + 2 * dst_pitch + dst_Bpp), c[5], c[8]);
2962
#define PIXEL21_6 interp1((Uint32 *)(dst + 2 * dst_pitch + dst_Bpp), c[8], c[5]);
2963
#define PIXEL21_C *(Uint32 *)(dst + 2 * dst_pitch + dst_Bpp) = c[5];
2965
#define PIXEL22_1M interp1((Uint32 *)(dst + 2 * dst_pitch + 2 * dst_Bpp), c[5], c[9]);
2966
#define PIXEL22_1D interp1((Uint32 *)(dst + 2 * dst_pitch + 2 * dst_Bpp), c[5], c[8]);
2967
#define PIXEL22_1R interp1((Uint32 *)(dst + 2 * dst_pitch + 2 * dst_Bpp), c[5], c[6]);
2968
#define PIXEL22_2 interp2((Uint32 *)(dst + 2 * dst_pitch + 2 * dst_Bpp), c[5], c[6], c[8]);
2969
#define PIXEL22_4 interp4((Uint32 *)(dst + 2 * dst_pitch + 2 * dst_Bpp), c[5], c[6], c[8]);
2970
#define PIXEL22_5 interp5((Uint32 *)(dst + 2 * dst_pitch + 2 * dst_Bpp), c[6], c[8]);
2971
#define PIXEL22_C *(Uint32 *)(dst + 2 * dst_pitch + 2 * dst_Bpp) = c[5];
2973
void hq3x_32( SDL_Surface *src_surface, SDL_Surface *dst_surface )
2975
Uint8 *src = src_surface->pixels, *src_temp,
2976
*dst = dst_surface->pixels, *dst_temp;
2977
int src_pitch = src_surface->pitch,
2978
dst_pitch = dst_surface->pitch;
2979
const int dst_Bpp = 4; // dst_surface->format->BytesPerPixel
2981
const int height = vga_height, // src_surface->h
2982
width = vga_width; // src_surface->w
2984
int prevline, nextline;
3000
for (int j = 0; j < height; j++)
3005
prevline = (j > 0) ? -width : 0;
3006
nextline = (j < height - 1) ? width : 0;
3008
for (int i = 0; i < width; i++)
3010
w[2] = *(src + prevline);
3012
w[8] = *(src + nextline);
3016
w[1] = *(src + prevline - 1);
3018
w[7] = *(src + nextline - 1);
3027
w[3] = *(src + prevline + 1);
3029
w[9] = *(src + nextline + 1);
3039
YUV1 = yuv_palette[w[5]];
3041
for (int k=1; k<=9; k++)
3047
YUV2 = yuv_palette[w[k]];
3048
if ( ( abs((YUV1 & Ymask) - (YUV2 & Ymask)) > trY ) ||
3049
( abs((YUV1 & Umask) - (YUV2 & Umask)) > trU ) ||
3050
( abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV ) )
3056
for (int k=1; k<=9; k++)
3057
c[k] = rgb_palette[w[k]] & 0xfcfcfcfc; // hq3x has a nasty inability to accept more than 6 bits for each component
3285
if (diff(w[2], w[6]))
3313
if (diff(w[6], w[8]))
3335
if (diff(w[8], w[4]))
3353
if (diff(w[4], w[2]))
3463
if (diff(w[2], w[6]))
3491
if (diff(w[6], w[8]))
3513
if (diff(w[8], w[4]))
3531
if (diff(w[4], w[2]))
3554
if (diff(w[2], w[6]))
3578
if (diff(w[2], w[6]))
3602
if (diff(w[6], w[8]))
3626
if (diff(w[6], w[8]))
3650
if (diff(w[8], w[4]))
3674
if (diff(w[8], w[4]))
3698
if (diff(w[4], w[2]))
3722
if (diff(w[4], w[2]))
3850
if (diff(w[4], w[2]))
3861
if (diff(w[2], w[6]))
3881
if (diff(w[2], w[6]))
3895
if (diff(w[6], w[8]))
3914
if (diff(w[8], w[4]))
3925
if (diff(w[6], w[8]))
3940
if (diff(w[4], w[2]))
3954
if (diff(w[8], w[4]))
3969
if (diff(w[4], w[2]))
3992
if (diff(w[2], w[6]))
4019
if (diff(w[6], w[8]))
4040
if (diff(w[8], w[4]))
4058
if (diff(w[2], w[6]))
4085
if (diff(w[6], w[8]))
4106
if (diff(w[8], w[4]))
4123
if (diff(w[4], w[2]))
4301
if (diff(w[4], w[2]))
4310
if (diff(w[2], w[6]))
4330
if (diff(w[2], w[6]))
4343
if (diff(w[6], w[8]))
4361
if (diff(w[8], w[4]))
4370
if (diff(w[6], w[8]))
4382
if (diff(w[4], w[2]))
4395
if (diff(w[8], w[4]))
4409
if (diff(w[4], w[2]))
4422
if (diff(w[8], w[4]))
4436
if (diff(w[4], w[2]))
4445
if (diff(w[2], w[6]))
4465
if (diff(w[2], w[6]))
4478
if (diff(w[6], w[8]))
4496
if (diff(w[8], w[4]))
4505
if (diff(w[6], w[8]))
4517
if (diff(w[4], w[2]))
4526
if (diff(w[2], w[6]))
4537
if (diff(w[8], w[4]))
4546
if (diff(w[6], w[8]))
4559
if (diff(w[2], w[6]))
4583
if (diff(w[2], w[6]))
4607
if (diff(w[6], w[8]))
4631
if (diff(w[6], w[8]))
4655
if (diff(w[8], w[4]))
4679
if (diff(w[8], w[4]))
4703
if (diff(w[4], w[2]))
4727
if (diff(w[4], w[2]))
4755
if (diff(w[8], w[4]))
4772
if (diff(w[4], w[2]))
4795
if (diff(w[2], w[6]))
4822
if (diff(w[6], w[8]))
4839
if (diff(w[2], w[6]))
4866
if (diff(w[6], w[8]))
4887
if (diff(w[8], w[4]))
4904
if (diff(w[4], w[2]))
5035
if (diff(w[8], w[4]))
5043
if (diff(w[6], w[8]))
5059
if (diff(w[4], w[2]))
5067
if (diff(w[2], w[6]))
5088
if (diff(w[4], w[2]))
5100
if (diff(w[8], w[4]))
5119
if (diff(w[2], w[6]))
5130
if (diff(w[6], w[8]))
5146
if (diff(w[4], w[2]))
5158
if (diff(w[2], w[6]))
5180
if (diff(w[8], w[4]))
5192
if (diff(w[6], w[8]))
5205
if (diff(w[2], w[6]))
5221
if (diff(w[6], w[8]))
5233
if (diff(w[4], w[2]))
5248
if (diff(w[8], w[4]))
5262
if (diff(w[4], w[2]))
5271
if (diff(w[2], w[6]))
5281
if (diff(w[8], w[4]))
5293
if (diff(w[6], w[8]))
5305
if (diff(w[4], w[2]))
5313
if (diff(w[2], w[6]))
5327
if (diff(w[8], w[4]))
5336
if (diff(w[6], w[8]))
5348
if (diff(w[4], w[2]))
5357
if (diff(w[2], w[6]))
5367
if (diff(w[8], w[4]))
5375
if (diff(w[6], w[8]))
5391
if (diff(w[4], w[2]))
5403
if (diff(w[2], w[6]))
5413
if (diff(w[8], w[4]))
5422
if (diff(w[6], w[8]))
5486
if (diff(w[4], w[2]))
5495
if (diff(w[2], w[6]))
5515
if (diff(w[2], w[6]))
5528
if (diff(w[6], w[8]))
5546
if (diff(w[8], w[4]))
5555
if (diff(w[6], w[8]))
5567
if (diff(w[4], w[2]))
5580
if (diff(w[8], w[4]))
5601
if (diff(w[8], w[4]))
5616
if (diff(w[4], w[2]))
5639
if (diff(w[2], w[6]))
5666
if (diff(w[6], w[8]))
5705
if (diff(w[2], w[6]))
5718
if (diff(w[8], w[4]))
5735
if (diff(w[4], w[2]))
5750
if (diff(w[6], w[8]))
5766
if (diff(w[8], w[4]))
5789
if (diff(w[6], w[8]))
5812
if (diff(w[4], w[2]))
5835
if (diff(w[8], w[4]))
5858
if (diff(w[2], w[6]))
5881
if (diff(w[4], w[2]))
5904
if (diff(w[6], w[8]))
5927
if (diff(w[2], w[6]))
5957
if (diff(w[8], w[4]))
5972
if (diff(w[4], w[2]))
5995
if (diff(w[2], w[6]))
6022
if (diff(w[6], w[8]))
6038
if (diff(w[8], w[4]))
6049
if (diff(w[6], w[8]))
6063
if (diff(w[4], w[2]))
6077
if (diff(w[8], w[4]))
6092
if (diff(w[4], w[2]))
6103
if (diff(w[2], w[6]))
6122
if (diff(w[2], w[6]))
6136
if (diff(w[6], w[8]))
6155
if (diff(w[8], w[4]))
6166
if (diff(w[6], w[8]))
6183
if (diff(w[8], w[4]))
6192
if (diff(w[6], w[8]))
6206
if (diff(w[4], w[2]))
6220
if (diff(w[8], w[4]))
6234
if (diff(w[4], w[2]))
6247
if (diff(w[8], w[4]))
6262
if (diff(w[4], w[2]))
6271
if (diff(w[2], w[6]))
6290
if (diff(w[4], w[2]))
6301
if (diff(w[2], w[6]))
6320
if (diff(w[2], w[6]))
6332
if (diff(w[6], w[8]))
6347
if (diff(w[2], w[6]))
6362
if (diff(w[6], w[8]))
6375
if (diff(w[2], w[6]))
6386
if (diff(w[8], w[4]))
6396
if (diff(w[6], w[8]))
6418
if (diff(w[8], w[4]))
6427
if (diff(w[6], w[8]))
6439
if (diff(w[4], w[2]))
6451
if (diff(w[8], w[4]))
6463
if (diff(w[6], w[8]))
6477
if (diff(w[4], w[2]))
6490
if (diff(w[8], w[4]))
6504
if (diff(w[4], w[2]))
6516
if (diff(w[2], w[6]))
6527
if (diff(w[8], w[4]))
6542
if (diff(w[4], w[2]))
6551
if (diff(w[2], w[6]))
6569
if (diff(w[4], w[2]))
6579
if (diff(w[2], w[6]))
6593
if (diff(w[6], w[8]))
6609
if (diff(w[2], w[6]))
6622
if (diff(w[6], w[8]))
6634
if (diff(w[4], w[2]))
6643
if (diff(w[2], w[6]))
6654
if (diff(w[8], w[4]))
6663
if (diff(w[6], w[8]))
6679
src = src_temp + src_pitch;
6680
dst = dst_temp + 3 * dst_pitch;
6685
#define PIXEL4_00_0 *(Uint32 *)(dst) = c[5];
6686
#define PIXEL4_00_11 interp1((Uint32 *)(dst), c[5], c[4]);
6687
#define PIXEL4_00_12 interp1((Uint32 *)(dst), c[5], c[2]);
6688
#define PIXEL4_00_20 interp2((Uint32 *)(dst), c[5], c[2], c[4]);
6689
#define PIXEL4_00_50 interp5((Uint32 *)(dst), c[2], c[4]);
6690
#define PIXEL4_00_80 interp8((Uint32 *)(dst), c[5], c[1]);
6691
#define PIXEL4_00_81 interp8((Uint32 *)(dst), c[5], c[4]);
6692
#define PIXEL4_00_82 interp8((Uint32 *)(dst), c[5], c[2]);
6693
#define PIXEL4_01_0 *(Uint32 *)(dst + dst_Bpp) = c[5];
6694
#define PIXEL4_01_10 interp1((Uint32 *)(dst + dst_Bpp), c[5], c[1]);
6695
#define PIXEL4_01_12 interp1((Uint32 *)(dst + dst_Bpp), c[5], c[2]);
6696
#define PIXEL4_01_14 interp1((Uint32 *)(dst + dst_Bpp), c[2], c[5]);
6697
#define PIXEL4_01_21 interp2((Uint32 *)(dst + dst_Bpp), c[2], c[5], c[4]);
6698
#define PIXEL4_01_31 interp3((Uint32 *)(dst + dst_Bpp), c[5], c[4]);
6699
#define PIXEL4_01_50 interp5((Uint32 *)(dst + dst_Bpp), c[2], c[5]);
6700
#define PIXEL4_01_60 interp6((Uint32 *)(dst + dst_Bpp), c[5], c[2], c[4]);
6701
#define PIXEL4_01_61 interp6((Uint32 *)(dst + dst_Bpp), c[5], c[2], c[1]);
6702
#define PIXEL4_01_82 interp8((Uint32 *)(dst + dst_Bpp), c[5], c[2]);
6703
#define PIXEL4_01_83 interp8((Uint32 *)(dst + dst_Bpp), c[2], c[4]);
6704
#define PIXEL4_02_0 *(Uint32 *)(dst + 2 * dst_Bpp) = c[5];
6705
#define PIXEL4_02_10 interp1((Uint32 *)(dst + 2 * dst_Bpp), c[5], c[3]);
6706
#define PIXEL4_02_11 interp1((Uint32 *)(dst + 2 * dst_Bpp), c[5], c[2]);
6707
#define PIXEL4_02_13 interp1((Uint32 *)(dst + 2 * dst_Bpp), c[2], c[5]);
6708
#define PIXEL4_02_21 interp2((Uint32 *)(dst + 2 * dst_Bpp), c[2], c[5], c[6]);
6709
#define PIXEL4_02_32 interp3((Uint32 *)(dst + 2 * dst_Bpp), c[5], c[6]);
6710
#define PIXEL4_02_50 interp5((Uint32 *)(dst + 2 * dst_Bpp), c[2], c[5]);
6711
#define PIXEL4_02_60 interp6((Uint32 *)(dst + 2 * dst_Bpp), c[5], c[2], c[6]);
6712
#define PIXEL4_02_61 interp6((Uint32 *)(dst + 2 * dst_Bpp), c[5], c[2], c[3]);
6713
#define PIXEL4_02_81 interp8((Uint32 *)(dst + 2 * dst_Bpp), c[5], c[2]);
6714
#define PIXEL4_02_83 interp8((Uint32 *)(dst + 2 * dst_Bpp), c[2], c[6]);
6715
#define PIXEL4_03_0 *(Uint32 *)(dst + 3 * dst_Bpp) = c[5];
6716
#define PIXEL4_03_11 interp1((Uint32 *)(dst + 3 * dst_Bpp), c[5], c[2]);
6717
#define PIXEL4_03_12 interp1((Uint32 *)(dst + 3 * dst_Bpp), c[5], c[6]);
6718
#define PIXEL4_03_20 interp2((Uint32 *)(dst + 3 * dst_Bpp), c[5], c[2], c[6]);
6719
#define PIXEL4_03_50 interp5((Uint32 *)(dst + 3 * dst_Bpp), c[2], c[6]);
6720
#define PIXEL4_03_80 interp8((Uint32 *)(dst + 3 * dst_Bpp), c[5], c[3]);
6721
#define PIXEL4_03_81 interp8((Uint32 *)(dst + 3 * dst_Bpp), c[5], c[2]);
6722
#define PIXEL4_03_82 interp8((Uint32 *)(dst + 3 * dst_Bpp), c[5], c[6]);
6723
#define PIXEL4_10_0 *(Uint32 *)(dst + dst_pitch) = c[5];
6724
#define PIXEL4_10_10 interp1((Uint32 *)(dst + dst_pitch ), c[5], c[1]);
6725
#define PIXEL4_10_11 interp1((Uint32 *)(dst + dst_pitch ), c[5], c[4]);
6726
#define PIXEL4_10_13 interp1((Uint32 *)(dst + dst_pitch ), c[4], c[5]);
6727
#define PIXEL4_10_21 interp2((Uint32 *)(dst + dst_pitch ), c[4], c[5], c[2]);
6728
#define PIXEL4_10_32 interp3((Uint32 *)(dst + dst_pitch ), c[5], c[2]);
6729
#define PIXEL4_10_50 interp5((Uint32 *)(dst + dst_pitch ), c[4], c[5]);
6730
#define PIXEL4_10_60 interp6((Uint32 *)(dst + dst_pitch ), c[5], c[4], c[2]);
6731
#define PIXEL4_10_61 interp6((Uint32 *)(dst + dst_pitch ), c[5], c[4], c[1]);
6732
#define PIXEL4_10_81 interp8((Uint32 *)(dst + dst_pitch ), c[5], c[4]);
6733
#define PIXEL4_10_83 interp8((Uint32 *)(dst + dst_pitch ), c[4], c[2]);
6734
#define PIXEL4_11_0 *(Uint32 *)(dst + dst_pitch + dst_Bpp) = c[5];
6735
#define PIXEL4_11_30 interp3((Uint32 *)(dst + dst_pitch + dst_Bpp), c[5], c[1]);
6736
#define PIXEL4_11_31 interp3((Uint32 *)(dst + dst_pitch + dst_Bpp), c[5], c[4]);
6737
#define PIXEL4_11_32 interp3((Uint32 *)(dst + dst_pitch + dst_Bpp), c[5], c[2]);
6738
#define PIXEL4_11_70 interp7((Uint32 *)(dst + dst_pitch + dst_Bpp), c[5], c[4], c[2]);
6739
#define PIXEL4_12_0 *(Uint32 *)(dst + dst_pitch + 2 * dst_Bpp) = c[5];
6740
#define PIXEL4_12_30 interp3((Uint32 *)(dst + dst_pitch + 2 * dst_Bpp), c[5], c[3]);
6741
#define PIXEL4_12_31 interp3((Uint32 *)(dst + dst_pitch + 2 * dst_Bpp), c[5], c[2]);
6742
#define PIXEL4_12_32 interp3((Uint32 *)(dst + dst_pitch + 2 * dst_Bpp), c[5], c[6]);
6743
#define PIXEL4_12_70 interp7((Uint32 *)(dst + dst_pitch + 2 * dst_Bpp), c[5], c[6], c[2]);
6744
#define PIXEL4_13_0 *(Uint32 *)(dst + dst_pitch + 3 * dst_Bpp) = c[5];
6745
#define PIXEL4_13_10 interp1((Uint32 *)(dst + dst_pitch + 3 * dst_Bpp), c[5], c[3]);
6746
#define PIXEL4_13_12 interp1((Uint32 *)(dst + dst_pitch + 3 * dst_Bpp), c[5], c[6]);
6747
#define PIXEL4_13_14 interp1((Uint32 *)(dst + dst_pitch + 3 * dst_Bpp), c[6], c[5]);
6748
#define PIXEL4_13_21 interp2((Uint32 *)(dst + dst_pitch + 3 * dst_Bpp), c[6], c[5], c[2]);
6749
#define PIXEL4_13_31 interp3((Uint32 *)(dst + dst_pitch + 3 * dst_Bpp), c[5], c[2]);
6750
#define PIXEL4_13_50 interp5((Uint32 *)(dst + dst_pitch + 3 * dst_Bpp), c[6], c[5]);
6751
#define PIXEL4_13_60 interp6((Uint32 *)(dst + dst_pitch + 3 * dst_Bpp), c[5], c[6], c[2]);
6752
#define PIXEL4_13_61 interp6((Uint32 *)(dst + dst_pitch + 3 * dst_Bpp), c[5], c[6], c[3]);
6753
#define PIXEL4_13_82 interp8((Uint32 *)(dst + dst_pitch + 3 * dst_Bpp), c[5], c[6]);
6754
#define PIXEL4_13_83 interp8((Uint32 *)(dst + dst_pitch + 3 * dst_Bpp), c[6], c[2]);
6755
#define PIXEL4_20_0 *(Uint32 *)(dst + 2 * dst_pitch) = c[5];
6756
#define PIXEL4_20_10 interp1((Uint32 *)(dst + 2 * dst_pitch ), c[5], c[7]);
6757
#define PIXEL4_20_12 interp1((Uint32 *)(dst + 2 * dst_pitch ), c[5], c[4]);
6758
#define PIXEL4_20_14 interp1((Uint32 *)(dst + 2 * dst_pitch ), c[4], c[5]);
6759
#define PIXEL4_20_21 interp2((Uint32 *)(dst + 2 * dst_pitch ), c[4], c[5], c[8]);
6760
#define PIXEL4_20_31 interp3((Uint32 *)(dst + 2 * dst_pitch ), c[5], c[8]);
6761
#define PIXEL4_20_50 interp5((Uint32 *)(dst + 2 * dst_pitch ), c[4], c[5]);
6762
#define PIXEL4_20_60 interp6((Uint32 *)(dst + 2 * dst_pitch ), c[5], c[4], c[8]);
6763
#define PIXEL4_20_61 interp6((Uint32 *)(dst + 2 * dst_pitch ), c[5], c[4], c[7]);
6764
#define PIXEL4_20_82 interp8((Uint32 *)(dst + 2 * dst_pitch ), c[5], c[4]);
6765
#define PIXEL4_20_83 interp8((Uint32 *)(dst + 2 * dst_pitch ), c[4], c[8]);
6766
#define PIXEL4_21_0 *(Uint32 *)(dst + 2 * dst_pitch + dst_Bpp) = c[5];
6767
#define PIXEL4_21_30 interp3((Uint32 *)(dst + 2 * dst_pitch + dst_Bpp), c[5], c[7]);
6768
#define PIXEL4_21_31 interp3((Uint32 *)(dst + 2 * dst_pitch + dst_Bpp), c[5], c[8]);
6769
#define PIXEL4_21_32 interp3((Uint32 *)(dst + 2 * dst_pitch + dst_Bpp), c[5], c[4]);
6770
#define PIXEL4_21_70 interp7((Uint32 *)(dst + 2 * dst_pitch + dst_Bpp), c[5], c[4], c[8]);
6771
#define PIXEL4_22_0 *(Uint32 *)(dst + 2 * dst_pitch + 2 * dst_Bpp) = c[5];
6772
#define PIXEL4_22_30 interp3((Uint32 *)(dst + 2 * dst_pitch + 2 * dst_Bpp), c[5], c[9]);
6773
#define PIXEL4_22_31 interp3((Uint32 *)(dst + 2 * dst_pitch + 2 * dst_Bpp), c[5], c[6]);
6774
#define PIXEL4_22_32 interp3((Uint32 *)(dst + 2 * dst_pitch + 2 * dst_Bpp), c[5], c[8]);
6775
#define PIXEL4_22_70 interp7((Uint32 *)(dst + 2 * dst_pitch + 2 * dst_Bpp), c[5], c[6], c[8]);
6776
#define PIXEL4_23_0 *(Uint32 *)(dst + 2 * dst_pitch + 3 * dst_Bpp) = c[5];
6777
#define PIXEL4_23_10 interp1((Uint32 *)(dst + 2 * dst_pitch + 3 * dst_Bpp), c[5], c[9]);
6778
#define PIXEL4_23_11 interp1((Uint32 *)(dst + 2 * dst_pitch + 3 * dst_Bpp), c[5], c[6]);
6779
#define PIXEL4_23_13 interp1((Uint32 *)(dst + 2 * dst_pitch + 3 * dst_Bpp), c[6], c[5]);
6780
#define PIXEL4_23_21 interp2((Uint32 *)(dst + 2 * dst_pitch + 3 * dst_Bpp), c[6], c[5], c[8]);
6781
#define PIXEL4_23_32 interp3((Uint32 *)(dst + 2 * dst_pitch + 3 * dst_Bpp), c[5], c[8]);
6782
#define PIXEL4_23_50 interp5((Uint32 *)(dst + 2 * dst_pitch + 3 * dst_Bpp), c[6], c[5]);
6783
#define PIXEL4_23_60 interp6((Uint32 *)(dst + 2 * dst_pitch + 3 * dst_Bpp), c[5], c[6], c[8]);
6784
#define PIXEL4_23_61 interp6((Uint32 *)(dst + 2 * dst_pitch + 3 * dst_Bpp), c[5], c[6], c[9]);
6785
#define PIXEL4_23_81 interp8((Uint32 *)(dst + 2 * dst_pitch + 3 * dst_Bpp), c[5], c[6]);
6786
#define PIXEL4_23_83 interp8((Uint32 *)(dst + 2 * dst_pitch + 3 * dst_Bpp), c[6], c[8]);
6787
#define PIXEL4_30_0 *(Uint32 *)(dst + 3 * dst_pitch) = c[5];
6788
#define PIXEL4_30_11 interp1((Uint32 *)(dst + 3 * dst_pitch ), c[5], c[8]);
6789
#define PIXEL4_30_12 interp1((Uint32 *)(dst + 3 * dst_pitch ), c[5], c[4]);
6790
#define PIXEL4_30_20 interp2((Uint32 *)(dst + 3 * dst_pitch ), c[5], c[8], c[4]);
6791
#define PIXEL4_30_50 interp5((Uint32 *)(dst + 3 * dst_pitch ), c[8], c[4]);
6792
#define PIXEL4_30_80 interp8((Uint32 *)(dst + 3 * dst_pitch ), c[5], c[7]);
6793
#define PIXEL4_30_81 interp8((Uint32 *)(dst + 3 * dst_pitch ), c[5], c[8]);
6794
#define PIXEL4_30_82 interp8((Uint32 *)(dst + 3 * dst_pitch ), c[5], c[4]);
6795
#define PIXEL4_31_0 *(Uint32 *)(dst + 3 * dst_pitch + dst_Bpp) = c[5];
6796
#define PIXEL4_31_10 interp1((Uint32 *)(dst + 3 * dst_pitch + dst_Bpp), c[5], c[7]);
6797
#define PIXEL4_31_11 interp1((Uint32 *)(dst + 3 * dst_pitch + dst_Bpp), c[5], c[8]);
6798
#define PIXEL4_31_13 interp1((Uint32 *)(dst + 3 * dst_pitch + dst_Bpp), c[8], c[5]);
6799
#define PIXEL4_31_21 interp2((Uint32 *)(dst + 3 * dst_pitch + dst_Bpp), c[8], c[5], c[4]);
6800
#define PIXEL4_31_32 interp3((Uint32 *)(dst + 3 * dst_pitch + dst_Bpp), c[5], c[4]);
6801
#define PIXEL4_31_50 interp5((Uint32 *)(dst + 3 * dst_pitch + dst_Bpp), c[8], c[5]);
6802
#define PIXEL4_31_60 interp6((Uint32 *)(dst + 3 * dst_pitch + dst_Bpp), c[5], c[8], c[4]);
6803
#define PIXEL4_31_61 interp6((Uint32 *)(dst + 3 * dst_pitch + dst_Bpp), c[5], c[8], c[7]);
6804
#define PIXEL4_31_81 interp8((Uint32 *)(dst + 3 * dst_pitch + dst_Bpp), c[5], c[8]);
6805
#define PIXEL4_31_83 interp8((Uint32 *)(dst + 3 * dst_pitch + dst_Bpp), c[8], c[4]);
6806
#define PIXEL4_32_0 *(Uint32 *)(dst + 3 * dst_pitch + 2 * dst_Bpp) = c[5];
6807
#define PIXEL4_32_10 interp1((Uint32 *)(dst + 3 * dst_pitch + 2 * dst_Bpp), c[5], c[9]);
6808
#define PIXEL4_32_12 interp1((Uint32 *)(dst + 3 * dst_pitch + 2 * dst_Bpp), c[5], c[8]);
6809
#define PIXEL4_32_14 interp1((Uint32 *)(dst + 3 * dst_pitch + 2 * dst_Bpp), c[8], c[5]);
6810
#define PIXEL4_32_21 interp2((Uint32 *)(dst + 3 * dst_pitch + 2 * dst_Bpp), c[8], c[5], c[6]);
6811
#define PIXEL4_32_31 interp3((Uint32 *)(dst + 3 * dst_pitch + 2 * dst_Bpp), c[5], c[6]);
6812
#define PIXEL4_32_50 interp5((Uint32 *)(dst + 3 * dst_pitch + 2 * dst_Bpp), c[8], c[5]);
6813
#define PIXEL4_32_60 interp6((Uint32 *)(dst + 3 * dst_pitch + 2 * dst_Bpp), c[5], c[8], c[6]);
6814
#define PIXEL4_32_61 interp6((Uint32 *)(dst + 3 * dst_pitch + 2 * dst_Bpp), c[5], c[8], c[9]);
6815
#define PIXEL4_32_82 interp8((Uint32 *)(dst + 3 * dst_pitch + 2 * dst_Bpp), c[5], c[8]);
6816
#define PIXEL4_32_83 interp8((Uint32 *)(dst + 3 * dst_pitch + 2 * dst_Bpp), c[8], c[6]);
6817
#define PIXEL4_33_0 *(Uint32 *)(dst + 3 * dst_pitch + 3 * dst_Bpp) = c[5];
6818
#define PIXEL4_33_11 interp1((Uint32 *)(dst + 3 * dst_pitch + 3 * dst_Bpp), c[5], c[6]);
6819
#define PIXEL4_33_12 interp1((Uint32 *)(dst + 3 * dst_pitch + 3 * dst_Bpp), c[5], c[8]);
6820
#define PIXEL4_33_20 interp2((Uint32 *)(dst + 3 * dst_pitch + 3 * dst_Bpp), c[5], c[8], c[6]);
6821
#define PIXEL4_33_50 interp5((Uint32 *)(dst + 3 * dst_pitch + 3 * dst_Bpp), c[8], c[6]);
6822
#define PIXEL4_33_80 interp8((Uint32 *)(dst + 3 * dst_pitch + 3 * dst_Bpp), c[5], c[9]);
6823
#define PIXEL4_33_81 interp8((Uint32 *)(dst + 3 * dst_pitch + 3 * dst_Bpp), c[5], c[6]);
6824
#define PIXEL4_33_82 interp8((Uint32 *)(dst + 3 * dst_pitch + 3 * dst_Bpp), c[5], c[8]);
6826
void hq4x_32( SDL_Surface *src_surface, SDL_Surface *dst_surface )
6828
Uint8 *src = src_surface->pixels, *src_temp,
6829
*dst = dst_surface->pixels, *dst_temp;
6830
int src_pitch = src_surface->pitch,
6831
dst_pitch = dst_surface->pitch;
6832
const int dst_Bpp = 4; // dst_surface->format->BytesPerPixel
6834
const int height = vga_height, // src_surface->h
6835
width = vga_width; // src_surface->w
6837
int prevline, nextline;
6853
for (int j = 0; j < height; j++)
6858
prevline = (j > 0) ? -width : 0;
6859
nextline = (j < height - 1) ? width : 0;
6861
for (int i = 0; i < width; i++)
6863
w[2] = *(src + prevline);
6865
w[8] = *(src + nextline);
6869
w[1] = *(src + prevline - 1);
6871
w[7] = *(src + nextline - 1);
6880
w[3] = *(src + prevline + 1);
6882
w[9] = *(src + nextline + 1);
6892
YUV1 = yuv_palette[w[5]];
6894
for (int k=1; k<=9; k++)
6900
YUV2 = yuv_palette[w[k]];
6901
if ( ( abs((YUV1 & Ymask) - (YUV2 & Ymask)) > trY ) ||
6902
( abs((YUV1 & Umask) - (YUV2 & Umask)) > trU ) ||
6903
( abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV ) )
6909
for (int k=1; k<=9; k++)
6910
c[k] = rgb_palette[w[k]] & 0xfcfcfcfc; // hq4x has a nasty inability to accept more than 6 bits for each component
7230
if (diff(w[2], w[6]))
7269
if (diff(w[6], w[8]))
7298
if (diff(w[8], w[4]))
7321
if (diff(w[4], w[2]))
7482
if (diff(w[2], w[6]))
7521
if (diff(w[6], w[8]))
7548
if (diff(w[8], w[4]))
7570
if (diff(w[4], w[2]))
7600
if (diff(w[2], w[6]))
7635
if (diff(w[2], w[6]))
7669
if (diff(w[6], w[8]))
7709
if (diff(w[6], w[8]))
7740
if (diff(w[8], w[4]))
7765
if (diff(w[8], w[4]))
7798
if (diff(w[4], w[2]))
7831
if (diff(w[4], w[2]))
8024
if (diff(w[4], w[2]))
8036
if (diff(w[2], w[6]))
8065
if (diff(w[2], w[6]))
8083
if (diff(w[6], w[8]))
8110
if (diff(w[8], w[4]))
8124
if (diff(w[6], w[8]))
8141
if (diff(w[4], w[2]))
8158
if (diff(w[8], w[4]))
8179
if (diff(w[4], w[2]))
8210
if (diff(w[2], w[6]))
8248
if (diff(w[6], w[8]))
8274
if (diff(w[8], w[4]))
8297
if (diff(w[2], w[6]))
8335
if (diff(w[6], w[8]))
8361
if (diff(w[8], w[4]))
8382
if (diff(w[4], w[2]))
8651
if (diff(w[4], w[2]))
8665
if (diff(w[2], w[6]))
8693
if (diff(w[2], w[6]))
8711
if (diff(w[6], w[8]))
8739
if (diff(w[8], w[4]))
8753
if (diff(w[6], w[8]))
8771
if (diff(w[4], w[2]))
8789
if (diff(w[8], w[4]))
8811
if (diff(w[4], w[2]))
8829
if (diff(w[8], w[4]))
8851
if (diff(w[4], w[2]))
8865
if (diff(w[2], w[6]))
8893
if (diff(w[2], w[6]))
8911
if (diff(w[6], w[8]))
8939
if (diff(w[8], w[4]))
8953
if (diff(w[6], w[8]))
8971
if (diff(w[4], w[2]))
8985
if (diff(w[2], w[6]))
8999
if (diff(w[8], w[4]))
9013
if (diff(w[6], w[8]))
9032
if (diff(w[2], w[6]))
9067
if (diff(w[2], w[6]))
9101
if (diff(w[6], w[8]))
9141
if (diff(w[6], w[8]))
9172
if (diff(w[8], w[4]))
9197
if (diff(w[8], w[4]))
9230
if (diff(w[4], w[2]))
9263
if (diff(w[4], w[2]))
9303
if (diff(w[8], w[4]))
9324
if (diff(w[4], w[2]))
9355
if (diff(w[2], w[6]))
9393
if (diff(w[6], w[8]))
9413
if (diff(w[2], w[6]))
9451
if (diff(w[6], w[8]))
9477
if (diff(w[8], w[4]))
9498
if (diff(w[4], w[2]))
9695
if (diff(w[8], w[4]))
9710
if (diff(w[6], w[8]))
9726
if (diff(w[4], w[2]))
9740
if (diff(w[2], w[6]))
9765
if (diff(w[4], w[2]))
9783
if (diff(w[8], w[4]))
9806
if (diff(w[2], w[6]))
9825
if (diff(w[6], w[8]))
9843
if (diff(w[4], w[2]))
9855
if (diff(w[2], w[6]))
9890
if (diff(w[8], w[4]))
9903
if (diff(w[6], w[8]))
9923
if (diff(w[2], w[6]))
9940
if (diff(w[6], w[8]))
9960
if (diff(w[4], w[2]))
9977
if (diff(w[8], w[4]))
9999
if (diff(w[4], w[2]))
10013
if (diff(w[2], w[6]))
10027
if (diff(w[8], w[4]))
10040
if (diff(w[6], w[8]))
10058
if (diff(w[4], w[2]))
10072
if (diff(w[2], w[6]))
10085
if (diff(w[8], w[4]))
10099
if (diff(w[6], w[8]))
10117
if (diff(w[4], w[2]))
10131
if (diff(w[2], w[6]))
10145
if (diff(w[8], w[4]))
10160
if (diff(w[6], w[8]))
10176
if (diff(w[4], w[2]))
10188
if (diff(w[2], w[6]))
10203
if (diff(w[8], w[4]))
10217
if (diff(w[6], w[8]))
10315
if (diff(w[4], w[2]))
10329
if (diff(w[2], w[6]))
10357
if (diff(w[2], w[6]))
10375
if (diff(w[6], w[8]))
10403
if (diff(w[8], w[4]))
10417
if (diff(w[6], w[8]))
10435
if (diff(w[4], w[2]))
10453
if (diff(w[8], w[4]))
10484
if (diff(w[8], w[4]))
10507
if (diff(w[4], w[2]))
10540
if (diff(w[2], w[6]))
10579
if (diff(w[6], w[8]))
10641
if (diff(w[2], w[6]))
10656
if (diff(w[8], w[4]))
10677
if (diff(w[4], w[2]))
10697
if (diff(w[6], w[8]))
10715
if (diff(w[8], w[4]))
10750
if (diff(w[6], w[8]))
10779
if (diff(w[4], w[2]))
10819
if (diff(w[8], w[4]))
10845
if (diff(w[2], w[6]))
10875
if (diff(w[4], w[2]))
10917
if (diff(w[6], w[8]))
10939
if (diff(w[2], w[6]))
10984
if (diff(w[8], w[4]))
11000
if (diff(w[4], w[2]))
11031
if (diff(w[2], w[6]))
11071
if (diff(w[6], w[8]))
11091
if (diff(w[8], w[4]))
11105
if (diff(w[6], w[8]))
11121
if (diff(w[4], w[2]))
11138
if (diff(w[8], w[4]))
11159
if (diff(w[4], w[2]))
11171
if (diff(w[2], w[6]))
11199
if (diff(w[2], w[6]))
11217
if (diff(w[6], w[8]))
11243
if (diff(w[8], w[4]))
11259
if (diff(w[6], w[8]))
11282
if (diff(w[6], w[8]))
11294
if (diff(w[8], w[4]))
11307
if (diff(w[4], w[2]))
11328
if (diff(w[8], w[4]))
11343
if (diff(w[4], w[2]))
11358
if (diff(w[8], w[4]))
11379
if (diff(w[4], w[2]))
11388
if (diff(w[2], w[6]))
11415
if (diff(w[4], w[2]))
11428
if (diff(w[2], w[6]))
11454
if (diff(w[2], w[6]))
11469
if (diff(w[6], w[8]))
11489
if (diff(w[2], w[6]))
11511
if (diff(w[6], w[8]))
11525
if (diff(w[2], w[6]))
11540
if (diff(w[8], w[4]))
11556
if (diff(w[6], w[8]))
11580
if (diff(w[8], w[4]))
11590
if (diff(w[6], w[8]))
11602
if (diff(w[4], w[2]))
11622
if (diff(w[6], w[8]))
11634
if (diff(w[8], w[4]))
11647
if (diff(w[4], w[2]))
11666
if (diff(w[8], w[4]))
11681
if (diff(w[4], w[2]))
11690
if (diff(w[2], w[6]))
11705
if (diff(w[8], w[4]))
11726
if (diff(w[4], w[2]))
11736
if (diff(w[2], w[6]))
11760
if (diff(w[4], w[2]))
11773
if (diff(w[2], w[6]))
11787
if (diff(w[6], w[8]))
11808
if (diff(w[2], w[6]))
11827
if (diff(w[6], w[8]))
11839
if (diff(w[4], w[2]))
11849
if (diff(w[2], w[6]))
11865
if (diff(w[8], w[4]))
11875
if (diff(w[6], w[8]))
11888
dst += 4 * dst_Bpp;
11891
src = src_temp + src_pitch;
11892
dst = dst_temp + 4 * dst_pitch;
11896
// kate: tab-width 4; vim: set noet: