1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/liboil/src/ref/rowcolsad8x8.c Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,185 @@
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 +#define ABS(x) ((x)>0 ? (x) : -(x))
1.41 +#define DSP_OP_ABS_DIFF(a,b) ABS((((int)(a)) - ((int)(b))))
1.42 +
1.43 +/**
1.44 + * oil_rowsad8x8_u8:
1.45 + * @d_1:
1.46 + * @s1_8x8:
1.47 + * @s2_8x8:
1.48 + *
1.49 + * Calculates the sum of absolute differences between @s1_8x8 and @s1_8s8
1.50 + * for the first 4 elements of the first row, and the sum of absolute
1.51 + * differences for the last 4 elements of the first row, and places the
1.52 + * maximum of those values in @dest.
1.53 + *
1.54 + * FIXME: This function is declared incorrectly.
1.55 + */
1.56 +OIL_DEFINE_CLASS (rowsad8x8_u8,
1.57 + "uint32_t *d_1, uint8_t *s1_8x8, uint8_t *s2_8x8");
1.58 +/**
1.59 + * oil_colsad8x8_u8:
1.60 + * @d_1:
1.61 + * @s1_8x8:
1.62 + * @s2_8x8:
1.63 + *
1.64 + * Divides the 8x8 block into 16 1x4 regions, and calculates the
1.65 + * sum of absolute differences between @s1_8x8 and @s2_8x8 for
1.66 + * each region. The maximum of the results in each region is
1.67 + * placed in @d_1.
1.68 + */
1.69 +OIL_DEFINE_CLASS (colsad8x8_u8,
1.70 + "uint32_t *d_1, uint8_t *s1_8x8, int ss1, uint8_t *s2_8x8, int ss2");
1.71 +
1.72 +static void
1.73 +rowsad8x8_u8_ref (uint32_t *dest, uint8_t *src1, uint8_t *src2)
1.74 +{
1.75 + uint32_t SadValue;
1.76 + uint32_t SadValue1;
1.77 +
1.78 + SadValue = DSP_OP_ABS_DIFF (src1[0], src2[0]) +
1.79 + DSP_OP_ABS_DIFF (src1[1], src2[1]) +
1.80 + DSP_OP_ABS_DIFF (src1[2], src2[2]) +
1.81 + DSP_OP_ABS_DIFF (src1[3], src2[3]);
1.82 +
1.83 + SadValue1 = DSP_OP_ABS_DIFF (src1[4], src2[4]) +
1.84 + DSP_OP_ABS_DIFF (src1[5], src2[5]) +
1.85 + DSP_OP_ABS_DIFF (src1[6], src2[6]) +
1.86 + DSP_OP_ABS_DIFF (src1[7], src2[7]);
1.87 +
1.88 + *dest = (SadValue > SadValue1) ? SadValue : SadValue1;
1.89 +}
1.90 +OIL_DEFINE_IMPL_REF (rowsad8x8_u8_ref, rowsad8x8_u8);
1.91 +
1.92 +static void
1.93 +colsad8x8_u8_ref (uint32_t *dest, uint8_t *src1, int ss1, uint8_t *src2, int ss2)
1.94 +{
1.95 + uint32_t SadValue[8] = {0,0,0,0,0,0,0,0};
1.96 + uint32_t SadValue2[8] = {0,0,0,0,0,0,0,0};
1.97 + uint32_t MaxSad = 0;
1.98 + uint32_t i;
1.99 +
1.100 + for ( i = 0; i < 4; i++ ){
1.101 + SadValue[0] += ABS(src1[0] - src2[0]);
1.102 + SadValue[1] += ABS(src1[1] - src2[1]);
1.103 + SadValue[2] += ABS(src1[2] - src2[2]);
1.104 + SadValue[3] += ABS(src1[3] - src2[3]);
1.105 + SadValue[4] += ABS(src1[4] - src2[4]);
1.106 + SadValue[5] += ABS(src1[5] - src2[5]);
1.107 + SadValue[6] += ABS(src1[6] - src2[6]);
1.108 + SadValue[7] += ABS(src1[7] - src2[7]);
1.109 +
1.110 + src1 += ss1;
1.111 + src2 += ss2;
1.112 + }
1.113 +
1.114 + for ( i = 0; i < 4; i++ ){
1.115 + SadValue2[0] += ABS(src1[0] - src2[0]);
1.116 + SadValue2[1] += ABS(src1[1] - src2[1]);
1.117 + SadValue2[2] += ABS(src1[2] - src2[2]);
1.118 + SadValue2[3] += ABS(src1[3] - src2[3]);
1.119 + SadValue2[4] += ABS(src1[4] - src2[4]);
1.120 + SadValue2[5] += ABS(src1[5] - src2[5]);
1.121 + SadValue2[6] += ABS(src1[6] - src2[6]);
1.122 + SadValue2[7] += ABS(src1[7] - src2[7]);
1.123 +
1.124 + src1 += ss1;
1.125 + src2 += ss2;
1.126 + }
1.127 +
1.128 + for ( i = 0; i < 8; i++ ){
1.129 + if ( SadValue[i] > MaxSad )
1.130 + MaxSad = SadValue[i];
1.131 + if ( SadValue2[i] > MaxSad )
1.132 + MaxSad = SadValue2[i];
1.133 + }
1.134 +
1.135 + *dest = MaxSad;
1.136 +}
1.137 +OIL_DEFINE_IMPL_REF (colsad8x8_u8_ref, colsad8x8_u8);
1.138 +
1.139 +
1.140 +
1.141 +#ifdef __SYMBIAN32__
1.142 +
1.143 +OilFunctionClass* __oil_function_class_rowsad8x8_u8() {
1.144 + return &_oil_function_class_rowsad8x8_u8;
1.145 +}
1.146 +#endif
1.147 +
1.148 +#ifdef __SYMBIAN32__
1.149 +
1.150 +OilFunctionClass* __oil_function_class_colsad8x8_u8() {
1.151 + return &_oil_function_class_colsad8x8_u8;
1.152 +}
1.153 +#endif
1.154 +
1.155 +
1.156 +
1.157 +#ifdef __SYMBIAN32__
1.158 +
1.159 +OilFunctionImpl* __oil_function_impl_rowsad8x8_u8_ref() {
1.160 + return &_oil_function_impl_rowsad8x8_u8_ref;
1.161 +}
1.162 +#endif
1.163 +
1.164 +#ifdef __SYMBIAN32__
1.165 +
1.166 +OilFunctionImpl* __oil_function_impl_colsad8x8_u8_ref() {
1.167 + return &_oil_function_impl_colsad8x8_u8_ref;
1.168 +}
1.169 +#endif
1.170 +
1.171 +
1.172 +
1.173 +#ifdef __SYMBIAN32__
1.174 +
1.175 +EXPORT_C void** _oil_function_class_ptr_rowsad8x8_u8 () {
1.176 + oil_function_class_ptr_rowsad8x8_u8 = __oil_function_class_rowsad8x8_u8();
1.177 + return &oil_function_class_ptr_rowsad8x8_u8->func;
1.178 + }
1.179 +#endif
1.180 +
1.181 +#ifdef __SYMBIAN32__
1.182 +
1.183 +EXPORT_C void** _oil_function_class_ptr_colsad8x8_u8 () {
1.184 + oil_function_class_ptr_colsad8x8_u8 = __oil_function_class_colsad8x8_u8();
1.185 + return &oil_function_class_ptr_colsad8x8_u8->func;
1.186 + }
1.187 +#endif
1.188 +