sl@0
|
1 |
/*
|
sl@0
|
2 |
* LIBOIL - Library of Optimized Inner Loops
|
sl@0
|
3 |
* Copyright (c) 2001,2002,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/liboil.h>
|
sl@0
|
34 |
#include <liboil/liboiltest.h>
|
sl@0
|
35 |
#include <liboil/liboilrandom.h>
|
sl@0
|
36 |
#include "liboil/dct/dct.h"
|
sl@0
|
37 |
#include <math.h>
|
sl@0
|
38 |
|
sl@0
|
39 |
#ifdef __SYMBIAN32__
|
sl@0
|
40 |
#ifdef __WINSCW__
|
sl@0
|
41 |
#pragma warn_unusedarg off
|
sl@0
|
42 |
#endif//__WINSCW__
|
sl@0
|
43 |
#endif//__SYMBIAN32__
|
sl@0
|
44 |
|
sl@0
|
45 |
static void
|
sl@0
|
46 |
idct8theora_s16_test (OilTest *test)
|
sl@0
|
47 |
{
|
sl@0
|
48 |
int i;
|
sl@0
|
49 |
int stride = test->params[OIL_ARG_SSTR1].value;
|
sl@0
|
50 |
uint16_t *ptr = (uint16_t *)oil_test_get_source_data(test,OIL_ARG_SRC1);
|
sl@0
|
51 |
|
sl@0
|
52 |
for(i=0;i<8;i++){
|
sl@0
|
53 |
OIL_GET(ptr, i*stride, int16_t) = oil_rand_s16() >> 3;
|
sl@0
|
54 |
//OIL_GET(ptr, i*stride, int16_t) = 0;
|
sl@0
|
55 |
}
|
sl@0
|
56 |
//OIL_GET(ptr, 0*stride, int16_t) = 100;
|
sl@0
|
57 |
|
sl@0
|
58 |
}
|
sl@0
|
59 |
|
sl@0
|
60 |
static void
|
sl@0
|
61 |
idct8x8theora_s16_test (OilTest *test)
|
sl@0
|
62 |
{
|
sl@0
|
63 |
int i;
|
sl@0
|
64 |
int j;
|
sl@0
|
65 |
int stride = test->params[OIL_ARG_SSTR1].value;
|
sl@0
|
66 |
uint16_t *ptr = (uint16_t *)oil_test_get_source_data(test,OIL_ARG_SRC1);
|
sl@0
|
67 |
|
sl@0
|
68 |
for(i=0;i<8;i++){
|
sl@0
|
69 |
for(j=0;j<8;j++){
|
sl@0
|
70 |
OIL_GET(ptr, i*stride + j*2, int16_t) = oil_rand_s16() >> 3;
|
sl@0
|
71 |
}
|
sl@0
|
72 |
}
|
sl@0
|
73 |
|
sl@0
|
74 |
}
|
sl@0
|
75 |
|
sl@0
|
76 |
/**
|
sl@0
|
77 |
* oil_idct8theora_s16:
|
sl@0
|
78 |
* @d_8:
|
sl@0
|
79 |
* @dstr:
|
sl@0
|
80 |
* @s_8:
|
sl@0
|
81 |
* @sstr:
|
sl@0
|
82 |
*
|
sl@0
|
83 |
* Performs a Inverse Discrete Cosine Transform on @s_8 and places
|
sl@0
|
84 |
* the result in @d_8, as defined by the Theora specification.
|
sl@0
|
85 |
*/
|
sl@0
|
86 |
OIL_DEFINE_CLASS_FULL (idct8theora_s16, "int16_t *d_8, int dstr, int16_t *s_8, int sstr", idct8theora_s16_test);
|
sl@0
|
87 |
/**
|
sl@0
|
88 |
* oil_idct8x8theora_s16:
|
sl@0
|
89 |
* @d_8x8:
|
sl@0
|
90 |
* @dstr:
|
sl@0
|
91 |
* @s_8x8:
|
sl@0
|
92 |
* @sstr:
|
sl@0
|
93 |
*
|
sl@0
|
94 |
* Performs a Inverse Discrete Cosine Transform on @s_8x8 and places
|
sl@0
|
95 |
* the result in @d_8x8, as defined by the Theora specification.
|
sl@0
|
96 |
*/
|
sl@0
|
97 |
OIL_DEFINE_CLASS_FULL (idct8x8theora_s16, "int16_t *d_8x8, int dstr, int16_t *s_8x8, int sstr", idct8x8theora_s16_test);
|
sl@0
|
98 |
|
sl@0
|
99 |
|
sl@0
|
100 |
|
sl@0
|
101 |
#define C1 64277
|
sl@0
|
102 |
#define C2 60547
|
sl@0
|
103 |
#define C3 54491
|
sl@0
|
104 |
#define C4 46341
|
sl@0
|
105 |
#define C5 36410
|
sl@0
|
106 |
#define C6 25080
|
sl@0
|
107 |
#define C7 12785
|
sl@0
|
108 |
|
sl@0
|
109 |
#define S7 64277
|
sl@0
|
110 |
#define S6 60547
|
sl@0
|
111 |
#define S5 54491
|
sl@0
|
112 |
#define S4 46341
|
sl@0
|
113 |
#define S3 36410
|
sl@0
|
114 |
#define S2 25080
|
sl@0
|
115 |
#define S1 12785
|
sl@0
|
116 |
|
sl@0
|
117 |
#define TRUNC(x) ((int16_t)x)
|
sl@0
|
118 |
#define MULT(a,b) (((a)*(b))>>16)
|
sl@0
|
119 |
|
sl@0
|
120 |
static void
|
sl@0
|
121 |
idct8theora_s16_ref (int16_t *dest, int dstr, const int16_t *src, int sstr)
|
sl@0
|
122 |
{
|
sl@0
|
123 |
int32_t t[10];
|
sl@0
|
124 |
int32_t r;
|
sl@0
|
125 |
|
sl@0
|
126 |
#define Y(i) OIL_GET(src,sstr*(i),int16_t)
|
sl@0
|
127 |
#define X(i) OIL_GET(dest,sstr*(i),int16_t)
|
sl@0
|
128 |
|
sl@0
|
129 |
/* the ordering here corresponds closely to the theora spec */
|
sl@0
|
130 |
t[0] = MULT(C4, Y(0) + Y(4));
|
sl@0
|
131 |
t[0] = TRUNC(t[0]);
|
sl@0
|
132 |
t[1] = MULT(C4, Y(0) - Y(4));
|
sl@0
|
133 |
t[1] = TRUNC(t[1]);
|
sl@0
|
134 |
t[2] = MULT(C6, Y(2)) - MULT(S6, Y(6));
|
sl@0
|
135 |
t[3] = MULT(S6, Y(2)) + MULT(C6, Y(6));
|
sl@0
|
136 |
t[4] = MULT(C7, Y(1)) - MULT(S7, Y(7));
|
sl@0
|
137 |
t[5] = MULT(C3, Y(5)) - MULT(S3, Y(3));
|
sl@0
|
138 |
t[6] = MULT(S3, Y(5)) + MULT(C3, Y(3));
|
sl@0
|
139 |
t[7] = MULT(S7, Y(1)) + MULT(C7, Y(7));
|
sl@0
|
140 |
r = t[4] + t[5];
|
sl@0
|
141 |
t[5] = MULT(C4, t[4] - t[5]);
|
sl@0
|
142 |
t[5] = TRUNC(t[5]);
|
sl@0
|
143 |
t[4] = r;
|
sl@0
|
144 |
r = t[7] + t[6];
|
sl@0
|
145 |
t[6] = MULT(C4, t[7] - t[6]);
|
sl@0
|
146 |
t[6] = TRUNC(t[6]);
|
sl@0
|
147 |
t[7] = r;
|
sl@0
|
148 |
r = t[0] + t[3];
|
sl@0
|
149 |
t[3] = t[0] - t[3];
|
sl@0
|
150 |
t[0] = r;
|
sl@0
|
151 |
r = t[1] + t[2];
|
sl@0
|
152 |
t[2] = t[1] - t[2];
|
sl@0
|
153 |
t[1] = r;
|
sl@0
|
154 |
r = t[6] + t[5];
|
sl@0
|
155 |
t[5] = t[6] - t[5];
|
sl@0
|
156 |
t[6] = r;
|
sl@0
|
157 |
r = t[0] + t[7];
|
sl@0
|
158 |
r = TRUNC(r);
|
sl@0
|
159 |
X(0) = r;
|
sl@0
|
160 |
r = t[1] + t[6];
|
sl@0
|
161 |
r = TRUNC(r);
|
sl@0
|
162 |
X(1) = r;
|
sl@0
|
163 |
r = t[2] + t[5];
|
sl@0
|
164 |
r = TRUNC(r);
|
sl@0
|
165 |
X(2) = r;
|
sl@0
|
166 |
r = t[3] + t[4];
|
sl@0
|
167 |
r = TRUNC(r);
|
sl@0
|
168 |
X(3) = r;
|
sl@0
|
169 |
r = t[3] - t[4];
|
sl@0
|
170 |
r = TRUNC(r);
|
sl@0
|
171 |
X(4) = r;
|
sl@0
|
172 |
r = t[2] - t[5];
|
sl@0
|
173 |
r = TRUNC(r);
|
sl@0
|
174 |
X(5) = r;
|
sl@0
|
175 |
r = t[1] - t[6];
|
sl@0
|
176 |
r = TRUNC(r);
|
sl@0
|
177 |
X(6) = r;
|
sl@0
|
178 |
r = t[0] - t[7];
|
sl@0
|
179 |
r = TRUNC(r);
|
sl@0
|
180 |
X(7) = r;
|
sl@0
|
181 |
}
|
sl@0
|
182 |
OIL_DEFINE_IMPL_REF (idct8theora_s16_ref, idct8theora_s16);
|
sl@0
|
183 |
|
sl@0
|
184 |
|
sl@0
|
185 |
static void
|
sl@0
|
186 |
idct8x8theora_s16_ref (int16_t *dest, int dstr, const int16_t *src, int sstr)
|
sl@0
|
187 |
{
|
sl@0
|
188 |
int i;
|
sl@0
|
189 |
int16_t tmp[64];
|
sl@0
|
190 |
|
sl@0
|
191 |
for(i=0;i<8;i++){
|
sl@0
|
192 |
idct8theora_s16_ref(
|
sl@0
|
193 |
OIL_OFFSET(tmp, 8*sizeof(int16_t) * i), sizeof(int16_t),
|
sl@0
|
194 |
OIL_OFFSET(src, sstr * i), sizeof(int16_t));
|
sl@0
|
195 |
}
|
sl@0
|
196 |
for(i=0;i<8;i++){
|
sl@0
|
197 |
idct8theora_s16_ref(
|
sl@0
|
198 |
OIL_OFFSET(dest, sizeof(int16_t) * i), dstr,
|
sl@0
|
199 |
OIL_OFFSET(tmp, sizeof(int16_t) * i), sizeof(int16_t) * 8);
|
sl@0
|
200 |
}
|
sl@0
|
201 |
}
|
sl@0
|
202 |
OIL_DEFINE_IMPL_REF (idct8x8theora_s16_ref, idct8x8theora_s16);
|
sl@0
|
203 |
|
sl@0
|
204 |
|
sl@0
|
205 |
|
sl@0
|
206 |
|
sl@0
|
207 |
#ifdef __SYMBIAN32__
|
sl@0
|
208 |
|
sl@0
|
209 |
OilFunctionClass* __oil_function_class_idct8theora_s16() {
|
sl@0
|
210 |
return &_oil_function_class_idct8theora_s16;
|
sl@0
|
211 |
}
|
sl@0
|
212 |
#endif
|
sl@0
|
213 |
|
sl@0
|
214 |
#ifdef __SYMBIAN32__
|
sl@0
|
215 |
|
sl@0
|
216 |
OilFunctionClass* __oil_function_class_idct8x8theora_s16() {
|
sl@0
|
217 |
return &_oil_function_class_idct8x8theora_s16;
|
sl@0
|
218 |
}
|
sl@0
|
219 |
#endif
|
sl@0
|
220 |
|
sl@0
|
221 |
|
sl@0
|
222 |
|
sl@0
|
223 |
#ifdef __SYMBIAN32__
|
sl@0
|
224 |
|
sl@0
|
225 |
OilFunctionImpl* __oil_function_impl_idct8theora_s16_ref() {
|
sl@0
|
226 |
return &_oil_function_impl_idct8theora_s16_ref;
|
sl@0
|
227 |
}
|
sl@0
|
228 |
#endif
|
sl@0
|
229 |
|
sl@0
|
230 |
#ifdef __SYMBIAN32__
|
sl@0
|
231 |
|
sl@0
|
232 |
OilFunctionImpl* __oil_function_impl_idct8x8theora_s16_ref() {
|
sl@0
|
233 |
return &_oil_function_impl_idct8x8theora_s16_ref;
|
sl@0
|
234 |
}
|
sl@0
|
235 |
#endif
|
sl@0
|
236 |
|
sl@0
|
237 |
|
sl@0
|
238 |
|
sl@0
|
239 |
#ifdef __SYMBIAN32__
|
sl@0
|
240 |
|
sl@0
|
241 |
EXPORT_C void** _oil_function_class_ptr_idct8theora_s16 () {
|
sl@0
|
242 |
oil_function_class_ptr_idct8theora_s16 = __oil_function_class_idct8theora_s16();
|
sl@0
|
243 |
return &oil_function_class_ptr_idct8theora_s16->func;
|
sl@0
|
244 |
}
|
sl@0
|
245 |
#endif
|
sl@0
|
246 |
|
sl@0
|
247 |
#ifdef __SYMBIAN32__
|
sl@0
|
248 |
|
sl@0
|
249 |
EXPORT_C void** _oil_function_class_ptr_idct8x8theora_s16 () {
|
sl@0
|
250 |
oil_function_class_ptr_idct8x8theora_s16 = __oil_function_class_idct8x8theora_s16();
|
sl@0
|
251 |
return &oil_function_class_ptr_idct8x8theora_s16->func;
|
sl@0
|
252 |
}
|
sl@0
|
253 |
#endif
|
sl@0
|
254 |
|