60 * DESCRIPTION
61 * The functions step along the lines from xLeft to xRight and apply
62 * the bilinear filtering.
63 *
64 */
65
66 #include "mlib_ImageAffine.h"
67
68 /***************************************************************/
69 #define DTYPE mlib_u8
70 #define FTYPE mlib_f32
71
72 /***************************************************************/
73 #define TTYPE mlib_f32
74 #define I2F(x) mlib_U82F32[x]
75 #define ROUND(x) ((x) + 0.5f)
76
77 #define FUN_NAME(CHAN) mlib_ImageAffine_u8_##CHAN##_bl
78
79 /***************************************************************/
80 #ifdef __sparc /* for SPARC, using floating-point multiplies is faster */
81
82 /***************************************************************/
83 #define GET_POINTERS(ind) \
84 fdx = (FTYPE)(X & MLIB_MASK) * scale; \
85 fdy = (FTYPE)(Y & MLIB_MASK) * scale; \
86 ySrc = MLIB_POINTER_SHIFT(Y); Y += dY; \
87 xSrc = X >> MLIB_SHIFT; X += dX; \
88 srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + ind * xSrc; \
89 srcPixelPtr2 = (DTYPE *)((mlib_u8 *)srcPixelPtr + srcYStride)
90
91 /***************************************************************/
92 #define COUNT(ind) \
93 pix0_##ind = a00_##ind + fdy * (a10_##ind - a00_##ind); \
94 pix1_##ind = a01_##ind + fdy * (a11_##ind - a01_##ind); \
95 res##ind = ROUND(pix0_##ind + fdx * (pix1_##ind - pix0_##ind))
96
97 /***************************************************************/
98 #define LOAD(ind, ind1, ind2) \
99 a00_##ind = I2F(srcPixelPtr[ind1]); \
100 a01_##ind = I2F(srcPixelPtr[ind2]); \
101 a10_##ind = I2F(srcPixelPtr2[ind1]); \
102 a11_##ind = I2F(srcPixelPtr2[ind2])
103
104 /***************************************************************/
105 mlib_status FUN_NAME(1ch)(mlib_affine_param *param)
106 {
107 DECLAREVAR_BL();
108 DTYPE *dstLineEnd;
109 DTYPE *srcPixelPtr2;
110 FTYPE scale = (FTYPE) 1.0 / MLIB_PREC;
111
112 for (j = yStart; j <= yFinish; j++) {
113 FTYPE fdx, fdy;
114 TTYPE a00_0, a01_0, a10_0, a11_0;
115 FTYPE pix0_0, pix1_0, res0;
116
117 CLIP(1);
118 dstLineEnd = (DTYPE *) dstData + xRight;
119
120 GET_POINTERS(1);
121 LOAD(0, 0, 1);
122
123 #ifdef __SUNPRO_C
124 #pragma pipeloop(0)
125 #endif /* __SUNPRO_C */
126 for (; dstPixelPtr < dstLineEnd; dstPixelPtr++) {
127 COUNT(0);
128 GET_POINTERS(1);
129 LOAD(0, 0, 1);
130 dstPixelPtr[0] = (DTYPE) res0;
131 }
132
133 COUNT(0);
134 dstPixelPtr[0] = (DTYPE) res0;
135 }
136
137 return MLIB_SUCCESS;
138 }
139
140 /***************************************************************/
141 mlib_status FUN_NAME(2ch)(mlib_affine_param *param)
142 {
143 DECLAREVAR_BL();
144 DTYPE *dstLineEnd;
145 DTYPE *srcPixelPtr2;
146 FTYPE scale = (FTYPE) 1.0 / MLIB_PREC;
147
148 for (j = yStart; j <= yFinish; j++) {
149 FTYPE fdx, fdy;
150 TTYPE a00_0, a01_0, a10_0, a11_0;
151 TTYPE a00_1, a01_1, a10_1, a11_1;
152 FTYPE pix0_0, pix1_0, res0;
153 FTYPE pix0_1, pix1_1, res1;
154
155 CLIP(2);
156 dstLineEnd = (DTYPE *) dstData + 2 * xRight;
157
158 GET_POINTERS(2);
159 LOAD(0, 0, 2);
160 LOAD(1, 1, 3);
161
162 #ifdef __SUNPRO_C
163 #pragma pipeloop(0)
164 #endif /* __SUNPRO_C */
165 for (; dstPixelPtr < dstLineEnd; dstPixelPtr += 2) {
166 COUNT(0);
167 COUNT(1);
168 GET_POINTERS(2);
169 LOAD(0, 0, 2);
170 LOAD(1, 1, 3);
171 dstPixelPtr[0] = (DTYPE) res0;
172 dstPixelPtr[1] = (DTYPE) res1;
173 }
174
175 COUNT(0);
176 COUNT(1);
177 dstPixelPtr[0] = (DTYPE) res0;
178 dstPixelPtr[1] = (DTYPE) res1;
179 }
180
181 return MLIB_SUCCESS;
182 }
183
184 /***************************************************************/
185 mlib_status FUN_NAME(3ch)(mlib_affine_param *param)
186 {
187 DECLAREVAR_BL();
188 DTYPE *dstLineEnd;
189 DTYPE *srcPixelPtr2;
190 FTYPE scale = (FTYPE) 1.0 / MLIB_PREC;
191
192 for (j = yStart; j <= yFinish; j++) {
193 FTYPE fdx, fdy;
194 FTYPE a00_0, a01_0, a10_0, a11_0;
195 FTYPE a00_1, a01_1, a10_1, a11_1;
196 FTYPE a00_2, a01_2, a10_2, a11_2;
197 FTYPE pix0_0, pix1_0, res0;
198 FTYPE pix0_1, pix1_1, res1;
199 FTYPE pix0_2, pix1_2, res2;
200
201 CLIP(3);
202 dstLineEnd = (DTYPE *) dstData + 3 * xRight;
203
204 GET_POINTERS(3);
205 LOAD(0, 0, 3);
206 LOAD(1, 1, 4);
207 LOAD(2, 2, 5);
208
209 #ifdef __SUNPRO_C
210 #pragma pipeloop(0)
211 #endif /* __SUNPRO_C */
212 for (; dstPixelPtr < dstLineEnd; dstPixelPtr += 3) {
213 COUNT(0);
214 COUNT(1);
215 COUNT(2);
216 GET_POINTERS(3);
217 LOAD(0, 0, 3);
218 LOAD(1, 1, 4);
219 LOAD(2, 2, 5);
220 dstPixelPtr[0] = (DTYPE) res0;
221 dstPixelPtr[1] = (DTYPE) res1;
222 dstPixelPtr[2] = (DTYPE) res2;
223 }
224
225 COUNT(0);
226 COUNT(1);
227 COUNT(2);
228 dstPixelPtr[0] = (DTYPE) res0;
229 dstPixelPtr[1] = (DTYPE) res1;
230 dstPixelPtr[2] = (DTYPE) res2;
231 }
232
233 return MLIB_SUCCESS;
234 }
235
236 /***************************************************************/
237 mlib_status FUN_NAME(4ch)(mlib_affine_param *param)
238 {
239 DECLAREVAR_BL();
240 DTYPE *dstLineEnd;
241 DTYPE *srcPixelPtr2;
242 FTYPE scale = (FTYPE) 1.0 / MLIB_PREC;
243
244 for (j = yStart; j <= yFinish; j++) {
245 FTYPE fdx, fdy;
246 TTYPE a00_0, a01_0, a10_0, a11_0;
247 TTYPE a00_1, a01_1, a10_1, a11_1;
248 TTYPE a00_2, a01_2, a10_2, a11_2;
249 TTYPE a00_3, a01_3, a10_3, a11_3;
250 FTYPE pix0_0, pix1_0, res0;
251 FTYPE pix0_1, pix1_1, res1;
252 FTYPE pix0_2, pix1_2, res2;
253 FTYPE pix0_3, pix1_3, res3;
254
255 CLIP(4);
256 dstLineEnd = (DTYPE *) dstData + 4 * xRight;
257
258 GET_POINTERS(4);
259 LOAD(0, 0, 4);
260 LOAD(1, 1, 5);
261 LOAD(2, 2, 6);
262 LOAD(3, 3, 7);
263
264 #ifdef __SUNPRO_C
265 #pragma pipeloop(0)
266 #endif /* __SUNPRO_C */
267 for (; dstPixelPtr < dstLineEnd; dstPixelPtr += 4) {
268 COUNT(0);
269 COUNT(1);
270 COUNT(2);
271 COUNT(3);
272 GET_POINTERS(4);
273 LOAD(0, 0, 4);
274 LOAD(1, 1, 5);
275 LOAD(2, 2, 6);
276 LOAD(3, 3, 7);
277 dstPixelPtr[0] = (DTYPE) res0;
278 dstPixelPtr[1] = (DTYPE) res1;
279 dstPixelPtr[2] = (DTYPE) res2;
280 dstPixelPtr[3] = (DTYPE) res3;
281 }
282
283 COUNT(0);
284 COUNT(1);
285 COUNT(2);
286 COUNT(3);
287 dstPixelPtr[0] = (DTYPE) res0;
288 dstPixelPtr[1] = (DTYPE) res1;
289 dstPixelPtr[2] = (DTYPE) res2;
290 dstPixelPtr[3] = (DTYPE) res3;
291 }
292
293 return MLIB_SUCCESS;
294 }
295
296 #else /* for x86, using integer multiplies is faster */
297
298 /* for SHORT/USHORT decrease MLIB_SHIFT due to
299 * overflow in multiplies like fdy * (a10 - a00)
300 */
301 /*
302 #undef MLIB_SHIFT
303 #define MLIB_SHIFT 15
304 */
305
306 #define MLIB_ROUND (1 << (MLIB_SHIFT - 1))
307
308 /***************************************************************/
309 #define GET_POINTERS(ind) \
310 fdx = X & MLIB_MASK; \
311 fdy = Y & MLIB_MASK; \
312 ySrc = MLIB_POINTER_SHIFT(Y); \
313 xSrc = X >> MLIB_SHIFT; \
314 srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + ind * xSrc; \
315 srcPixelPtr2 = (DTYPE *)((mlib_u8 *)srcPixelPtr + srcYStride); \
316 X += dX; \
535 LOAD(2, 2, 6);
536 LOAD(3, 3, 7);
537 dstPixelPtr[0] = (DTYPE) res0;
538 dstPixelPtr[1] = (DTYPE) res1;
539 dstPixelPtr[2] = (DTYPE) res2;
540 dstPixelPtr[3] = (DTYPE) res3;
541 }
542
543 COUNT(0);
544 COUNT(1);
545 COUNT(2);
546 COUNT(3);
547 dstPixelPtr[0] = (DTYPE) res0;
548 dstPixelPtr[1] = (DTYPE) res1;
549 dstPixelPtr[2] = (DTYPE) res2;
550 dstPixelPtr[3] = (DTYPE) res3;
551 }
552
553 return MLIB_SUCCESS;
554 }
555
556 #endif /* __sparc ( for SPARC, using floating-point multiplies is faster ) */
557
558 /***************************************************************/
|
60 * DESCRIPTION
61 * The functions step along the lines from xLeft to xRight and apply
62 * the bilinear filtering.
63 *
64 */
65
66 #include "mlib_ImageAffine.h"
67
68 /***************************************************************/
69 #define DTYPE mlib_u8
70 #define FTYPE mlib_f32
71
72 /***************************************************************/
73 #define TTYPE mlib_f32
74 #define I2F(x) mlib_U82F32[x]
75 #define ROUND(x) ((x) + 0.5f)
76
77 #define FUN_NAME(CHAN) mlib_ImageAffine_u8_##CHAN##_bl
78
79 /***************************************************************/
80 /* for x86, using integer multiplies is faster */
81
82 /* for SHORT/USHORT decrease MLIB_SHIFT due to
83 * overflow in multiplies like fdy * (a10 - a00)
84 */
85 /*
86 #undef MLIB_SHIFT
87 #define MLIB_SHIFT 15
88 */
89
90 #define MLIB_ROUND (1 << (MLIB_SHIFT - 1))
91
92 /***************************************************************/
93 #define GET_POINTERS(ind) \
94 fdx = X & MLIB_MASK; \
95 fdy = Y & MLIB_MASK; \
96 ySrc = MLIB_POINTER_SHIFT(Y); \
97 xSrc = X >> MLIB_SHIFT; \
98 srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + ind * xSrc; \
99 srcPixelPtr2 = (DTYPE *)((mlib_u8 *)srcPixelPtr + srcYStride); \
100 X += dX; \
319 LOAD(2, 2, 6);
320 LOAD(3, 3, 7);
321 dstPixelPtr[0] = (DTYPE) res0;
322 dstPixelPtr[1] = (DTYPE) res1;
323 dstPixelPtr[2] = (DTYPE) res2;
324 dstPixelPtr[3] = (DTYPE) res3;
325 }
326
327 COUNT(0);
328 COUNT(1);
329 COUNT(2);
330 COUNT(3);
331 dstPixelPtr[0] = (DTYPE) res0;
332 dstPixelPtr[1] = (DTYPE) res1;
333 dstPixelPtr[2] = (DTYPE) res2;
334 dstPixelPtr[3] = (DTYPE) res3;
335 }
336
337 return MLIB_SUCCESS;
338 }
339
340 /***************************************************************/
|