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>
37 * oil_err_intra8x8_u8:
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.
46 OIL_DEFINE_CLASS (err_intra8x8_u8,
47 "uint32_t *d_1, uint8_t *s1_8x8, int ss1");
49 * oil_err_inter8x8_u8:
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.
63 OIL_DEFINE_CLASS (err_inter8x8_u8,
64 "uint32_t *d_1, uint8_t *s1_8x8, int ss1, uint8_t *s2_8x8, int ss2");
66 * oil_err_inter8x8_u8_avg:
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
79 * This result is 64 times the variance of the mean of the intermediate
82 * FIXME: This function is broken, since the reference function uses
83 * @ss2 as the stride for both @s2_8x8 and @s3_8x8.
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");
88 #define DSP_OP_AVG(a,b) ((((int)(a)) + ((int)(b)))/2)
89 #define DSP_OP_DIFF(a,b) (((int)(a)) - ((int)(b)))
92 err_intra8x8_u8_ref (uint32_t *dest, uint8_t *src1, int ss1)
99 /* Examine alternate pixel locations. */
101 xxsum += src1[0]*src1[0];
103 xxsum += src1[1]*src1[1];
105 xxsum += src1[2]*src1[2];
107 xxsum += src1[3]*src1[3];
109 xxsum += src1[4]*src1[4];
111 xxsum += src1[5]*src1[5];
113 xxsum += src1[6]*src1[6];
115 xxsum += src1[7]*src1[7];
117 /* Step to next row of block. */
120 /* Compute population variance as mis-match metric. */
121 *dest = (((xxsum<<6) - xsum*xsum ));
123 OIL_DEFINE_IMPL_REF (err_intra8x8_u8_ref, err_intra8x8_u8);
126 err_inter8x8_u8_ref (uint32_t *dest, uint8_t *src1, int ss1, uint8_t *src2, int ss2)
134 diff = DSP_OP_DIFF (src1[0], src2[0]);
138 diff = DSP_OP_DIFF (src1[1], src2[1]);
142 diff = DSP_OP_DIFF (src1[2], src2[2]);
146 diff = DSP_OP_DIFF (src1[3], src2[3]);
150 diff = DSP_OP_DIFF (src1[4], src2[4]);
154 diff = DSP_OP_DIFF (src1[5], src2[5]);
158 diff = DSP_OP_DIFF (src1[6], src2[6]);
162 diff = DSP_OP_DIFF (src1[7], src2[7]);
166 /* Step to next row of block. */
171 /* Compute and return population variance as mis-match metric. */
172 *dest = (((xxsum<<6) - xsum*xsum));
174 OIL_DEFINE_IMPL_REF (err_inter8x8_u8_ref, err_inter8x8_u8);
177 err_inter8x8_u8_avg_ref (uint32_t *dest, uint8_t *src1, int ss1, uint8_t *src2, uint8_t *src3, int ss2)
185 diff = DSP_OP_DIFF(src1[0], DSP_OP_AVG (src2[0], src3[0]));
189 diff = DSP_OP_DIFF(src1[1], DSP_OP_AVG (src2[1], src3[1]));
193 diff = DSP_OP_DIFF(src1[2], DSP_OP_AVG (src2[2], src3[2]));
197 diff = DSP_OP_DIFF(src1[3], DSP_OP_AVG (src2[3], src3[3]));
201 diff = DSP_OP_DIFF(src1[4], DSP_OP_AVG (src2[4], src3[4]));
205 diff = DSP_OP_DIFF(src1[5], DSP_OP_AVG (src2[5], src3[5]));
209 diff = DSP_OP_DIFF(src1[6], DSP_OP_AVG (src2[6], src3[6]));
213 diff = DSP_OP_DIFF(src1[7], DSP_OP_AVG (src2[7], src3[7]));
217 /* Step to next row of block. */
223 /* Compute and return population variance as mis-match metric. */
224 *dest = (((xxsum<<6) - xsum*xsum));
227 OIL_DEFINE_IMPL_REF (err_inter8x8_u8_avg_ref, err_inter8x8_u8_avg);
232 OilFunctionClass* __oil_function_class_err_intra8x8_u8() {
233 return &_oil_function_class_err_intra8x8_u8;
239 OilFunctionClass* __oil_function_class_err_inter8x8_u8() {
240 return &_oil_function_class_err_inter8x8_u8;
246 OilFunctionClass* __oil_function_class_err_inter8x8_u8_avg() {
247 return &_oil_function_class_err_inter8x8_u8_avg;
255 OilFunctionImpl* __oil_function_impl_err_intra8x8_u8_ref() {
256 return &_oil_function_impl_err_intra8x8_u8_ref;
262 OilFunctionImpl* __oil_function_impl_err_inter8x8_u8_ref() {
263 return &_oil_function_impl_err_inter8x8_u8_ref;
269 OilFunctionImpl* __oil_function_impl_err_inter8x8_u8_avg_ref() {
270 return &_oil_function_impl_err_inter8x8_u8_avg_ref;
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;
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;
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;