Update contrib.
2 * LIBOIL - Library of Optimized Inner Loops
3 * Copyright (c) 2003,2004 David A. Schleef <ds@schleef.org>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
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.
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.
27 //Portions Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
33 #include <liboil/liboilfunction.h>
34 #include "liboil/simdpack/simdpack.h"
37 #define ABS(x) ((x)>0 ? (x) : -(x))
38 #define DSP_OP_ABS_DIFF(a,b) ABS((((int)(a)) - ((int)(b))))
46 * Calculates the sum of absolute differences between @s1_8x8 and @s1_8s8
47 * for the first 4 elements of the first row, and the sum of absolute
48 * differences for the last 4 elements of the first row, and places the
49 * maximum of those values in @dest.
51 * FIXME: This function is declared incorrectly.
53 OIL_DEFINE_CLASS (rowsad8x8_u8,
54 "uint32_t *d_1, uint8_t *s1_8x8, uint8_t *s2_8x8");
61 * Divides the 8x8 block into 16 1x4 regions, and calculates the
62 * sum of absolute differences between @s1_8x8 and @s2_8x8 for
63 * each region. The maximum of the results in each region is
66 OIL_DEFINE_CLASS (colsad8x8_u8,
67 "uint32_t *d_1, uint8_t *s1_8x8, int ss1, uint8_t *s2_8x8, int ss2");
70 rowsad8x8_u8_ref (uint32_t *dest, uint8_t *src1, uint8_t *src2)
75 SadValue = DSP_OP_ABS_DIFF (src1[0], src2[0]) +
76 DSP_OP_ABS_DIFF (src1[1], src2[1]) +
77 DSP_OP_ABS_DIFF (src1[2], src2[2]) +
78 DSP_OP_ABS_DIFF (src1[3], src2[3]);
80 SadValue1 = DSP_OP_ABS_DIFF (src1[4], src2[4]) +
81 DSP_OP_ABS_DIFF (src1[5], src2[5]) +
82 DSP_OP_ABS_DIFF (src1[6], src2[6]) +
83 DSP_OP_ABS_DIFF (src1[7], src2[7]);
85 *dest = (SadValue > SadValue1) ? SadValue : SadValue1;
87 OIL_DEFINE_IMPL_REF (rowsad8x8_u8_ref, rowsad8x8_u8);
90 colsad8x8_u8_ref (uint32_t *dest, uint8_t *src1, int ss1, uint8_t *src2, int ss2)
92 uint32_t SadValue[8] = {0,0,0,0,0,0,0,0};
93 uint32_t SadValue2[8] = {0,0,0,0,0,0,0,0};
97 for ( i = 0; i < 4; i++ ){
98 SadValue[0] += ABS(src1[0] - src2[0]);
99 SadValue[1] += ABS(src1[1] - src2[1]);
100 SadValue[2] += ABS(src1[2] - src2[2]);
101 SadValue[3] += ABS(src1[3] - src2[3]);
102 SadValue[4] += ABS(src1[4] - src2[4]);
103 SadValue[5] += ABS(src1[5] - src2[5]);
104 SadValue[6] += ABS(src1[6] - src2[6]);
105 SadValue[7] += ABS(src1[7] - src2[7]);
111 for ( i = 0; i < 4; i++ ){
112 SadValue2[0] += ABS(src1[0] - src2[0]);
113 SadValue2[1] += ABS(src1[1] - src2[1]);
114 SadValue2[2] += ABS(src1[2] - src2[2]);
115 SadValue2[3] += ABS(src1[3] - src2[3]);
116 SadValue2[4] += ABS(src1[4] - src2[4]);
117 SadValue2[5] += ABS(src1[5] - src2[5]);
118 SadValue2[6] += ABS(src1[6] - src2[6]);
119 SadValue2[7] += ABS(src1[7] - src2[7]);
125 for ( i = 0; i < 8; i++ ){
126 if ( SadValue[i] > MaxSad )
127 MaxSad = SadValue[i];
128 if ( SadValue2[i] > MaxSad )
129 MaxSad = SadValue2[i];
134 OIL_DEFINE_IMPL_REF (colsad8x8_u8_ref, colsad8x8_u8);
140 OilFunctionClass* __oil_function_class_rowsad8x8_u8() {
141 return &_oil_function_class_rowsad8x8_u8;
147 OilFunctionClass* __oil_function_class_colsad8x8_u8() {
148 return &_oil_function_class_colsad8x8_u8;
156 OilFunctionImpl* __oil_function_impl_rowsad8x8_u8_ref() {
157 return &_oil_function_impl_rowsad8x8_u8_ref;
163 OilFunctionImpl* __oil_function_impl_colsad8x8_u8_ref() {
164 return &_oil_function_impl_colsad8x8_u8_ref;
172 EXPORT_C void** _oil_function_class_ptr_rowsad8x8_u8 () {
173 oil_function_class_ptr_rowsad8x8_u8 = __oil_function_class_rowsad8x8_u8();
174 return &oil_function_class_ptr_rowsad8x8_u8->func;
180 EXPORT_C void** _oil_function_class_ptr_colsad8x8_u8 () {
181 oil_function_class_ptr_colsad8x8_u8 = __oil_function_class_colsad8x8_u8();
182 return &oil_function_class_ptr_colsad8x8_u8->func;