Update contrib.
2 * LIBOIL - Library of Optimized Inner Loops
3 * Copyright (c) 2001,2002,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/liboil.h>
34 #include <liboil/liboiltest.h>
35 #include <liboil/liboilrandom.h>
36 #include "liboil/dct/dct.h"
41 #pragma warn_unusedarg off
46 idct8theora_s16_test (OilTest *test)
49 int stride = test->params[OIL_ARG_SSTR1].value;
50 uint16_t *ptr = (uint16_t *)oil_test_get_source_data(test,OIL_ARG_SRC1);
53 OIL_GET(ptr, i*stride, int16_t) = oil_rand_s16() >> 3;
54 //OIL_GET(ptr, i*stride, int16_t) = 0;
56 //OIL_GET(ptr, 0*stride, int16_t) = 100;
61 idct8x8theora_s16_test (OilTest *test)
65 int stride = test->params[OIL_ARG_SSTR1].value;
66 uint16_t *ptr = (uint16_t *)oil_test_get_source_data(test,OIL_ARG_SRC1);
70 OIL_GET(ptr, i*stride + j*2, int16_t) = oil_rand_s16() >> 3;
77 * oil_idct8theora_s16:
83 * Performs a Inverse Discrete Cosine Transform on @s_8 and places
84 * the result in @d_8, as defined by the Theora specification.
86 OIL_DEFINE_CLASS_FULL (idct8theora_s16, "int16_t *d_8, int dstr, int16_t *s_8, int sstr", idct8theora_s16_test);
88 * oil_idct8x8theora_s16:
94 * Performs a Inverse Discrete Cosine Transform on @s_8x8 and places
95 * the result in @d_8x8, as defined by the Theora specification.
97 OIL_DEFINE_CLASS_FULL (idct8x8theora_s16, "int16_t *d_8x8, int dstr, int16_t *s_8x8, int sstr", idct8x8theora_s16_test);
117 #define TRUNC(x) ((int16_t)x)
118 #define MULT(a,b) (((a)*(b))>>16)
121 idct8theora_s16_ref (int16_t *dest, int dstr, const int16_t *src, int sstr)
126 #define Y(i) OIL_GET(src,sstr*(i),int16_t)
127 #define X(i) OIL_GET(dest,sstr*(i),int16_t)
129 /* the ordering here corresponds closely to the theora spec */
130 t[0] = MULT(C4, Y(0) + Y(4));
132 t[1] = MULT(C4, Y(0) - Y(4));
134 t[2] = MULT(C6, Y(2)) - MULT(S6, Y(6));
135 t[3] = MULT(S6, Y(2)) + MULT(C6, Y(6));
136 t[4] = MULT(C7, Y(1)) - MULT(S7, Y(7));
137 t[5] = MULT(C3, Y(5)) - MULT(S3, Y(3));
138 t[6] = MULT(S3, Y(5)) + MULT(C3, Y(3));
139 t[7] = MULT(S7, Y(1)) + MULT(C7, Y(7));
141 t[5] = MULT(C4, t[4] - t[5]);
145 t[6] = MULT(C4, t[7] - t[6]);
182 OIL_DEFINE_IMPL_REF (idct8theora_s16_ref, idct8theora_s16);
186 idct8x8theora_s16_ref (int16_t *dest, int dstr, const int16_t *src, int sstr)
193 OIL_OFFSET(tmp, 8*sizeof(int16_t) * i), sizeof(int16_t),
194 OIL_OFFSET(src, sstr * i), sizeof(int16_t));
198 OIL_OFFSET(dest, sizeof(int16_t) * i), dstr,
199 OIL_OFFSET(tmp, sizeof(int16_t) * i), sizeof(int16_t) * 8);
202 OIL_DEFINE_IMPL_REF (idct8x8theora_s16_ref, idct8x8theora_s16);
209 OilFunctionClass* __oil_function_class_idct8theora_s16() {
210 return &_oil_function_class_idct8theora_s16;
216 OilFunctionClass* __oil_function_class_idct8x8theora_s16() {
217 return &_oil_function_class_idct8x8theora_s16;
225 OilFunctionImpl* __oil_function_impl_idct8theora_s16_ref() {
226 return &_oil_function_impl_idct8theora_s16_ref;
232 OilFunctionImpl* __oil_function_impl_idct8x8theora_s16_ref() {
233 return &_oil_function_impl_idct8x8theora_s16_ref;
241 EXPORT_C void** _oil_function_class_ptr_idct8theora_s16 () {
242 oil_function_class_ptr_idct8theora_s16 = __oil_function_class_idct8theora_s16();
243 return &oil_function_class_ptr_idct8theora_s16->func;
249 EXPORT_C void** _oil_function_class_ptr_idct8x8theora_s16 () {
250 oil_function_class_ptr_idct8x8theora_s16 = __oil_function_class_idct8x8theora_s16();
251 return &oil_function_class_ptr_idct8x8theora_s16->func;