|
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 |
|
35 |
|
36 /** |
|
37 * oil_err_intra8x8_u8: |
|
38 * @d_1: |
|
39 * @s1_8x8: |
|
40 * @ss1: |
|
41 * |
|
42 * Calculates the sum of squared differences from the mean over |
|
43 * @s1_8x8 and places the result in @d_1. This result is 64 times |
|
44 * the variance of the mean of @s1_8x8. |
|
45 */ |
|
46 OIL_DEFINE_CLASS (err_intra8x8_u8, |
|
47 "uint32_t *d_1, uint8_t *s1_8x8, int ss1"); |
|
48 /** |
|
49 * oil_err_inter8x8_u8: |
|
50 * @d_1: |
|
51 * @s1_8x8: |
|
52 * @ss1: |
|
53 * @s2_8x8: |
|
54 * @ss2: |
|
55 * |
|
56 * Calculates an intermediate 8x8 block where each element is the |
|
57 * difference between @s1_8x8 and @s2_8x8. |
|
58 * The sum of squares of the difference of each element in the |
|
59 * intermediate block and the mean of the intermediate block is |
|
60 * placed into @d_1. This result is |
|
61 * equal to 64 times the variance of the mean of the intermediate block. |
|
62 */ |
|
63 OIL_DEFINE_CLASS (err_inter8x8_u8, |
|
64 "uint32_t *d_1, uint8_t *s1_8x8, int ss1, uint8_t *s2_8x8, int ss2"); |
|
65 /** |
|
66 * oil_err_inter8x8_u8_avg: |
|
67 * @d_1: |
|
68 * @s1_8x8: |
|
69 * @ss1: |
|
70 * @s2_8x8: |
|
71 * @s3_8x8: |
|
72 * @ss2: |
|
73 * |
|
74 * Calculates an intermediate 8x8 block where each element is the |
|
75 * difference between @s1_8x8 and the average of @s2_8x8 and @s3_8x8. |
|
76 * The sum of squares of the difference of each element in the |
|
77 * intermediate block and the mean of the intermediate block is |
|
78 * placed into @d_1. |
|
79 * This result is 64 times the variance of the mean of the intermediate |
|
80 * block. |
|
81 * |
|
82 * FIXME: This function is broken, since the reference function uses |
|
83 * @ss2 as the stride for both @s2_8x8 and @s3_8x8. |
|
84 */ |
|
85 OIL_DEFINE_CLASS (err_inter8x8_u8_avg, |
|
86 "uint32_t *d_1, uint8_t *s1_8x8, int ss1, uint8_t *s2_8x8, uint8_t *s3_8x8, int ss2"); |
|
87 |
|
88 #define DSP_OP_AVG(a,b) ((((int)(a)) + ((int)(b)))/2) |
|
89 #define DSP_OP_DIFF(a,b) (((int)(a)) - ((int)(b))) |
|
90 |
|
91 static void |
|
92 err_intra8x8_u8_ref (uint32_t *dest, uint8_t *src1, int ss1) |
|
93 { |
|
94 uint32_t i; |
|
95 uint32_t xsum=0; |
|
96 uint32_t xxsum=0; |
|
97 |
|
98 for (i=8; i; i--) { |
|
99 /* Examine alternate pixel locations. */ |
|
100 xsum += src1[0]; |
|
101 xxsum += src1[0]*src1[0]; |
|
102 xsum += src1[1]; |
|
103 xxsum += src1[1]*src1[1]; |
|
104 xsum += src1[2]; |
|
105 xxsum += src1[2]*src1[2]; |
|
106 xsum += src1[3]; |
|
107 xxsum += src1[3]*src1[3]; |
|
108 xsum += src1[4]; |
|
109 xxsum += src1[4]*src1[4]; |
|
110 xsum += src1[5]; |
|
111 xxsum += src1[5]*src1[5]; |
|
112 xsum += src1[6]; |
|
113 xxsum += src1[6]*src1[6]; |
|
114 xsum += src1[7]; |
|
115 xxsum += src1[7]*src1[7]; |
|
116 |
|
117 /* Step to next row of block. */ |
|
118 src1 += ss1; |
|
119 } |
|
120 /* Compute population variance as mis-match metric. */ |
|
121 *dest = (((xxsum<<6) - xsum*xsum )); |
|
122 } |
|
123 OIL_DEFINE_IMPL_REF (err_intra8x8_u8_ref, err_intra8x8_u8); |
|
124 |
|
125 static void |
|
126 err_inter8x8_u8_ref (uint32_t *dest, uint8_t *src1, int ss1, uint8_t *src2, int ss2) |
|
127 { |
|
128 uint32_t i; |
|
129 uint32_t xsum=0; |
|
130 uint32_t xxsum=0; |
|
131 int32_t diff; |
|
132 |
|
133 for (i=8; i; i--) { |
|
134 diff = DSP_OP_DIFF (src1[0], src2[0]); |
|
135 xsum += diff; |
|
136 xxsum += diff*diff; |
|
137 |
|
138 diff = DSP_OP_DIFF (src1[1], src2[1]); |
|
139 xsum += diff; |
|
140 xxsum += diff*diff; |
|
141 |
|
142 diff = DSP_OP_DIFF (src1[2], src2[2]); |
|
143 xsum += diff; |
|
144 xxsum += diff*diff; |
|
145 |
|
146 diff = DSP_OP_DIFF (src1[3], src2[3]); |
|
147 xsum += diff; |
|
148 xxsum += diff*diff; |
|
149 |
|
150 diff = DSP_OP_DIFF (src1[4], src2[4]); |
|
151 xsum += diff; |
|
152 xxsum += diff*diff; |
|
153 |
|
154 diff = DSP_OP_DIFF (src1[5], src2[5]); |
|
155 xsum += diff; |
|
156 xxsum += diff*diff; |
|
157 |
|
158 diff = DSP_OP_DIFF (src1[6], src2[6]); |
|
159 xsum += diff; |
|
160 xxsum += diff*diff; |
|
161 |
|
162 diff = DSP_OP_DIFF (src1[7], src2[7]); |
|
163 xsum += diff; |
|
164 xxsum += diff*diff; |
|
165 |
|
166 /* Step to next row of block. */ |
|
167 src1 += ss1; |
|
168 src2 += ss2; |
|
169 } |
|
170 |
|
171 /* Compute and return population variance as mis-match metric. */ |
|
172 *dest = (((xxsum<<6) - xsum*xsum)); |
|
173 } |
|
174 OIL_DEFINE_IMPL_REF (err_inter8x8_u8_ref, err_inter8x8_u8); |
|
175 |
|
176 static void |
|
177 err_inter8x8_u8_avg_ref (uint32_t *dest, uint8_t *src1, int ss1, uint8_t *src2, uint8_t *src3, int ss2) |
|
178 { |
|
179 uint32_t i; |
|
180 uint32_t xsum=0; |
|
181 uint32_t xxsum=0; |
|
182 int32_t diff; |
|
183 |
|
184 for (i=8; i; i--) { |
|
185 diff = DSP_OP_DIFF(src1[0], DSP_OP_AVG (src2[0], src3[0])); |
|
186 xsum += diff; |
|
187 xxsum += diff*diff; |
|
188 |
|
189 diff = DSP_OP_DIFF(src1[1], DSP_OP_AVG (src2[1], src3[1])); |
|
190 xsum += diff; |
|
191 xxsum += diff*diff; |
|
192 |
|
193 diff = DSP_OP_DIFF(src1[2], DSP_OP_AVG (src2[2], src3[2])); |
|
194 xsum += diff; |
|
195 xxsum += diff*diff; |
|
196 |
|
197 diff = DSP_OP_DIFF(src1[3], DSP_OP_AVG (src2[3], src3[3])); |
|
198 xsum += diff; |
|
199 xxsum += diff*diff; |
|
200 |
|
201 diff = DSP_OP_DIFF(src1[4], DSP_OP_AVG (src2[4], src3[4])); |
|
202 xsum += diff; |
|
203 xxsum += diff*diff; |
|
204 |
|
205 diff = DSP_OP_DIFF(src1[5], DSP_OP_AVG (src2[5], src3[5])); |
|
206 xsum += diff; |
|
207 xxsum += diff*diff; |
|
208 |
|
209 diff = DSP_OP_DIFF(src1[6], DSP_OP_AVG (src2[6], src3[6])); |
|
210 xsum += diff; |
|
211 xxsum += diff*diff; |
|
212 |
|
213 diff = DSP_OP_DIFF(src1[7], DSP_OP_AVG (src2[7], src3[7])); |
|
214 xsum += diff; |
|
215 xxsum += diff*diff; |
|
216 |
|
217 /* Step to next row of block. */ |
|
218 src1 += ss1; |
|
219 src2 += ss2; |
|
220 src3 += ss2; |
|
221 } |
|
222 |
|
223 /* Compute and return population variance as mis-match metric. */ |
|
224 *dest = (((xxsum<<6) - xsum*xsum)); |
|
225 } |
|
226 |
|
227 OIL_DEFINE_IMPL_REF (err_inter8x8_u8_avg_ref, err_inter8x8_u8_avg); |
|
228 |
|
229 |
|
230 #ifdef __SYMBIAN32__ |
|
231 |
|
232 OilFunctionClass* __oil_function_class_err_intra8x8_u8() { |
|
233 return &_oil_function_class_err_intra8x8_u8; |
|
234 } |
|
235 #endif |
|
236 |
|
237 #ifdef __SYMBIAN32__ |
|
238 |
|
239 OilFunctionClass* __oil_function_class_err_inter8x8_u8() { |
|
240 return &_oil_function_class_err_inter8x8_u8; |
|
241 } |
|
242 #endif |
|
243 |
|
244 #ifdef __SYMBIAN32__ |
|
245 |
|
246 OilFunctionClass* __oil_function_class_err_inter8x8_u8_avg() { |
|
247 return &_oil_function_class_err_inter8x8_u8_avg; |
|
248 } |
|
249 #endif |
|
250 |
|
251 |
|
252 |
|
253 #ifdef __SYMBIAN32__ |
|
254 |
|
255 OilFunctionImpl* __oil_function_impl_err_intra8x8_u8_ref() { |
|
256 return &_oil_function_impl_err_intra8x8_u8_ref; |
|
257 } |
|
258 #endif |
|
259 |
|
260 #ifdef __SYMBIAN32__ |
|
261 |
|
262 OilFunctionImpl* __oil_function_impl_err_inter8x8_u8_ref() { |
|
263 return &_oil_function_impl_err_inter8x8_u8_ref; |
|
264 } |
|
265 #endif |
|
266 |
|
267 #ifdef __SYMBIAN32__ |
|
268 |
|
269 OilFunctionImpl* __oil_function_impl_err_inter8x8_u8_avg_ref() { |
|
270 return &_oil_function_impl_err_inter8x8_u8_avg_ref; |
|
271 } |
|
272 #endif |
|
273 |
|
274 |
|
275 |
|
276 #ifdef __SYMBIAN32__ |
|
277 |
|
278 EXPORT_C void** _oil_function_class_ptr_err_intra8x8_u8 () { |
|
279 oil_function_class_ptr_err_intra8x8_u8 = __oil_function_class_err_intra8x8_u8(); |
|
280 return &oil_function_class_ptr_err_intra8x8_u8->func; |
|
281 } |
|
282 #endif |
|
283 |
|
284 #ifdef __SYMBIAN32__ |
|
285 |
|
286 EXPORT_C void** _oil_function_class_ptr_err_inter8x8_u8 () { |
|
287 oil_function_class_ptr_err_inter8x8_u8 = __oil_function_class_err_inter8x8_u8(); |
|
288 return &oil_function_class_ptr_err_inter8x8_u8->func; |
|
289 } |
|
290 #endif |
|
291 |
|
292 #ifdef __SYMBIAN32__ |
|
293 |
|
294 EXPORT_C void** _oil_function_class_ptr_err_inter8x8_u8_avg () { |
|
295 oil_function_class_ptr_err_inter8x8_u8_avg = __oil_function_class_err_inter8x8_u8_avg(); |
|
296 return &oil_function_class_ptr_err_inter8x8_u8_avg->func; |
|
297 } |
|
298 #endif |
|
299 |