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_s16
70 #define FTYPE mlib_d64
71
72 /***************************************************************/
73 #define TTYPE mlib_s32
74 #define I2F(x) (x)
75 #define ROUND(x) (x)
76
77 #define FUN_NAME(CHAN) mlib_ImageAffine_s16_##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 mlib_status FUN_NAME(1ch)(mlib_affine_param *param)
105 {
106 DECLAREVAR_BL();
107 DTYPE *dstLineEnd;
108 DTYPE *srcPixelPtr2;
109 FTYPE scale = (FTYPE) 1.0 / MLIB_PREC;
110
111 for (j = yStart; j <= yFinish; j++) {
112 FTYPE fdx, fdy;
113 TTYPE a00_0, a01_0, a10_0, a11_0;
114 FTYPE pix0_0, pix1_0, res0;
115
116 CLIP(1);
117 dstLineEnd = (DTYPE *) dstData + xRight;
118
119 GET_POINTERS(1);
120 LOAD(0, 0, 1);
121 #ifdef __SUNPRO_C
122 #pragma pipeloop(0)
123 #endif /* __SUNPRO_C */
124 for (; dstPixelPtr < dstLineEnd; dstPixelPtr++) {
125 COUNT(0);
126 GET_POINTERS(1);
127 LOAD(0, 0, 1);
128 dstPixelPtr[0] = (DTYPE) res0;
129 }
130
131 COUNT(0);
132 dstPixelPtr[0] = (DTYPE) res0;
133 }
134
135 return MLIB_SUCCESS;
136 }
137
138 mlib_status FUN_NAME(2ch)(mlib_affine_param *param)
139 {
140 DECLAREVAR_BL();
141 DTYPE *dstLineEnd;
142 DTYPE *srcPixelPtr2;
143 FTYPE scale = (FTYPE) 1.0 / MLIB_PREC;
144
145 for (j = yStart; j <= yFinish; j++) {
146 FTYPE fdx, fdy;
147 TTYPE a00_0, a01_0, a10_0, a11_0;
148 TTYPE a00_1, a01_1, a10_1, a11_1;
149 FTYPE pix0_0, pix1_0, res0;
150 FTYPE pix0_1, pix1_1, res1;
151
152 CLIP(2);
153 dstLineEnd = (DTYPE *) dstData + 2 * xRight;
154
155 GET_POINTERS(2);
156 LOAD(0, 0, 2);
157 LOAD(1, 1, 3);
158 #ifdef __SUNPRO_C
159 #pragma pipeloop(0)
160 #endif /* __SUNPRO_C */
161 for (; dstPixelPtr < dstLineEnd; dstPixelPtr += 2) {
162 COUNT(0);
163 COUNT(1);
164 GET_POINTERS(2);
165 LOAD(0, 0, 2);
166 LOAD(1, 1, 3);
167 dstPixelPtr[0] = (DTYPE) res0;
168 dstPixelPtr[1] = (DTYPE) res1;
169 }
170
171 COUNT(0);
172 COUNT(1);
173 dstPixelPtr[0] = (DTYPE) res0;
174 dstPixelPtr[1] = (DTYPE) res1;
175 }
176
177 return MLIB_SUCCESS;
178 }
179
180 mlib_status FUN_NAME(3ch)(mlib_affine_param *param)
181 {
182 DECLAREVAR_BL();
183 DTYPE *dstLineEnd;
184 DTYPE *srcPixelPtr2;
185 FTYPE scale = (FTYPE) 1.0 / MLIB_PREC;
186
187 for (j = yStart; j <= yFinish; j++) {
188 FTYPE fdx, fdy;
189 FTYPE a00_0, a01_0, a10_0, a11_0;
190 FTYPE a00_1, a01_1, a10_1, a11_1;
191 FTYPE a00_2, a01_2, a10_2, a11_2;
192 FTYPE pix0_0, pix1_0, res0;
193 FTYPE pix0_1, pix1_1, res1;
194 FTYPE pix0_2, pix1_2, res2;
195
196 CLIP(3);
197 dstLineEnd = (DTYPE *) dstData + 3 * xRight;
198
199 GET_POINTERS(3);
200 LOAD(0, 0, 3);
201 LOAD(1, 1, 4);
202 LOAD(2, 2, 5);
203 #ifdef __SUNPRO_C
204 #pragma pipeloop(0)
205 #endif /* __SUNPRO_C */
206 for (; dstPixelPtr < dstLineEnd; dstPixelPtr += 3) {
207 COUNT(0);
208 COUNT(1);
209 COUNT(2);
210 GET_POINTERS(3);
211 LOAD(0, 0, 3);
212 LOAD(1, 1, 4);
213 LOAD(2, 2, 5);
214 dstPixelPtr[0] = (DTYPE) res0;
215 dstPixelPtr[1] = (DTYPE) res1;
216 dstPixelPtr[2] = (DTYPE) res2;
217 }
218
219 COUNT(0);
220 COUNT(1);
221 COUNT(2);
222 dstPixelPtr[0] = (DTYPE) res0;
223 dstPixelPtr[1] = (DTYPE) res1;
224 dstPixelPtr[2] = (DTYPE) res2;
225 }
226
227 return MLIB_SUCCESS;
228 }
229
230 mlib_status FUN_NAME(4ch)(mlib_affine_param *param)
231 {
232 DECLAREVAR_BL();
233 DTYPE *dstLineEnd;
234 DTYPE *srcPixelPtr2;
235 FTYPE scale = (FTYPE) 1.0 / MLIB_PREC;
236
237 for (j = yStart; j <= yFinish; j++) {
238 FTYPE fdx, fdy;
239 TTYPE a00_0, a01_0, a10_0, a11_0;
240 TTYPE a00_1, a01_1, a10_1, a11_1;
241 TTYPE a00_2, a01_2, a10_2, a11_2;
242 TTYPE a00_3, a01_3, a10_3, a11_3;
243 FTYPE pix0_0, pix1_0, res0;
244 FTYPE pix0_1, pix1_1, res1;
245 FTYPE pix0_2, pix1_2, res2;
246 FTYPE pix0_3, pix1_3, res3;
247
248 CLIP(4);
249 dstLineEnd = (DTYPE *) dstData + 4 * xRight;
250
251 GET_POINTERS(4);
252 LOAD(0, 0, 4);
253 LOAD(1, 1, 5);
254 LOAD(2, 2, 6);
255 LOAD(3, 3, 7);
256 #ifdef __SUNPRO_C
257 #pragma pipeloop(0)
258 #endif /* __SUNPRO_C */
259 for (; dstPixelPtr < dstLineEnd; dstPixelPtr += 4) {
260 COUNT(0);
261 COUNT(1);
262 COUNT(2);
263 COUNT(3);
264 GET_POINTERS(4);
265 LOAD(0, 0, 4);
266 LOAD(1, 1, 5);
267 LOAD(2, 2, 6);
268 LOAD(3, 3, 7);
269 dstPixelPtr[0] = (DTYPE) res0;
270 dstPixelPtr[1] = (DTYPE) res1;
271 dstPixelPtr[2] = (DTYPE) res2;
272 dstPixelPtr[3] = (DTYPE) res3;
273 }
274
275 COUNT(0);
276 COUNT(1);
277 COUNT(2);
278 COUNT(3);
279 dstPixelPtr[0] = (DTYPE) res0;
280 dstPixelPtr[1] = (DTYPE) res1;
281 dstPixelPtr[2] = (DTYPE) res2;
282 dstPixelPtr[3] = (DTYPE) res3;
283 }
284
285 return MLIB_SUCCESS;
286 }
287
288 #else /* for x86, using integer multiplies is faster */
289
290 /***************************************************************/
291 /* for SHORT/USHORT decrease MLIB_SHIFT due to
292 * overflow in multiplies like fdy * (a10 - a00)
293 */
294 #undef MLIB_SHIFT
295 #define MLIB_SHIFT 15
296
297 #define MLIB_ROUND (1 << (MLIB_SHIFT - 1))
298
299 /***************************************************************/
300 #define GET_POINTERS(ind) \
301 fdx = X & MLIB_MASK; \
302 fdy = Y & MLIB_MASK; \
303 ySrc = MLIB_POINTER_SHIFT(Y); \
304 xSrc = X >> MLIB_SHIFT; \
305 srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + ind * xSrc; \
306 srcPixelPtr2 = (DTYPE *)((mlib_u8 *)srcPixelPtr + srcYStride); \
307 X += dX; \
308 Y += dY
546 LOAD(2, 2, 6);
547 LOAD(3, 3, 7);
548 dstPixelPtr[0] = (DTYPE) res0;
549 dstPixelPtr[1] = (DTYPE) res1;
550 dstPixelPtr[2] = (DTYPE) res2;
551 dstPixelPtr[3] = (DTYPE) res3;
552 }
553
554 COUNT(0);
555 COUNT(1);
556 COUNT(2);
557 COUNT(3);
558 dstPixelPtr[0] = (DTYPE) res0;
559 dstPixelPtr[1] = (DTYPE) res1;
560 dstPixelPtr[2] = (DTYPE) res2;
561 dstPixelPtr[3] = (DTYPE) res3;
562 }
563
564 return MLIB_SUCCESS;
565 }
566
567 #endif /* __sparc ( for SPARC, using floating-point multiplies is faster ) */
568
569 /***************************************************************/
|
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_s16
70 #define FTYPE mlib_d64
71
72 /***************************************************************/
73 #define TTYPE mlib_s32
74 #define I2F(x) (x)
75 #define ROUND(x) (x)
76
77 #define FUN_NAME(CHAN) mlib_ImageAffine_s16_##CHAN##_bl
78
79 /***************************************************************/
80 /* for x86, using integer multiplies is faster */
81
82 /***************************************************************/
83 /* for SHORT/USHORT decrease MLIB_SHIFT due to
84 * overflow in multiplies like fdy * (a10 - a00)
85 */
86 #undef MLIB_SHIFT
87 #define MLIB_SHIFT 15
88
89 #define MLIB_ROUND (1 << (MLIB_SHIFT - 1))
90
91 /***************************************************************/
92 #define GET_POINTERS(ind) \
93 fdx = X & MLIB_MASK; \
94 fdy = Y & MLIB_MASK; \
95 ySrc = MLIB_POINTER_SHIFT(Y); \
96 xSrc = X >> MLIB_SHIFT; \
97 srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + ind * xSrc; \
98 srcPixelPtr2 = (DTYPE *)((mlib_u8 *)srcPixelPtr + srcYStride); \
99 X += dX; \
100 Y += dY
338 LOAD(2, 2, 6);
339 LOAD(3, 3, 7);
340 dstPixelPtr[0] = (DTYPE) res0;
341 dstPixelPtr[1] = (DTYPE) res1;
342 dstPixelPtr[2] = (DTYPE) res2;
343 dstPixelPtr[3] = (DTYPE) res3;
344 }
345
346 COUNT(0);
347 COUNT(1);
348 COUNT(2);
349 COUNT(3);
350 dstPixelPtr[0] = (DTYPE) res0;
351 dstPixelPtr[1] = (DTYPE) res1;
352 dstPixelPtr[2] = (DTYPE) res2;
353 dstPixelPtr[3] = (DTYPE) res3;
354 }
355
356 return MLIB_SUCCESS;
357 }
358
359 /***************************************************************/
|