sl@0
|
1 |
/*
|
sl@0
|
2 |
* LIBOIL - Library of Optimized Inner Loops
|
sl@0
|
3 |
* Copyright (c) 2003,2004 David A. Schleef <ds@schleef.org>
|
sl@0
|
4 |
* All rights reserved.
|
sl@0
|
5 |
*
|
sl@0
|
6 |
* Redistribution and use in source and binary forms, with or without
|
sl@0
|
7 |
* modification, are permitted provided that the following conditions
|
sl@0
|
8 |
* are met:
|
sl@0
|
9 |
* 1. Redistributions of source code must retain the above copyright
|
sl@0
|
10 |
* notice, this list of conditions and the following disclaimer.
|
sl@0
|
11 |
* 2. Redistributions in binary form must reproduce the above copyright
|
sl@0
|
12 |
* notice, this list of conditions and the following disclaimer in the
|
sl@0
|
13 |
* documentation and/or other materials provided with the distribution.
|
sl@0
|
14 |
*
|
sl@0
|
15 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
sl@0
|
16 |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
sl@0
|
17 |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
sl@0
|
18 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
sl@0
|
19 |
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
sl@0
|
20 |
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
sl@0
|
21 |
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
sl@0
|
22 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
sl@0
|
23 |
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
sl@0
|
24 |
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
sl@0
|
25 |
* POSSIBILITY OF SUCH DAMAGE.
|
sl@0
|
26 |
*/
|
sl@0
|
27 |
//Portions Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
|
sl@0
|
28 |
|
sl@0
|
29 |
#ifdef HAVE_CONFIG_H
|
sl@0
|
30 |
#include "config.h"
|
sl@0
|
31 |
#endif
|
sl@0
|
32 |
|
sl@0
|
33 |
#include <liboil/liboilfunction.h>
|
sl@0
|
34 |
#include "liboil/simdpack/simdpack.h"
|
sl@0
|
35 |
#include <math.h>
|
sl@0
|
36 |
|
sl@0
|
37 |
#define ABS(x) ((x)>0 ? (x) : -(x))
|
sl@0
|
38 |
#define DSP_OP_ABS_DIFF(a,b) ABS((((int)(a)) - ((int)(b))))
|
sl@0
|
39 |
|
sl@0
|
40 |
/**
|
sl@0
|
41 |
* oil_rowsad8x8_u8:
|
sl@0
|
42 |
* @d_1:
|
sl@0
|
43 |
* @s1_8x8:
|
sl@0
|
44 |
* @s2_8x8:
|
sl@0
|
45 |
*
|
sl@0
|
46 |
* Calculates the sum of absolute differences between @s1_8x8 and @s1_8s8
|
sl@0
|
47 |
* for the first 4 elements of the first row, and the sum of absolute
|
sl@0
|
48 |
* differences for the last 4 elements of the first row, and places the
|
sl@0
|
49 |
* maximum of those values in @dest.
|
sl@0
|
50 |
*
|
sl@0
|
51 |
* FIXME: This function is declared incorrectly.
|
sl@0
|
52 |
*/
|
sl@0
|
53 |
OIL_DEFINE_CLASS (rowsad8x8_u8,
|
sl@0
|
54 |
"uint32_t *d_1, uint8_t *s1_8x8, uint8_t *s2_8x8");
|
sl@0
|
55 |
/**
|
sl@0
|
56 |
* oil_colsad8x8_u8:
|
sl@0
|
57 |
* @d_1:
|
sl@0
|
58 |
* @s1_8x8:
|
sl@0
|
59 |
* @s2_8x8:
|
sl@0
|
60 |
*
|
sl@0
|
61 |
* Divides the 8x8 block into 16 1x4 regions, and calculates the
|
sl@0
|
62 |
* sum of absolute differences between @s1_8x8 and @s2_8x8 for
|
sl@0
|
63 |
* each region. The maximum of the results in each region is
|
sl@0
|
64 |
* placed in @d_1.
|
sl@0
|
65 |
*/
|
sl@0
|
66 |
OIL_DEFINE_CLASS (colsad8x8_u8,
|
sl@0
|
67 |
"uint32_t *d_1, uint8_t *s1_8x8, int ss1, uint8_t *s2_8x8, int ss2");
|
sl@0
|
68 |
|
sl@0
|
69 |
static void
|
sl@0
|
70 |
rowsad8x8_u8_ref (uint32_t *dest, uint8_t *src1, uint8_t *src2)
|
sl@0
|
71 |
{
|
sl@0
|
72 |
uint32_t SadValue;
|
sl@0
|
73 |
uint32_t SadValue1;
|
sl@0
|
74 |
|
sl@0
|
75 |
SadValue = DSP_OP_ABS_DIFF (src1[0], src2[0]) +
|
sl@0
|
76 |
DSP_OP_ABS_DIFF (src1[1], src2[1]) +
|
sl@0
|
77 |
DSP_OP_ABS_DIFF (src1[2], src2[2]) +
|
sl@0
|
78 |
DSP_OP_ABS_DIFF (src1[3], src2[3]);
|
sl@0
|
79 |
|
sl@0
|
80 |
SadValue1 = DSP_OP_ABS_DIFF (src1[4], src2[4]) +
|
sl@0
|
81 |
DSP_OP_ABS_DIFF (src1[5], src2[5]) +
|
sl@0
|
82 |
DSP_OP_ABS_DIFF (src1[6], src2[6]) +
|
sl@0
|
83 |
DSP_OP_ABS_DIFF (src1[7], src2[7]);
|
sl@0
|
84 |
|
sl@0
|
85 |
*dest = (SadValue > SadValue1) ? SadValue : SadValue1;
|
sl@0
|
86 |
}
|
sl@0
|
87 |
OIL_DEFINE_IMPL_REF (rowsad8x8_u8_ref, rowsad8x8_u8);
|
sl@0
|
88 |
|
sl@0
|
89 |
static void
|
sl@0
|
90 |
colsad8x8_u8_ref (uint32_t *dest, uint8_t *src1, int ss1, uint8_t *src2, int ss2)
|
sl@0
|
91 |
{
|
sl@0
|
92 |
uint32_t SadValue[8] = {0,0,0,0,0,0,0,0};
|
sl@0
|
93 |
uint32_t SadValue2[8] = {0,0,0,0,0,0,0,0};
|
sl@0
|
94 |
uint32_t MaxSad = 0;
|
sl@0
|
95 |
uint32_t i;
|
sl@0
|
96 |
|
sl@0
|
97 |
for ( i = 0; i < 4; i++ ){
|
sl@0
|
98 |
SadValue[0] += ABS(src1[0] - src2[0]);
|
sl@0
|
99 |
SadValue[1] += ABS(src1[1] - src2[1]);
|
sl@0
|
100 |
SadValue[2] += ABS(src1[2] - src2[2]);
|
sl@0
|
101 |
SadValue[3] += ABS(src1[3] - src2[3]);
|
sl@0
|
102 |
SadValue[4] += ABS(src1[4] - src2[4]);
|
sl@0
|
103 |
SadValue[5] += ABS(src1[5] - src2[5]);
|
sl@0
|
104 |
SadValue[6] += ABS(src1[6] - src2[6]);
|
sl@0
|
105 |
SadValue[7] += ABS(src1[7] - src2[7]);
|
sl@0
|
106 |
|
sl@0
|
107 |
src1 += ss1;
|
sl@0
|
108 |
src2 += ss2;
|
sl@0
|
109 |
}
|
sl@0
|
110 |
|
sl@0
|
111 |
for ( i = 0; i < 4; i++ ){
|
sl@0
|
112 |
SadValue2[0] += ABS(src1[0] - src2[0]);
|
sl@0
|
113 |
SadValue2[1] += ABS(src1[1] - src2[1]);
|
sl@0
|
114 |
SadValue2[2] += ABS(src1[2] - src2[2]);
|
sl@0
|
115 |
SadValue2[3] += ABS(src1[3] - src2[3]);
|
sl@0
|
116 |
SadValue2[4] += ABS(src1[4] - src2[4]);
|
sl@0
|
117 |
SadValue2[5] += ABS(src1[5] - src2[5]);
|
sl@0
|
118 |
SadValue2[6] += ABS(src1[6] - src2[6]);
|
sl@0
|
119 |
SadValue2[7] += ABS(src1[7] - src2[7]);
|
sl@0
|
120 |
|
sl@0
|
121 |
src1 += ss1;
|
sl@0
|
122 |
src2 += ss2;
|
sl@0
|
123 |
}
|
sl@0
|
124 |
|
sl@0
|
125 |
for ( i = 0; i < 8; i++ ){
|
sl@0
|
126 |
if ( SadValue[i] > MaxSad )
|
sl@0
|
127 |
MaxSad = SadValue[i];
|
sl@0
|
128 |
if ( SadValue2[i] > MaxSad )
|
sl@0
|
129 |
MaxSad = SadValue2[i];
|
sl@0
|
130 |
}
|
sl@0
|
131 |
|
sl@0
|
132 |
*dest = MaxSad;
|
sl@0
|
133 |
}
|
sl@0
|
134 |
OIL_DEFINE_IMPL_REF (colsad8x8_u8_ref, colsad8x8_u8);
|
sl@0
|
135 |
|
sl@0
|
136 |
|
sl@0
|
137 |
|
sl@0
|
138 |
#ifdef __SYMBIAN32__
|
sl@0
|
139 |
|
sl@0
|
140 |
OilFunctionClass* __oil_function_class_rowsad8x8_u8() {
|
sl@0
|
141 |
return &_oil_function_class_rowsad8x8_u8;
|
sl@0
|
142 |
}
|
sl@0
|
143 |
#endif
|
sl@0
|
144 |
|
sl@0
|
145 |
#ifdef __SYMBIAN32__
|
sl@0
|
146 |
|
sl@0
|
147 |
OilFunctionClass* __oil_function_class_colsad8x8_u8() {
|
sl@0
|
148 |
return &_oil_function_class_colsad8x8_u8;
|
sl@0
|
149 |
}
|
sl@0
|
150 |
#endif
|
sl@0
|
151 |
|
sl@0
|
152 |
|
sl@0
|
153 |
|
sl@0
|
154 |
#ifdef __SYMBIAN32__
|
sl@0
|
155 |
|
sl@0
|
156 |
OilFunctionImpl* __oil_function_impl_rowsad8x8_u8_ref() {
|
sl@0
|
157 |
return &_oil_function_impl_rowsad8x8_u8_ref;
|
sl@0
|
158 |
}
|
sl@0
|
159 |
#endif
|
sl@0
|
160 |
|
sl@0
|
161 |
#ifdef __SYMBIAN32__
|
sl@0
|
162 |
|
sl@0
|
163 |
OilFunctionImpl* __oil_function_impl_colsad8x8_u8_ref() {
|
sl@0
|
164 |
return &_oil_function_impl_colsad8x8_u8_ref;
|
sl@0
|
165 |
}
|
sl@0
|
166 |
#endif
|
sl@0
|
167 |
|
sl@0
|
168 |
|
sl@0
|
169 |
|
sl@0
|
170 |
#ifdef __SYMBIAN32__
|
sl@0
|
171 |
|
sl@0
|
172 |
EXPORT_C void** _oil_function_class_ptr_rowsad8x8_u8 () {
|
sl@0
|
173 |
oil_function_class_ptr_rowsad8x8_u8 = __oil_function_class_rowsad8x8_u8();
|
sl@0
|
174 |
return &oil_function_class_ptr_rowsad8x8_u8->func;
|
sl@0
|
175 |
}
|
sl@0
|
176 |
#endif
|
sl@0
|
177 |
|
sl@0
|
178 |
#ifdef __SYMBIAN32__
|
sl@0
|
179 |
|
sl@0
|
180 |
EXPORT_C void** _oil_function_class_ptr_colsad8x8_u8 () {
|
sl@0
|
181 |
oil_function_class_ptr_colsad8x8_u8 = __oil_function_class_colsad8x8_u8();
|
sl@0
|
182 |
return &oil_function_class_ptr_colsad8x8_u8->func;
|
sl@0
|
183 |
}
|
sl@0
|
184 |
#endif
|
sl@0
|
185 |
|