1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/liboil/src/ref/sad8x8.c Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,499 @@
1.4 +/*
1.5 + * LIBOIL - Library of Optimized Inner Loops
1.6 + * Copyright (c) 2003,2004 David A. Schleef <ds@schleef.org>
1.7 + * All rights reserved.
1.8 + *
1.9 + * Redistribution and use in source and binary forms, with or without
1.10 + * modification, are permitted provided that the following conditions
1.11 + * are met:
1.12 + * 1. Redistributions of source code must retain the above copyright
1.13 + * notice, this list of conditions and the following disclaimer.
1.14 + * 2. Redistributions in binary form must reproduce the above copyright
1.15 + * notice, this list of conditions and the following disclaimer in the
1.16 + * documentation and/or other materials provided with the distribution.
1.17 + *
1.18 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1.19 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1.20 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1.21 + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
1.22 + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1.23 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1.24 + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1.25 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
1.26 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
1.27 + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1.28 + * POSSIBILITY OF SUCH DAMAGE.
1.29 + */
1.30 +//Portions Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
1.31 +
1.32 +#ifdef HAVE_CONFIG_H
1.33 +#include "config.h"
1.34 +#endif
1.35 +
1.36 +#include <liboil/liboilfunction.h>
1.37 +#include "liboil/simdpack/simdpack.h"
1.38 +#include <math.h>
1.39 +
1.40 +
1.41 +/**
1.42 + * oil_sad8x8_u8:
1.43 + * @d_1:
1.44 + * @s1_8x8:
1.45 + * @ss1:
1.46 + * @s2_8x8:
1.47 + * @ss2:
1.48 + *
1.49 + * Calculates the sum of absolute differences between elements in @s1_8x8
1.50 + * and @s2_8x8, and places the result in @d_1.
1.51 + */
1.52 +OIL_DEFINE_CLASS (sad8x8_u8,
1.53 + "uint32_t *d_1, uint8_t *s1_8x8, int ss1, uint8_t *s2_8x8, int ss2");
1.54 +/**
1.55 + * oil_sad8x8_s16_2:
1.56 + * @d_1:
1.57 + * @s1_8x8:
1.58 + * @ss1:
1.59 + * @s2_8x8:
1.60 + * @ss2:
1.61 + *
1.62 + * Calculates the sum of absolute differences between elements in @s1_8x8
1.63 + * and @s2_8x8, and places the result in @d_1.
1.64 + */
1.65 +OIL_DEFINE_CLASS (sad8x8_s16_2,
1.66 + "uint32_t *d_1, int16_t *s1_8x8, int ss1, int16_t *s2_8x8, int ss2");
1.67 +/**
1.68 + * oil_sad8x8_f64_2:
1.69 + * @d_1:
1.70 + * @s1_8x8:
1.71 + * @ss1:
1.72 + * @s2_8x8:
1.73 + * @ss2:
1.74 + *
1.75 + * Calculates the sum of absolute differences between elements in @s1_8x8
1.76 + * and @s2_8x8, and places the result in @d_1.
1.77 + */
1.78 +OIL_DEFINE_CLASS (sad8x8_f64_2,
1.79 + "double *d_1, double *s1_8x8, int ss1, double *s2_8x8, int ss2");
1.80 +/**
1.81 + * oil_sad8x8_8xn_u8:
1.82 + * @d_1:
1.83 + * @s1_8x8:
1.84 + * @ss1:
1.85 + * @s2_8xnp7:
1.86 + * @ss2:
1.87 + * @n:
1.88 + *
1.89 + * Calculates the sum of absolute differences between elements in @s1_8x8
1.90 + * and the 8x8 block of array elements starting at row i in @s2_8x8, and
1.91 + * places the result in @d_n.
1.92 + */
1.93 +OIL_DEFINE_CLASS (sad8x8_8xn_u8,
1.94 + "uint32_t *d_n, uint8_t *s1_8x8, int ss1, uint8_t *s2_8xnp7, int ss2, int n");
1.95 +
1.96 +/**
1.97 + * oil_sad12x12_u8:
1.98 + * @d_1:
1.99 + * @s1_12x12:
1.100 + * @ss1:
1.101 + * @s2_12x12:
1.102 + * @ss2:
1.103 + *
1.104 + * Calculates the sum of absolute differences between elements in @s1_12x12
1.105 + * and @s2_12x12, and places the result in @d_1.
1.106 + */
1.107 +OIL_DEFINE_CLASS (sad12x12_u8,
1.108 + "uint32_t *d_1, uint8_t *s1_12x12, int ss1, uint8_t *s2_12x12, int ss2");
1.109 +/**
1.110 + * oil_sad12x12_12xn_u8:
1.111 + * @d_1:
1.112 + * @s1_12x12:
1.113 + * @ss1:
1.114 + * @s2_12xnp11:
1.115 + * @ss2:
1.116 + * @n:
1.117 + *
1.118 + * Calculates the sum of absolute differences between elements in @s1_12x12
1.119 + * and the 12x12 block of array elements starting at row i in @s2_12x12, and
1.120 + * places the result in @d_n.
1.121 + */
1.122 +OIL_DEFINE_CLASS (sad12x12_12xn_u8,
1.123 + "uint32_t *d_n, uint8_t *s1_12x12, int ss1, uint8_t *s2_12xnp11, int ss2, int n");
1.124 +/**
1.125 + * oil_sad16x16_u8:
1.126 + * @d_1:
1.127 + * @s1_16x16:
1.128 + * @ss1:
1.129 + * @s2_16x16:
1.130 + * @ss2:
1.131 + *
1.132 + * Calculates the sum of absolute differences between elements in @s1_16x16
1.133 + * and @s2_16x16, and places the result in @d_1.
1.134 + */
1.135 +OIL_DEFINE_CLASS (sad16x16_u8,
1.136 + "uint32_t *d_1, uint8_t *s1_16x16, int ss1, uint8_t *s2_16x16, int ss2");
1.137 +/**
1.138 + * oil_sad16x16_16xn_u8:
1.139 + * @d_1:
1.140 + * @s1_16x16:
1.141 + * @ss1:
1.142 + * @s2_16xnp15:
1.143 + * @ss2:
1.144 + * @n:
1.145 + *
1.146 + * Calculates the sum of absolute differences between elements in @s1_16x16
1.147 + * and the 16x16 block of array elements starting at row i in @s2_16x16, and
1.148 + * places the result in @d_n.
1.149 + */
1.150 +OIL_DEFINE_CLASS (sad16x16_16xn_u8,
1.151 + "uint32_t *d_n, uint8_t *s1_16x16, int ss1, uint8_t *s2_16xnp15, int ss2, int n");
1.152 +
1.153 +
1.154 +static void
1.155 +sad8x8_f64_2_ref (double *dest, double *src1, int sstr1, double *src2,
1.156 + int sstr2)
1.157 +{
1.158 + int i, j;
1.159 + double sum;
1.160 +
1.161 + sum = 0;
1.162 + for (i = 0; i < 8; i++) {
1.163 + for (j = 0; j < 8; j++) {
1.164 + sum += fabs (OIL_GET (src1, sstr1 * i + j * sizeof (double), double) -
1.165 + OIL_GET (src2, sstr2 * i + j * sizeof (double), double));
1.166 + }
1.167 + }
1.168 + *dest = sum;
1.169 +}
1.170 +
1.171 +OIL_DEFINE_IMPL_REF (sad8x8_f64_2_ref, sad8x8_f64_2);
1.172 +
1.173 +static void
1.174 +sad8x8_s16_2_ref (uint32_t * dest, int16_t * src1, int sstr1, int16_t * src2,
1.175 + int sstr2)
1.176 +{
1.177 + int i, j;
1.178 + int d;
1.179 + uint32_t sum;
1.180 +
1.181 + sum = 0;
1.182 + for (i = 0; i < 8; i++) {
1.183 + for (j = 0; j < 8; j++) {
1.184 + d = ((int) OIL_GET (src1, sstr1 * i + j * sizeof (int16_t), int16_t)) -
1.185 + ((int) OIL_GET (src2, sstr2 * i + j * sizeof (int16_t), int16_t));
1.186 + sum += (d < 0) ? -d : d;
1.187 + }
1.188 + }
1.189 + *dest = sum;
1.190 +}
1.191 +OIL_DEFINE_IMPL_REF (sad8x8_s16_2_ref, sad8x8_s16_2);
1.192 +
1.193 +static void
1.194 +sad8x8_u8_ref (uint32_t * dest, uint8_t * src1, int sstr1, uint8_t * src2,
1.195 + int sstr2)
1.196 +{
1.197 + int i, j;
1.198 + int d;
1.199 + uint32_t sum;
1.200 +
1.201 + sum = 0;
1.202 + for (i = 0; i < 8; i++) {
1.203 + for (j = 0; j < 8; j++) {
1.204 + d = ((int) OIL_GET (src1, sstr1 * i + j * sizeof (uint8_t), uint8_t)) -
1.205 + ((int) OIL_GET (src2, sstr2 * i + j * sizeof (uint8_t), uint8_t));
1.206 + sum += (d < 0) ? -d : d;
1.207 + }
1.208 + }
1.209 + *dest = sum;
1.210 +}
1.211 +OIL_DEFINE_IMPL_REF (sad8x8_u8_ref, sad8x8_u8);
1.212 +
1.213 +static void
1.214 +sad8x8_8xn_u8_ref (uint32_t * dest, uint8_t * src1, int sstr1, uint8_t * src2,
1.215 + int sstr2, int n)
1.216 +{
1.217 + int i, j, k;
1.218 + int d;
1.219 + uint32_t sum;
1.220 +
1.221 + for (i=0;i<n;i++){
1.222 + sum = 0;
1.223 + for (j = 0; j < 8; j++) {
1.224 + for (k = 0; k < 8; k++) {
1.225 + d = ((int) OIL_GET (src1, sstr1 * j + k * sizeof (uint8_t), uint8_t)) -
1.226 + ((int) OIL_GET (src2, sstr2 * (i+j) + k * sizeof (uint8_t), uint8_t));
1.227 + sum += (d < 0) ? -d : d;
1.228 + }
1.229 + }
1.230 + dest[i] = sum;
1.231 + }
1.232 +}
1.233 +OIL_DEFINE_IMPL_REF (sad8x8_8xn_u8_ref, sad8x8_8xn_u8);
1.234 +
1.235 +
1.236 +static void
1.237 +sad12x12_u8_ref (uint32_t * dest, uint8_t * src1, int sstr1, uint8_t * src2,
1.238 + int sstr2)
1.239 +{
1.240 + int i, j;
1.241 + int d;
1.242 + uint32_t sum;
1.243 +
1.244 + sum = 0;
1.245 + for (i = 0; i < 12; i++) {
1.246 + for (j = 0; j < 12; j++) {
1.247 + d = ((int) OIL_GET (src1, sstr1 * i + j * sizeof (uint8_t), uint8_t)) -
1.248 + ((int) OIL_GET (src2, sstr2 * i + j * sizeof (uint8_t), uint8_t));
1.249 + sum += (d < 0) ? -d : d;
1.250 + }
1.251 + }
1.252 + *dest = sum;
1.253 +}
1.254 +OIL_DEFINE_IMPL_REF (sad12x12_u8_ref, sad12x12_u8);
1.255 +
1.256 +static void
1.257 +sad12x12_12xn_u8_ref (uint32_t * dest, uint8_t * src1, int sstr1, uint8_t * src2,
1.258 + int sstr2, int n)
1.259 +{
1.260 + int i, j, k;
1.261 + int d;
1.262 + uint32_t sum;
1.263 +
1.264 + for (i=0;i<n;i++){
1.265 + sum = 0;
1.266 + for (j = 0; j < 12; j++) {
1.267 + for (k = 0; k < 12; k++) {
1.268 + d = ((int) OIL_GET (src1, sstr1 * j + k * sizeof (uint8_t), uint8_t)) -
1.269 + ((int) OIL_GET (src2, sstr2 * (i+j) + k * sizeof (uint8_t), uint8_t));
1.270 + sum += (d < 0) ? -d : d;
1.271 + }
1.272 + }
1.273 + dest[i] = sum;
1.274 + }
1.275 +}
1.276 +OIL_DEFINE_IMPL_REF (sad12x12_12xn_u8_ref, sad12x12_12xn_u8);
1.277 +
1.278 +
1.279 +static void
1.280 +sad16x16_u8_ref (uint32_t * dest, uint8_t * src1, int sstr1, uint8_t * src2,
1.281 + int sstr2)
1.282 +{
1.283 + int i, j;
1.284 + int d;
1.285 + uint32_t sum;
1.286 +
1.287 + sum = 0;
1.288 + for (i = 0; i < 16; i++) {
1.289 + for (j = 0; j < 16; j++) {
1.290 + d = ((int) OIL_GET (src1, sstr1 * i + j * sizeof (uint8_t), uint8_t)) -
1.291 + ((int) OIL_GET (src2, sstr2 * i + j * sizeof (uint8_t), uint8_t));
1.292 + sum += (d < 0) ? -d : d;
1.293 + }
1.294 + }
1.295 + *dest = sum;
1.296 +}
1.297 +OIL_DEFINE_IMPL_REF (sad16x16_u8_ref, sad16x16_u8);
1.298 +
1.299 +static void
1.300 +sad16x16_16xn_u8_ref (uint32_t * dest, uint8_t * src1, int sstr1, uint8_t * src2,
1.301 + int sstr2, int n)
1.302 +{
1.303 + int i, j, k;
1.304 + int d;
1.305 + uint32_t sum;
1.306 +
1.307 + for (i=0;i<n;i++){
1.308 + sum = 0;
1.309 + for (j = 0; j < 16; j++) {
1.310 + for (k = 0; k < 16; k++) {
1.311 + d = ((int) OIL_GET (src1, sstr1 * j + k * sizeof (uint8_t), uint8_t)) -
1.312 + ((int) OIL_GET (src2, sstr2 * (i+j) + k * sizeof (uint8_t), uint8_t));
1.313 + sum += (d < 0) ? -d : d;
1.314 + }
1.315 + }
1.316 + dest[i] = sum;
1.317 + }
1.318 +}
1.319 +OIL_DEFINE_IMPL_REF (sad16x16_16xn_u8_ref, sad16x16_16xn_u8);
1.320 +
1.321 +
1.322 +
1.323 +#ifdef __SYMBIAN32__
1.324 +
1.325 +OilFunctionClass* __oil_function_class_sad8x8_u8() {
1.326 + return &_oil_function_class_sad8x8_u8;
1.327 +}
1.328 +#endif
1.329 +
1.330 +#ifdef __SYMBIAN32__
1.331 +
1.332 +OilFunctionClass* __oil_function_class_sad8x8_s16_2() {
1.333 + return &_oil_function_class_sad8x8_s16_2;
1.334 +}
1.335 +#endif
1.336 +
1.337 +#ifdef __SYMBIAN32__
1.338 +
1.339 +OilFunctionClass* __oil_function_class_sad8x8_f64_2() {
1.340 + return &_oil_function_class_sad8x8_f64_2;
1.341 +}
1.342 +#endif
1.343 +
1.344 +#ifdef __SYMBIAN32__
1.345 +
1.346 +OilFunctionClass* __oil_function_class_sad8x8_8xn_u8() {
1.347 + return &_oil_function_class_sad8x8_8xn_u8;
1.348 +}
1.349 +#endif
1.350 +
1.351 +#ifdef __SYMBIAN32__
1.352 +
1.353 +OilFunctionClass* __oil_function_class_sad12x12_u8() {
1.354 + return &_oil_function_class_sad12x12_u8;
1.355 +}
1.356 +#endif
1.357 +
1.358 +#ifdef __SYMBIAN32__
1.359 +
1.360 +OilFunctionClass* __oil_function_class_sad12x12_12xn_u8() {
1.361 + return &_oil_function_class_sad12x12_12xn_u8;
1.362 +}
1.363 +#endif
1.364 +
1.365 +#ifdef __SYMBIAN32__
1.366 +
1.367 +OilFunctionClass* __oil_function_class_sad16x16_u8() {
1.368 + return &_oil_function_class_sad16x16_u8;
1.369 +}
1.370 +#endif
1.371 +
1.372 +#ifdef __SYMBIAN32__
1.373 +
1.374 +OilFunctionClass* __oil_function_class_sad16x16_16xn_u8() {
1.375 + return &_oil_function_class_sad16x16_16xn_u8;
1.376 +}
1.377 +#endif
1.378 +
1.379 +
1.380 +
1.381 +#ifdef __SYMBIAN32__
1.382 +
1.383 +OilFunctionImpl* __oil_function_impl_sad8x8_f64_2_ref() {
1.384 + return &_oil_function_impl_sad8x8_f64_2_ref;
1.385 +}
1.386 +#endif
1.387 +
1.388 +#ifdef __SYMBIAN32__
1.389 +
1.390 +OilFunctionImpl* __oil_function_impl_sad8x8_s16_2_ref() {
1.391 + return &_oil_function_impl_sad8x8_s16_2_ref;
1.392 +}
1.393 +#endif
1.394 +
1.395 +#ifdef __SYMBIAN32__
1.396 +
1.397 +OilFunctionImpl* __oil_function_impl_sad8x8_u8_ref() {
1.398 + return &_oil_function_impl_sad8x8_u8_ref;
1.399 +}
1.400 +#endif
1.401 +
1.402 +#ifdef __SYMBIAN32__
1.403 +
1.404 +OilFunctionImpl* __oil_function_impl_sad8x8_8xn_u8_ref() {
1.405 + return &_oil_function_impl_sad8x8_8xn_u8_ref;
1.406 +}
1.407 +#endif
1.408 +
1.409 +#ifdef __SYMBIAN32__
1.410 +
1.411 +OilFunctionImpl* __oil_function_impl_sad12x12_u8_ref() {
1.412 + return &_oil_function_impl_sad12x12_u8_ref;
1.413 +}
1.414 +#endif
1.415 +
1.416 +#ifdef __SYMBIAN32__
1.417 +
1.418 +OilFunctionImpl* __oil_function_impl_sad12x12_12xn_u8_ref() {
1.419 + return &_oil_function_impl_sad12x12_12xn_u8_ref;
1.420 +}
1.421 +#endif
1.422 +
1.423 +#ifdef __SYMBIAN32__
1.424 +
1.425 +OilFunctionImpl* __oil_function_impl_sad16x16_u8_ref() {
1.426 + return &_oil_function_impl_sad16x16_u8_ref;
1.427 +}
1.428 +#endif
1.429 +
1.430 +#ifdef __SYMBIAN32__
1.431 +
1.432 +OilFunctionImpl* __oil_function_impl_sad16x16_16xn_u8_ref() {
1.433 + return &_oil_function_impl_sad16x16_16xn_u8_ref;
1.434 +}
1.435 +#endif
1.436 +
1.437 +
1.438 +
1.439 +#ifdef __SYMBIAN32__
1.440 +
1.441 +EXPORT_C void** _oil_function_class_ptr_sad8x8_u8 () {
1.442 + oil_function_class_ptr_sad8x8_u8 = __oil_function_class_sad8x8_u8();
1.443 + return &oil_function_class_ptr_sad8x8_u8->func;
1.444 + }
1.445 +#endif
1.446 +
1.447 +#ifdef __SYMBIAN32__
1.448 +
1.449 +EXPORT_C void** _oil_function_class_ptr_sad8x8_s16_2 () {
1.450 + oil_function_class_ptr_sad8x8_s16_2 = __oil_function_class_sad8x8_s16_2();
1.451 + return &oil_function_class_ptr_sad8x8_s16_2->func;
1.452 + }
1.453 +#endif
1.454 +
1.455 +#ifdef __SYMBIAN32__
1.456 +
1.457 +EXPORT_C void** _oil_function_class_ptr_sad8x8_f64_2 () {
1.458 + oil_function_class_ptr_sad8x8_f64_2 = __oil_function_class_sad8x8_f64_2();
1.459 + return &oil_function_class_ptr_sad8x8_f64_2->func;
1.460 + }
1.461 +#endif
1.462 +
1.463 +#ifdef __SYMBIAN32__
1.464 +
1.465 +EXPORT_C void** _oil_function_class_ptr_sad8x8_8xn_u8 () {
1.466 + oil_function_class_ptr_sad8x8_8xn_u8 = __oil_function_class_sad8x8_8xn_u8();
1.467 + return &oil_function_class_ptr_sad8x8_8xn_u8->func;
1.468 + }
1.469 +#endif
1.470 +
1.471 +#ifdef __SYMBIAN32__
1.472 +
1.473 +EXPORT_C void** _oil_function_class_ptr_sad12x12_u8 () {
1.474 + oil_function_class_ptr_sad12x12_u8 = __oil_function_class_sad12x12_u8();
1.475 + return &oil_function_class_ptr_sad12x12_u8->func;
1.476 + }
1.477 +#endif
1.478 +
1.479 +#ifdef __SYMBIAN32__
1.480 +
1.481 +EXPORT_C void** _oil_function_class_ptr_sad12x12_12xn_u8 () {
1.482 + oil_function_class_ptr_sad12x12_12xn_u8 = __oil_function_class_sad12x12_12xn_u8();
1.483 + return &oil_function_class_ptr_sad12x12_12xn_u8->func;
1.484 + }
1.485 +#endif
1.486 +
1.487 +#ifdef __SYMBIAN32__
1.488 +
1.489 +EXPORT_C void** _oil_function_class_ptr_sad16x16_u8 () {
1.490 + oil_function_class_ptr_sad16x16_u8 = __oil_function_class_sad16x16_u8();
1.491 + return &oil_function_class_ptr_sad16x16_u8->func;
1.492 + }
1.493 +#endif
1.494 +
1.495 +#ifdef __SYMBIAN32__
1.496 +
1.497 +EXPORT_C void** _oil_function_class_ptr_sad16x16_16xn_u8 () {
1.498 + oil_function_class_ptr_sad16x16_16xn_u8 = __oil_function_class_sad16x16_16xn_u8();
1.499 + return &oil_function_class_ptr_sad16x16_16xn_u8->func;
1.500 + }
1.501 +#endif
1.502 +