33 #include "nomlib/graphics/hqx/hqx.hpp"
35 #define PIXEL00_0 *dp = w[5];
36 #define PIXEL00_11 *dp = Interp1(w[5], w[4]);
37 #define PIXEL00_12 *dp = Interp1(w[5], w[2]);
38 #define PIXEL00_20 *dp = Interp2(w[5], w[2], w[4]);
39 #define PIXEL00_50 *dp = Interp5(w[2], w[4]);
40 #define PIXEL00_80 *dp = Interp8(w[5], w[1]);
41 #define PIXEL00_81 *dp = Interp8(w[5], w[4]);
42 #define PIXEL00_82 *dp = Interp8(w[5], w[2]);
43 #define PIXEL01_0 *(dp+1) = w[5];
44 #define PIXEL01_10 *(dp+1) = Interp1(w[5], w[1]);
45 #define PIXEL01_12 *(dp+1) = Interp1(w[5], w[2]);
46 #define PIXEL01_14 *(dp+1) = Interp1(w[2], w[5]);
47 #define PIXEL01_21 *(dp+1) = Interp2(w[2], w[5], w[4]);
48 #define PIXEL01_31 *(dp+1) = Interp3(w[5], w[4]);
49 #define PIXEL01_50 *(dp+1) = Interp5(w[2], w[5]);
50 #define PIXEL01_60 *(dp+1) = Interp6(w[5], w[2], w[4]);
51 #define PIXEL01_61 *(dp+1) = Interp6(w[5], w[2], w[1]);
52 #define PIXEL01_82 *(dp+1) = Interp8(w[5], w[2]);
53 #define PIXEL01_83 *(dp+1) = Interp8(w[2], w[4]);
54 #define PIXEL02_0 *(dp+2) = w[5];
55 #define PIXEL02_10 *(dp+2) = Interp1(w[5], w[3]);
56 #define PIXEL02_11 *(dp+2) = Interp1(w[5], w[2]);
57 #define PIXEL02_13 *(dp+2) = Interp1(w[2], w[5]);
58 #define PIXEL02_21 *(dp+2) = Interp2(w[2], w[5], w[6]);
59 #define PIXEL02_32 *(dp+2) = Interp3(w[5], w[6]);
60 #define PIXEL02_50 *(dp+2) = Interp5(w[2], w[5]);
61 #define PIXEL02_60 *(dp+2) = Interp6(w[5], w[2], w[6]);
62 #define PIXEL02_61 *(dp+2) = Interp6(w[5], w[2], w[3]);
63 #define PIXEL02_81 *(dp+2) = Interp8(w[5], w[2]);
64 #define PIXEL02_83 *(dp+2) = Interp8(w[2], w[6]);
65 #define PIXEL03_0 *(dp+3) = w[5];
66 #define PIXEL03_11 *(dp+3) = Interp1(w[5], w[2]);
67 #define PIXEL03_12 *(dp+3) = Interp1(w[5], w[6]);
68 #define PIXEL03_20 *(dp+3) = Interp2(w[5], w[2], w[6]);
69 #define PIXEL03_50 *(dp+3) = Interp5(w[2], w[6]);
70 #define PIXEL03_80 *(dp+3) = Interp8(w[5], w[3]);
71 #define PIXEL03_81 *(dp+3) = Interp8(w[5], w[2]);
72 #define PIXEL03_82 *(dp+3) = Interp8(w[5], w[6]);
73 #define PIXEL10_0 *(dp+dpL) = w[5];
74 #define PIXEL10_10 *(dp+dpL) = Interp1(w[5], w[1]);
75 #define PIXEL10_11 *(dp+dpL) = Interp1(w[5], w[4]);
76 #define PIXEL10_13 *(dp+dpL) = Interp1(w[4], w[5]);
77 #define PIXEL10_21 *(dp+dpL) = Interp2(w[4], w[5], w[2]);
78 #define PIXEL10_32 *(dp+dpL) = Interp3(w[5], w[2]);
79 #define PIXEL10_50 *(dp+dpL) = Interp5(w[4], w[5]);
80 #define PIXEL10_60 *(dp+dpL) = Interp6(w[5], w[4], w[2]);
81 #define PIXEL10_61 *(dp+dpL) = Interp6(w[5], w[4], w[1]);
82 #define PIXEL10_81 *(dp+dpL) = Interp8(w[5], w[4]);
83 #define PIXEL10_83 *(dp+dpL) = Interp8(w[4], w[2]);
84 #define PIXEL11_0 *(dp+dpL+1) = w[5];
85 #define PIXEL11_30 *(dp+dpL+1) = Interp3(w[5], w[1]);
86 #define PIXEL11_31 *(dp+dpL+1) = Interp3(w[5], w[4]);
87 #define PIXEL11_32 *(dp+dpL+1) = Interp3(w[5], w[2]);
88 #define PIXEL11_70 *(dp+dpL+1) = Interp7(w[5], w[4], w[2]);
89 #define PIXEL12_0 *(dp+dpL+2) = w[5];
90 #define PIXEL12_30 *(dp+dpL+2) = Interp3(w[5], w[3]);
91 #define PIXEL12_31 *(dp+dpL+2) = Interp3(w[5], w[2]);
92 #define PIXEL12_32 *(dp+dpL+2) = Interp3(w[5], w[6]);
93 #define PIXEL12_70 *(dp+dpL+2) = Interp7(w[5], w[6], w[2]);
94 #define PIXEL13_0 *(dp+dpL+3) = w[5];
95 #define PIXEL13_10 *(dp+dpL+3) = Interp1(w[5], w[3]);
96 #define PIXEL13_12 *(dp+dpL+3) = Interp1(w[5], w[6]);
97 #define PIXEL13_14 *(dp+dpL+3) = Interp1(w[6], w[5]);
98 #define PIXEL13_21 *(dp+dpL+3) = Interp2(w[6], w[5], w[2]);
99 #define PIXEL13_31 *(dp+dpL+3) = Interp3(w[5], w[2]);
100 #define PIXEL13_50 *(dp+dpL+3) = Interp5(w[6], w[5]);
101 #define PIXEL13_60 *(dp+dpL+3) = Interp6(w[5], w[6], w[2]);
102 #define PIXEL13_61 *(dp+dpL+3) = Interp6(w[5], w[6], w[3]);
103 #define PIXEL13_82 *(dp+dpL+3) = Interp8(w[5], w[6]);
104 #define PIXEL13_83 *(dp+dpL+3) = Interp8(w[6], w[2]);
105 #define PIXEL20_0 *(dp+dpL+dpL) = w[5];
106 #define PIXEL20_10 *(dp+dpL+dpL) = Interp1(w[5], w[7]);
107 #define PIXEL20_12 *(dp+dpL+dpL) = Interp1(w[5], w[4]);
108 #define PIXEL20_14 *(dp+dpL+dpL) = Interp1(w[4], w[5]);
109 #define PIXEL20_21 *(dp+dpL+dpL) = Interp2(w[4], w[5], w[8]);
110 #define PIXEL20_31 *(dp+dpL+dpL) = Interp3(w[5], w[8]);
111 #define PIXEL20_50 *(dp+dpL+dpL) = Interp5(w[4], w[5]);
112 #define PIXEL20_60 *(dp+dpL+dpL) = Interp6(w[5], w[4], w[8]);
113 #define PIXEL20_61 *(dp+dpL+dpL) = Interp6(w[5], w[4], w[7]);
114 #define PIXEL20_82 *(dp+dpL+dpL) = Interp8(w[5], w[4]);
115 #define PIXEL20_83 *(dp+dpL+dpL) = Interp8(w[4], w[8]);
116 #define PIXEL21_0 *(dp+dpL+dpL+1) = w[5];
117 #define PIXEL21_30 *(dp+dpL+dpL+1) = Interp3(w[5], w[7]);
118 #define PIXEL21_31 *(dp+dpL+dpL+1) = Interp3(w[5], w[8]);
119 #define PIXEL21_32 *(dp+dpL+dpL+1) = Interp3(w[5], w[4]);
120 #define PIXEL21_70 *(dp+dpL+dpL+1) = Interp7(w[5], w[4], w[8]);
121 #define PIXEL22_0 *(dp+dpL+dpL+2) = w[5];
122 #define PIXEL22_30 *(dp+dpL+dpL+2) = Interp3(w[5], w[9]);
123 #define PIXEL22_31 *(dp+dpL+dpL+2) = Interp3(w[5], w[6]);
124 #define PIXEL22_32 *(dp+dpL+dpL+2) = Interp3(w[5], w[8]);
125 #define PIXEL22_70 *(dp+dpL+dpL+2) = Interp7(w[5], w[6], w[8]);
126 #define PIXEL23_0 *(dp+dpL+dpL+3) = w[5];
127 #define PIXEL23_10 *(dp+dpL+dpL+3) = Interp1(w[5], w[9]);
128 #define PIXEL23_11 *(dp+dpL+dpL+3) = Interp1(w[5], w[6]);
129 #define PIXEL23_13 *(dp+dpL+dpL+3) = Interp1(w[6], w[5]);
130 #define PIXEL23_21 *(dp+dpL+dpL+3) = Interp2(w[6], w[5], w[8]);
131 #define PIXEL23_32 *(dp+dpL+dpL+3) = Interp3(w[5], w[8]);
132 #define PIXEL23_50 *(dp+dpL+dpL+3) = Interp5(w[6], w[5]);
133 #define PIXEL23_60 *(dp+dpL+dpL+3) = Interp6(w[5], w[6], w[8]);
134 #define PIXEL23_61 *(dp+dpL+dpL+3) = Interp6(w[5], w[6], w[9]);
135 #define PIXEL23_81 *(dp+dpL+dpL+3) = Interp8(w[5], w[6]);
136 #define PIXEL23_83 *(dp+dpL+dpL+3) = Interp8(w[6], w[8]);
137 #define PIXEL30_0 *(dp+dpL+dpL+dpL) = w[5];
138 #define PIXEL30_11 *(dp+dpL+dpL+dpL) = Interp1(w[5], w[8]);
139 #define PIXEL30_12 *(dp+dpL+dpL+dpL) = Interp1(w[5], w[4]);
140 #define PIXEL30_20 *(dp+dpL+dpL+dpL) = Interp2(w[5], w[8], w[4]);
141 #define PIXEL30_50 *(dp+dpL+dpL+dpL) = Interp5(w[8], w[4]);
142 #define PIXEL30_80 *(dp+dpL+dpL+dpL) = Interp8(w[5], w[7]);
143 #define PIXEL30_81 *(dp+dpL+dpL+dpL) = Interp8(w[5], w[8]);
144 #define PIXEL30_82 *(dp+dpL+dpL+dpL) = Interp8(w[5], w[4]);
145 #define PIXEL31_0 *(dp+dpL+dpL+dpL+1) = w[5];
146 #define PIXEL31_10 *(dp+dpL+dpL+dpL+1) = Interp1(w[5], w[7]);
147 #define PIXEL31_11 *(dp+dpL+dpL+dpL+1) = Interp1(w[5], w[8]);
148 #define PIXEL31_13 *(dp+dpL+dpL+dpL+1) = Interp1(w[8], w[5]);
149 #define PIXEL31_21 *(dp+dpL+dpL+dpL+1) = Interp2(w[8], w[5], w[4]);
150 #define PIXEL31_32 *(dp+dpL+dpL+dpL+1) = Interp3(w[5], w[4]);
151 #define PIXEL31_50 *(dp+dpL+dpL+dpL+1) = Interp5(w[8], w[5]);
152 #define PIXEL31_60 *(dp+dpL+dpL+dpL+1) = Interp6(w[5], w[8], w[4]);
153 #define PIXEL31_61 *(dp+dpL+dpL+dpL+1) = Interp6(w[5], w[8], w[7]);
154 #define PIXEL31_81 *(dp+dpL+dpL+dpL+1) = Interp8(w[5], w[8]);
155 #define PIXEL31_83 *(dp+dpL+dpL+dpL+1) = Interp8(w[8], w[4]);
156 #define PIXEL32_0 *(dp+dpL+dpL+dpL+2) = w[5];
157 #define PIXEL32_10 *(dp+dpL+dpL+dpL+2) = Interp1(w[5], w[9]);
158 #define PIXEL32_12 *(dp+dpL+dpL+dpL+2) = Interp1(w[5], w[8]);
159 #define PIXEL32_14 *(dp+dpL+dpL+dpL+2) = Interp1(w[8], w[5]);
160 #define PIXEL32_21 *(dp+dpL+dpL+dpL+2) = Interp2(w[8], w[5], w[6]);
161 #define PIXEL32_31 *(dp+dpL+dpL+dpL+2) = Interp3(w[5], w[6]);
162 #define PIXEL32_50 *(dp+dpL+dpL+dpL+2) = Interp5(w[8], w[5]);
163 #define PIXEL32_60 *(dp+dpL+dpL+dpL+2) = Interp6(w[5], w[8], w[6]);
164 #define PIXEL32_61 *(dp+dpL+dpL+dpL+2) = Interp6(w[5], w[8], w[9]);
165 #define PIXEL32_82 *(dp+dpL+dpL+dpL+2) = Interp8(w[5], w[8]);
166 #define PIXEL32_83 *(dp+dpL+dpL+dpL+2) = Interp8(w[8], w[6]);
167 #define PIXEL33_0 *(dp+dpL+dpL+dpL+3) = w[5];
168 #define PIXEL33_11 *(dp+dpL+dpL+dpL+3) = Interp1(w[5], w[6]);
169 #define PIXEL33_12 *(dp+dpL+dpL+dpL+3) = Interp1(w[5], w[8]);
170 #define PIXEL33_20 *(dp+dpL+dpL+dpL+3) = Interp2(w[5], w[8], w[6]);
171 #define PIXEL33_50 *(dp+dpL+dpL+dpL+3) = Interp5(w[8], w[6]);
172 #define PIXEL33_80 *(dp+dpL+dpL+dpL+3) = Interp8(w[5], w[9]);
173 #define PIXEL33_81 *(dp+dpL+dpL+dpL+3) = Interp8(w[5], w[6]);
174 #define PIXEL33_82 *(dp+dpL+dpL+dpL+3) = Interp8(w[5], w[8]);
179 void hq4x_32_rb( uint32* sp, uint32 srb, uint32* dp, uint32 drb, int32 Xres, int32 Yres )
182 int32 prevline, nextline;
184 int32 dpL = (drb >> 2);
185 int32 spL = (srb >> 2);
186 uint8 *sRowP = (uint8 *) sp;
187 uint8 *dRowP = (uint8 *) dp;
201 for (j=0; j<Yres; j++)
203 if (j>0) prevline = -spL;
else prevline = 0;
204 if (j<Yres-1) nextline = spL;
else nextline = 0;
206 for (i=0; i<Xres; i++)
208 w[2] = *(sp + prevline);
210 w[8] = *(sp + nextline);
214 w[1] = *(sp + prevline - 1);
216 w[7] = *(sp + nextline - 1);
227 w[3] = *(sp + prevline + 1);
229 w[9] = *(sp + nextline + 1);
241 yuv1 = rgb_to_yuv(w[5]);
249 yuv2 = rgb_to_yuv(w[k]);
250 if (yuv_diff(yuv1, yuv2))
574 if (Diff(w[2], w[6]))
613 if (Diff(w[6], w[8]))
642 if (Diff(w[8], w[4]))
665 if (Diff(w[4], w[2]))
826 if (Diff(w[2], w[6]))
865 if (Diff(w[6], w[8]))
892 if (Diff(w[8], w[4]))
914 if (Diff(w[4], w[2]))
944 if (Diff(w[2], w[6]))
979 if (Diff(w[2], w[6]))
1013 if (Diff(w[6], w[8]))
1053 if (Diff(w[6], w[8]))
1084 if (Diff(w[8], w[4]))
1109 if (Diff(w[8], w[4]))
1142 if (Diff(w[4], w[2]))
1175 if (Diff(w[4], w[2]))
1368 if (Diff(w[4], w[2]))
1380 if (Diff(w[2], w[6]))
1409 if (Diff(w[2], w[6]))
1427 if (Diff(w[6], w[8]))
1454 if (Diff(w[8], w[4]))
1468 if (Diff(w[6], w[8]))
1485 if (Diff(w[4], w[2]))
1502 if (Diff(w[8], w[4]))
1523 if (Diff(w[4], w[2]))
1554 if (Diff(w[2], w[6]))
1592 if (Diff(w[6], w[8]))
1618 if (Diff(w[8], w[4]))
1641 if (Diff(w[2], w[6]))
1679 if (Diff(w[6], w[8]))
1705 if (Diff(w[8], w[4]))
1726 if (Diff(w[4], w[2]))
1995 if (Diff(w[4], w[2]))
2009 if (Diff(w[2], w[6]))
2037 if (Diff(w[2], w[6]))
2055 if (Diff(w[6], w[8]))
2083 if (Diff(w[8], w[4]))
2097 if (Diff(w[6], w[8]))
2115 if (Diff(w[4], w[2]))
2133 if (Diff(w[8], w[4]))
2155 if (Diff(w[4], w[2]))
2173 if (Diff(w[8], w[4]))
2195 if (Diff(w[4], w[2]))
2209 if (Diff(w[2], w[6]))
2237 if (Diff(w[2], w[6]))
2255 if (Diff(w[6], w[8]))
2283 if (Diff(w[8], w[4]))
2297 if (Diff(w[6], w[8]))
2315 if (Diff(w[4], w[2]))
2329 if (Diff(w[2], w[6]))
2343 if (Diff(w[8], w[4]))
2357 if (Diff(w[6], w[8]))
2376 if (Diff(w[2], w[6]))
2411 if (Diff(w[2], w[6]))
2445 if (Diff(w[6], w[8]))
2485 if (Diff(w[6], w[8]))
2516 if (Diff(w[8], w[4]))
2541 if (Diff(w[8], w[4]))
2574 if (Diff(w[4], w[2]))
2607 if (Diff(w[4], w[2]))
2647 if (Diff(w[8], w[4]))
2668 if (Diff(w[4], w[2]))
2699 if (Diff(w[2], w[6]))
2737 if (Diff(w[6], w[8]))
2757 if (Diff(w[2], w[6]))
2795 if (Diff(w[6], w[8]))
2821 if (Diff(w[8], w[4]))
2842 if (Diff(w[4], w[2]))
3039 if (Diff(w[8], w[4]))
3054 if (Diff(w[6], w[8]))
3070 if (Diff(w[4], w[2]))
3084 if (Diff(w[2], w[6]))
3109 if (Diff(w[4], w[2]))
3127 if (Diff(w[8], w[4]))
3150 if (Diff(w[2], w[6]))
3169 if (Diff(w[6], w[8]))
3187 if (Diff(w[4], w[2]))
3199 if (Diff(w[2], w[6]))
3234 if (Diff(w[8], w[4]))
3247 if (Diff(w[6], w[8]))
3267 if (Diff(w[2], w[6]))
3284 if (Diff(w[6], w[8]))
3304 if (Diff(w[4], w[2]))
3321 if (Diff(w[8], w[4]))
3343 if (Diff(w[4], w[2]))
3357 if (Diff(w[2], w[6]))
3371 if (Diff(w[8], w[4]))
3384 if (Diff(w[6], w[8]))
3402 if (Diff(w[4], w[2]))
3416 if (Diff(w[2], w[6]))
3429 if (Diff(w[8], w[4]))
3443 if (Diff(w[6], w[8]))
3461 if (Diff(w[4], w[2]))
3475 if (Diff(w[2], w[6]))
3489 if (Diff(w[8], w[4]))
3504 if (Diff(w[6], w[8]))
3520 if (Diff(w[4], w[2]))
3532 if (Diff(w[2], w[6]))
3547 if (Diff(w[8], w[4]))
3561 if (Diff(w[6], w[8]))
3659 if (Diff(w[4], w[2]))
3673 if (Diff(w[2], w[6]))
3701 if (Diff(w[2], w[6]))
3719 if (Diff(w[6], w[8]))
3747 if (Diff(w[8], w[4]))
3761 if (Diff(w[6], w[8]))
3779 if (Diff(w[4], w[2]))
3797 if (Diff(w[8], w[4]))
3828 if (Diff(w[8], w[4]))
3851 if (Diff(w[4], w[2]))
3884 if (Diff(w[2], w[6]))
3923 if (Diff(w[6], w[8]))
3985 if (Diff(w[2], w[6]))
4000 if (Diff(w[8], w[4]))
4021 if (Diff(w[4], w[2]))
4041 if (Diff(w[6], w[8]))
4059 if (Diff(w[8], w[4]))
4094 if (Diff(w[6], w[8]))
4123 if (Diff(w[4], w[2]))
4163 if (Diff(w[8], w[4]))
4189 if (Diff(w[2], w[6]))
4219 if (Diff(w[4], w[2]))
4261 if (Diff(w[6], w[8]))
4283 if (Diff(w[2], w[6]))
4328 if (Diff(w[8], w[4]))
4344 if (Diff(w[4], w[2]))
4375 if (Diff(w[2], w[6]))
4415 if (Diff(w[6], w[8]))
4435 if (Diff(w[8], w[4]))
4449 if (Diff(w[6], w[8]))
4465 if (Diff(w[4], w[2]))
4482 if (Diff(w[8], w[4]))
4503 if (Diff(w[4], w[2]))
4515 if (Diff(w[2], w[6]))
4543 if (Diff(w[2], w[6]))
4561 if (Diff(w[6], w[8]))
4587 if (Diff(w[8], w[4]))
4603 if (Diff(w[6], w[8]))
4626 if (Diff(w[6], w[8]))
4638 if (Diff(w[8], w[4]))
4651 if (Diff(w[4], w[2]))
4672 if (Diff(w[8], w[4]))
4687 if (Diff(w[4], w[2]))
4702 if (Diff(w[8], w[4]))
4723 if (Diff(w[4], w[2]))
4732 if (Diff(w[2], w[6]))
4759 if (Diff(w[4], w[2]))
4772 if (Diff(w[2], w[6]))
4798 if (Diff(w[2], w[6]))
4813 if (Diff(w[6], w[8]))
4833 if (Diff(w[2], w[6]))
4855 if (Diff(w[6], w[8]))
4869 if (Diff(w[2], w[6]))
4884 if (Diff(w[8], w[4]))
4900 if (Diff(w[6], w[8]))
4924 if (Diff(w[8], w[4]))
4934 if (Diff(w[6], w[8]))
4946 if (Diff(w[4], w[2]))
4966 if (Diff(w[6], w[8]))
4978 if (Diff(w[8], w[4]))
4991 if (Diff(w[4], w[2]))
5010 if (Diff(w[8], w[4]))
5025 if (Diff(w[4], w[2]))
5034 if (Diff(w[2], w[6]))
5049 if (Diff(w[8], w[4]))
5070 if (Diff(w[4], w[2]))
5080 if (Diff(w[2], w[6]))
5104 if (Diff(w[4], w[2]))
5117 if (Diff(w[2], w[6]))
5131 if (Diff(w[6], w[8]))
5152 if (Diff(w[2], w[6]))
5171 if (Diff(w[6], w[8]))
5183 if (Diff(w[4], w[2]))
5193 if (Diff(w[2], w[6]))
5209 if (Diff(w[8], w[4]))
5219 if (Diff(w[6], w[8]))
5235 sp = (uint32 *) sRowP;
5238 dp = (uint32 *) dRowP;
5242 void hq4x_32 ( uint32* src, uint32* dest, int32 width, int32 height )
5244 uint32 rowBytesL = width * 4;
5246 hq4x_32_rb (src, rowBytesL, dest, rowBytesL * 4, width, height );