summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/codecs/libcook/Makefile.test4
-rw-r--r--apps/codecs/libcook/README.rockbox29
-rw-r--r--apps/codecs/libcook/cook_fixp_mdct.h545
-rw-r--r--apps/codecs/libcook/cook_fixpoint.h36
-rw-r--r--apps/codecs/libcook/cookdata_fixpoint.h270
5 files changed, 14 insertions, 870 deletions
diff --git a/apps/codecs/libcook/Makefile.test b/apps/codecs/libcook/Makefile.test
index c8a3236935..2fc34648d1 100644
--- a/apps/codecs/libcook/Makefile.test
+++ b/apps/codecs/libcook/Makefile.test
@@ -1,5 +1,5 @@
1CFLAGS = -Wall -O3 -DTEST -D"DEBUGF=printf" 1CFLAGS = -Wall -O3 -DTEST -D"DEBUGF=printf" -D"ROCKBOX_LITTLE_ENDIAN=1" -D"ICONST_ATTR=" -D"ICODE_ATTR="
2OBJS = main.o bitstream.o cook.o ../librm/rm.o 2OBJS = main.o bitstream.o cook.o ../librm/rm.o ../lib/mdct2.o ../lib/mdct_lookup.o
3cooktest: $(OBJS) 3cooktest: $(OBJS)
4 gcc -o cooktest $(OBJS) 4 gcc -o cooktest $(OBJS)
5 5
diff --git a/apps/codecs/libcook/README.rockbox b/apps/codecs/libcook/README.rockbox
index b51508f8a9..ae72f2a2f2 100644
--- a/apps/codecs/libcook/README.rockbox
+++ b/apps/codecs/libcook/README.rockbox
@@ -13,24 +13,6 @@ IMPORT DETAILS
13 13
14The decoder is based on ffmpeg-svn r18079. 14The decoder is based on ffmpeg-svn r18079.
15 15
16The file libavcodec/cook.c was modified to remove all ffmpeg-specific
17code and to use the current rm parser.
18
19In initializing random_state in COOKContext, ffmpeg used a random_seed()
20function that was weird in the way it gets the random number. So it was
21decided to not use this function at all,and the value was initialized to 1,
22because according to Benjamin Larsson random_seed() could just be
23replaced by any value.
24
25The current files contain lots of code which is either not needed by
26the decoder or totally disabled (#if 0 .. #endif) to enable
27compiling. This was during the isolation of the decoder from ffmpeg,
28the intention was to take as few files as possible to be able to
29compile cook.c and the related files outside ffmpeg.
30
31The decoder still uses floating point and relies on dynamic allocations
32in some parts of it. It's still not ready to be ported to rockbox.
33
34CONVERSION TO FIXED-POINT 16CONVERSION TO FIXED-POINT
35 17
36A patch from ffmpeg's mailing list was used to convert the decoder to 18A patch from ffmpeg's mailing list was used to convert the decoder to
@@ -44,8 +26,9 @@ be done manually. The patch was also applied to cookdata.h and was
44used to create cookdata_fixpoint.h, cook_fixpoint.h and 26used to create cookdata_fixpoint.h, cook_fixpoint.h and
45cook_fixp_mdct.h. 27cook_fixp_mdct.h.
46 28
47The patch used a cook_random() function for noise filling. this was 29cook_fixp_mdct.h and parts from cookdata_fixpoint.h were dropped and
48dropped and av_lfg_get() was used instead for consistency. 30rockbox's mdct library is now used in both the test program and the
31real codec.
49 32
50Note : Only parts of the patch were committed to ffmpeg's repository. 33Note : Only parts of the patch were committed to ffmpeg's repository.
51 34
@@ -54,5 +37,11 @@ TESTING
54The test program should compile in any Unix-like environment using the 37The test program should compile in any Unix-like environment using the
55command "make -f Makefile.test". 38command "make -f Makefile.test".
56 39
40For ARM targets add -DCPU_ARM to CFLAGS in Makefile.test to make use of
41the asm ARM optimisations in rockbox's mdct library.
42
43For Big-endian targets, change -D"ROCKBOX_LITTLE_ENDIAN=1"
44to -D"ROCKBOX_BIG_ENDIAN=1" in Makefile.test.
45
57Running "./cooktest file.rm" will decode the audio data to a WAV file 46Running "./cooktest file.rm" will decode the audio data to a WAV file
58called "output.wav" in the current directory. 47called "output.wav" in the current directory.
diff --git a/apps/codecs/libcook/cook_fixp_mdct.h b/apps/codecs/libcook/cook_fixp_mdct.h
deleted file mode 100644
index dcd6d96227..0000000000
--- a/apps/codecs/libcook/cook_fixp_mdct.h
+++ /dev/null
@@ -1,545 +0,0 @@
1/*
2 * The following (normalized modified discrete cosine transform)
3 * is taken from the OggVorbis 'TREMOR' source code.
4 *
5 * It has been modified for the ffmpeg cook fixed point decoder.
6 */
7
8/********************************************************************
9 * *
10 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
11 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
12 * *
13 ********************************************************************
14
15 Redistribution and use in source and binary forms, with or without
16 modification, are permitted provided that the following conditions
17 are met:
18
19 - Redistributions of source code must retain the above copyright
20 notice, this list of conditions and the following disclaimer.
21
22 - Redistributions in binary form must reproduce the above copyright
23 notice, this list of conditions and the following disclaimer in the
24 documentation and/or other materials provided with the distribution.
25
26 - Neither the name of the Xiph.org Foundation nor the names of its
27 contributors may be used to endorse or promote products derived from
28 this software without specific prior written permission.
29
30 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION
34 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41
42 *********************************************************************
43
44 function: normalized modified discrete cosine transform
45 power of two length transform only [64 <= n ]
46 last mod: $Id: mdct.c 14281 2004-12-30 12:11:32Z henry $
47
48 Original algorithm adapted long ago from _The use of multirate filter
49 banks for coding of high quality digital audio_, by T. Sporer,
50 K. Brandenburg and B. Edler, collection of the European Signal
51 Processing Conference (EUSIPCO), Amsterdam, June 1992, Vol.1, pp
52 211-214
53
54 The below code implements an algorithm that no longer looks much like
55 that presented in the paper, but the basic structure remains if you
56 dig deep enough to see it.
57
58 This module DOES NOT INCLUDE code to generate/apply the window
59 function. Everybody has their own weird favorite including me... I
60 happen to like the properties of y=sin(.5PI*sin^2(x)), but others may
61 vehemently disagree.
62
63 ********************************************************************/
64
65#define STIN static inline
66
67typedef int32_t ogg_int32_t;
68
69#define DATA_TYPE ogg_int32_t
70#define REG_TYPE register ogg_int32_t
71#define LOOKUP_T const uint16_t
72
73static inline ogg_int32_t MULT32(ogg_int32_t x, ogg_int32_t y) {
74 return fixp_mult_su(x, y) >> 1;
75}
76
77static inline ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) {
78 return fixp_mult_su(x, y);
79}
80
81/*
82 * This should be used as a memory barrier, forcing all cached values in
83 * registers to wr writen back to memory. Might or might not be beneficial
84 * depending on the architecture and compiler.
85 */
86#define MB()
87
88/*
89 * The XPROD functions are meant to optimize the cross products found all
90 * over the place in mdct.c by forcing memory operation ordering to avoid
91 * unnecessary register reloads as soon as memory is being written to.
92 * However this is only beneficial on CPUs with a sane number of general
93 * purpose registers which exclude the Intel x86. On Intel, better let the
94 * compiler actually reload registers directly from original memory by using
95 * macros.
96 */
97
98#ifdef __i386__
99
100#define XPROD32(_a, _b, _t, _v, _x, _y) \
101 { *(_x)=MULT32(_a,_t)+MULT32(_b,_v); \
102 *(_y)=MULT32(_b,_t)-MULT32(_a,_v); }
103#define XPROD31(_a, _b, _t, _v, _x, _y) \
104 { *(_x)=MULT31(_a,_t)+MULT31(_b,_v); \
105 *(_y)=MULT31(_b,_t)-MULT31(_a,_v); }
106#define XNPROD31(_a, _b, _t, _v, _x, _y) \
107 { *(_x)=MULT31(_a,_t)-MULT31(_b,_v); \
108 *(_y)=MULT31(_b,_t)+MULT31(_a,_v); }
109
110#else
111
112static inline void XPROD32(ogg_int32_t a, ogg_int32_t b,
113 ogg_int32_t t, ogg_int32_t v,
114 ogg_int32_t *x, ogg_int32_t *y)
115{
116 *x = MULT32(a, t) + MULT32(b, v);
117 *y = MULT32(b, t) - MULT32(a, v);
118}
119
120static inline void XPROD31(ogg_int32_t a, ogg_int32_t b,
121 ogg_int32_t t, ogg_int32_t v,
122 ogg_int32_t *x, ogg_int32_t *y)
123{
124 *x = MULT31(a, t) + MULT31(b, v);
125 *y = MULT31(b, t) - MULT31(a, v);
126}
127
128static inline void XNPROD31(ogg_int32_t a, ogg_int32_t b,
129 ogg_int32_t t, ogg_int32_t v,
130 ogg_int32_t *x, ogg_int32_t *y)
131{
132 *x = MULT31(a, t) - MULT31(b, v);
133 *y = MULT31(b, t) + MULT31(a, v);
134}
135
136#endif
137
138
139/* 8 point butterfly (in place) */
140STIN void mdct_butterfly_8(DATA_TYPE *x){
141
142 REG_TYPE r0 = x[4] + x[0];
143 REG_TYPE r1 = x[4] - x[0];
144 REG_TYPE r2 = x[5] + x[1];
145 REG_TYPE r3 = x[5] - x[1];
146 REG_TYPE r4 = x[6] + x[2];
147 REG_TYPE r5 = x[6] - x[2];
148 REG_TYPE r6 = x[7] + x[3];
149 REG_TYPE r7 = x[7] - x[3];
150
151 x[0] = r5 + r3;
152 x[1] = r7 - r1;
153 x[2] = r5 - r3;
154 x[3] = r7 + r1;
155 x[4] = r4 - r0;
156 x[5] = r6 - r2;
157 x[6] = r4 + r0;
158 x[7] = r6 + r2;
159 MB();
160}
161
162/* 16 point butterfly (in place, 4 register) */
163STIN void mdct_butterfly_16(DATA_TYPE *x){
164
165 REG_TYPE r0, r1;
166
167 r0 = x[ 0] - x[ 8]; x[ 8] += x[ 0];
168 r1 = x[ 1] - x[ 9]; x[ 9] += x[ 1];
169 x[ 0] = MULT31((r0 + r1) , cPI2_8);
170 x[ 1] = MULT31((r1 - r0) , cPI2_8);
171 MB();
172
173 r0 = x[10] - x[ 2]; x[10] += x[ 2];
174 r1 = x[ 3] - x[11]; x[11] += x[ 3];
175 x[ 2] = r1; x[ 3] = r0;
176 MB();
177
178 r0 = x[12] - x[ 4]; x[12] += x[ 4];
179 r1 = x[13] - x[ 5]; x[13] += x[ 5];
180 x[ 4] = MULT31((r0 - r1) , cPI2_8);
181 x[ 5] = MULT31((r0 + r1) , cPI2_8);
182 MB();
183
184 r0 = x[14] - x[ 6]; x[14] += x[ 6];
185 r1 = x[15] - x[ 7]; x[15] += x[ 7];
186 x[ 6] = r0; x[ 7] = r1;
187 MB();
188
189 mdct_butterfly_8(x);
190 mdct_butterfly_8(x+8);
191}
192
193/* 32 point butterfly (in place, 4 register) */
194STIN void mdct_butterfly_32(DATA_TYPE *x){
195
196 REG_TYPE r0, r1;
197
198 r0 = x[30] - x[14]; x[30] += x[14];
199 r1 = x[31] - x[15]; x[31] += x[15];
200 x[14] = r0; x[15] = r1;
201 MB();
202
203 r0 = x[28] - x[12]; x[28] += x[12];
204 r1 = x[29] - x[13]; x[29] += x[13];
205 XNPROD31( r0, r1, cPI1_8, cPI3_8, &x[12], &x[13] );
206 MB();
207
208 r0 = x[26] - x[10]; x[26] += x[10];
209 r1 = x[27] - x[11]; x[27] += x[11];
210 x[10] = MULT31((r0 - r1) , cPI2_8);
211 x[11] = MULT31((r0 + r1) , cPI2_8);
212 MB();
213
214 r0 = x[24] - x[ 8]; x[24] += x[ 8];
215 r1 = x[25] - x[ 9]; x[25] += x[ 9];
216 XNPROD31( r0, r1, cPI3_8, cPI1_8, &x[ 8], &x[ 9] );
217 MB();
218
219 r0 = x[22] - x[ 6]; x[22] += x[ 6];
220 r1 = x[ 7] - x[23]; x[23] += x[ 7];
221 x[ 6] = r1; x[ 7] = r0;
222 MB();
223
224 r0 = x[ 4] - x[20]; x[20] += x[ 4];
225 r1 = x[ 5] - x[21]; x[21] += x[ 5];
226 XPROD31 ( r0, r1, cPI3_8, cPI1_8, &x[ 4], &x[ 5] );
227 MB();
228
229 r0 = x[ 2] - x[18]; x[18] += x[ 2];
230 r1 = x[ 3] - x[19]; x[19] += x[ 3];
231 x[ 2] = MULT31((r1 + r0) , cPI2_8);
232 x[ 3] = MULT31((r1 - r0) , cPI2_8);
233 MB();
234
235 r0 = x[ 0] - x[16]; x[16] += x[ 0];
236 r1 = x[ 1] - x[17]; x[17] += x[ 1];
237 XPROD31 ( r0, r1, cPI1_8, cPI3_8, &x[ 0], &x[ 1] );
238 MB();
239
240 mdct_butterfly_16(x);
241 mdct_butterfly_16(x+16);
242}
243
244/* N/stage point generic N stage butterfly (in place, 2 register) */
245STIN void mdct_butterfly_generic(DATA_TYPE *x,int points,int step){
246
247 LOOKUP_T *T = sincos_lookup;
248 DATA_TYPE *x1 = x + points - 8;
249 DATA_TYPE *x2 = x + (points>>1) - 8;
250 REG_TYPE r0;
251 REG_TYPE r1;
252
253 //av_log(0, 0, "bfly: points=%d, step=%d\n", points, step);
254
255 do{
256 r0 = x1[6] - x2[6]; x1[6] += x2[6];
257 r1 = x2[7] - x1[7]; x1[7] += x2[7];
258 XPROD31( r1, r0, T[0], T[1], &x2[6], &x2[7] ); T+=step;
259
260 r0 = x1[4] - x2[4]; x1[4] += x2[4];
261 r1 = x2[5] - x1[5]; x1[5] += x2[5];
262 XPROD31( r1, r0, T[0], T[1], &x2[4], &x2[5] ); T+=step;
263
264 r0 = x1[2] - x2[2]; x1[2] += x2[2];
265 r1 = x2[3] - x1[3]; x1[3] += x2[3];
266 XPROD31( r1, r0, T[0], T[1], &x2[2], &x2[3] ); T+=step;
267
268 r0 = x1[0] - x2[0]; x1[0] += x2[0];
269 r1 = x2[1] - x1[1]; x1[1] += x2[1];
270 XPROD31( r1, r0, T[0], T[1], &x2[0], &x2[1] ); T+=step;
271
272 x1-=8; x2-=8;
273 }while(T<sincos_lookup+2048);
274 do{
275 r0 = x1[6] - x2[6]; x1[6] += x2[6];
276 r1 = x1[7] - x2[7]; x1[7] += x2[7];
277 XNPROD31( r0, r1, T[0], T[1], &x2[6], &x2[7] ); T-=step;
278
279 r0 = x1[4] - x2[4]; x1[4] += x2[4];
280 r1 = x1[5] - x2[5]; x1[5] += x2[5];
281 XNPROD31( r0, r1, T[0], T[1], &x2[4], &x2[5] ); T-=step;
282
283 r0 = x1[2] - x2[2]; x1[2] += x2[2];
284 r1 = x1[3] - x2[3]; x1[3] += x2[3];
285 XNPROD31( r0, r1, T[0], T[1], &x2[2], &x2[3] ); T-=step;
286
287 r0 = x1[0] - x2[0]; x1[0] += x2[0];
288 r1 = x1[1] - x2[1]; x1[1] += x2[1];
289 XNPROD31( r0, r1, T[0], T[1], &x2[0], &x2[1] ); T-=step;
290
291 x1-=8; x2-=8;
292 }while(T>sincos_lookup);
293 do{
294 r0 = x2[6] - x1[6]; x1[6] += x2[6];
295 r1 = x2[7] - x1[7]; x1[7] += x2[7];
296 XPROD31( r0, r1, T[0], T[1], &x2[6], &x2[7] ); T+=step;
297
298 r0 = x2[4] - x1[4]; x1[4] += x2[4];
299 r1 = x2[5] - x1[5]; x1[5] += x2[5];
300 XPROD31( r0, r1, T[0], T[1], &x2[4], &x2[5] ); T+=step;
301
302 r0 = x2[2] - x1[2]; x1[2] += x2[2];
303 r1 = x2[3] - x1[3]; x1[3] += x2[3];
304 XPROD31( r0, r1, T[0], T[1], &x2[2], &x2[3] ); T+=step;
305
306 r0 = x2[0] - x1[0]; x1[0] += x2[0];
307 r1 = x2[1] - x1[1]; x1[1] += x2[1];
308 XPROD31( r0, r1, T[0], T[1], &x2[0], &x2[1] ); T+=step;
309
310 x1-=8; x2-=8;
311 }while(T<sincos_lookup+2048);
312 do{
313 r0 = x1[6] - x2[6]; x1[6] += x2[6];
314 r1 = x2[7] - x1[7]; x1[7] += x2[7];
315 XNPROD31( r1, r0, T[0], T[1], &x2[6], &x2[7] ); T-=step;
316
317 r0 = x1[4] - x2[4]; x1[4] += x2[4];
318 r1 = x2[5] - x1[5]; x1[5] += x2[5];
319 XNPROD31( r1, r0, T[0], T[1], &x2[4], &x2[5] ); T-=step;
320
321 r0 = x1[2] - x2[2]; x1[2] += x2[2];
322 r1 = x2[3] - x1[3]; x1[3] += x2[3];
323 XNPROD31( r1, r0, T[0], T[1], &x2[2], &x2[3] ); T-=step;
324
325 r0 = x1[0] - x2[0]; x1[0] += x2[0];
326 r1 = x2[1] - x1[1]; x1[1] += x2[1];
327 XNPROD31( r1, r0, T[0], T[1], &x2[0], &x2[1] ); T-=step;
328
329 x1-=8; x2-=8;
330 }while(T>sincos_lookup);
331}
332
333STIN void mdct_butterflies(DATA_TYPE *x,int points,int shift){
334
335 int stages=8-shift;
336 int i,j;
337
338 for(i=0;--stages>0;i++){
339 for(j=0;j<(1<<i);j++)
340 mdct_butterfly_generic(x+(points>>i)*j,points>>i,8<<(i+shift));
341 }
342
343 for(j=0;j<points;j+=32)
344 mdct_butterfly_32(x+j);
345
346}
347
348static unsigned char bitrev[16]={0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15};
349
350STIN int bitrev12(int x){
351 return bitrev[x>>8]|(bitrev[(x&0x0f0)>>4]<<4)|(((int)bitrev[x&0x00f])<<8);
352}
353
354STIN void mdct_bitreverse(DATA_TYPE *x,int n,int step,int shift){
355
356 int bit = 0;
357 DATA_TYPE *w0 = x;
358 DATA_TYPE *w1 = x = w0+(n>>1);
359 LOOKUP_T *T = sincos_lookup+(step>>1);
360 LOOKUP_T *Ttop = T+2048;
361 DATA_TYPE r2;
362
363 //av_log(0, 0, "brev: shift=%d, step=%d\n", shift, step);
364
365 do{
366 DATA_TYPE r3 = bitrev12(bit++);
367 DATA_TYPE *x0 = x + ((r3 ^ 0xfff)>>shift) -1;
368 DATA_TYPE *x1 = x + (r3>>shift);
369
370 REG_TYPE r0 = x0[0] + x1[0];
371 REG_TYPE r1 = x1[1] - x0[1];
372
373 XPROD32( r0, r1, T[1], T[0], &r2, &r3 ); T+=step;
374
375 w1 -= 4;
376
377 r0 = (x0[1] + x1[1])>>1;
378 r1 = (x0[0] - x1[0])>>1;
379 w0[0] = r0 + r2;
380 w0[1] = r1 + r3;
381 w1[2] = r0 - r2;
382 w1[3] = r3 - r1;
383
384 r3 = bitrev12(bit++);
385 x0 = x + ((r3 ^ 0xfff)>>shift) -1;
386 x1 = x + (r3>>shift);
387
388 r0 = x0[0] + x1[0];
389 r1 = x1[1] - x0[1];
390
391 XPROD32( r0, r1, T[1], T[0], &r2, &r3 ); T+=step;
392
393 r0 = (x0[1] + x1[1])>>1;
394 r1 = (x0[0] - x1[0])>>1;
395 w0[2] = r0 + r2;
396 w0[3] = r1 + r3;
397 w1[0] = r0 - r2;
398 w1[1] = r3 - r1;
399
400 w0 += 4;
401 }while(T<Ttop);
402 do{
403 DATA_TYPE r3 = bitrev12(bit++);
404 DATA_TYPE *x0 = x + ((r3 ^ 0xfff)>>shift) -1;
405 DATA_TYPE *x1 = x + (r3>>shift);
406
407 REG_TYPE r0 = x0[0] + x1[0];
408 REG_TYPE r1 = x1[1] - x0[1];
409
410 T-=step; XPROD32( r0, r1, T[0], T[1], &r2, &r3 );
411
412 w1 -= 4;
413
414 r0 = (x0[1] + x1[1])>>1;
415 r1 = (x0[0] - x1[0])>>1;
416 w0[0] = r0 + r2;
417 w0[1] = r1 + r3;
418 w1[2] = r0 - r2;
419 w1[3] = r3 - r1;
420
421 r3 = bitrev12(bit++);
422 x0 = x + ((r3 ^ 0xfff)>>shift) -1;
423 x1 = x + (r3>>shift);
424
425 r0 = x0[0] + x1[0];
426 r1 = x1[1] - x0[1];
427
428 T-=step; XPROD32( r0, r1, T[0], T[1], &r2, &r3 );
429
430 r0 = (x0[1] + x1[1])>>1;
431 r1 = (x0[0] - x1[0])>>1;
432 w0[2] = r0 + r2;
433 w0[3] = r1 + r3;
434 w1[0] = r0 - r2;
435 w1[1] = r3 - r1;
436
437 w0 += 4;
438 }while(w0<w1);
439}
440
441STIN void cook_mdct_backward(int n, DATA_TYPE *in, DATA_TYPE *out){
442 int n2=n>>1;
443 int n4=n>>2;
444 DATA_TYPE *iX;
445 DATA_TYPE *oX;
446 LOOKUP_T *T;
447 int shift;
448 int step;
449
450 for (shift=6;!(n&(1<<shift));shift++);
451
452 shift=13-shift;
453 step=4<<shift;
454 //step=16;
455 //av_log(0, 0, "mdct: shift=%d, step=%d\n", shift, step);
456
457 /* rotate */
458
459 iX = in+n2-7;
460 oX = out+n2+n4;
461 T = sincos_lookup;
462
463 do{
464 oX-=4;
465 XPROD31( iX[4], iX[6], T[0], T[1], &oX[2], &oX[3] ); T+=step;
466 XPROD31( iX[0], iX[2], T[0], T[1], &oX[0], &oX[1] ); T+=step;
467 iX-=8;
468 }while(iX>=in+n4);
469 do{
470 oX-=4;
471 XPROD31( iX[4], iX[6], T[1], T[0], &oX[2], &oX[3] ); T-=step;
472 XPROD31( iX[0], iX[2], T[1], T[0], &oX[0], &oX[1] ); T-=step;
473 iX-=8;
474 }while(iX>=in);
475
476 iX = in+n2-8;
477 oX = out+n2+n4;
478 T = sincos_lookup;
479
480 do{
481 T+=step; XNPROD31( iX[6], iX[4], T[0], T[1], &oX[0], &oX[1] );
482 T+=step; XNPROD31( iX[2], iX[0], T[0], T[1], &oX[2], &oX[3] );
483 iX-=8;
484 oX+=4;
485 }while(iX>=in+n4);
486 do{
487 T-=step; XNPROD31( iX[6], iX[4], T[1], T[0], &oX[0], &oX[1] );
488 T-=step; XNPROD31( iX[2], iX[0], T[1], T[0], &oX[2], &oX[3] );
489 iX-=8;
490 oX+=4;
491 }while(iX>=in);
492
493 mdct_butterflies(out+n2,n2,shift);
494 mdct_bitreverse(out,n,step,shift);
495
496 /* rotate */
497
498 step>>=2;
499 //step=4;
500 {
501 DATA_TYPE *oX1=out+n2+n4;
502 DATA_TYPE *oX2=out+n2+n4;
503 DATA_TYPE *iX =out;
504
505 T=sincos_lookup+(step>>1);
506 do{
507 oX1-=4;
508 XPROD31( iX[0], -iX[1], T[0], T[1], &oX1[3], &oX2[0] ); T+=step;
509 XPROD31( iX[2], -iX[3], T[0], T[1], &oX1[2], &oX2[1] ); T+=step;
510 XPROD31( iX[4], -iX[5], T[0], T[1], &oX1[1], &oX2[2] ); T+=step;
511 XPROD31( iX[6], -iX[7], T[0], T[1], &oX1[0], &oX2[3] ); T+=step;
512 oX2+=4;
513 iX+=8;
514 }while(iX<oX1);
515
516 iX=out+n2+n4;
517 oX1=out+n4;
518 oX2=oX1;
519
520 do{
521 oX1-=4;
522 iX-=4;
523
524 oX2[0] = -(oX1[3] = iX[3]);
525 oX2[1] = -(oX1[2] = iX[2]);
526 oX2[2] = -(oX1[1] = iX[1]);
527 oX2[3] = -(oX1[0] = iX[0]);
528
529 oX2+=4;
530 }while(oX2<iX);
531
532 iX=out+n2+n4;
533 oX1=out+n2+n4;
534 oX2=out+n2;
535
536 do{
537 oX1-=4;
538 oX1[0]= iX[3];
539 oX1[1]= iX[2];
540 oX1[2]= iX[1];
541 oX1[3]= iX[0];
542 iX+=4;
543 }while(oX1>oX2);
544 }
545}
diff --git a/apps/codecs/libcook/cook_fixpoint.h b/apps/codecs/libcook/cook_fixpoint.h
index 8848d89af7..33646125dd 100644
--- a/apps/codecs/libcook/cook_fixpoint.h
+++ b/apps/codecs/libcook/cook_fixpoint.h
@@ -21,7 +21,7 @@
21 */ 21 */
22 22
23/** 23/**
24 * @file cook_float.h 24 * @file cook_fixpoint.h
25 * 25 *
26 * Cook AKA RealAudio G2 fixed point functions. 26 * Cook AKA RealAudio G2 fixed point functions.
27 * 27 *
@@ -183,7 +183,6 @@ static void scalar_dequant_math(COOKContext *q, int index,
183 } 183 }
184} 184}
185 185
186#ifdef TEST
187/** 186/**
188 * The modulated lapped transform, this takes transform coefficients 187 * The modulated lapped transform, this takes transform coefficients
189 * and transforms them into timedomain samples. 188 * and transforms them into timedomain samples.
@@ -194,36 +193,8 @@ static void scalar_dequant_math(COOKContext *q, int index,
194 * @param outbuffer pointer to the timedomain buffer 193 * @param outbuffer pointer to the timedomain buffer
195 * @param mlt_tmp pointer to temporary storage space 194 * @param mlt_tmp pointer to temporary storage space
196 */ 195 */
197#include "cook_fixp_mdct.h" 196#include "../lib/mdct_lookup.h"
198 197#include "../lib/mdct2.h"
199static inline void imlt_math(COOKContext *q, FIXP *in)
200{
201 const int n = q->samples_per_channel;
202 const int step = 4 << (10 - av_log2(n));
203 int i = 0, j = step>>1;
204
205 cook_mdct_backward(2 * n, in, q->mono_mdct_output);
206
207 do {
208 FIXP tmp = q->mono_mdct_output[i];
209
210 q->mono_mdct_output[i] =
211 fixp_mult_su(-q->mono_mdct_output[n + i], sincos_lookup[j]);
212 q->mono_mdct_output[n + i] = fixp_mult_su(tmp, sincos_lookup[j+1]);
213 j += step;
214 } while (++i < n/2);
215 do {
216 FIXP tmp = q->mono_mdct_output[i];
217
218 j -= step;
219 q->mono_mdct_output[i] =
220 fixp_mult_su(-q->mono_mdct_output[n + i], sincos_lookup[j+1]);
221 q->mono_mdct_output[n + i] = fixp_mult_su(tmp, sincos_lookup[j]);
222 } while (++i < n);
223}
224#else
225#include <codecs/lib/codeclib.h>
226#include <codecs/lib/mdct_lookup.h>
227 198
228static inline void imlt_math(COOKContext *q, FIXP *in) 199static inline void imlt_math(COOKContext *q, FIXP *in)
229{ 200{
@@ -254,7 +225,6 @@ static inline void imlt_math(COOKContext *q, FIXP *in)
254 q->mono_mdct_output[n + i] = fixmul31(tmp, (sincos_lookup0[j]) ); 225 q->mono_mdct_output[n + i] = fixmul31(tmp, (sincos_lookup0[j]) );
255 } while (++i < n); 226 } while (++i < n);
256} 227}
257#endif
258 228
259/** 229/**
260 * Perform buffer overlapping. 230 * Perform buffer overlapping.
diff --git a/apps/codecs/libcook/cookdata_fixpoint.h b/apps/codecs/libcook/cookdata_fixpoint.h
index 72ccabeb89..1bb0686306 100644
--- a/apps/codecs/libcook/cookdata_fixpoint.h
+++ b/apps/codecs/libcook/cookdata_fixpoint.h
@@ -39,276 +39,6 @@ typedef FIXP REAL_T;
39typedef struct { 39typedef struct {
40} realvars_t; 40} realvars_t;
41 41
42#ifdef TEST
43#define cPI1_8 0xec83 /* 1pi/8 2^16 */
44#define cPI2_8 0xb505 /* 2pi/8 2^16 */
45#define cPI3_8 0x61f8 /* 3pi/8 2^16 */
46
47
48
49static const FIXPU sincos_lookup[2050] = {
50 /* x_i = 2^16 sin(i 2pi/8192), 2^16 cos(i 2pi/8192); i=0..1024 */
51 0x0000, 0xffff, 0x0032, 0xffff, 0x0065, 0xffff, 0x0097, 0xffff,
52 0x00c9, 0xffff, 0x00fb, 0xffff, 0x012e, 0xffff, 0x0160, 0xffff,
53 0x0192, 0xffff, 0x01c4, 0xfffe, 0x01f7, 0xfffe, 0x0229, 0xfffe,
54 0x025b, 0xfffd, 0x028d, 0xfffd, 0x02c0, 0xfffc, 0x02f2, 0xfffc,
55 0x0324, 0xfffb, 0x0356, 0xfffa, 0x0389, 0xfffa, 0x03bb, 0xfff9,
56 0x03ed, 0xfff8, 0x0420, 0xfff7, 0x0452, 0xfff7, 0x0484, 0xfff6,
57 0x04b6, 0xfff5, 0x04e9, 0xfff4, 0x051b, 0xfff3, 0x054d, 0xfff2,
58 0x057f, 0xfff1, 0x05b2, 0xfff0, 0x05e4, 0xffef, 0x0616, 0xffed,
59 0x0648, 0xffec, 0x067b, 0xffeb, 0x06ad, 0xffea, 0x06df, 0xffe8,
60 0x0711, 0xffe7, 0x0744, 0xffe6, 0x0776, 0xffe4, 0x07a8, 0xffe3,
61 0x07da, 0xffe1, 0x080d, 0xffe0, 0x083f, 0xffde, 0x0871, 0xffdc,
62 0x08a3, 0xffdb, 0x08d5, 0xffd9, 0x0908, 0xffd7, 0x093a, 0xffd5,
63 0x096c, 0xffd4, 0x099e, 0xffd2, 0x09d1, 0xffd0, 0x0a03, 0xffce,
64 0x0a35, 0xffcc, 0x0a67, 0xffca, 0x0a9a, 0xffc8, 0x0acc, 0xffc6,
65 0x0afe, 0xffc4, 0x0b30, 0xffc1, 0x0b62, 0xffbf, 0x0b95, 0xffbd,
66 0x0bc7, 0xffbb, 0x0bf9, 0xffb8, 0x0c2b, 0xffb6, 0x0c5d, 0xffb4,
67 0x0c90, 0xffb1, 0x0cc2, 0xffaf, 0x0cf4, 0xffac, 0x0d26, 0xffa9,
68 0x0d59, 0xffa7, 0x0d8b, 0xffa4, 0x0dbd, 0xffa2, 0x0def, 0xff9f,
69 0x0e21, 0xff9c, 0x0e53, 0xff99, 0x0e86, 0xff96, 0x0eb8, 0xff94,
70 0x0eea, 0xff91, 0x0f1c, 0xff8e, 0x0f4e, 0xff8b, 0x0f81, 0xff88,
71 0x0fb3, 0xff85, 0x0fe5, 0xff82, 0x1017, 0xff7e, 0x1049, 0xff7b,
72 0x107b, 0xff78, 0x10ae, 0xff75, 0x10e0, 0xff71, 0x1112, 0xff6e,
73 0x1144, 0xff6b, 0x1176, 0xff67, 0x11a8, 0xff64, 0x11da, 0xff60,
74 0x120d, 0xff5d, 0x123f, 0xff59, 0x1271, 0xff56, 0x12a3, 0xff52,
75 0x12d5, 0xff4e, 0x1307, 0xff4b, 0x1339, 0xff47, 0x136c, 0xff43,
76 0x139e, 0xff3f, 0x13d0, 0xff3b, 0x1402, 0xff38, 0x1434, 0xff34,
77 0x1466, 0xff30, 0x1498, 0xff2c, 0x14ca, 0xff28, 0x14fc, 0xff23,
78 0x152e, 0xff1f, 0x1561, 0xff1b, 0x1593, 0xff17, 0x15c5, 0xff13,
79 0x15f7, 0xff0e, 0x1629, 0xff0a, 0x165b, 0xff06, 0x168d, 0xff01,
80 0x16bf, 0xfefd, 0x16f1, 0xfef8, 0x1723, 0xfef4, 0x1755, 0xfeef,
81 0x1787, 0xfeeb, 0x17b9, 0xfee6, 0x17eb, 0xfee1, 0x181d, 0xfedd,
82 0x1850, 0xfed8, 0x1882, 0xfed3, 0x18b4, 0xfece, 0x18e6, 0xfec9,
83 0x1918, 0xfec4, 0x194a, 0xfebf, 0x197c, 0xfeba, 0x19ae, 0xfeb5,
84 0x19e0, 0xfeb0, 0x1a12, 0xfeab, 0x1a44, 0xfea6, 0x1a76, 0xfea1,
85 0x1aa8, 0xfe9c, 0x1ada, 0xfe97, 0x1b0c, 0xfe91, 0x1b3e, 0xfe8c,
86 0x1b70, 0xfe87, 0x1ba2, 0xfe81, 0x1bd4, 0xfe7c, 0x1c06, 0xfe76,
87 0x1c38, 0xfe71, 0x1c69, 0xfe6b, 0x1c9b, 0xfe66, 0x1ccd, 0xfe60,
88 0x1cff, 0xfe5a, 0x1d31, 0xfe55, 0x1d63, 0xfe4f, 0x1d95, 0xfe49,
89 0x1dc7, 0xfe43, 0x1df9, 0xfe3d, 0x1e2b, 0xfe37, 0x1e5d, 0xfe31,
90 0x1e8f, 0xfe2b, 0x1ec1, 0xfe25, 0x1ef3, 0xfe1f, 0x1f24, 0xfe19,
91 0x1f56, 0xfe13, 0x1f88, 0xfe0d, 0x1fba, 0xfe07, 0x1fec, 0xfe01,
92 0x201e, 0xfdfa, 0x2050, 0xfdf4, 0x2082, 0xfdee, 0x20b3, 0xfde7,
93 0x20e5, 0xfde1, 0x2117, 0xfdda, 0x2149, 0xfdd4, 0x217b, 0xfdcd,
94 0x21ad, 0xfdc7, 0x21de, 0xfdc0, 0x2210, 0xfdb9, 0x2242, 0xfdb3,
95 0x2274, 0xfdac, 0x22a6, 0xfda5, 0x22d7, 0xfd9e, 0x2309, 0xfd97,
96 0x233b, 0xfd90, 0x236d, 0xfd89, 0x239f, 0xfd83, 0x23d0, 0xfd7c,
97 0x2402, 0xfd74, 0x2434, 0xfd6d, 0x2466, 0xfd66, 0x2497, 0xfd5f,
98 0x24c9, 0xfd58, 0x24fb, 0xfd51, 0x252d, 0xfd49, 0x255e, 0xfd42,
99 0x2590, 0xfd3b, 0x25c2, 0xfd33, 0x25f4, 0xfd2c, 0x2625, 0xfd24,
100 0x2657, 0xfd1d, 0x2689, 0xfd15, 0x26ba, 0xfd0e, 0x26ec, 0xfd06,
101 0x271e, 0xfcfe, 0x274f, 0xfcf7, 0x2781, 0xfcef, 0x27b3, 0xfce7,
102 0x27e4, 0xfcdf, 0x2816, 0xfcd8, 0x2848, 0xfcd0, 0x2879, 0xfcc8,
103 0x28ab, 0xfcc0, 0x28dd, 0xfcb8, 0x290e, 0xfcb0, 0x2940, 0xfca8,
104 0x2971, 0xfca0, 0x29a3, 0xfc97, 0x29d5, 0xfc8f, 0x2a06, 0xfc87,
105 0x2a38, 0xfc7f, 0x2a69, 0xfc76, 0x2a9b, 0xfc6e, 0x2acc, 0xfc66,
106 0x2afe, 0xfc5d, 0x2b30, 0xfc55, 0x2b61, 0xfc4c, 0x2b93, 0xfc44,
107 0x2bc4, 0xfc3b, 0x2bf6, 0xfc33, 0x2c27, 0xfc2a, 0x2c59, 0xfc21,
108 0x2c8a, 0xfc18, 0x2cbc, 0xfc10, 0x2ced, 0xfc07, 0x2d1f, 0xfbfe,
109 0x2d50, 0xfbf5, 0x2d82, 0xfbec, 0x2db3, 0xfbe3, 0x2de5, 0xfbda,
110 0x2e16, 0xfbd1, 0x2e47, 0xfbc8, 0x2e79, 0xfbbf, 0x2eaa, 0xfbb6,
111 0x2edc, 0xfbad, 0x2f0d, 0xfba4, 0x2f3f, 0xfb9a, 0x2f70, 0xfb91,
112 0x2fa1, 0xfb88, 0x2fd3, 0xfb7e, 0x3004, 0xfb75, 0x3035, 0xfb6b,
113 0x3067, 0xfb62, 0x3098, 0xfb58, 0x30ca, 0xfb4f, 0x30fb, 0xfb45,
114 0x312c, 0xfb3c, 0x315e, 0xfb32, 0x318f, 0xfb28, 0x31c0, 0xfb1f,
115 0x31f1, 0xfb15, 0x3223, 0xfb0b, 0x3254, 0xfb01, 0x3285, 0xfaf7,
116 0x32b7, 0xfaed, 0x32e8, 0xfae3, 0x3319, 0xfad9, 0x334a, 0xfacf,
117 0x337c, 0xfac5, 0x33ad, 0xfabb, 0x33de, 0xfab1, 0x340f, 0xfaa7,
118 0x3440, 0xfa9c, 0x3472, 0xfa92, 0x34a3, 0xfa88, 0x34d4, 0xfa7d,
119 0x3505, 0xfa73, 0x3536, 0xfa69, 0x3568, 0xfa5e, 0x3599, 0xfa54,
120 0x35ca, 0xfa49, 0x35fb, 0xfa3e, 0x362c, 0xfa34, 0x365d, 0xfa29,
121 0x368e, 0xfa1f, 0x36c0, 0xfa14, 0x36f1, 0xfa09, 0x3722, 0xf9fe,
122 0x3753, 0xf9f3, 0x3784, 0xf9e8, 0x37b5, 0xf9de, 0x37e6, 0xf9d3,
123 0x3817, 0xf9c8, 0x3848, 0xf9bd, 0x3879, 0xf9b2, 0x38aa, 0xf9a6,
124 0x38db, 0xf99b, 0x390c, 0xf990, 0x393d, 0xf985, 0x396e, 0xf97a,
125 0x399f, 0xf96e, 0x39d0, 0xf963, 0x3a01, 0xf958, 0x3a32, 0xf94c,
126 0x3a63, 0xf941, 0x3a94, 0xf935, 0x3ac5, 0xf92a, 0x3af6, 0xf91e,
127 0x3b27, 0xf913, 0x3b58, 0xf907, 0x3b88, 0xf8fb, 0x3bb9, 0xf8f0,
128 0x3bea, 0xf8e4, 0x3c1b, 0xf8d8, 0x3c4c, 0xf8cc, 0x3c7d, 0xf8c0,
129 0x3cae, 0xf8b4, 0x3cde, 0xf8a9, 0x3d0f, 0xf89d, 0x3d40, 0xf891,
130 0x3d71, 0xf885, 0x3da2, 0xf878, 0x3dd2, 0xf86c, 0x3e03, 0xf860,
131 0x3e34, 0xf854, 0x3e65, 0xf848, 0x3e95, 0xf83b, 0x3ec6, 0xf82f,
132 0x3ef7, 0xf823, 0x3f28, 0xf816, 0x3f58, 0xf80a, 0x3f89, 0xf7fe,
133 0x3fba, 0xf7f1, 0x3fea, 0xf7e5, 0x401b, 0xf7d8, 0x404c, 0xf7cb,
134 0x407c, 0xf7bf, 0x40ad, 0xf7b2, 0x40de, 0xf7a5, 0x410e, 0xf799,
135 0x413f, 0xf78c, 0x416f, 0xf77f, 0x41a0, 0xf772, 0x41d1, 0xf765,
136 0x4201, 0xf758, 0x4232, 0xf74b, 0x4262, 0xf73e, 0x4293, 0xf731,
137 0x42c3, 0xf724, 0x42f4, 0xf717, 0x4324, 0xf70a, 0x4355, 0xf6fd,
138 0x4385, 0xf6ef, 0x43b6, 0xf6e2, 0x43e6, 0xf6d5, 0x4417, 0xf6c7,
139 0x4447, 0xf6ba, 0x4478, 0xf6ad, 0x44a8, 0xf69f, 0x44d9, 0xf692,
140 0x4509, 0xf684, 0x4539, 0xf677, 0x456a, 0xf669, 0x459a, 0xf65b,
141 0x45cb, 0xf64e, 0x45fb, 0xf640, 0x462b, 0xf632, 0x465c, 0xf624,
142 0x468c, 0xf616, 0x46bc, 0xf609, 0x46ec, 0xf5fb, 0x471d, 0xf5ed,
143 0x474d, 0xf5df, 0x477d, 0xf5d1, 0x47ae, 0xf5c3, 0x47de, 0xf5b5,
144 0x480e, 0xf5a6, 0x483e, 0xf598, 0x486f, 0xf58a, 0x489f, 0xf57c,
145 0x48cf, 0xf56e, 0x48ff, 0xf55f, 0x492f, 0xf551, 0x495f, 0xf543,
146 0x4990, 0xf534, 0x49c0, 0xf526, 0x49f0, 0xf517, 0x4a20, 0xf509,
147 0x4a50, 0xf4fa, 0x4a80, 0xf4eb, 0x4ab0, 0xf4dd, 0x4ae0, 0xf4ce,
148 0x4b10, 0xf4bf, 0x4b40, 0xf4b1, 0x4b71, 0xf4a2, 0x4ba1, 0xf493,
149 0x4bd1, 0xf484, 0x4c01, 0xf475, 0x4c31, 0xf466, 0x4c61, 0xf457,
150 0x4c90, 0xf448, 0x4cc0, 0xf439, 0x4cf0, 0xf42a, 0x4d20, 0xf41b,
151 0x4d50, 0xf40c, 0x4d80, 0xf3fd, 0x4db0, 0xf3ed, 0x4de0, 0xf3de,
152 0x4e10, 0xf3cf, 0x4e40, 0xf3c0, 0x4e70, 0xf3b0, 0x4e9f, 0xf3a1,
153 0x4ecf, 0xf391, 0x4eff, 0xf382, 0x4f2f, 0xf372, 0x4f5f, 0xf363,
154 0x4f8e, 0xf353, 0x4fbe, 0xf343, 0x4fee, 0xf334, 0x501e, 0xf324,
155 0x504d, 0xf314, 0x507d, 0xf304, 0x50ad, 0xf2f5, 0x50dd, 0xf2e5,
156 0x510c, 0xf2d5, 0x513c, 0xf2c5, 0x516c, 0xf2b5, 0x519b, 0xf2a5,
157 0x51cb, 0xf295, 0x51fb, 0xf285, 0x522a, 0xf275, 0x525a, 0xf265,
158 0x5289, 0xf254, 0x52b9, 0xf244, 0x52e8, 0xf234, 0x5318, 0xf224,
159 0x5348, 0xf213, 0x5377, 0xf203, 0x53a7, 0xf1f3, 0x53d6, 0xf1e2,
160 0x5406, 0xf1d2, 0x5435, 0xf1c1, 0x5464, 0xf1b1, 0x5494, 0xf1a0,
161 0x54c3, 0xf18f, 0x54f3, 0xf17f, 0x5522, 0xf16e, 0x5552, 0xf15d,
162 0x5581, 0xf14c, 0x55b0, 0xf13c, 0x55e0, 0xf12b, 0x560f, 0xf11a,
163 0x563e, 0xf109, 0x566e, 0xf0f8, 0x569d, 0xf0e7, 0x56cc, 0xf0d6,
164 0x56fc, 0xf0c5, 0x572b, 0xf0b4, 0x575a, 0xf0a3, 0x5789, 0xf092,
165 0x57b9, 0xf080, 0x57e8, 0xf06f, 0x5817, 0xf05e, 0x5846, 0xf04d,
166 0x5875, 0xf03b, 0x58a5, 0xf02a, 0x58d4, 0xf018, 0x5903, 0xf007,
167 0x5932, 0xeff5, 0x5961, 0xefe4, 0x5990, 0xefd2, 0x59bf, 0xefc1,
168 0x59ee, 0xefaf, 0x5a1d, 0xef9d, 0x5a4c, 0xef8c, 0x5a7b, 0xef7a,
169 0x5aaa, 0xef68, 0x5ad9, 0xef56, 0x5b08, 0xef45, 0x5b37, 0xef33,
170 0x5b66, 0xef21, 0x5b95, 0xef0f, 0x5bc4, 0xeefd, 0x5bf3, 0xeeeb,
171 0x5c22, 0xeed9, 0x5c51, 0xeec7, 0x5c80, 0xeeb4, 0x5caf, 0xeea2,
172 0x5cde, 0xee90, 0x5d0c, 0xee7e, 0x5d3b, 0xee6b, 0x5d6a, 0xee59,
173 0x5d99, 0xee47, 0x5dc8, 0xee34, 0x5df6, 0xee22, 0x5e25, 0xee0f,
174 0x5e54, 0xedfd, 0x5e83, 0xedea, 0x5eb1, 0xedd8, 0x5ee0, 0xedc5,
175 0x5f0f, 0xedb3, 0x5f3d, 0xeda0, 0x5f6c, 0xed8d, 0x5f9b, 0xed7a,
176 0x5fc9, 0xed68, 0x5ff8, 0xed55, 0x6026, 0xed42, 0x6055, 0xed2f,
177 0x6084, 0xed1c, 0x60b2, 0xed09, 0x60e1, 0xecf6, 0x610f, 0xece3,
178 0x613e, 0xecd0, 0x616c, 0xecbd, 0x619b, 0xecaa, 0x61c9, 0xec97,
179 0x61f8, 0xec83, 0x6226, 0xec70, 0x6254, 0xec5d, 0x6283, 0xec4a,
180 0x62b1, 0xec36, 0x62e0, 0xec23, 0x630e, 0xec0f, 0x633c, 0xebfc,
181 0x636b, 0xebe8, 0x6399, 0xebd5, 0x63c7, 0xebc1, 0x63f5, 0xebae,
182 0x6424, 0xeb9a, 0x6452, 0xeb86, 0x6480, 0xeb73, 0x64ae, 0xeb5f,
183 0x64dd, 0xeb4b, 0x650b, 0xeb37, 0x6539, 0xeb23, 0x6567, 0xeb0f,
184 0x6595, 0xeafc, 0x65c3, 0xeae8, 0x65f2, 0xead4, 0x6620, 0xeac0,
185 0x664e, 0xeaab, 0x667c, 0xea97, 0x66aa, 0xea83, 0x66d8, 0xea6f,
186 0x6706, 0xea5b, 0x6734, 0xea47, 0x6762, 0xea32, 0x6790, 0xea1e,
187 0x67be, 0xea0a, 0x67ec, 0xe9f5, 0x681a, 0xe9e1, 0x6848, 0xe9cc,
188 0x6876, 0xe9b8, 0x68a3, 0xe9a3, 0x68d1, 0xe98f, 0x68ff, 0xe97a,
189 0x692d, 0xe966, 0x695b, 0xe951, 0x6989, 0xe93c, 0x69b6, 0xe927,
190 0x69e4, 0xe913, 0x6a12, 0xe8fe, 0x6a40, 0xe8e9, 0x6a6d, 0xe8d4,
191 0x6a9b, 0xe8bf, 0x6ac9, 0xe8aa, 0x6af6, 0xe895, 0x6b24, 0xe880,
192 0x6b52, 0xe86b, 0x6b7f, 0xe856, 0x6bad, 0xe841, 0x6bdb, 0xe82c,
193 0x6c08, 0xe817, 0x6c36, 0xe801, 0x6c63, 0xe7ec, 0x6c91, 0xe7d7,
194 0x6cbe, 0xe7c2, 0x6cec, 0xe7ac, 0x6d19, 0xe797, 0x6d47, 0xe781,
195 0x6d74, 0xe76c, 0x6da2, 0xe756, 0x6dcf, 0xe741, 0x6dfc, 0xe72b,
196 0x6e2a, 0xe716, 0x6e57, 0xe700, 0x6e85, 0xe6ea, 0x6eb2, 0xe6d5,
197 0x6edf, 0xe6bf, 0x6f0d, 0xe6a9, 0x6f3a, 0xe693, 0x6f67, 0xe67d,
198 0x6f94, 0xe667, 0x6fc2, 0xe652, 0x6fef, 0xe63c, 0x701c, 0xe626,
199 0x7049, 0xe610, 0x7076, 0xe5f9, 0x70a3, 0xe5e3, 0x70d1, 0xe5cd,
200 0x70fe, 0xe5b7, 0x712b, 0xe5a1, 0x7158, 0xe58b, 0x7185, 0xe574,
201 0x71b2, 0xe55e, 0x71df, 0xe548, 0x720c, 0xe531, 0x7239, 0xe51b,
202 0x7266, 0xe504, 0x7293, 0xe4ee, 0x72c0, 0xe4d7, 0x72ed, 0xe4c1,
203 0x731a, 0xe4aa, 0x7347, 0xe494, 0x7373, 0xe47d, 0x73a0, 0xe466,
204 0x73cd, 0xe450, 0x73fa, 0xe439, 0x7427, 0xe422, 0x7454, 0xe40b,
205 0x7480, 0xe3f4, 0x74ad, 0xe3de, 0x74da, 0xe3c7, 0x7507, 0xe3b0,
206 0x7533, 0xe399, 0x7560, 0xe382, 0x758d, 0xe36b, 0x75b9, 0xe353,
207 0x75e6, 0xe33c, 0x7612, 0xe325, 0x763f, 0xe30e, 0x766c, 0xe2f7,
208 0x7698, 0xe2df, 0x76c5, 0xe2c8, 0x76f1, 0xe2b1, 0x771e, 0xe299,
209 0x774a, 0xe282, 0x7777, 0xe26b, 0x77a3, 0xe253, 0x77d0, 0xe23c,
210 0x77fc, 0xe224, 0x7828, 0xe20d, 0x7855, 0xe1f5, 0x7881, 0xe1dd,
211 0x78ad, 0xe1c6, 0x78da, 0xe1ae, 0x7906, 0xe196, 0x7932, 0xe17e,
212 0x795f, 0xe167, 0x798b, 0xe14f, 0x79b7, 0xe137, 0x79e3, 0xe11f,
213 0x7a10, 0xe107, 0x7a3c, 0xe0ef, 0x7a68, 0xe0d7, 0x7a94, 0xe0bf,
214 0x7ac0, 0xe0a7, 0x7aec, 0xe08f, 0x7b18, 0xe077, 0x7b44, 0xe05e,
215 0x7b70, 0xe046, 0x7b9c, 0xe02e, 0x7bc8, 0xe016, 0x7bf4, 0xdffd,
216 0x7c20, 0xdfe5, 0x7c4c, 0xdfcd, 0x7c78, 0xdfb4, 0x7ca4, 0xdf9c,
217 0x7cd0, 0xdf83, 0x7cfc, 0xdf6b, 0x7d28, 0xdf52, 0x7d54, 0xdf39,
218 0x7d7f, 0xdf21, 0x7dab, 0xdf08, 0x7dd7, 0xdef0, 0x7e03, 0xded7,
219 0x7e2f, 0xdebe, 0x7e5a, 0xdea5, 0x7e86, 0xde8c, 0x7eb2, 0xde74,
220 0x7edd, 0xde5b, 0x7f09, 0xde42, 0x7f35, 0xde29, 0x7f60, 0xde10,
221 0x7f8c, 0xddf7, 0x7fb7, 0xddde, 0x7fe3, 0xddc5, 0x800f, 0xddab,
222 0x803a, 0xdd92, 0x8066, 0xdd79, 0x8091, 0xdd60, 0x80bc, 0xdd47,
223 0x80e8, 0xdd2d, 0x8113, 0xdd14, 0x813f, 0xdcfb, 0x816a, 0xdce1,
224 0x8195, 0xdcc8, 0x81c1, 0xdcae, 0x81ec, 0xdc95, 0x8217, 0xdc7b,
225 0x8243, 0xdc62, 0x826e, 0xdc48, 0x8299, 0xdc2f, 0x82c4, 0xdc15,
226 0x82f0, 0xdbfb, 0x831b, 0xdbe1, 0x8346, 0xdbc8, 0x8371, 0xdbae,
227 0x839c, 0xdb94, 0x83c7, 0xdb7a, 0x83f2, 0xdb60, 0x841d, 0xdb46,
228 0x8449, 0xdb2c, 0x8474, 0xdb12, 0x849f, 0xdaf8, 0x84ca, 0xdade,
229 0x84f5, 0xdac4, 0x851f, 0xdaaa, 0x854a, 0xda90, 0x8575, 0xda76,
230 0x85a0, 0xda5c, 0x85cb, 0xda41, 0x85f6, 0xda27, 0x8621, 0xda0d,
231 0x864c, 0xd9f2, 0x8676, 0xd9d8, 0x86a1, 0xd9be, 0x86cc, 0xd9a3,
232 0x86f7, 0xd989, 0x8721, 0xd96e, 0x874c, 0xd954, 0x8777, 0xd939,
233 0x87a1, 0xd91e, 0x87cc, 0xd904, 0x87f6, 0xd8e9, 0x8821, 0xd8ce,
234 0x884c, 0xd8b4, 0x8876, 0xd899, 0x88a1, 0xd87e, 0x88cb, 0xd863,
235 0x88f6, 0xd848, 0x8920, 0xd82d, 0x894a, 0xd812, 0x8975, 0xd7f8,
236 0x899f, 0xd7dc, 0x89ca, 0xd7c1, 0x89f4, 0xd7a6, 0x8a1e, 0xd78b,
237 0x8a49, 0xd770, 0x8a73, 0xd755, 0x8a9d, 0xd73a, 0x8ac7, 0xd71f,
238 0x8af2, 0xd703, 0x8b1c, 0xd6e8, 0x8b46, 0xd6cd, 0x8b70, 0xd6b1,
239 0x8b9a, 0xd696, 0x8bc5, 0xd67a, 0x8bef, 0xd65f, 0x8c19, 0xd644,
240 0x8c43, 0xd628, 0x8c6d, 0xd60c, 0x8c97, 0xd5f1, 0x8cc1, 0xd5d5,
241 0x8ceb, 0xd5ba, 0x8d15, 0xd59e, 0x8d3f, 0xd582, 0x8d69, 0xd566,
242 0x8d93, 0xd54b, 0x8dbc, 0xd52f, 0x8de6, 0xd513, 0x8e10, 0xd4f7,
243 0x8e3a, 0xd4db, 0x8e64, 0xd4bf, 0x8e8d, 0xd4a3, 0x8eb7, 0xd487,
244 0x8ee1, 0xd46b, 0x8f0b, 0xd44f, 0x8f34, 0xd433, 0x8f5e, 0xd417,
245 0x8f88, 0xd3fb, 0x8fb1, 0xd3df, 0x8fdb, 0xd3c2, 0x9004, 0xd3a6,
246 0x902e, 0xd38a, 0x9057, 0xd36d, 0x9081, 0xd351, 0x90aa, 0xd335,
247 0x90d4, 0xd318, 0x90fd, 0xd2fc, 0x9127, 0xd2df, 0x9150, 0xd2c3,
248 0x9179, 0xd2a6, 0x91a3, 0xd28a, 0x91cc, 0xd26d, 0x91f5, 0xd250,
249 0x921f, 0xd234, 0x9248, 0xd217, 0x9271, 0xd1fa, 0x929a, 0xd1de,
250 0x92c4, 0xd1c1, 0x92ed, 0xd1a4, 0x9316, 0xd187, 0x933f, 0xd16a,
251 0x9368, 0xd14d, 0x9391, 0xd130, 0x93ba, 0xd113, 0x93e3, 0xd0f6,
252 0x940c, 0xd0d9, 0x9435, 0xd0bc, 0x945e, 0xd09f, 0x9487, 0xd082,
253 0x94b0, 0xd065, 0x94d9, 0xd047, 0x9502, 0xd02a, 0x952b, 0xd00d,
254 0x9554, 0xcff0, 0x957d, 0xcfd2, 0x95a5, 0xcfb5, 0x95ce, 0xcf98,
255 0x95f7, 0xcf7a, 0x9620, 0xcf5d, 0x9648, 0xcf3f, 0x9671, 0xcf22,
256 0x969a, 0xcf04, 0x96c2, 0xcee7, 0x96eb, 0xcec9, 0x9713, 0xceab,
257 0x973c, 0xce8e, 0x9765, 0xce70, 0x978d, 0xce52, 0x97b6, 0xce34,
258 0x97de, 0xce17, 0x9807, 0xcdf9, 0x982f, 0xcddb, 0x9857, 0xcdbd,
259 0x9880, 0xcd9f, 0x98a8, 0xcd81, 0x98d0, 0xcd63, 0x98f9, 0xcd45,
260 0x9921, 0xcd27, 0x9949, 0xcd09, 0x9972, 0xcceb, 0x999a, 0xcccd,
261 0x99c2, 0xccae, 0x99ea, 0xcc90, 0x9a12, 0xcc72, 0x9a3a, 0xcc54,
262 0x9a63, 0xcc35, 0x9a8b, 0xcc17, 0x9ab3, 0xcbf9, 0x9adb, 0xcbda,
263 0x9b03, 0xcbbc, 0x9b2b, 0xcb9e, 0x9b53, 0xcb7f, 0x9b7b, 0xcb61,
264 0x9ba3, 0xcb42, 0x9bca, 0xcb23, 0x9bf2, 0xcb05, 0x9c1a, 0xcae6,
265 0x9c42, 0xcac7, 0x9c6a, 0xcaa9, 0x9c92, 0xca8a, 0x9cb9, 0xca6b,
266 0x9ce1, 0xca4d, 0x9d09, 0xca2e, 0x9d31, 0xca0f, 0x9d58, 0xc9f0,
267 0x9d80, 0xc9d1, 0x9da7, 0xc9b2, 0x9dcf, 0xc993, 0x9df7, 0xc974,
268 0x9e1e, 0xc955, 0x9e46, 0xc936, 0x9e6d, 0xc917, 0x9e95, 0xc8f8,
269 0x9ebc, 0xc8d9, 0x9ee3, 0xc8ba, 0x9f0b, 0xc89a, 0x9f32, 0xc87b,
270 0x9f5a, 0xc85c, 0x9f81, 0xc83c, 0x9fa8, 0xc81d, 0x9fd0, 0xc7fe,
271 0x9ff7, 0xc7de, 0xa01e, 0xc7bf, 0xa045, 0xc7a0, 0xa06c, 0xc780,
272 0xa094, 0xc761, 0xa0bb, 0xc741, 0xa0e2, 0xc721, 0xa109, 0xc702,
273 0xa130, 0xc6e2, 0xa157, 0xc6c2, 0xa17e, 0xc6a3, 0xa1a5, 0xc683,
274 0xa1cc, 0xc663, 0xa1f3, 0xc644, 0xa21a, 0xc624, 0xa241, 0xc604,
275 0xa268, 0xc5e4, 0xa28e, 0xc5c4, 0xa2b5, 0xc5a4, 0xa2dc, 0xc584,
276 0xa303, 0xc564, 0xa32a, 0xc544, 0xa350, 0xc524, 0xa377, 0xc504,
277 0xa39e, 0xc4e4, 0xa3c4, 0xc4c4, 0xa3eb, 0xc4a4, 0xa412, 0xc483,
278 0xa438, 0xc463, 0xa45f, 0xc443, 0xa485, 0xc423, 0xa4ac, 0xc402,
279 0xa4d2, 0xc3e2, 0xa4f9, 0xc3c2, 0xa51f, 0xc3a1, 0xa545, 0xc381,
280 0xa56c, 0xc360, 0xa592, 0xc340, 0xa5b8, 0xc31f, 0xa5df, 0xc2ff,
281 0xa605, 0xc2de, 0xa62b, 0xc2be, 0xa652, 0xc29d, 0xa678, 0xc27c,
282 0xa69e, 0xc25c, 0xa6c4, 0xc23b, 0xa6ea, 0xc21a, 0xa710, 0xc1f9,
283 0xa736, 0xc1d8, 0xa75c, 0xc1b8, 0xa782, 0xc197, 0xa7a8, 0xc176,
284 0xa7ce, 0xc155, 0xa7f4, 0xc134, 0xa81a, 0xc113, 0xa840, 0xc0f2,
285 0xa866, 0xc0d1, 0xa88c, 0xc0b0, 0xa8b2, 0xc08f, 0xa8d7, 0xc06e,
286 0xa8fd, 0xc04c, 0xa923, 0xc02b, 0xa949, 0xc00a, 0xa96e, 0xbfe9,
287 0xa994, 0xbfc7, 0xa9ba, 0xbfa6, 0xa9df, 0xbf85, 0xaa05, 0xbf63,
288 0xaa2a, 0xbf42, 0xaa50, 0xbf21, 0xaa76, 0xbeff, 0xaa9b, 0xbede,
289 0xaac1, 0xbebc, 0xaae6, 0xbe9b, 0xab0b, 0xbe79, 0xab31, 0xbe57,
290 0xab56, 0xbe36, 0xab7b, 0xbe14, 0xaba1, 0xbdf2, 0xabc6, 0xbdd1,
291 0xabeb, 0xbdaf, 0xac11, 0xbd8d, 0xac36, 0xbd6b, 0xac5b, 0xbd4a,
292 0xac80, 0xbd28, 0xaca5, 0xbd06, 0xacca, 0xbce4, 0xacef, 0xbcc2,
293 0xad14, 0xbca0, 0xad39, 0xbc7e, 0xad5e, 0xbc5c, 0xad83, 0xbc3a,
294 0xada8, 0xbc18, 0xadcd, 0xbbf6, 0xadf2, 0xbbd4, 0xae17, 0xbbb1,
295 0xae3c, 0xbb8f, 0xae61, 0xbb6d, 0xae85, 0xbb4b, 0xaeaa, 0xbb28,
296 0xaecf, 0xbb06, 0xaef4, 0xbae4, 0xaf18, 0xbac1, 0xaf3d, 0xba9f,
297 0xaf62, 0xba7d, 0xaf86, 0xba5a, 0xafab, 0xba38, 0xafcf, 0xba15,
298 0xaff4, 0xb9f3, 0xb018, 0xb9d0, 0xb03d, 0xb9ae, 0xb061, 0xb98b,
299 0xb086, 0xb968, 0xb0aa, 0xb946, 0xb0ce, 0xb923, 0xb0f3, 0xb900,
300 0xb117, 0xb8dd, 0xb13b, 0xb8bb, 0xb160, 0xb898, 0xb184, 0xb875,
301 0xb1a8, 0xb852, 0xb1cc, 0xb82f, 0xb1f0, 0xb80c, 0xb215, 0xb7e9,
302 0xb239, 0xb7c6, 0xb25d, 0xb7a3, 0xb281, 0xb780, 0xb2a5, 0xb75d,
303 0xb2c9, 0xb73a, 0xb2ed, 0xb717, 0xb311, 0xb6f4, 0xb335, 0xb6d1,
304 0xb358, 0xb6ad, 0xb37c, 0xb68a, 0xb3a0, 0xb667, 0xb3c4, 0xb644,
305 0xb3e8, 0xb620, 0xb40b, 0xb5fd, 0xb42f, 0xb5da, 0xb453, 0xb5b6,
306 0xb477, 0xb593, 0xb49a, 0xb56f, 0xb4be, 0xb54c, 0xb4e1, 0xb528,
307 0xb505, 0xb505
308};
309
310#endif
311
312static const FIXPU pow128_tab[128] = { 42static const FIXPU pow128_tab[128] = {
313 /* x_i = 2^(15+i/128) */ 43 /* x_i = 2^(15+i/128) */
314 0x8000, 0x80b2, 0x8165, 0x8219, 0x82ce, 0x8383, 0x843a, 0x84f2, 0x85ab, 44 0x8000, 0x80b2, 0x8165, 0x8219, 0x82ce, 0x8383, 0x843a, 0x84f2, 0x85ab,