|
1 /* |
|
2 * LIBOIL - Library of Optimized Inner Loops |
|
3 * Copyright (c) 2003,2004 David A. Schleef <ds@schleef.org> |
|
4 * All rights reserved. |
|
5 * |
|
6 * Redistribution and use in source and binary forms, with or without |
|
7 * modification, are permitted provided that the following conditions |
|
8 * are met: |
|
9 * 1. Redistributions of source code must retain the above copyright |
|
10 * notice, this list of conditions and the following disclaimer. |
|
11 * 2. Redistributions in binary form must reproduce the above copyright |
|
12 * notice, this list of conditions and the following disclaimer in the |
|
13 * documentation and/or other materials provided with the distribution. |
|
14 * |
|
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
|
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, |
|
19 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
|
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
|
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
|
23 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
|
24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
25 * POSSIBILITY OF SUCH DAMAGE. |
|
26 */ |
|
27 //Portions Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. |
|
28 |
|
29 #ifdef HAVE_CONFIG_H |
|
30 #include "config.h" |
|
31 #endif |
|
32 |
|
33 #include <liboil/liboilfunction.h> |
|
34 #include "liboil/simdpack/simdpack.h" |
|
35 #include <math.h> |
|
36 |
|
37 |
|
38 /** |
|
39 * oil_sad8x8_u8: |
|
40 * @d_1: |
|
41 * @s1_8x8: |
|
42 * @ss1: |
|
43 * @s2_8x8: |
|
44 * @ss2: |
|
45 * |
|
46 * Calculates the sum of absolute differences between elements in @s1_8x8 |
|
47 * and @s2_8x8, and places the result in @d_1. |
|
48 */ |
|
49 OIL_DEFINE_CLASS (sad8x8_u8, |
|
50 "uint32_t *d_1, uint8_t *s1_8x8, int ss1, uint8_t *s2_8x8, int ss2"); |
|
51 /** |
|
52 * oil_sad8x8_s16_2: |
|
53 * @d_1: |
|
54 * @s1_8x8: |
|
55 * @ss1: |
|
56 * @s2_8x8: |
|
57 * @ss2: |
|
58 * |
|
59 * Calculates the sum of absolute differences between elements in @s1_8x8 |
|
60 * and @s2_8x8, and places the result in @d_1. |
|
61 */ |
|
62 OIL_DEFINE_CLASS (sad8x8_s16_2, |
|
63 "uint32_t *d_1, int16_t *s1_8x8, int ss1, int16_t *s2_8x8, int ss2"); |
|
64 /** |
|
65 * oil_sad8x8_f64_2: |
|
66 * @d_1: |
|
67 * @s1_8x8: |
|
68 * @ss1: |
|
69 * @s2_8x8: |
|
70 * @ss2: |
|
71 * |
|
72 * Calculates the sum of absolute differences between elements in @s1_8x8 |
|
73 * and @s2_8x8, and places the result in @d_1. |
|
74 */ |
|
75 OIL_DEFINE_CLASS (sad8x8_f64_2, |
|
76 "double *d_1, double *s1_8x8, int ss1, double *s2_8x8, int ss2"); |
|
77 /** |
|
78 * oil_sad8x8_8xn_u8: |
|
79 * @d_1: |
|
80 * @s1_8x8: |
|
81 * @ss1: |
|
82 * @s2_8xnp7: |
|
83 * @ss2: |
|
84 * @n: |
|
85 * |
|
86 * Calculates the sum of absolute differences between elements in @s1_8x8 |
|
87 * and the 8x8 block of array elements starting at row i in @s2_8x8, and |
|
88 * places the result in @d_n. |
|
89 */ |
|
90 OIL_DEFINE_CLASS (sad8x8_8xn_u8, |
|
91 "uint32_t *d_n, uint8_t *s1_8x8, int ss1, uint8_t *s2_8xnp7, int ss2, int n"); |
|
92 |
|
93 /** |
|
94 * oil_sad12x12_u8: |
|
95 * @d_1: |
|
96 * @s1_12x12: |
|
97 * @ss1: |
|
98 * @s2_12x12: |
|
99 * @ss2: |
|
100 * |
|
101 * Calculates the sum of absolute differences between elements in @s1_12x12 |
|
102 * and @s2_12x12, and places the result in @d_1. |
|
103 */ |
|
104 OIL_DEFINE_CLASS (sad12x12_u8, |
|
105 "uint32_t *d_1, uint8_t *s1_12x12, int ss1, uint8_t *s2_12x12, int ss2"); |
|
106 /** |
|
107 * oil_sad12x12_12xn_u8: |
|
108 * @d_1: |
|
109 * @s1_12x12: |
|
110 * @ss1: |
|
111 * @s2_12xnp11: |
|
112 * @ss2: |
|
113 * @n: |
|
114 * |
|
115 * Calculates the sum of absolute differences between elements in @s1_12x12 |
|
116 * and the 12x12 block of array elements starting at row i in @s2_12x12, and |
|
117 * places the result in @d_n. |
|
118 */ |
|
119 OIL_DEFINE_CLASS (sad12x12_12xn_u8, |
|
120 "uint32_t *d_n, uint8_t *s1_12x12, int ss1, uint8_t *s2_12xnp11, int ss2, int n"); |
|
121 /** |
|
122 * oil_sad16x16_u8: |
|
123 * @d_1: |
|
124 * @s1_16x16: |
|
125 * @ss1: |
|
126 * @s2_16x16: |
|
127 * @ss2: |
|
128 * |
|
129 * Calculates the sum of absolute differences between elements in @s1_16x16 |
|
130 * and @s2_16x16, and places the result in @d_1. |
|
131 */ |
|
132 OIL_DEFINE_CLASS (sad16x16_u8, |
|
133 "uint32_t *d_1, uint8_t *s1_16x16, int ss1, uint8_t *s2_16x16, int ss2"); |
|
134 /** |
|
135 * oil_sad16x16_16xn_u8: |
|
136 * @d_1: |
|
137 * @s1_16x16: |
|
138 * @ss1: |
|
139 * @s2_16xnp15: |
|
140 * @ss2: |
|
141 * @n: |
|
142 * |
|
143 * Calculates the sum of absolute differences between elements in @s1_16x16 |
|
144 * and the 16x16 block of array elements starting at row i in @s2_16x16, and |
|
145 * places the result in @d_n. |
|
146 */ |
|
147 OIL_DEFINE_CLASS (sad16x16_16xn_u8, |
|
148 "uint32_t *d_n, uint8_t *s1_16x16, int ss1, uint8_t *s2_16xnp15, int ss2, int n"); |
|
149 |
|
150 |
|
151 static void |
|
152 sad8x8_f64_2_ref (double *dest, double *src1, int sstr1, double *src2, |
|
153 int sstr2) |
|
154 { |
|
155 int i, j; |
|
156 double sum; |
|
157 |
|
158 sum = 0; |
|
159 for (i = 0; i < 8; i++) { |
|
160 for (j = 0; j < 8; j++) { |
|
161 sum += fabs (OIL_GET (src1, sstr1 * i + j * sizeof (double), double) - |
|
162 OIL_GET (src2, sstr2 * i + j * sizeof (double), double)); |
|
163 } |
|
164 } |
|
165 *dest = sum; |
|
166 } |
|
167 |
|
168 OIL_DEFINE_IMPL_REF (sad8x8_f64_2_ref, sad8x8_f64_2); |
|
169 |
|
170 static void |
|
171 sad8x8_s16_2_ref (uint32_t * dest, int16_t * src1, int sstr1, int16_t * src2, |
|
172 int sstr2) |
|
173 { |
|
174 int i, j; |
|
175 int d; |
|
176 uint32_t sum; |
|
177 |
|
178 sum = 0; |
|
179 for (i = 0; i < 8; i++) { |
|
180 for (j = 0; j < 8; j++) { |
|
181 d = ((int) OIL_GET (src1, sstr1 * i + j * sizeof (int16_t), int16_t)) - |
|
182 ((int) OIL_GET (src2, sstr2 * i + j * sizeof (int16_t), int16_t)); |
|
183 sum += (d < 0) ? -d : d; |
|
184 } |
|
185 } |
|
186 *dest = sum; |
|
187 } |
|
188 OIL_DEFINE_IMPL_REF (sad8x8_s16_2_ref, sad8x8_s16_2); |
|
189 |
|
190 static void |
|
191 sad8x8_u8_ref (uint32_t * dest, uint8_t * src1, int sstr1, uint8_t * src2, |
|
192 int sstr2) |
|
193 { |
|
194 int i, j; |
|
195 int d; |
|
196 uint32_t sum; |
|
197 |
|
198 sum = 0; |
|
199 for (i = 0; i < 8; i++) { |
|
200 for (j = 0; j < 8; j++) { |
|
201 d = ((int) OIL_GET (src1, sstr1 * i + j * sizeof (uint8_t), uint8_t)) - |
|
202 ((int) OIL_GET (src2, sstr2 * i + j * sizeof (uint8_t), uint8_t)); |
|
203 sum += (d < 0) ? -d : d; |
|
204 } |
|
205 } |
|
206 *dest = sum; |
|
207 } |
|
208 OIL_DEFINE_IMPL_REF (sad8x8_u8_ref, sad8x8_u8); |
|
209 |
|
210 static void |
|
211 sad8x8_8xn_u8_ref (uint32_t * dest, uint8_t * src1, int sstr1, uint8_t * src2, |
|
212 int sstr2, int n) |
|
213 { |
|
214 int i, j, k; |
|
215 int d; |
|
216 uint32_t sum; |
|
217 |
|
218 for (i=0;i<n;i++){ |
|
219 sum = 0; |
|
220 for (j = 0; j < 8; j++) { |
|
221 for (k = 0; k < 8; k++) { |
|
222 d = ((int) OIL_GET (src1, sstr1 * j + k * sizeof (uint8_t), uint8_t)) - |
|
223 ((int) OIL_GET (src2, sstr2 * (i+j) + k * sizeof (uint8_t), uint8_t)); |
|
224 sum += (d < 0) ? -d : d; |
|
225 } |
|
226 } |
|
227 dest[i] = sum; |
|
228 } |
|
229 } |
|
230 OIL_DEFINE_IMPL_REF (sad8x8_8xn_u8_ref, sad8x8_8xn_u8); |
|
231 |
|
232 |
|
233 static void |
|
234 sad12x12_u8_ref (uint32_t * dest, uint8_t * src1, int sstr1, uint8_t * src2, |
|
235 int sstr2) |
|
236 { |
|
237 int i, j; |
|
238 int d; |
|
239 uint32_t sum; |
|
240 |
|
241 sum = 0; |
|
242 for (i = 0; i < 12; i++) { |
|
243 for (j = 0; j < 12; j++) { |
|
244 d = ((int) OIL_GET (src1, sstr1 * i + j * sizeof (uint8_t), uint8_t)) - |
|
245 ((int) OIL_GET (src2, sstr2 * i + j * sizeof (uint8_t), uint8_t)); |
|
246 sum += (d < 0) ? -d : d; |
|
247 } |
|
248 } |
|
249 *dest = sum; |
|
250 } |
|
251 OIL_DEFINE_IMPL_REF (sad12x12_u8_ref, sad12x12_u8); |
|
252 |
|
253 static void |
|
254 sad12x12_12xn_u8_ref (uint32_t * dest, uint8_t * src1, int sstr1, uint8_t * src2, |
|
255 int sstr2, int n) |
|
256 { |
|
257 int i, j, k; |
|
258 int d; |
|
259 uint32_t sum; |
|
260 |
|
261 for (i=0;i<n;i++){ |
|
262 sum = 0; |
|
263 for (j = 0; j < 12; j++) { |
|
264 for (k = 0; k < 12; k++) { |
|
265 d = ((int) OIL_GET (src1, sstr1 * j + k * sizeof (uint8_t), uint8_t)) - |
|
266 ((int) OIL_GET (src2, sstr2 * (i+j) + k * sizeof (uint8_t), uint8_t)); |
|
267 sum += (d < 0) ? -d : d; |
|
268 } |
|
269 } |
|
270 dest[i] = sum; |
|
271 } |
|
272 } |
|
273 OIL_DEFINE_IMPL_REF (sad12x12_12xn_u8_ref, sad12x12_12xn_u8); |
|
274 |
|
275 |
|
276 static void |
|
277 sad16x16_u8_ref (uint32_t * dest, uint8_t * src1, int sstr1, uint8_t * src2, |
|
278 int sstr2) |
|
279 { |
|
280 int i, j; |
|
281 int d; |
|
282 uint32_t sum; |
|
283 |
|
284 sum = 0; |
|
285 for (i = 0; i < 16; i++) { |
|
286 for (j = 0; j < 16; j++) { |
|
287 d = ((int) OIL_GET (src1, sstr1 * i + j * sizeof (uint8_t), uint8_t)) - |
|
288 ((int) OIL_GET (src2, sstr2 * i + j * sizeof (uint8_t), uint8_t)); |
|
289 sum += (d < 0) ? -d : d; |
|
290 } |
|
291 } |
|
292 *dest = sum; |
|
293 } |
|
294 OIL_DEFINE_IMPL_REF (sad16x16_u8_ref, sad16x16_u8); |
|
295 |
|
296 static void |
|
297 sad16x16_16xn_u8_ref (uint32_t * dest, uint8_t * src1, int sstr1, uint8_t * src2, |
|
298 int sstr2, int n) |
|
299 { |
|
300 int i, j, k; |
|
301 int d; |
|
302 uint32_t sum; |
|
303 |
|
304 for (i=0;i<n;i++){ |
|
305 sum = 0; |
|
306 for (j = 0; j < 16; j++) { |
|
307 for (k = 0; k < 16; k++) { |
|
308 d = ((int) OIL_GET (src1, sstr1 * j + k * sizeof (uint8_t), uint8_t)) - |
|
309 ((int) OIL_GET (src2, sstr2 * (i+j) + k * sizeof (uint8_t), uint8_t)); |
|
310 sum += (d < 0) ? -d : d; |
|
311 } |
|
312 } |
|
313 dest[i] = sum; |
|
314 } |
|
315 } |
|
316 OIL_DEFINE_IMPL_REF (sad16x16_16xn_u8_ref, sad16x16_16xn_u8); |
|
317 |
|
318 |
|
319 |
|
320 #ifdef __SYMBIAN32__ |
|
321 |
|
322 OilFunctionClass* __oil_function_class_sad8x8_u8() { |
|
323 return &_oil_function_class_sad8x8_u8; |
|
324 } |
|
325 #endif |
|
326 |
|
327 #ifdef __SYMBIAN32__ |
|
328 |
|
329 OilFunctionClass* __oil_function_class_sad8x8_s16_2() { |
|
330 return &_oil_function_class_sad8x8_s16_2; |
|
331 } |
|
332 #endif |
|
333 |
|
334 #ifdef __SYMBIAN32__ |
|
335 |
|
336 OilFunctionClass* __oil_function_class_sad8x8_f64_2() { |
|
337 return &_oil_function_class_sad8x8_f64_2; |
|
338 } |
|
339 #endif |
|
340 |
|
341 #ifdef __SYMBIAN32__ |
|
342 |
|
343 OilFunctionClass* __oil_function_class_sad8x8_8xn_u8() { |
|
344 return &_oil_function_class_sad8x8_8xn_u8; |
|
345 } |
|
346 #endif |
|
347 |
|
348 #ifdef __SYMBIAN32__ |
|
349 |
|
350 OilFunctionClass* __oil_function_class_sad12x12_u8() { |
|
351 return &_oil_function_class_sad12x12_u8; |
|
352 } |
|
353 #endif |
|
354 |
|
355 #ifdef __SYMBIAN32__ |
|
356 |
|
357 OilFunctionClass* __oil_function_class_sad12x12_12xn_u8() { |
|
358 return &_oil_function_class_sad12x12_12xn_u8; |
|
359 } |
|
360 #endif |
|
361 |
|
362 #ifdef __SYMBIAN32__ |
|
363 |
|
364 OilFunctionClass* __oil_function_class_sad16x16_u8() { |
|
365 return &_oil_function_class_sad16x16_u8; |
|
366 } |
|
367 #endif |
|
368 |
|
369 #ifdef __SYMBIAN32__ |
|
370 |
|
371 OilFunctionClass* __oil_function_class_sad16x16_16xn_u8() { |
|
372 return &_oil_function_class_sad16x16_16xn_u8; |
|
373 } |
|
374 #endif |
|
375 |
|
376 |
|
377 |
|
378 #ifdef __SYMBIAN32__ |
|
379 |
|
380 OilFunctionImpl* __oil_function_impl_sad8x8_f64_2_ref() { |
|
381 return &_oil_function_impl_sad8x8_f64_2_ref; |
|
382 } |
|
383 #endif |
|
384 |
|
385 #ifdef __SYMBIAN32__ |
|
386 |
|
387 OilFunctionImpl* __oil_function_impl_sad8x8_s16_2_ref() { |
|
388 return &_oil_function_impl_sad8x8_s16_2_ref; |
|
389 } |
|
390 #endif |
|
391 |
|
392 #ifdef __SYMBIAN32__ |
|
393 |
|
394 OilFunctionImpl* __oil_function_impl_sad8x8_u8_ref() { |
|
395 return &_oil_function_impl_sad8x8_u8_ref; |
|
396 } |
|
397 #endif |
|
398 |
|
399 #ifdef __SYMBIAN32__ |
|
400 |
|
401 OilFunctionImpl* __oil_function_impl_sad8x8_8xn_u8_ref() { |
|
402 return &_oil_function_impl_sad8x8_8xn_u8_ref; |
|
403 } |
|
404 #endif |
|
405 |
|
406 #ifdef __SYMBIAN32__ |
|
407 |
|
408 OilFunctionImpl* __oil_function_impl_sad12x12_u8_ref() { |
|
409 return &_oil_function_impl_sad12x12_u8_ref; |
|
410 } |
|
411 #endif |
|
412 |
|
413 #ifdef __SYMBIAN32__ |
|
414 |
|
415 OilFunctionImpl* __oil_function_impl_sad12x12_12xn_u8_ref() { |
|
416 return &_oil_function_impl_sad12x12_12xn_u8_ref; |
|
417 } |
|
418 #endif |
|
419 |
|
420 #ifdef __SYMBIAN32__ |
|
421 |
|
422 OilFunctionImpl* __oil_function_impl_sad16x16_u8_ref() { |
|
423 return &_oil_function_impl_sad16x16_u8_ref; |
|
424 } |
|
425 #endif |
|
426 |
|
427 #ifdef __SYMBIAN32__ |
|
428 |
|
429 OilFunctionImpl* __oil_function_impl_sad16x16_16xn_u8_ref() { |
|
430 return &_oil_function_impl_sad16x16_16xn_u8_ref; |
|
431 } |
|
432 #endif |
|
433 |
|
434 |
|
435 |
|
436 #ifdef __SYMBIAN32__ |
|
437 |
|
438 EXPORT_C void** _oil_function_class_ptr_sad8x8_u8 () { |
|
439 oil_function_class_ptr_sad8x8_u8 = __oil_function_class_sad8x8_u8(); |
|
440 return &oil_function_class_ptr_sad8x8_u8->func; |
|
441 } |
|
442 #endif |
|
443 |
|
444 #ifdef __SYMBIAN32__ |
|
445 |
|
446 EXPORT_C void** _oil_function_class_ptr_sad8x8_s16_2 () { |
|
447 oil_function_class_ptr_sad8x8_s16_2 = __oil_function_class_sad8x8_s16_2(); |
|
448 return &oil_function_class_ptr_sad8x8_s16_2->func; |
|
449 } |
|
450 #endif |
|
451 |
|
452 #ifdef __SYMBIAN32__ |
|
453 |
|
454 EXPORT_C void** _oil_function_class_ptr_sad8x8_f64_2 () { |
|
455 oil_function_class_ptr_sad8x8_f64_2 = __oil_function_class_sad8x8_f64_2(); |
|
456 return &oil_function_class_ptr_sad8x8_f64_2->func; |
|
457 } |
|
458 #endif |
|
459 |
|
460 #ifdef __SYMBIAN32__ |
|
461 |
|
462 EXPORT_C void** _oil_function_class_ptr_sad8x8_8xn_u8 () { |
|
463 oil_function_class_ptr_sad8x8_8xn_u8 = __oil_function_class_sad8x8_8xn_u8(); |
|
464 return &oil_function_class_ptr_sad8x8_8xn_u8->func; |
|
465 } |
|
466 #endif |
|
467 |
|
468 #ifdef __SYMBIAN32__ |
|
469 |
|
470 EXPORT_C void** _oil_function_class_ptr_sad12x12_u8 () { |
|
471 oil_function_class_ptr_sad12x12_u8 = __oil_function_class_sad12x12_u8(); |
|
472 return &oil_function_class_ptr_sad12x12_u8->func; |
|
473 } |
|
474 #endif |
|
475 |
|
476 #ifdef __SYMBIAN32__ |
|
477 |
|
478 EXPORT_C void** _oil_function_class_ptr_sad12x12_12xn_u8 () { |
|
479 oil_function_class_ptr_sad12x12_12xn_u8 = __oil_function_class_sad12x12_12xn_u8(); |
|
480 return &oil_function_class_ptr_sad12x12_12xn_u8->func; |
|
481 } |
|
482 #endif |
|
483 |
|
484 #ifdef __SYMBIAN32__ |
|
485 |
|
486 EXPORT_C void** _oil_function_class_ptr_sad16x16_u8 () { |
|
487 oil_function_class_ptr_sad16x16_u8 = __oil_function_class_sad16x16_u8(); |
|
488 return &oil_function_class_ptr_sad16x16_u8->func; |
|
489 } |
|
490 #endif |
|
491 |
|
492 #ifdef __SYMBIAN32__ |
|
493 |
|
494 EXPORT_C void** _oil_function_class_ptr_sad16x16_16xn_u8 () { |
|
495 oil_function_class_ptr_sad16x16_16xn_u8 = __oil_function_class_sad16x16_16xn_u8(); |
|
496 return &oil_function_class_ptr_sad16x16_16xn_u8->func; |
|
497 } |
|
498 #endif |
|
499 |