summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/libtremor
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbcodec/codecs/libtremor')
-rw-r--r--lib/rbcodec/codecs/libtremor/CHANGELOG19
-rw-r--r--lib/rbcodec/codecs/libtremor/COPYING28
-rw-r--r--lib/rbcodec/codecs/libtremor/README46
-rw-r--r--lib/rbcodec/codecs/libtremor/README.rockbox17
-rw-r--r--lib/rbcodec/codecs/libtremor/SOURCES16
-rw-r--r--lib/rbcodec/codecs/libtremor/asm_arm.h190
-rw-r--r--lib/rbcodec/codecs/libtremor/asm_mcf5249.h85
-rw-r--r--lib/rbcodec/codecs/libtremor/backends.h133
-rw-r--r--lib/rbcodec/codecs/libtremor/bitwise.c867
-rw-r--r--lib/rbcodec/codecs/libtremor/block.c471
-rw-r--r--lib/rbcodec/codecs/libtremor/codebook.c587
-rw-r--r--lib/rbcodec/codecs/libtremor/codebook.h101
-rw-r--r--lib/rbcodec/codecs/libtremor/codec_internal.h93
-rw-r--r--lib/rbcodec/codecs/libtremor/config-tremor.h55
-rw-r--r--lib/rbcodec/codecs/libtremor/config_types.h25
-rw-r--r--lib/rbcodec/codecs/libtremor/ctype.c4
-rw-r--r--lib/rbcodec/codecs/libtremor/ffmpeg_stuff.h140
-rw-r--r--lib/rbcodec/codecs/libtremor/floor0.c444
-rw-r--r--lib/rbcodec/codecs/libtremor/floor1.c426
-rw-r--r--lib/rbcodec/codecs/libtremor/framing.c2102
-rw-r--r--lib/rbcodec/codecs/libtremor/info.c330
-rw-r--r--lib/rbcodec/codecs/libtremor/ivorbiscodec.h204
-rw-r--r--lib/rbcodec/codecs/libtremor/ivorbisfile.h131
-rw-r--r--lib/rbcodec/codecs/libtremor/libtremor.make18
-rw-r--r--lib/rbcodec/codecs/libtremor/lsp_lookup.h132
-rw-r--r--lib/rbcodec/codecs/libtremor/mapping0.c416
-rw-r--r--lib/rbcodec/codecs/libtremor/misc.h276
-rw-r--r--lib/rbcodec/codecs/libtremor/ogg.h282
-rw-r--r--lib/rbcodec/codecs/libtremor/oggmalloc.c86
-rw-r--r--lib/rbcodec/codecs/libtremor/os.h62
-rw-r--r--lib/rbcodec/codecs/libtremor/os_types.h58
-rw-r--r--lib/rbcodec/codecs/libtremor/registry.c50
-rw-r--r--lib/rbcodec/codecs/libtremor/registry.h40
-rw-r--r--lib/rbcodec/codecs/libtremor/res012.c374
-rw-r--r--lib/rbcodec/codecs/libtremor/sharedbook.c460
-rw-r--r--lib/rbcodec/codecs/libtremor/synthesis.c129
-rw-r--r--lib/rbcodec/codecs/libtremor/vorbisfile.c1671
-rw-r--r--lib/rbcodec/codecs/libtremor/window.c82
-rw-r--r--lib/rbcodec/codecs/libtremor/window.h27
-rw-r--r--lib/rbcodec/codecs/libtremor/window_lookup.h2087
40 files changed, 12764 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/libtremor/CHANGELOG b/lib/rbcodec/codecs/libtremor/CHANGELOG
new file mode 100644
index 0000000000..53f23351e2
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/CHANGELOG
@@ -0,0 +1,19 @@
1*** 20020517: 1.0.2 ***
2
3 Playback bugfix to floor1; mode mistakenly used for sizing instead
4 of blockflag
5
6*** 20020515: 1.0.1 ***
7
8 Added complete API documentation to source tarball. No code
9 changes.
10
11*** 20020412: 1.0.1 ***
12
13 Fixed a clipping bug that affected ARM processors; negative
14 overflows were being properly clipped, but then clobbered to
15 positive by the positive overflow chec (asm_arm.h:CLIP_TO_15)
16
17*** 20020403: 1.0.0 ***
18
19 Initial version \ No newline at end of file
diff --git a/lib/rbcodec/codecs/libtremor/COPYING b/lib/rbcodec/codecs/libtremor/COPYING
new file mode 100644
index 0000000000..6111c6c5a6
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/COPYING
@@ -0,0 +1,28 @@
1Copyright (c) 2002, Xiph.org Foundation
2
3Redistribution and use in source and binary forms, with or without
4modification, are permitted provided that the following conditions
5are met:
6
7- Redistributions of source code must retain the above copyright
8notice, this list of conditions and the following disclaimer.
9
10- Redistributions in binary form must reproduce the above copyright
11notice, this list of conditions and the following disclaimer in the
12documentation and/or other materials provided with the distribution.
13
14- Neither the name of the Xiph.org Foundation nor the names of its
15contributors may be used to endorse or promote products derived from
16this software without specific prior written permission.
17
18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION
22OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/lib/rbcodec/codecs/libtremor/README b/lib/rbcodec/codecs/libtremor/README
new file mode 100644
index 0000000000..1321175322
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/README
@@ -0,0 +1,46 @@
1This README covers the Ogg Vorbis 'Tremor' integer playback codec
2source as of date 2002 09 02, version 1.0.0.
3
4 ******
5
6The C source in this package will build on any ANSI C compiler and
7function completely and properly on any platform. The included build
8system assumes GNU build system and make tools (m4, automake,
9autoconf, libtool and gmake). GCC is not required, although GCC is
10the most tested compiler. To build using GNU tools, type in the
11source directory:
12
13./autogen.sh
14make
15
16Currently, the source implements playback in pure C on all platforms
17except ARM, where a [currently] small amount of assembly (see
18asm_arm.h) is used to implement 64 bit math operations and fast LSP
19computation. If building on ARM without the benefit of GNU build
20system tools, be sure that '_ARM_ASSEM_' is #defined by the build
21system if this assembly is desired, else the resulting library will
22use whatever 64 bit math builtins the compiler implements.
23
24No math library is required by this source. No floating point
25operations are used at any point in either setup or decode. This
26decoder library will properly decode any past, current or future
27Vorbis I file or stream.
28
29 ********
30
31The build system produces a static and [when supported by the OS]
32dynamic library named 'libvorbisidec'. This library exposes an API
33nearly identical to the BSD reference library's 'libvorbisfile',
34including all the features familiar to users of vorbisfile. This API
35is similar enough that the proper header file to include is named
36'ivorbisfile.h' [included in the source build directory]. Lower level
37libvorbis-style headers and structures are in 'ivorbiscodec.h'
38[included in the source build directory]. A simple example program,
39ivorbisfile_example.c, can be built with 'make example'.
40
41 ********
42
43Detailed Tremor API Documentation begins at doc/index.html
44
45Monty
46xiph.org
diff --git a/lib/rbcodec/codecs/libtremor/README.rockbox b/lib/rbcodec/codecs/libtremor/README.rockbox
new file mode 100644
index 0000000000..a4e141f6b3
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/README.rockbox
@@ -0,0 +1,17 @@
1Library: Tremor-1.1.2 (Released 2002-05-17)
2Imported: 2005-02-16 by Marcoen Hirschberg
3
4This directory contains a local version of Tremor for use by Rockbox
5for software decoding of Ogg Vorbis files.
6
7LICENSING INFORMATION
8
9Tremor is distributed under Xiph.Org's BSD-like license - see the file COPYING
10in this directory for details.
11
12IMPORT DETAILS
13
14The base version first imported into Rockbox was the SVN version of
15Tremor-1.0.2 which was checked out on 2005-02-16.
16
17The autoconf/automake files were removed, as well as the doc and debian directories.
diff --git a/lib/rbcodec/codecs/libtremor/SOURCES b/lib/rbcodec/codecs/libtremor/SOURCES
new file mode 100644
index 0000000000..c622699599
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/SOURCES
@@ -0,0 +1,16 @@
1bitwise.c
2block.c
3codebook.c
4floor0.c
5floor1.c
6framing.c
7info.c
8mapping0.c
9registry.c
10res012.c
11sharedbook.c
12synthesis.c
13vorbisfile.c
14window.c
15ctype.c
16oggmalloc.c
diff --git a/lib/rbcodec/codecs/libtremor/asm_arm.h b/lib/rbcodec/codecs/libtremor/asm_arm.h
new file mode 100644
index 0000000000..42834a2581
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/asm_arm.h
@@ -0,0 +1,190 @@
1/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
4 * *
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * *
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
11 * *
12 ********************************************************************
13
14 function: arm7 and later wide math functions
15
16 ********************************************************************/
17
18#ifdef _ARM_ASSEM_
19#if ARM_ARCH < 6
20#define INCL_OPTIMIZED_VECTOR_FMUL_WINDOW
21static inline void ff_vector_fmul_window_c(ogg_int32_t *dst, const ogg_int32_t *src0,
22 const ogg_int32_t *src1, const ogg_int32_t *win, int len)
23{
24 /* len is always a power of 2 and always >= 16 so this is unrolled 2 times*/
25 ogg_int32_t *dst0 = dst, *dst1 = dst + 2*len;
26 const ogg_int32_t *win0 = win, *win1 = win + 2*len;
27 src1 += len;
28 asm volatile ("cmp %[len], #0\n\t"
29 "b 1f\n\t"
30 "0:\n\t"
31 "ldr r0, [%[src0]], #4\n\t"
32 "ldr r1, [%[src1], #-4]!\n\t"
33 "ldr r2, [%[win0]], #4\n\t"
34 "ldr r3, [%[win1], #-4]!\n\t"
35 "smull r4, r5, r0, r2\n\t"
36 "smlal r4, r5, r1, r3\n\t"
37 "rsb r2, r2, #0\n\t"
38 "lsl r5, r5, #1\n\t"
39 "str r5, [%[dst1], #-4]!\n\t"
40 "smull r4, r5, r0, r3\n\t"
41 "smlal r4, r5, r1, r2\n\t"
42 "ldr r0, [%[src0]], #4\n\t"
43 "ldr r1, [%[src1], #-4]!\n\t"
44 "lsl r5, r5, #1\n\t"
45 "str r5, [%[dst0]], #4\n\t"
46
47 "ldr r2, [%[win0]], #4\n\t"
48 "ldr r3, [%[win1], #-4]!\n\t"
49 "smull r4, r5, r0, r2\n\t"
50 "smlal r4, r5, r1, r3\n\t"
51 "rsb r2, r2, #0\n\t"
52 "lsl r5, r5, #1\n\t"
53 "str r5, [%[dst1], #-4]!\n\t"
54 "smull r4, r5, r0, r3\n\t"
55 "smlal r4, r5, r1, r2\n\t"
56 "subs %[len], %[len], #2\n\t"
57 "lsl r5, r5, #1\n\t"
58 "str r5, [%[dst0]], #4\n\t"
59 "1:\n\t"
60 "bgt 0b\n\t"
61 : [dst0] "+r" (dst0), [dst1] "+r" (dst1),
62 [src0] "+r" (src0), [src1] "+r" (src1),
63 [win0] "+r" (win0), [win1] "+r" (win1),
64 [len] "+r" (len)
65 :: "r0", "r1", "r2", "r3", "r4", "r5", "cc", "memory");
66}
67#endif
68#ifndef _V_LSP_MATH_ASM
69#define _V_LSP_MATH_ASM
70
71static inline void lsp_loop_asm(ogg_uint32_t *qip,ogg_uint32_t *pip,
72 ogg_int32_t *qexpp,
73 ogg_int32_t *ilsp,ogg_int32_t wi,
74 ogg_int32_t m){
75
76 ogg_uint32_t qi=*qip,pi=*pip;
77 ogg_int32_t qexp=*qexpp;
78
79 asm("mov r0,%3;"
80 "movs r1,%5,asr#1;"
81 "add r0,r0,r1,lsl#3;"
82 "beq 2f;\n"
83 "1:"
84
85 "ldmdb r0!,{r1,r3};"
86 "subs r1,r1,%4;" //ilsp[j]-wi
87 "rsbmi r1,r1,#0;" //labs(ilsp[j]-wi)
88 "umull %0,r2,r1,%0;" //qi*=labs(ilsp[j]-wi)
89
90 "subs r1,r3,%4;" //ilsp[j+1]-wi
91 "rsbmi r1,r1,#0;" //labs(ilsp[j+1]-wi)
92 "umull %1,r3,r1,%1;" //pi*=labs(ilsp[j+1]-wi)
93
94 "cmn r2,r3;" // shift down 16?
95 "beq 0f;"
96 "add %2,%2,#16;"
97 "mov %0,%0,lsr #16;"
98 "orr %0,%0,r2,lsl #16;"
99 "mov %1,%1,lsr #16;"
100 "orr %1,%1,r3,lsl #16;"
101 "0:"
102 "cmp r0,%3;\n"
103 "bhi 1b;\n"
104
105 "2:"
106 // odd filter assymetry
107 "ands r0,%5,#1;\n"
108 "beq 3f;\n"
109 "add r0,%3,%5,lsl#2;\n"
110
111 "ldr r1,[r0,#-4];\n"
112 "mov r0,#0x4000;\n"
113
114 "subs r1,r1,%4;\n" //ilsp[j]-wi
115 "rsbmi r1,r1,#0;\n" //labs(ilsp[j]-wi)
116 "umull %0,r2,r1,%0;\n" //qi*=labs(ilsp[j]-wi)
117 "umull %1,r3,r0,%1;\n" //pi*=labs(ilsp[j+1]-wi)
118
119 "cmn r2,r3;\n" // shift down 16?
120 "beq 3f;\n"
121 "add %2,%2,#16;\n"
122 "mov %0,%0,lsr #16;\n"
123 "orr %0,%0,r2,lsl #16;\n"
124 "mov %1,%1,lsr #16;\n"
125 "orr %1,%1,r3,lsl #16;\n"
126
127 //qi=(pi>>shift)*labs(ilsp[j]-wi);
128 //pi=(qi>>shift)*labs(ilsp[j+1]-wi);
129 //qexp+=shift;
130
131 //}
132
133 /* normalize to max 16 sig figs */
134 "3:"
135 "mov r2,#0;"
136 "orr r1,%0,%1;"
137 "tst r1,#0xff000000;"
138 "addne r2,r2,#8;"
139 "movne r1,r1,lsr #8;"
140 "tst r1,#0x00f00000;"
141 "addne r2,r2,#4;"
142 "movne r1,r1,lsr #4;"
143 "tst r1,#0x000c0000;"
144 "addne r2,r2,#2;"
145 "movne r1,r1,lsr #2;"
146 "tst r1,#0x00020000;"
147 "addne r2,r2,#1;"
148 "movne r1,r1,lsr #1;"
149 "tst r1,#0x00010000;"
150 "addne r2,r2,#1;"
151 "mov %0,%0,lsr r2;"
152 "mov %1,%1,lsr r2;"
153 "add %2,%2,r2;"
154
155 : "+r"(qi),"+r"(pi),"+r"(qexp)
156 : "r"(ilsp),"r"(wi),"r"(m)
157 : "r0","r1","r2","r3","cc");
158
159 *qip=qi;
160 *pip=pi;
161 *qexpp=qexp;
162}
163
164static inline void lsp_norm_asm(ogg_uint32_t *qip,ogg_int32_t *qexpp){
165
166 ogg_uint32_t qi=*qip;
167 ogg_int32_t qexp=*qexpp;
168
169 asm("tst %0,#0x0000ff00;"
170 "moveq %0,%0,lsl #8;"
171 "subeq %1,%1,#8;"
172 "tst %0,#0x0000f000;"
173 "moveq %0,%0,lsl #4;"
174 "subeq %1,%1,#4;"
175 "tst %0,#0x0000c000;"
176 "moveq %0,%0,lsl #2;"
177 "subeq %1,%1,#2;"
178 "tst %0,#0x00008000;"
179 "moveq %0,%0,lsl #1;"
180 "subeq %1,%1,#1;"
181 : "+r"(qi),"+r"(qexp)
182 :
183 : "cc");
184 *qip=qi;
185 *qexpp=qexp;
186}
187
188#endif
189#endif
190
diff --git a/lib/rbcodec/codecs/libtremor/asm_mcf5249.h b/lib/rbcodec/codecs/libtremor/asm_mcf5249.h
new file mode 100644
index 0000000000..38aa117d84
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/asm_mcf5249.h
@@ -0,0 +1,85 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2005 by Pedro Vasconcelos
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20/* asm routines for wide math on the MCF5249 */
21
22#include "os_types.h"
23
24#if defined(CPU_COLDFIRE)
25
26#ifndef _V_WIDE_MATH
27#define _V_WIDE_MATH
28
29#define INCL_OPTIMIZED_VECTOR_FMUL_WINDOW
30static inline void ff_vector_fmul_window_c(ogg_int32_t *dst, const ogg_int32_t *src0,
31 const ogg_int32_t *src1, const ogg_int32_t *win, int len)
32{
33 /* len is always a power of 2 and always >= 16 so this is unrolled 4 times*/
34 ogg_int32_t *dst0 = dst, *dst1 = dst + 2*len;
35 const ogg_int32_t *win0 = win, *win1 = win + 2*len;
36 src1 += len;
37 asm volatile ("move.l (%[src0])+, %%d0\n\t"
38 "move.l -(%[win1]), %%d3\n\t"
39 "tst.l %[len]\n\t"
40 "bra.s 1f\n\t"
41 "0:\n\t"
42 "mac.l %%d0, %%d3, (%[win0])+, %%d2, %%acc0\n\t"
43 "mac.l %%d0, %%d2, -(%[src1]), %%d1, %%acc1\n\t"
44 "msac.l %%d1, %%d2, (%[src0])+, %%d0, %%acc0\n\t"
45 "mac.l %%d1, %%d3, -(%[win1]), %%d3, %%acc1\n\t"
46 "mac.l %%d0, %%d3, (%[win0])+, %%d2, %%acc2\n\t"
47 "mac.l %%d0, %%d2, -(%[src1]), %%d1, %%acc3\n\t"
48 "msac.l %%d1, %%d2, (%[src0])+, %%d0, %%acc2\n\t"
49 "mac.l %%d1, %%d3, -(%[win1]), %%d3, %%acc3\n\t"
50 "movclr.l %%acc0, %%d1\n\t"
51 "movclr.l %%acc2, %%d2\n\t"
52 "subq.l #8, %[dst1]\n\t"
53 "movclr.l %%acc1, %%d5\n\t"
54 "movclr.l %%acc3, %%d4\n\t"
55 "movem.l %%d4-%%d5, (%[dst1])\n\t"
56 "mac.l %%d0, %%d3, (%[win0])+, %%d5, %%acc0\n\t"
57 "mac.l %%d0, %%d5, -(%[src1]), %%d4, %%acc1\n\t"
58 "msac.l %%d4, %%d5, (%[src0])+, %%d0, %%acc0\n\t"
59 "mac.l %%d4, %%d3, -(%[win1]), %%d3, %%acc1\n\t"
60 "mac.l %%d0, %%d3, (%[win0])+, %%d5, %%acc2\n\t"
61 "mac.l %%d0, %%d5, -(%[src1]), %%d4, %%acc3\n\t"
62 "msac.l %%d4, %%d5, (%[src0])+, %%d0, %%acc2\n\t" /* will read one past end of src0 */
63 "mac.l %%d4, %%d3, -(%[win1]), %%d3, %%acc3\n\t" /* will read one into win0 */
64 "movclr.l %%acc0, %%d4\n\t"
65 "movclr.l %%acc2, %%d5\n\t"
66 "movem.l %%d1-%%d2/%%d4-%%d5, (%[dst0])\n\t"
67 "lea (16, %[dst0]), %[dst0]\n\t"
68 "subq.l #8, %[dst1]\n\t"
69 "movclr.l %%acc1, %%d2\n\t"
70 "movclr.l %%acc3, %%d1\n\t"
71 "movem.l %%d1-%%d2, (%[dst1])\n\t"
72 "subq.l #4, %[len]\n\t"
73 "1:\n\t"
74 "bgt.s 0b\n\t"
75 : [dst0] "+a" (dst0), [dst1] "+a" (dst1),
76 [src0] "+a" (src0), [src1] "+a" (src1),
77 [win0] "+a" (win0), [win1] "+a" (win1),
78 [len] "+d" (len)
79 :: "d0", "d1", "d2", "d3", "d4", "d5", "cc", "memory" );
80}
81
82#define MB()
83
84#endif
85#endif
diff --git a/lib/rbcodec/codecs/libtremor/backends.h b/lib/rbcodec/codecs/libtremor/backends.h
new file mode 100644
index 0000000000..e27f1f2b80
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/backends.h
@@ -0,0 +1,133 @@
1/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
4 * *
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * *
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
11 * *
12 ********************************************************************
13
14 function: backend and mapping structures
15
16 ********************************************************************/
17
18/* this is exposed up here because we need it for static modes.
19 Lookups for each backend aren't exposed because there's no reason
20 to do so */
21
22#ifndef _vorbis_backend_h_
23#define _vorbis_backend_h_
24
25#include "codec_internal.h"
26
27/* this would all be simpler/shorter with templates, but.... */
28/* Transform backend generic *************************************/
29
30/* only mdct right now. Flesh it out more if we ever transcend mdct
31 in the transform domain */
32
33/* Floor backend generic *****************************************/
34typedef struct{
35 vorbis_info_floor *(*unpack)(vorbis_info *,oggpack_buffer *);
36 vorbis_look_floor *(*look) (vorbis_dsp_state *,vorbis_info_mode *,
37 vorbis_info_floor *);
38 void (*free_info) (vorbis_info_floor *);
39 void (*free_look) (vorbis_look_floor *);
40 void *(*inverse1) (struct vorbis_block *,vorbis_look_floor *);
41 int (*inverse2) (struct vorbis_block *,vorbis_look_floor *,
42 void *buffer,ogg_int32_t *);
43} vorbis_func_floor;
44
45typedef struct{
46 int order;
47 long rate;
48 long barkmap;
49
50 int ampbits;
51 int ampdB;
52
53 int numbooks; /* <= 16 */
54 int books[16];
55
56} vorbis_info_floor0;
57
58#define VIF_POSIT 63
59#define VIF_CLASS 16
60#define VIF_PARTS 31
61typedef struct{
62 int partitions; /* 0 to 31 */
63 int partitionclass[VIF_PARTS]; /* 0 to 15 */
64
65 int class_dim[VIF_CLASS]; /* 1 to 8 */
66 int class_subs[VIF_CLASS]; /* 0,1,2,3 (bits: 1<<n poss) */
67 int class_book[VIF_CLASS]; /* subs ^ dim entries */
68 int class_subbook[VIF_CLASS][8]; /* [VIF_CLASS][subs] */
69
70
71 int mult; /* 1 2 3 or 4 */
72 int postlist[VIF_POSIT+2]; /* first two implicit */
73
74} vorbis_info_floor1;
75
76/* Residue backend generic *****************************************/
77typedef struct{
78 vorbis_info_residue *(*unpack)(vorbis_info *,oggpack_buffer *);
79 vorbis_look_residue *(*look) (vorbis_dsp_state *,vorbis_info_mode *,
80 vorbis_info_residue *);
81 void (*free_info) (vorbis_info_residue *);
82 void (*free_look) (vorbis_look_residue *);
83 int (*inverse) (struct vorbis_block *,vorbis_look_residue *,
84 ogg_int32_t **,int *,int);
85} vorbis_func_residue;
86
87typedef struct vorbis_info_residue0{
88/* block-partitioned VQ coded straight residue */
89 long begin;
90 long end;
91
92 /* first stage (lossless partitioning) */
93 int grouping; /* group n vectors per partition */
94 int partitions; /* possible codebooks for a partition */
95 int partvals; /* partitions ^ groupbook dim */
96 int groupbook; /* huffbook for partitioning */
97 int secondstages[64]; /* expanded out to pointers in lookup */
98 int booklist[512]; /* list of second stage books */
99} vorbis_info_residue0;
100
101/* Mapping backend generic *****************************************/
102typedef struct{
103 vorbis_info_mapping *(*unpack)(vorbis_info *,oggpack_buffer *);
104 vorbis_look_mapping *(*look) (vorbis_dsp_state *,vorbis_info_mode *,
105 vorbis_info_mapping *);
106 void (*free_info) (vorbis_info_mapping *);
107 void (*free_look) (vorbis_look_mapping *);
108 int (*inverse) (struct vorbis_block *vb,vorbis_look_mapping *);
109} vorbis_func_mapping;
110
111typedef struct vorbis_info_mapping0{
112 int submaps; /* <= 16 */
113 int chmuxlist[CHANNELS]; /* up to 256 channels in a Vorbis stream */
114
115 int floorsubmap[16]; /* [mux] submap to floors */
116 int residuesubmap[16]; /* [mux] submap to residue */
117
118#if 0
119 int psy[2]; /* by blocktype; impulse/padding for short,
120 transition/normal for long */
121#endif
122
123 int coupling_steps;
124 unsigned char coupling_mag[256];
125 unsigned char coupling_ang[256];
126} vorbis_info_mapping0;
127
128#endif
129
130
131
132
133
diff --git a/lib/rbcodec/codecs/libtremor/bitwise.c b/lib/rbcodec/codecs/libtremor/bitwise.c
new file mode 100644
index 0000000000..040384abc6
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/bitwise.c
@@ -0,0 +1,867 @@
1/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE Ogg CONTAINER SOURCE CODE. *
4 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
5 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
6 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
7 * *
8 * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2010 *
9 * by the Xiph.Org Foundation http://www.xiph.org/ *
10 * *
11 ********************************************************************
12
13 function: packing variable sized words into an octet stream
14 last mod: $Id$
15
16 ********************************************************************/
17
18/* We're 'LSb' endian; if we write a word but read individual bits,
19 then we'll read the lsb first */
20
21#include <string.h>
22#include <stdlib.h>
23#include <limits.h>
24#include "ogg.h"
25
26#define BUFFER_INCREMENT 256
27
28const unsigned long mask[] ICONST_ATTR =
29{0x00000000,0x00000001,0x00000003,0x00000007,0x0000000f,
30 0x0000001f,0x0000003f,0x0000007f,0x000000ff,0x000001ff,
31 0x000003ff,0x000007ff,0x00000fff,0x00001fff,0x00003fff,
32 0x00007fff,0x0000ffff,0x0001ffff,0x0003ffff,0x0007ffff,
33 0x000fffff,0x001fffff,0x003fffff,0x007fffff,0x00ffffff,
34 0x01ffffff,0x03ffffff,0x07ffffff,0x0fffffff,0x1fffffff,
35 0x3fffffff,0x7fffffff,0xffffffff };
36
37#if 0
38static const unsigned int mask8B[]=
39{0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff};
40
41void oggpack_writeinit(oggpack_buffer *b){
42 memset(b,0,sizeof(*b));
43 b->ptr=b->buffer=_ogg_malloc(BUFFER_INCREMENT);
44 b->buffer[0]='\0';
45 b->storage=BUFFER_INCREMENT;
46}
47
48void oggpackB_writeinit(oggpack_buffer *b){
49 oggpack_writeinit(b);
50}
51
52int oggpack_writecheck(oggpack_buffer *b){
53 if(!b->ptr || !b->storage)return -1;
54 return 0;
55}
56
57int oggpackB_writecheck(oggpack_buffer *b){
58 return oggpack_writecheck(b);
59}
60
61void oggpack_writetrunc(oggpack_buffer *b,long bits){
62 long bytes=bits>>3;
63 if(b->ptr){
64 bits-=bytes*8;
65 b->ptr=b->buffer+bytes;
66 b->endbit=bits;
67 b->endbyte=bytes;
68 *b->ptr&=mask[bits];
69 }
70}
71
72void oggpackB_writetrunc(oggpack_buffer *b,long bits){
73 long bytes=bits>>3;
74 if(b->ptr){
75 bits-=bytes*8;
76 b->ptr=b->buffer+bytes;
77 b->endbit=bits;
78 b->endbyte=bytes;
79 *b->ptr&=mask8B[bits];
80 }
81}
82
83/* Takes only up to 32 bits. */
84void oggpack_write(oggpack_buffer *b,unsigned long value,int bits){
85 if(bits<0 || bits>32) goto err;
86 if(b->endbyte>=b->storage-4){
87 void *ret;
88 if(!b->ptr)return;
89 if(b->storage>LONG_MAX-BUFFER_INCREMENT) goto err;
90 ret=_ogg_realloc(b->buffer,b->storage+BUFFER_INCREMENT);
91 if(!ret) goto err;
92 b->buffer=ret;
93 b->storage+=BUFFER_INCREMENT;
94 b->ptr=b->buffer+b->endbyte;
95 }
96
97 value&=mask[bits];
98 bits+=b->endbit;
99
100 b->ptr[0]|=value<<b->endbit;
101
102 if(bits>=8){
103 b->ptr[1]=(unsigned char)(value>>(8-b->endbit));
104 if(bits>=16){
105 b->ptr[2]=(unsigned char)(value>>(16-b->endbit));
106 if(bits>=24){
107 b->ptr[3]=(unsigned char)(value>>(24-b->endbit));
108 if(bits>=32){
109 if(b->endbit)
110 b->ptr[4]=(unsigned char)(value>>(32-b->endbit));
111 else
112 b->ptr[4]=0;
113 }
114 }
115 }
116 }
117
118 b->endbyte+=bits/8;
119 b->ptr+=bits/8;
120 b->endbit=bits&7;
121 return;
122 err:
123 oggpack_writeclear(b);
124}
125
126/* Takes only up to 32 bits. */
127void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits){
128 if(bits<0 || bits>32) goto err;
129 if(b->endbyte>=b->storage-4){
130 void *ret;
131 if(!b->ptr)return;
132 if(b->storage>LONG_MAX-BUFFER_INCREMENT) goto err;
133 ret=_ogg_realloc(b->buffer,b->storage+BUFFER_INCREMENT);
134 if(!ret) goto err;
135 b->buffer=ret;
136 b->storage+=BUFFER_INCREMENT;
137 b->ptr=b->buffer+b->endbyte;
138 }
139
140 value=(value&mask[bits])<<(32-bits);
141 bits+=b->endbit;
142
143 b->ptr[0]|=value>>(24+b->endbit);
144
145 if(bits>=8){
146 b->ptr[1]=(unsigned char)(value>>(16+b->endbit));
147 if(bits>=16){
148 b->ptr[2]=(unsigned char)(value>>(8+b->endbit));
149 if(bits>=24){
150 b->ptr[3]=(unsigned char)(value>>(b->endbit));
151 if(bits>=32){
152 if(b->endbit)
153 b->ptr[4]=(unsigned char)(value<<(8-b->endbit));
154 else
155 b->ptr[4]=0;
156 }
157 }
158 }
159 }
160
161 b->endbyte+=bits/8;
162 b->ptr+=bits/8;
163 b->endbit=bits&7;
164 return;
165 err:
166 oggpack_writeclear(b);
167}
168
169void oggpack_writealign(oggpack_buffer *b){
170 int bits=8-b->endbit;
171 if(bits<8)
172 oggpack_write(b,0,bits);
173}
174
175void oggpackB_writealign(oggpack_buffer *b){
176 int bits=8-b->endbit;
177 if(bits<8)
178 oggpackB_write(b,0,bits);
179}
180
181static void oggpack_writecopy_helper(oggpack_buffer *b,
182 void *source,
183 long bits,
184 void (*w)(oggpack_buffer *,
185 unsigned long,
186 int),
187 int msb){
188 unsigned char *ptr=(unsigned char *)source;
189
190 long bytes=bits/8;
191 bits-=bytes*8;
192
193 if(b->endbit){
194 int i;
195 /* unaligned copy. Do it the hard way. */
196 for(i=0;i<bytes;i++)
197 w(b,(unsigned long)(ptr[i]),8);
198 }else{
199 /* aligned block copy */
200 if(b->endbyte+bytes+1>=b->storage){
201 void *ret;
202 if(!b->ptr) goto err;
203 if(b->endbyte+bytes+BUFFER_INCREMENT>b->storage) goto err;
204 b->storage=b->endbyte+bytes+BUFFER_INCREMENT;
205 ret=_ogg_realloc(b->buffer,b->storage);
206 if(!ret) goto err;
207 b->buffer=ret;
208 b->ptr=b->buffer+b->endbyte;
209 }
210
211 memmove(b->ptr,source,bytes);
212 b->ptr+=bytes;
213 b->endbyte+=bytes;
214 *b->ptr=0;
215
216 }
217 if(bits){
218 if(msb)
219 w(b,(unsigned long)(ptr[bytes]>>(8-bits)),bits);
220 else
221 w(b,(unsigned long)(ptr[bytes]),bits);
222 }
223 return;
224 err:
225 oggpack_writeclear(b);
226}
227
228void oggpack_writecopy(oggpack_buffer *b,void *source,long bits){
229 oggpack_writecopy_helper(b,source,bits,oggpack_write,0);
230}
231
232void oggpackB_writecopy(oggpack_buffer *b,void *source,long bits){
233 oggpack_writecopy_helper(b,source,bits,oggpackB_write,1);
234}
235
236void oggpack_reset(oggpack_buffer *b){
237 if(!b->ptr)return;
238 b->ptr=b->buffer;
239 b->buffer[0]=0;
240 b->endbit=b->endbyte=0;
241}
242
243void oggpackB_reset(oggpack_buffer *b){
244 oggpack_reset(b);
245}
246
247void oggpack_writeclear(oggpack_buffer *b){
248 if(b->buffer)_ogg_free(b->buffer);
249 memset(b,0,sizeof(*b));
250}
251
252void oggpackB_writeclear(oggpack_buffer *b){
253 oggpack_writeclear(b);
254}
255#endif
256void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes){
257 memset(b,0,sizeof(*b));
258 b->buffer=b->ptr=buf;
259 b->storage=bytes;
260}
261#if 0
262void oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes){
263 oggpack_readinit(b,buf,bytes);
264}
265#endif
266/* Read in bits without advancing the bitptr; bits <= 32 */
267/* moved to ogg.h for inlining */
268#if 0
269long oggpack_look(oggpack_buffer *b,int bits){
270 unsigned long ret;
271 unsigned long m;
272
273 if(bits<0 || bits>32) return -1;
274 m=mask[bits];
275 bits+=b->endbit;
276
277 if(b->endbyte >= b->storage-4){
278 /* not the main path */
279 if(b->endbyte > b->storage-((bits+7)>>3)) return -1;
280 /* special case to avoid reading b->ptr[0], which might be past the end of
281 the buffer; also skips some useless accounting */
282 else if(!bits)return(0L);
283 }
284
285 ret=b->ptr[0]>>b->endbit;
286 if(bits>8){
287 ret|=b->ptr[1]<<(8-b->endbit);
288 if(bits>16){
289 ret|=b->ptr[2]<<(16-b->endbit);
290 if(bits>24){
291 ret|=b->ptr[3]<<(24-b->endbit);
292 if(bits>32 && b->endbit)
293 ret|=b->ptr[4]<<(32-b->endbit);
294 }
295 }
296 }
297 return(m&ret);
298}
299#endif
300
301#if 0
302/* Read in bits without advancing the bitptr; bits <= 32 */
303long oggpackB_look(oggpack_buffer *b,int bits){
304 unsigned long ret;
305 int m=32-bits;
306
307 if(m<0 || m>32) return -1;
308 bits+=b->endbit;
309
310 if(b->endbyte >= b->storage-4){
311 /* not the main path */
312 if(b->endbyte > b->storage-((bits+7)>>3)) return -1;
313 /* special case to avoid reading b->ptr[0], which might be past the end of
314 the buffer; also skips some useless accounting */
315 else if(!bits)return(0L);
316 }
317
318 ret=b->ptr[0]<<(24+b->endbit);
319 if(bits>8){
320 ret|=b->ptr[1]<<(16+b->endbit);
321 if(bits>16){
322 ret|=b->ptr[2]<<(8+b->endbit);
323 if(bits>24){
324 ret|=b->ptr[3]<<(b->endbit);
325 if(bits>32 && b->endbit)
326 ret|=b->ptr[4]>>(8-b->endbit);
327 }
328 }
329 }
330 return ((ret&0xffffffff)>>(m>>1))>>((m+1)>>1);
331}
332
333long oggpack_look1(oggpack_buffer *b){
334 if(b->endbyte>=b->storage)return(-1);
335 return((b->ptr[0]>>b->endbit)&1);
336}
337
338long oggpackB_look1(oggpack_buffer *b){
339 if(b->endbyte>=b->storage)return(-1);
340 return((b->ptr[0]>>(7-b->endbit))&1);
341}
342#endif
343/* moved to ogg.h for inlining
344void oggpack_adv(oggpack_buffer *b,int bits){
345 bits+=b->endbit;
346
347 if(b->endbyte > b->storage-((bits+7)>>3)) goto overflow;
348
349 b->ptr+=bits/8;
350 b->endbyte+=bits/8;
351 b->endbit=bits&7;
352 return;
353
354 overflow:
355 b->ptr=NULL;
356 b->endbyte=b->storage;
357 b->endbit=1;
358}
359*/
360#if 0
361void oggpackB_adv(oggpack_buffer *b,int bits){
362 oggpack_adv(b,bits);
363}
364
365void oggpack_adv1(oggpack_buffer *b){
366 if(++(b->endbit)>7){
367 b->endbit=0;
368 b->ptr++;
369 b->endbyte++;
370 }
371}
372
373void oggpackB_adv1(oggpack_buffer *b){
374 oggpack_adv1(b);
375}
376#endif
377/* bits <= 32 */
378long oggpack_read(oggpack_buffer *b,int bits) ICODE_ATTR_TREMOR_NOT_MDCT;
379long oggpack_read(oggpack_buffer *b,int bits){
380 long ret;
381 unsigned long m;
382
383 if(bits<0 || bits>32) goto err;
384 m=mask[bits];
385 bits+=b->endbit;
386
387 if(b->endbyte >= b->storage-4){
388 /* not the main path */
389 if(b->endbyte > b->storage-((bits+7)>>3)) goto overflow;
390 /* special case to avoid reading b->ptr[0], which might be past the end of
391 the buffer; also skips some useless accounting */
392 else if(!bits)return(0L);
393 }
394
395 ret=b->ptr[0]>>b->endbit;
396 if(bits>8){
397 ret|=b->ptr[1]<<(8-b->endbit);
398 if(bits>16){
399 ret|=b->ptr[2]<<(16-b->endbit);
400 if(bits>24){
401 ret|=b->ptr[3]<<(24-b->endbit);
402 if(bits>32 && b->endbit){
403 ret|=b->ptr[4]<<(32-b->endbit);
404 }
405 }
406 }
407 }
408 ret&=m;
409 b->ptr+=bits/8;
410 b->endbyte+=bits/8;
411 b->endbit=bits&7;
412 return ret;
413
414 overflow:
415 err:
416 b->ptr=NULL;
417 b->endbyte=b->storage;
418 b->endbit=1;
419 return -1L;
420}
421#if 0
422/* bits <= 32 */
423long oggpackB_read(oggpack_buffer *b,int bits){
424 long ret;
425 long m=32-bits;
426
427 if(m<0 || m>32) goto err;
428 bits+=b->endbit;
429
430 if(b->endbyte+4>=b->storage){
431 /* not the main path */
432 if(b->endbyte > b->storage-((bits+7)>>3)) goto overflow;
433 /* special case to avoid reading b->ptr[0], which might be past the end of
434 the buffer; also skips some useless accounting */
435 else if(!bits)return(0L);
436 }
437
438 ret=b->ptr[0]<<(24+b->endbit);
439 if(bits>8){
440 ret|=b->ptr[1]<<(16+b->endbit);
441 if(bits>16){
442 ret|=b->ptr[2]<<(8+b->endbit);
443 if(bits>24){
444 ret|=b->ptr[3]<<(b->endbit);
445 if(bits>32 && b->endbit)
446 ret|=b->ptr[4]>>(8-b->endbit);
447 }
448 }
449 }
450 ret=((ret&0xffffffffUL)>>(m>>1))>>((m+1)>>1);
451
452 b->ptr+=bits/8;
453 b->endbyte+=bits/8;
454 b->endbit=bits&7;
455 return ret;
456
457 overflow:
458 err:
459 b->ptr=NULL;
460 b->endbyte=b->storage;
461 b->endbit=1;
462 return -1L;
463}
464
465long oggpack_read1(oggpack_buffer *b){
466 long ret;
467
468 if(b->endbyte >= b->storage) goto overflow;
469 ret=(b->ptr[0]>>b->endbit)&1;
470
471 b->endbit++;
472 if(b->endbit>7){
473 b->endbit=0;
474 b->ptr++;
475 b->endbyte++;
476 }
477 return ret;
478
479 overflow:
480 b->ptr=NULL;
481 b->endbyte=b->storage;
482 b->endbit=1;
483 return -1L;
484}
485
486long oggpackB_read1(oggpack_buffer *b){
487 long ret;
488
489 if(b->endbyte >= b->storage) goto overflow;
490 ret=(b->ptr[0]>>(7-b->endbit))&1;
491
492 b->endbit++;
493 if(b->endbit>7){
494 b->endbit=0;
495 b->ptr++;
496 b->endbyte++;
497 }
498 return ret;
499
500 overflow:
501 b->ptr=NULL;
502 b->endbyte=b->storage;
503 b->endbit=1;
504 return -1L;
505}
506#endif
507/* moved to ogg.h for inlining
508long oggpack_bytes(oggpack_buffer *b){
509 return(b->endbyte+(b->endbit+7)/8);
510}
511*/
512#if 0
513long oggpack_bits(oggpack_buffer *b){
514 return(b->endbyte*8+b->endbit);
515}
516
517long oggpackB_bytes(oggpack_buffer *b){
518 return oggpack_bytes(b);
519}
520
521long oggpackB_bits(oggpack_buffer *b){
522 return oggpack_bits(b);
523}
524
525unsigned char *oggpack_get_buffer(oggpack_buffer *b){
526 return(b->buffer);
527}
528
529unsigned char *oggpackB_get_buffer(oggpack_buffer *b){
530 return oggpack_get_buffer(b);
531}
532#endif
533/* Self test of the bitwise routines; everything else is based on
534 them, so they damned well better be solid. */
535
536#ifdef _V_SELFTEST
537#include <stdio.h>
538
539static int ilog(unsigned int v){
540 int ret=0;
541 while(v){
542 ret++;
543 v>>=1;
544 }
545 return(ret);
546}
547
548oggpack_buffer o;
549oggpack_buffer r;
550
551void report(char *in){
552 fprintf(stderr,"%s",in);
553 exit(1);
554}
555
556void cliptest(unsigned long *b,int vals,int bits,int *comp,int compsize){
557 long bytes,i;
558 unsigned char *buffer;
559
560 oggpack_reset(&o);
561 for(i=0;i<vals;i++)
562 oggpack_write(&o,b[i],bits?bits:ilog(b[i]));
563 buffer=oggpack_get_buffer(&o);
564 bytes=oggpack_bytes(&o);
565 if(bytes!=compsize)report("wrong number of bytes!\n");
566 for(i=0;i<bytes;i++)if(buffer[i]!=comp[i]){
567 for(i=0;i<bytes;i++)fprintf(stderr,"%x %x\n",(int)buffer[i],(int)comp[i]);
568 report("wrote incorrect value!\n");
569 }
570 oggpack_readinit(&r,buffer,bytes);
571 for(i=0;i<vals;i++){
572 int tbit=bits?bits:ilog(b[i]);
573 if(oggpack_look(&r,tbit)==-1)
574 report("out of data!\n");
575 if(oggpack_look(&r,tbit)!=(b[i]&mask[tbit]))
576 report("looked at incorrect value!\n");
577 if(tbit==1)
578 if(oggpack_look1(&r)!=(b[i]&mask[tbit]))
579 report("looked at single bit incorrect value!\n");
580 if(tbit==1){
581 if(oggpack_read1(&r)!=(b[i]&mask[tbit]))
582 report("read incorrect single bit value!\n");
583 }else{
584 if(oggpack_read(&r,tbit)!=(b[i]&mask[tbit]))
585 report("read incorrect value!\n");
586 }
587 }
588 if(oggpack_bytes(&r)!=bytes)report("leftover bytes after read!\n");
589}
590
591void cliptestB(unsigned long *b,int vals,int bits,int *comp,int compsize){
592 long bytes,i;
593 unsigned char *buffer;
594
595 oggpackB_reset(&o);
596 for(i=0;i<vals;i++)
597 oggpackB_write(&o,b[i],bits?bits:ilog(b[i]));
598 buffer=oggpackB_get_buffer(&o);
599 bytes=oggpackB_bytes(&o);
600 if(bytes!=compsize)report("wrong number of bytes!\n");
601 for(i=0;i<bytes;i++)if(buffer[i]!=comp[i]){
602 for(i=0;i<bytes;i++)fprintf(stderr,"%x %x\n",(int)buffer[i],(int)comp[i]);
603 report("wrote incorrect value!\n");
604 }
605 oggpackB_readinit(&r,buffer,bytes);
606 for(i=0;i<vals;i++){
607 int tbit=bits?bits:ilog(b[i]);
608 if(oggpackB_look(&r,tbit)==-1)
609 report("out of data!\n");
610 if(oggpackB_look(&r,tbit)!=(b[i]&mask[tbit]))
611 report("looked at incorrect value!\n");
612 if(tbit==1)
613 if(oggpackB_look1(&r)!=(b[i]&mask[tbit]))
614 report("looked at single bit incorrect value!\n");
615 if(tbit==1){
616 if(oggpackB_read1(&r)!=(b[i]&mask[tbit]))
617 report("read incorrect single bit value!\n");
618 }else{
619 if(oggpackB_read(&r,tbit)!=(b[i]&mask[tbit]))
620 report("read incorrect value!\n");
621 }
622 }
623 if(oggpackB_bytes(&r)!=bytes)report("leftover bytes after read!\n");
624}
625
626int main(void){
627 unsigned char *buffer;
628 long bytes,i;
629 static unsigned long testbuffer1[]=
630 {18,12,103948,4325,543,76,432,52,3,65,4,56,32,42,34,21,1,23,32,546,456,7,
631 567,56,8,8,55,3,52,342,341,4,265,7,67,86,2199,21,7,1,5,1,4};
632 int test1size=43;
633
634 static unsigned long testbuffer2[]=
635 {216531625L,1237861823,56732452,131,3212421,12325343,34547562,12313212,
636 1233432,534,5,346435231,14436467,7869299,76326614,167548585,
637 85525151,0,12321,1,349528352};
638 int test2size=21;
639
640 static unsigned long testbuffer3[]=
641 {1,0,14,0,1,0,12,0,1,0,0,0,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0,1,1,1,1,1,0,0,1,
642 0,1,30,1,1,1,0,0,1,0,0,0,12,0,11,0,1,0,0,1};
643 int test3size=56;
644
645 static unsigned long large[]=
646 {2136531625L,2137861823,56732452,131,3212421,12325343,34547562,12313212,
647 1233432,534,5,2146435231,14436467,7869299,76326614,167548585,
648 85525151,0,12321,1,2146528352};
649
650 int onesize=33;
651 static int one[33]={146,25,44,151,195,15,153,176,233,131,196,65,85,172,47,40,
652 34,242,223,136,35,222,211,86,171,50,225,135,214,75,172,
653 223,4};
654 static int oneB[33]={150,101,131,33,203,15,204,216,105,193,156,65,84,85,222,
655 8,139,145,227,126,34,55,244,171,85,100,39,195,173,18,
656 245,251,128};
657
658 int twosize=6;
659 static int two[6]={61,255,255,251,231,29};
660 static int twoB[6]={247,63,255,253,249,120};
661
662 int threesize=54;
663 static int three[54]={169,2,232,252,91,132,156,36,89,13,123,176,144,32,254,
664 142,224,85,59,121,144,79,124,23,67,90,90,216,79,23,83,
665 58,135,196,61,55,129,183,54,101,100,170,37,127,126,10,
666 100,52,4,14,18,86,77,1};
667 static int threeB[54]={206,128,42,153,57,8,183,251,13,89,36,30,32,144,183,
668 130,59,240,121,59,85,223,19,228,180,134,33,107,74,98,
669 233,253,196,135,63,2,110,114,50,155,90,127,37,170,104,
670 200,20,254,4,58,106,176,144,0};
671
672 int foursize=38;
673 static int four[38]={18,6,163,252,97,194,104,131,32,1,7,82,137,42,129,11,72,
674 132,60,220,112,8,196,109,64,179,86,9,137,195,208,122,169,
675 28,2,133,0,1};
676 static int fourB[38]={36,48,102,83,243,24,52,7,4,35,132,10,145,21,2,93,2,41,
677 1,219,184,16,33,184,54,149,170,132,18,30,29,98,229,67,
678 129,10,4,32};
679
680 int fivesize=45;
681 static int five[45]={169,2,126,139,144,172,30,4,80,72,240,59,130,218,73,62,
682 241,24,210,44,4,20,0,248,116,49,135,100,110,130,181,169,
683 84,75,159,2,1,0,132,192,8,0,0,18,22};
684 static int fiveB[45]={1,84,145,111,245,100,128,8,56,36,40,71,126,78,213,226,
685 124,105,12,0,133,128,0,162,233,242,67,152,77,205,77,
686 172,150,169,129,79,128,0,6,4,32,0,27,9,0};
687
688 int sixsize=7;
689 static int six[7]={17,177,170,242,169,19,148};
690 static int sixB[7]={136,141,85,79,149,200,41};
691
692 /* Test read/write together */
693 /* Later we test against pregenerated bitstreams */
694 oggpack_writeinit(&o);
695
696 fprintf(stderr,"\nSmall preclipped packing (LSb): ");
697 cliptest(testbuffer1,test1size,0,one,onesize);
698 fprintf(stderr,"ok.");
699
700 fprintf(stderr,"\nNull bit call (LSb): ");
701 cliptest(testbuffer3,test3size,0,two,twosize);
702 fprintf(stderr,"ok.");
703
704 fprintf(stderr,"\nLarge preclipped packing (LSb): ");
705 cliptest(testbuffer2,test2size,0,three,threesize);
706 fprintf(stderr,"ok.");
707
708 fprintf(stderr,"\n32 bit preclipped packing (LSb): ");
709 oggpack_reset(&o);
710 for(i=0;i<test2size;i++)
711 oggpack_write(&o,large[i],32);
712 buffer=oggpack_get_buffer(&o);
713 bytes=oggpack_bytes(&o);
714 oggpack_readinit(&r,buffer,bytes);
715 for(i=0;i<test2size;i++){
716 if(oggpack_look(&r,32)==-1)report("out of data. failed!");
717 if(oggpack_look(&r,32)!=large[i]){
718 fprintf(stderr,"%ld != %ld (%lx!=%lx):",oggpack_look(&r,32),large[i],
719 oggpack_look(&r,32),large[i]);
720 report("read incorrect value!\n");
721 }
722 oggpack_adv(&r,32);
723 }
724 if(oggpack_bytes(&r)!=bytes)report("leftover bytes after read!\n");
725 fprintf(stderr,"ok.");
726
727 fprintf(stderr,"\nSmall unclipped packing (LSb): ");
728 cliptest(testbuffer1,test1size,7,four,foursize);
729 fprintf(stderr,"ok.");
730
731 fprintf(stderr,"\nLarge unclipped packing (LSb): ");
732 cliptest(testbuffer2,test2size,17,five,fivesize);
733 fprintf(stderr,"ok.");
734
735 fprintf(stderr,"\nSingle bit unclipped packing (LSb): ");
736 cliptest(testbuffer3,test3size,1,six,sixsize);
737 fprintf(stderr,"ok.");
738
739 fprintf(stderr,"\nTesting read past end (LSb): ");
740 oggpack_readinit(&r,(unsigned char *)"\0\0\0\0\0\0\0\0",8);
741 for(i=0;i<64;i++){
742 if(oggpack_read(&r,1)!=0){
743 fprintf(stderr,"failed; got -1 prematurely.\n");
744 exit(1);
745 }
746 }
747 if(oggpack_look(&r,1)!=-1 ||
748 oggpack_read(&r,1)!=-1){
749 fprintf(stderr,"failed; read past end without -1.\n");
750 exit(1);
751 }
752 oggpack_readinit(&r,(unsigned char *)"\0\0\0\0\0\0\0\0",8);
753 if(oggpack_read(&r,30)!=0 || oggpack_read(&r,16)!=0){
754 fprintf(stderr,"failed 2; got -1 prematurely.\n");
755 exit(1);
756 }
757
758 if(oggpack_look(&r,18)!=0 ||
759 oggpack_look(&r,18)!=0){
760 fprintf(stderr,"failed 3; got -1 prematurely.\n");
761 exit(1);
762 }
763 if(oggpack_look(&r,19)!=-1 ||
764 oggpack_look(&r,19)!=-1){
765 fprintf(stderr,"failed; read past end without -1.\n");
766 exit(1);
767 }
768 if(oggpack_look(&r,32)!=-1 ||
769 oggpack_look(&r,32)!=-1){
770 fprintf(stderr,"failed; read past end without -1.\n");
771 exit(1);
772 }
773 oggpack_writeclear(&o);
774 fprintf(stderr,"ok.\n");
775
776 /********** lazy, cut-n-paste retest with MSb packing ***********/
777
778 /* Test read/write together */
779 /* Later we test against pregenerated bitstreams */
780 oggpackB_writeinit(&o);
781
782 fprintf(stderr,"\nSmall preclipped packing (MSb): ");
783 cliptestB(testbuffer1,test1size,0,oneB,onesize);
784 fprintf(stderr,"ok.");
785
786 fprintf(stderr,"\nNull bit call (MSb): ");
787 cliptestB(testbuffer3,test3size,0,twoB,twosize);
788 fprintf(stderr,"ok.");
789
790 fprintf(stderr,"\nLarge preclipped packing (MSb): ");
791 cliptestB(testbuffer2,test2size,0,threeB,threesize);
792 fprintf(stderr,"ok.");
793
794 fprintf(stderr,"\n32 bit preclipped packing (MSb): ");
795 oggpackB_reset(&o);
796 for(i=0;i<test2size;i++)
797 oggpackB_write(&o,large[i],32);
798 buffer=oggpackB_get_buffer(&o);
799 bytes=oggpackB_bytes(&o);
800 oggpackB_readinit(&r,buffer,bytes);
801 for(i=0;i<test2size;i++){
802 if(oggpackB_look(&r,32)==-1)report("out of data. failed!");
803 if(oggpackB_look(&r,32)!=large[i]){
804 fprintf(stderr,"%ld != %ld (%lx!=%lx):",oggpackB_look(&r,32),large[i],
805 oggpackB_look(&r,32),large[i]);
806 report("read incorrect value!\n");
807 }
808 oggpackB_adv(&r,32);
809 }
810 if(oggpackB_bytes(&r)!=bytes)report("leftover bytes after read!\n");
811 fprintf(stderr,"ok.");
812
813 fprintf(stderr,"\nSmall unclipped packing (MSb): ");
814 cliptestB(testbuffer1,test1size,7,fourB,foursize);
815 fprintf(stderr,"ok.");
816
817 fprintf(stderr,"\nLarge unclipped packing (MSb): ");
818 cliptestB(testbuffer2,test2size,17,fiveB,fivesize);
819 fprintf(stderr,"ok.");
820
821 fprintf(stderr,"\nSingle bit unclipped packing (MSb): ");
822 cliptestB(testbuffer3,test3size,1,sixB,sixsize);
823 fprintf(stderr,"ok.");
824
825 fprintf(stderr,"\nTesting read past end (MSb): ");
826 oggpackB_readinit(&r,(unsigned char *)"\0\0\0\0\0\0\0\0",8);
827 for(i=0;i<64;i++){
828 if(oggpackB_read(&r,1)!=0){
829 fprintf(stderr,"failed; got -1 prematurely.\n");
830 exit(1);
831 }
832 }
833 if(oggpackB_look(&r,1)!=-1 ||
834 oggpackB_read(&r,1)!=-1){
835 fprintf(stderr,"failed; read past end without -1.\n");
836 exit(1);
837 }
838 oggpackB_readinit(&r,(unsigned char *)"\0\0\0\0\0\0\0\0",8);
839 if(oggpackB_read(&r,30)!=0 || oggpackB_read(&r,16)!=0){
840 fprintf(stderr,"failed 2; got -1 prematurely.\n");
841 exit(1);
842 }
843
844 if(oggpackB_look(&r,18)!=0 ||
845 oggpackB_look(&r,18)!=0){
846 fprintf(stderr,"failed 3; got -1 prematurely.\n");
847 exit(1);
848 }
849 if(oggpackB_look(&r,19)!=-1 ||
850 oggpackB_look(&r,19)!=-1){
851 fprintf(stderr,"failed; read past end without -1.\n");
852 exit(1);
853 }
854 if(oggpackB_look(&r,32)!=-1 ||
855 oggpackB_look(&r,32)!=-1){
856 fprintf(stderr,"failed; read past end without -1.\n");
857 exit(1);
858 }
859 oggpackB_writeclear(&o);
860 fprintf(stderr,"ok.\n\n");
861
862
863 return(0);
864}
865#endif /* _V_SELFTEST */
866
867#undef BUFFER_INCREMENT
diff --git a/lib/rbcodec/codecs/libtremor/block.c b/lib/rbcodec/codecs/libtremor/block.c
new file mode 100644
index 0000000000..b820f1cbc2
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/block.c
@@ -0,0 +1,471 @@
1/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
4 * *
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * *
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
11 * *
12 ********************************************************************
13
14 function: PCM data vector blocking, windowing and dis/reassembly
15
16 ********************************************************************/
17
18#include "config-tremor.h"
19#include <stdio.h>
20#include <string.h>
21#include "ogg.h"
22#include "ivorbiscodec.h"
23#include "codec_internal.h"
24
25#include "window.h"
26#include "registry.h"
27#include "misc.h"
28#include "ffmpeg_stuff.h"
29//#include <codecs/lib/codeclib.h>
30
31static int ilog(unsigned int v){
32 int ret=0;
33 if(v)--v;
34 while(v){
35 ret++;
36 v>>=1;
37 }
38 return(ret);
39}
40
41static ogg_int32_t* _pcmbp[CHANNELS] IBSS_ATTR;
42static ogg_int32_t* _pcmret[CHANNELS] IBSS_ATTR;
43/* save original pointers returned by malloc so we can free it easily */
44static ogg_int32_t* malloc_pointers[3] = {NULL};
45
46/* pcm accumulator examples (not exhaustive):
47
48 <-------------- lW ---------------->
49 <--------------- W ---------------->
50: .....|..... _______________ |
51: .''' | '''_--- | |\ |
52:.....''' |_____--- '''......| | \_______|
53:.................|__________________|_______|__|______|
54 |<------ Sl ------>| > Sr < |endW
55 |beginSl |endSl | |endSr
56 |beginW |endlW |beginSr
57
58
59 |< lW >|
60 <--------------- W ---------------->
61 | | .. ______________ |
62 | | ' `/ | ---_ |
63 |___.'___/`. | ---_____|
64 |_______|__|_______|_________________|
65 | >|Sl|< |<------ Sr ----->|endW
66 | | |endSl |beginSr |endSr
67 |beginW | |endlW
68 mult[0] |beginSl mult[n]
69
70 <-------------- lW ----------------->
71 |<--W-->|
72: .............. ___ | |
73: .''' |`/ \ | |
74:.....''' |/`....\|...|
75:.........................|___|___|___|
76 |Sl |Sr |endW
77 | | |endSr
78 | |beginSr
79 | |endSl
80 |beginSl
81 |beginW
82*/
83
84/* block abstraction setup *********************************************/
85
86#ifndef WORD_ALIGN
87#define WORD_ALIGN 8
88#endif
89
90int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb){
91 memset(vb,0,sizeof(*vb));
92 vb->vd=v;
93 vb->localalloc=0;
94 vb->localstore=NULL;
95
96 return(0);
97}
98
99void *_vorbis_block_alloc(vorbis_block *vb,long bytes){
100 bytes=(bytes+(WORD_ALIGN-1)) & ~(WORD_ALIGN-1);
101 if(bytes+vb->localtop>vb->localalloc){
102 /* can't just _ogg_realloc... there are outstanding pointers */
103 if(vb->localstore){
104 struct alloc_chain *link=(struct alloc_chain *)_ogg_malloc(sizeof(*link));
105 vb->totaluse+=vb->localtop;
106 link->next=vb->reap;
107 link->ptr=vb->localstore;
108 vb->reap=link;
109 }
110 /* highly conservative */
111 vb->localalloc=bytes;
112 vb->localstore=_ogg_malloc(vb->localalloc);
113 vb->localtop=0;
114 }
115 {
116 void *ret=(void *)(((char *)vb->localstore)+vb->localtop);
117 vb->localtop+=bytes;
118 return ret;
119 }
120}
121
122/* reap the chain, pull the ripcord */
123void _vorbis_block_ripcord(vorbis_block *vb){
124 /* reap the chain */
125 struct alloc_chain *reap=vb->reap;
126 while(reap){
127 struct alloc_chain *next=reap->next;
128 _ogg_free(reap->ptr);
129 memset(reap,0,sizeof(*reap));
130 _ogg_free(reap);
131 reap=next;
132 }
133 /* consolidate storage */
134 if(vb->totaluse){
135 vb->localstore=_ogg_realloc(vb->localstore,vb->totaluse+vb->localalloc);
136 vb->localalloc+=vb->totaluse;
137 vb->totaluse=0;
138 }
139
140 /* pull the ripcord */
141 vb->localtop=0;
142 vb->reap=NULL;
143}
144
145int vorbis_block_clear(vorbis_block *vb){
146 _vorbis_block_ripcord(vb);
147 if(vb->localstore)_ogg_free(vb->localstore);
148
149 memset(vb,0,sizeof(*vb));
150 return(0);
151}
152
153static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){
154 int i;
155 long b_size[2];
156
157 codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
158 private_state *b=NULL;
159
160 if(ci==NULL) return 1;
161
162 memset(v,0,sizeof(*v));
163 b=(private_state *)(v->backend_state=_ogg_calloc(1,sizeof(*b)));
164
165 v->vi=vi;
166 b->modebits=ilog(ci->modes);
167
168#ifdef TREMOR_USE_IRAM
169 /* allocate IRAM buffer for the PCM data generated by synthesis */
170 iram_malloc_init();
171
172 v->floors = iram_malloc(vi->channels*ci->blocksizes[1]/2*sizeof(ogg_int32_t));
173 v->residues[0] = iram_malloc(vi->channels*ci->blocksizes[1]/2*sizeof(ogg_int32_t));
174 /* if we can get away with it, put a double buffer into IRAM too, so that
175 overlap-add runs iram-to-iram and we avoid needing to memcpy */
176 v->residues[1] = iram_malloc(vi->channels*ci->blocksizes[1]/2*sizeof(ogg_int32_t));
177 if (v->residues[1] == NULL)
178 v->saved = iram_malloc(vi->channels*ci->blocksizes[1]/4*sizeof(ogg_int32_t));
179
180#endif
181
182 if (v->residues[0] == NULL) {
183 malloc_pointers[0] = _ogg_malloc(vi->channels*ci->blocksizes[1]/2*sizeof(ogg_int32_t));
184 v->residues[0] = malloc_pointers[0];
185 }
186
187 if (v->residues[1] == NULL && v->saved == NULL) {
188 malloc_pointers[1] = _ogg_malloc(vi->channels*ci->blocksizes[1]/2*sizeof(ogg_int32_t));
189 v->residues[1] = malloc_pointers[1];
190 }
191
192 if (v->floors == NULL) {
193 malloc_pointers[2] = _ogg_malloc(vi->channels*ci->blocksizes[1]/2*sizeof(ogg_int32_t));
194 v->floors = malloc_pointers[2];
195 }
196
197 /* needed for the first overlap/add */
198 if (v->saved) {
199 memset(v->saved, 0, vi->channels*ci->blocksizes[1]/4*sizeof(ogg_int32_t));
200 for (i = 0; i < vi->channels; i++)
201 v->saved_ptr[i] = v->saved + i*ci->blocksizes[1]/4;
202 } else {
203 memset(v->residues[1], 0, vi->channels*ci->blocksizes[1]/2*sizeof(ogg_int32_t));
204 for (i = 0; i < vi->channels; i++)
205 v->saved_ptr[i] = v->residues[1] + i*ci->blocksizes[1]/2;
206 }
207
208 /* Vorbis I uses only window type 0 */
209 b_size[0]=ci->blocksizes[0]/2;
210 b_size[1]=ci->blocksizes[1]/2;
211 b->window[0]=_vorbis_window(0,b_size[0]);
212 b->window[1]=_vorbis_window(0,b_size[1]);
213
214#ifdef TREMOR_USE_IRAM
215 /* allocate IRAM buffer for window tables too, if sufficient iram available */
216 /* give preference to the larger window over the smaller window
217 (on the assumption that both windows are equally likely used) */
218 LOOKUP_TNC *iramposw;
219 for(i=1; i>=0; i--){
220 iramposw=iram_malloc(b_size[i]*sizeof(LOOKUP_TNC));
221 if(iramposw!=NULL) {
222 memcpy(iramposw, b->window[i], b_size[i]*sizeof(LOOKUP_TNC));
223 b->window[i]=iramposw;
224 }
225 }
226#endif
227
228 /* finish the codebooks */
229 if(!ci->fullbooks){
230 ci->fullbooks=(codebook *)_ogg_calloc(ci->books,sizeof(*ci->fullbooks));
231 for(i=0;i<ci->books;i++){
232 if(ci->book_param[i]==NULL)
233 goto abort_books;
234 if(vorbis_book_init_decode(ci->fullbooks+i,ci->book_param[i]))
235 goto abort_books;
236 /* decode codebooks are now standalone after init */
237 vorbis_staticbook_destroy(ci->book_param[i]);
238 ci->book_param[i]=NULL;
239 }
240 }
241
242 v->pcm_storage=ci->blocksizes[1];
243 v->pcmret=_pcmret;
244 v->pcmb=_pcmbp;
245
246 _pcmbp[0]=NULL;
247 _pcmbp[1]=NULL;
248
249 /* all 1 (large block) or 0 (small block) */
250 /* explicitly set for the sake of clarity */
251 v->lW=0; /* previous window size */
252 v->W=0; /* current window size */
253
254 /* initialize all the mapping/backend lookups */
255 b->mode=(vorbis_look_mapping **)_ogg_calloc(ci->modes,sizeof(*b->mode));
256 for(i=0;i<ci->modes;i++){
257 int mapnum=ci->mode_param[i]->mapping;
258 int maptype=ci->map_type[mapnum];
259 b->mode[i]=_mapping_P[maptype]->look(v,ci->mode_param[i],
260 ci->map_param[mapnum]);
261 }
262
263 return(0);
264abort_books:
265 for(i=0;i<ci->books;i++){
266 if(ci->book_param[i]!=NULL){
267 vorbis_staticbook_destroy(ci->book_param[i]);
268 ci->book_param[i]=NULL;
269 }
270 }
271 vorbis_dsp_clear(v);
272 return -1;
273}
274
275int vorbis_synthesis_restart(vorbis_dsp_state *v){
276 vorbis_info *vi=v->vi;
277 codec_setup_info *ci;
278
279 if(!v->backend_state)return -1;
280 if(!vi)return -1;
281 ci=vi->codec_setup;
282 if(!ci)return -1;
283
284 v->pcm_current=0;
285
286 v->pcm_returned=-1;
287 v->granulepos=-1;
288 v->sequence=-1;
289 ((private_state *)(v->backend_state))->sample_count=-1;
290
291 return(0);
292}
293
294int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi){
295 if(_vds_init(v,vi))return 1;
296 vorbis_synthesis_restart(v);
297
298 return 0;
299}
300
301void vorbis_dsp_clear(vorbis_dsp_state *v){
302 int i;
303 if(v){
304 vorbis_info *vi=v->vi;
305 codec_setup_info *ci=(codec_setup_info *)(vi?vi->codec_setup:NULL);
306 private_state *b=(private_state *)v->backend_state;
307
308 if(vi != NULL)
309 {
310 /* pcm buffer came from oggmalloc rather than iram */
311 for(i=0;i<3;i++)
312 if(malloc_pointers[i]) {
313 _ogg_free(malloc_pointers[i]);
314 malloc_pointers[i] = NULL;
315 }
316 }
317
318 /* free mode lookups; these are actually vorbis_look_mapping structs */
319 if(ci){
320 for(i=0;i<ci->modes;i++){
321 int mapnum=ci->mode_param[i]->mapping;
322 int maptype=ci->map_type[mapnum];
323 if(b && b->mode)_mapping_P[maptype]->free_look(b->mode[i]);
324 }
325 }
326
327 if(b){
328 if(b->mode)_ogg_free(b->mode);
329 _ogg_free(b);
330 }
331
332 memset(v,0,sizeof(*v));
333 }
334}
335
336/* Unlike in analysis, the window is only partially applied for each
337 block. The time domain envelope is not yet handled at the point of
338 calling (as it relies on the previous block). */
339
340int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb)
341 ICODE_ATTR;
342int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){
343 vorbis_info *vi=v->vi;
344 codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
345 private_state *b=v->backend_state;
346
347 if(v->pcm_current>v->pcm_returned && v->pcm_returned!=-1)return(OV_EINVAL);
348
349 v->lW=v->W;
350 v->W=vb->W;
351 v->nW=-1;
352
353 if((v->sequence==-1)||
354 (v->sequence+1 != vb->sequence)){
355 v->granulepos=-1; /* out of sequence; lose count */
356 b->sample_count=-1;
357 }
358
359 v->sequence=vb->sequence;
360 int n=ci->blocksizes[v->W]/2;
361 int ln=ci->blocksizes[v->lW]/2;
362
363 if(LIKELY(vb->pcmend != 0)){ /* no pcm to process if vorbis_synthesis_trackonly
364 was called on block */
365 window_overlap_add(ci->blocksizes[v->W], ci->blocksizes[v->lW],
366 ci->blocksizes[0], ci->blocksizes[1], vi->channels,
367 b->window[v->W & v->lW], v);
368 /* deal with initial packet state; we do this using the explicit
369 pcm_returned==-1 flag otherwise we're sensitive to first block
370 being short or long */
371
372 if(v->pcm_returned==-1){
373 v->pcm_returned=0;
374 v->pcm_current=0;
375 }else{
376 v->pcm_returned=0;
377 v->pcm_current=(n+ln)/2;
378 }
379 }
380
381 /* track the frame number... This is for convenience, but also
382 making sure our last packet doesn't end with added padding. If
383 the last packet is partial, the number of samples we'll have to
384 return will be past the vb->granulepos.
385
386 This is not foolproof! It will be confused if we begin
387 decoding at the last page after a seek or hole. In that case,
388 we don't have a starting point to judge where the last frame
389 is. For this reason, vorbisfile will always try to make sure
390 it reads the last two marked pages in proper sequence */
391
392 if(b->sample_count==-1){
393 b->sample_count=0;
394 }else{
395 b->sample_count+=(n+ln)/2;
396 }
397
398 if(v->granulepos==-1){
399 if(vb->granulepos!=-1){ /* only set if we have a position to set to */
400
401 v->granulepos=vb->granulepos;
402
403 /* is this a short page? */
404 if(b->sample_count>v->granulepos){
405 /* corner case; if this is both the first and last audio page,
406 then spec says the end is cut, not beginning */
407 if(vb->eofflag){
408 /* trim the end */
409 /* no preceeding granulepos; assume we started at zero (we'd
410 have to in a short single-page stream) */
411 /* granulepos could be -1 due to a seek, but that would result
412 in a long coun`t, not short count */
413
414 v->pcm_current-=(b->sample_count-v->granulepos);
415 }else{
416 /* trim the beginning */
417 v->pcm_returned+=(b->sample_count-v->granulepos);
418 if(v->pcm_returned>v->pcm_current)
419 v->pcm_returned=v->pcm_current;
420 }
421
422 }
423
424 }
425 }else{
426 v->granulepos+=(n+ln)/2;
427 if(vb->granulepos!=-1 && v->granulepos!=vb->granulepos){
428
429 if(v->granulepos>vb->granulepos){
430 long extra=v->granulepos-vb->granulepos;
431
432 if(extra)
433 if(vb->eofflag){
434 /* partial last frame. Strip the extra samples off */
435 v->pcm_current-=extra;
436 } /* else {Shouldn't happen *unless* the bitstream is out of
437 spec. Either way, believe the bitstream } */
438 } /* else {Shouldn't happen *unless* the bitstream is out of
439 spec. Either way, believe the bitstream } */
440 v->granulepos=vb->granulepos;
441 }
442 }
443
444 /* Update, cleanup */
445
446 if(vb->eofflag)v->eofflag=1;
447 return(0);
448}
449
450/* pcm==NULL indicates we just want the pending samples, no more */
451int vorbis_synthesis_pcmout(vorbis_dsp_state *v,ogg_int32_t ***pcm) ICODE_ATTR;
452int vorbis_synthesis_pcmout(vorbis_dsp_state *v,ogg_int32_t ***pcm){
453 vorbis_info *vi=v->vi;
454 if(v->pcm_returned>-1 && v->pcm_returned<v->pcm_current){
455 if(pcm){
456 int i;
457 for(i=0;i<vi->channels;i++)
458 v->pcmret[i]=v->pcmb[i]+v->pcm_returned;
459 *pcm=v->pcmret;
460 }
461 return(v->pcm_current-v->pcm_returned);
462 }
463 return 0;
464}
465
466int vorbis_synthesis_read(vorbis_dsp_state *v,int bytes){
467 if(bytes && v->pcm_returned+bytes>v->pcm_current)return(OV_EINVAL);
468 v->pcm_returned+=bytes;
469 return(0);
470}
471
diff --git a/lib/rbcodec/codecs/libtremor/codebook.c b/lib/rbcodec/codecs/libtremor/codebook.c
new file mode 100644
index 0000000000..7087f0a323
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/codebook.c
@@ -0,0 +1,587 @@
1/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
4 * *
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * *
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
11 * *
12 ********************************************************************
13
14 function: basic codebook pack/unpack/code/decode operations
15
16 ********************************************************************/
17
18#include "config-tremor.h"
19#include <string.h>
20#include <math.h>
21#include "ogg.h"
22#include "ivorbiscodec.h"
23#include "codebook.h"
24#include "misc.h"
25#include "os.h"
26
27/* unpacks a codebook from the packet buffer into the codebook struct,
28 readies the codebook auxiliary structures for decode *************/
29static_codebook *vorbis_staticbook_unpack(oggpack_buffer *opb){
30 long i,j;
31 static_codebook *s=_ogg_calloc(1,sizeof(*s));
32
33 /* make sure alignment is correct */
34 if(oggpack_read(opb,24)!=0x564342)goto _eofout;
35
36 /* first the basic parameters */
37 s->dim=oggpack_read(opb,16);
38 s->entries=oggpack_read(opb,24);
39 if(s->entries==-1)goto _eofout;
40
41 if(_ilog(s->dim)+_ilog(s->entries)>24)goto _eofout;
42
43 /* codeword ordering.... length ordered or unordered? */
44 switch((int)oggpack_read(opb,1)){
45 case 0:{
46 long unused;
47 /* allocated but unused entries? */
48 unused=oggpack_read(opb,1);
49 if((s->entries*(unused?1:5)+7)>>3>opb->storage-oggpack_bytes(opb))
50 goto _eofout;
51 /* unordered */
52 s->lengthlist=(long *)_ogg_malloc(sizeof(*s->lengthlist)*s->entries);
53
54 /* allocated but unused entries? */
55 if(unused){
56 /* yes, unused entries */
57
58 for(i=0;i<s->entries;i++){
59 if(oggpack_read(opb,1)){
60 long num=oggpack_read(opb,5);
61 if(num==-1)goto _eofout;
62 s->lengthlist[i]=num+1;
63 }else
64 s->lengthlist[i]=0;
65 }
66 }else{
67 /* all entries used; no tagging */
68 for(i=0;i<s->entries;i++){
69 long num=oggpack_read(opb,5);
70 if(num==-1)goto _eofout;
71 s->lengthlist[i]=num+1;
72 }
73 }
74
75 break;
76 }
77 case 1:
78 /* ordered */
79 {
80 long length=oggpack_read(opb,5)+1;
81 if(length==0)goto _eofout;
82 s->lengthlist=(long *)_ogg_malloc(sizeof(*s->lengthlist)*s->entries);
83
84 for(i=0;i<s->entries;){
85 long num=oggpack_read(opb,_ilog(s->entries-i));
86 if(num==-1)goto _eofout;
87 if(length>32 || num>s->entries-i ||
88 (num>0 && (num-1)>>(length>>1)>>((length+1)>>1))>0){
89 goto _errout;
90 }
91 for(j=0;j<num;j++,i++)
92 s->lengthlist[i]=length;
93 length++;
94 }
95 }
96 break;
97 default:
98 /* EOF */
99 goto _eofout;
100 }
101
102 /* Do we have a mapping to unpack? */
103 switch((s->maptype=oggpack_read(opb,4))){
104 case 0:
105 /* no mapping */
106 break;
107 case 1: case 2:
108 /* implicitly populated value mapping */
109 /* explicitly populated value mapping */
110
111 s->q_min=oggpack_read(opb,32);
112 s->q_delta=oggpack_read(opb,32);
113 s->q_quant=oggpack_read(opb,4)+1;
114 s->q_sequencep=oggpack_read(opb,1);
115 if(s->q_sequencep==-1)goto _eofout;
116
117 {
118 int quantvals=0;
119 switch(s->maptype){
120 case 1:
121 quantvals=(s->dim==0?0:_book_maptype1_quantvals(s));
122 break;
123 case 2:
124 quantvals=s->entries*s->dim;
125 break;
126 }
127
128 /* quantized values */
129 if((quantvals*s->q_quant+7)>>3>opb->storage-oggpack_bytes(opb))
130 goto _eofout;
131 s->quantlist=(long *)_ogg_malloc(sizeof(*s->quantlist)*quantvals);
132 for(i=0;i<quantvals;i++)
133 s->quantlist[i]=oggpack_read(opb,s->q_quant);
134
135 if(quantvals&&s->quantlist[quantvals-1]==-1)goto _eofout;
136 }
137 break;
138 default:
139 goto _errout;
140 }
141
142 /* all set */
143 return(s);
144
145 _errout:
146 _eofout:
147 vorbis_staticbook_destroy(s);
148 return(NULL);
149}
150
151/* the 'eliminate the decode tree' optimization actually requires the
152 codewords to be MSb first, not LSb. This is an annoying inelegancy
153 (and one of the first places where carefully thought out design
154 turned out to be wrong; Vorbis II and future Ogg codecs should go
155 to an MSb bitpacker), but not actually the huge hit it appears to
156 be. The first-stage decode table catches most words so that
157 bitreverse is not in the main execution path. */
158
159static inline ogg_uint32_t bitreverse(register ogg_uint32_t x)
160{
161 unsigned tmp, ret;
162#ifdef _ARM_ASSEM_
163#if ARM_ARCH >= 6
164 unsigned mask = 0x0f0f0f0f;
165#else
166 unsigned mask = 0x00ff00ff;
167#endif
168 asm (
169#if ARM_ARCH >= 6
170 "rev %[r], %[x] \n" /* swap halfwords and bytes */
171 "and %[t], %[m], %[r] \n" /* Sequence is one instruction */
172 "eor %[r], %[t], %[r] \n" /* longer than on <= ARMv5, but */
173 "mov %[t], %[t], lsl #4 \n" /* interlock free */
174 "orr %[r], %[t], %[r], lsr #4\n" /* nibbles swapped */
175 "eor %[m], %[m], %[m], lsl #2\n" /* mask = 0x33333333 */
176 "and %[t], %[m], %[r] \n"
177 "eor %[r], %[t], %[r] \n"
178 "mov %[t], %[t], lsl #2 \n"
179 "orr %[r], %[t], %[r], lsr #2\n" /* dibits swapped */
180 "eor %[m], %[m], %[m], lsl #1\n" /* mask = 0x55555555 */
181 "and %[t], %[m], %[r] \n"
182 "eor %[r], %[t], %[r] \n"
183 "mov %[t], %[t], lsl #1 \n"
184 "orr %[r], %[t], %[r], lsr #1\n" /* bits swapped */
185#else /* ARM_ARCH <= 5 */
186 "mov %[r], %[x], ror #16 \n" /* swap halfwords */
187 "and %[t], %[m], %[r], lsr #8\n"
188 "eor %[r], %[r], %[t], lsl #8\n"
189 "orr %[r], %[t], %[r], lsl #8\n" /* bytes swapped */
190 "eor %[m], %[m], %[m], lsl #4\n" /* mask = 0x0f0f0f0f */
191 "and %[t], %[m], %[r], lsr #4\n"
192 "eor %[r], %[r], %[t], lsl #4\n"
193 "orr %[r], %[t], %[r], lsl #4\n" /* nibbles swapped */
194 "eor %[m], %[m], %[m], lsl #2\n" /* mask = 0x33333333 */
195 "and %[t], %[m], %[r], lsr #2\n"
196 "eor %[r], %[r], %[t], lsl #2\n"
197 "orr %[r], %[t], %[r], lsl #2\n" /* dibits swapped */
198 "eor %[m], %[m], %[m], lsl #1\n" /* mask = 0x55555555 */
199 "and %[t], %[m], %[r], lsr #1\n"
200 "eor %[r], %[r], %[t], lsl #1\n"
201 "orr %[r], %[t], %[r], lsl #1\n" /* bits swapped */
202#endif /* ARM_ARCH */
203 : /* outputs */
204 [m]"+r"(mask),
205 [r]"=r"(ret),
206 [t]"=r"(tmp)
207 : /* inputs */
208 [x]"r"(x)
209 );
210#else /* !_ARM_ASSEM_ */
211
212 ret = (x>>16) | (x<<16);
213 tmp = ret & 0x00ff00ff;
214 ret ^= tmp;
215 ret = (ret >> 8) | (tmp << 8); /* bytes swapped */
216 tmp = ret & 0x0f0f0f0f;
217 ret ^= tmp;
218 ret = (ret >> 4) | (tmp << 4); /* 4-bit units swapped */
219 tmp = ret & 0x33333333;
220 ret ^= tmp;
221 ret = (ret >> 2) | (tmp << 2); /* 2-bit units swapped */
222 tmp = ret & 0x55555555;
223 ret ^= tmp;
224 ret = (ret >> 1) | (tmp << 1); /* done */
225#endif /* !_ARM_ASSEM_ */
226 return ret;
227}
228
229static inline long bisect_codelist(long lo, long hi, ogg_uint32_t cache,
230 const ogg_uint32_t *codelist)
231{
232 ogg_uint32_t testword=bitreverse(cache);
233 long p;
234 while(LIKELY(p = (hi-lo) >> 1) > 0){
235 if(codelist[lo+p] > testword)
236 hi -= p;
237 else
238 lo += p;
239 }
240 return lo;
241}
242
243STIN long decode_packed_entry_number(codebook *book,
244 oggpack_buffer *b){
245 int read=book->dec_maxlength;
246 long lo,hi;
247 long lok = oggpack_look(b,book->dec_firsttablen);
248
249 if (LIKELY(lok >= 0)) {
250 ogg_int32_t entry = book->dec_firsttable[lok];
251 if(UNLIKELY(entry < 0)){
252 lo=(entry>>15)&0x7fff;
253 hi=book->used_entries-(entry&0x7fff);
254 }else{
255 oggpack_adv(b, book->dec_codelengths[entry-1]);
256 return(entry-1);
257 }
258 }else{
259 lo=0;
260 hi=book->used_entries;
261 }
262
263 lok = oggpack_look(b, read);
264
265 while(lok<0 && read>1)
266 lok = oggpack_look(b, --read);
267
268 if(lok<0){
269 oggpack_adv(b,1); /* force eop */
270 return -1;
271 }
272
273 /* bisect search for the codeword in the ordered list */
274 {
275 lo = bisect_codelist(lo, hi, lok, book->codelist);
276
277 if(book->dec_codelengths[lo]<=read){
278 oggpack_adv(b, book->dec_codelengths[lo]);
279 return(lo);
280 }
281 }
282
283 oggpack_adv(b, read+1);
284 return(-1);
285}
286
287static long decode_packed_block(codebook *book, oggpack_buffer *b,
288 long *buf, int n){
289 long *bufptr = buf;
290 long *bufend = buf + n;
291
292 while (bufptr<bufend) {
293 if(b->endbyte < b->storage - 8) {
294 ogg_uint32_t *ptr;
295 unsigned long bit, bitend;
296 unsigned long adr;
297 ogg_uint32_t cache = 0;
298 int cachesize = 0;
299 const unsigned int cachemask = (1<<book->dec_firsttablen)-1;
300 const int book_dec_maxlength = book->dec_maxlength;
301 const ogg_uint32_t *book_dec_firsttable = book->dec_firsttable;
302 const long book_used_entries = book->used_entries;
303 const ogg_uint32_t *book_codelist = book->codelist;
304 const char *book_dec_codelengths = book->dec_codelengths;
305
306 adr = (unsigned long)b->ptr;
307 bit = (adr&3)*8+b->endbit;
308 ptr = (ogg_uint32_t*)(adr&~3);
309 bitend = ((adr&3)+(b->storage-b->endbyte))*8;
310 while (bufptr<bufend){
311 if (UNLIKELY(cachesize<book_dec_maxlength)) {
312 if (bit-cachesize+32>=bitend)
313 break;
314 bit-=cachesize;
315 cache = letoh32(ptr[bit>>5]);
316 if (bit&31) {
317 cache >>= (bit&31);
318 cache |= letoh32(ptr[(bit>>5)+1]) << (32-(bit&31));
319 }
320 cachesize=32;
321 bit+=32;
322 }
323
324 ogg_int32_t entry = book_dec_firsttable[cache&cachemask];
325 if(UNLIKELY(entry < 0)){
326 const long lo = (entry>>15)&0x7fff, hi = book_used_entries-(entry&0x7fff);
327 entry = bisect_codelist(lo, hi, cache, book_codelist);
328 }else
329 entry--;
330
331 *bufptr++ = entry;
332 int l = book_dec_codelengths[entry];
333 cachesize -= l;
334 cache >>= l;
335 }
336
337 adr=(unsigned long)b->ptr;
338 bit-=(adr&3)*8+cachesize;
339 b->endbyte+=bit/8;
340 b->ptr+=bit/8;
341 b->endbit=bit&7;
342 } else {
343 long r = decode_packed_entry_number(book, b);
344 if (r == -1) return bufptr-buf;
345 *bufptr++ = r;
346 }
347 }
348 return n;
349}
350
351/* Decode side is specced and easier, because we don't need to find
352 matches using different criteria; we simply read and map. There are
353 two things we need to do 'depending':
354
355 We may need to support interleave. We don't really, but it's
356 convenient to do it here rather than rebuild the vector later.
357
358 Cascades may be additive or multiplicitive; this is not inherent in
359 the codebook, but set in the code using the codebook. Like
360 interleaving, it's easiest to do it here.
361 addmul==0 -> declarative (set the value)
362 addmul==1 -> additive
363 addmul==2 -> multiplicitive */
364
365/* returns the [original, not compacted] entry number or -1 on eof *********/
366long vorbis_book_decode(codebook *book, oggpack_buffer *b){
367 if(book->used_entries>0){
368 long packed_entry=decode_packed_entry_number(book,b);
369 if(packed_entry>=0)
370 return(book->dec_index[packed_entry]);
371 }
372
373 /* if there's no dec_index, the codebook unpacking isn't collapsed */
374 return(-1);
375}
376
377/* returns 0 on OK or -1 on eof *************************************/
378/* decode vector / dim granularity gaurding is done in the upper layer */
379long vorbis_book_decodevs_add(codebook *book,ogg_int32_t *a,
380 oggpack_buffer *b,int n,int point){
381 if(book->used_entries>0){
382 int step=n/book->dim;
383 long *entry = (long *)alloca(sizeof(*entry)*step);
384 ogg_int32_t **t = (ogg_int32_t **)alloca(sizeof(*t)*step);
385 int i,j,o;
386 int shift=point-book->binarypoint;
387
388 if(shift>=0){
389 for (i = 0; i < step; i++) {
390 entry[i]=decode_packed_entry_number(book,b);
391 if(entry[i]==-1)return(-1);
392 t[i] = book->valuelist+entry[i]*book->dim;
393 }
394 for(i=0,o=0;i<book->dim;i++,o+=step)
395 for (j=0;j<step;j++)
396 a[o+j]+=t[j][i]>>shift;
397 }else{
398 for (i = 0; i < step; i++) {
399 entry[i]=decode_packed_entry_number(book,b);
400 if(entry[i]==-1)return(-1);
401 t[i] = book->valuelist+entry[i]*book->dim;
402 }
403 for(i=0,o=0;i<book->dim;i++,o+=step)
404 for (j=0;j<step;j++)
405 a[o+j]+=t[j][i]<<-shift;
406 }
407 }
408 return(0);
409}
410
411/* decode vector / dim granularity gaurding is done in the upper layer */
412long vorbis_book_decodev_add(codebook *book,ogg_int32_t *a,
413 oggpack_buffer *b,int n,int point){
414 if(book->used_entries>0){
415 int i,j,entry;
416 ogg_int32_t *t;
417 int shift=point-book->binarypoint;
418
419 if(shift>=0){
420 for(i=0;i<n;){
421 entry = decode_packed_entry_number(book,b);
422 if(entry==-1)return(-1);
423 t = book->valuelist+entry*book->dim;
424 for (j=0;j<book->dim;)
425 a[i++]+=t[j++]>>shift;
426 }
427 }else{
428 shift = -shift;
429 for(i=0;i<n;){
430 entry = decode_packed_entry_number(book,b);
431 if(entry==-1)return(-1);
432 t = book->valuelist+entry*book->dim;
433 for (j=0;j<book->dim;)
434 a[i++]+=t[j++]<<shift;
435 }
436 }
437 }
438 return(0);
439}
440
441/* unlike the others, we guard against n not being an integer number
442 of <dim> internally rather than in the upper layer (called only by
443 floor0) */
444long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a,
445 oggpack_buffer *b,int n,int point){
446 if(book->used_entries>0){
447 int i,j,entry;
448 ogg_int32_t *t;
449 int shift=point-book->binarypoint;
450
451 if(shift>=0){
452
453 for(i=0;i<n;){
454 entry = decode_packed_entry_number(book,b);
455 if(entry==-1)return(-1);
456 t = book->valuelist+entry*book->dim;
457 for (j=0;i<n && j<book->dim;){
458 a[i++]=t[j++]>>shift;
459 }
460 }
461 }else{
462 shift = -shift;
463 for(i=0;i<n;){
464 entry = decode_packed_entry_number(book,b);
465 if(entry==-1)return(-1);
466 t = book->valuelist+entry*book->dim;
467 for (j=0;i<n && j<book->dim;){
468 a[i++]=t[j++]<<shift;
469 }
470 }
471 }
472 }else{
473
474 int i;
475 for(i=0;i<n;){
476 a[i++]=0;
477 }
478 }
479 return(0);
480}
481
482/* decode vector / dim granularity gaurding is done in the upper layer */
483static long vorbis_book_decodevv_add_2ch_even(codebook *book,ogg_int32_t **a,
484 long offset,oggpack_buffer *b,
485 unsigned int n,int point){
486 long k,chunk,read;
487 int shift=point-book->binarypoint;
488 long entries[32];
489 ogg_int32_t *p0 = &(a[0][offset]);
490 ogg_int32_t *p1 = &(a[1][offset]);
491 const unsigned long dim = book->dim;
492 const ogg_int32_t * const vlist = book->valuelist;
493
494 if(shift>=0){
495 while(n>0){
496 chunk=32;
497 if (16*dim>n)
498 chunk=(n*2-1)/dim + 1;
499 read = decode_packed_block(book,b,entries,chunk);
500 for(k=0;k<read;k++){
501 const ogg_int32_t *t = vlist+entries[k]*dim;
502 const ogg_int32_t *u = t+dim;
503 do{
504 *p0++ += *t++>>shift;
505 *p1++ += *t++>>shift;
506 }while(t<u);
507 }
508 if (read<chunk)return-1;
509 n -= read*dim/2;
510 }
511 }else{
512 shift = -shift;
513 while(n>0){
514 chunk=32;
515 if (16*dim>n)
516 chunk=(n*2-1)/dim + 1;
517 read = decode_packed_block(book,b,entries,chunk);
518 for(k=0;k<read;k++){
519 const ogg_int32_t *t = vlist+entries[k]*dim;
520 const ogg_int32_t *u = t+dim;
521 do{
522 *p0++ += *t++<<shift;
523 *p1++ += *t++<<shift;
524 }while(t<u);
525 }
526 if (read<chunk)return-1;
527 n -= read*dim/2;
528 }
529 }
530 return(0);
531}
532
533long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a,
534 long offset,int ch,
535 oggpack_buffer *b,int n,int point){
536 if(LIKELY(book->used_entries>0)){
537 long i,j,k,chunk,read;
538 int chptr=0;
539 int shift=point-book->binarypoint;
540 long entries[32];
541
542 if (!(book->dim&1) && ch==2)
543 return vorbis_book_decodevv_add_2ch_even(book,a,offset,b,n,point);
544
545 if(shift>=0){
546
547 for(i=offset;i<offset+n;){
548 chunk=32;
549 if (chunk*book->dim>(offset+n-i)*ch)
550 chunk=((offset+n-i)*ch+book->dim-1)/book->dim;
551 read = decode_packed_block(book,b,entries,chunk);
552 for(k=0;k<read;k++){
553 const ogg_int32_t *t = book->valuelist+entries[k]*book->dim;
554 for (j=0;j<book->dim;j++){
555 a[chptr++][i]+=t[j]>>shift;
556 if(chptr==ch){
557 chptr=0;
558 i++;
559 }
560 }
561 }
562 if (read<chunk)return-1;
563 }
564 }else{
565 shift = -shift;
566 for(i=offset;i<offset+n;){
567 chunk=32;
568 if (chunk*book->dim>(offset+n-i)*ch)
569 chunk=((offset+n-i)*ch+book->dim-1)/book->dim;
570 read = decode_packed_block(book,b,entries,chunk);
571 for(k=0;k<read;k++){
572 const ogg_int32_t *t = book->valuelist+entries[k]*book->dim;
573 for (j=0;j<book->dim;j++){
574 a[chptr++][i]+=t[j]<<shift;
575 if(chptr==ch){
576 chptr=0;
577 i++;
578 }
579 }
580 }
581 if (read<chunk)return-1;
582 }
583 }
584 }
585 return(0);
586}
587
diff --git a/lib/rbcodec/codecs/libtremor/codebook.h b/lib/rbcodec/codecs/libtremor/codebook.h
new file mode 100644
index 0000000000..29ac9fd923
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/codebook.h
@@ -0,0 +1,101 @@
1/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
4 * *
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * *
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
11 * *
12 ********************************************************************
13
14 function: basic shared codebook operations
15
16 ********************************************************************/
17
18#ifndef _V_CODEBOOK_H_
19#define _V_CODEBOOK_H_
20
21#include "ogg.h"
22
23/* This structure encapsulates huffman and VQ style encoding books; it
24 doesn't do anything specific to either.
25
26 valuelist/quantlist are nonNULL (and q_* significant) only if
27 there's entry->value mapping to be done.
28
29 If encode-side mapping must be done (and thus the entry needs to be
30 hunted), the auxiliary encode pointer will point to a decision
31 tree. This is true of both VQ and huffman, but is mostly useful
32 with VQ.
33
34*/
35
36typedef struct static_codebook{
37 long dim; /* codebook dimensions (elements per vector) */
38 long entries; /* codebook entries */
39 long *lengthlist; /* codeword lengths in bits */
40
41 /* mapping ***************************************************************/
42 int maptype; /* 0=none
43 1=implicitly populated values from map column
44 2=listed arbitrary values */
45
46 /* The below does a linear, single monotonic sequence mapping. */
47 long q_min; /* packed 32 bit float; quant value 0 maps to minval */
48 long q_delta; /* packed 32 bit float; val 1 - val 0 == delta */
49 int q_quant; /* bits: 0 < quant <= 16 */
50 int q_sequencep; /* bitflag */
51
52 long *quantlist; /* map == 1: (int)(entries^(1/dim)) element column map
53 map == 2: list of dim*entries quantized entry vals
54 */
55} static_codebook;
56
57typedef struct codebook{
58 long dim; /* codebook dimensions (elements per vector) */
59 long entries; /* codebook entries */
60 long used_entries; /* populated codebook entries */
61
62 /* the below are ordered by bitreversed codeword and only used
63 entries are populated */
64 int binarypoint;
65 ogg_int32_t *valuelist; /* list of dim*entries actual entry values */
66 ogg_uint32_t *codelist; /* list of bitstream codewords for each entry */
67
68 int *dec_index;
69 char *dec_codelengths;
70 ogg_uint32_t *dec_firsttable;
71 int dec_firsttablen;
72 int dec_maxlength;
73
74 long q_min; /* packed 32 bit float; quant value 0 maps to minval */
75 long q_delta; /* packed 32 bit float; val 1 - val 0 == delta */
76
77} codebook;
78
79extern void vorbis_staticbook_destroy(static_codebook *b);
80extern int vorbis_book_init_decode(codebook *dest,const static_codebook *source);
81
82extern void vorbis_book_clear(codebook *b);
83extern long _book_maptype1_quantvals(const static_codebook *b);
84
85extern static_codebook *vorbis_staticbook_unpack(oggpack_buffer *b);
86
87extern long vorbis_book_decode(codebook *book, oggpack_buffer *b);
88extern long vorbis_book_decodevs_add(codebook *book, ogg_int32_t *a,
89 oggpack_buffer *b,int n,int point);
90extern long vorbis_book_decodev_set(codebook *book, ogg_int32_t *a,
91 oggpack_buffer *b,int n,int point);
92extern long vorbis_book_decodev_add(codebook *book, ogg_int32_t *a,
93 oggpack_buffer *b,int n,int point);
94extern long vorbis_book_decodevv_add(codebook *book, ogg_int32_t **a,
95 long off,int ch,
96 oggpack_buffer *b,int n,int point);
97
98extern int _ilog(unsigned int v);
99
100
101#endif
diff --git a/lib/rbcodec/codecs/libtremor/codec_internal.h b/lib/rbcodec/codecs/libtremor/codec_internal.h
new file mode 100644
index 0000000000..3cbd7cde89
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/codec_internal.h
@@ -0,0 +1,93 @@
1/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
4 * *
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * *
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
11 * *
12 ********************************************************************
13
14 function: libvorbis codec headers
15
16 ********************************************************************/
17
18#ifndef _V_CODECI_H_
19#define _V_CODECI_H_
20
21#include "codebook.h"
22
23typedef void vorbis_look_mapping;
24typedef void vorbis_look_floor;
25typedef void vorbis_look_residue;
26typedef void vorbis_look_transform;
27
28/* mode ************************************************************/
29typedef struct {
30 int blockflag;
31 int windowtype;
32 int transformtype;
33 int mapping;
34} vorbis_info_mode;
35
36typedef void vorbis_info_floor;
37typedef void vorbis_info_residue;
38typedef void vorbis_info_mapping;
39
40typedef struct private_state {
41 /* local lookup storage */
42 const void *window[2];
43
44 /* backend lookups are tied to the mode, not the backend or naked mapping */
45 int modebits;
46 vorbis_look_mapping **mode;
47
48 ogg_int64_t sample_count;
49
50} private_state;
51
52/* codec_setup_info contains all the setup information specific to the
53 specific compression/decompression mode in progress (eg,
54 psychoacoustic settings, channel setup, options, codebook
55 etc).
56*********************************************************************/
57
58typedef struct codec_setup_info {
59
60 /* Vorbis supports only short and long blocks, but allows the
61 encoder to choose the sizes */
62
63 int blocksizes_nbits[2];
64 long blocksizes[2]; /* = 1<<nbits */
65
66 /* modes are the primary means of supporting on-the-fly different
67 blocksizes, different channel mappings (LR or M/A),
68 different residue backends, etc. Each mode consists of a
69 blocksize flag and a mapping (along with the mapping setup */
70
71 int modes;
72 int maps;
73 int times;
74 int floors;
75 int residues;
76 int books;
77
78 vorbis_info_mode *mode_param[64];
79 int map_type[64];
80 vorbis_info_mapping *map_param[64];
81 int time_type[64];
82 int floor_type[64];
83 vorbis_info_floor *floor_param[64];
84 int residue_type[64];
85 vorbis_info_residue *residue_param[64];
86 static_codebook *book_param[256];
87 codebook *fullbooks;
88
89 int passlimit[32]; /* iteration limit per couple/quant pass */
90 int coupling_passes;
91} codec_setup_info;
92
93#endif
diff --git a/lib/rbcodec/codecs/libtremor/config-tremor.h b/lib/rbcodec/codecs/libtremor/config-tremor.h
new file mode 100644
index 0000000000..cf2dbe977d
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/config-tremor.h
@@ -0,0 +1,55 @@
1#ifndef _CONFIG_TREMOR_H
2#define _CONFIG_TREMOR_H
3
4#include "codeclib.h"
5
6#ifdef CPU_ARM
7#define _ARM_ASSEM_
8#endif
9
10#ifndef BYTE_ORDER
11#ifdef ROCKBOX_BIG_ENDIAN
12#define BIG_ENDIAN 1
13#define LITTLE_ENDIAN 0
14#define BYTE_ORDER BIG_ENDIAN
15#else
16#define BYTE_ORDER LITTLE_ENDIAN
17#define LITTLE_ENDIAN 1
18#define BIG_ENDIAN 0
19#endif
20#endif
21
22#ifndef ICODE_ATTR_TREMOR_NOT_MDCT
23#define ICODE_ATTR_TREMOR_NOT_MDCT ICODE_ATTR
24#endif
25
26/* Enable special handling of buffers in faster ram, not usefull when no
27 such different ram is available. There are 3 different memory configurations
28 * No special iram, uses double buffers to avoid copying data
29 * Small special iram, copies buffers to run hottest processing in iram
30 * Large iram, uses double buffers in iram */
31#ifdef USE_IRAM
32#define TREMOR_USE_IRAM
33
34/* Define CPU of large IRAM (PP5022/5024, MCF5250) */
35#if (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) || defined(CPU_S5L870X) || (CONFIG_CPU == MCF5250)
36/* PCM_BUFFER : 32768 byte (4096*2*4 or 2048*4*4) *
37 * WINDOW_LOOKUP : 9216 Byte (256*4 + 2048*4) *
38 * TOTAL : 41984 */
39#define IRAM_IBSS_SIZE 41984
40
41/* Define CPU of Normal IRAM (96KB) */
42#else
43/* floor and double residue buffer : 24576 Byte (2048/2*4*2*3) *
44 * WINDOW_LOOKUP : 4608 Byte (128*4 + 1024*4) *
45 * TOTAL : 29184 */
46#define IRAM_IBSS_SIZE 29184
47#endif
48#endif
49
50/* max 2 channels */
51#define CHANNELS 2
52
53// #define _LOW_ACCURACY_
54
55#endif /* _CONFIG_TREMOR_H */
diff --git a/lib/rbcodec/codecs/libtremor/config_types.h b/lib/rbcodec/codecs/libtremor/config_types.h
new file mode 100644
index 0000000000..1fdcb27fe7
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/config_types.h
@@ -0,0 +1,25 @@
1/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
4 * *
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * *
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
11 * *
12 ********************************************************************
13
14 function: #ifdef jail to whip a few platforms into the UNIX ideal.
15
16 ********************************************************************/
17#ifndef _OS_CVTYPES_H
18#define _OS_CVTYPES_H
19
20typedef long long ogg_int64_t;
21typedef int ogg_int32_t;
22typedef unsigned int ogg_uint32_t;
23typedef short ogg_int16_t;
24
25#endif
diff --git a/lib/rbcodec/codecs/libtremor/ctype.c b/lib/rbcodec/codecs/libtremor/ctype.c
new file mode 100644
index 0000000000..9f22047675
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/ctype.c
@@ -0,0 +1,4 @@
1#include "config.h"
2#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
3#include "libc/ctype.c"
4#endif
diff --git a/lib/rbcodec/codecs/libtremor/ffmpeg_stuff.h b/lib/rbcodec/codecs/libtremor/ffmpeg_stuff.h
new file mode 100644
index 0000000000..d7fa846507
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/ffmpeg_stuff.h
@@ -0,0 +1,140 @@
1/**
2 * @file
3 * Common code for Vorbis I encoder and decoder
4 * @author Denes Balatoni ( dbalatoni programozo hu )
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23/* render_line and friend taken from ffmpeg (libavcodec/vorbis.c) */
24
25#include "misc.h"
26
27static inline void render_line_unrolled(int x, int y, int x1,
28 int sy, int ady, int adx,
29 const ogg_int32_t *lookup, ogg_int32_t *buf)
30{
31 int err = -adx;
32 x -= x1 - 1;
33 buf += x1 - 1;
34 while (++x < 0) {
35 err += ady;
36 if (err >= 0) {
37 err += ady - adx;
38 y += sy;
39 buf[x] = MULT31_SHIFT15(buf[x],lookup[y]);
40 x++;
41 }
42 buf[x] = MULT31_SHIFT15(buf[x],lookup[y]);
43 }
44 if (x <= 0) {
45 if (err + ady >= 0)
46 y += sy;
47 buf[x] = MULT31_SHIFT15(buf[x],lookup[y]);
48 }
49}
50
51static inline void render_line(int x0, int y0, int x1, int y1,
52 const ogg_int32_t *lookup, ogg_int32_t *buf)
53{
54 int dy = y1 - y0;
55 int adx = x1 - x0;
56 int ady = abs(dy);
57 int sy = dy < 0 ? -1 : 1;
58 buf[x0] = MULT31_SHIFT15(buf[x0],lookup[y0]);
59 if (ady*2 <= adx) { // optimized common case
60 render_line_unrolled(x0, y0, x1, sy, ady, adx, lookup, buf);
61 } else {
62 int base = dy / adx;
63 int x = x0;
64 int y = y0;
65 int err = -adx;
66 ady -= abs(base) * adx;
67 while (++x < x1) {
68 y += base;
69 err += ady;
70 if (err >= 0) {
71 err -= adx;
72 y += sy;
73 }
74 buf[x] = MULT31_SHIFT15(buf[x],lookup[y]);
75 }
76 }
77}
78
79#ifndef INCL_OPTIMIZED_VECTOR_FMUL_WINDOW
80#define INCL_OPTIMIZED_VECTOR_FMUL_WINDOW
81static inline void ff_vector_fmul_window_c(ogg_int32_t *dst, const ogg_int32_t *src0,
82 const ogg_int32_t *src1, const ogg_int32_t *win, int len){
83 int i,j;
84 dst += len;
85 win += len;
86 src0+= len;
87 for(i=-len, j=len-1; i<0; i++, j--) {
88 ogg_int32_t s0 = src0[i];
89 ogg_int32_t s1 = src1[j];
90 ogg_int32_t wi = win[i];
91 ogg_int32_t wj = win[j];
92 XNPROD31(s0, s1, wj, wi, &dst[i], &dst[j]);
93 /*
94 dst[i] = MULT31(s0,wj) - MULT31(s1,wi);
95 dst[j] = MULT31(s0,wi) + MULT31(s1,wj);
96 */
97 }
98}
99#endif
100
101static inline void copy_normalize(ogg_int32_t *dst, ogg_int32_t *src, int len)
102{
103 memcpy(dst, src, len * sizeof(ogg_int32_t));
104}
105
106static inline void window_overlap_add(unsigned int blocksize, unsigned int lastblock,
107 unsigned int bs0, unsigned int bs1, int ch,
108 const ogg_int32_t *win, vorbis_dsp_state *v)
109{
110 unsigned retlen = (blocksize + lastblock) / 4;
111 int j;
112 for (j = 0; j < ch; j++) {
113 ogg_int32_t *residue = v->residues[v->ri] + j * blocksize / 2;
114 ogg_int32_t *saved = v->saved_ptr[j];
115 ogg_int32_t *ret = v->floors + j * retlen;
116 ogg_int32_t *buf = residue;
117
118 if (v->W == v->lW) {
119 ff_vector_fmul_window_c(ret, saved, buf, win, blocksize / 4);
120 } else if (v->W > v->lW) {
121 ff_vector_fmul_window_c(ret, saved, buf, win, bs0 / 4);
122 copy_normalize(ret+bs0/2, buf+bs0/4, (bs1-bs0)/4);
123 } else {
124 copy_normalize(ret, saved, (bs1 - bs0) / 4);
125 ff_vector_fmul_window_c(ret + (bs1 - bs0) / 4, saved + (bs1 - bs0) / 4, buf, win, bs0 / 4);
126 }
127 if (v->residues[1] == NULL) {
128 memcpy(saved, buf + blocksize / 4, blocksize / 4 * sizeof(ogg_int32_t));
129 v->saved_ptr[j] = v->saved + j * bs1 / 4;
130 } else {
131 v->saved_ptr[j] = buf + blocksize / 4;
132 }
133
134 v->pcmb[j] = ret;
135 }
136
137 if (v->residues[1] != NULL) {
138 v->ri ^= 1;
139 }
140}
diff --git a/lib/rbcodec/codecs/libtremor/floor0.c b/lib/rbcodec/codecs/libtremor/floor0.c
new file mode 100644
index 0000000000..cd0a9f89f6
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/floor0.c
@@ -0,0 +1,444 @@
1/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
4 * *
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * *
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
11 * *
12 ********************************************************************
13
14 function: floor backend 0 implementation
15
16 ********************************************************************/
17
18#include "config-tremor.h"
19#include <string.h>
20#include <math.h>
21#include "ogg.h"
22#include "ivorbiscodec.h"
23#include "codec_internal.h"
24#include "registry.h"
25#include "codebook.h"
26#include "misc.h"
27#include "os.h"
28
29#define LSP_FRACBITS 14
30
31typedef struct {
32 long n;
33 int ln;
34 int m;
35 int *linearmap;
36
37 vorbis_info_floor0 *vi;
38 ogg_int32_t *lsp_look;
39
40} vorbis_look_floor0;
41
42/*************** LSP decode ********************/
43
44#include "lsp_lookup.h"
45
46/* interpolated 1./sqrt(p) where .5 <= a < 1. (.100000... to .111111...) in
47 16.16 format
48 returns in m.8 format */
49
50static const long ADJUST_SQRT2[2] ={8192,5792};
51static inline ogg_int32_t vorbis_invsqlook_i(long a,long e){
52 long i=(a&0x7fff)>>(INVSQ_LOOKUP_I_SHIFT-1);
53 long d=a&INVSQ_LOOKUP_I_MASK; /* 0.10 */
54 long val=INVSQ_LOOKUP_I[i]- /* 1.16 */
55 ((INVSQ_LOOKUP_IDel[i]*d)>>INVSQ_LOOKUP_I_SHIFT); /* result 1.16 */
56 val*=ADJUST_SQRT2[e&1];
57 e=(e>>1)+21;
58 return(val>>e);
59}
60
61/* interpolated lookup based fromdB function, domain -140dB to 0dB only */
62/* a is in n.12 format */
63static inline ogg_int32_t vorbis_fromdBlook_i(long a){
64 int i=(-a)>>(12-FROMdB2_SHIFT);
65 if(i<0) return 0x7fffffff;
66 if(i>=(FROMdB_LOOKUP_SZ<<FROMdB_SHIFT))return 0;
67
68 return FROMdB_LOOKUP[i>>FROMdB_SHIFT] * FROMdB2_LOOKUP[i&FROMdB2_MASK];
69}
70
71/* interpolated lookup based cos function, domain 0 to PI only */
72/* a is in 0.16 format, where 0==0, 2^^16-1==PI, return 0.14 */
73static inline ogg_int32_t vorbis_coslook_i(long a){
74 int i=a>>COS_LOOKUP_I_SHIFT;
75 int d=a&COS_LOOKUP_I_MASK;
76 return COS_LOOKUP_I[i]- ((d*(COS_LOOKUP_I[i]-COS_LOOKUP_I[i+1]))>>
77 COS_LOOKUP_I_SHIFT);
78}
79
80/* interpolated lookup based cos function */
81/* a is in 0.16 format, where 0==0, 2^^16==PI, return .LSP_FRACBITS */
82static inline ogg_int32_t vorbis_coslook2_i(long a){
83 a=a&0x1ffff;
84
85 if(a>0x10000)a=0x20000-a;
86 {
87 int i=a>>COS_LOOKUP_I_SHIFT;
88 int d=a&COS_LOOKUP_I_MASK;
89 a=((COS_LOOKUP_I[i]<<COS_LOOKUP_I_SHIFT)-
90 d*(COS_LOOKUP_I[i]-COS_LOOKUP_I[i+1]))>>
91 (COS_LOOKUP_I_SHIFT-LSP_FRACBITS+14);
92 }
93
94 return(a);
95}
96
97static const int barklook[28] ={
98 0,100,200,301, 405,516,635,766,
99 912,1077,1263,1476, 1720,2003,2333,2721,
100 3184,3742,4428,5285, 6376,7791,9662,12181,
101 15624,20397,27087,36554
102};
103
104/* used in init only; interpolate the long way */
105static inline ogg_int32_t toBARK(int n){
106 int i;
107 for(i=0;i<27;i++)
108 if(n>=barklook[i] && n<barklook[i+1])break;
109
110 if(i==27){
111 return 27<<15;
112 }else{
113 int gap=barklook[i+1]-barklook[i];
114 int del=n-barklook[i];
115
116 return((i<<15)+((del<<15)/gap));
117 }
118}
119
120static const unsigned char MLOOP_1[64] ={
121 0,10,11,11, 12,12,12,12, 13,13,13,13, 13,13,13,13,
122 14,14,14,14, 14,14,14,14, 14,14,14,14, 14,14,14,14,
123 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15,
124 15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15,
125};
126
127static const unsigned char MLOOP_2[64] ={
128 0,4,5,5, 6,6,6,6, 7,7,7,7, 7,7,7,7,
129 8,8,8,8, 8,8,8,8, 8,8,8,8, 8,8,8,8,
130 9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9,
131 9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9,
132};
133
134static const unsigned char MLOOP_3[8] ={0,1,2,2,3,3,3,3};
135
136static void vorbis_lsp_to_curve(ogg_int32_t *curve,int *map,int n,int ln,
137 ogg_int32_t *lsp,int m,
138 ogg_int32_t amp,
139 ogg_int32_t ampoffset,
140 ogg_int32_t *icos){
141
142 (void)ln;
143 /* 0 <= m < 256 */
144
145 /* set up for using all int later */
146 int i;
147 int ampoffseti=ampoffset*4096;
148 int ampi=amp;
149 ogg_int32_t *ilsp=(ogg_int32_t *)alloca(m*sizeof(*ilsp));
150 /* lsp is in 8.24, range 0 to PI; coslook wants it in .16 0 to 1*/
151 for(i=0;i<m;i++){
152#ifndef _LOW_ACCURACY_
153 ogg_int32_t val=MULT32(lsp[i],0x517cc2);
154#else
155 ogg_int32_t val=((lsp[i]>>10)*0x517d)>>14;
156#endif
157
158 /* safeguard against a malicious stream */
159 if(val<0 || (val>>COS_LOOKUP_I_SHIFT)>=COS_LOOKUP_I_SZ){
160 memset(curve,0,sizeof(*curve)*n);
161 return;
162 }
163
164 ilsp[i]=vorbis_coslook_i(val);
165 }
166
167 i=0;
168 while(i<n){
169 int j,k=map[i];
170 ogg_uint32_t pi=46341; /* 2**-.5 in 0.16 */
171 ogg_uint32_t qi=46341;
172 ogg_int32_t qexp=0,shift;
173 ogg_int32_t wi=icos[k];
174
175#ifdef _V_LSP_MATH_ASM
176 (void)shift; /* kill warnings */
177 (void)j;
178 lsp_loop_asm(&qi,&pi,&qexp,ilsp,wi,m);
179
180 pi=((pi*pi)>>16);
181 qi=((qi*qi)>>16);
182
183 if(m&1){
184 qexp= qexp*2-28*((m+1)>>1)+m;
185 pi*=(1<<14)-((wi*wi)>>14);
186 qi+=pi>>14;
187 }else{
188 qexp= qexp*2-13*m;
189
190 pi*=(1<<14)-wi;
191 qi*=(1<<14)+wi;
192
193 qi=(qi+pi)>>14;
194 }
195
196 if(qi&0xffff0000){ /* checks for 1.xxxxxxxxxxxxxxxx */
197 qi>>=1; qexp++;
198 }else
199 lsp_norm_asm(&qi,&qexp);
200
201#else
202
203 j=1;
204 if(m>1){
205 qi*=labs(ilsp[0]-wi);
206 pi*=labs(ilsp[1]-wi);
207
208 for(j+=2;j<m;j+=2){
209 if(!(shift=MLOOP_1[(pi|qi)>>25]))
210 if(!(shift=MLOOP_2[(pi|qi)>>19]))
211 shift=MLOOP_3[(pi|qi)>>16];
212 qi=(qi>>shift)*labs(ilsp[j-1]-wi);
213 pi=(pi>>shift)*labs(ilsp[j]-wi);
214 qexp+=shift;
215 }
216 }
217 if(!(shift=MLOOP_1[(pi|qi)>>25]))
218 if(!(shift=MLOOP_2[(pi|qi)>>19]))
219 shift=MLOOP_3[(pi|qi)>>16];
220
221 /* pi,qi normalized collectively, both tracked using qexp */
222
223 if(m&1){
224 /* odd order filter; slightly assymetric */
225 /* the last coefficient */
226 qi=(qi>>shift)*labs(ilsp[j-1]-wi);
227 pi=(pi>>shift)<<14;
228 qexp+=shift;
229
230 if(!(shift=MLOOP_1[(pi|qi)>>25]))
231 if(!(shift=MLOOP_2[(pi|qi)>>19]))
232 shift=MLOOP_3[(pi|qi)>>16];
233
234 pi>>=shift;
235 qi>>=shift;
236 qexp+=shift-14*((m+1)>>1);
237
238 pi=((pi*pi)>>16);
239 qi=((qi*qi)>>16);
240 qexp=qexp*2+m;
241
242 pi*=(1<<14)-((wi*wi)>>14);
243 qi+=pi>>14;
244
245 }else{
246 /* even order filter; still symmetric */
247
248 /* p*=p(1-w), q*=q(1+w), let normalization drift because it isn't
249 worth tracking step by step */
250
251 pi>>=shift;
252 qi>>=shift;
253 qexp+=shift-7*m;
254
255 pi=((pi*pi)>>16);
256 qi=((qi*qi)>>16);
257 qexp=qexp*2+m;
258
259 pi*=(1<<14)-wi;
260 qi*=(1<<14)+wi;
261 qi=(qi+pi)>>14;
262
263 }
264
265
266 /* we've let the normalization drift because it wasn't important;
267 however, for the lookup, things must be normalized again. We
268 need at most one right shift or a number of left shifts */
269
270 if(qi&0xffff0000){ /* checks for 1.xxxxxxxxxxxxxxxx */
271 qi>>=1; qexp++;
272 }else
273 while(qi && !(qi&0x8000)){ /* checks for 0.0xxxxxxxxxxxxxxx or less*/
274 qi<<=1; qexp--;
275 }
276
277#endif
278
279 amp=vorbis_fromdBlook_i(ampi* /* n.4 */
280 vorbis_invsqlook_i(qi,qexp)-
281 /* m.8, m+n<=8 */
282 ampoffseti); /* 8.12[0] */
283
284#ifdef _LOW_ACCURACY_
285 amp>>=9;
286#endif
287 curve[i]= MULT31_SHIFT15(curve[i],amp);
288 while(map[++i]==k) curve[i]= MULT31_SHIFT15(curve[i],amp);
289 }
290}
291
292/*************** vorbis decode glue ************/
293
294static void floor0_free_info(vorbis_info_floor *i){
295 vorbis_info_floor0 *info=(vorbis_info_floor0 *)i;
296 if(info){
297 memset(info,0,sizeof(*info));
298 _ogg_free(info);
299 }
300}
301
302static void floor0_free_look(vorbis_look_floor *i){
303 vorbis_look_floor0 *look=(vorbis_look_floor0 *)i;
304 if(look){
305
306 if(look->linearmap)_ogg_free(look->linearmap);
307 if(look->lsp_look)_ogg_free(look->lsp_look);
308 memset(look,0,sizeof(*look));
309 _ogg_free(look);
310 }
311}
312
313static vorbis_info_floor *floor0_unpack (vorbis_info *vi,oggpack_buffer *opb){
314 codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
315 int j;
316
317 vorbis_info_floor0 *info=(vorbis_info_floor0 *)_ogg_malloc(sizeof(*info));
318 info->order=oggpack_read(opb,8);
319 info->rate=oggpack_read(opb,16);
320 info->barkmap=oggpack_read(opb,16);
321 info->ampbits=oggpack_read(opb,6);
322 info->ampdB=oggpack_read(opb,8);
323 info->numbooks=oggpack_read(opb,4)+1;
324
325 if(info->order<1)goto err_out;
326 if(info->rate<1)goto err_out;
327 if(info->barkmap<1)goto err_out;
328 if(info->numbooks<1)goto err_out;
329
330 for(j=0;j<info->numbooks;j++){
331 info->books[j]=oggpack_read(opb,8);
332 if(info->books[j]<0 || info->books[j]>=ci->books)goto err_out;
333 if(ci->book_param[info->books[j]]->maptype==0)goto err_out;
334 if(ci->book_param[info->books[j]]->dim<1)goto err_out;
335 }
336 return(info);
337
338 err_out:
339 floor0_free_info(info);
340 return(NULL);
341}
342
343/* initialize Bark scale and normalization lookups. We could do this
344 with static tables, but Vorbis allows a number of possible
345 combinations, so it's best to do it computationally.
346
347 The below is authoritative in terms of defining scale mapping.
348 Note that the scale depends on the sampling rate as well as the
349 linear block and mapping sizes */
350
351static vorbis_look_floor *floor0_look (vorbis_dsp_state *vd,vorbis_info_mode *mi,
352 vorbis_info_floor *i){
353 int j;
354 // ogg_int32_t scale;
355 vorbis_info *vi=vd->vi;
356 codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
357 vorbis_info_floor0 *info=(vorbis_info_floor0 *)i;
358 vorbis_look_floor0 *look=(vorbis_look_floor0 *)_ogg_calloc(1,sizeof(*look));
359 look->m=info->order;
360 look->n=ci->blocksizes[mi->blockflag]/2;
361 look->ln=info->barkmap;
362 look->vi=info;
363
364 /* the mapping from a linear scale to a smaller bark scale is
365 straightforward. We do *not* make sure that the linear mapping
366 does not skip bark-scale bins; the decoder simply skips them and
367 the encoder may do what it wishes in filling them. They're
368 necessary in some mapping combinations to keep the scale spacing
369 accurate */
370 look->linearmap=(int *)_ogg_malloc((look->n+1)*sizeof(*look->linearmap));
371 for(j=0;j<look->n;j++){
372
373 int val=(look->ln*
374 ((toBARK(info->rate/2*j/look->n)<<11)/toBARK(info->rate/2)))>>11;
375
376 if(val>=look->ln)val=look->ln-1; /* guard against the approximation */
377 look->linearmap[j]=val;
378 }
379 look->linearmap[j]=-1;
380
381 look->lsp_look=(ogg_int32_t *)_ogg_malloc(look->ln*sizeof(*look->lsp_look));
382 for(j=0;j<look->ln;j++)
383 look->lsp_look[j]=vorbis_coslook2_i(0x10000*j/look->ln);
384
385 return look;
386}
387
388static void *floor0_inverse1(vorbis_block *vb,vorbis_look_floor *i){
389 vorbis_look_floor0 *look=(vorbis_look_floor0 *)i;
390 vorbis_info_floor0 *info=look->vi;
391 int j,k;
392
393 int ampraw=oggpack_read(&vb->opb,info->ampbits);
394 if(ampraw>0){ /* also handles the -1 out of data case */
395 long maxval=(1<<info->ampbits)-1;
396 int amp=((ampraw*info->ampdB)<<4)/maxval;
397 int booknum=oggpack_read(&vb->opb,_ilog(info->numbooks));
398
399 if(booknum!=-1 && booknum<info->numbooks){ /* be paranoid */
400 codec_setup_info *ci=(codec_setup_info *)vb->vd->vi->codec_setup;
401 codebook *b=ci->fullbooks+info->books[booknum];
402 ogg_int32_t last=0;
403 ogg_int32_t *lsp=(ogg_int32_t *)_vorbis_block_alloc(vb,sizeof(*lsp)*(look->m+1));
404
405 if(vorbis_book_decodev_set(b,lsp,&vb->opb,look->m,-24)==-1)goto eop;
406 for(j=0;j<look->m;){
407 for(k=0;j<look->m && k<b->dim;k++,j++)lsp[j]+=last;
408 last=lsp[j-1];
409 }
410
411 lsp[look->m]=amp;
412 return(lsp);
413 }
414 }
415 eop:
416 return(NULL);
417}
418
419static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i,
420 void *memo,ogg_int32_t *out){
421 vorbis_look_floor0 *look=(vorbis_look_floor0 *)i;
422 vorbis_info_floor0 *info=look->vi;
423 (void)vb;
424
425 if(memo){
426 ogg_int32_t *lsp=(ogg_int32_t *)memo;
427 ogg_int32_t amp=lsp[look->m];
428
429 /* take the coefficients back to a spectral envelope curve */
430 vorbis_lsp_to_curve(out,look->linearmap,look->n,look->ln,
431 lsp,look->m,amp,info->ampdB,look->lsp_look);
432 return(1);
433 }
434 memset(out,0,sizeof(*out)*look->n);
435 return(0);
436}
437
438/* export hooks */
439const vorbis_func_floor floor0_exportbundle ICONST_ATTR ={
440 &floor0_unpack,&floor0_look,&floor0_free_info,
441 &floor0_free_look,&floor0_inverse1,&floor0_inverse2
442};
443
444
diff --git a/lib/rbcodec/codecs/libtremor/floor1.c b/lib/rbcodec/codecs/libtremor/floor1.c
new file mode 100644
index 0000000000..d2268db121
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/floor1.c
@@ -0,0 +1,426 @@
1/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
4 * *
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * *
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
11 * *
12 ********************************************************************
13
14 function: floor backend 1 implementation
15
16 ********************************************************************/
17
18#include "config-tremor.h"
19#include <string.h>
20#include <math.h>
21#include "ogg.h"
22#include "ivorbiscodec.h"
23#include "codec_internal.h"
24#include "registry.h"
25#include "codebook.h"
26#include "misc.h"
27#include "ffmpeg_stuff.h"
28
29#define floor1_rangedB 140 /* floor 1 fixed at -140dB to 0dB range */
30
31typedef struct {
32 int forward_index[VIF_POSIT+2];
33
34 int hineighbor[VIF_POSIT];
35 int loneighbor[VIF_POSIT];
36 int posts;
37
38 int n;
39 int quant_q;
40 vorbis_info_floor1 *vi;
41
42} vorbis_look_floor1;
43
44/***********************************************/
45
46static void floor1_free_info(vorbis_info_floor *i){
47 vorbis_info_floor1 *info=(vorbis_info_floor1 *)i;
48 if(info){
49 //memset(info,0,sizeof(*info));
50 _ogg_free(info);
51 }
52}
53
54static void floor1_free_look(vorbis_look_floor *i){
55 vorbis_look_floor1 *look=(vorbis_look_floor1 *)i;
56 if(look){
57 //memset(look,0,sizeof(*look));
58 _ogg_free(look);
59 }
60}
61
62static inline int ilog(register unsigned int v){
63 register int ret=0;
64 while(v){
65 ret++;
66 v>>=1;
67 }
68 return(ret);
69}
70
71static int icomp(const void *a,const void *b){
72 return(**(int **)a-**(int **)b);
73}
74
75static vorbis_info_floor *floor1_unpack (vorbis_info *vi,oggpack_buffer *opb){
76 codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
77 int j,k,count=0,maxclass=-1,rangebits;
78
79 vorbis_info_floor1 *info=(vorbis_info_floor1 *)_ogg_calloc(1,sizeof(*info));
80 /* read partitions */
81 info->partitions=oggpack_read(opb,5); /* only 0 to 31 legal */
82 for(j=0;j<info->partitions;j++){
83 info->partitionclass[j]=oggpack_read(opb,4); /* only 0 to 15 legal */
84 if(info->partitionclass[j]<0)goto err_out;
85 if(maxclass<info->partitionclass[j])maxclass=info->partitionclass[j];
86 }
87
88 /* read partition classes */
89 for(j=0;j<maxclass+1;j++){
90 info->class_dim[j]=oggpack_read(opb,3)+1; /* 1 to 8 */
91 info->class_subs[j]=oggpack_read(opb,2); /* 0,1,2,3 bits */
92 if(info->class_subs[j]<0)
93 goto err_out;
94 if(info->class_subs[j])info->class_book[j]=oggpack_read(opb,8);
95 if(info->class_book[j]<0 || info->class_book[j]>=ci->books)
96 goto err_out;
97 for(k=0;k<(1<<info->class_subs[j]);k++){
98 info->class_subbook[j][k]=oggpack_read(opb,8)-1;
99 if(info->class_subbook[j][k]<-1 || info->class_subbook[j][k]>=ci->books)
100 goto err_out;
101 }
102 }
103
104 /* read the post list */
105 info->mult=oggpack_read(opb,2)+1; /* only 1,2,3,4 legal now */
106 rangebits=oggpack_read(opb,4);
107 if(rangebits<0)goto err_out;
108
109 for(j=0,k=0;j<info->partitions;j++){
110 count+=info->class_dim[info->partitionclass[j]];
111 for(;k<count;k++){
112 int t=info->postlist[k+2]=oggpack_read(opb,rangebits);
113 if(t<0 || t>=(1<<rangebits))
114 goto err_out;
115 }
116 }
117 info->postlist[0]=0;
118 info->postlist[1]=1<<rangebits;
119
120 /* don't allow repeated values in post list as they'd result in
121 zero-length segments */
122 {
123 int *sortpointer[VIF_POSIT+2];
124 for(j=0;j<count+2;j++)sortpointer[j]=info->postlist+j;
125 qsort(sortpointer,count+2,sizeof(*sortpointer),icomp);
126
127 for(j=1;j<count+2;j++)
128 if(*sortpointer[j-1]==*sortpointer[j])goto err_out;
129 }
130
131 return(info);
132
133 err_out:
134 floor1_free_info(info);
135 return(NULL);
136}
137
138static vorbis_look_floor *floor1_look(vorbis_dsp_state *vd,vorbis_info_mode *mi,
139 vorbis_info_floor *in){
140
141 int *sortpointer[VIF_POSIT+2];
142 vorbis_info_floor1 *info=(vorbis_info_floor1 *)in;
143 vorbis_look_floor1 *look=(vorbis_look_floor1 *)_ogg_calloc(1,sizeof(*look));
144 int i,j,n=0;
145
146 (void)vd;
147 (void)mi;
148 look->vi=info;
149 look->n=info->postlist[1];
150
151 /* we drop each position value in-between already decoded values,
152 and use linear interpolation to predict each new value past the
153 edges. The positions are read in the order of the position
154 list... we precompute the bounding positions in the lookup. Of
155 course, the neighbors can change (if a position is declined), but
156 this is an initial mapping */
157
158 for(i=0;i<info->partitions;i++)n+=info->class_dim[info->partitionclass[i]];
159 n+=2;
160 look->posts=n;
161
162 /* also store a sorted position index */
163 for(i=0;i<n;i++)sortpointer[i]=info->postlist+i;
164 qsort(sortpointer,n,sizeof(*sortpointer),icomp);
165
166 /* points from sort order back to range number */
167 for(i=0;i<n;i++)look->forward_index[i]=sortpointer[i]-info->postlist;
168
169 /* quantize values to multiplier spec */
170 switch(info->mult){
171 case 1: /* 1024 -> 256 */
172 look->quant_q=256;
173 break;
174 case 2: /* 1024 -> 128 */
175 look->quant_q=128;
176 break;
177 case 3: /* 1024 -> 86 */
178 look->quant_q=86;
179 break;
180 case 4: /* 1024 -> 64 */
181 look->quant_q=64;
182 break;
183 }
184
185 /* discover our neighbors for decode where we don't use fit flags
186 (that would push the neighbors outward) */
187 for(i=0;i<n-2;i++){
188 int lo=0;
189 int hi=1;
190 int lx=0;
191 int hx=look->n;
192 int currentx=info->postlist[i+2];
193 for(j=0;j<i+2;j++){
194 int x=info->postlist[j];
195 if(x>lx && x<currentx){
196 lo=j;
197 lx=x;
198 }
199 if(x<hx && x>currentx){
200 hi=j;
201 hx=x;
202 }
203 }
204 look->loneighbor[i]=lo;
205 look->hineighbor[i]=hi;
206 }
207
208 return(look);
209}
210
211static int render_point(int x0,int x1,int y0,int y1,int x){
212 y0&=0x7fff; /* mask off flag */
213 y1&=0x7fff;
214 return y0+((y1-y0)*(x-x0))/(x1-x0);
215}
216
217#ifdef _LOW_ACCURACY_
218# define XdB(n) ((((n)>>8)+1)>>1)
219#else
220# define XdB(n) (n)
221#endif
222
223/* keep the floor lookup table in fast IRAM */
224static const ogg_int32_t FLOOR_fromdB_LOOKUP[256] ICONST_ATTR = {
225 XdB(0x000000e5), XdB(0x000000f4), XdB(0x00000103), XdB(0x00000114),
226 XdB(0x00000126), XdB(0x00000139), XdB(0x0000014e), XdB(0x00000163),
227 XdB(0x0000017a), XdB(0x00000193), XdB(0x000001ad), XdB(0x000001c9),
228 XdB(0x000001e7), XdB(0x00000206), XdB(0x00000228), XdB(0x0000024c),
229 XdB(0x00000272), XdB(0x0000029b), XdB(0x000002c6), XdB(0x000002f4),
230 XdB(0x00000326), XdB(0x0000035a), XdB(0x00000392), XdB(0x000003cd),
231 XdB(0x0000040c), XdB(0x00000450), XdB(0x00000497), XdB(0x000004e4),
232 XdB(0x00000535), XdB(0x0000058c), XdB(0x000005e8), XdB(0x0000064a),
233 XdB(0x000006b3), XdB(0x00000722), XdB(0x00000799), XdB(0x00000818),
234 XdB(0x0000089e), XdB(0x0000092e), XdB(0x000009c6), XdB(0x00000a69),
235 XdB(0x00000b16), XdB(0x00000bcf), XdB(0x00000c93), XdB(0x00000d64),
236 XdB(0x00000e43), XdB(0x00000f30), XdB(0x0000102d), XdB(0x0000113a),
237 XdB(0x00001258), XdB(0x0000138a), XdB(0x000014cf), XdB(0x00001629),
238 XdB(0x0000179a), XdB(0x00001922), XdB(0x00001ac4), XdB(0x00001c82),
239 XdB(0x00001e5c), XdB(0x00002055), XdB(0x0000226f), XdB(0x000024ac),
240 XdB(0x0000270e), XdB(0x00002997), XdB(0x00002c4b), XdB(0x00002f2c),
241 XdB(0x0000323d), XdB(0x00003581), XdB(0x000038fb), XdB(0x00003caf),
242 XdB(0x000040a0), XdB(0x000044d3), XdB(0x0000494c), XdB(0x00004e10),
243 XdB(0x00005323), XdB(0x0000588a), XdB(0x00005e4b), XdB(0x0000646b),
244 XdB(0x00006af2), XdB(0x000071e5), XdB(0x0000794c), XdB(0x0000812e),
245 XdB(0x00008993), XdB(0x00009283), XdB(0x00009c09), XdB(0x0000a62d),
246 XdB(0x0000b0f9), XdB(0x0000bc79), XdB(0x0000c8b9), XdB(0x0000d5c4),
247 XdB(0x0000e3a9), XdB(0x0000f274), XdB(0x00010235), XdB(0x000112fd),
248 XdB(0x000124dc), XdB(0x000137e4), XdB(0x00014c29), XdB(0x000161bf),
249 XdB(0x000178bc), XdB(0x00019137), XdB(0x0001ab4a), XdB(0x0001c70e),
250 XdB(0x0001e4a1), XdB(0x0002041f), XdB(0x000225aa), XdB(0x00024962),
251 XdB(0x00026f6d), XdB(0x000297f0), XdB(0x0002c316), XdB(0x0002f109),
252 XdB(0x000321f9), XdB(0x00035616), XdB(0x00038d97), XdB(0x0003c8b4),
253 XdB(0x000407a7), XdB(0x00044ab2), XdB(0x00049218), XdB(0x0004de23),
254 XdB(0x00052f1e), XdB(0x0005855c), XdB(0x0005e135), XdB(0x00064306),
255 XdB(0x0006ab33), XdB(0x00071a24), XdB(0x0007904b), XdB(0x00080e20),
256 XdB(0x00089422), XdB(0x000922da), XdB(0x0009bad8), XdB(0x000a5cb6),
257 XdB(0x000b091a), XdB(0x000bc0b1), XdB(0x000c8436), XdB(0x000d5471),
258 XdB(0x000e3233), XdB(0x000f1e5f), XdB(0x001019e4), XdB(0x001125c1),
259 XdB(0x00124306), XdB(0x001372d5), XdB(0x0014b663), XdB(0x00160ef7),
260 XdB(0x00177df0), XdB(0x001904c1), XdB(0x001aa4f9), XdB(0x001c603d),
261 XdB(0x001e384f), XdB(0x00202f0f), XdB(0x0022467a), XdB(0x002480b1),
262 XdB(0x0026dff7), XdB(0x002966b3), XdB(0x002c1776), XdB(0x002ef4fc),
263 XdB(0x0032022d), XdB(0x00354222), XdB(0x0038b828), XdB(0x003c67c2),
264 XdB(0x004054ae), XdB(0x004482e8), XdB(0x0048f6af), XdB(0x004db488),
265 XdB(0x0052c142), XdB(0x005821ff), XdB(0x005ddc33), XdB(0x0063f5b0),
266 XdB(0x006a74a7), XdB(0x00715faf), XdB(0x0078bdce), XdB(0x0080967f),
267 XdB(0x0088f1ba), XdB(0x0091d7f9), XdB(0x009b5247), XdB(0x00a56a41),
268 XdB(0x00b02a27), XdB(0x00bb9ce2), XdB(0x00c7ce12), XdB(0x00d4ca17),
269 XdB(0x00e29e20), XdB(0x00f15835), XdB(0x0101074b), XdB(0x0111bb4e),
270 XdB(0x01238531), XdB(0x01367704), XdB(0x014aa402), XdB(0x016020a7),
271 XdB(0x017702c3), XdB(0x018f6190), XdB(0x01a955cb), XdB(0x01c4f9cf),
272 XdB(0x01e269a8), XdB(0x0201c33b), XdB(0x0223265a), XdB(0x0246b4ea),
273 XdB(0x026c9302), XdB(0x0294e716), XdB(0x02bfda13), XdB(0x02ed9793),
274 XdB(0x031e4e09), XdB(0x03522ee4), XdB(0x03896ed0), XdB(0x03c445e2),
275 XdB(0x0402efd6), XdB(0x0445ac4b), XdB(0x048cbefc), XdB(0x04d87013),
276 XdB(0x05290c67), XdB(0x057ee5ca), XdB(0x05da5364), XdB(0x063bb204),
277 XdB(0x06a36485), XdB(0x0711d42b), XdB(0x0787710e), XdB(0x0804b299),
278 XdB(0x088a17ef), XdB(0x0918287e), XdB(0x09af747c), XdB(0x0a50957e),
279 XdB(0x0afc2f19), XdB(0x0bb2ef7f), XdB(0x0c759034), XdB(0x0d44d6ca),
280 XdB(0x0e2195bc), XdB(0x0f0cad0d), XdB(0x10070b62), XdB(0x1111aeea),
281 XdB(0x122da66c), XdB(0x135c120f), XdB(0x149e24d9), XdB(0x15f525b1),
282 XdB(0x176270e3), XdB(0x18e7794b), XdB(0x1a85c9ae), XdB(0x1c3f06d1),
283 XdB(0x1e14f07d), XdB(0x200963d7), XdB(0x221e5ccd), XdB(0x2455f870),
284 XdB(0x26b2770b), XdB(0x29363e2b), XdB(0x2be3db5c), XdB(0x2ebe06b6),
285 XdB(0x31c7a55b), XdB(0x3503ccd4), XdB(0x3875c5aa), XdB(0x3c210f44),
286 XdB(0x4009632b), XdB(0x4432b8cf), XdB(0x48a149bc), XdB(0x4d59959e),
287 XdB(0x52606733), XdB(0x57bad899), XdB(0x5d6e593a), XdB(0x6380b298),
288 XdB(0x69f80e9a), XdB(0x70dafda8), XdB(0x78307d76), XdB(0x7fffffff),
289};
290
291static void *floor1_inverse1(vorbis_block *vb,vorbis_look_floor *in)
292 ICODE_ATTR_TREMOR_NOT_MDCT;
293static void *floor1_inverse1(vorbis_block *vb,vorbis_look_floor *in){
294 vorbis_look_floor1 *look=(vorbis_look_floor1 *)in;
295 vorbis_info_floor1 *info=look->vi;
296 codec_setup_info *ci=(codec_setup_info *)vb->vd->vi->codec_setup;
297 int i,j,k;
298 codebook *books=ci->fullbooks;
299
300 /* unpack wrapped/predicted values from stream */
301 if(oggpack_read(&vb->opb,1)==1){
302 int *fit_value=(int *)_vorbis_block_alloc(vb,(look->posts)*sizeof(*fit_value));
303 int ilg = ilog(look->quant_q-1);
304 fit_value[0]=oggpack_read(&vb->opb,ilg);
305 fit_value[1]=oggpack_read(&vb->opb,ilg);
306
307 /* partition by partition */
308 /* partition by partition */
309 for(i=0,j=2;i<info->partitions;i++){
310 int classv=info->partitionclass[i];
311 int cdim=info->class_dim[classv];
312 int csubbits=info->class_subs[classv];
313 int csub=1<<csubbits;
314 int cval=0;
315
316 /* decode the partition's first stage cascade value */
317 if(csubbits){
318 cval=vorbis_book_decode(books+info->class_book[classv],&vb->opb);
319
320 if(cval==-1)goto eop;
321 }
322
323 for(k=0;k<cdim;k++){
324 int book=info->class_subbook[classv][cval&(csub-1)];
325 cval>>=csubbits;
326 if(book>=0){
327 if((fit_value[j+k]=vorbis_book_decode(books+book,&vb->opb))==-1)
328 goto eop;
329 }else{
330 fit_value[j+k]=0;
331 }
332 }
333 j+=cdim;
334 }
335
336 /* unwrap positive values and reconsitute via linear interpolation */
337 for(i=2;i<look->posts;i++){
338 int predicted=render_point(info->postlist[look->loneighbor[i-2]],
339 info->postlist[look->hineighbor[i-2]],
340 fit_value[look->loneighbor[i-2]],
341 fit_value[look->hineighbor[i-2]],
342 info->postlist[i]);
343 int hiroom=look->quant_q-predicted;
344 int loroom=predicted;
345 int room=(hiroom<loroom?hiroom:loroom)<<1;
346 int val=fit_value[i];
347
348 if(val){
349 if(val>=room){
350 if(hiroom>loroom){
351 val = val-loroom;
352 }else{
353 val = -1-(val-hiroom);
354 }
355 }else{
356 if(val&1){
357 val= -((val+1)>>1);
358 }else{
359 val>>=1;
360 }
361 }
362
363 fit_value[i]=(val+predicted)&0x7fff;;
364 fit_value[look->loneighbor[i-2]]&=0x7fff;
365 fit_value[look->hineighbor[i-2]]&=0x7fff;
366
367 }else{
368 fit_value[i]=predicted|0x8000;
369 }
370 }
371
372 return(fit_value);
373 }
374 eop:
375 return(NULL);
376}
377
378static int floor1_inverse2(vorbis_block *vb,vorbis_look_floor *in,void *memo,
379 ogg_int32_t *out) ICODE_ATTR_TREMOR_NOT_MDCT;
380static int floor1_inverse2(vorbis_block *vb,vorbis_look_floor *in,void *memo,
381 ogg_int32_t *out){
382 vorbis_look_floor1 *look=(vorbis_look_floor1 *)in;
383 vorbis_info_floor1 *info=look->vi;
384
385 codec_setup_info *ci=(codec_setup_info *)vb->vd->vi->codec_setup;
386 int n=ci->blocksizes[vb->W]/2;
387 int j;
388
389 if(memo){
390 /* render the lines */
391 int *fit_value=(int *)memo;
392 int hx=0;
393 int lx=0;
394 int ly=fit_value[0]*info->mult;
395 /* guard lookup against out-of-range values */
396 ly=(ly<0?0:ly>255?255:ly);
397
398 for(j=1;j<look->posts;j++){
399 int current=look->forward_index[j];
400 int hy=fit_value[current]&0x7fff;
401 if(hy==fit_value[current]){
402
403 hx=info->postlist[current];
404 hy*=info->mult;
405 /* guard lookup against out-of-range values */
406 hy=(hy<0?0:hy>255?255:hy);
407
408 render_line(lx, ly, hx, hy, FLOOR_fromdB_LOOKUP, out);
409
410 lx=hx;
411 ly=hy;
412 }
413 }
414 for(j=hx;j<n;j++)out[j]*=ly; /* be certain */
415 return(1);
416 }
417 memset(out,0,sizeof(*out)*n);
418 return(0);
419}
420
421/* export hooks */
422const vorbis_func_floor floor1_exportbundle ICONST_ATTR = {
423 &floor1_unpack,&floor1_look,&floor1_free_info,
424 &floor1_free_look,&floor1_inverse1,&floor1_inverse2
425};
426
diff --git a/lib/rbcodec/codecs/libtremor/framing.c b/lib/rbcodec/codecs/libtremor/framing.c
new file mode 100644
index 0000000000..582084853a
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/framing.c
@@ -0,0 +1,2102 @@
1/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE Ogg CONTAINER SOURCE CODE. *
4 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
5 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
6 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
7 * *
8 * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2010 *
9 * by the Xiph.Org Foundation http://www.xiph.org/ *
10 * *
11 ********************************************************************
12
13 function: code raw packets into framed OggSquish stream and
14 decode Ogg streams back into raw packets
15 last mod: $Id$
16
17 note: The CRC code is directly derived from public domain code by
18 Ross Williams (ross@guest.adelaide.edu.au). See docs/framing.html
19 for details.
20
21 ********************************************************************/
22
23#include <stdlib.h>
24#include <string.h>
25#include "ogg.h"
26
27/* A complete description of Ogg framing exists in docs/framing.html */
28
29static int ogg_page_version(const ogg_page *og){
30 return((int)(og->header[4]));
31}
32
33int ogg_page_continued(const ogg_page *og){
34 return((int)(og->header[5]&0x01));
35}
36
37int ogg_page_bos(const ogg_page *og){
38 return((int)(og->header[5]&0x02));
39}
40
41int ogg_page_eos(const ogg_page *og){
42 return((int)(og->header[5]&0x04));
43}
44
45ogg_int64_t ogg_page_granulepos(const ogg_page *og){
46 unsigned char *page=og->header;
47 ogg_int64_t granulepos=page[13]&(0xff);
48 granulepos= (granulepos<<8)|(page[12]&0xff);
49 granulepos= (granulepos<<8)|(page[11]&0xff);
50 granulepos= (granulepos<<8)|(page[10]&0xff);
51 granulepos= (granulepos<<8)|(page[9]&0xff);
52 granulepos= (granulepos<<8)|(page[8]&0xff);
53 granulepos= (granulepos<<8)|(page[7]&0xff);
54 granulepos= (granulepos<<8)|(page[6]&0xff);
55 return(granulepos);
56}
57
58ogg_uint32_t ogg_page_serialno(const ogg_page *og){
59 return(og->header[14] |
60 (og->header[15]<<8) |
61 (og->header[16]<<16) |
62 (og->header[17]<<24));
63}
64
65static long ogg_page_pageno(const ogg_page *og){
66 return(og->header[18] |
67 (og->header[19]<<8) |
68 (og->header[20]<<16) |
69 (og->header[21]<<24));
70}
71
72
73
74/* returns the number of packets that are completed on this page (if
75 the leading packet is begun on a previous page, but ends on this
76 page, it's counted */
77
78/* NOTE:
79If a page consists of a packet begun on a previous page, and a new
80packet begun (but not completed) on this page, the return will be:
81 ogg_page_packets(page) ==1,
82 ogg_page_continued(page) !=0
83
84If a page happens to be a single packet that was begun on a
85previous page, and spans to the next page (in the case of a three or
86more page packet), the return will be:
87 ogg_page_packets(page) ==0,
88 ogg_page_continued(page) !=0
89*/
90/*
91int ogg_page_packets(const ogg_page *og){
92 int i,n=og->header[26],count=0;
93 for(i=0;i<n;i++)
94 if(og->header[27+i]<255)count++;
95 return(count);
96}
97*/
98
99#if 0
100/* helper to initialize lookup for direct-table CRC (illustrative; we
101 use the static init below) */
102
103static ogg_uint32_t _ogg_crc_entry(unsigned long index){
104 int i;
105 unsigned long r;
106
107 r = index << 24;
108 for (i=0; i<8; i++)
109 if (r & 0x80000000UL)
110 r = (r << 1) ^ 0x04c11db7; /* The same as the ethernet generator
111 polynomial, although we use an
112 unreflected alg and an init/final
113 of 0, not 0xffffffff */
114 else
115 r<<=1;
116 return (r & 0xffffffffUL);
117}
118#endif
119
120static const ogg_uint32_t crc_lookup[256] ICONST_ATTR = {
121 0x00000000,0x04c11db7,0x09823b6e,0x0d4326d9,
122 0x130476dc,0x17c56b6b,0x1a864db2,0x1e475005,
123 0x2608edb8,0x22c9f00f,0x2f8ad6d6,0x2b4bcb61,
124 0x350c9b64,0x31cd86d3,0x3c8ea00a,0x384fbdbd,
125 0x4c11db70,0x48d0c6c7,0x4593e01e,0x4152fda9,
126 0x5f15adac,0x5bd4b01b,0x569796c2,0x52568b75,
127 0x6a1936c8,0x6ed82b7f,0x639b0da6,0x675a1011,
128 0x791d4014,0x7ddc5da3,0x709f7b7a,0x745e66cd,
129 0x9823b6e0,0x9ce2ab57,0x91a18d8e,0x95609039,
130 0x8b27c03c,0x8fe6dd8b,0x82a5fb52,0x8664e6e5,
131 0xbe2b5b58,0xbaea46ef,0xb7a96036,0xb3687d81,
132 0xad2f2d84,0xa9ee3033,0xa4ad16ea,0xa06c0b5d,
133 0xd4326d90,0xd0f37027,0xddb056fe,0xd9714b49,
134 0xc7361b4c,0xc3f706fb,0xceb42022,0xca753d95,
135 0xf23a8028,0xf6fb9d9f,0xfbb8bb46,0xff79a6f1,
136 0xe13ef6f4,0xe5ffeb43,0xe8bccd9a,0xec7dd02d,
137 0x34867077,0x30476dc0,0x3d044b19,0x39c556ae,
138 0x278206ab,0x23431b1c,0x2e003dc5,0x2ac12072,
139 0x128e9dcf,0x164f8078,0x1b0ca6a1,0x1fcdbb16,
140 0x018aeb13,0x054bf6a4,0x0808d07d,0x0cc9cdca,
141 0x7897ab07,0x7c56b6b0,0x71159069,0x75d48dde,
142 0x6b93dddb,0x6f52c06c,0x6211e6b5,0x66d0fb02,
143 0x5e9f46bf,0x5a5e5b08,0x571d7dd1,0x53dc6066,
144 0x4d9b3063,0x495a2dd4,0x44190b0d,0x40d816ba,
145 0xaca5c697,0xa864db20,0xa527fdf9,0xa1e6e04e,
146 0xbfa1b04b,0xbb60adfc,0xb6238b25,0xb2e29692,
147 0x8aad2b2f,0x8e6c3698,0x832f1041,0x87ee0df6,
148 0x99a95df3,0x9d684044,0x902b669d,0x94ea7b2a,
149 0xe0b41de7,0xe4750050,0xe9362689,0xedf73b3e,
150 0xf3b06b3b,0xf771768c,0xfa325055,0xfef34de2,
151 0xc6bcf05f,0xc27dede8,0xcf3ecb31,0xcbffd686,
152 0xd5b88683,0xd1799b34,0xdc3abded,0xd8fba05a,
153 0x690ce0ee,0x6dcdfd59,0x608edb80,0x644fc637,
154 0x7a089632,0x7ec98b85,0x738aad5c,0x774bb0eb,
155 0x4f040d56,0x4bc510e1,0x46863638,0x42472b8f,
156 0x5c007b8a,0x58c1663d,0x558240e4,0x51435d53,
157 0x251d3b9e,0x21dc2629,0x2c9f00f0,0x285e1d47,
158 0x36194d42,0x32d850f5,0x3f9b762c,0x3b5a6b9b,
159 0x0315d626,0x07d4cb91,0x0a97ed48,0x0e56f0ff,
160 0x1011a0fa,0x14d0bd4d,0x19939b94,0x1d528623,
161 0xf12f560e,0xf5ee4bb9,0xf8ad6d60,0xfc6c70d7,
162 0xe22b20d2,0xe6ea3d65,0xeba91bbc,0xef68060b,
163 0xd727bbb6,0xd3e6a601,0xdea580d8,0xda649d6f,
164 0xc423cd6a,0xc0e2d0dd,0xcda1f604,0xc960ebb3,
165 0xbd3e8d7e,0xb9ff90c9,0xb4bcb610,0xb07daba7,
166 0xae3afba2,0xaafbe615,0xa7b8c0cc,0xa379dd7b,
167 0x9b3660c6,0x9ff77d71,0x92b45ba8,0x9675461f,
168 0x8832161a,0x8cf30bad,0x81b02d74,0x857130c3,
169 0x5d8a9099,0x594b8d2e,0x5408abf7,0x50c9b640,
170 0x4e8ee645,0x4a4ffbf2,0x470cdd2b,0x43cdc09c,
171 0x7b827d21,0x7f436096,0x7200464f,0x76c15bf8,
172 0x68860bfd,0x6c47164a,0x61043093,0x65c52d24,
173 0x119b4be9,0x155a565e,0x18197087,0x1cd86d30,
174 0x029f3d35,0x065e2082,0x0b1d065b,0x0fdc1bec,
175 0x3793a651,0x3352bbe6,0x3e119d3f,0x3ad08088,
176 0x2497d08d,0x2056cd3a,0x2d15ebe3,0x29d4f654,
177 0xc5a92679,0xc1683bce,0xcc2b1d17,0xc8ea00a0,
178 0xd6ad50a5,0xd26c4d12,0xdf2f6bcb,0xdbee767c,
179 0xe3a1cbc1,0xe760d676,0xea23f0af,0xeee2ed18,
180 0xf0a5bd1d,0xf464a0aa,0xf9278673,0xfde69bc4,
181 0x89b8fd09,0x8d79e0be,0x803ac667,0x84fbdbd0,
182 0x9abc8bd5,0x9e7d9662,0x933eb0bb,0x97ffad0c,
183 0xafb010b1,0xab710d06,0xa6322bdf,0xa2f33668,
184 0xbcb4666d,0xb8757bda,0xb5365d03,0xb1f740b4};
185
186/* init the encode/decode logical stream state */
187
188int ogg_stream_init(ogg_stream_state *os,int serialno){
189 if(os){
190 memset(os,0,sizeof(*os));
191 os->body_storage=16*1024;
192 os->lacing_storage=1024;
193
194 os->body_data=_ogg_malloc(os->body_storage*sizeof(*os->body_data));
195 os->lacing_vals=_ogg_malloc(os->lacing_storage*sizeof(*os->lacing_vals));
196 os->granule_vals=_ogg_malloc(os->lacing_storage*sizeof(*os->granule_vals));
197
198 if(!os->body_data || !os->lacing_vals || !os->granule_vals){
199 ogg_stream_clear(os);
200 return -1;
201 }
202
203 os->serialno=serialno;
204
205 return(0);
206 }
207 return(-1);
208}
209
210/* async/delayed error detection for the ogg_stream_state */
211static int ogg_stream_check(ogg_stream_state *os){
212 if(!os || !os->body_data) return -1;
213 return 0;
214}
215
216/* _clear does not free os, only the non-flat storage within */
217int ogg_stream_clear(ogg_stream_state *os){
218 if(os){
219 if(os->body_data)_ogg_free(os->body_data);
220 if(os->lacing_vals)_ogg_free(os->lacing_vals);
221 if(os->granule_vals)_ogg_free(os->granule_vals);
222
223 memset(os,0,sizeof(*os));
224 }
225 return(0);
226}
227/*
228int ogg_stream_destroy(ogg_stream_state *os){
229 if(os){
230 ogg_stream_clear(os);
231 _ogg_free(os);
232 }
233 return(0);
234}
235*/
236/* Helpers for ogg_stream_encode; this keeps the structure and
237 what's happening fairly clear */
238
239int _os_body_expand(ogg_stream_state *os,int needed){
240 if(os->body_storage<=os->body_fill+needed){
241 void *ret;
242 ret=_ogg_realloc(os->body_data,(os->body_storage+needed+1024)*
243 sizeof(*os->body_data));
244 if(!ret){
245 ogg_stream_clear(os);
246 return -1;
247 }
248 os->body_storage+=(needed+1024);
249 os->body_data=ret;
250 }
251 return 0;
252}
253
254static int _os_lacing_expand(ogg_stream_state *os,int needed){
255 if(os->lacing_storage<=os->lacing_fill+needed){
256 void *ret;
257 ret=_ogg_realloc(os->lacing_vals,(os->lacing_storage+needed+32)*
258 sizeof(*os->lacing_vals));
259 if(!ret){
260 ogg_stream_clear(os);
261 return -1;
262 }
263 os->lacing_vals=ret;
264 ret=_ogg_realloc(os->granule_vals,(os->lacing_storage+needed+32)*
265 sizeof(*os->granule_vals));
266 if(!ret){
267 ogg_stream_clear(os);
268 return -1;
269 }
270 os->granule_vals=ret;
271 os->lacing_storage+=(needed+32);
272 }
273 return 0;
274}
275
276/* checksum the page */
277/* Direct table CRC; note that this will be faster in the future if we
278 perform the checksum simultaneously with other copies */
279
280static void ogg_page_checksum_set(ogg_page *og){
281 if(og){
282 ogg_uint32_t crc_reg=0;
283 int i;
284
285 /* safety; needed for API behavior, but not framing code */
286 og->header[22]=0;
287 og->header[23]=0;
288 og->header[24]=0;
289 og->header[25]=0;
290
291 for(i=0;i<og->header_len;i++)
292 crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)&0xff)^og->header[i]];
293 for(i=0;i<og->body_len;i++)
294 crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)&0xff)^og->body[i]];
295
296 og->header[22]=(unsigned char)(crc_reg&0xff);
297 og->header[23]=(unsigned char)((crc_reg>>8)&0xff);
298 og->header[24]=(unsigned char)((crc_reg>>16)&0xff);
299 og->header[25]=(unsigned char)((crc_reg>>24)&0xff);
300 }
301}
302
303#if 0
304/* submit data to the internal buffer of the framing engine */
305int ogg_stream_iovecin(ogg_stream_state *os, ogg_iovec_t *iov, int count,
306 long e_o_s, ogg_int64_t granulepos){
307
308 int bytes = 0, lacing_vals, i;
309
310 if(ogg_stream_check(os)) return -1;
311 if(!iov) return 0;
312
313 for (i = 0; i < count; ++i) bytes += (int)iov[i].iov_len;
314 lacing_vals=bytes/255+1;
315
316 if(os->body_returned){
317 /* advance packet data according to the body_returned pointer. We
318 had to keep it around to return a pointer into the buffer last
319 call */
320
321 os->body_fill-=os->body_returned;
322 if(os->body_fill)
323 memmove(os->body_data,os->body_data+os->body_returned,
324 os->body_fill);
325 os->body_returned=0;
326 }
327
328 /* make sure we have the buffer storage */
329 if(_os_body_expand(os,bytes) || _os_lacing_expand(os,lacing_vals))
330 return -1;
331
332 /* Copy in the submitted packet. Yes, the copy is a waste; this is
333 the liability of overly clean abstraction for the time being. It
334 will actually be fairly easy to eliminate the extra copy in the
335 future */
336
337 for (i = 0; i < count; ++i) {
338 memcpy(os->body_data+os->body_fill, iov[i].iov_base, iov[i].iov_len);
339 os->body_fill += (int)iov[i].iov_len;
340 }
341
342 /* Store lacing vals for this packet */
343 for(i=0;i<lacing_vals-1;i++){
344 os->lacing_vals[os->lacing_fill+i]=255;
345 os->granule_vals[os->lacing_fill+i]=os->granulepos;
346 }
347 os->lacing_vals[os->lacing_fill+i]=bytes%255;
348 os->granulepos=os->granule_vals[os->lacing_fill+i]=granulepos;
349
350 /* flag the first segment as the beginning of the packet */
351 os->lacing_vals[os->lacing_fill]|= 0x100;
352
353 os->lacing_fill+=lacing_vals;
354
355 /* for the sake of completeness */
356 os->packetno++;
357
358 if(e_o_s)os->e_o_s=1;
359
360 return(0);
361}
362
363int ogg_stream_packetin(ogg_stream_state *os,ogg_packet *op){
364 ogg_iovec_t iov;
365 iov.iov_base = op->packet;
366 iov.iov_len = op->bytes;
367 return ogg_stream_iovecin(os, &iov, 1, op->e_o_s, op->granulepos);
368}
369
370
371/* Conditionally flush a page; force==0 will only flush nominal-size
372 pages, force==1 forces us to flush a page regardless of page size
373 so long as there's any data available at all. */
374static int ogg_stream_flush_i(ogg_stream_state *os,ogg_page *og, int force, int nfill){
375 int i;
376 int vals=0;
377 int maxvals=(os->lacing_fill>255?255:os->lacing_fill);
378 int bytes=0;
379 long acc=0;
380 ogg_int64_t granule_pos=-1;
381
382 if(ogg_stream_check(os)) return(0);
383 if(maxvals==0) return(0);
384
385 /* construct a page */
386 /* decide how many segments to include */
387
388 /* If this is the initial header case, the first page must only include
389 the initial header packet */
390 if(os->b_o_s==0){ /* 'initial header page' case */
391 granule_pos=0;
392 for(vals=0;vals<maxvals;vals++){
393 if((os->lacing_vals[vals]&0x0ff)<255){
394 vals++;
395 break;
396 }
397 }
398 }else{
399
400 /* The extra packets_done, packet_just_done logic here attempts to do two things:
401 1) Don't unneccessarily span pages.
402 2) Unless necessary, don't flush pages if there are less than four packets on
403 them; this expands page size to reduce unneccessary overhead if incoming packets
404 are large.
405 These are not necessary behaviors, just 'always better than naive flushing'
406 without requiring an application to explicitly request a specific optimized
407 behavior. We'll want an explicit behavior setup pathway eventually as well. */
408
409 int packets_done=0;
410 int packet_just_done=0;
411 for(vals=0;vals<maxvals;vals++){
412 if(acc>nfill && packet_just_done>=4){
413 force=1;
414 break;
415 }
416 acc+=os->lacing_vals[vals]&0x0ff;
417 if((os->lacing_vals[vals]&0xff)<255){
418 granule_pos=os->granule_vals[vals];
419 packet_just_done=++packets_done;
420 }else
421 packet_just_done=0;
422 }
423 if(vals==255)force=1;
424 }
425
426 if(!force) return(0);
427
428 /* construct the header in temp storage */
429 memcpy(os->header,"OggS",4);
430
431 /* stream structure version */
432 os->header[4]=0x00;
433
434 /* continued packet flag? */
435 os->header[5]=0x00;
436 if((os->lacing_vals[0]&0x100)==0)os->header[5]|=0x01;
437 /* first page flag? */
438 if(os->b_o_s==0)os->header[5]|=0x02;
439 /* last page flag? */
440 if(os->e_o_s && os->lacing_fill==vals)os->header[5]|=0x04;
441 os->b_o_s=1;
442
443 /* 64 bits of PCM position */
444 for(i=6;i<14;i++){
445 os->header[i]=(unsigned char)(granule_pos&0xff);
446 granule_pos>>=8;
447 }
448
449 /* 32 bits of stream serial number */
450 {
451 long serialno=os->serialno;
452 for(i=14;i<18;i++){
453 os->header[i]=(unsigned char)(serialno&0xff);
454 serialno>>=8;
455 }
456 }
457
458 /* 32 bits of page counter (we have both counter and page header
459 because this val can roll over) */
460 if(os->pageno==-1)os->pageno=0; /* because someone called
461 stream_reset; this would be a
462 strange thing to do in an
463 encode stream, but it has
464 plausible uses */
465 {
466 long pageno=os->pageno++;
467 for(i=18;i<22;i++){
468 os->header[i]=(unsigned char)(pageno&0xff);
469 pageno>>=8;
470 }
471 }
472
473 /* zero for computation; filled in later */
474 os->header[22]=0;
475 os->header[23]=0;
476 os->header[24]=0;
477 os->header[25]=0;
478
479 /* segment table */
480 os->header[26]=(unsigned char)(vals&0xff);
481 for(i=0;i<vals;i++)
482 bytes+=os->header[i+27]=(unsigned char)(os->lacing_vals[i]&0xff);
483
484 /* set pointers in the ogg_page struct */
485 og->header=os->header;
486 og->header_len=os->header_fill=vals+27;
487 og->body=os->body_data+os->body_returned;
488 og->body_len=bytes;
489
490 /* advance the lacing data and set the body_returned pointer */
491
492 os->lacing_fill-=vals;
493 memmove(os->lacing_vals,os->lacing_vals+vals,os->lacing_fill*sizeof(*os->lacing_vals));
494 memmove(os->granule_vals,os->granule_vals+vals,os->lacing_fill*sizeof(*os->granule_vals));
495 os->body_returned+=bytes;
496
497 /* calculate the checksum */
498
499 ogg_page_checksum_set(og);
500
501 /* done */
502 return(1);
503}
504
505/* This will flush remaining packets into a page (returning nonzero),
506 even if there is not enough data to trigger a flush normally
507 (undersized page). If there are no packets or partial packets to
508 flush, ogg_stream_flush returns 0. Note that ogg_stream_flush will
509 try to flush a normal sized page like ogg_stream_pageout; a call to
510 ogg_stream_flush does not guarantee that all packets have flushed.
511 Only a return value of 0 from ogg_stream_flush indicates all packet
512 data is flushed into pages.
513
514 since ogg_stream_flush will flush the last page in a stream even if
515 it's undersized, you almost certainly want to use ogg_stream_pageout
516 (and *not* ogg_stream_flush) unless you specifically need to flush
517 an page regardless of size in the middle of a stream. */
518
519int ogg_stream_flush(ogg_stream_state *os,ogg_page *og){
520 return ogg_stream_flush_i(os,og,1,4096);
521}
522
523/* This constructs pages from buffered packet segments. The pointers
524returned are to static buffers; do not free. The returned buffers are
525good only until the next call (using the same ogg_stream_state) */
526
527int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og){
528 int force=0;
529 if(ogg_stream_check(os)) return 0;
530
531 if((os->e_o_s&&os->lacing_fill) || /* 'were done, now flush' case */
532 (os->lacing_fill&&!os->b_o_s)) /* 'initial header page' case */
533 force=1;
534
535 return(ogg_stream_flush_i(os,og,force,4096));
536}
537
538/* Like the above, but an argument is provided to adjust the nominal
539page size for applications which are smart enough to provide their
540own delay based flushing */
541
542int ogg_stream_pageout_fill(ogg_stream_state *os, ogg_page *og, int nfill){
543 int force=0;
544 if(ogg_stream_check(os)) return 0;
545
546 if((os->e_o_s&&os->lacing_fill) || /* 'were done, now flush' case */
547 (os->lacing_fill&&!os->b_o_s)) /* 'initial header page' case */
548 force=1;
549
550 return(ogg_stream_flush_i(os,og,force,nfill));
551}
552
553int ogg_stream_eos(ogg_stream_state *os){
554 if(ogg_stream_check(os)) return 1;
555 return os->e_o_s;
556}
557#endif
558/* DECODING PRIMITIVES: packet streaming layer **********************/
559
560/* This has two layers to place more of the multi-serialno and paging
561 control in the application's hands. First, we expose a data buffer
562 using ogg_sync_buffer(). The app either copies into the
563 buffer, or passes it directly to read(), etc. We then call
564 ogg_sync_wrote() to tell how many bytes we just added.
565
566 Pages are returned (pointers into the buffer in ogg_sync_state)
567 by ogg_sync_pageout(). The page is then submitted to
568 ogg_stream_pagein() along with the appropriate
569 ogg_stream_state* (ie, matching serialno). We then get raw
570 packets out calling ogg_stream_packetout() with a
571 ogg_stream_state. */
572
573/* initialize the struct to a known state */
574int ogg_sync_init(ogg_sync_state *oy){
575 if(oy){
576 oy->storage = -1; /* used as a readiness flag */
577 memset(oy,0,sizeof(*oy));
578 }
579 return(0);
580}
581
582/* clear non-flat storage within */
583int ogg_sync_clear(ogg_sync_state *oy){
584 if(oy){
585 if(oy->data)_ogg_free(oy->data);
586 memset(oy,0,sizeof(*oy));
587 }
588 return(0);
589}
590
591/*
592int ogg_sync_destroy(ogg_sync_state *oy){
593 if(oy){
594 ogg_sync_clear(oy);
595 _ogg_free(oy);
596 }
597 return(0);
598}
599*/
600static int ogg_sync_check(ogg_sync_state *oy){
601 if(oy->storage<0) return -1;
602 return 0;
603}
604
605char *ogg_sync_buffer(ogg_sync_state *oy, long size){
606 if(ogg_sync_check(oy)) return NULL;
607
608 /* first, clear out any space that has been previously returned */
609 if(oy->returned){
610 oy->fill-=oy->returned;
611 if(oy->fill>0)
612 memmove(oy->data,oy->data+oy->returned,oy->fill);
613 oy->returned=0;
614 }
615
616 if(size>oy->storage-oy->fill){
617 /* We need to extend the internal buffer */
618 long newsize=size+oy->fill+4096; /* an extra page to be nice */
619 void *ret;
620
621 if(oy->data)
622 ret=_ogg_realloc(oy->data,newsize);
623 else
624 ret=_ogg_malloc(newsize);
625 if(!ret){
626 ogg_sync_clear(oy);
627 return NULL;
628 }
629 oy->data=ret;
630 oy->storage=newsize;
631 }
632
633 /* expose a segment at least as large as requested at the fill mark */
634 return((char *)oy->data+oy->fill);
635}
636
637int ogg_sync_wrote(ogg_sync_state *oy, long bytes){
638 if(ogg_sync_check(oy))return -1;
639 if(oy->fill+bytes>oy->storage)return -1;
640 oy->fill+=bytes;
641 return(0);
642}
643
644/* sync the stream. This is meant to be useful for finding page
645 boundaries.
646
647 return values for this:
648 -n) skipped n bytes
649 0) page not ready; more data (no bytes skipped)
650 n) page synced at current location; page length n bytes
651
652*/
653
654long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og){
655 unsigned char *page=oy->data+oy->returned;
656 unsigned char *next;
657 long bytes=oy->fill-oy->returned;
658
659 if(ogg_sync_check(oy))return 0;
660
661 if(oy->headerbytes==0){
662 int headerbytes,i;
663 if(bytes<27)return(0); /* not enough for a header */
664
665 /* verify capture pattern */
666 if(memcmp(page,"OggS",4))goto sync_fail;
667
668 headerbytes=page[26]+27;
669 if(bytes<headerbytes)return(0); /* not enough for header + seg table */
670
671 /* count up body length in the segment table */
672
673 for(i=0;i<page[26];i++)
674 oy->bodybytes+=page[27+i];
675 oy->headerbytes=headerbytes;
676 }
677
678 if(oy->bodybytes+oy->headerbytes>bytes)return(0);
679
680 /* The whole test page is buffered. Verify the checksum */
681 {
682 /* Grab the checksum bytes, set the header field to zero */
683 char chksum[4];
684 ogg_page log;
685
686 memcpy(chksum,page+22,4);
687 memset(page+22,0,4);
688
689 /* set up a temp page struct and recompute the checksum */
690 log.header=page;
691 log.header_len=oy->headerbytes;
692 log.body=page+oy->headerbytes;
693 log.body_len=oy->bodybytes;
694 ogg_page_checksum_set(&log);
695
696 /* Compare */
697 if(memcmp(chksum,page+22,4)){
698 /* D'oh. Mismatch! Corrupt page (or miscapture and not a page
699 at all) */
700 /* replace the computed checksum with the one actually read in */
701 memcpy(page+22,chksum,4);
702
703 /* Bad checksum. Lose sync */
704 goto sync_fail;
705 }
706 }
707
708 /* yes, have a whole page all ready to go */
709 {
710 unsigned char *page=oy->data+oy->returned;
711 long bytes;
712
713 if(og){
714 og->header=page;
715 og->header_len=oy->headerbytes;
716 og->body=page+oy->headerbytes;
717 og->body_len=oy->bodybytes;
718 }
719
720 oy->unsynced=0;
721 oy->returned+=(bytes=oy->headerbytes+oy->bodybytes);
722 oy->headerbytes=0;
723 oy->bodybytes=0;
724 return(bytes);
725 }
726
727 sync_fail:
728
729 oy->headerbytes=0;
730 oy->bodybytes=0;
731
732 /* search for possible capture */
733 next=memchr(page+1,'O',bytes-1);
734 if(!next)
735 next=oy->data+oy->fill;
736
737 oy->returned=(int)(next-oy->data);
738 return((long)-(next-page));
739}
740
741/* sync the stream and get a page. Keep trying until we find a page.
742 Suppress 'sync errors' after reporting the first.
743
744 return values:
745 -1) recapture (hole in data)
746 0) need more data
747 1) page returned
748
749 Returns pointers into buffered data; invalidated by next call to
750 _stream, _clear, _init, or _buffer */
751
752#if 0
753int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og){
754
755 if(ogg_sync_check(oy))return 0;
756
757 /* all we need to do is verify a page at the head of the stream
758 buffer. If it doesn't verify, we look for the next potential
759 frame */
760
761 for(;;){
762 long ret=ogg_sync_pageseek(oy,og);
763 if(ret>0){
764 /* have a page */
765 return(1);
766 }
767 if(ret==0){
768 /* need more data */
769 return(0);
770 }
771
772 /* head did not start a synced page... skipped some bytes */
773 if(!oy->unsynced){
774 oy->unsynced=1;
775 return(-1);
776 }
777
778 /* loop. keep looking */
779
780 }
781}
782#endif
783/* add the incoming page to the stream state; we decompose the page
784 into packet segments here as well. */
785
786int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og, bool copy_body){
787 unsigned char *header=og->header;
788 unsigned char *body=og->body;
789 long bodysize=og->body_len;
790 int segptr=0;
791
792 int version=ogg_page_version(og);
793 int continued=ogg_page_continued(og);
794 int bos=ogg_page_bos(og);
795 int eos=ogg_page_eos(og);
796 ogg_int64_t granulepos=ogg_page_granulepos(og);
797 ogg_uint32_t serialno=ogg_page_serialno(og);
798 long pageno=ogg_page_pageno(og);
799 int segments=header[26];
800
801 if(ogg_stream_check(os)) return -1;
802
803 /* clean up 'returned data' */
804 {
805 long lr=os->lacing_returned;
806 long br=os->body_returned;
807
808 /* body data */
809 if(br){
810 os->body_fill-=br;
811 if(os->body_fill)
812 memmove(os->body_data,os->body_data+br,os->body_fill);
813 os->body_returned=0;
814 }
815
816 if(lr){
817 /* segment table */
818 if(os->lacing_fill-lr){
819 memmove(os->lacing_vals,os->lacing_vals+lr,
820 (os->lacing_fill-lr)*sizeof(*os->lacing_vals));
821 memmove(os->granule_vals,os->granule_vals+lr,
822 (os->lacing_fill-lr)*sizeof(*os->granule_vals));
823 }
824 os->lacing_fill-=lr;
825 os->lacing_packet-=lr;
826 os->lacing_returned=0;
827 }
828 }
829
830 /* check the serial number */
831 if(serialno!=os->serialno)return(-1);
832 if(version>0)return(-1);
833
834 if(_os_lacing_expand(os,segments+1)) return -1;
835
836 /* are we in sequence? */
837 if(pageno!=os->pageno){
838 int i;
839
840 /* unroll previous partial packet (if any) */
841 for(i=os->lacing_packet;i<os->lacing_fill;i++)
842 os->body_fill-=os->lacing_vals[i]&0xff;
843 os->lacing_fill=os->lacing_packet;
844
845 /* make a note of dropped data in segment table */
846 if(os->pageno!=-1){
847 os->lacing_vals[os->lacing_fill++]=0x400;
848 os->lacing_packet++;
849 }
850 }
851
852 /* are we a 'continued packet' page? If so, we may need to skip
853 some segments */
854 if(continued){
855 if(os->lacing_fill<1 ||
856 os->lacing_vals[os->lacing_fill-1]==0x400){
857 bos=0;
858 for(;segptr<segments;segptr++){
859 int val=header[27+segptr];
860 body+=val;
861 bodysize-=val;
862 if(val<255){
863 segptr++;
864 break;
865 }
866 }
867 }
868 }
869
870 if(bodysize){
871 if(copy_body){
872 if(_os_body_expand(os,bodysize)) return -1;
873 memcpy(os->body_data+os->body_fill,body,bodysize);
874 }
875 os->body_fill+=bodysize;
876 }
877
878 {
879 int saved=-1;
880 while(segptr<segments){
881 int val=header[27+segptr];
882 os->lacing_vals[os->lacing_fill]=val;
883 os->granule_vals[os->lacing_fill]=-1;
884
885 if(bos){
886 os->lacing_vals[os->lacing_fill]|=0x100;
887 bos=0;
888 }
889
890 if(val<255)saved=os->lacing_fill;
891
892 os->lacing_fill++;
893 segptr++;
894
895 if(val<255)os->lacing_packet=os->lacing_fill;
896 }
897
898 /* set the granulepos on the last granuleval of the last full packet */
899 if(saved!=-1){
900 os->granule_vals[saved]=granulepos;
901 }
902
903 }
904
905 if(eos){
906 os->e_o_s=1;
907 if(os->lacing_fill>0)
908 os->lacing_vals[os->lacing_fill-1]|=0x200;
909 }
910
911 os->pageno=pageno+1;
912
913 return(0);
914}
915
916/* clear things to an initial state. Good to call, eg, before seeking */
917int ogg_sync_reset(ogg_sync_state *oy){
918 if(ogg_sync_check(oy))return -1;
919
920 oy->fill=0;
921 oy->returned=0;
922 oy->unsynced=0;
923 oy->headerbytes=0;
924 oy->bodybytes=0;
925 return(0);
926}
927
928int ogg_stream_reset(ogg_stream_state *os){
929 if(ogg_stream_check(os)) return -1;
930
931 os->body_fill=0;
932 os->body_returned=0;
933
934 os->lacing_fill=0;
935 os->lacing_packet=0;
936 os->lacing_returned=0;
937
938/* os->header_fill=0; */
939
940 os->e_o_s=0;
941 os->b_o_s=0;
942 os->pageno=-1;
943 os->packetno=0;
944 os->granulepos=0;
945
946 return(0);
947}
948
949int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno){
950 if(ogg_stream_check(os)) return -1;
951 ogg_stream_reset(os);
952 os->serialno=serialno;
953 return(0);
954}
955
956static int _packetout(ogg_stream_state *os,ogg_packet *op,int adv)
957 ICODE_ATTR_TREMOR_NOT_MDCT;
958static int _packetout(ogg_stream_state *os,ogg_packet *op,int adv){
959
960 /* The last part of decode. We have the stream broken into packet
961 segments. Now we need to group them into packets (or return the
962 out of sync markers) */
963
964 int ptr=os->lacing_returned;
965
966 if(os->lacing_packet<=ptr)return(0);
967
968 if(os->lacing_vals[ptr]&0x400){
969 /* we need to tell the codec there's a gap; it might need to
970 handle previous packet dependencies. */
971 os->lacing_returned++;
972 os->packetno++;
973 return(-1);
974 }
975
976 if(!op && !adv)return(1); /* just using peek as an inexpensive way
977 to ask if there's a whole packet
978 waiting */
979
980 /* Gather the whole packet. We'll have no holes or a partial packet */
981 {
982 int size=os->lacing_vals[ptr]&0xff;
983 long bytes=size;
984 int eos=os->lacing_vals[ptr]&0x200; /* last packet of the stream? */
985 int bos=os->lacing_vals[ptr]&0x100; /* first packet of the stream? */
986
987 while(size==255){
988 int val=os->lacing_vals[++ptr];
989 size=val&0xff;
990 if(val&0x200)eos=0x200;
991 bytes+=size;
992 }
993
994 if(op){
995 op->e_o_s=eos;
996 op->b_o_s=bos;
997 op->packet=os->body_data+os->body_returned;
998 op->packetno=os->packetno;
999 op->granulepos=os->granule_vals[ptr];
1000 op->bytes=bytes;
1001 }
1002
1003 if(adv){
1004 os->body_returned+=bytes;
1005 os->lacing_returned=ptr+1;
1006 os->packetno++;
1007 }
1008 }
1009 return(1);
1010}
1011
1012int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op)
1013 ICODE_ATTR_TREMOR_NOT_MDCT;
1014int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op){
1015 if(ogg_stream_check(os)) return 0;
1016 return _packetout(os,op,1);
1017}
1018
1019int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op)
1020 ICODE_ATTR_TREMOR_NOT_MDCT;
1021int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op){
1022 if(ogg_stream_check(os)) return 0;
1023 return _packetout(os,op,0);
1024}
1025
1026/*
1027void ogg_packet_clear(ogg_packet *op) {
1028 _ogg_free(op->packet);
1029 memset(op, 0, sizeof(*op));
1030}
1031*/
1032#ifdef _V_SELFTEST
1033#include <stdio.h>
1034
1035ogg_stream_state os_en, os_de;
1036ogg_sync_state oy;
1037
1038void checkpacket(ogg_packet *op,long len, int no, long pos){
1039 long j;
1040 static int sequence=0;
1041 static int lastno=0;
1042
1043 if(op->bytes!=len){
1044 fprintf(stderr,"incorrect packet length (%ld != %ld)!\n",op->bytes,len);
1045 exit(1);
1046 }
1047 if(op->granulepos!=pos){
1048 fprintf(stderr,"incorrect packet granpos (%ld != %ld)!\n",(long)op->granulepos,pos);
1049 exit(1);
1050 }
1051
1052 /* packet number just follows sequence/gap; adjust the input number
1053 for that */
1054 if(no==0){
1055 sequence=0;
1056 }else{
1057 sequence++;
1058 if(no>lastno+1)
1059 sequence++;
1060 }
1061 lastno=no;
1062 if(op->packetno!=sequence){
1063 fprintf(stderr,"incorrect packet sequence %ld != %d\n",
1064 (long)(op->packetno),sequence);
1065 exit(1);
1066 }
1067
1068 /* Test data */
1069 for(j=0;j<op->bytes;j++)
1070 if(op->packet[j]!=((j+no)&0xff)){
1071 fprintf(stderr,"body data mismatch (1) at pos %ld: %x!=%lx!\n\n",
1072 j,op->packet[j],(j+no)&0xff);
1073 exit(1);
1074 }
1075}
1076
1077void check_page(unsigned char *data,const int *header,ogg_page *og){
1078 long j;
1079 /* Test data */
1080 for(j=0;j<og->body_len;j++)
1081 if(og->body[j]!=data[j]){
1082 fprintf(stderr,"body data mismatch (2) at pos %ld: %x!=%x!\n\n",
1083 j,data[j],og->body[j]);
1084 exit(1);
1085 }
1086
1087 /* Test header */
1088 for(j=0;j<og->header_len;j++){
1089 if(og->header[j]!=header[j]){
1090 fprintf(stderr,"header content mismatch at pos %ld:\n",j);
1091 for(j=0;j<header[26]+27;j++)
1092 fprintf(stderr," (%ld)%02x:%02x",j,header[j],og->header[j]);
1093 fprintf(stderr,"\n");
1094 exit(1);
1095 }
1096 }
1097 if(og->header_len!=header[26]+27){
1098 fprintf(stderr,"header length incorrect! (%ld!=%d)\n",
1099 og->header_len,header[26]+27);
1100 exit(1);
1101 }
1102}
1103
1104void print_header(ogg_page *og){
1105 int j;
1106 fprintf(stderr,"\nHEADER:\n");
1107 fprintf(stderr," capture: %c %c %c %c version: %d flags: %x\n",
1108 og->header[0],og->header[1],og->header[2],og->header[3],
1109 (int)og->header[4],(int)og->header[5]);
1110
1111 fprintf(stderr," granulepos: %d serialno: %d pageno: %ld\n",
1112 (og->header[9]<<24)|(og->header[8]<<16)|
1113 (og->header[7]<<8)|og->header[6],
1114 (og->header[17]<<24)|(og->header[16]<<16)|
1115 (og->header[15]<<8)|og->header[14],
1116 ((long)(og->header[21])<<24)|(og->header[20]<<16)|
1117 (og->header[19]<<8)|og->header[18]);
1118
1119 fprintf(stderr," checksum: %02x:%02x:%02x:%02x\n segments: %d (",
1120 (int)og->header[22],(int)og->header[23],
1121 (int)og->header[24],(int)og->header[25],
1122 (int)og->header[26]);
1123
1124 for(j=27;j<og->header_len;j++)
1125 fprintf(stderr,"%d ",(int)og->header[j]);
1126 fprintf(stderr,")\n\n");
1127}
1128
1129void copy_page(ogg_page *og){
1130 unsigned char *temp=_ogg_malloc(og->header_len);
1131 memcpy(temp,og->header,og->header_len);
1132 og->header=temp;
1133
1134 temp=_ogg_malloc(og->body_len);
1135 memcpy(temp,og->body,og->body_len);
1136 og->body=temp;
1137}
1138
1139void free_page(ogg_page *og){
1140 _ogg_free (og->header);
1141 _ogg_free (og->body);
1142}
1143
1144void error(void){
1145 fprintf(stderr,"error!\n");
1146 exit(1);
1147}
1148
1149/* 17 only */
1150const int head1_0[] = {0x4f,0x67,0x67,0x53,0,0x06,
1151 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1152 0x01,0x02,0x03,0x04,0,0,0,0,
1153 0x15,0xed,0xec,0x91,
1154 1,
1155 17};
1156
1157/* 17, 254, 255, 256, 500, 510, 600 byte, pad */
1158const int head1_1[] = {0x4f,0x67,0x67,0x53,0,0x02,
1159 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1160 0x01,0x02,0x03,0x04,0,0,0,0,
1161 0x59,0x10,0x6c,0x2c,
1162 1,
1163 17};
1164const int head2_1[] = {0x4f,0x67,0x67,0x53,0,0x04,
1165 0x07,0x18,0x00,0x00,0x00,0x00,0x00,0x00,
1166 0x01,0x02,0x03,0x04,1,0,0,0,
1167 0x89,0x33,0x85,0xce,
1168 13,
1169 254,255,0,255,1,255,245,255,255,0,
1170 255,255,90};
1171
1172/* nil packets; beginning,middle,end */
1173const int head1_2[] = {0x4f,0x67,0x67,0x53,0,0x02,
1174 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1175 0x01,0x02,0x03,0x04,0,0,0,0,
1176 0xff,0x7b,0x23,0x17,
1177 1,
1178 0};
1179const int head2_2[] = {0x4f,0x67,0x67,0x53,0,0x04,
1180 0x07,0x28,0x00,0x00,0x00,0x00,0x00,0x00,
1181 0x01,0x02,0x03,0x04,1,0,0,0,
1182 0x5c,0x3f,0x66,0xcb,
1183 17,
1184 17,254,255,0,0,255,1,0,255,245,255,255,0,
1185 255,255,90,0};
1186
1187/* large initial packet */
1188const int head1_3[] = {0x4f,0x67,0x67,0x53,0,0x02,
1189 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1190 0x01,0x02,0x03,0x04,0,0,0,0,
1191 0x01,0x27,0x31,0xaa,
1192 18,
1193 255,255,255,255,255,255,255,255,
1194 255,255,255,255,255,255,255,255,255,10};
1195
1196const int head2_3[] = {0x4f,0x67,0x67,0x53,0,0x04,
1197 0x07,0x08,0x00,0x00,0x00,0x00,0x00,0x00,
1198 0x01,0x02,0x03,0x04,1,0,0,0,
1199 0x7f,0x4e,0x8a,0xd2,
1200 4,
1201 255,4,255,0};
1202
1203
1204/* continuing packet test */
1205const int head1_4[] = {0x4f,0x67,0x67,0x53,0,0x02,
1206 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1207 0x01,0x02,0x03,0x04,0,0,0,0,
1208 0xff,0x7b,0x23,0x17,
1209 1,
1210 0};
1211
1212const int head2_4[] = {0x4f,0x67,0x67,0x53,0,0x00,
1213 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
1214 0x01,0x02,0x03,0x04,1,0,0,0,
1215 0xf8,0x3c,0x19,0x79,
1216 255,
1217 255,255,255,255,255,255,255,255,
1218 255,255,255,255,255,255,255,255,
1219 255,255,255,255,255,255,255,255,
1220 255,255,255,255,255,255,255,255,
1221 255,255,255,255,255,255,255,255,
1222 255,255,255,255,255,255,255,255,
1223 255,255,255,255,255,255,255,255,
1224 255,255,255,255,255,255,255,255,
1225 255,255,255,255,255,255,255,255,
1226 255,255,255,255,255,255,255,255,
1227 255,255,255,255,255,255,255,255,
1228 255,255,255,255,255,255,255,255,
1229 255,255,255,255,255,255,255,255,
1230 255,255,255,255,255,255,255,255,
1231 255,255,255,255,255,255,255,255,
1232 255,255,255,255,255,255,255,255,
1233 255,255,255,255,255,255,255,255,
1234 255,255,255,255,255,255,255,255,
1235 255,255,255,255,255,255,255,255,
1236 255,255,255,255,255,255,255,255,
1237 255,255,255,255,255,255,255,255,
1238 255,255,255,255,255,255,255,255,
1239 255,255,255,255,255,255,255,255,
1240 255,255,255,255,255,255,255,255,
1241 255,255,255,255,255,255,255,255,
1242 255,255,255,255,255,255,255,255,
1243 255,255,255,255,255,255,255,255,
1244 255,255,255,255,255,255,255,255,
1245 255,255,255,255,255,255,255,255,
1246 255,255,255,255,255,255,255,255,
1247 255,255,255,255,255,255,255,255,
1248 255,255,255,255,255,255,255};
1249
1250const int head3_4[] = {0x4f,0x67,0x67,0x53,0,0x05,
1251 0x07,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,
1252 0x01,0x02,0x03,0x04,2,0,0,0,
1253 0x38,0xe6,0xb6,0x28,
1254 6,
1255 255,220,255,4,255,0};
1256
1257
1258/* spill expansion test */
1259const int head1_4b[] = {0x4f,0x67,0x67,0x53,0,0x02,
1260 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1261 0x01,0x02,0x03,0x04,0,0,0,0,
1262 0xff,0x7b,0x23,0x17,
1263 1,
1264 0};
1265
1266const int head2_4b[] = {0x4f,0x67,0x67,0x53,0,0x00,
1267 0x07,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
1268 0x01,0x02,0x03,0x04,1,0,0,0,
1269 0xce,0x8f,0x17,0x1a,
1270 23,
1271 255,255,255,255,255,255,255,255,
1272 255,255,255,255,255,255,255,255,255,10,255,4,255,0,0};
1273
1274
1275const int head3_4b[] = {0x4f,0x67,0x67,0x53,0,0x04,
1276 0x07,0x14,0x00,0x00,0x00,0x00,0x00,0x00,
1277 0x01,0x02,0x03,0x04,2,0,0,0,
1278 0x9b,0xb2,0x50,0xa1,
1279 1,
1280 0};
1281
1282/* page with the 255 segment limit */
1283const int head1_5[] = {0x4f,0x67,0x67,0x53,0,0x02,
1284 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1285 0x01,0x02,0x03,0x04,0,0,0,0,
1286 0xff,0x7b,0x23,0x17,
1287 1,
1288 0};
1289
1290const int head2_5[] = {0x4f,0x67,0x67,0x53,0,0x00,
1291 0x07,0xfc,0x03,0x00,0x00,0x00,0x00,0x00,
1292 0x01,0x02,0x03,0x04,1,0,0,0,
1293 0xed,0x2a,0x2e,0xa7,
1294 255,
1295 10,10,10,10,10,10,10,10,
1296 10,10,10,10,10,10,10,10,
1297 10,10,10,10,10,10,10,10,
1298 10,10,10,10,10,10,10,10,
1299 10,10,10,10,10,10,10,10,
1300 10,10,10,10,10,10,10,10,
1301 10,10,10,10,10,10,10,10,
1302 10,10,10,10,10,10,10,10,
1303 10,10,10,10,10,10,10,10,
1304 10,10,10,10,10,10,10,10,
1305 10,10,10,10,10,10,10,10,
1306 10,10,10,10,10,10,10,10,
1307 10,10,10,10,10,10,10,10,
1308 10,10,10,10,10,10,10,10,
1309 10,10,10,10,10,10,10,10,
1310 10,10,10,10,10,10,10,10,
1311 10,10,10,10,10,10,10,10,
1312 10,10,10,10,10,10,10,10,
1313 10,10,10,10,10,10,10,10,
1314 10,10,10,10,10,10,10,10,
1315 10,10,10,10,10,10,10,10,
1316 10,10,10,10,10,10,10,10,
1317 10,10,10,10,10,10,10,10,
1318 10,10,10,10,10,10,10,10,
1319 10,10,10,10,10,10,10,10,
1320 10,10,10,10,10,10,10,10,
1321 10,10,10,10,10,10,10,10,
1322 10,10,10,10,10,10,10,10,
1323 10,10,10,10,10,10,10,10,
1324 10,10,10,10,10,10,10,10,
1325 10,10,10,10,10,10,10,10,
1326 10,10,10,10,10,10,10};
1327
1328const int head3_5[] = {0x4f,0x67,0x67,0x53,0,0x04,
1329 0x07,0x00,0x04,0x00,0x00,0x00,0x00,0x00,
1330 0x01,0x02,0x03,0x04,2,0,0,0,
1331 0x6c,0x3b,0x82,0x3d,
1332 1,
1333 50};
1334
1335
1336/* packet that overspans over an entire page */
1337const int head1_6[] = {0x4f,0x67,0x67,0x53,0,0x02,
1338 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1339 0x01,0x02,0x03,0x04,0,0,0,0,
1340 0xff,0x7b,0x23,0x17,
1341 1,
1342 0};
1343
1344const int head2_6[] = {0x4f,0x67,0x67,0x53,0,0x00,
1345 0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,
1346 0x01,0x02,0x03,0x04,1,0,0,0,
1347 0x68,0x22,0x7c,0x3d,
1348 255,
1349 100,
1350 255,255,255,255,255,255,255,255,
1351 255,255,255,255,255,255,255,255,
1352 255,255,255,255,255,255,255,255,
1353 255,255,255,255,255,255,255,255,
1354 255,255,255,255,255,255,255,255,
1355 255,255,255,255,255,255,255,255,
1356 255,255,255,255,255,255,255,255,
1357 255,255,255,255,255,255,255,255,
1358 255,255,255,255,255,255,255,255,
1359 255,255,255,255,255,255,255,255,
1360 255,255,255,255,255,255,255,255,
1361 255,255,255,255,255,255,255,255,
1362 255,255,255,255,255,255,255,255,
1363 255,255,255,255,255,255,255,255,
1364 255,255,255,255,255,255,255,255,
1365 255,255,255,255,255,255,255,255,
1366 255,255,255,255,255,255,255,255,
1367 255,255,255,255,255,255,255,255,
1368 255,255,255,255,255,255,255,255,
1369 255,255,255,255,255,255,255,255,
1370 255,255,255,255,255,255,255,255,
1371 255,255,255,255,255,255,255,255,
1372 255,255,255,255,255,255,255,255,
1373 255,255,255,255,255,255,255,255,
1374 255,255,255,255,255,255,255,255,
1375 255,255,255,255,255,255,255,255,
1376 255,255,255,255,255,255,255,255,
1377 255,255,255,255,255,255,255,255,
1378 255,255,255,255,255,255,255,255,
1379 255,255,255,255,255,255,255,255,
1380 255,255,255,255,255,255,255,255,
1381 255,255,255,255,255,255};
1382
1383const int head3_6[] = {0x4f,0x67,0x67,0x53,0,0x01,
1384 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
1385 0x01,0x02,0x03,0x04,2,0,0,0,
1386 0xf4,0x87,0xba,0xf3,
1387 255,
1388 255,255,255,255,255,255,255,255,
1389 255,255,255,255,255,255,255,255,
1390 255,255,255,255,255,255,255,255,
1391 255,255,255,255,255,255,255,255,
1392 255,255,255,255,255,255,255,255,
1393 255,255,255,255,255,255,255,255,
1394 255,255,255,255,255,255,255,255,
1395 255,255,255,255,255,255,255,255,
1396 255,255,255,255,255,255,255,255,
1397 255,255,255,255,255,255,255,255,
1398 255,255,255,255,255,255,255,255,
1399 255,255,255,255,255,255,255,255,
1400 255,255,255,255,255,255,255,255,
1401 255,255,255,255,255,255,255,255,
1402 255,255,255,255,255,255,255,255,
1403 255,255,255,255,255,255,255,255,
1404 255,255,255,255,255,255,255,255,
1405 255,255,255,255,255,255,255,255,
1406 255,255,255,255,255,255,255,255,
1407 255,255,255,255,255,255,255,255,
1408 255,255,255,255,255,255,255,255,
1409 255,255,255,255,255,255,255,255,
1410 255,255,255,255,255,255,255,255,
1411 255,255,255,255,255,255,255,255,
1412 255,255,255,255,255,255,255,255,
1413 255,255,255,255,255,255,255,255,
1414 255,255,255,255,255,255,255,255,
1415 255,255,255,255,255,255,255,255,
1416 255,255,255,255,255,255,255,255,
1417 255,255,255,255,255,255,255,255,
1418 255,255,255,255,255,255,255,255,
1419 255,255,255,255,255,255,255};
1420
1421const int head4_6[] = {0x4f,0x67,0x67,0x53,0,0x05,
1422 0x07,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
1423 0x01,0x02,0x03,0x04,3,0,0,0,
1424 0xf7,0x2f,0x6c,0x60,
1425 5,
1426 254,255,4,255,0};
1427
1428/* packet that overspans over an entire page */
1429const int head1_7[] = {0x4f,0x67,0x67,0x53,0,0x02,
1430 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1431 0x01,0x02,0x03,0x04,0,0,0,0,
1432 0xff,0x7b,0x23,0x17,
1433 1,
1434 0};
1435
1436const int head2_7[] = {0x4f,0x67,0x67,0x53,0,0x00,
1437 0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,
1438 0x01,0x02,0x03,0x04,1,0,0,0,
1439 0x68,0x22,0x7c,0x3d,
1440 255,
1441 100,
1442 255,255,255,255,255,255,255,255,
1443 255,255,255,255,255,255,255,255,
1444 255,255,255,255,255,255,255,255,
1445 255,255,255,255,255,255,255,255,
1446 255,255,255,255,255,255,255,255,
1447 255,255,255,255,255,255,255,255,
1448 255,255,255,255,255,255,255,255,
1449 255,255,255,255,255,255,255,255,
1450 255,255,255,255,255,255,255,255,
1451 255,255,255,255,255,255,255,255,
1452 255,255,255,255,255,255,255,255,
1453 255,255,255,255,255,255,255,255,
1454 255,255,255,255,255,255,255,255,
1455 255,255,255,255,255,255,255,255,
1456 255,255,255,255,255,255,255,255,
1457 255,255,255,255,255,255,255,255,
1458 255,255,255,255,255,255,255,255,
1459 255,255,255,255,255,255,255,255,
1460 255,255,255,255,255,255,255,255,
1461 255,255,255,255,255,255,255,255,
1462 255,255,255,255,255,255,255,255,
1463 255,255,255,255,255,255,255,255,
1464 255,255,255,255,255,255,255,255,
1465 255,255,255,255,255,255,255,255,
1466 255,255,255,255,255,255,255,255,
1467 255,255,255,255,255,255,255,255,
1468 255,255,255,255,255,255,255,255,
1469 255,255,255,255,255,255,255,255,
1470 255,255,255,255,255,255,255,255,
1471 255,255,255,255,255,255,255,255,
1472 255,255,255,255,255,255,255,255,
1473 255,255,255,255,255,255};
1474
1475const int head3_7[] = {0x4f,0x67,0x67,0x53,0,0x05,
1476 0x07,0x08,0x00,0x00,0x00,0x00,0x00,0x00,
1477 0x01,0x02,0x03,0x04,2,0,0,0,
1478 0xd4,0xe0,0x60,0xe5,
1479 1,
1480 0};
1481
1482void test_pack(const int *pl, const int **headers, int byteskip,
1483 int pageskip, int packetskip){
1484 unsigned char *data=_ogg_malloc(1024*1024); /* for scripted test cases only */
1485 long inptr=0;
1486 long outptr=0;
1487 long deptr=0;
1488 long depacket=0;
1489 long granule_pos=7,pageno=0;
1490 int i,j,packets,pageout=pageskip;
1491 int eosflag=0;
1492 int bosflag=0;
1493
1494 int byteskipcount=0;
1495
1496 ogg_stream_reset(&os_en);
1497 ogg_stream_reset(&os_de);
1498 ogg_sync_reset(&oy);
1499
1500 for(packets=0;packets<packetskip;packets++)
1501 depacket+=pl[packets];
1502
1503 for(packets=0;;packets++)if(pl[packets]==-1)break;
1504
1505 for(i=0;i<packets;i++){
1506 /* construct a test packet */
1507 ogg_packet op;
1508 int len=pl[i];
1509
1510 op.packet=data+inptr;
1511 op.bytes=len;
1512 op.e_o_s=(pl[i+1]<0?1:0);
1513 op.granulepos=granule_pos;
1514
1515 granule_pos+=1024;
1516
1517 for(j=0;j<len;j++)data[inptr++]=i+j;
1518
1519 /* submit the test packet */
1520 ogg_stream_packetin(&os_en,&op);
1521
1522 /* retrieve any finished pages */
1523 {
1524 ogg_page og;
1525
1526 while(ogg_stream_pageout(&os_en,&og)){
1527 /* We have a page. Check it carefully */
1528
1529 fprintf(stderr,"%ld, ",pageno);
1530
1531 if(headers[pageno]==NULL){
1532 fprintf(stderr,"coded too many pages!\n");
1533 exit(1);
1534 }
1535
1536 check_page(data+outptr,headers[pageno],&og);
1537
1538 outptr+=og.body_len;
1539 pageno++;
1540 if(pageskip){
1541 bosflag=1;
1542 pageskip--;
1543 deptr+=og.body_len;
1544 }
1545
1546 /* have a complete page; submit it to sync/decode */
1547
1548 {
1549 ogg_page og_de;
1550 ogg_packet op_de,op_de2;
1551 char *buf=ogg_sync_buffer(&oy,og.header_len+og.body_len);
1552 char *next=buf;
1553 byteskipcount+=og.header_len;
1554 if(byteskipcount>byteskip){
1555 memcpy(next,og.header,byteskipcount-byteskip);
1556 next+=byteskipcount-byteskip;
1557 byteskipcount=byteskip;
1558 }
1559
1560 byteskipcount+=og.body_len;
1561 if(byteskipcount>byteskip){
1562 memcpy(next,og.body,byteskipcount-byteskip);
1563 next+=byteskipcount-byteskip;
1564 byteskipcount=byteskip;
1565 }
1566
1567 ogg_sync_wrote(&oy,next-buf);
1568
1569 while(1){
1570 int ret=ogg_sync_pageout(&oy,&og_de);
1571 if(ret==0)break;
1572 if(ret<0)continue;
1573 /* got a page. Happy happy. Verify that it's good. */
1574
1575 fprintf(stderr,"(%d), ",pageout);
1576
1577 check_page(data+deptr,headers[pageout],&og_de);
1578 deptr+=og_de.body_len;
1579 pageout++;
1580
1581 /* submit it to deconstitution */
1582 ogg_stream_pagein(&os_de,&og_de);
1583
1584 /* packets out? */
1585 while(ogg_stream_packetpeek(&os_de,&op_de2)>0){
1586 ogg_stream_packetpeek(&os_de,NULL);
1587 ogg_stream_packetout(&os_de,&op_de); /* just catching them all */
1588
1589 /* verify peek and out match */
1590 if(memcmp(&op_de,&op_de2,sizeof(op_de))){
1591 fprintf(stderr,"packetout != packetpeek! pos=%ld\n",
1592 depacket);
1593 exit(1);
1594 }
1595
1596 /* verify the packet! */
1597 /* check data */
1598 if(memcmp(data+depacket,op_de.packet,op_de.bytes)){
1599 fprintf(stderr,"packet data mismatch in decode! pos=%ld\n",
1600 depacket);
1601 exit(1);
1602 }
1603 /* check bos flag */
1604 if(bosflag==0 && op_de.b_o_s==0){
1605 fprintf(stderr,"b_o_s flag not set on packet!\n");
1606 exit(1);
1607 }
1608 if(bosflag && op_de.b_o_s){
1609 fprintf(stderr,"b_o_s flag incorrectly set on packet!\n");
1610 exit(1);
1611 }
1612 bosflag=1;
1613 depacket+=op_de.bytes;
1614
1615 /* check eos flag */
1616 if(eosflag){
1617 fprintf(stderr,"Multiple decoded packets with eos flag!\n");
1618 exit(1);
1619 }
1620
1621 if(op_de.e_o_s)eosflag=1;
1622
1623 /* check granulepos flag */
1624 if(op_de.granulepos!=-1){
1625 fprintf(stderr," granule:%ld ",(long)op_de.granulepos);
1626 }
1627 }
1628 }
1629 }
1630 }
1631 }
1632 }
1633 _ogg_free(data);
1634 if(headers[pageno]!=NULL){
1635 fprintf(stderr,"did not write last page!\n");
1636 exit(1);
1637 }
1638 if(headers[pageout]!=NULL){
1639 fprintf(stderr,"did not decode last page!\n");
1640 exit(1);
1641 }
1642 if(inptr!=outptr){
1643 fprintf(stderr,"encoded page data incomplete!\n");
1644 exit(1);
1645 }
1646 if(inptr!=deptr){
1647 fprintf(stderr,"decoded page data incomplete!\n");
1648 exit(1);
1649 }
1650 if(inptr!=depacket){
1651 fprintf(stderr,"decoded packet data incomplete!\n");
1652 exit(1);
1653 }
1654 if(!eosflag){
1655 fprintf(stderr,"Never got a packet with EOS set!\n");
1656 exit(1);
1657 }
1658 fprintf(stderr,"ok.\n");
1659}
1660
1661int main(void){
1662
1663 ogg_stream_init(&os_en,0x04030201);
1664 ogg_stream_init(&os_de,0x04030201);
1665 ogg_sync_init(&oy);
1666
1667 /* Exercise each code path in the framing code. Also verify that
1668 the checksums are working. */
1669
1670 {
1671 /* 17 only */
1672 const int packets[]={17, -1};
1673 const int *headret[]={head1_0,NULL};
1674
1675 fprintf(stderr,"testing single page encoding... ");
1676 test_pack(packets,headret,0,0,0);
1677 }
1678
1679 {
1680 /* 17, 254, 255, 256, 500, 510, 600 byte, pad */
1681 const int packets[]={17, 254, 255, 256, 500, 510, 600, -1};
1682 const int *headret[]={head1_1,head2_1,NULL};
1683
1684 fprintf(stderr,"testing basic page encoding... ");
1685 test_pack(packets,headret,0,0,0);
1686 }
1687
1688 {
1689 /* nil packets; beginning,middle,end */
1690 const int packets[]={0,17, 254, 255, 0, 256, 0, 500, 510, 600, 0, -1};
1691 const int *headret[]={head1_2,head2_2,NULL};
1692
1693 fprintf(stderr,"testing basic nil packets... ");
1694 test_pack(packets,headret,0,0,0);
1695 }
1696
1697 {
1698 /* large initial packet */
1699 const int packets[]={4345,259,255,-1};
1700 const int *headret[]={head1_3,head2_3,NULL};
1701
1702 fprintf(stderr,"testing initial-packet lacing > 4k... ");
1703 test_pack(packets,headret,0,0,0);
1704 }
1705
1706 {
1707 /* continuing packet test; with page spill expansion, we have to
1708 overflow the lacing table. */
1709 const int packets[]={0,65500,259,255,-1};
1710 const int *headret[]={head1_4,head2_4,head3_4,NULL};
1711
1712 fprintf(stderr,"testing single packet page span... ");
1713 test_pack(packets,headret,0,0,0);
1714 }
1715
1716 {
1717 /* spill expand packet test */
1718 const int packets[]={0,4345,259,255,0,0,-1};
1719 const int *headret[]={head1_4b,head2_4b,head3_4b,NULL};
1720
1721 fprintf(stderr,"testing page spill expansion... ");
1722 test_pack(packets,headret,0,0,0);
1723 }
1724
1725 /* page with the 255 segment limit */
1726 {
1727
1728 const int packets[]={0,10,10,10,10,10,10,10,10,
1729 10,10,10,10,10,10,10,10,
1730 10,10,10,10,10,10,10,10,
1731 10,10,10,10,10,10,10,10,
1732 10,10,10,10,10,10,10,10,
1733 10,10,10,10,10,10,10,10,
1734 10,10,10,10,10,10,10,10,
1735 10,10,10,10,10,10,10,10,
1736 10,10,10,10,10,10,10,10,
1737 10,10,10,10,10,10,10,10,
1738 10,10,10,10,10,10,10,10,
1739 10,10,10,10,10,10,10,10,
1740 10,10,10,10,10,10,10,10,
1741 10,10,10,10,10,10,10,10,
1742 10,10,10,10,10,10,10,10,
1743 10,10,10,10,10,10,10,10,
1744 10,10,10,10,10,10,10,10,
1745 10,10,10,10,10,10,10,10,
1746 10,10,10,10,10,10,10,10,
1747 10,10,10,10,10,10,10,10,
1748 10,10,10,10,10,10,10,10,
1749 10,10,10,10,10,10,10,10,
1750 10,10,10,10,10,10,10,10,
1751 10,10,10,10,10,10,10,10,
1752 10,10,10,10,10,10,10,10,
1753 10,10,10,10,10,10,10,10,
1754 10,10,10,10,10,10,10,10,
1755 10,10,10,10,10,10,10,10,
1756 10,10,10,10,10,10,10,10,
1757 10,10,10,10,10,10,10,10,
1758 10,10,10,10,10,10,10,10,
1759 10,10,10,10,10,10,10,50,-1};
1760 const int *headret[]={head1_5,head2_5,head3_5,NULL};
1761
1762 fprintf(stderr,"testing max packet segments... ");
1763 test_pack(packets,headret,0,0,0);
1764 }
1765
1766 {
1767 /* packet that overspans over an entire page */
1768 const int packets[]={0,100,130049,259,255,-1};
1769 const int *headret[]={head1_6,head2_6,head3_6,head4_6,NULL};
1770
1771 fprintf(stderr,"testing very large packets... ");
1772 test_pack(packets,headret,0,0,0);
1773 }
1774
1775 {
1776 /* test for the libogg 1.1.1 resync in large continuation bug
1777 found by Josh Coalson) */
1778 const int packets[]={0,100,130049,259,255,-1};
1779 const int *headret[]={head1_6,head2_6,head3_6,head4_6,NULL};
1780
1781 fprintf(stderr,"testing continuation resync in very large packets... ");
1782 test_pack(packets,headret,100,2,3);
1783 }
1784
1785 {
1786 /* term only page. why not? */
1787 const int packets[]={0,100,64770,-1};
1788 const int *headret[]={head1_7,head2_7,head3_7,NULL};
1789
1790 fprintf(stderr,"testing zero data page (1 nil packet)... ");
1791 test_pack(packets,headret,0,0,0);
1792 }
1793
1794
1795
1796 {
1797 /* build a bunch of pages for testing */
1798 unsigned char *data=_ogg_malloc(1024*1024);
1799 int pl[]={0, 1,1,98,4079, 1,1,2954,2057, 76,34,912,0,234,1000,1000, 1000,300,-1};
1800 int inptr=0,i,j;
1801 ogg_page og[5];
1802
1803 ogg_stream_reset(&os_en);
1804
1805 for(i=0;pl[i]!=-1;i++){
1806 ogg_packet op;
1807 int len=pl[i];
1808
1809 op.packet=data+inptr;
1810 op.bytes=len;
1811 op.e_o_s=(pl[i+1]<0?1:0);
1812 op.granulepos=(i+1)*1000;
1813
1814 for(j=0;j<len;j++)data[inptr++]=i+j;
1815 ogg_stream_packetin(&os_en,&op);
1816 }
1817
1818 _ogg_free(data);
1819
1820 /* retrieve finished pages */
1821 for(i=0;i<5;i++){
1822 if(ogg_stream_pageout(&os_en,&og[i])==0){
1823 fprintf(stderr,"Too few pages output building sync tests!\n");
1824 exit(1);
1825 }
1826 copy_page(&og[i]);
1827 }
1828
1829 /* Test lost pages on pagein/packetout: no rollback */
1830 {
1831 ogg_page temp;
1832 ogg_packet test;
1833
1834 fprintf(stderr,"Testing loss of pages... ");
1835
1836 ogg_sync_reset(&oy);
1837 ogg_stream_reset(&os_de);
1838 for(i=0;i<5;i++){
1839 memcpy(ogg_sync_buffer(&oy,og[i].header_len),og[i].header,
1840 og[i].header_len);
1841 ogg_sync_wrote(&oy,og[i].header_len);
1842 memcpy(ogg_sync_buffer(&oy,og[i].body_len),og[i].body,og[i].body_len);
1843 ogg_sync_wrote(&oy,og[i].body_len);
1844 }
1845
1846 ogg_sync_pageout(&oy,&temp);
1847 ogg_stream_pagein(&os_de,&temp);
1848 ogg_sync_pageout(&oy,&temp);
1849 ogg_stream_pagein(&os_de,&temp);
1850 ogg_sync_pageout(&oy,&temp);
1851 /* skip */
1852 ogg_sync_pageout(&oy,&temp);
1853 ogg_stream_pagein(&os_de,&temp);
1854
1855 /* do we get the expected results/packets? */
1856
1857 if(ogg_stream_packetout(&os_de,&test)!=1)error();
1858 checkpacket(&test,0,0,0);
1859 if(ogg_stream_packetout(&os_de,&test)!=1)error();
1860 checkpacket(&test,1,1,-1);
1861 if(ogg_stream_packetout(&os_de,&test)!=1)error();
1862 checkpacket(&test,1,2,-1);
1863 if(ogg_stream_packetout(&os_de,&test)!=1)error();
1864 checkpacket(&test,98,3,-1);
1865 if(ogg_stream_packetout(&os_de,&test)!=1)error();
1866 checkpacket(&test,4079,4,5000);
1867 if(ogg_stream_packetout(&os_de,&test)!=-1){
1868 fprintf(stderr,"Error: loss of page did not return error\n");
1869 exit(1);
1870 }
1871 if(ogg_stream_packetout(&os_de,&test)!=1)error();
1872 checkpacket(&test,76,9,-1);
1873 if(ogg_stream_packetout(&os_de,&test)!=1)error();
1874 checkpacket(&test,34,10,-1);
1875 fprintf(stderr,"ok.\n");
1876 }
1877
1878 /* Test lost pages on pagein/packetout: rollback with continuation */
1879 {
1880 ogg_page temp;
1881 ogg_packet test;
1882
1883 fprintf(stderr,"Testing loss of pages (rollback required)... ");
1884
1885 ogg_sync_reset(&oy);
1886 ogg_stream_reset(&os_de);
1887 for(i=0;i<5;i++){
1888 memcpy(ogg_sync_buffer(&oy,og[i].header_len),og[i].header,
1889 og[i].header_len);
1890 ogg_sync_wrote(&oy,og[i].header_len);
1891 memcpy(ogg_sync_buffer(&oy,og[i].body_len),og[i].body,og[i].body_len);
1892 ogg_sync_wrote(&oy,og[i].body_len);
1893 }
1894
1895 ogg_sync_pageout(&oy,&temp);
1896 ogg_stream_pagein(&os_de,&temp);
1897 ogg_sync_pageout(&oy,&temp);
1898 ogg_stream_pagein(&os_de,&temp);
1899 ogg_sync_pageout(&oy,&temp);
1900 ogg_stream_pagein(&os_de,&temp);
1901 ogg_sync_pageout(&oy,&temp);
1902 /* skip */
1903 ogg_sync_pageout(&oy,&temp);
1904 ogg_stream_pagein(&os_de,&temp);
1905
1906 /* do we get the expected results/packets? */
1907
1908 if(ogg_stream_packetout(&os_de,&test)!=1)error();
1909 checkpacket(&test,0,0,0);
1910 if(ogg_stream_packetout(&os_de,&test)!=1)error();
1911 checkpacket(&test,1,1,-1);
1912 if(ogg_stream_packetout(&os_de,&test)!=1)error();
1913 checkpacket(&test,1,2,-1);
1914 if(ogg_stream_packetout(&os_de,&test)!=1)error();
1915 checkpacket(&test,98,3,-1);
1916 if(ogg_stream_packetout(&os_de,&test)!=1)error();
1917 checkpacket(&test,4079,4,5000);
1918 if(ogg_stream_packetout(&os_de,&test)!=1)error();
1919 checkpacket(&test,1,5,-1);
1920 if(ogg_stream_packetout(&os_de,&test)!=1)error();
1921 checkpacket(&test,1,6,-1);
1922 if(ogg_stream_packetout(&os_de,&test)!=1)error();
1923 checkpacket(&test,2954,7,-1);
1924 if(ogg_stream_packetout(&os_de,&test)!=1)error();
1925 checkpacket(&test,2057,8,9000);
1926 if(ogg_stream_packetout(&os_de,&test)!=-1){
1927 fprintf(stderr,"Error: loss of page did not return error\n");
1928 exit(1);
1929 }
1930 if(ogg_stream_packetout(&os_de,&test)!=1)error();
1931 checkpacket(&test,300,17,18000);
1932 fprintf(stderr,"ok.\n");
1933 }
1934
1935 /* the rest only test sync */
1936 {
1937 ogg_page og_de;
1938 /* Test fractional page inputs: incomplete capture */
1939 fprintf(stderr,"Testing sync on partial inputs... ");
1940 ogg_sync_reset(&oy);
1941 memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header,
1942 3);
1943 ogg_sync_wrote(&oy,3);
1944 if(ogg_sync_pageout(&oy,&og_de)>0)error();
1945
1946 /* Test fractional page inputs: incomplete fixed header */
1947 memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header+3,
1948 20);
1949 ogg_sync_wrote(&oy,20);
1950 if(ogg_sync_pageout(&oy,&og_de)>0)error();
1951
1952 /* Test fractional page inputs: incomplete header */
1953 memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header+23,
1954 5);
1955 ogg_sync_wrote(&oy,5);
1956 if(ogg_sync_pageout(&oy,&og_de)>0)error();
1957
1958 /* Test fractional page inputs: incomplete body */
1959
1960 memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header+28,
1961 og[1].header_len-28);
1962 ogg_sync_wrote(&oy,og[1].header_len-28);
1963 if(ogg_sync_pageout(&oy,&og_de)>0)error();
1964
1965 memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body,1000);
1966 ogg_sync_wrote(&oy,1000);
1967 if(ogg_sync_pageout(&oy,&og_de)>0)error();
1968
1969 memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body+1000,
1970 og[1].body_len-1000);
1971 ogg_sync_wrote(&oy,og[1].body_len-1000);
1972 if(ogg_sync_pageout(&oy,&og_de)<=0)error();
1973
1974 fprintf(stderr,"ok.\n");
1975 }
1976
1977 /* Test fractional page inputs: page + incomplete capture */
1978 {
1979 ogg_page og_de;
1980 fprintf(stderr,"Testing sync on 1+partial inputs... ");
1981 ogg_sync_reset(&oy);
1982
1983 memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header,
1984 og[1].header_len);
1985 ogg_sync_wrote(&oy,og[1].header_len);
1986
1987 memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body,
1988 og[1].body_len);
1989 ogg_sync_wrote(&oy,og[1].body_len);
1990
1991 memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header,
1992 20);
1993 ogg_sync_wrote(&oy,20);
1994 if(ogg_sync_pageout(&oy,&og_de)<=0)error();
1995 if(ogg_sync_pageout(&oy,&og_de)>0)error();
1996
1997 memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header+20,
1998 og[1].header_len-20);
1999 ogg_sync_wrote(&oy,og[1].header_len-20);
2000 memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body,
2001 og[1].body_len);
2002 ogg_sync_wrote(&oy,og[1].body_len);
2003 if(ogg_sync_pageout(&oy,&og_de)<=0)error();
2004
2005 fprintf(stderr,"ok.\n");
2006 }
2007
2008 /* Test recapture: garbage + page */
2009 {
2010 ogg_page og_de;
2011 fprintf(stderr,"Testing search for capture... ");
2012 ogg_sync_reset(&oy);
2013
2014 /* 'garbage' */
2015 memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body,
2016 og[1].body_len);
2017 ogg_sync_wrote(&oy,og[1].body_len);
2018
2019 memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header,
2020 og[1].header_len);
2021 ogg_sync_wrote(&oy,og[1].header_len);
2022
2023 memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body,
2024 og[1].body_len);
2025 ogg_sync_wrote(&oy,og[1].body_len);
2026
2027 memcpy(ogg_sync_buffer(&oy,og[2].header_len),og[2].header,
2028 20);
2029 ogg_sync_wrote(&oy,20);
2030 if(ogg_sync_pageout(&oy,&og_de)>0)error();
2031 if(ogg_sync_pageout(&oy,&og_de)<=0)error();
2032 if(ogg_sync_pageout(&oy,&og_de)>0)error();
2033
2034 memcpy(ogg_sync_buffer(&oy,og[2].header_len),og[2].header+20,
2035 og[2].header_len-20);
2036 ogg_sync_wrote(&oy,og[2].header_len-20);
2037 memcpy(ogg_sync_buffer(&oy,og[2].body_len),og[2].body,
2038 og[2].body_len);
2039 ogg_sync_wrote(&oy,og[2].body_len);
2040 if(ogg_sync_pageout(&oy,&og_de)<=0)error();
2041
2042 fprintf(stderr,"ok.\n");
2043 }
2044
2045 /* Test recapture: page + garbage + page */
2046 {
2047 ogg_page og_de;
2048 fprintf(stderr,"Testing recapture... ");
2049 ogg_sync_reset(&oy);
2050
2051 memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header,
2052 og[1].header_len);
2053 ogg_sync_wrote(&oy,og[1].header_len);
2054
2055 memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body,
2056 og[1].body_len);
2057 ogg_sync_wrote(&oy,og[1].body_len);
2058
2059 memcpy(ogg_sync_buffer(&oy,og[2].header_len),og[2].header,
2060 og[2].header_len);
2061 ogg_sync_wrote(&oy,og[2].header_len);
2062
2063 memcpy(ogg_sync_buffer(&oy,og[2].header_len),og[2].header,
2064 og[2].header_len);
2065 ogg_sync_wrote(&oy,og[2].header_len);
2066
2067 if(ogg_sync_pageout(&oy,&og_de)<=0)error();
2068
2069 memcpy(ogg_sync_buffer(&oy,og[2].body_len),og[2].body,
2070 og[2].body_len-5);
2071 ogg_sync_wrote(&oy,og[2].body_len-5);
2072
2073 memcpy(ogg_sync_buffer(&oy,og[3].header_len),og[3].header,
2074 og[3].header_len);
2075 ogg_sync_wrote(&oy,og[3].header_len);
2076
2077 memcpy(ogg_sync_buffer(&oy,og[3].body_len),og[3].body,
2078 og[3].body_len);
2079 ogg_sync_wrote(&oy,og[3].body_len);
2080
2081 if(ogg_sync_pageout(&oy,&og_de)>0)error();
2082 if(ogg_sync_pageout(&oy,&og_de)<=0)error();
2083
2084 fprintf(stderr,"ok.\n");
2085 }
2086
2087 /* Free page data that was previously copied */
2088 {
2089 for(i=0;i<5;i++){
2090 free_page(&og[i]);
2091 }
2092 }
2093 }
2094
2095 return(0);
2096}
2097
2098#endif
2099
2100
2101
2102
diff --git a/lib/rbcodec/codecs/libtremor/info.c b/lib/rbcodec/codecs/libtremor/info.c
new file mode 100644
index 0000000000..d922711e34
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/info.c
@@ -0,0 +1,330 @@
1/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
4 * *
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * *
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
11 * *
12 ********************************************************************
13
14 function: maintain the info structure, info <-> header packets
15
16 ********************************************************************/
17
18/* general handling of the header and the vorbis_info structure (and
19 substructures) */
20
21#include "config-tremor.h"
22#include <string.h>
23#include <ctype.h>
24#include "ogg.h"
25#include "ivorbiscodec.h"
26#include "codec_internal.h"
27#include "codebook.h"
28#include "registry.h"
29#include "window.h"
30#include "misc.h"
31#include "os.h"
32
33/* helpers */
34static void _v_readstring(oggpack_buffer *o,char *buf,int bytes){
35 while(bytes--){
36 *buf++=oggpack_read(o,8);
37 }
38}
39
40/*
41void vorbis_comment_init(vorbis_comment *vc){
42 memset(vc,0,sizeof(*vc));
43}
44
45void vorbis_comment_clear(vorbis_comment *vc){
46 if(vc){
47 long i;
48 if(vc->user_comments){
49 for(i=0;i<vc->comments;i++)
50 if(vc->user_comments[i])_ogg_free(vc->user_comments[i]);
51 _ogg_free(vc->user_comments);
52 }
53 if(vc->comment_lengths)_ogg_free(vc->comment_lengths);
54 if(vc->vendor)_ogg_free(vc->vendor);
55 memset(vc,0,sizeof(*vc));
56 }
57}
58*/
59
60/* blocksize 0 is guaranteed to be short, 1 is guarantted to be long.
61 They may be equal, but short will never ge greater than long */
62int vorbis_info_blocksize(vorbis_info *vi,int zo){
63 codec_setup_info *ci = (codec_setup_info *)vi->codec_setup;
64 return ci ? ci->blocksizes[zo] : -1;
65}
66
67/* used by synthesis, which has a full, alloced vi */
68void vorbis_info_init(vorbis_info *vi){
69 memset(vi,0,sizeof(*vi));
70 vi->codec_setup=(codec_setup_info *)_ogg_calloc(1,sizeof(codec_setup_info));
71}
72
73void vorbis_info_clear(vorbis_info *vi){
74 codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
75 int i;
76
77 if(ci){
78
79 for(i=0;i<ci->modes;i++)
80 if(ci->mode_param[i])_ogg_free(ci->mode_param[i]);
81
82 for(i=0;i<ci->maps;i++) /* unpack does the range checking */
83 if(ci->map_param[i])
84 _mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]);
85
86 for(i=0;i<ci->floors;i++) /* unpack does the range checking */
87 if(ci->floor_param[i])
88 _floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]);
89
90 for(i=0;i<ci->residues;i++) /* unpack does the range checking */
91 if(ci->residue_param[i])
92 _residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]);
93
94 for(i=0;i<ci->books;i++){
95 if(ci->book_param[i]){
96 /* knows if the book was not alloced */
97 vorbis_staticbook_destroy(ci->book_param[i]);
98 }
99 if(ci->fullbooks)
100 vorbis_book_clear(ci->fullbooks+i);
101 }
102 if(ci->fullbooks)
103 _ogg_free(ci->fullbooks);
104
105 _ogg_free(ci);
106 }
107
108 memset(vi,0,sizeof(*vi));
109}
110
111/* Header packing/unpacking ********************************************/
112
113static int _vorbis_unpack_info(vorbis_info *vi,oggpack_buffer *opb){
114 codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
115 if(!ci)return(OV_EFAULT);
116
117 vi->version=oggpack_read(opb,32);
118 if(vi->version!=0)return(OV_EVERSION);
119
120 vi->channels=oggpack_read(opb,8);
121 vi->rate=oggpack_read(opb,32);
122
123 vi->bitrate_upper=oggpack_read(opb,32);
124 vi->bitrate_nominal=oggpack_read(opb,32);
125 vi->bitrate_lower=oggpack_read(opb,32);
126
127 ci->blocksizes_nbits[0]=oggpack_read(opb,4);
128 ci->blocksizes_nbits[1]=oggpack_read(opb,4);
129 ci->blocksizes[0]=1<<(ci->blocksizes_nbits[0]);
130 ci->blocksizes[1]=1<<(ci->blocksizes_nbits[1]);
131
132 if(vi->rate<1)goto err_out;
133 if(vi->channels<1)goto err_out;
134 if(ci->blocksizes[0]<64)goto err_out;
135 if(ci->blocksizes[1]<ci->blocksizes[0])goto err_out;
136 if(ci->blocksizes[1]>8192)goto err_out;
137
138 if(oggpack_read(opb,1)!=1)goto err_out; /* EOP check */
139
140 return(0);
141 err_out:
142 vorbis_info_clear(vi);
143 return(OV_EBADHEADER);
144}
145
146#if 0
147static int _vorbis_unpack_comment(vorbis_comment *vc,oggpack_buffer *opb){
148 int vendorlen;
149 vendorlen=oggpack_read(opb,32);
150 if(vendorlen<0)goto err_out;
151 if(vendorlen>opb->storage-oggpack_bytes(opb))goto err_out;
152 vc->vendor=(char *)_ogg_calloc(vendorlen+1,1);
153 if(vc->vendor==NULL)goto err_out;
154 _v_readstring(opb,vc->vendor,vendorlen);
155 vc->comments=0;
156 /* ROCKBOX: the meat of this function was deleted as we don't need it */
157 return(0);
158 err_out:
159 vorbis_comment_clear(vc);
160 return(OV_EBADHEADER);
161}
162#endif
163
164/* all of the real encoding details are here. The modes, books,
165 everything */
166static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){
167 codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
168 int i;
169 if(!ci)return(OV_EFAULT);
170
171 /* codebooks */
172 ci->books=oggpack_read(opb,8)+1;
173 if(ci->books<=0)goto err_out;
174 for(i=0;i<ci->books;i++){
175 ci->book_param[i]=vorbis_staticbook_unpack(opb);
176 if(!ci->book_param[i])goto err_out;
177 }
178
179 /* time backend settings */
180 ci->times=oggpack_read(opb,6)+1;
181 if(ci->times<=0)goto err_out;
182 for(i=0;i<ci->times;i++){
183 ci->time_type[i]=oggpack_read(opb,16);
184 if(ci->time_type[i]<0 || ci->time_type[i]>=VI_TIMEB)goto err_out;
185 /* ci->time_param[i]=_time_P[ci->time_type[i]]->unpack(vi,opb);
186 Vorbis I has no time backend */
187 /*if(!ci->time_param[i])goto err_out;*/
188 }
189
190 /* floor backend settings */
191 ci->floors=oggpack_read(opb,6)+1;
192 if(ci->floors<=0)goto err_out;
193 for(i=0;i<ci->floors;i++){
194 ci->floor_type[i]=oggpack_read(opb,16);
195 if(ci->floor_type[i]<0 || ci->floor_type[i]>=VI_FLOORB)goto err_out;
196 ci->floor_param[i]=_floor_P[ci->floor_type[i]]->unpack(vi,opb);
197 if(!ci->floor_param[i])goto err_out;
198 }
199
200 /* residue backend settings */
201 ci->residues=oggpack_read(opb,6)+1;
202 if(ci->residues<=0)goto err_out;
203 for(i=0;i<ci->residues;i++){
204 ci->residue_type[i]=oggpack_read(opb,16);
205 if(ci->residue_type[i]<0 || ci->residue_type[i]>=VI_RESB)goto err_out;
206 ci->residue_param[i]=_residue_P[ci->residue_type[i]]->unpack(vi,opb);
207 if(!ci->residue_param[i])goto err_out;
208 }
209
210 /* map backend settings */
211 ci->maps=oggpack_read(opb,6)+1;
212 if(ci->maps<=0)goto err_out;
213 for(i=0;i<ci->maps;i++){
214 ci->map_type[i]=oggpack_read(opb,16);
215 if(ci->map_type[i]<0 || ci->map_type[i]>=VI_MAPB)goto err_out;
216 ci->map_param[i]=_mapping_P[ci->map_type[i]]->unpack(vi,opb);
217 if(!ci->map_param[i])goto err_out;
218 }
219
220 /* mode settings */
221 ci->modes=oggpack_read(opb,6)+1;
222 if(ci->modes<=0)goto err_out;
223 for(i=0;i<ci->modes;i++){
224 ci->mode_param[i]=(vorbis_info_mode *)_ogg_calloc(1,sizeof(*ci->mode_param[i]));
225 ci->mode_param[i]->blockflag=oggpack_read(opb,1);
226 ci->mode_param[i]->windowtype=oggpack_read(opb,16);
227 ci->mode_param[i]->transformtype=oggpack_read(opb,16);
228 ci->mode_param[i]->mapping=oggpack_read(opb,8);
229
230 if(ci->mode_param[i]->windowtype>=VI_WINDOWB)goto err_out;
231 if(ci->mode_param[i]->transformtype>=VI_WINDOWB)goto err_out;
232 if(ci->mode_param[i]->mapping>=ci->maps)goto err_out;
233 if(ci->mode_param[i]->mapping<0)goto err_out;
234 }
235
236 if(oggpack_read(opb,1)!=1)goto err_out; /* top level EOP check */
237
238 return(0);
239 err_out:
240 vorbis_info_clear(vi);
241 return(OV_EBADHEADER);
242}
243
244/* Is this packet a vorbis ID header? */
245int vorbis_synthesis_idheader(ogg_packet *op){
246 oggpack_buffer opb;
247 char buffer[6];
248
249 if(op){
250 oggpack_readinit(&opb,op->packet,op->bytes);
251
252 if(!op->b_o_s)
253 return(0); /* Not the initial packet */
254
255 if(oggpack_read(&opb,8) != 1)
256 return 0; /* not an ID header */
257
258 memset(buffer,0,6);
259 _v_readstring(&opb,buffer,6);
260 if(memcmp(buffer,"vorbis",6))
261 return 0; /* not vorbis */
262
263 return 1;
264 }
265
266 return 0;
267}
268
269/* The Vorbis header is in three packets; the initial small packet in
270 the first page that identifies basic parameters, a second packet
271 with bitstream comments and a third packet that holds the
272 codebook. */
273
274int vorbis_synthesis_headerin(vorbis_info *vi,ogg_packet *op){
275 oggpack_buffer opb;
276
277 if(op){
278 oggpack_readinit(&opb,op->packet,op->bytes);
279
280 /* Which of the three types of header is this? */
281 /* Also verify header-ness, vorbis */
282 {
283 char buffer[6];
284 int packtype=oggpack_read(&opb,8);
285 memset(buffer,0,6);
286 _v_readstring(&opb,buffer,6);
287 if(memcmp(buffer,"vorbis",6)){
288 /* not a vorbis header */
289 return(OV_ENOTVORBIS);
290 }
291 switch(packtype){
292 case 0x01: /* least significant *bit* is read first */
293 if(!op->b_o_s){
294 /* Not the initial packet */
295 return(OV_EBADHEADER);
296 }
297 if(vi->rate!=0){
298 /* previously initialized info header */
299 return(OV_EBADHEADER);
300 }
301
302 return(_vorbis_unpack_info(vi,&opb));
303
304 case 0x03: /* least significant *bit* is read first */
305 if(vi->rate==0){
306 /* um... we didn't get the initial header */
307 return(OV_EBADHEADER);
308 }
309
310 /*return(_vorbis_unpack_comment(vc,&opb));*/
311 return 0;
312
313 case 0x05: /* least significant *bit* is read first */
314 if(vi->rate==0 /*|| vc->vendor==NULL*/){
315 /* um... we didn;t get the initial header or comments yet */
316 return(OV_EBADHEADER);
317 }
318
319 return(_vorbis_unpack_books(vi,&opb));
320
321 default:
322 /* Not a valid vorbis header type */
323 return(OV_EBADHEADER);
324 break;
325 }
326 }
327 }
328 return(OV_EBADHEADER);
329}
330
diff --git a/lib/rbcodec/codecs/libtremor/ivorbiscodec.h b/lib/rbcodec/codecs/libtremor/ivorbiscodec.h
new file mode 100644
index 0000000000..4fb041603d
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/ivorbiscodec.h
@@ -0,0 +1,204 @@
1/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
4 * *
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * *
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
11 * *
12 ********************************************************************
13
14 function: libvorbis codec headers
15
16 ********************************************************************/
17
18#ifndef _vorbis_codec_h_
19#define _vorbis_codec_h_
20
21#ifdef __cplusplus
22extern "C"
23{
24#endif /* __cplusplus */
25
26#include "ogg.h"
27//#include <codecs/lib/codeclib.h>
28
29typedef struct vorbis_info{
30 int version;
31 int channels;
32 long rate;
33
34 /* The below bitrate declarations are *hints*.
35 Combinations of the three values carry the following implications:
36
37 all three set to the same value:
38 implies a fixed rate bitstream
39 only nominal set:
40 implies a VBR stream that averages the nominal bitrate. No hard
41 upper/lower limit
42 upper and or lower set:
43 implies a VBR bitstream that obeys the bitrate limits. nominal
44 may also be set to give a nominal rate.
45 none set:
46 the coder does not care to speculate.
47 */
48
49 long bitrate_upper;
50 long bitrate_nominal;
51 long bitrate_lower;
52
53 void *codec_setup;
54} vorbis_info;
55
56/* vorbis_dsp_state buffers the current vorbis audio
57 analysis/synthesis state. The DSP state belongs to a specific
58 logical bitstream ****************************************************/
59typedef struct vorbis_dsp_state{
60 vorbis_info *vi;
61
62 ogg_int32_t *residues[2];
63 ogg_int32_t *floors;
64 ogg_int32_t *saved;
65 ogg_int32_t *saved_ptr[CHANNELS];
66
67 int ri;
68
69 ogg_int32_t **pcmb;
70 ogg_int32_t **pcmret;
71 int pcm_storage;
72 int pcm_current;
73 int pcm_returned;
74
75 int eofflag;
76
77 long lW;
78 long W;
79 long nW;
80
81 ogg_int64_t granulepos;
82 ogg_int64_t sequence;
83
84 void *backend_state;
85} vorbis_dsp_state;
86
87typedef struct vorbis_block{
88 /* necessary stream state for linking to the framing abstraction */
89 oggpack_buffer opb;
90
91 long lW;
92 long W;
93 long nW;
94 int pcmend;
95 int mode;
96
97 int eofflag;
98 ogg_int64_t granulepos;
99 ogg_int64_t sequence;
100 vorbis_dsp_state *vd; /* For read-only access of configuration */
101
102 /* local storage to avoid remallocing; it's up to the mapping to
103 structure it */
104 void *localstore;
105 long localtop;
106 long localalloc;
107 long totaluse;
108 struct alloc_chain *reap;
109} vorbis_block;
110
111/* vorbis_block is a single block of data to be processed as part of
112the analysis/synthesis stream; it belongs to a specific logical
113bitstream, but is independant from other vorbis_blocks belonging to
114that logical bitstream. *************************************************/
115
116struct alloc_chain{
117 void *ptr;
118 struct alloc_chain *next;
119};
120
121/* vorbis_info contains all the setup information specific to the
122 specific compression/decompression mode in progress (eg,
123 psychoacoustic settings, channel setup, options, codebook
124 etc). vorbis_info and substructures are in backends.h.
125*********************************************************************/
126
127/* the comments are not part of vorbis_info so that vorbis_info can be
128 static storage */
129typedef struct vorbis_comment{
130 /* unlimited user comment fields. libvorbis writes 'libvorbis'
131 whatever vendor is set to in encode */
132 char **user_comments;
133 int *comment_lengths;
134 int comments;
135 char *vendor;
136
137} vorbis_comment;
138
139
140/* libvorbis encodes in two abstraction layers; first we perform DSP
141 and produce a packet (see docs/analysis.txt). The packet is then
142 coded into a framed OggSquish bitstream by the second layer (see
143 docs/framing.txt). Decode is the reverse process; we sync/frame
144 the bitstream and extract individual packets, then decode the
145 packet back into PCM audio.
146
147 The extra framing/packetizing is used in streaming formats, such as
148 files. Over the net (such as with UDP), the framing and
149 packetization aren't necessary as they're provided by the transport
150 and the streaming layer is not used */
151
152/* Vorbis PRIMITIVES: general ***************************************/
153
154extern void vorbis_info_init(vorbis_info *vi);
155extern void vorbis_info_clear(vorbis_info *vi);
156extern int vorbis_info_blocksize(vorbis_info *vi,int zo);
157/*
158extern void vorbis_comment_init(vorbis_comment *vc);
159extern void vorbis_comment_add(vorbis_comment *vc, char *comment);
160extern void vorbis_comment_add_tag(vorbis_comment *vc,
161 char *tag, char *contents);
162extern void vorbis_comment_clear(vorbis_comment *vc);
163*/
164extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb);
165extern int vorbis_block_clear(vorbis_block *vb);
166extern void vorbis_dsp_clear(vorbis_dsp_state *v);
167
168/* Vorbis PRIMITIVES: synthesis layer *******************************/
169extern int vorbis_synthesis_idheader(ogg_packet *op);
170extern int vorbis_synthesis_headerin(vorbis_info *vi,ogg_packet *op);
171
172extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi);
173extern int vorbis_synthesis_restart(vorbis_dsp_state *v);
174extern int vorbis_synthesis(vorbis_block *vb,ogg_packet *op);
175extern int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op);
176extern int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb);
177extern int vorbis_synthesis_pcmout(vorbis_dsp_state *v,ogg_int32_t ***pcm);
178extern int vorbis_synthesis_read(vorbis_dsp_state *v,int samples);
179extern long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op);
180
181/* Vorbis ERRORS and return codes ***********************************/
182
183#define OV_FALSE -1
184#define OV_EOF -2
185#define OV_HOLE -3
186
187#define OV_EREAD -128
188#define OV_EFAULT -129
189#define OV_EIMPL -130
190#define OV_EINVAL -131
191#define OV_ENOTVORBIS -132
192#define OV_EBADHEADER -133
193#define OV_EVERSION -134
194#define OV_ENOTAUDIO -135
195#define OV_EBADPACKET -136
196#define OV_EBADLINK -137
197#define OV_ENOSEEK -138
198
199#ifdef __cplusplus
200}
201#endif /* __cplusplus */
202
203#endif
204
diff --git a/lib/rbcodec/codecs/libtremor/ivorbisfile.h b/lib/rbcodec/codecs/libtremor/ivorbisfile.h
new file mode 100644
index 0000000000..076783514e
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/ivorbisfile.h
@@ -0,0 +1,131 @@
1/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
4 * *
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * *
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
11 * *
12 ********************************************************************
13
14 function: stdio-based convenience library for opening/seeking/decoding
15
16 ********************************************************************/
17
18#ifndef _OV_FILE_H_
19#define _OV_FILE_H_
20
21#ifdef __cplusplus
22extern "C"
23{
24#endif /* __cplusplus */
25
26#include <stdio.h>
27#include "ivorbiscodec.h"
28
29
30#define CHUNKSIZE 1024
31/* The function prototypes for the callbacks are basically the same as for
32 * the stdio functions fread, fseek, fclose, ftell.
33 * The one difference is that the FILE * arguments have been replaced with
34 * a void * - this is to be used as a pointer to whatever internal data these
35 * functions might need. In the stdio case, it's just a FILE * cast to a void *
36 *
37 * If you use other functions, check the docs for these functions and return
38 * the right values. For seek_func(), you *MUST* return -1 if the stream is
39 * unseekable
40 */
41typedef struct {
42 size_t (*read_func) (void *ptr, size_t size, size_t nmemb, void *datasource);
43 int (*seek_func) (void *datasource, ogg_int64_t offset, int whence);
44 int (*close_func) (void *datasource);
45 long (*tell_func) (void *datasource);
46} ov_callbacks;
47
48#define NOTOPEN 0
49#define PARTOPEN 1
50#define OPENED 2
51#define STREAMSET 3
52#define INITSET 4
53
54typedef struct OggVorbis_File {
55 void *datasource; /* Pointer to a FILE *, etc. */
56 int seekable;
57 ogg_int64_t offset;
58 ogg_int64_t end;
59 ogg_sync_state oy;
60
61 /* If the FILE handle isn't seekable (eg, a pipe), only the current
62 stream appears */
63 int links;
64 ogg_int64_t *offsets;
65 ogg_int64_t *dataoffsets;
66 ogg_uint32_t *serialnos;
67 ogg_int64_t *pcmlengths;
68 vorbis_info *vi;
69/* vorbis_comment *vc; */
70
71 /* Decoding working state local storage */
72 ogg_int64_t pcm_offset;
73 int ready_state;
74 ogg_uint32_t current_serialno;
75 int current_link;
76
77 ogg_int64_t bittrack;
78 ogg_int64_t samptrack;
79
80 ogg_stream_state os; /* take physical pages, weld into a logical
81 stream of packets */
82 vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
83 vorbis_block vb; /* local working space for packet->PCM decode */
84
85 ov_callbacks callbacks;
86
87} OggVorbis_File;
88
89extern int ov_clear(OggVorbis_File *vf);
90extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf,
91 const char *initial, long ibytes, ov_callbacks callbacks);
92
93extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf,
94 const char *initial, long ibytes, ov_callbacks callbacks);
95extern int ov_test_open(OggVorbis_File *vf);
96
97extern long ov_bitrate(OggVorbis_File *vf,int i);
98extern long ov_bitrate_instant(OggVorbis_File *vf);
99extern long ov_streams(OggVorbis_File *vf);
100extern long ov_seekable(OggVorbis_File *vf);
101extern long ov_serialnumber(OggVorbis_File *vf,int i);
102
103extern ogg_int64_t ov_raw_total(OggVorbis_File *vf,int i);
104extern ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i);
105extern ogg_int64_t ov_time_total(OggVorbis_File *vf,int i);
106
107extern int ov_raw_seek(OggVorbis_File *vf,ogg_int64_t pos);
108extern int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos);
109extern int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos);
110extern int ov_time_seek(OggVorbis_File *vf,ogg_int64_t pos);
111extern int ov_time_seek_page(OggVorbis_File *vf,ogg_int64_t pos);
112
113extern ogg_int64_t ov_raw_tell(OggVorbis_File *vf);
114extern ogg_int64_t ov_pcm_tell(OggVorbis_File *vf);
115extern ogg_int64_t ov_time_tell(OggVorbis_File *vf);
116
117extern vorbis_info *ov_info(OggVorbis_File *vf,int link);
118extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link);
119
120extern long ov_read(OggVorbis_File *vf,char *buffer,int length,
121 int *bitstream);
122extern long ov_read_fixed(OggVorbis_File *vf,ogg_int32_t ***pcm_channels,
123 int length,int *bitstream);
124
125#ifdef __cplusplus
126}
127#endif /* __cplusplus */
128
129#endif
130
131
diff --git a/lib/rbcodec/codecs/libtremor/libtremor.make b/lib/rbcodec/codecs/libtremor/libtremor.make
new file mode 100644
index 0000000000..4a581508b0
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/libtremor.make
@@ -0,0 +1,18 @@
1# __________ __ ___.
2# Open \______ \ ____ ____ | | _\_ |__ _______ ___
3# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6# \/ \/ \/ \/ \/
7# $Id$
8#
9
10# libtremor
11TREMORLIB := $(CODECDIR)/libtremor.a
12TREMORLIB_SRC := $(call preprocess, $(RBCODECLIB_DIR)/codecs/libtremor/SOURCES)
13TREMORLIB_OBJ := $(call c2obj, $(TREMORLIB_SRC))
14OTHER_SRC += $(TREMORLIB_SRC)
15
16$(TREMORLIB): $(TREMORLIB_OBJ)
17 $(SILENT)$(shell rm -f $@)
18 $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null
diff --git a/lib/rbcodec/codecs/libtremor/lsp_lookup.h b/lib/rbcodec/codecs/libtremor/lsp_lookup.h
new file mode 100644
index 0000000000..d996677ca1
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/lsp_lookup.h
@@ -0,0 +1,132 @@
1/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
4 * *
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * *
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
11 * *
12 ********************************************************************
13
14 function: lookup data
15
16 ********************************************************************/
17
18#ifndef _V_LOOKUP_DATA_H_
19#define _V_LOOKUP_DATA_H_
20
21#include "os_types.h"
22
23#define FROMdB_LOOKUP_SZ 35
24#define FROMdB2_LOOKUP_SZ 32
25#define FROMdB_SHIFT 5
26#define FROMdB2_SHIFT 3
27#define FROMdB2_MASK 31
28
29static const ogg_int32_t FROMdB_LOOKUP[FROMdB_LOOKUP_SZ] ={
30 0x003fffff, 0x0028619b, 0x00197a96, 0x0010137a,
31 0x000a24b0, 0x00066666, 0x000409c3, 0x00028c42,
32 0x00019b8c, 0x000103ab, 0x0000a3d7, 0x00006760,
33 0x0000413a, 0x00002928, 0x000019f8, 0x00001062,
34 0x00000a56, 0x00000686, 0x0000041e, 0x00000299,
35 0x000001a3, 0x00000109, 0x000000a7, 0x00000069,
36 0x00000042, 0x0000002a, 0x0000001a, 0x00000011,
37 0x0000000b, 0x00000007, 0x00000004, 0x00000003,
38 0x00000002, 0x00000001, 0x00000001};
39
40static const ogg_int32_t FROMdB2_LOOKUP[FROMdB2_LOOKUP_SZ] ={
41 0x000001fc, 0x000001f5, 0x000001ee, 0x000001e7,
42 0x000001e0, 0x000001d9, 0x000001d2, 0x000001cc,
43 0x000001c5, 0x000001bf, 0x000001b8, 0x000001b2,
44 0x000001ac, 0x000001a6, 0x000001a0, 0x0000019a,
45 0x00000194, 0x0000018e, 0x00000188, 0x00000183,
46 0x0000017d, 0x00000178, 0x00000172, 0x0000016d,
47 0x00000168, 0x00000163, 0x0000015e, 0x00000159,
48 0x00000154, 0x0000014f, 0x0000014a, 0x00000145,
49};
50
51#define INVSQ_LOOKUP_I_SHIFT 10
52#define INVSQ_LOOKUP_I_MASK 1023
53static const long INVSQ_LOOKUP_I[64+1] ={
54 92682, 91966, 91267, 90583,
55 89915, 89261, 88621, 87995,
56 87381, 86781, 86192, 85616,
57 85051, 84497, 83953, 83420,
58 82897, 82384, 81880, 81385,
59 80899, 80422, 79953, 79492,
60 79039, 78594, 78156, 77726,
61 77302, 76885, 76475, 76072,
62 75674, 75283, 74898, 74519,
63 74146, 73778, 73415, 73058,
64 72706, 72359, 72016, 71679,
65 71347, 71019, 70695, 70376,
66 70061, 69750, 69444, 69141,
67 68842, 68548, 68256, 67969,
68 67685, 67405, 67128, 66855,
69 66585, 66318, 66054, 65794,
70 65536,
71};
72
73static const long INVSQ_LOOKUP_IDel[64] ={
74 716, 699, 684, 668,
75 654, 640, 626, 614,
76 600, 589, 576, 565,
77 554, 544, 533, 523,
78 513, 504, 495, 486,
79 477, 469, 461, 453,
80 445, 438, 430, 424,
81 417, 410, 403, 398,
82 391, 385, 379, 373,
83 368, 363, 357, 352,
84 347, 343, 337, 332,
85 328, 324, 319, 315,
86 311, 306, 303, 299,
87 294, 292, 287, 284,
88 280, 277, 273, 270,
89 267, 264, 260, 258,
90};
91
92#define COS_LOOKUP_I_SHIFT 9
93#define COS_LOOKUP_I_MASK 511
94#define COS_LOOKUP_I_SZ 128
95static const ogg_int32_t COS_LOOKUP_I[COS_LOOKUP_I_SZ+1] ={
96 16384, 16379, 16364, 16340,
97 16305, 16261, 16207, 16143,
98 16069, 15986, 15893, 15791,
99 15679, 15557, 15426, 15286,
100 15137, 14978, 14811, 14635,
101 14449, 14256, 14053, 13842,
102 13623, 13395, 13160, 12916,
103 12665, 12406, 12140, 11866,
104 11585, 11297, 11003, 10702,
105 10394, 10080, 9760, 9434,
106 9102, 8765, 8423, 8076,
107 7723, 7366, 7005, 6639,
108 6270, 5897, 5520, 5139,
109 4756, 4370, 3981, 3590,
110 3196, 2801, 2404, 2006,
111 1606, 1205, 804, 402,
112 0, -401, -803, -1204,
113 -1605, -2005, -2403, -2800,
114 -3195, -3589, -3980, -4369,
115 -4755, -5138, -5519, -5896,
116 -6269, -6638, -7004, -7365,
117 -7722, -8075, -8422, -8764,
118 -9101, -9433, -9759, -10079,
119 -10393, -10701, -11002, -11296,
120 -11584, -11865, -12139, -12405,
121 -12664, -12915, -13159, -13394,
122 -13622, -13841, -14052, -14255,
123 -14448, -14634, -14810, -14977,
124 -15136, -15285, -15425, -15556,
125 -15678, -15790, -15892, -15985,
126 -16068, -16142, -16206, -16260,
127 -16304, -16339, -16363, -16378,
128 -16383,
129};
130
131#endif
132
diff --git a/lib/rbcodec/codecs/libtremor/mapping0.c b/lib/rbcodec/codecs/libtremor/mapping0.c
new file mode 100644
index 0000000000..084d5e076d
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/mapping0.c
@@ -0,0 +1,416 @@
1/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
4 * *
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * *
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
11 * *
12 ********************************************************************
13
14 function: channel mapping 0 implementation
15
16 ********************************************************************/
17
18#include "config-tremor.h"
19#include <stdio.h>
20#include <string.h>
21#include <math.h>
22#include "ogg.h"
23#include "ivorbiscodec.h"
24#include "codeclib.h"
25#include "codec_internal.h"
26#include "codebook.h"
27#include "window.h"
28#include "registry.h"
29#include "misc.h"
30#include <codecs/lib/codeclib.h>
31
32/* simplistic, wasteful way of doing this (unique lookup for each
33 mode/submapping); there should be a central repository for
34 identical lookups. That will require minor work, so I'm putting it
35 off as low priority.
36
37 Why a lookup for each backend in a given mode? Because the
38 blocksize is set by the mode, and low backend lookups may require
39 parameters from other areas of the mode/mapping */
40
41typedef struct {
42 vorbis_info_mode *mode;
43 vorbis_info_mapping0 *map;
44
45 vorbis_look_floor **floor_look;
46
47 vorbis_look_residue **residue_look;
48
49 vorbis_func_floor **floor_func;
50 vorbis_func_residue **residue_func;
51
52 int ch;
53 long lastframe; /* if a different mode is called, we need to
54 invalidate decay */
55} vorbis_look_mapping0;
56
57static void mapping0_free_info(vorbis_info_mapping *i){
58 vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)i;
59 if(info){
60 memset(info,0,sizeof(*info));
61 _ogg_free(info);
62 }
63}
64
65static void mapping0_free_look(vorbis_look_mapping *look){
66 int i;
67 vorbis_look_mapping0 *l=(vorbis_look_mapping0 *)look;
68 if(l){
69
70 for(i=0;i<l->map->submaps;i++){
71 l->floor_func[i]->free_look(l->floor_look[i]);
72 l->residue_func[i]->free_look(l->residue_look[i]);
73 }
74
75 _ogg_free(l->floor_func);
76 _ogg_free(l->residue_func);
77 _ogg_free(l->floor_look);
78 _ogg_free(l->residue_look);
79 memset(l,0,sizeof(*l));
80 _ogg_free(l);
81 }
82}
83
84static vorbis_look_mapping *mapping0_look(vorbis_dsp_state *vd,vorbis_info_mode *vm,
85 vorbis_info_mapping *m){
86 int i;
87 vorbis_info *vi=vd->vi;
88 codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
89 vorbis_look_mapping0 *look=(vorbis_look_mapping0 *)_ogg_calloc(1,sizeof(*look));
90 vorbis_info_mapping0 *info=look->map=(vorbis_info_mapping0 *)m;
91 look->mode=vm;
92
93 look->floor_look=(vorbis_look_floor **)_ogg_calloc(info->submaps,sizeof(*look->floor_look));
94
95 look->residue_look=(vorbis_look_residue **)_ogg_calloc(info->submaps,sizeof(*look->residue_look));
96
97 look->floor_func=(vorbis_func_floor **)_ogg_calloc(info->submaps,sizeof(*look->floor_func));
98 look->residue_func=(vorbis_func_residue **)_ogg_calloc(info->submaps,sizeof(*look->residue_func));
99
100 for(i=0;i<info->submaps;i++){
101 int floornum=info->floorsubmap[i];
102 int resnum=info->residuesubmap[i];
103
104 look->floor_func[i]=_floor_P[ci->floor_type[floornum]];
105 look->floor_look[i]=look->floor_func[i]->
106 look(vd,vm,ci->floor_param[floornum]);
107 look->residue_func[i]=_residue_P[ci->residue_type[resnum]];
108 look->residue_look[i]=look->residue_func[i]->
109 look(vd,vm,ci->residue_param[resnum]);
110
111 }
112
113 look->ch=vi->channels;
114
115 return(look);
116}
117
118static int ilog(unsigned int v){
119 int ret=0;
120 if(v)--v;
121 while(v){
122 ret++;
123 v>>=1;
124 }
125 return(ret);
126}
127
128
129/* also responsible for range checking */
130static vorbis_info_mapping *mapping0_unpack(vorbis_info *vi,oggpack_buffer *opb){
131 int i,b;
132 vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)_ogg_calloc(1,sizeof(*info));
133 codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
134 memset(info,0,sizeof(*info));
135
136 b=oggpack_read(opb,1);
137 if(b<0)goto err_out;
138 if(b){
139 info->submaps=oggpack_read(opb,4)+1;
140 if(info->submaps<=0)goto err_out;
141 }else
142 info->submaps=1;
143
144 b=oggpack_read(opb,1);
145 if(b<0)goto err_out;
146 if(b){
147 info->coupling_steps=oggpack_read(opb,8)+1;
148 if(info->coupling_steps<=0)goto err_out;
149 for(i=0;i<info->coupling_steps;i++){
150 int testM=oggpack_read(opb,ilog(vi->channels));
151 info->coupling_mag[i]=testM;
152 int testA=oggpack_read(opb,ilog(vi->channels));
153 info->coupling_ang[i]=testA;
154
155 if(testM<0 ||
156 testA<0 ||
157 testM==testA ||
158 testM>=vi->channels ||
159 testA>=vi->channels) goto err_out;
160 }
161
162 }
163
164 if(oggpack_read(opb,2)!=0)goto err_out; /* 2,3:reserved */
165
166 if(info->submaps>1){
167 for(i=0;i<vi->channels;i++){
168 info->chmuxlist[i]=oggpack_read(opb,4);
169 if(info->chmuxlist[i]>=info->submaps || info->chmuxlist[i]<0)goto err_out;
170 }
171 }
172 for(i=0;i<info->submaps;i++){
173 int temp=oggpack_read(opb,8);
174 if(temp>=ci->times)goto err_out;
175 info->floorsubmap[i]=oggpack_read(opb,8);
176 if(info->floorsubmap[i]>=ci->floors || info->floorsubmap[i]<0)goto err_out;
177 info->residuesubmap[i]=oggpack_read(opb,8);
178 if(info->residuesubmap[i]>=ci->residues || info->residuesubmap[i]<0)
179 goto err_out;
180 }
181
182 return info;
183
184 err_out:
185 mapping0_free_info(info);
186 return(NULL);
187}
188
189#ifdef _ARM_ASSEM_
190#define MAGANG( _mag, _ang )\
191{\
192 register int temp;\
193 asm( "mov %[temp], %[ang]\n\t"\
194 "cmp %[mag], #0\n\t"\
195 "rsble %[temp], %[temp], #0\n\t"\
196 "cmp %[ang], #0\n\t"\
197 "subgt %[ang], %[mag], %[temp]\n\t"\
198 "movle %[ang], %[mag]\n\t"\
199 "addle %[mag], %[mag], %[temp]\n\t"\
200 : [mag] "+r" ( ( _mag ) ), [ang] "+r" ( ( _ang ) ), [temp] "=&r" (temp)\
201 :\
202 : "cc" );\
203}
204
205static inline void channel_couple(ogg_int32_t *pcmM, ogg_int32_t *pcmA, int n)
206{
207 ogg_int32_t * const pcmMend = pcmM + n/2;
208 while(LIKELY(pcmM < pcmMend))
209 {
210 register int M0 asm("r2"),M1 asm("r3"),M2 asm("r4"),M3 asm("r5");
211 register int A0 asm("r6"),A1 asm("r7"),A2 asm("r8"),A3 asm("r9");
212 asm volatile( "ldmia %[pcmM], {%[M0], %[M1], %[M2], %[M3]}\n\t"
213 "ldmia %[pcmA], {%[A0], %[A1], %[A2], %[A3]}\n\t"
214 : [M0] "=r" (M0), [M1] "=r" (M1), [M2] "=r" (M2), [M3] "=r" (M3),
215 [A0] "=r" (A0), [A1] "=r" (A1), [A2] "=r" (A2), [A3] "=r" (A3)
216 : [pcmM] "r" (pcmM), [pcmA] "r" (pcmA)
217 : "memory" );
218 MAGANG( M0, A0 );
219 MAGANG( M1, A1 );
220 MAGANG( M2, A2 );
221 MAGANG( M3, A3 );
222 asm volatile( "stmia %[pcmM]!, {%[M0], %[M1], %[M2], %[M3]}\n\t"
223 "stmia %[pcmA]!, {%[A0], %[A1], %[A2], %[A3]}\n\t"
224 : [pcmM] "+r" (pcmM), [pcmA] "+r" (pcmA)
225 : [M0] "r" (M0), [M1] "r" (M1), [M2] "r" (M2), [M3] "r" (M3),
226 [A0] "r" (A0), [A1] "r" (A1), [A2] "r" (A2), [A3] "r" (A3)
227 : "memory" );
228 }
229}
230
231#elif defined CPU_COLDFIRE
232
233#define MAGANG( _mag, _ang, _off )\
234{\
235 asm volatile( "tst.l %[mag]\n\t"\
236 "bgt.s 1f\n\t"\
237 "neg.l %[ang]\n\t" /* neg sets cc so we might as well jump */ \
238 "ble.s 2f\n\t"\
239 ".word 0x51fb\n\t" /* trapf.l, shadow next 2 insns */ \
240 /* if we didn't jump, the next test will */ \
241 /* false anyway */ \
242 "1:\n\t"\
243 "tst.l %[ang]\n\t"\
244 "bgt.s 2f\n\t"\
245 "add.l %[mag], %[ang]\n\t"\
246 "move.l %[ang], (" #_off ", %[pcmM])\n\t"\
247 ".word 0x51fa\n\t" /* trapf.w, shadow next insn */ \
248 "2:\n\t"\
249 "sub.l %[ang], %[mag]\n\t"\
250 "move.l %[mag], (%[pcmA])+\n\t"\
251 : [mag] "+r" ( ( _mag ) ), [ang] "+d" ( ( _ang ) ),\
252 [pcmA] "+a" (pcmA)\
253 : [pcmM] "a" (pcmM)\
254 : "cc", "memory" );\
255}
256static inline void channel_couple(ogg_int32_t *pcmM, ogg_int32_t *pcmA, unsigned int n)
257{
258 ogg_int32_t * const pcmMend = pcmM + n/2;
259 while(LIKELY(pcmM < pcmMend))
260 {
261 register int M0 asm("a2"),M1 asm("a3"),M2 asm("a4"),M3 asm("a5");
262 register int A0 asm("d2"),A1 asm("d3"),A2 asm("d4"),A3 asm("d5");
263 asm volatile( "movem.l (%[pcmM]), %[M0]-%[M3]\n\t"
264 "movem.l (%[pcmA]), %[A0]-%[A3]\n\t"
265 : [M0] "=r" (M0), [M1] "=r" (M1), [M2] "=r" (M2), [M3] "=r" (M3),
266 [A0] "=r" (A0), [A1] "=r" (A1), [A2] "=r" (A2), [A3] "=r" (A3)
267 : [pcmM] "a" (pcmM), [pcmA] "a" (pcmA) );
268
269 /* use offsets instead of autoinc since the store to pcmM is conditional */
270 MAGANG( M0, A0, 0 );
271 MAGANG( M1, A1, 4 );
272 MAGANG( M2, A2, 8 );
273 MAGANG( M3, A3, 12 );
274
275 asm volatile( "lea.l (4*4, %[pcmM]), %[pcmM]\n\t"
276 : [pcmM] "+a" (pcmM));
277 }
278}
279#else
280static inline void channel_couple(ogg_int32_t *pcmM, ogg_int32_t *pcmA, int n)
281{
282 int j;
283 for(j=0;j<n/2;j++){
284 ogg_int32_t mag = pcmM[j], ang = pcmA[j], _ang;
285 if(mag>0)
286 _ang = ang;
287 else
288 _ang = -ang;
289
290 if(ang>0)
291 pcmA[j]=mag-_ang;
292 else{
293 pcmA[j]=mag;
294 pcmM[j]=mag+_ang;
295 }
296
297 }
298}
299#endif
300
301static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){
302 vorbis_dsp_state *vd=vb->vd;
303 vorbis_info *vi=vd->vi;
304 codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
305 vorbis_look_mapping0 *look=(vorbis_look_mapping0 *)l;
306 vorbis_info_mapping0 *info=look->map;
307
308 int i,j;
309 long n=vb->pcmend=ci->blocksizes[vb->W];
310
311 /* bounded mapping arrays instead of using alloca();
312 avoids memory leak; we can only deal with stereo anyway */
313 ogg_int32_t *pcmbundle[CHANNELS];
314 int zerobundle[CHANNELS];
315 int nonzero[CHANNELS];
316 void *floormemo[CHANNELS];
317
318 /* time domain information decode (note that applying the
319 information would have to happen later; we'll probably add a
320 function entry to the harness for that later */
321 /* NOT IMPLEMENTED */
322
323 /* recover the spectral envelope; store it in the PCM vector for now */
324 for(i=0;i<vi->channels;i++){
325 int submap=info->chmuxlist[i];
326 floormemo[i]=look->floor_func[submap]->
327 inverse1(vb,look->floor_look[submap]);
328 if(floormemo[i])
329 nonzero[i]=1;
330 else
331 nonzero[i]=0;
332 memset(vd->floors + i * ci->blocksizes[vb->W]/2,0,sizeof(ogg_int32_t)*n/2);
333 }
334
335 /* channel coupling can 'dirty' the nonzero listing */
336 for(i=0;i<info->coupling_steps;i++){
337 if(nonzero[info->coupling_mag[i]] ||
338 nonzero[info->coupling_ang[i]]){
339 nonzero[info->coupling_mag[i]]=1;
340 nonzero[info->coupling_ang[i]]=1;
341 }
342 }
343
344 /* recover the residue into our working vectors */
345 for(i=0;i<info->submaps;i++){
346 int ch_in_bundle=0;
347 for(j=0;j<vi->channels;j++){
348 if(info->chmuxlist[j]==i){
349 if(nonzero[j])
350 zerobundle[ch_in_bundle]=1;
351 else
352 zerobundle[ch_in_bundle]=0;
353 pcmbundle[ch_in_bundle++] = vd->floors + j * ci->blocksizes[vb->W]/2;
354 }
355 }
356
357 look->residue_func[i]->inverse(vb,look->residue_look[i],
358 pcmbundle,zerobundle,ch_in_bundle);
359 }
360
361 //for(j=0;j<vi->channels;j++)
362 //_analysis_output("coupled",seq+j,vb->pcm[j],-8,n/2,0,0);
363
364
365 /* channel coupling */
366 for(i=info->coupling_steps-1;i>=0;i--){
367 ogg_int32_t *pcmM = vd->floors + info->coupling_mag[i] * ci->blocksizes[vb->W]/2;
368 ogg_int32_t *pcmA = vd->floors + info->coupling_ang[i] * ci->blocksizes[vb->W]/2;
369 channel_couple(pcmM,pcmA,n);
370 }
371
372 //for(j=0;j<vi->channels;j++)
373 //_analysis_output("residue",seq+j,vb->pcm[j],-8,n/2,0,0);
374
375 //for(j=0;j<vi->channels;j++)
376 //_analysis_output("mdct",seq+j,vb->pcm[j],-24,n/2,0,1);
377
378 /* transform the PCM data; takes PCM vector, vb; modifies PCM vector */
379 /* only MDCT right now.... */
380 for(i=0;i<vi->channels;i++){
381 ogg_int32_t *pcm = vd->floors + i*ci->blocksizes[vb->W]/2;
382 int submap=info->chmuxlist[i];
383
384 if(nonzero[i]) {
385 /* compute and apply spectral envelope */
386 look->floor_func[submap]->
387 inverse2(vb,look->floor_look[submap],floormemo[i],pcm);
388
389 ff_imdct_half(ci->blocksizes_nbits[vb->W],
390 (int32_t*)vd->residues[vd->ri] + i*ci->blocksizes[vb->W]/2,
391 (int32_t*)&vd->floors[i*ci->blocksizes[vb->W]/2]);
392 }
393 else
394 memset(vd->residues[vd->ri] + i*ci->blocksizes[vb->W]/2, 0, sizeof(ogg_int32_t)*n/2);
395 }
396
397 //for(j=0;j<vi->channels;j++)
398 //_analysis_output("imdct",seq+j,vb->pcm[j],-24,n,0,0);
399
400 //for(j=0;j<vi->channels;j++)
401 //_analysis_output("window",seq+j,vb->pcm[j],-24,n,0,0);
402
403 //seq+=vi->channels;
404 /* all done! */
405 return(0);
406}
407
408/* export hooks */
409const vorbis_func_mapping mapping0_exportbundle ICONST_ATTR ={
410 &mapping0_unpack,
411 &mapping0_look,
412 &mapping0_free_info,
413 &mapping0_free_look,
414 &mapping0_inverse
415};
416
diff --git a/lib/rbcodec/codecs/libtremor/misc.h b/lib/rbcodec/codecs/libtremor/misc.h
new file mode 100644
index 0000000000..592a60ffd8
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/misc.h
@@ -0,0 +1,276 @@
1/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
4 * *
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * *
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
11 * *
12 ********************************************************************
13
14 function: miscellaneous math and prototypes
15
16 ********************************************************************/
17
18#include "config-tremor.h"
19
20#ifndef _V_RANDOM_H_
21#define _V_RANDOM_H_
22#include "ivorbiscodec.h"
23#include "os_types.h"
24
25#include "codeclib_misc.h"
26
27#include "asm_arm.h"
28#include "asm_mcf5249.h"
29
30/* Some prototypes that were not defined elsewhere */
31void *_vorbis_block_alloc(vorbis_block *vb,long bytes);
32void _vorbis_block_ripcord(vorbis_block *vb);
33extern int _ilog(unsigned int v);
34
35#ifndef _V_WIDE_MATH
36#define _V_WIDE_MATH
37
38#ifndef _LOW_ACCURACY_
39/* 64 bit multiply */
40/* #include <sys/types.h> */
41#if 0
42#if BYTE_ORDER==LITTLE_ENDIAN
43union magic {
44 struct {
45 ogg_int32_t lo;
46 ogg_int32_t hi;
47 } halves;
48 ogg_int64_t whole;
49};
50#elif BYTE_ORDER==BIG_ENDIAN
51union magic {
52 struct {
53 ogg_int32_t hi;
54 ogg_int32_t lo;
55 } halves;
56 ogg_int64_t whole;
57};
58#endif
59
60static inline ogg_int32_t MULT32(ogg_int32_t x, ogg_int32_t y) {
61 union magic magic;
62 magic.whole = (ogg_int64_t)x * y;
63 return magic.halves.hi;
64}
65static inline ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) {
66 return MULT32(x,y)<<1;
67}
68
69static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
70 union magic magic;
71 magic.whole = (ogg_int64_t)x * y;
72 return ((ogg_uint32_t)(magic.halves.lo)>>15) | ((magic.halves.hi)<<17);
73}
74#endif
75#else
76/* 32 bit multiply, more portable but less accurate */
77
78/*
79 * Note: Precision is biased towards the first argument therefore ordering
80 * is important. Shift values were chosen for the best sound quality after
81 * many listening tests.
82 */
83
84/*
85 * For MULT32 and MULT31: The second argument is always a lookup table
86 * value already preshifted from 31 to 8 bits. We therefore take the
87 * opportunity to save on text space and use unsigned char for those
88 * tables in this case.
89 */
90
91static inline ogg_int32_t MULT32(ogg_int32_t x, ogg_int32_t y) {
92 return (x >> 9) * y; /* y preshifted >>23 */
93}
94
95static inline ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) {
96 return (x >> 8) * y; /* y preshifted >>23 */
97}
98
99static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
100 return (x >> 6) * y; /* y preshifted >>9 */
101}
102#endif
103
104/*
105 * This should be used as a memory barrier, forcing all cached values in
106 * registers to wr writen back to memory. Might or might not be beneficial
107 * depending on the architecture and compiler.
108 */
109#define MB()
110
111/*
112 * The XPROD functions are meant to optimize the cross products found all
113 * over the place in mdct.c by forcing memory operation ordering to avoid
114 * unnecessary register reloads as soon as memory is being written to.
115 * However this is only beneficial on CPUs with a sane number of general
116 * purpose registers which exclude the Intel x86. On Intel, better let the
117 * compiler actually reload registers directly from original memory by using
118 * macros.
119 */
120
121/* replaced XPROD32 with a macro to avoid memory reference
122 _x, _y are the results (must be l-values) */
123/*
124#define XPROD32(_a, _b, _t, _v, _x, _y) \
125 { (_x)=MULT32(_a,_t)+MULT32(_b,_v); \
126 (_y)=MULT32(_b,_t)-MULT32(_a,_v); }
127*/
128
129#ifdef __i386__
130
131#define XPROD31(_a, _b, _t, _v, _x, _y) \
132 { *(_x)=MULT31(_a,_t)+MULT31(_b,_v); \
133 *(_y)=MULT31(_b,_t)-MULT31(_a,_v); }
134#define XNPROD31(_a, _b, _t, _v, _x, _y) \
135 { *(_x)=MULT31(_a,_t)-MULT31(_b,_v); \
136 *(_y)=MULT31(_b,_t)+MULT31(_a,_v); }
137
138#else
139/*
140static inline void XPROD31(ogg_int32_t a, ogg_int32_t b,
141 ogg_int32_t t, ogg_int32_t v,
142 ogg_int32_t *x, ogg_int32_t *y)
143{
144 *x = MULT31(a, t) + MULT31(b, v);
145 *y = MULT31(b, t) - MULT31(a, v);
146}
147
148static inline void XNPROD31(ogg_int32_t a, ogg_int32_t b,
149 ogg_int32_t t, ogg_int32_t v,
150 ogg_int32_t *x, ogg_int32_t *y)
151{
152 *x = MULT31(a, t) - MULT31(b, v);
153 *y = MULT31(b, t) + MULT31(a, v);
154}
155*/
156#endif
157
158#if 0
159#ifndef _V_VECT_OPS
160#define _V_VECT_OPS
161
162/* generic misc.h has symmetrical versions of vect_add_right_left
163 and vect_add_left_right (since symmetrical versions of
164 vect_mult_fw and vect_mult_bw i.e. both use MULT31) */
165static inline
166void vect_add_right_left(ogg_int32_t *x, const ogg_int32_t *y, int n)
167{
168 while (n>0) {
169 *x++ += *y++;
170 n--;
171 }
172}
173
174static inline
175void vect_add_left_right(ogg_int32_t *x, const ogg_int32_t *y, int n)
176{
177 vect_add_right_left(x,y,n);
178}
179
180static inline
181void ogg_vect_mult_fw(ogg_int32_t *data, LOOKUP_T *window, int n)
182{
183 while(n>0) {
184 *data = MULT31(*data, *window);
185 data++;
186 window++;
187 n--;
188 }
189}
190
191static inline
192void ogg_vect_mult_bw(ogg_int32_t *data, LOOKUP_T *window, int n)
193{
194 while(n>0) {
195 *data = MULT31(*data, *window);
196 data++;
197 window--;
198 n--;
199 }
200}
201
202/* generic memcpy is probably optimal */
203static inline void vect_copy(ogg_int32_t *x, const ogg_int32_t *y, int n)
204{
205 memcpy(x,y,n*sizeof(ogg_int32_t));
206}
207#endif
208
209static inline ogg_int32_t VFLOAT_MULT(ogg_int32_t a,ogg_int32_t ap,
210 ogg_int32_t b,ogg_int32_t bp,
211 ogg_int32_t *p){
212 if(a && b){
213#ifndef _LOW_ACCURACY_
214 *p=ap+bp+32;
215 return MULT32(a,b);
216#else
217 *p=ap+bp+31;
218 return (a>>15)*(b>>16);
219#endif
220 }else
221 return 0;
222}
223#endif
224#endif
225static inline ogg_int32_t VFLOAT_MULTI(ogg_int32_t a,ogg_int32_t ap,
226 ogg_int32_t i,
227 ogg_int32_t *p){
228
229 int ip=_ilog(abs(i))-31;
230 return VFLOAT_MULT(a,ap,i<<-ip,ip,p);
231}
232#if 0
233static inline ogg_int32_t VFLOAT_ADD(ogg_int32_t a,ogg_int32_t ap,
234 ogg_int32_t b,ogg_int32_t bp,
235 ogg_int32_t *p){
236
237 if(!a){
238 *p=bp;
239 return b;
240 }else if(!b){
241 *p=ap;
242 return a;
243 }
244
245 /* yes, this can leak a bit. */
246 if(ap>bp){
247 int shift=ap-bp+1;
248 *p=ap+1;
249 a>>=1;
250 if(shift<32){
251 b=(b+(1<<(shift-1)))>>shift;
252 }else{
253 b=0;
254 }
255 }else{
256 int shift=bp-ap+1;
257 *p=bp+1;
258 b>>=1;
259 if(shift<32){
260 a=(a+(1<<(shift-1)))>>shift;
261 }else{
262 a=0;
263 }
264 }
265
266 a+=b;
267 if((a&0xc0000000)==0xc0000000 ||
268 (a&0xc0000000)==0){
269 a<<=1;
270 (*p)--;
271 }
272 return(a);
273}
274#endif
275#endif
276
diff --git a/lib/rbcodec/codecs/libtremor/ogg.h b/lib/rbcodec/codecs/libtremor/ogg.h
new file mode 100644
index 0000000000..d3af919b85
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/ogg.h
@@ -0,0 +1,282 @@
1/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
4 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
5 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
6 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
7 * *
8 * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 *
9 * by the Xiph.Org Foundation http://www.xiph.org/ *
10 * *
11 ********************************************************************
12
13 function: toplevel libogg include
14 last mod: $Id$
15
16 ********************************************************************/
17#ifndef _OGG_H
18#define _OGG_H
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24#include <stddef.h>
25#include "os_types.h"
26
27extern const unsigned long mask[] ICONST_ATTR;
28
29typedef struct {
30 void *iov_base;
31 size_t iov_len;
32} ogg_iovec_t;
33
34typedef struct {
35 long endbyte;
36 int endbit;
37
38 unsigned char *buffer;
39 unsigned char *ptr;
40 long storage;
41} oggpack_buffer;
42
43/* ogg_page is used to encapsulate the data in one Ogg bitstream page *****/
44
45typedef struct {
46 unsigned char *header;
47 long header_len;
48 unsigned char *body;
49 long body_len;
50} ogg_page;
51
52/* ogg_stream_state contains the current encode/decode state of a logical
53 Ogg bitstream **********************************************************/
54
55typedef struct {
56 unsigned char *body_data; /* bytes from packet bodies */
57 long body_storage; /* storage elements allocated */
58 long body_fill; /* elements stored; fill mark */
59 long body_returned; /* elements of fill returned */
60
61
62 int *lacing_vals; /* The values that will go to the segment table */
63 ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact
64 this way, but it is simple coupled to the
65 lacing fifo */
66 long lacing_storage;
67 long lacing_fill;
68 long lacing_packet;
69 long lacing_returned;
70
71#if 0
72 unsigned char header[282]; /* working space for header encode */
73 int header_fill;
74#endif
75 int e_o_s; /* set when we have buffered the last packet in the
76 logical bitstream */
77 int b_o_s; /* set after we've written the initial page
78 of a logical bitstream */
79 ogg_uint32_t serialno;
80 long pageno;
81 ogg_int64_t packetno; /* sequence number for decode; the framing
82 knows where there's a hole in the data,
83 but we need coupling so that the codec
84 (which is in a separate abstraction
85 layer) also knows about the gap */
86 ogg_int64_t granulepos;
87
88} ogg_stream_state;
89
90/* ogg_packet is used to encapsulate the data and metadata belonging
91 to a single raw Ogg/Vorbis packet *************************************/
92
93typedef struct {
94 unsigned char *packet;
95 long bytes;
96 long b_o_s;
97 long e_o_s;
98
99 ogg_int64_t granulepos;
100
101 ogg_int64_t packetno; /* sequence number for decode; the framing
102 knows where there's a hole in the data,
103 but we need coupling so that the codec
104 (which is in a separate abstraction
105 layer) also knows about the gap */
106} ogg_packet;
107
108typedef struct {
109 unsigned char *data;
110 int storage;
111 int fill;
112 int returned;
113
114 int unsynced;
115 int headerbytes;
116 int bodybytes;
117} ogg_sync_state;
118
119/* Ogg BITSTREAM PRIMITIVES: bitstream ************************/
120/*
121extern void oggpack_writeinit(oggpack_buffer *b);
122extern int oggpack_writecheck(oggpack_buffer *b);
123extern void oggpack_writetrunc(oggpack_buffer *b,long bits);
124extern void oggpack_writealign(oggpack_buffer *b);
125extern void oggpack_writecopy(oggpack_buffer *b,void *source,long bits);
126extern void oggpack_reset(oggpack_buffer *b);
127extern void oggpack_writeclear(oggpack_buffer *b); */
128extern void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
129/*
130extern void oggpack_write(oggpack_buffer *b,unsigned long value,int bits);
131extern long oggpack_look(oggpack_buffer *b,int bits);
132*/
133
134static inline long oggpack_look(oggpack_buffer *b,int bits){
135 unsigned long ret;
136 unsigned long m;
137
138 if(bits<0 || bits>32) return -1;
139 m=mask[bits];
140 bits+=b->endbit;
141
142 if(b->endbyte >= b->storage-4){
143 /* not the main path */
144 if(b->endbyte > b->storage-((bits+7)>>3)) return -1;
145 /* special case to avoid reading b->ptr[0], which might be past the end of
146 the buffer; also skips some useless accounting */
147 else if(!bits)return(0L);
148 }
149
150 ret=b->ptr[0]>>b->endbit;
151 if(bits>8){
152 ret|=b->ptr[1]<<(8-b->endbit);
153 if(bits>16){
154 ret|=b->ptr[2]<<(16-b->endbit);
155 if(bits>24){
156 ret|=b->ptr[3]<<(24-b->endbit);
157 if(bits>32 && b->endbit)
158 ret|=b->ptr[4]<<(32-b->endbit);
159 }
160 }
161 }
162 return(m&ret);
163}
164/*
165extern long oggpack_look1(oggpack_buffer *b);
166extern void oggpack_adv(oggpack_buffer *b,int bits);
167*/
168
169static inline void oggpack_adv(oggpack_buffer *b, unsigned int bits){
170 bits+=b->endbit;
171
172 if(b->endbyte > b->storage-(int)((bits+7)>>3)) goto overflow;
173
174 b->ptr+=bits/8;
175 b->endbyte+=bits/8;
176 b->endbit=bits&7;
177 return;
178
179 overflow:
180 b->ptr=NULL;
181 b->endbyte=b->storage;
182 b->endbit=1;
183}
184
185/*
186extern void oggpack_adv1(oggpack_buffer *b);
187*/
188extern long oggpack_read(oggpack_buffer *b,int bits);
189/*
190extern long oggpack_read1(oggpack_buffer *b);
191extern long oggpack_bytes(oggpack_buffer *b);
192*/
193static inline long oggpack_bytes(oggpack_buffer *b){
194 return(b->endbyte+(b->endbit+7)/8);
195}
196#if 0
197extern long oggpack_bits(oggpack_buffer *b);
198extern unsigned char *oggpack_get_buffer(oggpack_buffer *b);
199
200extern void oggpackB_writeinit(oggpack_buffer *b);
201extern int oggpackB_writecheck(oggpack_buffer *b);
202extern void oggpackB_writetrunc(oggpack_buffer *b,long bits);
203extern void oggpackB_writealign(oggpack_buffer *b);
204extern void oggpackB_writecopy(oggpack_buffer *b,void *source,long bits);
205extern void oggpackB_reset(oggpack_buffer *b);
206extern void oggpackB_writeclear(oggpack_buffer *b);
207extern void oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
208extern void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits);
209extern long oggpackB_look(oggpack_buffer *b,int bits);
210extern long oggpackB_look1(oggpack_buffer *b);
211extern void oggpackB_adv(oggpack_buffer *b,int bits);
212extern void oggpackB_adv1(oggpack_buffer *b);
213extern long oggpackB_read(oggpack_buffer *b,int bits);
214extern long oggpackB_read1(oggpack_buffer *b);
215extern long oggpackB_bytes(oggpack_buffer *b);
216extern long oggpackB_bits(oggpack_buffer *b);
217extern unsigned char *oggpackB_get_buffer(oggpack_buffer *b);
218# endif
219/* Ogg BITSTREAM PRIMITIVES: encoding **************************/
220#if 0
221extern int ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op);
222extern int ogg_stream_iovecin(ogg_stream_state *os, ogg_iovec_t *iov,
223 int count, long e_o_s, ogg_int64_t granulepos);
224extern int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og);
225extern int ogg_stream_pageout_fill(ogg_stream_state *os, ogg_page *og, int nfill);
226extern int ogg_stream_flush(ogg_stream_state *os, ogg_page *og);
227#endif
228/* Ogg BITSTREAM PRIMITIVES: decoding **************************/
229
230extern int _os_body_expand(ogg_stream_state *os,int needed);
231
232extern int ogg_sync_init(ogg_sync_state *oy);
233extern int ogg_sync_clear(ogg_sync_state *oy);
234extern int ogg_sync_reset(ogg_sync_state *oy);
235/*
236extern int ogg_sync_destroy(ogg_sync_state *oy);
237extern int ogg_sync_check(ogg_sync_state *oy);
238*/
239
240extern char *ogg_sync_buffer(ogg_sync_state *oy, long size);
241extern int ogg_sync_wrote(ogg_sync_state *oy, long bytes);
242extern long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og);
243/*
244extern int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
245*/
246extern int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og, bool copy_body);
247extern int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
248extern int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op);
249
250/* Ogg BITSTREAM PRIMITIVES: general ***************************/
251
252extern int ogg_stream_init(ogg_stream_state *os,int serialno);
253extern int ogg_stream_clear(ogg_stream_state *os);
254extern int ogg_stream_reset(ogg_stream_state *os);
255extern int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno);
256/*
257extern int ogg_stream_destroy(ogg_stream_state *os);
258extern int ogg_stream_check(ogg_stream_state *os);
259*/
260extern int ogg_stream_eos(ogg_stream_state *os);
261
262/*
263extern void ogg_page_checksum_set(ogg_page *og);
264extern int ogg_page_version(const ogg_page *og);
265*/
266extern int ogg_page_continued(const ogg_page *og);
267extern int ogg_page_bos(const ogg_page *og);
268extern int ogg_page_eos(const ogg_page *og);
269extern ogg_int64_t ogg_page_granulepos(const ogg_page *og);
270extern ogg_uint32_t ogg_page_serialno(const ogg_page *og);
271/*
272extern long ogg_page_pageno(const ogg_page *og);
273extern int ogg_page_packets(const ogg_page *og);
274
275extern void ogg_packet_clear(ogg_packet *op);
276*/
277
278#ifdef __cplusplus
279}
280#endif
281
282#endif /* _OGG_H */
diff --git a/lib/rbcodec/codecs/libtremor/oggmalloc.c b/lib/rbcodec/codecs/libtremor/oggmalloc.c
new file mode 100644
index 0000000000..783e0f7240
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/oggmalloc.c
@@ -0,0 +1,86 @@
1#include "os_types.h"
2#include <tlsf.h>
3
4#if defined(CPU_ARM) || defined(CPU_COLDFIRE) || defined(CPU_MIPS)
5#include <setjmp.h>
6extern jmp_buf rb_jump_buf;
7#define LONGJMP(x) longjmp(rb_jump_buf, x)
8#elif defined(SIMULATOR)
9#define LONGJMP(x) do { DEBUGF("Vorbis: allocation failed!\n"); return NULL; } while (false)
10#else
11#define LONGJMP(x) return NULL
12#endif
13
14void ogg_malloc_init(void)
15{
16 size_t bufsize;
17 void* buf = ci->codec_get_buffer(&bufsize);
18 init_memory_pool(bufsize, buf);
19}
20
21void ogg_malloc_destroy()
22{
23 size_t bufsize;
24 void* buf = ci->codec_get_buffer(&bufsize);
25 destroy_memory_pool(buf);
26}
27
28void *ogg_malloc(size_t size)
29{
30 void* x = tlsf_malloc(size);
31
32 if (x == NULL)
33 LONGJMP(1);
34
35 return x;
36}
37
38void *ogg_calloc(size_t nmemb, size_t size)
39{
40 void *x = tlsf_calloc(nmemb, size);
41
42 if (x == NULL)
43 LONGJMP(1);
44
45 return x;
46}
47
48void *ogg_realloc(void *ptr, size_t size)
49{
50 void *x = tlsf_realloc(ptr, size);
51
52 if (x == NULL)
53 LONGJMP(1);
54
55 return x;
56}
57
58void ogg_free(void* ptr)
59{
60 tlsf_free(ptr);
61}
62
63#ifdef TREMOR_USE_IRAM
64/* Allocate IRAM buffer */
65static unsigned char iram_buff[IRAM_IBSS_SIZE] IBSS_ATTR MEM_ALIGN_ATTR;
66static size_t iram_remain;
67
68void iram_malloc_init(void){
69 iram_remain=IRAM_IBSS_SIZE;
70}
71
72void *iram_malloc(size_t size){
73 void* x;
74
75 /* always ensure alignment to CACHEALIGN_SIZE byte */
76 size = (size + (CACHEALIGN_SIZE-1)) & ~(CACHEALIGN_SIZE-1);
77
78 if(size>iram_remain)
79 return NULL;
80
81 x = &iram_buff[IRAM_IBSS_SIZE-iram_remain];
82 iram_remain-=size;
83
84 return x;
85}
86#endif
diff --git a/lib/rbcodec/codecs/libtremor/os.h b/lib/rbcodec/codecs/libtremor/os.h
new file mode 100644
index 0000000000..bafcaedb62
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/os.h
@@ -0,0 +1,62 @@
1#ifndef _OS_H
2#define _OS_H
3/********************************************************************
4 * *
5 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
6 * *
7 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
8 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
9 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
10 * *
11 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
12 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
13 * *
14 ********************************************************************
15
16 function: #ifdef jail to whip a few platforms into the UNIX ideal.
17
18 ********************************************************************/
19
20#include <math.h>
21#include "os_types.h"
22
23#ifndef _V_IFDEFJAIL_H_
24# define _V_IFDEFJAIL_H_
25
26# ifdef __GNUC__
27# define STIN static inline
28# elif defined(_WIN32)
29# define STIN static __inline__
30# endif
31#else
32# define STIN static inline
33#endif
34
35#ifndef M_PI
36# define M_PI (3.1415926536f)
37#endif
38
39#ifdef _WIN32
40# include <malloc.h>
41# define rint(x) (floor((x)+0.5f))
42# define NO_FLOAT_MATH_LIB
43# define FAST_HYPOT(a, b) sqrt((a)*(a) + (b)*(b))
44#endif
45
46#ifdef HAVE_ALLOCA_H
47# include <alloca.h>
48#endif
49
50#ifdef USE_MEMORY_H
51# include <memory.h>
52#endif
53
54#ifndef min
55# define min(x,y) ((x)>(y)?(y):(x))
56#endif
57
58#ifndef max
59# define max(x,y) ((x)<(y)?(y):(x))
60#endif
61
62#endif /* _OS_H */
diff --git a/lib/rbcodec/codecs/libtremor/os_types.h b/lib/rbcodec/codecs/libtremor/os_types.h
new file mode 100644
index 0000000000..b5bd0b713a
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/os_types.h
@@ -0,0 +1,58 @@
1/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
4 * *
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * *
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
11 * *
12 ********************************************************************
13
14 function: #ifdef jail to whip a few platforms into the UNIX ideal.
15
16 ********************************************************************/
17#include "config-tremor.h"
18
19#ifndef _OS_TYPES_H
20#define _OS_TYPES_H
21
22#include <stdint.h>
23#include <stdlib.h>
24#include <codecs.h>
25
26#ifdef _LOW_ACCURACY_
27# define X(n) (((((n)>>22)+1)>>1) - ((((n)>>22)+1)>>9))
28# define LOOKUP_T const unsigned char
29# define LOOKUP_TNC unsigned char
30#else
31# define X(n) (n)
32# define LOOKUP_T const ogg_int32_t
33# define LOOKUP_TNC ogg_int32_t
34#endif
35
36/* make it easy on the folks that want to compile the libs with a
37 different malloc than stdlib */
38
39#define _ogg_malloc ogg_malloc
40#define _ogg_calloc ogg_calloc
41#define _ogg_realloc ogg_realloc
42#define _ogg_free ogg_free
43
44void ogg_malloc_init(void);
45void ogg_malloc_destroy(void);
46void *ogg_malloc(size_t size);
47void *ogg_calloc(size_t nmemb, size_t size);
48void *ogg_realloc(void *ptr, size_t size);
49void ogg_free(void *ptr);
50void iram_malloc_init(void);
51void *iram_malloc(size_t size);
52
53 typedef int16_t ogg_int16_t;
54 typedef int32_t ogg_int32_t;
55 typedef uint32_t ogg_uint32_t;
56 typedef int64_t ogg_int64_t;
57
58#endif /* _OS_TYPES_H */
diff --git a/lib/rbcodec/codecs/libtremor/registry.c b/lib/rbcodec/codecs/libtremor/registry.c
new file mode 100644
index 0000000000..b1592628a1
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/registry.c
@@ -0,0 +1,50 @@
1/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
4 * *
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * *
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
11 * *
12 ********************************************************************
13
14 function: registry for floor, res backends and channel mappings
15
16 ********************************************************************/
17
18#include "ivorbiscodec.h"
19#include "codec_internal.h"
20#include "registry.h"
21#include "misc.h"
22
23
24/* seems like major overkill now; the backend numbers will grow into
25 the infrastructure soon enough */
26
27extern vorbis_func_floor floor0_exportbundle;
28extern vorbis_func_floor floor1_exportbundle;
29extern vorbis_func_residue residue0_exportbundle;
30extern vorbis_func_residue residue1_exportbundle;
31extern vorbis_func_residue residue2_exportbundle;
32extern vorbis_func_mapping mapping0_exportbundle;
33
34vorbis_func_floor *_floor_P[] ICONST_ATTR = {
35 &floor0_exportbundle,
36 &floor1_exportbundle,
37};
38
39vorbis_func_residue *_residue_P[] ICONST_ATTR = {
40 &residue0_exportbundle,
41 &residue1_exportbundle,
42 &residue2_exportbundle,
43};
44
45vorbis_func_mapping *_mapping_P[] ICONST_ATTR = {
46 &mapping0_exportbundle,
47};
48
49
50
diff --git a/lib/rbcodec/codecs/libtremor/registry.h b/lib/rbcodec/codecs/libtremor/registry.h
new file mode 100644
index 0000000000..2bc8068f69
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/registry.h
@@ -0,0 +1,40 @@
1/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
4 * *
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * *
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
11 * *
12 ********************************************************************
13
14 function: registry for time, floor, res backends and channel mappings
15
16 ********************************************************************/
17
18#ifndef _V_REG_H_
19#define _V_REG_H_
20
21#define VI_TRANSFORMB 1
22#define VI_WINDOWB 1
23#define VI_TIMEB 1
24#define VI_FLOORB 2
25#define VI_RESB 3
26#define VI_MAPB 1
27
28#include "backends.h"
29
30#if defined(_WIN32) && defined(VORBISDLL_IMPORT)
31# define EXTERN __declspec(dllimport) extern
32#else
33# define EXTERN extern
34#endif
35
36EXTERN vorbis_func_floor *_floor_P[];
37EXTERN vorbis_func_residue *_residue_P[];
38EXTERN vorbis_func_mapping *_mapping_P[];
39
40#endif
diff --git a/lib/rbcodec/codecs/libtremor/res012.c b/lib/rbcodec/codecs/libtremor/res012.c
new file mode 100644
index 0000000000..e4ff440a6d
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/res012.c
@@ -0,0 +1,374 @@
1/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
4 * *
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * *
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
11 * *
12 ********************************************************************
13
14 function: residue backend 0, 1 and 2 implementation
15
16 ********************************************************************/
17
18#include "config-tremor.h"
19#include <string.h>
20#include <math.h>
21#include "ogg.h"
22#include "ivorbiscodec.h"
23#include "codec_internal.h"
24#include "registry.h"
25#include "codebook.h"
26#include "misc.h"
27#include "os.h"
28
29typedef struct {
30 vorbis_info_residue0 *info;
31 int map;
32
33 int parts;
34 int stages;
35 codebook *fullbooks;
36 codebook *phrasebook;
37 codebook ***partbooks;
38
39 int partvals;
40 int **decodemap;
41
42} vorbis_look_residue0;
43
44static void res0_free_info(vorbis_info_residue *i){
45 vorbis_info_residue0 *info=(vorbis_info_residue0 *)i;
46 if(info){
47 memset(info,0,sizeof(*info));
48 _ogg_free(info);
49 }
50}
51
52static void res0_free_look(vorbis_look_residue *i){
53 int j;
54 if(i){
55
56 vorbis_look_residue0 *look=(vorbis_look_residue0 *)i;
57
58 for(j=0;j<look->parts;j++)
59 if(look->partbooks[j])_ogg_free(look->partbooks[j]);
60 _ogg_free(look->partbooks);
61 for(j=0;j<look->partvals;j++)
62 _ogg_free(look->decodemap[j]);
63 _ogg_free(look->decodemap);
64
65 memset(look,0,sizeof(*look));
66 _ogg_free(look);
67 }
68}
69
70static int ilog(unsigned int v){
71 int ret=0;
72 while(v){
73 ret++;
74 v>>=1;
75 }
76 return(ret);
77}
78
79static int icount(unsigned int v){
80 int ret=0;
81 while(v){
82 ret+=v&1;
83 v>>=1;
84 }
85 return(ret);
86}
87
88/* vorbis_info is for range checking */
89static vorbis_info_residue *res0_unpack(vorbis_info *vi,oggpack_buffer *opb){
90 int j,acc=0;
91 vorbis_info_residue0 *info=(vorbis_info_residue0 *)_ogg_calloc(1,sizeof(*info));
92 codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
93
94 info->begin=oggpack_read(opb,24);
95 info->end=oggpack_read(opb,24);
96 info->grouping=oggpack_read(opb,24)+1;
97 info->partitions=oggpack_read(opb,6)+1;
98 info->groupbook=oggpack_read(opb,8);
99
100 /* check for premature EOP */
101 if(info->groupbook<0)goto errout;
102
103 for(j=0;j<info->partitions;j++){
104 int cascade=oggpack_read(opb,3);
105 int cflag=oggpack_read(opb,1);
106 if(cflag<0) goto errout;
107 if(cflag){
108 int c=oggpack_read(opb,5);
109 if(c<0) goto errout;
110 cascade|=(c<<3);
111 }
112 info->secondstages[j]=cascade;
113
114 acc+=icount(cascade);
115 }
116 for(j=0;j<acc;j++){
117 int book=oggpack_read(opb,8);
118 if(book<0) goto errout;
119 info->booklist[j]=book;
120 }
121
122 if(info->groupbook>=ci->books)goto errout;
123 for(j=0;j<acc;j++){
124 if(info->booklist[j]>=ci->books)goto errout;
125 if(ci->book_param[info->booklist[j]]->maptype==0)goto errout;
126 }
127
128 /* verify the phrasebook is not specifying an impossible or
129 inconsistent partitioning scheme. */
130 /* modify the phrasebook ranging check from r16327; an early beta
131 encoder had a bug where it used an oversized phrasebook by
132 accident. These files should continue to be playable, but don't
133 allow an exploit */
134 {
135 int entries = ci->book_param[info->groupbook]->entries;
136 int dim = ci->book_param[info->groupbook]->dim;
137 int partvals = 1;
138 if (dim<1) goto errout;
139 while(dim>0){
140 partvals *= info->partitions;
141 if(partvals > entries) goto errout;
142 dim--;
143 }
144 info->partvals = partvals;
145 }
146
147 return(info);
148 errout:
149 res0_free_info(info);
150 return(NULL);
151}
152
153static vorbis_look_residue *res0_look(vorbis_dsp_state *vd,vorbis_info_mode *vm,
154 vorbis_info_residue *vr){
155 vorbis_info_residue0 *info=(vorbis_info_residue0 *)vr;
156 vorbis_look_residue0 *look=(vorbis_look_residue0 *)_ogg_calloc(1,sizeof(*look));
157 codec_setup_info *ci=(codec_setup_info *)vd->vi->codec_setup;
158
159 int j,k,acc=0;
160 int dim;
161 int maxstage=0;
162 look->info=info;
163 look->map=vm->mapping;
164
165 look->parts=info->partitions;
166 look->fullbooks=ci->fullbooks;
167 look->phrasebook=ci->fullbooks+info->groupbook;
168 dim=look->phrasebook->dim;
169
170 look->partbooks=(codebook ***)_ogg_calloc(look->parts,sizeof(*look->partbooks));
171
172 for(j=0;j<look->parts;j++){
173 int stages=ilog(info->secondstages[j]);
174 if(stages){
175 if(stages>maxstage)maxstage=stages;
176 look->partbooks[j]=(codebook **)_ogg_calloc(stages,sizeof(*look->partbooks[j]));
177 for(k=0;k<stages;k++)
178 if(info->secondstages[j]&(1<<k)){
179 look->partbooks[j][k]=ci->fullbooks+info->booklist[acc++];
180#ifdef TRAIN_RES
181 look->training_data[k][j]=calloc(look->partbooks[j][k]->entries,
182 sizeof(***look->training_data));
183#endif
184 }
185 }
186 }
187
188 look->partvals=look->parts;
189 for(j=1;j<dim;j++)look->partvals*=look->parts;
190 look->stages=maxstage;
191 look->decodemap=(int **)_ogg_malloc(look->partvals*sizeof(*look->decodemap));
192 for(j=0;j<look->partvals;j++){
193 long val=j;
194 long mult=look->partvals/look->parts;
195 look->decodemap[j]=(int *)_ogg_malloc(dim*sizeof(*look->decodemap[j]));
196 for(k=0;k<dim;k++){
197 long deco=val/mult;
198 val-=deco*mult;
199 mult/=look->parts;
200 look->decodemap[j][k]=deco;
201 }
202 }
203
204 return(look);
205}
206
207/* a truncated packet here just means 'stop working'; it's not an error */
208static int _01inverse(vorbis_block *vb,vorbis_look_residue *vl,
209 ogg_int32_t **in,int ch,
210 long (*decodepart)(codebook *, ogg_int32_t *,
211 oggpack_buffer *,int,int)){
212
213 long i,j,k,l,s;
214 vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl;
215 vorbis_info_residue0 *info=look->info;
216
217 /* move all this setup out later */
218 int samples_per_partition=info->grouping;
219 int partitions_per_word=look->phrasebook->dim;
220 int max=vb->pcmend>>1;
221 int end=(info->end<max?info->end:max);
222 int n=end-info->begin;
223
224 if(n>0){
225 int partvals=n/samples_per_partition;
226 int partwords=(partvals+partitions_per_word-1)/partitions_per_word;
227 int ***partword=(int ***)alloca(ch*sizeof(*partword));
228
229 for(j=0;j<ch;j++)
230 partword[j]=(int **)_vorbis_block_alloc(vb,partwords*sizeof(*partword[j]));
231
232 for(s=0;s<look->stages;s++){
233
234 /* each loop decodes on partition codeword containing
235 partitions_pre_word partitions */
236 for(i=0,l=0;i<partvals;l++){
237 if(s==0){
238 /* fetch the partition word for each channel */
239 for(j=0;j<ch;j++){
240 int temp=vorbis_book_decode(look->phrasebook,&vb->opb);
241 if(temp==-1 || temp>=info->partvals)goto eopbreak;
242 partword[j][l]=look->decodemap[temp];
243 if(partword[j][l]==NULL)goto errout;
244 }
245 }
246
247 /* now we decode residual values for the partitions */
248 for(k=0;k<partitions_per_word && i<partvals;k++,i++)
249 for(j=0;j<ch;j++){
250 long offset=info->begin+i*samples_per_partition;
251 if(info->secondstages[partword[j][l][k]]&(1<<s)){
252 codebook *stagebook=look->partbooks[partword[j][l][k]][s];
253 if(stagebook){
254 if(decodepart(stagebook,in[j]+offset,&vb->opb,
255 samples_per_partition,-8)==-1)goto eopbreak;
256 }
257 }
258 }
259 }
260 }
261 }
262 errout:
263 eopbreak:
264 return(0);
265}
266
267static int res0_inverse(vorbis_block *vb,vorbis_look_residue *vl,
268 ogg_int32_t **in,int *nonzero,int ch){
269 int i,used=0;
270 for(i=0;i<ch;i++)
271 if(nonzero[i])
272 in[used++]=in[i];
273 if(used)
274 return(_01inverse(vb,vl,in,used,vorbis_book_decodevs_add));
275 else
276 return(0);
277}
278
279static int res1_inverse(vorbis_block *vb,vorbis_look_residue *vl,
280 ogg_int32_t **in,int *nonzero,int ch){
281 int i,used=0;
282 for(i=0;i<ch;i++)
283 if(nonzero[i])
284 in[used++]=in[i];
285 if(used)
286 return(_01inverse(vb,vl,in,used,vorbis_book_decodev_add));
287 else
288 return(0);
289}
290
291/* duplicate code here as speed is somewhat more important */
292static int res2_inverse(vorbis_block *vb,vorbis_look_residue *vl,
293 ogg_int32_t **in,int *nonzero,int ch)
294 ICODE_ATTR_TREMOR_NOT_MDCT;
295static int res2_inverse(vorbis_block *vb,vorbis_look_residue *vl,
296 ogg_int32_t **in,int *nonzero,int ch){
297 long i,k,l,s;
298 vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl;
299 vorbis_info_residue0 *info=look->info;
300
301 /* move all this setup out later */
302 int samples_per_partition=info->grouping;
303 int partitions_per_word=look->phrasebook->dim;
304 int max=(vb->pcmend*ch)>>1;
305 int end=(info->end<max?info->end:max);
306 int n=end-info->begin;
307
308 if(n>0){
309
310 int partvals=n/samples_per_partition;
311 int partwords=(partvals+partitions_per_word-1)/partitions_per_word;
312 int **partword=(int **)_vorbis_block_alloc(vb,partwords*sizeof(*partword));
313 int beginoff=info->begin/ch;
314
315 for(i=0;i<ch;i++)if(nonzero[i])break;
316 if(i==ch)return(0); /* no nonzero vectors */
317
318 samples_per_partition/=ch;
319
320 for(s=0;s<look->stages;s++){
321 for(i=0,l=0;i<partvals;l++){
322
323 if(s==0){
324 /* fetch the partition word */
325 int temp=vorbis_book_decode(look->phrasebook,&vb->opb);
326 if(temp==-1 || temp>=info->partvals)goto eopbreak;
327 partword[l]=look->decodemap[temp];
328 if(partword[l]==NULL)goto errout;
329 }
330
331 /* now we decode residual values for the partitions */
332 for(k=0;k<partitions_per_word && i<partvals;k++,i++)
333 if(info->secondstages[partword[l][k]]&(1<<s)){
334 codebook *stagebook=look->partbooks[partword[l][k]][s];
335 if(stagebook){
336 if(vorbis_book_decodevv_add(stagebook,in,
337 i*samples_per_partition+beginoff,ch,
338 &vb->opb,
339 samples_per_partition,-8)==-1)
340 goto eopbreak;
341 }
342 }
343 }
344 }
345 }
346 errout:
347 eopbreak:
348 return(0);
349}
350
351
352const vorbis_func_residue residue0_exportbundle ICONST_ATTR ={
353 &res0_unpack,
354 &res0_look,
355 &res0_free_info,
356 &res0_free_look,
357 &res0_inverse
358};
359
360const vorbis_func_residue residue1_exportbundle ICONST_ATTR ={
361 &res0_unpack,
362 &res0_look,
363 &res0_free_info,
364 &res0_free_look,
365 &res1_inverse
366};
367
368const vorbis_func_residue residue2_exportbundle ICONST_ATTR ={
369 &res0_unpack,
370 &res0_look,
371 &res0_free_info,
372 &res0_free_look,
373 &res2_inverse
374};
diff --git a/lib/rbcodec/codecs/libtremor/sharedbook.c b/lib/rbcodec/codecs/libtremor/sharedbook.c
new file mode 100644
index 0000000000..8b046217c7
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/sharedbook.c
@@ -0,0 +1,460 @@
1/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
4 * *
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * *
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
11 * *
12 ********************************************************************
13
14 function: basic shared codebook operations
15
16 ********************************************************************/
17
18#include "config-tremor.h"
19#include <math.h>
20#include <string.h>
21#include "ogg.h"
22#include "os.h"
23#include "misc.h"
24#include "ivorbiscodec.h"
25#include "codebook.h"
26
27/**** pack/unpack helpers ******************************************/
28int _ilog(unsigned int v){
29 int ret=0;
30 while(v){
31 ret++;
32 v>>=1;
33 }
34 return(ret);
35}
36
37/* 32 bit float (not IEEE; nonnormalized mantissa +
38 biased exponent) : neeeeeee eeemmmmm mmmmmmmm mmmmmmmm
39 Why not IEEE? It's just not that important here. */
40
41#define VQ_FEXP 10
42#define VQ_FMAN 21
43#define VQ_FEXP_BIAS 768 /* bias toward values smaller than 1. */
44
45static ogg_int32_t _float32_unpack(long val,int *point){
46 long mant=val&0x1fffff;
47 int sign=val&0x80000000;
48 long exp =(val&0x7fe00000L)>>VQ_FMAN;
49
50 exp-=(VQ_FMAN-1)+VQ_FEXP_BIAS;
51
52 if(mant){
53 while(!(mant&0x40000000)){
54 mant<<=1;
55 exp-=1;
56 }
57
58 if(sign)mant= -mant;
59 }else{
60 sign=0;
61 exp=-9999;
62 }
63
64 *point=exp;
65 return mant;
66}
67
68/* given a list of word lengths, generate a list of codewords. Works
69 for length ordered or unordered, always assigns the lowest valued
70 codewords first. Extended to handle unused entries (length 0) */
71static ogg_uint32_t *_make_words(long *l,long n,long sparsecount){
72 long i,j,count=0;
73 ogg_uint32_t marker[33];
74 ogg_uint32_t *r=(ogg_uint32_t *)_ogg_malloc((sparsecount?sparsecount:n)*sizeof(*r));
75 memset(marker,0,sizeof(marker));
76
77 for(i=0;i<n;i++){
78 long length=l[i];
79 if(length>0){
80 ogg_uint32_t entry=marker[length];
81
82 /* when we claim a node for an entry, we also claim the nodes
83 below it (pruning off the imagined tree that may have dangled
84 from it) as well as blocking the use of any nodes directly
85 above for leaves */
86
87 /* update ourself */
88 if(length<32 && (entry>>length)){
89 /* error condition; the lengths must specify an overpopulated tree */
90 _ogg_free(r);
91 return(NULL);
92 }
93 r[count++]=entry;
94
95 /* Look to see if the next shorter marker points to the node
96 above. if so, update it and repeat. */
97 {
98 for(j=length;j>0;j--){
99
100 if(marker[j]&1){
101 /* have to jump branches */
102 if(j==1)
103 marker[1]++;
104 else
105 marker[j]=marker[j-1]<<1;
106 break; /* invariant says next upper marker would already
107 have been moved if it was on the same path */
108 }
109 marker[j]++;
110 }
111 }
112
113 /* prune the tree; the implicit invariant says all the longer
114 markers were dangling from our just-taken node. Dangle them
115 from our *new* node. */
116 for(j=length+1;j<33;j++)
117 if((marker[j]>>1) == entry){
118 entry=marker[j];
119 marker[j]=marker[j-1]<<1;
120 }else
121 break;
122 }else
123 if(sparsecount==0)count++;
124 }
125
126 /* sanity check the huffman tree; an underpopulated tree must be
127 rejected. The only exception is the one-node pseudo-nil tree,
128 which appears to be underpopulated because the tree doesn't
129 really exist; there's only one possible 'codeword' or zero bits,
130 but the above tree-gen code doesn't mark that. */
131 if(sparsecount != 1){
132 for(i=1;i<33;i++)
133 if(marker[i] & (0xffffffffUL>>(32-i))){
134 _ogg_free(r);
135 return(NULL);
136 }
137 }
138
139 /* bitreverse the words because our bitwise packer/unpacker is LSb
140 endian */
141 for(i=0,count=0;i<n;i++){
142 ogg_uint32_t temp=0;
143 for(j=0;j<l[i];j++){
144 temp<<=1;
145 temp|=(r[count]>>j)&1;
146 }
147
148 if(sparsecount){
149 if(l[i])
150 r[count++]=temp;
151 }else
152 r[count++]=temp;
153 }
154
155 return(r);
156}
157
158/* there might be a straightforward one-line way to do the below
159 that's portable and totally safe against roundoff, but I haven't
160 thought of it. Therefore, we opt on the side of caution */
161long _book_maptype1_quantvals(const static_codebook *b){
162 /* get us a starting hint, we'll polish it below */
163 int bits=_ilog(b->entries);
164 int vals=b->entries>>((bits-1)*(b->dim-1)/b->dim);
165
166 while(1){
167 long acc=1;
168 long acc1=1;
169 int i;
170 for(i=0;i<b->dim;i++){
171 acc*=vals;
172 acc1*=vals+1;
173 }
174 if(acc<=b->entries && acc1>b->entries){
175 return(vals);
176 }else{
177 if(acc>b->entries){
178 vals--;
179 }else{
180 vals++;
181 }
182 }
183 }
184}
185
186/* different than what _book_unquantize does for mainline:
187 we repack the book in a fixed point format that shares the same
188 binary point. Upon first use, we can shift point if needed */
189
190/* we need to deal with two map types: in map type 1, the values are
191 generated algorithmically (each column of the vector counts through
192 the values in the quant vector). in map type 2, all the values came
193 in in an explicit list. Both value lists must be unpacked */
194
195static ogg_int32_t *_book_unquantize(const static_codebook *b,int n,
196 int *sparsemap,int *maxpoint){
197 long j,k,count=0;
198 if(b->maptype==1 || b->maptype==2){
199 int quantvals;
200 int minpoint,delpoint;
201 ogg_int32_t mindel=_float32_unpack(b->q_min,&minpoint);
202 ogg_int32_t delta=_float32_unpack(b->q_delta,&delpoint);
203 ogg_int32_t *r=(ogg_int32_t *)_ogg_calloc(n*b->dim,sizeof(*r));
204 int *rp=(int *)_ogg_calloc(n*b->dim,sizeof(*rp));
205
206 *maxpoint=minpoint;
207
208 /* maptype 1 and 2 both use a quantized value vector, but
209 different sizes */
210 switch(b->maptype){
211 case 1:
212 /* most of the time, entries%dimensions == 0, but we need to be
213 well defined. We define that the possible vales at each
214 scalar is values == entries/dim. If entries%dim != 0, we'll
215 have 'too few' values (values*dim<entries), which means that
216 we'll have 'left over' entries; left over entries use zeroed
217 values (and are wasted). So don't generate codebooks like
218 that */
219 quantvals=_book_maptype1_quantvals(b);
220 for(j=0;j<b->entries;j++){
221 if((sparsemap && b->lengthlist[j]) || !sparsemap){
222 ogg_int32_t last=0;
223 int lastpoint=0;
224 int indexdiv=1;
225 for(k=0;k<b->dim;k++){
226 int index= (j/indexdiv)%quantvals;
227 ogg_int32_t point=0;
228 int val=VFLOAT_MULTI(delta,delpoint,
229 abs(b->quantlist[index]),&point);
230
231 val=VFLOAT_ADD(mindel,minpoint,val,point,&point);
232 val=VFLOAT_ADD(last,lastpoint,val,point,&point);
233
234 if(b->q_sequencep){
235 last=val;
236 lastpoint=point;
237 }
238
239 if(sparsemap){
240 r[sparsemap[count]*b->dim+k]=val;
241 rp[sparsemap[count]*b->dim+k]=point;
242 }else{
243 r[count*b->dim+k]=val;
244 rp[count*b->dim+k]=point;
245 }
246 if(*maxpoint<point)*maxpoint=point;
247 indexdiv*=quantvals;
248 }
249 count++;
250 }
251
252 }
253 break;
254 case 2:
255 for(j=0;j<b->entries;j++){
256 if((sparsemap && b->lengthlist[j]) || !sparsemap){
257 ogg_int32_t last=0;
258 int lastpoint=0;
259
260 for(k=0;k<b->dim;k++){
261 ogg_int32_t point=0;
262 int val=VFLOAT_MULTI(delta,delpoint,
263 abs(b->quantlist[j*b->dim+k]),&point);
264
265 val=VFLOAT_ADD(mindel,minpoint,val,point,&point);
266 val=VFLOAT_ADD(last,lastpoint,val,point,&point);
267
268 if(b->q_sequencep){
269 last=val;
270 lastpoint=point;
271 }
272
273 if(sparsemap){
274 r[sparsemap[count]*b->dim+k]=val;
275 rp[sparsemap[count]*b->dim+k]=point;
276 }else{
277 r[count*b->dim+k]=val;
278 rp[count*b->dim+k]=point;
279 }
280 if(*maxpoint<point)*maxpoint=point;
281 }
282 count++;
283 }
284 }
285 break;
286 }
287
288 for(j=0;j<n*b->dim;j++)
289 if(rp[j]<*maxpoint)
290 r[j]>>=*maxpoint-rp[j];
291
292 _ogg_free(rp);
293 return(r);
294 }
295 return(NULL);
296}
297
298void vorbis_staticbook_destroy(static_codebook *b){
299 if(b->quantlist)_ogg_free(b->quantlist);
300 if(b->lengthlist)_ogg_free(b->lengthlist);
301 memset(b,0,sizeof(*b));
302 _ogg_free(b);
303}
304
305void vorbis_book_clear(codebook *b){
306 /* static book is not cleared; we're likely called on the lookup and
307 the static codebook belongs to the info struct */
308 if(b->valuelist)_ogg_free(b->valuelist);
309 if(b->codelist)_ogg_free(b->codelist);
310
311 if(b->dec_index)_ogg_free(b->dec_index);
312 if(b->dec_codelengths)_ogg_free(b->dec_codelengths);
313 if(b->dec_firsttable)_ogg_free(b->dec_firsttable);
314
315 memset(b,0,sizeof(*b));
316}
317
318static ogg_uint32_t bitreverse(ogg_uint32_t x){
319 x= ((x>>16)&0x0000ffffUL) | ((x<<16)&0xffff0000UL);
320 x= ((x>> 8)&0x00ff00ffUL) | ((x<< 8)&0xff00ff00UL);
321 x= ((x>> 4)&0x0f0f0f0fUL) | ((x<< 4)&0xf0f0f0f0UL);
322 x= ((x>> 2)&0x33333333UL) | ((x<< 2)&0xccccccccUL);
323 return((x>> 1)&0x55555555UL) | ((x<< 1)&0xaaaaaaaaUL);
324}
325
326static int sort32a(const void *a,const void *b){
327 return (**(ogg_uint32_t **)a>**(ogg_uint32_t **)b)-
328 (**(ogg_uint32_t **)a<**(ogg_uint32_t **)b);
329}
330
331/* decode codebook arrangement is more heavily optimized than encode */
332int vorbis_book_init_decode(codebook *c,const static_codebook *s){
333 int i,j,n=0,tabn;
334 int *sortindex;
335 memset(c,0,sizeof(*c));
336
337 /* count actually used entries */
338 for(i=0;i<s->entries;i++)
339 if(s->lengthlist[i]>0)
340 n++;
341
342 c->entries=s->entries;
343 c->used_entries=n;
344 c->dim=s->dim;
345
346 if(n>0){
347 /* two different remappings go on here.
348
349 First, we collapse the likely sparse codebook down only to
350 actually represented values/words. This collapsing needs to be
351 indexed as map-valueless books are used to encode original entry
352 positions as integers.
353
354 Second, we reorder all vectors, including the entry index above,
355 by sorted bitreversed codeword to allow treeless decode. */
356
357 /* perform sort */
358 ogg_uint32_t *codes=_make_words(s->lengthlist,s->entries,c->used_entries);
359 ogg_uint32_t **codep=(ogg_uint32_t **)_ogg_malloc(sizeof(*codep)*n);
360
361 if(codes==NULL||codep==NULL){
362 _ogg_free(codep);
363 _ogg_free(codes);
364 goto err_out;
365 }
366
367 for(i=0;i<n;i++){
368 codes[i]=bitreverse(codes[i]);
369 codep[i]=codes+i;
370 }
371
372 qsort(codep,n,sizeof(*codep),sort32a);
373
374 sortindex=(int *)_ogg_malloc(n*sizeof(*sortindex));
375 c->codelist=(ogg_uint32_t *)_ogg_malloc(n*sizeof(*c->codelist));
376 /* the index is a reverse index */
377 for(i=0;i<n;i++){
378 int position=codep[i]-codes;
379 sortindex[position]=i;
380 }
381
382 for(i=0;i<n;i++)
383 c->codelist[sortindex[i]]=codes[i];
384 _ogg_free(codep);
385 _ogg_free(codes);
386
387
388
389 c->valuelist=_book_unquantize(s,n,sortindex,&c->binarypoint);
390 c->dec_index=(int *)_ogg_malloc(n*sizeof(*c->dec_index));
391
392 for(n=0,i=0;i<s->entries;i++)
393 if(s->lengthlist[i]>0)
394 c->dec_index[sortindex[n++]]=i;
395
396 c->dec_codelengths=(char *)_ogg_malloc(n*sizeof(*c->dec_codelengths));
397 for(n=0,i=0;i<s->entries;i++)
398 if(s->lengthlist[i]>0)
399 c->dec_codelengths[sortindex[n++]]=s->lengthlist[i];
400
401 _ogg_free(sortindex);
402/* Use a larger cache size when we have a large codec buffer, helps decoding
403 speed especially on targets with slow memory and high bitrate files */
404#if CODEC_SIZE < 0x100000
405 c->dec_firsttablen=_ilog(c->used_entries)-4; /* this is magic */
406#else
407 c->dec_firsttablen=_ilog(c->used_entries)+1; /* this is magic */
408#endif
409 if(c->dec_firsttablen<5)c->dec_firsttablen=5;
410 if(c->dec_firsttablen>8)c->dec_firsttablen=8;
411
412 tabn=1<<c->dec_firsttablen;
413 c->dec_firsttable=(ogg_uint32_t *)_ogg_calloc(tabn,sizeof(*c->dec_firsttable));
414 c->dec_maxlength=0;
415
416 for(i=0;i<n;i++){
417 if(c->dec_maxlength<c->dec_codelengths[i])
418 c->dec_maxlength=c->dec_codelengths[i];
419 if(c->dec_codelengths[i]<=c->dec_firsttablen){
420 ogg_uint32_t orig=bitreverse(c->codelist[i]);
421 for(j=0;j<(1<<(c->dec_firsttablen-c->dec_codelengths[i]));j++)
422 c->dec_firsttable[orig|(j<<c->dec_codelengths[i])]=i+1;
423 }
424 }
425
426 /* now fill in 'unused' entries in the firsttable with hi/lo search
427 hints for the non-direct-hits */
428 {
429 ogg_uint32_t mask=0xfffffffeUL<<(31-c->dec_firsttablen);
430 long lo=0,hi=0;
431
432 for(i=0;i<tabn;i++){
433 ogg_uint32_t word=i<<(32-c->dec_firsttablen);
434 if(c->dec_firsttable[bitreverse(word)]==0){
435 while((lo+1)<n && c->codelist[lo+1]<=word)lo++;
436 while( hi<n && word>=(c->codelist[hi]&mask))hi++;
437
438 /* we only actually have 15 bits per hint to play with here.
439 In order to overflow gracefully (nothing breaks, efficiency
440 just drops), encode as the difference from the extremes. */
441 {
442 unsigned long loval=lo;
443 unsigned long hival=n-hi;
444
445 if(loval>0x7fff)loval=0x7fff;
446 if(hival>0x7fff)hival=0x7fff;
447 c->dec_firsttable[bitreverse(word)]=
448 0x80000000UL | (loval<<15) | hival;
449 }
450 }
451 }
452 }
453 }
454
455 return(0);
456 err_out:
457 vorbis_book_clear(c);
458 return(-1);
459}
460
diff --git a/lib/rbcodec/codecs/libtremor/synthesis.c b/lib/rbcodec/codecs/libtremor/synthesis.c
new file mode 100644
index 0000000000..d1ef99ae37
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/synthesis.c
@@ -0,0 +1,129 @@
1/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
4 * *
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * *
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
11 * *
12 ********************************************************************
13
14 function: single-block PCM synthesis
15 last mod: $Id$
16
17 ********************************************************************/
18
19#include <stdio.h>
20#include "ogg.h"
21#include "ivorbiscodec.h"
22#include "codec_internal.h"
23#include "registry.h"
24#include "misc.h"
25#include "os.h"
26
27
28static inline int _vorbis_synthesis1(vorbis_block *vb,ogg_packet *op,int decodep){
29 vorbis_dsp_state *vd= vb ? vb->vd : 0;
30 private_state *b= vd ? (private_state *)vd->backend_state: 0;
31 vorbis_info *vi= vd ? vd->vi : 0;
32 codec_setup_info *ci= vi ? (codec_setup_info *)vi->codec_setup : 0;
33 oggpack_buffer *opb=vb ? &vb->opb : 0;
34 int type,mode;
35
36 if (!vd || !b || !vi || !ci || !opb) {
37 return OV_EBADPACKET;
38 }
39
40 /* first things first. Make sure decode is ready */
41 _vorbis_block_ripcord(vb);
42 oggpack_readinit(opb,op->packet,op->bytes);
43
44 /* Check the packet type */
45 if(oggpack_read(opb,1)!=0){
46 /* Oops. This is not an audio data packet */
47 return(OV_ENOTAUDIO);
48 }
49
50 /* read our mode and pre/post windowsize */
51 mode=oggpack_read(opb,b->modebits);
52 if(mode==-1)return(OV_EBADPACKET);
53
54 vb->mode=mode;
55 if(!ci->mode_param[mode]){
56 return(OV_EBADPACKET);
57 }
58
59 vb->W=ci->mode_param[mode]->blockflag;
60 if(vb->W){
61 vb->lW=oggpack_read(opb,1);
62 vb->nW=oggpack_read(opb,1);
63 if(vb->nW==-1) return(OV_EBADPACKET);
64 }else{
65 vb->lW=0;
66 vb->nW=0;
67 }
68
69 /* more setup */
70 vb->granulepos=op->granulepos;
71 vb->sequence=op->packetno-3; /* first block is third packet */
72 vb->eofflag=op->e_o_s;
73
74 if(decodep && vi->channels<=CHANNELS)
75 {
76 /* set pcm end point */
77 vb->pcmend=ci->blocksizes[vb->W];
78
79 /* unpack_header enforces range checking */
80 type=ci->map_type[ci->mode_param[mode]->mapping];
81 return(_mapping_P[type]->inverse(vb,b->mode[mode]));
82 }else{
83 /* no pcm */
84 vb->pcmend=0;
85 return(0);
86 }
87}
88
89int vorbis_synthesis(vorbis_block *vb,ogg_packet *op)
90 ICODE_ATTR_TREMOR_NOT_MDCT;
91int vorbis_synthesis(vorbis_block *vb,ogg_packet *op){
92 return _vorbis_synthesis1(vb,op,1);
93}
94
95/* used to track pcm position without actually performing decode.
96 Useful for sequential 'fast forward' */
97int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op){
98 return _vorbis_synthesis1(vb,op,0);
99}
100
101long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op){
102 codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
103 oggpack_buffer opb;
104 int mode;
105
106 oggpack_readinit(&opb,op->packet,op->bytes);
107
108 /* Check the packet type */
109 if(oggpack_read(&opb,1)!=0){
110 /* Oops. This is not an audio data packet */
111 return(OV_ENOTAUDIO);
112 }
113
114 {
115 int modebits=0;
116 int v=ci->modes;
117 while(v>1){
118 modebits++;
119 v>>=1;
120 }
121
122 /* read our mode and pre/post windowsize */
123 mode=oggpack_read(&opb,modebits);
124 }
125 if(mode==-1)return(OV_EBADPACKET);
126 return(ci->blocksizes[ci->mode_param[mode]->blockflag]);
127}
128
129
diff --git a/lib/rbcodec/codecs/libtremor/vorbisfile.c b/lib/rbcodec/codecs/libtremor/vorbisfile.c
new file mode 100644
index 0000000000..271e5a09e3
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/vorbisfile.c
@@ -0,0 +1,1671 @@
1/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
4 * *
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * *
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
11 * *
12 ********************************************************************
13
14 function: stdio-based convenience library for opening/seeking/decoding
15 last mod: $Id$
16
17 ********************************************************************/
18
19#include "config-tremor.h"
20#include <stdio.h>
21#include <errno.h>
22#include <string.h>
23#include <math.h>
24#include "system.h"
25
26#include "ivorbiscodec.h"
27#include "ivorbisfile.h"
28
29#include "os.h"
30#include "misc.h"
31
32/* A 'chained bitstream' is a Vorbis bitstream that contains more than
33 one logical bitstream arranged end to end (the only form of Ogg
34 multiplexing allowed in a Vorbis bitstream; grouping [parallel
35 multiplexing] is not allowed in Vorbis) */
36
37/* A Vorbis file can be played beginning to end (streamed) without
38 worrying ahead of time about chaining (see decoder_example.c). If
39 we have the whole file, however, and want random access
40 (seeking/scrubbing) or desire to know the total length/time of a
41 file, we need to account for the possibility of chaining. */
42
43/* We can handle things a number of ways; we can determine the entire
44 bitstream structure right off the bat, or find pieces on demand.
45 This example determines and caches structure for the entire
46 bitstream, but builds a virtual decoder on the fly when moving
47 between links in the chain. */
48
49/* There are also different ways to implement seeking. Enough
50 information exists in an Ogg bitstream to seek to
51 sample-granularity positions in the output. Or, one can seek by
52 picking some portion of the stream roughly in the desired area if
53 we only want coarse navigation through the stream. */
54
55/*************************************************************************
56 * Many, many internal helpers. The intention is not to be confusing;
57 * rampant duplication and monolithic function implementation would be
58 * harder to understand anyway. The high level functions are last. Begin
59 * grokking near the end of the file */
60
61
62/* read a little more data from the file/pipe into the ogg_sync framer */
63static long _get_data(OggVorbis_File *vf){
64 if(!(vf->callbacks.read_func))return(-1);
65 if(vf->datasource){
66 char *buffer=ogg_sync_buffer(&vf->oy,CHUNKSIZE);
67 long bytes=(vf->callbacks.read_func)(buffer,1,CHUNKSIZE,vf->datasource);
68 if(bytes>0)ogg_sync_wrote(&vf->oy,bytes);
69 return(bytes);
70 }else
71 return(0);
72}
73
74/* save a tiny smidge of verbosity to make the code more readable */
75static int _seek_helper(OggVorbis_File *vf,ogg_int64_t offset){
76 if(vf->datasource){
77 if(!(vf->callbacks.seek_func)||
78 (vf->callbacks.seek_func)(vf->datasource, offset, SEEK_SET) == -1)
79 return OV_EREAD;
80 vf->offset=offset;
81 ogg_sync_reset(&vf->oy);
82 }else{
83 /* shouldn't happen unless someone writes a broken callback */
84 return OV_EFAULT;
85 }
86 return 0;
87}
88
89/* The read/seek functions track absolute position within the stream */
90
91/* from the head of the stream, get the next page. boundary specifies
92 if the function is allowed to fetch more data from the stream (and
93 how much) or only use internally buffered data.
94
95 boundary: -1) unbounded search
96 0) read no additional data; use cached only
97 n) search for a new page beginning for n bytes
98
99 return: <0) did not find a page (OV_FALSE, OV_EOF, OV_EREAD)
100 n) found a page at absolute offset n */
101
102static ogg_int64_t _get_next_page(OggVorbis_File *vf,ogg_page *og,
103 ogg_int64_t boundary){
104 if(boundary>0)boundary+=vf->offset;
105 while(1){
106 long more;
107
108 if(boundary>0 && vf->offset>=boundary)return(OV_FALSE);
109 more=ogg_sync_pageseek(&vf->oy,og);
110
111 if(more<0){
112 /* skipped n bytes */
113 vf->offset-=more;
114 }else{
115 if(more==0){
116 /* send more paramedics */
117 if(!boundary)return(OV_FALSE);
118 {
119 long ret=_get_data(vf);
120 if(ret==0)return(OV_EOF);
121 if(ret<0)return(OV_EREAD);
122 }
123 }else{
124 /* got a page. Return the offset at the page beginning,
125 advance the internal offset past the page end */
126 ogg_int64_t ret=vf->offset;
127 vf->offset+=more;
128 return(ret);
129
130 }
131 }
132 }
133}
134
135/* This is a nasty hack to work around the huge allocations we get from
136 huge comment packets, usually due to embedded album art */
137static int ogg_stream_discard_packet(OggVorbis_File *vf,ogg_page *og,
138 ogg_int64_t boundary){
139 int ret;
140 while((ret = ogg_stream_packetout(&vf->os, NULL)) == 0) {
141 if(_get_next_page(vf, og, boundary)<0)
142 break;
143 ogg_stream_pagein(&vf->os,og,false);
144 }
145 if (ret < 0)
146 return -1;
147 /* We might be pretending to have filled in more of the buffer than there is
148 actual space, in this case the body storage must be expanded before we
149 start writing to it */
150 if (vf->os.body_fill < og->body_len || vf->os.body_storage < vf->os.body_fill)
151 if(_os_body_expand(&vf->os, vf->os.body_fill - vf->os.body_storage + og->body_len))
152 return -1;
153 memcpy(vf->os.body_data+vf->os.body_fill-og->body_len, og->body, og->body_len);
154 return 1;
155}
156
157/* find the latest page beginning before the current stream cursor
158 position. Much dirtier than the above as Ogg doesn't have any
159 backward search linkage. no 'readp' as it will certainly have to
160 read. */
161/* returns offset or OV_EREAD, OV_FAULT */
162static ogg_int64_t _get_prev_page(OggVorbis_File *vf,ogg_page *og){
163 ogg_int64_t begin=vf->offset;
164 ogg_int64_t end=begin;
165 ogg_int64_t ret;
166 ogg_int64_t offset=-1;
167
168 while(offset==-1){
169 begin-=CHUNKSIZE;
170 if(begin<0)
171 begin=0;
172
173 ret=_seek_helper(vf,begin);
174 if(ret)return(ret);
175
176 while(vf->offset<end){
177 memset(og,0,sizeof(*og));
178 ret=_get_next_page(vf,og,end-vf->offset);
179 if(ret==OV_EREAD)return(OV_EREAD);
180 if(ret<0){
181 break;
182 }else{
183 offset=ret;
184 }
185 }
186 }
187
188 /* In a fully compliant, non-multiplexed stream, we'll still be
189 holding the last page. In multiplexed (or noncompliant streams),
190 we will probably have to re-read the last page we saw */
191 if(og->header_len==0){
192 ret=_seek_helper(vf,offset);
193 if(ret)return(ret);
194
195 ret=_get_next_page(vf,og,CHUNKSIZE);
196 if(ret<0)
197 /* this shouldn't be possible */
198 return(OV_EFAULT);
199 }
200
201 return(offset);
202}
203
204static void _add_serialno(ogg_page *og,ogg_uint32_t **serialno_list, int *n){
205 long s = ogg_page_serialno(og);
206 (*n)++;
207
208 if(*serialno_list){
209 *serialno_list = _ogg_realloc(*serialno_list, sizeof(**serialno_list)*(*n));
210 }else{
211 *serialno_list = _ogg_malloc(sizeof(**serialno_list));
212 }
213
214 (*serialno_list)[(*n)-1] = s;
215}
216
217/* returns nonzero if found */
218static int _lookup_serialno(ogg_uint32_t s, ogg_uint32_t *serialno_list, int n){
219 if(serialno_list){
220 while(n--){
221 if(*serialno_list == (ogg_uint32_t) s) return 1;
222 serialno_list++;
223 }
224 }
225 return 0;
226}
227
228static int _lookup_page_serialno(ogg_page *og, ogg_uint32_t *serialno_list, int n){
229 ogg_uint32_t s = ogg_page_serialno(og);
230 return _lookup_serialno(s,serialno_list,n);
231}
232
233/* performs the same search as _get_prev_page, but prefers pages of
234 the specified serial number. If a page of the specified serialno is
235 spotted during the seek-back-and-read-forward, it will return the
236 info of last page of the matching serial number instead of the very
237 last page. If no page of the specified serialno is seen, it will
238 return the info of last page and alter *serialno. */
239static ogg_int64_t _get_prev_page_serial(OggVorbis_File *vf,
240 ogg_uint32_t *serial_list, int serial_n,
241 int *serialno, ogg_int64_t *granpos){
242 ogg_page og;
243 ogg_int64_t begin=vf->offset;
244 ogg_int64_t end=begin;
245 ogg_int64_t ret;
246
247 ogg_int64_t prefoffset=-1;
248 ogg_int64_t offset=-1;
249 ogg_int64_t ret_serialno=-1;
250 ogg_int64_t ret_gran=-1;
251
252 while(offset==-1){
253 begin-=CHUNKSIZE;
254 if(begin<0)
255 begin=0;
256
257 ret=_seek_helper(vf,begin);
258 if(ret)return(ret);
259
260 while(vf->offset<end){
261 ret=_get_next_page(vf,&og,end-vf->offset);
262 if(ret==OV_EREAD)return(OV_EREAD);
263 if(ret<0){
264 break;
265 }else{
266 ret_serialno=ogg_page_serialno(&og);
267 ret_gran=ogg_page_granulepos(&og);
268 offset=ret;
269
270 if((ogg_uint32_t)ret_serialno == (ogg_uint32_t)*serialno){
271 prefoffset=ret;
272 *granpos=ret_gran;
273 }
274
275 if(!_lookup_serialno((ogg_uint32_t)ret_serialno,serial_list,serial_n)){
276 /* we fell off the end of the link, which means we seeked
277 back too far and shouldn't have been looking in that link
278 to begin with. If we found the preferred serial number,
279 forget that we saw it. */
280 prefoffset=-1;
281 }
282 }
283 }
284 }
285
286 /* we're not interested in the page... just the serialno and granpos. */
287 if(prefoffset>=0)return(prefoffset);
288
289 *serialno = ret_serialno;
290 *granpos = ret_gran;
291 return(offset);
292
293}
294
295/* uses the local ogg_stream storage in vf; this is important for
296 non-streaming input sources */
297static int _fetch_headers(OggVorbis_File *vf,vorbis_info *vi,
298 ogg_uint32_t **serialno_list, int *serialno_n,
299 ogg_page *og_ptr){
300 ogg_page og;
301 ogg_packet op;
302 int i,ret;
303 int allbos=0;
304
305 if(!og_ptr){
306 ogg_int64_t llret=_get_next_page(vf,&og,CHUNKSIZE);
307 if(llret==OV_EREAD)return(OV_EREAD);
308 if(llret<0)return(OV_ENOTVORBIS);
309 og_ptr=&og;
310 }
311
312 vorbis_info_init(vi);
313/* vorbis_comment_init(vc); */
314 vf->ready_state=OPENED;
315
316 /* extract the serialnos of all BOS pages + the first set of vorbis
317 headers we see in the link */
318
319 while(ogg_page_bos(og_ptr)){
320 if(serialno_list){
321 if(_lookup_page_serialno(og_ptr,*serialno_list,*serialno_n)){
322 /* a dupe serialnumber in an initial header packet set == invalid stream */
323 if(*serialno_list)_ogg_free(*serialno_list);
324 *serialno_list=0;
325 *serialno_n=0;
326 ret=OV_EBADHEADER;
327 goto bail_header;
328 }
329
330 _add_serialno(og_ptr,serialno_list,serialno_n);
331 }
332
333 if(vf->ready_state<STREAMSET){
334 /* we don't have a vorbis stream in this link yet, so begin
335 prospective stream setup. We need a stream to get packets */
336 ogg_stream_reset_serialno(&vf->os,ogg_page_serialno(og_ptr));
337 ogg_stream_pagein(&vf->os,og_ptr,true);
338
339 if(ogg_stream_packetout(&vf->os,&op) > 0 &&
340 vorbis_synthesis_idheader(&op)){
341 /* vorbis header; continue setup */
342 vf->ready_state=STREAMSET;
343 if((ret=vorbis_synthesis_headerin(vi,&op))){
344 ret=OV_EBADHEADER;
345 goto bail_header;
346 }
347 }
348 }
349
350 /* get next page */
351 {
352 ogg_int64_t llret=_get_next_page(vf,og_ptr,CHUNKSIZE);
353 if(llret==OV_EREAD){
354 ret=OV_EREAD;
355 goto bail_header;
356 }
357 if(llret<0){
358 ret=OV_ENOTVORBIS;
359 goto bail_header;
360 }
361
362 /* if this page also belongs to our vorbis stream, submit it and break */
363 if(vf->ready_state==STREAMSET &&
364 vf->os.serialno == ogg_page_serialno(og_ptr)){
365 ogg_stream_pagein(&vf->os,og_ptr,true);
366 break;
367 }
368 }
369 }
370
371 if(vf->ready_state!=STREAMSET){
372 ret = OV_ENOTVORBIS;
373 goto bail_header;
374 }
375
376 while(1){
377
378 i=0;
379 /* discard comment packet */
380 if(ogg_stream_discard_packet(vf,og_ptr,CHUNKSIZE) < 0){
381 ret=OV_EBADHEADER;
382 goto bail_header;
383 }
384 i++;
385
386 while(i<2){ /* get a page loop */
387
388 while(i<2){ /* get a packet loop */
389 int result=ogg_stream_packetout(&vf->os,&op);
390 if(result==0)break;
391 if(result==-1){
392 ret=OV_EBADHEADER;
393 goto bail_header;
394 }
395
396 if((ret=vorbis_synthesis_headerin(vi,&op)))
397 goto bail_header;
398
399 i++;
400 }
401
402 while(i<2){
403 if(_get_next_page(vf,og_ptr,CHUNKSIZE)<0){
404 ret=OV_EBADHEADER;
405 goto bail_header;
406 }
407
408 /* if this page belongs to the correct stream, go parse it */
409 if(vf->os.serialno == ogg_page_serialno(og_ptr)){
410 ogg_stream_pagein(&vf->os,og_ptr,true);
411 break;
412 }
413
414 /* if we never see the final vorbis headers before the link
415 ends, abort */
416 if(ogg_page_bos(og_ptr)){
417 if(allbos){
418 ret = OV_EBADHEADER;
419 goto bail_header;
420 }else
421 allbos=1;
422 }
423
424 /* otherwise, keep looking */
425 }
426 }
427
428 return 0;
429 }
430
431 bail_header:
432 vorbis_info_clear(vi);
433/* vorbis_comment_clear(vc); */
434 vf->ready_state=OPENED;
435
436 return ret;
437}
438
439/* Starting from current cursor position, get initial PCM offset of
440 next page. Consumes the page in the process without decoding
441 audio, however this is only called during stream parsing upon
442 seekable open. */
443static ogg_int64_t _initial_pcmoffset(OggVorbis_File *vf, vorbis_info *vi){
444 ogg_page og;
445 ogg_int64_t accumulated=0;
446 long lastblock=-1;
447 int result;
448 ogg_uint32_t serialno = vf->os.serialno;
449
450 while(1){
451 ogg_packet op;
452 if(_get_next_page(vf,&og,-1)<0)
453 break; /* should not be possible unless the file is truncated/mangled */
454
455 if(ogg_page_bos(&og)) break;
456 if(ogg_page_serialno(&og)!= serialno) continue;
457
458 /* count blocksizes of all frames in the page */
459 ogg_stream_pagein(&vf->os,&og,true);
460 while((result=ogg_stream_packetout(&vf->os,&op))){
461 if(result>0){ /* ignore holes */
462 long thisblock=vorbis_packet_blocksize(vi,&op);
463 if(lastblock!=-1)
464 accumulated+=(lastblock+thisblock)>>2;
465 lastblock=thisblock;
466 }
467 }
468
469 if(ogg_page_granulepos(&og)!=-1){
470 /* pcm offset of last packet on the first audio page */
471 accumulated= ogg_page_granulepos(&og)-accumulated;
472 break;
473 }
474 }
475
476 /* less than zero? This is a stream with samples trimmed off
477 the beginning, a normal occurrence; set the offset to zero */
478 if(accumulated<0)accumulated=0;
479
480 return accumulated;
481}
482
483/* finds each bitstream link one at a time using a bisection search
484 (has to begin by knowing the offset of the lb's initial page).
485 Recurses for each link so it can alloc the link storage after
486 finding them all, then unroll and fill the cache at the same time */
487static int _bisect_forward_serialno(OggVorbis_File *vf,
488 ogg_int64_t begin,
489 ogg_int64_t searched,
490 ogg_int64_t end,
491 ogg_int64_t endgran,
492 int endserial,
493 ogg_uint32_t *currentno_list,
494 int currentnos,
495 long m){
496 ogg_int64_t pcmoffset;
497 ogg_int64_t dataoffset=searched;
498 ogg_int64_t endsearched=end;
499 ogg_int64_t next=end;
500 ogg_int64_t searchgran=-1;
501 ogg_page og;
502 ogg_int64_t ret,last;
503 int serialno = vf->os.serialno;
504
505 /* invariants:
506 we have the headers and serialnos for the link beginning at 'begin'
507 we have the offset and granpos of the last page in the file (potentially
508 not a page we care about)
509 */
510
511 /* Is the last page in our list of current serialnumbers? */
512 if(_lookup_serialno(endserial,currentno_list,currentnos)){
513
514 /* last page is in the starting serialno list, so we've bisected
515 down to (or just started with) a single link. Now we need to
516 find the last vorbis page belonging to the first vorbis stream
517 for this link. */
518
519 while(endserial != serialno){
520 endserial = serialno;
521 vf->offset=_get_prev_page_serial(vf,currentno_list,currentnos,&endserial,&endgran);
522 }
523
524 vf->links=m+1;
525 if(vf->offsets)_ogg_free(vf->offsets);
526 if(vf->serialnos)_ogg_free(vf->serialnos);
527 if(vf->dataoffsets)_ogg_free(vf->dataoffsets);
528
529 vf->offsets=_ogg_malloc((vf->links+1)*sizeof(*vf->offsets));
530 vf->vi=_ogg_realloc(vf->vi,vf->links*sizeof(*vf->vi));
531/* vf->vc=_ogg_realloc(vf->vc,vf->links*sizeof(*vf->vc));*/
532 vf->serialnos=_ogg_malloc(vf->links*sizeof(*vf->serialnos));
533 vf->dataoffsets=_ogg_malloc(vf->links*sizeof(*vf->dataoffsets));
534 vf->pcmlengths=_ogg_malloc(vf->links*2*sizeof(*vf->pcmlengths));
535
536 vf->offsets[m+1]=end;
537 vf->offsets[m]=begin;
538 vf->pcmlengths[m*2+1]=endgran;
539
540 }else{
541
542 ogg_uint32_t *next_serialno_list=NULL;
543 int next_serialnos=0;
544 vorbis_info vi;
545/* vorbis_comment vc; */
546
547 /* the below guards against garbage seperating the last and
548 first pages of two links. */
549 while(searched<endsearched){
550 ogg_int64_t bisect;
551
552 if(endsearched-searched<CHUNKSIZE){
553 bisect=searched;
554 }else{
555 bisect=(searched+endsearched)/2;
556 }
557
558 if(bisect != vf->offset){
559 ret=_seek_helper(vf,bisect);
560 if(ret)return(ret);
561 }
562
563 last=_get_next_page(vf,&og,-1);
564 if(last==OV_EREAD)return(OV_EREAD);
565 if(last<0 || !_lookup_page_serialno(&og,currentno_list,currentnos)){
566 endsearched=bisect;
567 if(last>=0)next=last;
568 }else{
569 searched=vf->offset;
570 }
571 }
572
573 /* Bisection point found */
574
575 /* for the time being, fetch end PCM offset the simple way */
576 {
577 int testserial = serialno+1;
578 vf->offset = next;
579 while(testserial != serialno){
580 testserial = serialno;
581 vf->offset=_get_prev_page_serial(vf,currentno_list,currentnos,&testserial,&searchgran);
582 }
583 }
584
585 if(vf->offset!=next){
586 ret=_seek_helper(vf,next);
587 if(ret)return(ret);
588 }
589
590 ret=_fetch_headers(vf,&vi,&next_serialno_list,&next_serialnos,NULL);
591 if(ret)return(ret);
592 serialno = vf->os.serialno;
593 dataoffset = vf->offset;
594
595 /* this will consume a page, however the next bistection always
596 starts with a raw seek */
597 pcmoffset = _initial_pcmoffset(vf,&vi);
598
599 ret=_bisect_forward_serialno(vf,next,vf->offset,end,endgran,endserial,
600 next_serialno_list,next_serialnos,m+1);
601 if(ret)return(ret);
602
603 if(next_serialno_list)_ogg_free(next_serialno_list);
604
605 vf->offsets[m+1]=next;
606 vf->serialnos[m+1]=serialno;
607 vf->dataoffsets[m+1]=dataoffset;
608
609 vf->vi[m+1]=vi;
610/* vf->vc[m+1]=vc; */
611
612 vf->pcmlengths[m*2+1]=searchgran;
613 vf->pcmlengths[m*2+2]=pcmoffset;
614 vf->pcmlengths[m*2+3]-=pcmoffset;
615
616 }
617 return(0);
618}
619
620static int _make_decode_ready(OggVorbis_File *vf){
621 if(vf->ready_state>STREAMSET)return 0;
622 if(vf->ready_state<STREAMSET)return OV_EFAULT;
623 if(vf->seekable){
624 if(vorbis_synthesis_init(&vf->vd,vf->vi+vf->current_link))
625 return OV_EBADLINK;
626 }else{
627 if(vorbis_synthesis_init(&vf->vd,vf->vi))
628 return OV_EBADLINK;
629 }
630 vorbis_block_init(&vf->vd,&vf->vb);
631 vf->ready_state=INITSET;
632 vf->bittrack=0;
633 vf->samptrack=0;
634 return 0;
635}
636
637static int _open_seekable2(OggVorbis_File *vf){
638 ogg_int64_t dataoffset=vf->dataoffsets[0],end,endgran=-1;
639 int endserial=vf->os.serialno;
640 int serialno=vf->os.serialno;
641
642 /* we're partially open and have a first link header state in
643 storage in vf */
644
645 /* fetch initial PCM offset */
646 ogg_int64_t pcmoffset = _initial_pcmoffset(vf,vf->vi);
647
648 /* we can seek, so set out learning all about this file */
649 if(vf->callbacks.seek_func && vf->callbacks.tell_func){
650 (vf->callbacks.seek_func)(vf->datasource,0,SEEK_END);
651 vf->offset=vf->end=(vf->callbacks.tell_func)(vf->datasource);
652 }else{
653 vf->offset=vf->end=-1;
654 }
655
656 /* If seek_func is implemented, tell_func must also be implemented */
657 if(vf->end==-1) return(OV_EINVAL);
658
659 /* Get the offset of the last page of the physical bitstream, or, if
660 we're lucky the last vorbis page of this link as most OggVorbis
661 files will contain a single logical bitstream */
662 end=_get_prev_page_serial(vf,vf->serialnos+2,vf->serialnos[1],&endserial,&endgran);
663 if(end<0)return(end);
664
665 /* now determine bitstream structure recursively */
666 if(_bisect_forward_serialno(vf,0,dataoffset,vf->offset,endgran,endserial,
667 vf->serialnos+2,vf->serialnos[1],0)<0)return(OV_EREAD);
668
669 vf->offsets[0]=0;
670 vf->serialnos[0]=serialno;
671 vf->dataoffsets[0]=dataoffset;
672 vf->pcmlengths[0]=pcmoffset;
673 vf->pcmlengths[1]-=pcmoffset;
674
675 return(ov_raw_seek(vf,dataoffset));
676}
677
678/* clear out the current logical bitstream decoder */
679static void _decode_clear(OggVorbis_File *vf){
680 vorbis_dsp_clear(&vf->vd);
681 vorbis_block_clear(&vf->vb);
682 vf->ready_state=OPENED;
683}
684
685/* fetch and process a packet. Handles the case where we're at a
686 bitstream boundary and dumps the decoding machine. If the decoding
687 machine is unloaded, it loads it. It also keeps pcm_offset up to
688 date (seek and read both use this. seek uses a special hack with
689 readp).
690
691 return: <0) error, OV_HOLE (lost packet) or OV_EOF
692 0) need more data (only if readp==0)
693 1) got a packet
694*/
695
696static int _fetch_and_process_packet(OggVorbis_File *vf,
697 ogg_packet *op_in,
698 int readp,
699 int spanp){
700 ogg_page og;
701
702 /* handle one packet. Try to fetch it from current stream state */
703 /* extract packets from page */
704 while(1){
705
706 if(vf->ready_state==STREAMSET){
707 int ret=_make_decode_ready(vf);
708 if(ret<0)return ret;
709 }
710
711 /* process a packet if we can. If the machine isn't loaded,
712 neither is a page */
713 if(vf->ready_state==INITSET){
714 while(1) {
715 ogg_packet op;
716 ogg_packet *op_ptr=(op_in?op_in:&op);
717 int result=ogg_stream_packetout(&vf->os,op_ptr);
718 ogg_int64_t granulepos;
719
720 op_in=NULL;
721 if(result==-1)return(OV_HOLE); /* hole in the data. */
722 if(result>0){
723 /* got a packet. process it */
724 granulepos=op_ptr->granulepos;
725 if(!vorbis_synthesis(&vf->vb,op_ptr)){ /* lazy check for lazy
726 header handling. The
727 header packets aren't
728 audio, so if/when we
729 submit them,
730 vorbis_synthesis will
731 reject them */
732
733 /* suck in the synthesis data and track bitrate */
734 {
735 int oldsamples=vorbis_synthesis_pcmout(&vf->vd,NULL);
736 /* for proper use of libvorbis within libvorbisfile,
737 oldsamples will always be zero. */
738 if(oldsamples)return(OV_EFAULT);
739
740 vorbis_synthesis_blockin(&vf->vd,&vf->vb);
741 vf->samptrack+=vorbis_synthesis_pcmout(&vf->vd,NULL)-oldsamples;
742 vf->bittrack+=op_ptr->bytes*8;
743 }
744
745 /* update the pcm offset. */
746 if(granulepos!=-1 && !op_ptr->e_o_s){
747 int link=(vf->seekable?vf->current_link:0);
748 int i,samples;
749
750 /* this packet has a pcm_offset on it (the last packet
751 completed on a page carries the offset) After processing
752 (above), we know the pcm position of the *last* sample
753 ready to be returned. Find the offset of the *first*
754
755 As an aside, this trick is inaccurate if we begin
756 reading anew right at the last page; the end-of-stream
757 granulepos declares the last frame in the stream, and the
758 last packet of the last page may be a partial frame.
759 So, we need a previous granulepos from an in-sequence page
760 to have a reference point. Thus the !op_ptr->e_o_s clause
761 above */
762
763 if(vf->seekable && link>0)
764 granulepos-=vf->pcmlengths[link*2];
765 if(granulepos<0)granulepos=0; /* actually, this
766 shouldn't be possible
767 here unless the stream
768 is very broken */
769
770 samples=vorbis_synthesis_pcmout(&vf->vd,NULL);
771
772 granulepos-=samples;
773 for(i=0;i<link;i++)
774 granulepos+=vf->pcmlengths[i*2+1];
775 vf->pcm_offset=granulepos;
776 }
777 return(1);
778 }
779 }
780 else
781 break;
782 }
783 }
784
785 if(vf->ready_state>=OPENED){
786 ogg_int64_t ret;
787
788 while(1){
789 /* the loop is not strictly necessary, but there's no sense in
790 doing the extra checks of the larger loop for the common
791 case in a multiplexed bistream where the page is simply
792 part of a different logical bitstream; keep reading until
793 we get one with the correct serialno */
794
795 if(!readp)return(0);
796 if((ret=_get_next_page(vf,&og,-1))<0){
797 return(OV_EOF); /* eof. leave unitialized */
798 }
799
800 /* bitrate tracking; add the header's bytes here, the body bytes
801 are done by packet above */
802 vf->bittrack+=og.header_len*8;
803
804 if(vf->ready_state==INITSET){
805 if(vf->current_serialno!=ogg_page_serialno(&og)){
806
807 /* two possibilities:
808 1) our decoding just traversed a bitstream boundary
809 2) another stream is multiplexed into this logical section */
810
811 if(ogg_page_bos(&og)){
812 /* boundary case */
813 if(!spanp)
814 return(OV_EOF);
815
816 _decode_clear(vf);
817
818 if(!vf->seekable){
819 vorbis_info_clear(vf->vi);
820/* vorbis_comment_clear(vf->vc); */
821 }
822 break;
823
824 }else
825 continue; /* possibility #2 */
826 }
827 }
828
829 break;
830 }
831 }
832
833 /* Do we need to load a new machine before submitting the page? */
834 /* This is different in the seekable and non-seekable cases.
835
836 In the seekable case, we already have all the header
837 information loaded and cached; we just initialize the machine
838 with it and continue on our merry way.
839
840 In the non-seekable (streaming) case, we'll only be at a
841 boundary if we just left the previous logical bitstream and
842 we're now nominally at the header of the next bitstream
843 */
844
845 if(vf->ready_state!=INITSET){
846 int link;
847
848 if(vf->ready_state<STREAMSET){
849 if(vf->seekable){
850 ogg_uint32_t serialno = ogg_page_serialno(&og);
851
852 /* match the serialno to bitstream section. We use this rather than
853 offset positions to avoid problems near logical bitstream
854 boundaries */
855
856 for(link=0;link<vf->links;link++)
857 if(vf->serialnos[link]==serialno)break;
858
859 if(link==vf->links) continue; /* not the desired Vorbis
860 bitstream section; keep
861 trying */
862
863 vf->current_serialno=serialno;
864 vf->current_link=link;
865
866 ogg_stream_reset_serialno(&vf->os,vf->current_serialno);
867 vf->ready_state=STREAMSET;
868
869 }else{
870 /* we're streaming */
871 /* fetch the three header packets, build the info struct */
872
873 int ret=_fetch_headers(vf,vf->vi,NULL,NULL,&og);
874 if(ret)return(ret);
875 vf->current_serialno=vf->os.serialno;
876 vf->current_link++;
877 link=0;
878 }
879 }
880 }
881
882 /* the buffered page is the data we want, and we're ready for it;
883 add it to the stream state */
884 ogg_stream_pagein(&vf->os,&og,true);
885
886 }
887}
888
889static int _ov_open1(void *f,OggVorbis_File *vf,const char *initial,
890 long ibytes, ov_callbacks callbacks){
891 int offsettest=((f && callbacks.seek_func)?callbacks.seek_func(f,0,SEEK_CUR):-1);
892 ogg_uint32_t *serialno_list=NULL;
893 int serialno_list_size=0;
894 int ret;
895
896 memset(vf,0,sizeof(*vf));
897 vf->datasource=f;
898 vf->callbacks = callbacks;
899
900 /* init the framing state */
901 ogg_sync_init(&vf->oy);
902
903 /* perhaps some data was previously read into a buffer for testing
904 against other stream types. Allow initialization from this
905 previously read data (especially as we may be reading from a
906 non-seekable stream) */
907 if(initial){
908 char *buffer=ogg_sync_buffer(&vf->oy,ibytes);
909 memcpy(buffer,initial,ibytes);
910 ogg_sync_wrote(&vf->oy,ibytes);
911 }
912
913 /* can we seek? Stevens suggests the seek test was portable */
914 if(offsettest!=-1)vf->seekable=1;
915
916 /* No seeking yet; Set up a 'single' (current) logical bitstream
917 entry for partial open */
918 vf->links=1;
919 vf->vi=_ogg_calloc(vf->links,sizeof(*vf->vi));
920/* vf->vc=_ogg_calloc(vf->links,sizeof(*vf->vc)); */
921 ogg_stream_init(&vf->os,-1); /* fill in the serialno later */
922
923 /* Fetch all BOS pages, store the vorbis header and all seen serial
924 numbers, load subsequent vorbis setup headers */
925 if((ret=_fetch_headers(vf,vf->vi,&serialno_list,&serialno_list_size,NULL))<0){
926 vf->datasource=NULL;
927 ov_clear(vf);
928 }else{
929 /* serial number list for first link needs to be held somewhere
930 for second stage of seekable stream open; this saves having to
931 seek/reread first link's serialnumber data then. */
932 vf->serialnos=_ogg_calloc(serialno_list_size+2,sizeof(*vf->serialnos));
933 vf->serialnos[0]=vf->current_serialno=vf->os.serialno;
934 vf->serialnos[1]=serialno_list_size;
935 memcpy(vf->serialnos+2,serialno_list,serialno_list_size*sizeof(*vf->serialnos));
936
937 vf->offsets=_ogg_calloc(1,sizeof(*vf->offsets));
938 vf->dataoffsets=_ogg_calloc(1,sizeof(*vf->dataoffsets));
939 vf->offsets[0]=0;
940 vf->dataoffsets[0]=vf->offset;
941
942 vf->ready_state=PARTOPEN;
943 }
944 if(serialno_list)_ogg_free(serialno_list);
945 return(ret);
946}
947
948static int _ov_open2(OggVorbis_File *vf){
949 if(vf->ready_state != PARTOPEN) return OV_EINVAL;
950 vf->ready_state=OPENED;
951 if(vf->seekable){
952 int ret=_open_seekable2(vf);
953 if(ret){
954 vf->datasource=NULL;
955 ov_clear(vf);
956 }
957 return(ret);
958 }else
959 vf->ready_state=STREAMSET;
960
961 return 0;
962}
963
964
965/* clear out the OggVorbis_File struct */
966int ov_clear(OggVorbis_File *vf){
967 if(vf){
968 vorbis_block_clear(&vf->vb);
969 vorbis_dsp_clear(&vf->vd);
970 ogg_stream_clear(&vf->os);
971
972 if(vf->vi && vf->links){
973 int i;
974 for(i=0;i<vf->links;i++){
975 vorbis_info_clear(vf->vi+i);
976/* vorbis_comment_clear(vf->vc+i); */
977 }
978 _ogg_free(vf->vi);
979/* _ogg_free(vf->vc); */
980 }
981 if(vf->dataoffsets)_ogg_free(vf->dataoffsets);
982 if(vf->pcmlengths)_ogg_free(vf->pcmlengths);
983 if(vf->serialnos)_ogg_free(vf->serialnos);
984 if(vf->offsets)_ogg_free(vf->offsets);
985 ogg_sync_clear(&vf->oy);
986 if(vf->datasource && vf->callbacks.close_func)
987 (vf->callbacks.close_func)(vf->datasource);
988 memset(vf,0,sizeof(*vf));
989 }
990#ifdef DEBUG_LEAKS
991 _VDBG_dump();
992#endif
993 return(0);
994}
995
996/* inspects the OggVorbis file and finds/documents all the logical
997 bitstreams contained in it. Tries to be tolerant of logical
998 bitstream sections that are truncated/woogie.
999
1000 return: -1) error
1001 0) OK
1002*/
1003
1004int ov_open_callbacks(void *f,OggVorbis_File *vf,
1005 const char *initial,long ibytes,ov_callbacks callbacks){
1006 #if defined(CPU_COLDFIRE)
1007 /* this seems to be the closest we get to an init function, let's init emac
1008 here. rounding is disabled because of MULT31_SHIFT15, which will be
1009 inaccurate with rounding in its current incarnation */
1010 coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE);
1011 #endif
1012 int ret=_ov_open1(f,vf,initial,ibytes,callbacks);
1013 if(ret)return ret;
1014 return _ov_open2(vf);
1015}
1016
1017/* returns: total PCM length (samples) of content if i==-1 PCM length
1018 (samples) of that logical bitstream for i==0 to n
1019 OV_EINVAL if the stream is not seekable (we can't know the
1020 length) or only partially open
1021*/
1022ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i){
1023 if(vf->ready_state<OPENED)return(OV_EINVAL);
1024 if(!vf->seekable || i>=vf->links)return(OV_EINVAL);
1025 if(i<0){
1026 ogg_int64_t acc=0;
1027 int i;
1028 for(i=0;i<vf->links;i++)
1029 acc+=ov_pcm_total(vf,i);
1030 return(acc);
1031 }else{
1032 return(vf->pcmlengths[i*2+1]);
1033 }
1034}
1035
1036/* returns: total milliseconds of content if i==-1
1037 milliseconds in that logical bitstream for i==0 to n
1038 OV_EINVAL if the stream is not seekable (we can't know the
1039 length) or only partially open
1040*/
1041ogg_int64_t ov_time_total(OggVorbis_File *vf,int i){
1042 if(vf->ready_state<OPENED)return(OV_EINVAL);
1043 if(!vf->seekable || i>=vf->links)return(OV_EINVAL);
1044 if(i<0){
1045 ogg_int64_t acc=0;
1046 int i;
1047 for(i=0;i<vf->links;i++)
1048 acc+=ov_time_total(vf,i);
1049 return(acc);
1050 }else{
1051 return(((ogg_int64_t)vf->pcmlengths[i*2+1])*1000/vf->vi[i].rate);
1052 }
1053}
1054
1055/* seek to an offset relative to the *compressed* data. This also
1056 scans packets to update the PCM cursor. It will cross a logical
1057 bitstream boundary, but only if it can't get any packets out of the
1058 tail of the bitstream we seek to (so no surprises).
1059
1060 returns zero on success, nonzero on failure */
1061
1062int ov_raw_seek(OggVorbis_File *vf,ogg_int64_t pos){
1063 ogg_stream_state work_os;
1064 int ret;
1065
1066 if(vf->ready_state<OPENED)return(OV_EINVAL);
1067 if(!vf->seekable)
1068 return(OV_ENOSEEK); /* don't dump machine if we can't seek */
1069
1070 if(pos<0 || pos>vf->end)return(OV_EINVAL);
1071
1072 /* is the seek position outside our current link [if any]? */
1073 if(vf->ready_state>=STREAMSET){
1074 if(pos<vf->offsets[vf->current_link] || pos>=vf->offsets[vf->current_link+1])
1075 _decode_clear(vf); /* clear out stream state */
1076 }
1077
1078 /* don't yet clear out decoding machine (if it's initialized), in
1079 the case we're in the same link. Restart the decode lapping, and
1080 let _fetch_and_process_packet deal with a potential bitstream
1081 boundary */
1082 vf->pcm_offset=-1;
1083 ogg_stream_reset_serialno(&vf->os,
1084 vf->current_serialno); /* must set serialno */
1085 vorbis_synthesis_restart(&vf->vd);
1086
1087 ret=_seek_helper(vf,pos);
1088 if(ret)goto seek_error;
1089
1090 /* we need to make sure the pcm_offset is set, but we don't want to
1091 advance the raw cursor past good packets just to get to the first
1092 with a granulepos. That's not equivalent behavior to beginning
1093 decoding as immediately after the seek position as possible.
1094
1095 So, a hack. We use two stream states; a local scratch state and
1096 the shared vf->os stream state. We use the local state to
1097 scan, and the shared state as a buffer for later decode.
1098
1099 Unfortuantely, on the last page we still advance to last packet
1100 because the granulepos on the last page is not necessarily on a
1101 packet boundary, and we need to make sure the granpos is
1102 correct.
1103 */
1104
1105 {
1106 ogg_page og;
1107 ogg_packet op;
1108 int lastblock=0;
1109 int accblock=0;
1110 int thisblock=0;
1111 int lastflag=0;
1112 int firstflag=0;
1113 ogg_int64_t pagepos=-1;
1114
1115 ogg_stream_init(&work_os,vf->current_serialno); /* get the memory ready */
1116 ogg_stream_reset(&work_os); /* eliminate the spurious OV_HOLE
1117 return from not necessarily
1118 starting from the beginning */
1119
1120 while(1){
1121 if(vf->ready_state>=STREAMSET){
1122 /* snarf/scan a packet if we can */
1123 int result=ogg_stream_packetout(&work_os,&op);
1124
1125 if(result>0){
1126
1127 if(vf->vi[vf->current_link].codec_setup){
1128 thisblock=vorbis_packet_blocksize(vf->vi+vf->current_link,&op);
1129 if(thisblock<0){
1130 ogg_stream_packetout(&vf->os,NULL);
1131 thisblock=0;
1132 }else{
1133
1134 /* We can't get a guaranteed correct pcm position out of the
1135 last page in a stream because it might have a 'short'
1136 granpos, which can only be detected in the presence of a
1137 preceding page. However, if the last page is also the first
1138 page, the granpos rules of a first page take precedence. Not
1139 only that, but for first==last, the EOS page must be treated
1140 as if its a normal first page for the stream to open/play. */
1141 if(lastflag && !firstflag)
1142 ogg_stream_packetout(&vf->os,NULL);
1143 else
1144 if(lastblock)accblock+=(lastblock+thisblock)>>2;
1145 }
1146
1147 if(op.granulepos!=-1){
1148 int i,link=vf->current_link;
1149 ogg_int64_t granulepos=op.granulepos-vf->pcmlengths[link*2];
1150 if(granulepos<0)granulepos=0;
1151
1152 for(i=0;i<link;i++)
1153 granulepos+=vf->pcmlengths[i*2+1];
1154 vf->pcm_offset=granulepos-accblock;
1155 if(vf->pcm_offset<0)vf->pcm_offset=0;
1156 break;
1157 }
1158 lastblock=thisblock;
1159 continue;
1160 }else
1161 ogg_stream_packetout(&vf->os,NULL);
1162 }
1163 }
1164
1165 if(!lastblock){
1166 pagepos=_get_next_page(vf,&og,-1);
1167 if(pagepos<0){
1168 vf->pcm_offset=ov_pcm_total(vf,-1);
1169 break;
1170 }
1171 }else{
1172 /* huh? Bogus stream with packets but no granulepos */
1173 vf->pcm_offset=-1;
1174 break;
1175 }
1176
1177 /* has our decoding just traversed a bitstream boundary? */
1178 if(vf->ready_state>=STREAMSET){
1179 if(vf->current_serialno!=ogg_page_serialno(&og)){
1180
1181 /* two possibilities:
1182 1) our decoding just traversed a bitstream boundary
1183 2) another stream is multiplexed into this logical section? */
1184
1185 if(ogg_page_bos(&og)){
1186 /* we traversed */
1187 _decode_clear(vf); /* clear out stream state */
1188 ogg_stream_clear(&work_os);
1189 } /* else, do nothing; next loop will scoop another page */
1190 }
1191 }
1192
1193 if(vf->ready_state<STREAMSET){
1194 int link;
1195 ogg_uint32_t serialno = ogg_page_serialno(&og);
1196
1197 for(link=0;link<vf->links;link++)
1198 if(vf->serialnos[link]==serialno)break;
1199
1200 if(link==vf->links) continue; /* not the desired Vorbis
1201 bitstream section; keep
1202 trying */
1203 vf->current_link=link;
1204 vf->current_serialno=serialno;
1205 ogg_stream_reset_serialno(&vf->os,serialno);
1206 ogg_stream_reset_serialno(&work_os,serialno);
1207 vf->ready_state=STREAMSET;
1208 firstflag=(pagepos<=vf->dataoffsets[link]);
1209 }
1210
1211 ogg_stream_pagein(&vf->os,&og,true);
1212 ogg_stream_pagein(&work_os,&og,true);
1213 lastflag=ogg_page_eos(&og);
1214
1215 }
1216 }
1217
1218 ogg_stream_clear(&work_os);
1219 vf->bittrack=0;
1220 vf->samptrack=0;
1221 return(0);
1222
1223 seek_error:
1224 /* dump the machine so we're in a known state */
1225 vf->pcm_offset=-1;
1226 ogg_stream_clear(&work_os);
1227 _decode_clear(vf);
1228 return OV_EBADLINK;
1229}
1230
1231/* rescales the number x from the range of [0,from] to [0,to]
1232 x is in the range [0,from]
1233 from, to are in the range [1, 1<<62-1] */
1234ogg_int64_t rescale64(ogg_int64_t x, ogg_int64_t from, ogg_int64_t to){
1235 ogg_int64_t frac=0;
1236 ogg_int64_t ret=0;
1237 int i;
1238 if(x >= from) return to;
1239 if(x <= 0) return 0;
1240
1241 for(i=0;i<64;i++){
1242 if(x>=from){
1243 frac|=1;
1244 x-=from;
1245 }
1246 x<<=1;
1247 frac<<=1;
1248 }
1249
1250 for(i=0;i<64;i++){
1251 if(frac & 1){
1252 ret+=to;
1253 }
1254 frac>>=1;
1255 ret>>=1;
1256 }
1257
1258 return ret;
1259}
1260
1261/* Page granularity seek (faster than sample granularity because we
1262 don't do the last bit of decode to find a specific sample).
1263
1264 Seek to the last [granule marked] page preceding the specified pos
1265 location, such that decoding past the returned point will quickly
1266 arrive at the requested position. */
1267int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos){
1268 int link=-1;
1269 ogg_int64_t result=0;
1270 ogg_int64_t total=ov_pcm_total(vf,-1);
1271
1272 if(vf->ready_state<OPENED)return(OV_EINVAL);
1273 if(!vf->seekable)return(OV_ENOSEEK);
1274
1275 if(pos<0 || pos>total)return(OV_EINVAL);
1276
1277 /* which bitstream section does this pcm offset occur in? */
1278 for(link=vf->links-1;link>=0;link--){
1279 total-=vf->pcmlengths[link*2+1];
1280 if(pos>=total)break;
1281 }
1282
1283 /* search within the logical bitstream for the page with the highest
1284 pcm_pos preceding (or equal to) pos. There is a danger here;
1285 missing pages or incorrect frame number information in the
1286 bitstream could make our task impossible. Account for that (it
1287 would be an error condition) */
1288
1289 /* new search algorithm by HB (Nicholas Vinen) */
1290 {
1291 ogg_int64_t end=vf->offsets[link+1];
1292 ogg_int64_t begin=vf->offsets[link];
1293 ogg_int64_t begintime = vf->pcmlengths[link*2];
1294 ogg_int64_t endtime = vf->pcmlengths[link*2+1]+begintime;
1295 ogg_int64_t target=pos-total+begintime;
1296 ogg_int64_t best=begin;
1297
1298 ogg_page og;
1299 while(begin<end){
1300 ogg_int64_t bisect;
1301
1302 if(end-begin<CHUNKSIZE){
1303 bisect=begin;
1304 }else{
1305 /* take a (pretty decent) guess. */
1306 bisect=begin + rescale64(target-begintime,
1307 endtime-begintime,
1308 end-begin) - CHUNKSIZE;
1309 if(bisect<begin+CHUNKSIZE)
1310 bisect=begin;
1311 }
1312
1313 if(bisect!=vf->offset){
1314 result=_seek_helper(vf,bisect);
1315 if(result) goto seek_error;
1316 }
1317
1318 while(begin<end){
1319 result=_get_next_page(vf,&og,end-vf->offset);
1320 if(result==OV_EREAD) goto seek_error;
1321 if(result<0){
1322 if(bisect<=begin+1)
1323 end=begin; /* found it */
1324 else{
1325 if(bisect==0) goto seek_error;
1326 bisect-=CHUNKSIZE;
1327 if(bisect<=begin)bisect=begin+1;
1328 result=_seek_helper(vf,bisect);
1329 if(result) goto seek_error;
1330 }
1331 }else{
1332 ogg_int64_t granulepos;
1333
1334 if(ogg_page_serialno(&og)!=vf->serialnos[link])
1335 continue;
1336
1337 granulepos=ogg_page_granulepos(&og);
1338 if(granulepos==-1)continue;
1339
1340 if(granulepos<target){
1341 best=result; /* raw offset of packet with granulepos */
1342 begin=vf->offset; /* raw offset of next page */
1343 begintime=granulepos;
1344
1345 if(target-begintime>44100)break;
1346 bisect=begin; /* *not* begin + 1 */
1347 }else{
1348 if(bisect<=begin+1)
1349 end=begin; /* found it */
1350 else{
1351 if(end==vf->offset){ /* we're pretty close - we'd be stuck in */
1352 end=result;
1353 bisect-=CHUNKSIZE; /* an endless loop otherwise. */
1354 if(bisect<=begin)bisect=begin+1;
1355 result=_seek_helper(vf,bisect);
1356 if(result) goto seek_error;
1357 }else{
1358 end=bisect;
1359 endtime=granulepos;
1360 break;
1361 }
1362 }
1363 }
1364 }
1365 }
1366 }
1367
1368 /* found our page. seek to it, update pcm offset. Easier case than
1369 raw_seek, don't keep packets preceding granulepos. */
1370 {
1371 ogg_page og;
1372 ogg_packet op;
1373
1374 /* seek */
1375 result=_seek_helper(vf,best);
1376 vf->pcm_offset=-1;
1377 if(result) goto seek_error;
1378 result=_get_next_page(vf,&og,-1);
1379 if(result<0) goto seek_error;
1380
1381 if(link!=vf->current_link){
1382 /* Different link; dump entire decode machine */
1383 _decode_clear(vf);
1384
1385 vf->current_link=link;
1386 vf->current_serialno=vf->serialnos[link];
1387 vf->ready_state=STREAMSET;
1388
1389 }else{
1390 vorbis_synthesis_restart(&vf->vd);
1391 }
1392
1393 ogg_stream_reset_serialno(&vf->os,vf->current_serialno);
1394 ogg_stream_pagein(&vf->os,&og,true);
1395
1396 /* pull out all but last packet; the one with granulepos */
1397 while(1){
1398 result=ogg_stream_packetpeek(&vf->os,&op);
1399 if(result==0){
1400 /* !!! the packet finishing this page originated on a
1401 preceding page. Keep fetching previous pages until we
1402 get one with a granulepos or without the 'continued' flag
1403 set. Then just use raw_seek for simplicity. */
1404
1405 result=_seek_helper(vf,best);
1406 if(result<0) goto seek_error;
1407
1408 while(1){
1409 result=_get_prev_page(vf,&og);
1410 if(result<0) goto seek_error;
1411 if(ogg_page_serialno(&og)==vf->current_serialno &&
1412 (ogg_page_granulepos(&og)>-1 ||
1413 !ogg_page_continued(&og))){
1414 return ov_raw_seek(vf,result);
1415 }
1416 vf->offset=result;
1417 }
1418 }
1419 if(result<0){
1420 result = OV_EBADPACKET;
1421 goto seek_error;
1422 }
1423 if(op.granulepos!=-1){
1424 vf->pcm_offset=op.granulepos-vf->pcmlengths[vf->current_link*2];
1425 if(vf->pcm_offset<0)vf->pcm_offset=0;
1426 vf->pcm_offset+=total;
1427 break;
1428 }else
1429 result=ogg_stream_packetout(&vf->os,NULL);
1430 }
1431 }
1432 }
1433
1434 /* verify result */
1435 if(vf->pcm_offset>pos || pos>ov_pcm_total(vf,-1)){
1436 result=OV_EFAULT;
1437 goto seek_error;
1438 }
1439 vf->bittrack=0;
1440 vf->samptrack=0;
1441 return(0);
1442
1443 seek_error:
1444 /* dump machine so we're in a known state */
1445 vf->pcm_offset=-1;
1446 _decode_clear(vf);
1447 return (int)result;
1448}
1449
1450/* seek to a sample offset relative to the decompressed pcm stream
1451 returns zero on success, nonzero on failure */
1452
1453int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos){
1454 int thisblock,lastblock=0;
1455 int ret=ov_pcm_seek_page(vf,pos);
1456 if(ret<0)return(ret);
1457 if((ret=_make_decode_ready(vf)))return ret;
1458
1459 /* discard leading packets we don't need for the lapping of the
1460 position we want; don't decode them */
1461
1462 while(1){
1463 ogg_packet op;
1464 ogg_page og;
1465
1466 int ret=ogg_stream_packetpeek(&vf->os,&op);
1467 if(ret>0){
1468 thisblock=vorbis_packet_blocksize(vf->vi+vf->current_link,&op);
1469 if(thisblock<0){
1470 ogg_stream_packetout(&vf->os,NULL);
1471 continue; /* non audio packet */
1472 }
1473 if(lastblock)vf->pcm_offset+=(lastblock+thisblock)>>2;
1474
1475 if(vf->pcm_offset+((thisblock+
1476 vorbis_info_blocksize(vf->vi,1))>>2)>=pos)break;
1477
1478 /* remove the packet from packet queue and track its granulepos */
1479 ogg_stream_packetout(&vf->os,NULL);
1480 vorbis_synthesis_trackonly(&vf->vb,&op); /* set up a vb with
1481 only tracking, no
1482 pcm_decode */
1483 vorbis_synthesis_blockin(&vf->vd,&vf->vb);
1484
1485 /* end of logical stream case is hard, especially with exact
1486 length positioning. */
1487
1488 if(op.granulepos>-1){
1489 int i;
1490 /* always believe the stream markers */
1491 vf->pcm_offset=op.granulepos-vf->pcmlengths[vf->current_link*2];
1492 if(vf->pcm_offset<0)vf->pcm_offset=0;
1493 for(i=0;i<vf->current_link;i++)
1494 vf->pcm_offset+=vf->pcmlengths[i*2+1];
1495 }
1496
1497 lastblock=thisblock;
1498
1499 }else{
1500 if(ret<0 && ret!=OV_HOLE)break;
1501
1502 /* suck in a new page */
1503 if(_get_next_page(vf,&og,-1)<0)break;
1504 if(ogg_page_bos(&og))_decode_clear(vf);
1505
1506 if(vf->ready_state<STREAMSET){
1507 long serialno=ogg_page_serialno(&og);
1508 int link;
1509
1510 for(link=0;link<vf->links;link++)
1511 if(vf->serialnos[link]==(ogg_uint32_t) serialno)break;
1512 if(link==vf->links) continue;
1513 vf->current_link=link;
1514
1515 vf->ready_state=STREAMSET;
1516 vf->current_serialno=ogg_page_serialno(&og);
1517 ogg_stream_reset_serialno(&vf->os,serialno);
1518 ret=_make_decode_ready(vf);
1519 if(ret)return ret;
1520 lastblock=0;
1521 }
1522
1523 ogg_stream_pagein(&vf->os,&og,true);
1524 }
1525 }
1526
1527 vf->bittrack=0;
1528 vf->samptrack=0;
1529 /* discard samples until we reach the desired position. Crossing a
1530 logical bitstream boundary with abandon is OK. */
1531 while(vf->pcm_offset<pos){
1532 ogg_int64_t target=pos-vf->pcm_offset;
1533 long samples=vorbis_synthesis_pcmout(&vf->vd,NULL);
1534
1535 if(samples>target)samples=target;
1536 vorbis_synthesis_read(&vf->vd,samples);
1537 vf->pcm_offset+=samples;
1538
1539 if(samples<target)
1540 if(_fetch_and_process_packet(vf,NULL,1,1)<=0)
1541 vf->pcm_offset=ov_pcm_total(vf,-1); /* eof */
1542 }
1543 return 0;
1544}
1545
1546/* seek to a playback time relative to the decompressed pcm stream
1547 returns zero on success, nonzero on failure */
1548int ov_time_seek(OggVorbis_File *vf,ogg_int64_t milliseconds){
1549 /* translate time to PCM position and call ov_pcm_seek */
1550
1551 int link=-1;
1552 ogg_int64_t pcm_total=0;
1553 ogg_int64_t time_total=0;
1554
1555 if(vf->ready_state<OPENED)return(OV_EINVAL);
1556 if(!vf->seekable)return(OV_ENOSEEK);
1557 if(milliseconds<0)return(OV_EINVAL);
1558
1559 /* which bitstream section does this time offset occur in? */
1560 for(link=0;link<vf->links;link++){
1561 ogg_int64_t addsec = ov_time_total(vf,link);
1562 if(milliseconds<time_total+addsec)break;
1563 time_total+=addsec;
1564 pcm_total+=vf->pcmlengths[link*2+1];
1565 }
1566
1567 if(link==vf->links)return(OV_EINVAL);
1568
1569 /* enough information to convert time offset to pcm offset */
1570 {
1571 ogg_int64_t target=pcm_total+(milliseconds-time_total)*vf->vi[link].rate/1000;
1572 return(ov_pcm_seek(vf,target));
1573 }
1574}
1575
1576/* tell the current stream offset cursor. Note that seek followed by
1577 tell will likely not give the set offset due to caching */
1578ogg_int64_t ov_raw_tell(OggVorbis_File *vf){
1579 if(vf->ready_state<OPENED)return(OV_EINVAL);
1580 return(vf->offset);
1581}
1582
1583/* return time offset (milliseconds) of next PCM sample to be read */
1584ogg_int64_t ov_time_tell(OggVorbis_File *vf){
1585 int link=0;
1586 ogg_int64_t pcm_total=0;
1587 ogg_int64_t time_total=0;
1588
1589 if(vf->ready_state<OPENED)return(OV_EINVAL);
1590 if(vf->seekable){
1591 pcm_total=ov_pcm_total(vf,-1);
1592 time_total=ov_time_total(vf,-1);
1593
1594 /* which bitstream section does this time offset occur in? */
1595 for(link=vf->links-1;link>=0;link--){
1596 pcm_total-=vf->pcmlengths[link*2+1];
1597 time_total-=ov_time_total(vf,link);
1598 if(vf->pcm_offset>=pcm_total)break;
1599 }
1600 }
1601
1602 return(time_total+(1000*vf->pcm_offset-pcm_total)/vf->vi[link].rate);
1603}
1604
1605/* link: -1) return the vorbis_info struct for the bitstream section
1606 currently being decoded
1607 0-n) to request information for a specific bitstream section
1608
1609 In the case of a non-seekable bitstream, any call returns the
1610 current bitstream. NULL in the case that the machine is not
1611 initialized */
1612
1613vorbis_info *ov_info(OggVorbis_File *vf,int link){
1614 if(vf->seekable){
1615 if(link<0)
1616 if(vf->ready_state>=STREAMSET)
1617 return vf->vi+vf->current_link;
1618 else
1619 return vf->vi;
1620 else
1621 if(link>=vf->links)
1622 return NULL;
1623 else
1624 return vf->vi+link;
1625 }else{
1626 return vf->vi;
1627 }
1628}
1629
1630/* input values: pcm_channels) a float vector per channel of output
1631 length) the sample length being read by the app
1632
1633 return values: <0) error/hole in data (OV_HOLE), partial open (OV_EINVAL)
1634 0) EOF
1635 n) number of samples of PCM actually returned. The
1636 below works on a packet-by-packet basis, so the
1637 return length is not related to the 'length' passed
1638 in, just guaranteed to fit.
1639
1640 *section) set to the logical bitstream number */
1641
1642long ov_read_fixed(OggVorbis_File *vf,ogg_int32_t ***pcm_channels,int length,
1643 int *bitstream){
1644 if(vf->ready_state<OPENED)return(OV_EINVAL);
1645
1646 while(1){
1647 if(vf->ready_state==INITSET){
1648 ogg_int32_t **pcm;
1649 long samples=vorbis_synthesis_pcmout(&vf->vd,&pcm);
1650 if(samples){
1651 if(pcm_channels)*pcm_channels=pcm;
1652 if(samples>length)samples=length;
1653 vorbis_synthesis_read(&vf->vd,samples);
1654 vf->pcm_offset+=samples;
1655 if(bitstream)*bitstream=vf->current_link;
1656 return samples;
1657
1658 }
1659 }
1660
1661 /* suck in another packet */
1662 {
1663 int ret=_fetch_and_process_packet(vf,NULL,1,1);
1664 if(ret==OV_EOF)
1665 return(0);
1666 if(ret<=0)
1667 return(ret);
1668 }
1669 }
1670}
1671
diff --git a/lib/rbcodec/codecs/libtremor/window.c b/lib/rbcodec/codecs/libtremor/window.c
new file mode 100644
index 0000000000..3bc947f0e5
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/window.c
@@ -0,0 +1,82 @@
1/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
4 * *
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * *
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
11 * *
12 ********************************************************************
13
14 function: window functions
15
16 ********************************************************************/
17
18#include "config-tremor.h"
19#include <string.h>
20#include <math.h>
21#include "os.h"
22#include "misc.h"
23#include "window.h"
24#include "window_lookup.h"
25
26const void *_vorbis_window(int type, int left){
27
28 switch(type){
29 case 0:
30
31 switch(left){
32 case 32:
33 return vwin64;
34 case 64:
35 return vwin128;
36 case 128:
37 return vwin256;
38 case 256:
39 return vwin512;
40 case 512:
41 return vwin1024;
42 case 1024:
43 return vwin2048;
44 case 2048:
45 return vwin4096;
46 case 4096:
47 return vwin8192;
48 default:
49 return(0);
50 }
51 break;
52 default:
53 return(0);
54 }
55}
56#if 0
57void _vorbis_apply_window(ogg_int32_t *d,const void *window_p[2],
58 long *blocksizes,
59 int lW,int W,int nW){
60 LOOKUP_T *window[2]={window_p[0],window_p[1]};
61 long n=blocksizes[W];
62 long ln=blocksizes[lW];
63 long rn=blocksizes[nW];
64
65 long leftbegin=n/4-ln/4;
66 long leftend=leftbegin+ln/2;
67
68 long rightbegin=n/2+n/4-rn/4;
69 long rightend=rightbegin+rn/2;
70
71 /* Following memset is not required - we are careful to only overlap/add the
72 regions that geniunely overlap in the window region, and the portions
73 outside that region are not added (so don't need to be zerod). see block.c
74 memset((void *)&d[0], 0, sizeof(ogg_int32_t)*leftbegin); */
75
76 ogg_vect_mult_fw(&d[leftbegin], &window[lW][0], leftend-leftbegin);
77 ogg_vect_mult_bw(&d[rightbegin], &window[nW][rn/2-1], rightend-rightbegin);
78
79 /* Again - memset not needed
80 memset((void *)&d[rightend], 0, sizeof(ogg_int32_t)*(n-rightend)); */
81}
82#endif
diff --git a/lib/rbcodec/codecs/libtremor/window.h b/lib/rbcodec/codecs/libtremor/window.h
new file mode 100644
index 0000000000..166d0b8e9c
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/window.h
@@ -0,0 +1,27 @@
1/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
4 * *
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * *
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
11 * *
12 ********************************************************************
13
14 function: window functions
15
16 ********************************************************************/
17
18#ifndef _V_WINDOW_
19#define _V_WINDOW_
20
21extern const void *_vorbis_window(int type,int left);
22/*extern void _vorbis_apply_window(ogg_int32_t *d,const void *window[2],
23 long *blocksizes,
24 int lW,int W,int nW);*/
25
26
27#endif
diff --git a/lib/rbcodec/codecs/libtremor/window_lookup.h b/lib/rbcodec/codecs/libtremor/window_lookup.h
new file mode 100644
index 0000000000..5363b81042
--- /dev/null
+++ b/lib/rbcodec/codecs/libtremor/window_lookup.h
@@ -0,0 +1,2087 @@
1/********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
4 * *
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * *
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
11 * *
12 ********************************************************************
13
14 function: window lookup tables
15
16 ********************************************************************/
17
18
19#include "os_types.h"
20
21/* libvorbis currently only use the window sizes 256 and 2048, so only put
22 * them in fast IRAM.
23 */
24static LOOKUP_T vwin64[32] = {
25 X(0x001f0003), X(0x01168c98), X(0x030333c8), X(0x05dfe3a4),
26 X(0x09a49562), X(0x0e45df18), X(0x13b47ef2), X(0x19dcf676),
27 X(0x20a74d83), X(0x27f7137c), X(0x2fabb05a), X(0x37a1105a),
28 X(0x3fb0ab28), X(0x47b2dcd1), X(0x4f807bc6), X(0x56f48e70),
29 X(0x5dedfc79), X(0x64511653), X(0x6a08cfff), X(0x6f079328),
30 X(0x734796f4), X(0x76cab7f2), X(0x7999d6e8), X(0x7bc3cf9f),
31 X(0x7d5c20c1), X(0x7e7961df), X(0x7f33a567), X(0x7fa2e1d0),
32 X(0x7fdd78a5), X(0x7ff6ec6d), X(0x7ffed0e9), X(0x7ffffc3f),
33};
34
35static LOOKUP_T vwin128[64] = {
36 X(0x0007c04d), X(0x0045bb89), X(0x00c18b87), X(0x017ae294),
37 X(0x02714a4e), X(0x03a4217a), X(0x05129952), X(0x06bbb24f),
38 X(0x089e38a1), X(0x0ab8c073), X(0x0d09a228), X(0x0f8ef6bd),
39 X(0x12469488), X(0x152e0c7a), X(0x1842a81c), X(0x1b81686d),
40 X(0x1ee705d9), X(0x226ff15d), X(0x26185705), X(0x29dc21cc),
41 X(0x2db700fe), X(0x31a46f08), X(0x359fb9c1), X(0x39a40c0c),
42 X(0x3dac78b6), X(0x41b40674), X(0x45b5bcb0), X(0x49acb109),
43 X(0x4d94152b), X(0x516744bd), X(0x5521d320), X(0x58bf98a5),
44 X(0x5c3cbef4), X(0x5f95cc5d), X(0x62c7add7), X(0x65cfbf64),
45 X(0x68abd2ba), X(0x6b5a3405), X(0x6dd9acab), X(0x7029840d),
46 X(0x72497e38), X(0x7439d8ac), X(0x75fb4532), X(0x778ee30a),
47 X(0x78f6367e), X(0x7a331f1a), X(0x7b47cccd), X(0x7c36b416),
48 X(0x7d028192), X(0x7dae0d18), X(0x7e3c4caa), X(0x7eb04763),
49 X(0x7f0d08a7), X(0x7f5593b7), X(0x7f8cd7d5), X(0x7fb5a513),
50 X(0x7fd2a1fc), X(0x7fe64212), X(0x7ff2bd4c), X(0x7ffa0890),
51 X(0x7ffdcf39), X(0x7fff6dac), X(0x7fffed01), X(0x7fffffc4),
52};
53
54static LOOKUP_T vwin256[128] = {
55 X(0x0001f018), X(0x00117066), X(0x00306e9e), X(0x005ee5f1),
56 X(0x009ccf26), X(0x00ea208b), X(0x0146cdea), X(0x01b2c87f),
57 X(0x022dfedf), X(0x02b85ced), X(0x0351cbbd), X(0x03fa317f),
58 X(0x04b17167), X(0x05776b90), X(0x064bfcdc), X(0x072efedd),
59 X(0x082047b4), X(0x091fa9f1), X(0x0a2cf477), X(0x0b47f25d),
60 X(0x0c706ad2), X(0x0da620ff), X(0x0ee8d3ef), X(0x10383e75),
61 X(0x11941716), X(0x12fc0ff6), X(0x146fd6c8), X(0x15ef14c2),
62 X(0x17796e8e), X(0x190e844f), X(0x1aadf196), X(0x1c574d6e),
63 X(0x1e0a2a62), X(0x1fc61688), X(0x218a9b9c), X(0x23573f12),
64 X(0x252b823d), X(0x2706e269), X(0x28e8d913), X(0x2ad0dc0e),
65 X(0x2cbe5dc1), X(0x2eb0cd60), X(0x30a79733), X(0x32a224d5),
66 X(0x349fdd8b), X(0x36a02690), X(0x38a2636f), X(0x3aa5f65e),
67 X(0x3caa409e), X(0x3eaea2df), X(0x40b27da6), X(0x42b531b8),
68 X(0x44b62086), X(0x46b4ac99), X(0x48b03a05), X(0x4aa82ed5),
69 X(0x4c9bf37d), X(0x4e8af349), X(0x50749ccb), X(0x52586246),
70 X(0x5435ba1c), X(0x560c1f31), X(0x57db1152), X(0x59a21591),
71 X(0x5b60b6a3), X(0x5d168535), X(0x5ec31839), X(0x60660d36),
72 X(0x61ff0886), X(0x638db595), X(0x6511c717), X(0x668af734),
73 X(0x67f907b0), X(0x695bc207), X(0x6ab2f787), X(0x6bfe815a),
74 X(0x6d3e4090), X(0x6e721e16), X(0x6f9a0ab5), X(0x70b5fef8),
75 X(0x71c5fb16), X(0x72ca06cd), X(0x73c2313d), X(0x74ae90b2),
76 X(0x758f4275), X(0x76646a85), X(0x772e335c), X(0x77eccda0),
77 X(0x78a06fd7), X(0x79495613), X(0x79e7c19c), X(0x7a7bf894),
78 X(0x7b064596), X(0x7b86f757), X(0x7bfe6044), X(0x7c6cd615),
79 X(0x7cd2b16e), X(0x7d304d71), X(0x7d860756), X(0x7dd43e06),
80 X(0x7e1b51ad), X(0x7e5ba355), X(0x7e95947e), X(0x7ec986bb),
81 X(0x7ef7db4a), X(0x7f20f2b9), X(0x7f452c7f), X(0x7f64e6a7),
82 X(0x7f807d71), X(0x7f984aff), X(0x7faca700), X(0x7fbde662),
83 X(0x7fcc5b04), X(0x7fd85372), X(0x7fe21a99), X(0x7fe9f791),
84 X(0x7ff02d58), X(0x7ff4fa9e), X(0x7ff89990), X(0x7ffb3faa),
85 X(0x7ffd1d8b), X(0x7ffe5ecc), X(0x7fff29e0), X(0x7fff9ff3),
86 X(0x7fffdcd2), X(0x7ffff6d6), X(0x7ffffed0), X(0x7ffffffc),
87};
88
89static LOOKUP_T vwin512[256] = {
90 X(0x00007c06), X(0x00045c32), X(0x000c1c62), X(0x0017bc4c),
91 X(0x00273b7a), X(0x003a9955), X(0x0051d51c), X(0x006cede7),
92 X(0x008be2a9), X(0x00aeb22a), X(0x00d55b0d), X(0x00ffdbcc),
93 X(0x012e32b6), X(0x01605df5), X(0x01965b85), X(0x01d02939),
94 X(0x020dc4ba), X(0x024f2b83), X(0x02945ae6), X(0x02dd5004),
95 X(0x032a07d3), X(0x037a7f19), X(0x03ceb26e), X(0x04269e37),
96 X(0x04823eab), X(0x04e18fcc), X(0x05448d6d), X(0x05ab3329),
97 X(0x06157c68), X(0x0683645e), X(0x06f4e607), X(0x0769fc25),
98 X(0x07e2a146), X(0x085ecfbc), X(0x08de819f), X(0x0961b0cc),
99 X(0x09e856e3), X(0x0a726d46), X(0x0affed1d), X(0x0b90cf4c),
100 X(0x0c250c79), X(0x0cbc9d0b), X(0x0d577926), X(0x0df598aa),
101 X(0x0e96f337), X(0x0f3b8026), X(0x0fe3368f), X(0x108e0d42),
102 X(0x113bfaca), X(0x11ecf56b), X(0x12a0f324), X(0x1357e9ac),
103 X(0x1411ce70), X(0x14ce9698), X(0x158e3702), X(0x1650a444),
104 X(0x1715d2aa), X(0x17ddb638), X(0x18a842aa), X(0x19756b72),
105 X(0x1a4523b9), X(0x1b175e62), X(0x1bec0e04), X(0x1cc324f0),
106 X(0x1d9c9532), X(0x1e78508a), X(0x1f564876), X(0x20366e2e),
107 X(0x2118b2a2), X(0x21fd0681), X(0x22e35a37), X(0x23cb9dee),
108 X(0x24b5c18e), X(0x25a1b4c0), X(0x268f66f1), X(0x277ec74e),
109 X(0x286fc4cc), X(0x29624e23), X(0x2a5651d7), X(0x2b4bbe34),
110 X(0x2c428150), X(0x2d3a8913), X(0x2e33c332), X(0x2f2e1d35),
111 X(0x30298478), X(0x3125e62d), X(0x32232f61), X(0x33214cfc),
112 X(0x34202bc2), X(0x351fb85a), X(0x361fdf4f), X(0x37208d10),
113 X(0x3821adf7), X(0x39232e49), X(0x3a24fa3c), X(0x3b26fdf6),
114 X(0x3c292593), X(0x3d2b5d29), X(0x3e2d90c8), X(0x3f2fac7f),
115 X(0x40319c5f), X(0x41334c81), X(0x4234a905), X(0x43359e16),
116 X(0x443617f3), X(0x453602eb), X(0x46354b65), X(0x4733dde1),
117 X(0x4831a6ff), X(0x492e937f), X(0x4a2a9045), X(0x4b258a5f),
118 X(0x4c1f6f06), X(0x4d182ba2), X(0x4e0fadce), X(0x4f05e35b),
119 X(0x4ffaba53), X(0x50ee20fd), X(0x51e005e1), X(0x52d057ca),
120 X(0x53bf05ca), X(0x54abff3b), X(0x559733c7), X(0x56809365),
121 X(0x57680e62), X(0x584d955d), X(0x59311952), X(0x5a128b96),
122 X(0x5af1dddd), X(0x5bcf023a), X(0x5ca9eb27), X(0x5d828b81),
123 X(0x5e58d68d), X(0x5f2cbffc), X(0x5ffe3be9), X(0x60cd3edf),
124 X(0x6199bdda), X(0x6263ae45), X(0x632b0602), X(0x63efbb66),
125 X(0x64b1c53f), X(0x65711ad0), X(0x662db3d7), X(0x66e7888d),
126 X(0x679e91a5), X(0x6852c84e), X(0x69042635), X(0x69b2a582),
127 X(0x6a5e40dd), X(0x6b06f36c), X(0x6bacb8d2), X(0x6c4f8d30),
128 X(0x6cef6d26), X(0x6d8c55d4), X(0x6e2644d4), X(0x6ebd3840),
129 X(0x6f512ead), X(0x6fe2272e), X(0x7070214f), X(0x70fb1d17),
130 X(0x71831b06), X(0x72081c16), X(0x728a21b5), X(0x73092dc8),
131 X(0x738542a6), X(0x73fe631b), X(0x74749261), X(0x74e7d421),
132 X(0x75582c72), X(0x75c59fd5), X(0x76303333), X(0x7697ebdd),
133 X(0x76fccf85), X(0x775ee443), X(0x77be308a), X(0x781abb2e),
134 X(0x78748b59), X(0x78cba88e), X(0x79201aa7), X(0x7971e9cd),
135 X(0x79c11e79), X(0x7a0dc170), X(0x7a57dbc2), X(0x7a9f76c1),
136 X(0x7ae49c07), X(0x7b27556b), X(0x7b67ad02), X(0x7ba5ad1b),
137 X(0x7be1603a), X(0x7c1ad118), X(0x7c520a9e), X(0x7c8717e1),
138 X(0x7cba0421), X(0x7ceadac3), X(0x7d19a74f), X(0x7d46756e),
139 X(0x7d7150e5), X(0x7d9a4592), X(0x7dc15f69), X(0x7de6aa71),
140 X(0x7e0a32c0), X(0x7e2c0479), X(0x7e4c2bc7), X(0x7e6ab4db),
141 X(0x7e87abe9), X(0x7ea31d24), X(0x7ebd14be), X(0x7ed59edd),
142 X(0x7eecc7a3), X(0x7f029b21), X(0x7f17255a), X(0x7f2a723f),
143 X(0x7f3c8daa), X(0x7f4d835d), X(0x7f5d5f00), X(0x7f6c2c1b),
144 X(0x7f79f617), X(0x7f86c83a), X(0x7f92ada2), X(0x7f9db146),
145 X(0x7fa7ddf3), X(0x7fb13e46), X(0x7fb9dcb0), X(0x7fc1c36c),
146 X(0x7fc8fc83), X(0x7fcf91c7), X(0x7fd58cd2), X(0x7fdaf702),
147 X(0x7fdfd979), X(0x7fe43d1c), X(0x7fe82a8b), X(0x7febaa29),
148 X(0x7feec412), X(0x7ff1801c), X(0x7ff3e5d6), X(0x7ff5fc86),
149 X(0x7ff7cb29), X(0x7ff9586f), X(0x7ffaaaba), X(0x7ffbc81e),
150 X(0x7ffcb660), X(0x7ffd7af3), X(0x7ffe1afa), X(0x7ffe9b42),
151 X(0x7fff0047), X(0x7fff4e2f), X(0x7fff88c9), X(0x7fffb390),
152 X(0x7fffd1a6), X(0x7fffe5d7), X(0x7ffff296), X(0x7ffff9fd),
153 X(0x7ffffdcd), X(0x7fffff6d), X(0x7fffffed), X(0x7fffffff),
154};
155
156static LOOKUP_T vwin1024[512] = {
157 X(0x00001f02), X(0x0001170e), X(0x00030724), X(0x0005ef40),
158 X(0x0009cf59), X(0x000ea767), X(0x0014775e), X(0x001b3f2e),
159 X(0x0022fec8), X(0x002bb618), X(0x00356508), X(0x00400b81),
160 X(0x004ba968), X(0x00583ea0), X(0x0065cb0a), X(0x00744e84),
161 X(0x0083c8ea), X(0x00943a14), X(0x00a5a1da), X(0x00b80010),
162 X(0x00cb5488), X(0x00df9f10), X(0x00f4df76), X(0x010b1584),
163 X(0x01224101), X(0x013a61b2), X(0x01537759), X(0x016d81b6),
164 X(0x01888087), X(0x01a47385), X(0x01c15a69), X(0x01df34e6),
165 X(0x01fe02b1), X(0x021dc377), X(0x023e76e7), X(0x02601ca9),
166 X(0x0282b466), X(0x02a63dc1), X(0x02cab85d), X(0x02f023d6),
167 X(0x03167fcb), X(0x033dcbd3), X(0x03660783), X(0x038f3270),
168 X(0x03b94c29), X(0x03e4543a), X(0x04104a2e), X(0x043d2d8b),
169 X(0x046afdd5), X(0x0499ba8c), X(0x04c9632d), X(0x04f9f734),
170 X(0x052b7615), X(0x055ddf46), X(0x05913237), X(0x05c56e53),
171 X(0x05fa9306), X(0x06309fb6), X(0x066793c5), X(0x069f6e93),
172 X(0x06d82f7c), X(0x0711d5d9), X(0x074c60fe), X(0x0787d03d),
173 X(0x07c422e4), X(0x0801583e), X(0x083f6f91), X(0x087e681f),
174 X(0x08be4129), X(0x08fef9ea), X(0x0940919a), X(0x0983076d),
175 X(0x09c65a92), X(0x0a0a8a38), X(0x0a4f9585), X(0x0a957b9f),
176 X(0x0adc3ba7), X(0x0b23d4b9), X(0x0b6c45ee), X(0x0bb58e5a),
177 X(0x0bffad0f), X(0x0c4aa11a), X(0x0c966982), X(0x0ce3054d),
178 X(0x0d30737b), X(0x0d7eb308), X(0x0dcdc2eb), X(0x0e1da21a),
179 X(0x0e6e4f83), X(0x0ebfca11), X(0x0f1210ad), X(0x0f652238),
180 X(0x0fb8fd91), X(0x100da192), X(0x10630d11), X(0x10b93ee0),
181 X(0x111035cb), X(0x1167f09a), X(0x11c06e13), X(0x1219acf5),
182 X(0x1273abfb), X(0x12ce69db), X(0x1329e54a), X(0x13861cf3),
183 X(0x13e30f80), X(0x1440bb97), X(0x149f1fd8), X(0x14fe3ade),
184 X(0x155e0b40), X(0x15be8f92), X(0x161fc662), X(0x1681ae38),
185 X(0x16e4459b), X(0x17478b0b), X(0x17ab7d03), X(0x181019fb),
186 X(0x18756067), X(0x18db4eb3), X(0x1941e34a), X(0x19a91c92),
187 X(0x1a10f8ea), X(0x1a7976af), X(0x1ae29439), X(0x1b4c4fda),
188 X(0x1bb6a7e2), X(0x1c219a9a), X(0x1c8d2649), X(0x1cf9492e),
189 X(0x1d660188), X(0x1dd34d8e), X(0x1e412b74), X(0x1eaf996a),
190 X(0x1f1e959b), X(0x1f8e1e2f), X(0x1ffe3146), X(0x206ecd01),
191 X(0x20dfef78), X(0x215196c2), X(0x21c3c0f0), X(0x22366c10),
192 X(0x22a9962a), X(0x231d3d45), X(0x23915f60), X(0x2405fa7a),
193 X(0x247b0c8c), X(0x24f09389), X(0x25668d65), X(0x25dcf80c),
194 X(0x2653d167), X(0x26cb175e), X(0x2742c7d0), X(0x27bae09e),
195 X(0x28335fa2), X(0x28ac42b3), X(0x292587a5), X(0x299f2c48),
196 X(0x2a192e69), X(0x2a938bd1), X(0x2b0e4247), X(0x2b894f8d),
197 X(0x2c04b164), X(0x2c806588), X(0x2cfc69b2), X(0x2d78bb9a),
198 X(0x2df558f4), X(0x2e723f6f), X(0x2eef6cbb), X(0x2f6cde83),
199 X(0x2fea9270), X(0x30688627), X(0x30e6b74e), X(0x31652385),
200 X(0x31e3c86b), X(0x3262a39e), X(0x32e1b2b8), X(0x3360f352),
201 X(0x33e06303), X(0x345fff5e), X(0x34dfc5f8), X(0x355fb462),
202 X(0x35dfc82a), X(0x365ffee0), X(0x36e0560f), X(0x3760cb43),
203 X(0x37e15c05), X(0x386205df), X(0x38e2c657), X(0x39639af5),
204 X(0x39e4813e), X(0x3a6576b6), X(0x3ae678e3), X(0x3b678547),
205 X(0x3be89965), X(0x3c69b2c1), X(0x3ceacedc), X(0x3d6beb37),
206 X(0x3ded0557), X(0x3e6e1abb), X(0x3eef28e6), X(0x3f702d5a),
207 X(0x3ff1259a), X(0x40720f29), X(0x40f2e789), X(0x4173ac3f),
208 X(0x41f45ad0), X(0x4274f0c2), X(0x42f56b9a), X(0x4375c8e0),
209 X(0x43f6061d), X(0x447620db), X(0x44f616a5), X(0x4575e509),
210 X(0x45f58994), X(0x467501d6), X(0x46f44b62), X(0x477363cb),
211 X(0x47f248a6), X(0x4870f78e), X(0x48ef6e1a), X(0x496da9e8),
212 X(0x49eba897), X(0x4a6967c8), X(0x4ae6e521), X(0x4b641e47),
213 X(0x4be110e5), X(0x4c5dbaa7), X(0x4cda193f), X(0x4d562a5f),
214 X(0x4dd1ebbd), X(0x4e4d5b15), X(0x4ec87623), X(0x4f433aa9),
215 X(0x4fbda66c), X(0x5037b734), X(0x50b16acf), X(0x512abf0e),
216 X(0x51a3b1c5), X(0x521c40ce), X(0x52946a06), X(0x530c2b50),
217 X(0x53838292), X(0x53fa6db8), X(0x5470eab3), X(0x54e6f776),
218 X(0x555c91fc), X(0x55d1b844), X(0x56466851), X(0x56baa02f),
219 X(0x572e5deb), X(0x57a19f98), X(0x58146352), X(0x5886a737),
220 X(0x58f8696d), X(0x5969a81c), X(0x59da6177), X(0x5a4a93b4),
221 X(0x5aba3d0f), X(0x5b295bcb), X(0x5b97ee30), X(0x5c05f28d),
222 X(0x5c736738), X(0x5ce04a8d), X(0x5d4c9aed), X(0x5db856c1),
223 X(0x5e237c78), X(0x5e8e0a89), X(0x5ef7ff6f), X(0x5f6159b0),
224 X(0x5fca17d4), X(0x6032386e), X(0x6099ba15), X(0x61009b69),
225 X(0x6166db11), X(0x61cc77b9), X(0x62317017), X(0x6295c2e7),
226 X(0x62f96eec), X(0x635c72f1), X(0x63becdc8), X(0x64207e4b),
227 X(0x6481835a), X(0x64e1dbde), X(0x654186c8), X(0x65a0830e),
228 X(0x65fecfb1), X(0x665c6bb7), X(0x66b95630), X(0x67158e30),
229 X(0x677112d7), X(0x67cbe34b), X(0x6825feb9), X(0x687f6456),
230 X(0x68d81361), X(0x69300b1e), X(0x69874ada), X(0x69ddd1ea),
231 X(0x6a339fab), X(0x6a88b382), X(0x6add0cdb), X(0x6b30ab2a),
232 X(0x6b838dec), X(0x6bd5b4a6), X(0x6c271ee2), X(0x6c77cc36),
233 X(0x6cc7bc3d), X(0x6d16ee9b), X(0x6d6562fb), X(0x6db31911),
234 X(0x6e001099), X(0x6e4c4955), X(0x6e97c311), X(0x6ee27d9f),
235 X(0x6f2c78d9), X(0x6f75b4a2), X(0x6fbe30e4), X(0x7005ed91),
236 X(0x704ceaa1), X(0x70932816), X(0x70d8a5f8), X(0x711d6457),
237 X(0x7161634b), X(0x71a4a2f3), X(0x71e72375), X(0x7228e500),
238 X(0x7269e7c8), X(0x72aa2c0a), X(0x72e9b209), X(0x73287a12),
239 X(0x73668476), X(0x73a3d18f), X(0x73e061bc), X(0x741c3566),
240 X(0x74574cfa), X(0x7491a8ee), X(0x74cb49be), X(0x75042fec),
241 X(0x753c5c03), X(0x7573ce92), X(0x75aa882f), X(0x75e08979),
242 X(0x7615d313), X(0x764a65a7), X(0x767e41e5), X(0x76b16884),
243 X(0x76e3da40), X(0x771597dc), X(0x7746a221), X(0x7776f9dd),
244 X(0x77a69fe6), X(0x77d59514), X(0x7803da49), X(0x7831706a),
245 X(0x785e5861), X(0x788a9320), X(0x78b6219c), X(0x78e104cf),
246 X(0x790b3dbb), X(0x7934cd64), X(0x795db4d5), X(0x7985f51d),
247 X(0x79ad8f50), X(0x79d48486), X(0x79fad5de), X(0x7a208478),
248 X(0x7a45917b), X(0x7a69fe12), X(0x7a8dcb6c), X(0x7ab0fabb),
249 X(0x7ad38d36), X(0x7af5841a), X(0x7b16e0a3), X(0x7b37a416),
250 X(0x7b57cfb8), X(0x7b7764d4), X(0x7b9664b6), X(0x7bb4d0b0),
251 X(0x7bd2aa14), X(0x7beff23b), X(0x7c0caa7f), X(0x7c28d43c),
252 X(0x7c4470d2), X(0x7c5f81a5), X(0x7c7a081a), X(0x7c940598),
253 X(0x7cad7b8b), X(0x7cc66b5e), X(0x7cded680), X(0x7cf6be64),
254 X(0x7d0e247b), X(0x7d250a3c), X(0x7d3b711c), X(0x7d515a95),
255 X(0x7d66c822), X(0x7d7bbb3c), X(0x7d903563), X(0x7da43814),
256 X(0x7db7c4d0), X(0x7dcadd16), X(0x7ddd826a), X(0x7defb64d),
257 X(0x7e017a44), X(0x7e12cfd3), X(0x7e23b87f), X(0x7e3435cc),
258 X(0x7e444943), X(0x7e53f467), X(0x7e6338c0), X(0x7e7217d5),
259 X(0x7e80932b), X(0x7e8eac49), X(0x7e9c64b7), X(0x7ea9bdf8),
260 X(0x7eb6b994), X(0x7ec35910), X(0x7ecf9def), X(0x7edb89b6),
261 X(0x7ee71de9), X(0x7ef25c09), X(0x7efd4598), X(0x7f07dc16),
262 X(0x7f122103), X(0x7f1c15dc), X(0x7f25bc1f), X(0x7f2f1547),
263 X(0x7f3822cd), X(0x7f40e62b), X(0x7f4960d6), X(0x7f519443),
264 X(0x7f5981e7), X(0x7f612b31), X(0x7f689191), X(0x7f6fb674),
265 X(0x7f769b45), X(0x7f7d416c), X(0x7f83aa51), X(0x7f89d757),
266 X(0x7f8fc9df), X(0x7f958348), X(0x7f9b04ef), X(0x7fa0502e),
267 X(0x7fa56659), X(0x7faa48c7), X(0x7faef8c7), X(0x7fb377a7),
268 X(0x7fb7c6b3), X(0x7fbbe732), X(0x7fbfda67), X(0x7fc3a196),
269 X(0x7fc73dfa), X(0x7fcab0ce), X(0x7fcdfb4a), X(0x7fd11ea0),
270 X(0x7fd41c00), X(0x7fd6f496), X(0x7fd9a989), X(0x7fdc3bff),
271 X(0x7fdead17), X(0x7fe0fdee), X(0x7fe32f9d), X(0x7fe54337),
272 X(0x7fe739ce), X(0x7fe9146c), X(0x7fead41b), X(0x7fec79dd),
273 X(0x7fee06b2), X(0x7fef7b94), X(0x7ff0d97b), X(0x7ff22158),
274 X(0x7ff35417), X(0x7ff472a3), X(0x7ff57de0), X(0x7ff676ac),
275 X(0x7ff75de3), X(0x7ff8345a), X(0x7ff8fae4), X(0x7ff9b24b),
276 X(0x7ffa5b58), X(0x7ffaf6cd), X(0x7ffb8568), X(0x7ffc07e2),
277 X(0x7ffc7eed), X(0x7ffceb38), X(0x7ffd4d6d), X(0x7ffda631),
278 X(0x7ffdf621), X(0x7ffe3dd8), X(0x7ffe7dea), X(0x7ffeb6e7),
279 X(0x7ffee959), X(0x7fff15c4), X(0x7fff3ca9), X(0x7fff5e80),
280 X(0x7fff7bc0), X(0x7fff94d6), X(0x7fffaa2d), X(0x7fffbc29),
281 X(0x7fffcb29), X(0x7fffd786), X(0x7fffe195), X(0x7fffe9a3),
282 X(0x7fffeffa), X(0x7ffff4dd), X(0x7ffff889), X(0x7ffffb37),
283 X(0x7ffffd1a), X(0x7ffffe5d), X(0x7fffff29), X(0x7fffffa0),
284 X(0x7fffffdd), X(0x7ffffff7), X(0x7fffffff), X(0x7fffffff),
285};
286
287static LOOKUP_T vwin2048[1024] = {
288 X(0x000007c0), X(0x000045c4), X(0x0000c1ca), X(0x00017bd3),
289 X(0x000273de), X(0x0003a9eb), X(0x00051df9), X(0x0006d007),
290 X(0x0008c014), X(0x000aee1e), X(0x000d5a25), X(0x00100428),
291 X(0x0012ec23), X(0x00161216), X(0x001975fe), X(0x001d17da),
292 X(0x0020f7a8), X(0x00251564), X(0x0029710c), X(0x002e0a9e),
293 X(0x0032e217), X(0x0037f773), X(0x003d4ab0), X(0x0042dbca),
294 X(0x0048aabe), X(0x004eb788), X(0x00550224), X(0x005b8a8f),
295 X(0x006250c5), X(0x006954c1), X(0x0070967e), X(0x007815f9),
296 X(0x007fd32c), X(0x0087ce13), X(0x009006a9), X(0x00987ce9),
297 X(0x00a130cc), X(0x00aa224f), X(0x00b3516b), X(0x00bcbe1a),
298 X(0x00c66856), X(0x00d0501a), X(0x00da755f), X(0x00e4d81f),
299 X(0x00ef7853), X(0x00fa55f4), X(0x010570fc), X(0x0110c963),
300 X(0x011c5f22), X(0x01283232), X(0x0134428c), X(0x01409027),
301 X(0x014d1afb), X(0x0159e302), X(0x0166e831), X(0x01742a82),
302 X(0x0181a9ec), X(0x018f6665), X(0x019d5fe5), X(0x01ab9663),
303 X(0x01ba09d6), X(0x01c8ba34), X(0x01d7a775), X(0x01e6d18d),
304 X(0x01f63873), X(0x0205dc1e), X(0x0215bc82), X(0x0225d997),
305 X(0x02363350), X(0x0246c9a3), X(0x02579c86), X(0x0268abed),
306 X(0x0279f7cc), X(0x028b801a), X(0x029d44c9), X(0x02af45ce),
307 X(0x02c1831d), X(0x02d3fcaa), X(0x02e6b269), X(0x02f9a44c),
308 X(0x030cd248), X(0x03203c4f), X(0x0333e255), X(0x0347c44b),
309 X(0x035be225), X(0x03703bd5), X(0x0384d14d), X(0x0399a280),
310 X(0x03aeaf5e), X(0x03c3f7d9), X(0x03d97be4), X(0x03ef3b6e),
311 X(0x0405366a), X(0x041b6cc8), X(0x0431de78), X(0x04488b6c),
312 X(0x045f7393), X(0x047696dd), X(0x048df53b), X(0x04a58e9b),
313 X(0x04bd62ee), X(0x04d57223), X(0x04edbc28), X(0x050640ed),
314 X(0x051f0060), X(0x0537fa70), X(0x05512f0a), X(0x056a9e1e),
315 X(0x05844798), X(0x059e2b67), X(0x05b84978), X(0x05d2a1b8),
316 X(0x05ed3414), X(0x06080079), X(0x062306d3), X(0x063e470f),
317 X(0x0659c119), X(0x067574dd), X(0x06916247), X(0x06ad8941),
318 X(0x06c9e9b8), X(0x06e68397), X(0x070356c8), X(0x07206336),
319 X(0x073da8cb), X(0x075b2772), X(0x0778df15), X(0x0796cf9c),
320 X(0x07b4f8f3), X(0x07d35b01), X(0x07f1f5b1), X(0x0810c8eb),
321 X(0x082fd497), X(0x084f189e), X(0x086e94e9), X(0x088e495e),
322 X(0x08ae35e6), X(0x08ce5a68), X(0x08eeb6cc), X(0x090f4af8),
323 X(0x093016d3), X(0x09511a44), X(0x09725530), X(0x0993c77f),
324 X(0x09b57115), X(0x09d751d8), X(0x09f969ae), X(0x0a1bb87c),
325 X(0x0a3e3e26), X(0x0a60fa91), X(0x0a83eda2), X(0x0aa7173c),
326 X(0x0aca7743), X(0x0aee0d9b), X(0x0b11da28), X(0x0b35dccc),
327 X(0x0b5a156a), X(0x0b7e83e5), X(0x0ba3281f), X(0x0bc801fa),
328 X(0x0bed1159), X(0x0c12561c), X(0x0c37d025), X(0x0c5d7f55),
329 X(0x0c83638d), X(0x0ca97cae), X(0x0ccfca97), X(0x0cf64d2a),
330 X(0x0d1d0444), X(0x0d43efc7), X(0x0d6b0f92), X(0x0d926383),
331 X(0x0db9eb79), X(0x0de1a752), X(0x0e0996ee), X(0x0e31ba29),
332 X(0x0e5a10e2), X(0x0e829af6), X(0x0eab5841), X(0x0ed448a2),
333 X(0x0efd6bf4), X(0x0f26c214), X(0x0f504ade), X(0x0f7a062e),
334 X(0x0fa3f3df), X(0x0fce13cd), X(0x0ff865d2), X(0x1022e9ca),
335 X(0x104d9f8e), X(0x107886f9), X(0x10a39fe5), X(0x10ceea2c),
336 X(0x10fa65a6), X(0x1126122d), X(0x1151ef9a), X(0x117dfdc5),
337 X(0x11aa3c87), X(0x11d6abb6), X(0x12034b2c), X(0x12301ac0),
338 X(0x125d1a48), X(0x128a499b), X(0x12b7a891), X(0x12e536ff),
339 X(0x1312f4bb), X(0x1340e19c), X(0x136efd75), X(0x139d481e),
340 X(0x13cbc16a), X(0x13fa692f), X(0x14293f40), X(0x14584371),
341 X(0x14877597), X(0x14b6d585), X(0x14e6630d), X(0x15161e04),
342 X(0x1546063b), X(0x15761b85), X(0x15a65db3), X(0x15d6cc99),
343 X(0x16076806), X(0x16382fcd), X(0x166923bf), X(0x169a43ab),
344 X(0x16cb8f62), X(0x16fd06b5), X(0x172ea973), X(0x1760776b),
345 X(0x1792706e), X(0x17c49449), X(0x17f6e2cb), X(0x18295bc3),
346 X(0x185bfeff), X(0x188ecc4c), X(0x18c1c379), X(0x18f4e452),
347 X(0x19282ea4), X(0x195ba23c), X(0x198f3ee6), X(0x19c3046e),
348 X(0x19f6f2a1), X(0x1a2b094a), X(0x1a5f4833), X(0x1a93af28),
349 X(0x1ac83df3), X(0x1afcf460), X(0x1b31d237), X(0x1b66d744),
350 X(0x1b9c034e), X(0x1bd15621), X(0x1c06cf84), X(0x1c3c6f40),
351 X(0x1c72351e), X(0x1ca820e6), X(0x1cde3260), X(0x1d146953),
352 X(0x1d4ac587), X(0x1d8146c3), X(0x1db7eccd), X(0x1deeb76c),
353 X(0x1e25a667), X(0x1e5cb982), X(0x1e93f085), X(0x1ecb4b33),
354 X(0x1f02c953), X(0x1f3a6aaa), X(0x1f722efb), X(0x1faa160b),
355 X(0x1fe21f9e), X(0x201a4b79), X(0x2052995d), X(0x208b0910),
356 X(0x20c39a53), X(0x20fc4cea), X(0x21352097), X(0x216e151c),
357 X(0x21a72a3a), X(0x21e05fb5), X(0x2219b54d), X(0x22532ac3),
358 X(0x228cbfd8), X(0x22c6744d), X(0x230047e2), X(0x233a3a58),
359 X(0x23744b6d), X(0x23ae7ae3), X(0x23e8c878), X(0x242333ec),
360 X(0x245dbcfd), X(0x24986369), X(0x24d326f1), X(0x250e0750),
361 X(0x25490446), X(0x25841d90), X(0x25bf52ec), X(0x25faa417),
362 X(0x263610cd), X(0x267198cc), X(0x26ad3bcf), X(0x26e8f994),
363 X(0x2724d1d6), X(0x2760c451), X(0x279cd0c0), X(0x27d8f6e0),
364 X(0x2815366a), X(0x28518f1b), X(0x288e00ac), X(0x28ca8ad8),
365 X(0x29072d5a), X(0x2943e7eb), X(0x2980ba45), X(0x29bda422),
366 X(0x29faa53c), X(0x2a37bd4a), X(0x2a74ec07), X(0x2ab2312b),
367 X(0x2aef8c6f), X(0x2b2cfd8b), X(0x2b6a8437), X(0x2ba8202c),
368 X(0x2be5d120), X(0x2c2396cc), X(0x2c6170e7), X(0x2c9f5f29),
369 X(0x2cdd6147), X(0x2d1b76fa), X(0x2d599ff7), X(0x2d97dbf5),
370 X(0x2dd62aab), X(0x2e148bcf), X(0x2e52ff16), X(0x2e918436),
371 X(0x2ed01ae5), X(0x2f0ec2d9), X(0x2f4d7bc6), X(0x2f8c4562),
372 X(0x2fcb1f62), X(0x300a097a), X(0x3049035f), X(0x30880cc6),
373 X(0x30c72563), X(0x31064cea), X(0x3145830f), X(0x3184c786),
374 X(0x31c41a03), X(0x32037a39), X(0x3242e7dc), X(0x3282629f),
375 X(0x32c1ea36), X(0x33017e53), X(0x33411ea9), X(0x3380caec),
376 X(0x33c082ce), X(0x34004602), X(0x34401439), X(0x347fed27),
377 X(0x34bfd07e), X(0x34ffbdf0), X(0x353fb52e), X(0x357fb5ec),
378 X(0x35bfbfda), X(0x35ffd2aa), X(0x363fee0f), X(0x368011b9),
379 X(0x36c03d5a), X(0x370070a4), X(0x3740ab48), X(0x3780ecf7),
380 X(0x37c13562), X(0x3801843a), X(0x3841d931), X(0x388233f7),
381 X(0x38c2943d), X(0x3902f9b4), X(0x3943640d), X(0x3983d2f8),
382 X(0x39c44626), X(0x3a04bd48), X(0x3a45380e), X(0x3a85b62a),
383 X(0x3ac6374a), X(0x3b06bb20), X(0x3b47415c), X(0x3b87c9ae),
384 X(0x3bc853c7), X(0x3c08df57), X(0x3c496c0f), X(0x3c89f99f),
385 X(0x3cca87b6), X(0x3d0b1605), X(0x3d4ba43d), X(0x3d8c320e),
386 X(0x3dccbf27), X(0x3e0d4b3a), X(0x3e4dd5f6), X(0x3e8e5f0c),
387 X(0x3ecee62b), X(0x3f0f6b05), X(0x3f4fed49), X(0x3f906ca8),
388 X(0x3fd0e8d2), X(0x40116177), X(0x4051d648), X(0x409246f6),
389 X(0x40d2b330), X(0x41131aa7), X(0x41537d0c), X(0x4193da10),
390 X(0x41d43162), X(0x421482b4), X(0x4254cdb7), X(0x4295121b),
391 X(0x42d54f91), X(0x431585ca), X(0x4355b477), X(0x4395db49),
392 X(0x43d5f9f1), X(0x44161021), X(0x44561d8a), X(0x449621dd),
393 X(0x44d61ccc), X(0x45160e08), X(0x4555f544), X(0x4595d230),
394 X(0x45d5a47f), X(0x46156be3), X(0x4655280e), X(0x4694d8b2),
395 X(0x46d47d82), X(0x4714162f), X(0x4753a26d), X(0x479321ef),
396 X(0x47d29466), X(0x4811f987), X(0x48515104), X(0x48909a91),
397 X(0x48cfd5e1), X(0x490f02a7), X(0x494e2098), X(0x498d2f66),
398 X(0x49cc2ec7), X(0x4a0b1e6f), X(0x4a49fe11), X(0x4a88cd62),
399 X(0x4ac78c18), X(0x4b0639e6), X(0x4b44d683), X(0x4b8361a2),
400 X(0x4bc1dafa), X(0x4c004241), X(0x4c3e972c), X(0x4c7cd970),
401 X(0x4cbb08c5), X(0x4cf924e1), X(0x4d372d7a), X(0x4d752247),
402 X(0x4db30300), X(0x4df0cf5a), X(0x4e2e870f), X(0x4e6c29d6),
403 X(0x4ea9b766), X(0x4ee72f78), X(0x4f2491c4), X(0x4f61de02),
404 X(0x4f9f13ec), X(0x4fdc333b), X(0x50193ba8), X(0x50562ced),
405 X(0x509306c3), X(0x50cfc8e5), X(0x510c730d), X(0x514904f6),
406 X(0x51857e5a), X(0x51c1def5), X(0x51fe2682), X(0x523a54bc),
407 X(0x52766961), X(0x52b2642c), X(0x52ee44d9), X(0x532a0b26),
408 X(0x5365b6d0), X(0x53a14793), X(0x53dcbd2f), X(0x54181760),
409 X(0x545355e5), X(0x548e787d), X(0x54c97ee6), X(0x550468e1),
410 X(0x553f362c), X(0x5579e687), X(0x55b479b3), X(0x55eeef70),
411 X(0x5629477f), X(0x566381a1), X(0x569d9d97), X(0x56d79b24),
412 X(0x57117a0a), X(0x574b3a0a), X(0x5784dae9), X(0x57be5c69),
413 X(0x57f7be4d), X(0x5831005a), X(0x586a2254), X(0x58a32400),
414 X(0x58dc0522), X(0x5914c57f), X(0x594d64de), X(0x5985e305),
415 X(0x59be3fba), X(0x59f67ac3), X(0x5a2e93e9), X(0x5a668af2),
416 X(0x5a9e5fa6), X(0x5ad611ce), X(0x5b0da133), X(0x5b450d9d),
417 X(0x5b7c56d7), X(0x5bb37ca9), X(0x5bea7ede), X(0x5c215d41),
418 X(0x5c58179d), X(0x5c8eadbe), X(0x5cc51f6f), X(0x5cfb6c7c),
419 X(0x5d3194b2), X(0x5d6797de), X(0x5d9d75cf), X(0x5dd32e51),
420 X(0x5e08c132), X(0x5e3e2e43), X(0x5e737551), X(0x5ea8962d),
421 X(0x5edd90a7), X(0x5f12648e), X(0x5f4711b4), X(0x5f7b97ea),
422 X(0x5faff702), X(0x5fe42ece), X(0x60183f20), X(0x604c27cc),
423 X(0x607fe8a6), X(0x60b38180), X(0x60e6f22f), X(0x611a3a89),
424 X(0x614d5a62), X(0x61805190), X(0x61b31fe9), X(0x61e5c545),
425 X(0x62184179), X(0x624a945d), X(0x627cbdca), X(0x62aebd98),
426 X(0x62e0939f), X(0x63123fba), X(0x6343c1c1), X(0x6375198f),
427 X(0x63a646ff), X(0x63d749ec), X(0x64082232), X(0x6438cfad),
428 X(0x64695238), X(0x6499a9b3), X(0x64c9d5f9), X(0x64f9d6ea),
429 X(0x6529ac63), X(0x65595643), X(0x6588d46a), X(0x65b826b8),
430 X(0x65e74d0e), X(0x6616474b), X(0x66451552), X(0x6673b704),
431 X(0x66a22c44), X(0x66d074f4), X(0x66fe90f8), X(0x672c8033),
432 X(0x675a428a), X(0x6787d7e1), X(0x67b5401f), X(0x67e27b27),
433 X(0x680f88e1), X(0x683c6934), X(0x68691c05), X(0x6895a13e),
434 X(0x68c1f8c7), X(0x68ee2287), X(0x691a1e68), X(0x6945ec54),
435 X(0x69718c35), X(0x699cfdf5), X(0x69c8417f), X(0x69f356c0),
436 X(0x6a1e3da3), X(0x6a48f615), X(0x6a738002), X(0x6a9ddb5a),
437 X(0x6ac80808), X(0x6af205fd), X(0x6b1bd526), X(0x6b457575),
438 X(0x6b6ee6d8), X(0x6b982940), X(0x6bc13c9f), X(0x6bea20e5),
439 X(0x6c12d605), X(0x6c3b5bf1), X(0x6c63b29c), X(0x6c8bd9fb),
440 X(0x6cb3d200), X(0x6cdb9aa0), X(0x6d0333d0), X(0x6d2a9d86),
441 X(0x6d51d7b7), X(0x6d78e25a), X(0x6d9fbd67), X(0x6dc668d3),
442 X(0x6dece498), X(0x6e1330ad), X(0x6e394d0c), X(0x6e5f39ae),
443 X(0x6e84f68d), X(0x6eaa83a2), X(0x6ecfe0ea), X(0x6ef50e5e),
444 X(0x6f1a0bfc), X(0x6f3ed9bf), X(0x6f6377a4), X(0x6f87e5a8),
445 X(0x6fac23c9), X(0x6fd03206), X(0x6ff4105c), X(0x7017becc),
446 X(0x703b3d54), X(0x705e8bf5), X(0x7081aaaf), X(0x70a49984),
447 X(0x70c75874), X(0x70e9e783), X(0x710c46b2), X(0x712e7605),
448 X(0x7150757f), X(0x71724523), X(0x7193e4f6), X(0x71b554fd),
449 X(0x71d6953e), X(0x71f7a5bd), X(0x72188681), X(0x72393792),
450 X(0x7259b8f5), X(0x727a0ab2), X(0x729a2cd2), X(0x72ba1f5d),
451 X(0x72d9e25c), X(0x72f975d8), X(0x7318d9db), X(0x73380e6f),
452 X(0x735713a0), X(0x7375e978), X(0x73949003), X(0x73b3074c),
453 X(0x73d14f61), X(0x73ef684f), X(0x740d5222), X(0x742b0ce9),
454 X(0x744898b1), X(0x7465f589), X(0x74832381), X(0x74a022a8),
455 X(0x74bcf30e), X(0x74d994c3), X(0x74f607d8), X(0x75124c5f),
456 X(0x752e6268), X(0x754a4a05), X(0x7566034b), X(0x75818e4a),
457 X(0x759ceb16), X(0x75b819c4), X(0x75d31a66), X(0x75eded12),
458 X(0x760891dc), X(0x762308da), X(0x763d5221), X(0x76576dc8),
459 X(0x76715be4), X(0x768b1c8c), X(0x76a4afd9), X(0x76be15e0),
460 X(0x76d74ebb), X(0x76f05a82), X(0x7709394d), X(0x7721eb35),
461 X(0x773a7054), X(0x7752c8c4), X(0x776af49f), X(0x7782f400),
462 X(0x779ac701), X(0x77b26dbd), X(0x77c9e851), X(0x77e136d8),
463 X(0x77f8596f), X(0x780f5032), X(0x78261b3f), X(0x783cbab2),
464 X(0x78532eaa), X(0x78697745), X(0x787f94a0), X(0x789586db),
465 X(0x78ab4e15), X(0x78c0ea6d), X(0x78d65c03), X(0x78eba2f7),
466 X(0x7900bf68), X(0x7915b179), X(0x792a7949), X(0x793f16fb),
467 X(0x79538aaf), X(0x7967d488), X(0x797bf4a8), X(0x798feb31),
468 X(0x79a3b846), X(0x79b75c0a), X(0x79cad6a1), X(0x79de282e),
469 X(0x79f150d5), X(0x7a0450bb), X(0x7a172803), X(0x7a29d6d3),
470 X(0x7a3c5d50), X(0x7a4ebb9f), X(0x7a60f1e6), X(0x7a73004a),
471 X(0x7a84e6f2), X(0x7a96a604), X(0x7aa83da7), X(0x7ab9ae01),
472 X(0x7acaf73a), X(0x7adc1979), X(0x7aed14e6), X(0x7afde9a8),
473 X(0x7b0e97e8), X(0x7b1f1fcd), X(0x7b2f8182), X(0x7b3fbd2d),
474 X(0x7b4fd2f9), X(0x7b5fc30f), X(0x7b6f8d98), X(0x7b7f32bd),
475 X(0x7b8eb2a9), X(0x7b9e0d85), X(0x7bad437d), X(0x7bbc54b9),
476 X(0x7bcb4166), X(0x7bda09ae), X(0x7be8adbc), X(0x7bf72dbc),
477 X(0x7c0589d8), X(0x7c13c23d), X(0x7c21d716), X(0x7c2fc88f),
478 X(0x7c3d96d5), X(0x7c4b4214), X(0x7c58ca78), X(0x7c66302d),
479 X(0x7c737362), X(0x7c809443), X(0x7c8d92fc), X(0x7c9a6fbc),
480 X(0x7ca72aaf), X(0x7cb3c404), X(0x7cc03be8), X(0x7ccc9288),
481 X(0x7cd8c814), X(0x7ce4dcb9), X(0x7cf0d0a5), X(0x7cfca406),
482 X(0x7d08570c), X(0x7d13e9e5), X(0x7d1f5cbf), X(0x7d2aafca),
483 X(0x7d35e335), X(0x7d40f72e), X(0x7d4bebe4), X(0x7d56c188),
484 X(0x7d617848), X(0x7d6c1054), X(0x7d7689db), X(0x7d80e50e),
485 X(0x7d8b221b), X(0x7d954133), X(0x7d9f4286), X(0x7da92643),
486 X(0x7db2ec9b), X(0x7dbc95bd), X(0x7dc621da), X(0x7dcf9123),
487 X(0x7dd8e3c6), X(0x7de219f6), X(0x7deb33e2), X(0x7df431ba),
488 X(0x7dfd13af), X(0x7e05d9f2), X(0x7e0e84b4), X(0x7e171424),
489 X(0x7e1f8874), X(0x7e27e1d4), X(0x7e302074), X(0x7e384487),
490 X(0x7e404e3c), X(0x7e483dc4), X(0x7e501350), X(0x7e57cf11),
491 X(0x7e5f7138), X(0x7e66f9f4), X(0x7e6e6979), X(0x7e75bff5),
492 X(0x7e7cfd9a), X(0x7e842298), X(0x7e8b2f22), X(0x7e922366),
493 X(0x7e98ff97), X(0x7e9fc3e4), X(0x7ea6707f), X(0x7ead0598),
494 X(0x7eb38360), X(0x7eb9ea07), X(0x7ec039bf), X(0x7ec672b7),
495 X(0x7ecc9521), X(0x7ed2a12c), X(0x7ed8970a), X(0x7ede76ea),
496 X(0x7ee440fd), X(0x7ee9f573), X(0x7eef947d), X(0x7ef51e4b),
497 X(0x7efa930d), X(0x7efff2f2), X(0x7f053e2b), X(0x7f0a74e8),
498 X(0x7f0f9758), X(0x7f14a5ac), X(0x7f19a013), X(0x7f1e86bc),
499 X(0x7f2359d8), X(0x7f281995), X(0x7f2cc623), X(0x7f315fb1),
500 X(0x7f35e66e), X(0x7f3a5a8a), X(0x7f3ebc33), X(0x7f430b98),
501 X(0x7f4748e7), X(0x7f4b7450), X(0x7f4f8e01), X(0x7f539629),
502 X(0x7f578cf5), X(0x7f5b7293), X(0x7f5f4732), X(0x7f630b00),
503 X(0x7f66be2b), X(0x7f6a60df), X(0x7f6df34b), X(0x7f71759b),
504 X(0x7f74e7fe), X(0x7f784aa0), X(0x7f7b9daf), X(0x7f7ee156),
505 X(0x7f8215c3), X(0x7f853b22), X(0x7f88519f), X(0x7f8b5967),
506 X(0x7f8e52a6), X(0x7f913d87), X(0x7f941a36), X(0x7f96e8df),
507 X(0x7f99a9ad), X(0x7f9c5ccb), X(0x7f9f0265), X(0x7fa19aa5),
508 X(0x7fa425b5), X(0x7fa6a3c1), X(0x7fa914f3), X(0x7fab7974),
509 X(0x7fadd16f), X(0x7fb01d0d), X(0x7fb25c78), X(0x7fb48fd9),
510 X(0x7fb6b75a), X(0x7fb8d323), X(0x7fbae35d), X(0x7fbce831),
511 X(0x7fbee1c7), X(0x7fc0d047), X(0x7fc2b3d9), X(0x7fc48ca5),
512 X(0x7fc65ad3), X(0x7fc81e88), X(0x7fc9d7ee), X(0x7fcb872a),
513 X(0x7fcd2c63), X(0x7fcec7bf), X(0x7fd05966), X(0x7fd1e17c),
514 X(0x7fd36027), X(0x7fd4d58d), X(0x7fd641d3), X(0x7fd7a51e),
515 X(0x7fd8ff94), X(0x7fda5157), X(0x7fdb9a8e), X(0x7fdcdb5b),
516 X(0x7fde13e2), X(0x7fdf4448), X(0x7fe06caf), X(0x7fe18d3b),
517 X(0x7fe2a60e), X(0x7fe3b74b), X(0x7fe4c114), X(0x7fe5c38b),
518 X(0x7fe6bed2), X(0x7fe7b30a), X(0x7fe8a055), X(0x7fe986d4),
519 X(0x7fea66a7), X(0x7feb3ff0), X(0x7fec12cd), X(0x7fecdf5f),
520 X(0x7feda5c5), X(0x7fee6620), X(0x7fef208d), X(0x7fefd52c),
521 X(0x7ff0841c), X(0x7ff12d7a), X(0x7ff1d164), X(0x7ff26ff9),
522 X(0x7ff30955), X(0x7ff39d96), X(0x7ff42cd9), X(0x7ff4b739),
523 X(0x7ff53cd4), X(0x7ff5bdc5), X(0x7ff63a28), X(0x7ff6b217),
524 X(0x7ff725af), X(0x7ff7950a), X(0x7ff80043), X(0x7ff86773),
525 X(0x7ff8cab4), X(0x7ff92a21), X(0x7ff985d1), X(0x7ff9dddf),
526 X(0x7ffa3262), X(0x7ffa8374), X(0x7ffad12c), X(0x7ffb1ba1),
527 X(0x7ffb62ec), X(0x7ffba723), X(0x7ffbe85c), X(0x7ffc26b0),
528 X(0x7ffc6233), X(0x7ffc9afb), X(0x7ffcd11e), X(0x7ffd04b1),
529 X(0x7ffd35c9), X(0x7ffd647b), X(0x7ffd90da), X(0x7ffdbafa),
530 X(0x7ffde2f0), X(0x7ffe08ce), X(0x7ffe2ca7), X(0x7ffe4e8e),
531 X(0x7ffe6e95), X(0x7ffe8cce), X(0x7ffea94a), X(0x7ffec41b),
532 X(0x7ffedd52), X(0x7ffef4ff), X(0x7fff0b33), X(0x7fff1ffd),
533 X(0x7fff336e), X(0x7fff4593), X(0x7fff567d), X(0x7fff663a),
534 X(0x7fff74d8), X(0x7fff8265), X(0x7fff8eee), X(0x7fff9a81),
535 X(0x7fffa52b), X(0x7fffaef8), X(0x7fffb7f5), X(0x7fffc02d),
536 X(0x7fffc7ab), X(0x7fffce7c), X(0x7fffd4a9), X(0x7fffda3e),
537 X(0x7fffdf44), X(0x7fffe3c6), X(0x7fffe7cc), X(0x7fffeb60),
538 X(0x7fffee8a), X(0x7ffff153), X(0x7ffff3c4), X(0x7ffff5e3),
539 X(0x7ffff7b8), X(0x7ffff94b), X(0x7ffffaa1), X(0x7ffffbc1),
540 X(0x7ffffcb2), X(0x7ffffd78), X(0x7ffffe19), X(0x7ffffe9a),
541 X(0x7ffffeff), X(0x7fffff4e), X(0x7fffff89), X(0x7fffffb3),
542 X(0x7fffffd2), X(0x7fffffe6), X(0x7ffffff3), X(0x7ffffffa),
543 X(0x7ffffffe), X(0x7fffffff), X(0x7fffffff), X(0x7fffffff),
544};
545
546static LOOKUP_T vwin4096[2048] = {
547 X(0x000001f0), X(0x00001171), X(0x00003072), X(0x00005ef5),
548 X(0x00009cf8), X(0x0000ea7c), X(0x00014780), X(0x0001b405),
549 X(0x0002300b), X(0x0002bb91), X(0x00035698), X(0x0004011e),
550 X(0x0004bb25), X(0x000584ac), X(0x00065db3), X(0x0007463a),
551 X(0x00083e41), X(0x000945c7), X(0x000a5ccc), X(0x000b8350),
552 X(0x000cb954), X(0x000dfed7), X(0x000f53d8), X(0x0010b857),
553 X(0x00122c55), X(0x0013afd1), X(0x001542ca), X(0x0016e541),
554 X(0x00189735), X(0x001a58a7), X(0x001c2995), X(0x001e09ff),
555 X(0x001ff9e6), X(0x0021f948), X(0x00240826), X(0x00262680),
556 X(0x00285454), X(0x002a91a3), X(0x002cde6c), X(0x002f3aaf),
557 X(0x0031a66b), X(0x003421a0), X(0x0036ac4f), X(0x00394675),
558 X(0x003bf014), X(0x003ea92a), X(0x004171b7), X(0x004449bb),
559 X(0x00473135), X(0x004a2824), X(0x004d2e8a), X(0x00504463),
560 X(0x005369b2), X(0x00569e74), X(0x0059e2aa), X(0x005d3652),
561 X(0x0060996d), X(0x00640bf9), X(0x00678df7), X(0x006b1f66),
562 X(0x006ec045), X(0x00727093), X(0x00763051), X(0x0079ff7d),
563 X(0x007dde16), X(0x0081cc1d), X(0x0085c991), X(0x0089d671),
564 X(0x008df2bc), X(0x00921e71), X(0x00965991), X(0x009aa41a),
565 X(0x009efe0c), X(0x00a36766), X(0x00a7e028), X(0x00ac6850),
566 X(0x00b0ffde), X(0x00b5a6d1), X(0x00ba5d28), X(0x00bf22e4),
567 X(0x00c3f802), X(0x00c8dc83), X(0x00cdd065), X(0x00d2d3a8),
568 X(0x00d7e64a), X(0x00dd084c), X(0x00e239ac), X(0x00e77a69),
569 X(0x00ecca83), X(0x00f229f9), X(0x00f798ca), X(0x00fd16f5),
570 X(0x0102a479), X(0x01084155), X(0x010ded89), X(0x0113a913),
571 X(0x011973f3), X(0x011f4e27), X(0x012537af), X(0x012b308a),
572 X(0x013138b7), X(0x01375035), X(0x013d7702), X(0x0143ad1f),
573 X(0x0149f289), X(0x01504741), X(0x0156ab44), X(0x015d1e92),
574 X(0x0163a12a), X(0x016a330b), X(0x0170d433), X(0x017784a3),
575 X(0x017e4458), X(0x01851351), X(0x018bf18e), X(0x0192df0d),
576 X(0x0199dbcd), X(0x01a0e7cd), X(0x01a8030c), X(0x01af2d89),
577 X(0x01b66743), X(0x01bdb038), X(0x01c50867), X(0x01cc6fd0),
578 X(0x01d3e670), X(0x01db6c47), X(0x01e30153), X(0x01eaa593),
579 X(0x01f25907), X(0x01fa1bac), X(0x0201ed81), X(0x0209ce86),
580 X(0x0211beb8), X(0x0219be17), X(0x0221cca2), X(0x0229ea56),
581 X(0x02321733), X(0x023a5337), X(0x02429e60), X(0x024af8af),
582 X(0x02536220), X(0x025bdab3), X(0x02646267), X(0x026cf93a),
583 X(0x02759f2a), X(0x027e5436), X(0x0287185d), X(0x028feb9d),
584 X(0x0298cdf4), X(0x02a1bf62), X(0x02aabfe5), X(0x02b3cf7b),
585 X(0x02bcee23), X(0x02c61bdb), X(0x02cf58a2), X(0x02d8a475),
586 X(0x02e1ff55), X(0x02eb693e), X(0x02f4e230), X(0x02fe6a29),
587 X(0x03080127), X(0x0311a729), X(0x031b5c2d), X(0x03252031),
588 X(0x032ef334), X(0x0338d534), X(0x0342c630), X(0x034cc625),
589 X(0x0356d512), X(0x0360f2f6), X(0x036b1fce), X(0x03755b99),
590 X(0x037fa655), X(0x038a0001), X(0x0394689a), X(0x039ee020),
591 X(0x03a9668f), X(0x03b3fbe6), X(0x03bea024), X(0x03c95347),
592 X(0x03d4154d), X(0x03dee633), X(0x03e9c5f9), X(0x03f4b49b),
593 X(0x03ffb219), X(0x040abe71), X(0x0415d9a0), X(0x042103a5),
594 X(0x042c3c7d), X(0x04378428), X(0x0442daa2), X(0x044e3fea),
595 X(0x0459b3fd), X(0x046536db), X(0x0470c880), X(0x047c68eb),
596 X(0x0488181a), X(0x0493d60b), X(0x049fa2bc), X(0x04ab7e2a),
597 X(0x04b76854), X(0x04c36137), X(0x04cf68d1), X(0x04db7f21),
598 X(0x04e7a424), X(0x04f3d7d8), X(0x05001a3b), X(0x050c6b4a),
599 X(0x0518cb04), X(0x05253966), X(0x0531b66e), X(0x053e421a),
600 X(0x054adc68), X(0x05578555), X(0x05643cdf), X(0x05710304),
601 X(0x057dd7c1), X(0x058abb15), X(0x0597acfd), X(0x05a4ad76),
602 X(0x05b1bc7f), X(0x05beda14), X(0x05cc0635), X(0x05d940dd),
603 X(0x05e68a0b), X(0x05f3e1bd), X(0x060147f0), X(0x060ebca1),
604 X(0x061c3fcf), X(0x0629d176), X(0x06377194), X(0x06452027),
605 X(0x0652dd2c), X(0x0660a8a2), X(0x066e8284), X(0x067c6ad1),
606 X(0x068a6186), X(0x069866a1), X(0x06a67a1e), X(0x06b49bfc),
607 X(0x06c2cc38), X(0x06d10acf), X(0x06df57bf), X(0x06edb304),
608 X(0x06fc1c9d), X(0x070a9487), X(0x07191abe), X(0x0727af40),
609 X(0x0736520b), X(0x0745031c), X(0x0753c270), X(0x07629004),
610 X(0x07716bd6), X(0x078055e2), X(0x078f4e26), X(0x079e549f),
611 X(0x07ad694b), X(0x07bc8c26), X(0x07cbbd2e), X(0x07dafc5f),
612 X(0x07ea49b7), X(0x07f9a533), X(0x08090ed1), X(0x0818868c),
613 X(0x08280c62), X(0x0837a051), X(0x08474255), X(0x0856f26b),
614 X(0x0866b091), X(0x08767cc3), X(0x088656fe), X(0x08963f3f),
615 X(0x08a63584), X(0x08b639c8), X(0x08c64c0a), X(0x08d66c45),
616 X(0x08e69a77), X(0x08f6d69d), X(0x090720b3), X(0x091778b7),
617 X(0x0927dea5), X(0x0938527a), X(0x0948d433), X(0x095963cc),
618 X(0x096a0143), X(0x097aac94), X(0x098b65bb), X(0x099c2cb6),
619 X(0x09ad0182), X(0x09bde41a), X(0x09ced47d), X(0x09dfd2a5),
620 X(0x09f0de90), X(0x0a01f83b), X(0x0a131fa3), X(0x0a2454c3),
621 X(0x0a359798), X(0x0a46e820), X(0x0a584656), X(0x0a69b237),
622 X(0x0a7b2bc0), X(0x0a8cb2ec), X(0x0a9e47ba), X(0x0aafea24),
623 X(0x0ac19a29), X(0x0ad357c3), X(0x0ae522ef), X(0x0af6fbab),
624 X(0x0b08e1f1), X(0x0b1ad5c0), X(0x0b2cd712), X(0x0b3ee5e5),
625 X(0x0b510234), X(0x0b632bfd), X(0x0b75633b), X(0x0b87a7eb),
626 X(0x0b99fa08), X(0x0bac5990), X(0x0bbec67e), X(0x0bd140cf),
627 X(0x0be3c87e), X(0x0bf65d89), X(0x0c08ffeb), X(0x0c1bafa1),
628 X(0x0c2e6ca6), X(0x0c4136f6), X(0x0c540e8f), X(0x0c66f36c),
629 X(0x0c79e588), X(0x0c8ce4e1), X(0x0c9ff172), X(0x0cb30b37),
630 X(0x0cc6322c), X(0x0cd9664d), X(0x0ceca797), X(0x0cfff605),
631 X(0x0d135193), X(0x0d26ba3d), X(0x0d3a2fff), X(0x0d4db2d5),
632 X(0x0d6142ba), X(0x0d74dfac), X(0x0d8889a5), X(0x0d9c40a1),
633 X(0x0db0049d), X(0x0dc3d593), X(0x0dd7b380), X(0x0deb9e60),
634 X(0x0dff962f), X(0x0e139ae7), X(0x0e27ac85), X(0x0e3bcb05),
635 X(0x0e4ff662), X(0x0e642e98), X(0x0e7873a2), X(0x0e8cc57d),
636 X(0x0ea12423), X(0x0eb58f91), X(0x0eca07c2), X(0x0ede8cb1),
637 X(0x0ef31e5b), X(0x0f07bcba), X(0x0f1c67cb), X(0x0f311f88),
638 X(0x0f45e3ee), X(0x0f5ab4f7), X(0x0f6f92a0), X(0x0f847ce3),
639 X(0x0f9973bc), X(0x0fae7726), X(0x0fc3871e), X(0x0fd8a39d),
640 X(0x0fedcca1), X(0x10030223), X(0x1018441f), X(0x102d9291),
641 X(0x1042ed74), X(0x105854c3), X(0x106dc879), X(0x10834892),
642 X(0x1098d508), X(0x10ae6dd8), X(0x10c412fc), X(0x10d9c46f),
643 X(0x10ef822d), X(0x11054c30), X(0x111b2274), X(0x113104f5),
644 X(0x1146f3ac), X(0x115cee95), X(0x1172f5ab), X(0x118908e9),
645 X(0x119f284a), X(0x11b553ca), X(0x11cb8b62), X(0x11e1cf0f),
646 X(0x11f81ecb), X(0x120e7a90), X(0x1224e25a), X(0x123b5624),
647 X(0x1251d5e9), X(0x126861a3), X(0x127ef94e), X(0x12959ce3),
648 X(0x12ac4c5f), X(0x12c307bb), X(0x12d9cef2), X(0x12f0a200),
649 X(0x130780df), X(0x131e6b8a), X(0x133561fa), X(0x134c642c),
650 X(0x1363721a), X(0x137a8bbe), X(0x1391b113), X(0x13a8e214),
651 X(0x13c01eba), X(0x13d76702), X(0x13eebae5), X(0x14061a5e),
652 X(0x141d8567), X(0x1434fbfb), X(0x144c7e14), X(0x14640bae),
653 X(0x147ba4c1), X(0x14934949), X(0x14aaf941), X(0x14c2b4a2),
654 X(0x14da7b67), X(0x14f24d8a), X(0x150a2b06), X(0x152213d5),
655 X(0x153a07f1), X(0x15520755), X(0x156a11fb), X(0x158227dd),
656 X(0x159a48f5), X(0x15b2753d), X(0x15caacb1), X(0x15e2ef49),
657 X(0x15fb3d01), X(0x161395d2), X(0x162bf9b6), X(0x164468a8),
658 X(0x165ce2a1), X(0x1675679c), X(0x168df793), X(0x16a69280),
659 X(0x16bf385c), X(0x16d7e922), X(0x16f0a4cc), X(0x17096b54),
660 X(0x17223cb4), X(0x173b18e5), X(0x1753ffe2), X(0x176cf1a5),
661 X(0x1785ee27), X(0x179ef562), X(0x17b80750), X(0x17d123eb),
662 X(0x17ea4b2d), X(0x18037d10), X(0x181cb98d), X(0x1836009e),
663 X(0x184f523c), X(0x1868ae63), X(0x1882150a), X(0x189b862c),
664 X(0x18b501c4), X(0x18ce87c9), X(0x18e81836), X(0x1901b305),
665 X(0x191b582f), X(0x193507ad), X(0x194ec17a), X(0x1968858f),
666 X(0x198253e5), X(0x199c2c75), X(0x19b60f3a), X(0x19cffc2d),
667 X(0x19e9f347), X(0x1a03f482), X(0x1a1dffd7), X(0x1a381540),
668 X(0x1a5234b5), X(0x1a6c5e31), X(0x1a8691ac), X(0x1aa0cf21),
669 X(0x1abb1687), X(0x1ad567da), X(0x1aefc311), X(0x1b0a2826),
670 X(0x1b249712), X(0x1b3f0fd0), X(0x1b599257), X(0x1b741ea1),
671 X(0x1b8eb4a7), X(0x1ba95462), X(0x1bc3fdcd), X(0x1bdeb0de),
672 X(0x1bf96d91), X(0x1c1433dd), X(0x1c2f03bc), X(0x1c49dd27),
673 X(0x1c64c017), X(0x1c7fac85), X(0x1c9aa269), X(0x1cb5a1be),
674 X(0x1cd0aa7c), X(0x1cebbc9c), X(0x1d06d816), X(0x1d21fce4),
675 X(0x1d3d2aff), X(0x1d586260), X(0x1d73a2fe), X(0x1d8eecd4),
676 X(0x1daa3fda), X(0x1dc59c09), X(0x1de1015a), X(0x1dfc6fc5),
677 X(0x1e17e743), X(0x1e3367cd), X(0x1e4ef15b), X(0x1e6a83e7),
678 X(0x1e861f6a), X(0x1ea1c3da), X(0x1ebd7133), X(0x1ed9276b),
679 X(0x1ef4e67c), X(0x1f10ae5e), X(0x1f2c7f0a), X(0x1f485879),
680 X(0x1f643aa2), X(0x1f80257f), X(0x1f9c1908), X(0x1fb81536),
681 X(0x1fd41a00), X(0x1ff02761), X(0x200c3d4f), X(0x20285bc3),
682 X(0x204482b7), X(0x2060b221), X(0x207ce9fb), X(0x20992a3e),
683 X(0x20b572e0), X(0x20d1c3dc), X(0x20ee1d28), X(0x210a7ebe),
684 X(0x2126e895), X(0x21435aa6), X(0x215fd4ea), X(0x217c5757),
685 X(0x2198e1e8), X(0x21b57493), X(0x21d20f51), X(0x21eeb21b),
686 X(0x220b5ce7), X(0x22280fb0), X(0x2244ca6c), X(0x22618d13),
687 X(0x227e579f), X(0x229b2a06), X(0x22b80442), X(0x22d4e649),
688 X(0x22f1d015), X(0x230ec19d), X(0x232bbad9), X(0x2348bbc1),
689 X(0x2365c44c), X(0x2382d474), X(0x239fec30), X(0x23bd0b78),
690 X(0x23da3244), X(0x23f7608b), X(0x24149646), X(0x2431d36c),
691 X(0x244f17f5), X(0x246c63da), X(0x2489b711), X(0x24a71193),
692 X(0x24c47358), X(0x24e1dc57), X(0x24ff4c88), X(0x251cc3e2),
693 X(0x253a425e), X(0x2557c7f4), X(0x2575549a), X(0x2592e848),
694 X(0x25b082f7), X(0x25ce249e), X(0x25ebcd34), X(0x26097cb2),
695 X(0x2627330e), X(0x2644f040), X(0x2662b441), X(0x26807f07),
696 X(0x269e5089), X(0x26bc28c1), X(0x26da07a4), X(0x26f7ed2b),
697 X(0x2715d94d), X(0x2733cc02), X(0x2751c540), X(0x276fc500),
698 X(0x278dcb39), X(0x27abd7e2), X(0x27c9eaf3), X(0x27e80463),
699 X(0x28062429), X(0x28244a3e), X(0x28427697), X(0x2860a92d),
700 X(0x287ee1f7), X(0x289d20eb), X(0x28bb6603), X(0x28d9b134),
701 X(0x28f80275), X(0x291659c0), X(0x2934b709), X(0x29531a49),
702 X(0x29718378), X(0x298ff28b), X(0x29ae677b), X(0x29cce23e),
703 X(0x29eb62cb), X(0x2a09e91b), X(0x2a287523), X(0x2a4706dc),
704 X(0x2a659e3c), X(0x2a843b39), X(0x2aa2ddcd), X(0x2ac185ec),
705 X(0x2ae0338f), X(0x2afee6ad), X(0x2b1d9f3c), X(0x2b3c5d33),
706 X(0x2b5b208b), X(0x2b79e939), X(0x2b98b734), X(0x2bb78a74),
707 X(0x2bd662ef), X(0x2bf5409d), X(0x2c142374), X(0x2c330b6b),
708 X(0x2c51f87a), X(0x2c70ea97), X(0x2c8fe1b9), X(0x2caeddd6),
709 X(0x2ccddee7), X(0x2cece4e1), X(0x2d0befbb), X(0x2d2aff6d),
710 X(0x2d4a13ec), X(0x2d692d31), X(0x2d884b32), X(0x2da76de4),
711 X(0x2dc69540), X(0x2de5c13d), X(0x2e04f1d0), X(0x2e2426f0),
712 X(0x2e436095), X(0x2e629eb4), X(0x2e81e146), X(0x2ea1283f),
713 X(0x2ec07398), X(0x2edfc347), X(0x2eff1742), X(0x2f1e6f80),
714 X(0x2f3dcbf8), X(0x2f5d2ca0), X(0x2f7c916f), X(0x2f9bfa5c),
715 X(0x2fbb675d), X(0x2fdad869), X(0x2ffa4d76), X(0x3019c67b),
716 X(0x3039436f), X(0x3058c448), X(0x307848fc), X(0x3097d183),
717 X(0x30b75dd3), X(0x30d6ede2), X(0x30f681a6), X(0x31161917),
718 X(0x3135b42b), X(0x315552d8), X(0x3174f514), X(0x31949ad7),
719 X(0x31b44417), X(0x31d3f0ca), X(0x31f3a0e6), X(0x32135462),
720 X(0x32330b35), X(0x3252c555), X(0x327282b7), X(0x32924354),
721 X(0x32b20720), X(0x32d1ce13), X(0x32f19823), X(0x33116546),
722 X(0x33313573), X(0x3351089f), X(0x3370dec2), X(0x3390b7d1),
723 X(0x33b093c3), X(0x33d0728f), X(0x33f05429), X(0x3410388a),
724 X(0x34301fa7), X(0x34500977), X(0x346ff5ef), X(0x348fe506),
725 X(0x34afd6b3), X(0x34cfcaeb), X(0x34efc1a5), X(0x350fbad7),
726 X(0x352fb678), X(0x354fb47d), X(0x356fb4dd), X(0x358fb78e),
727 X(0x35afbc86), X(0x35cfc3bc), X(0x35efcd25), X(0x360fd8b8),
728 X(0x362fe66c), X(0x364ff636), X(0x3670080c), X(0x36901be5),
729 X(0x36b031b7), X(0x36d04978), X(0x36f0631e), X(0x37107ea0),
730 X(0x37309bf3), X(0x3750bb0e), X(0x3770dbe6), X(0x3790fe73),
731 X(0x37b122aa), X(0x37d14881), X(0x37f16fee), X(0x381198e8),
732 X(0x3831c365), X(0x3851ef5a), X(0x38721cbe), X(0x38924b87),
733 X(0x38b27bac), X(0x38d2ad21), X(0x38f2dfde), X(0x391313d8),
734 X(0x39334906), X(0x39537f5d), X(0x3973b6d4), X(0x3993ef60),
735 X(0x39b428f9), X(0x39d46393), X(0x39f49f25), X(0x3a14dba6),
736 X(0x3a35190a), X(0x3a555748), X(0x3a759657), X(0x3a95d62c),
737 X(0x3ab616be), X(0x3ad65801), X(0x3af699ed), X(0x3b16dc78),
738 X(0x3b371f97), X(0x3b576341), X(0x3b77a76c), X(0x3b97ec0d),
739 X(0x3bb8311b), X(0x3bd8768b), X(0x3bf8bc55), X(0x3c19026d),
740 X(0x3c3948ca), X(0x3c598f62), X(0x3c79d62b), X(0x3c9a1d1b),
741 X(0x3cba6428), X(0x3cdaab48), X(0x3cfaf271), X(0x3d1b3999),
742 X(0x3d3b80b6), X(0x3d5bc7be), X(0x3d7c0ea8), X(0x3d9c5569),
743 X(0x3dbc9bf7), X(0x3ddce248), X(0x3dfd2852), X(0x3e1d6e0c),
744 X(0x3e3db36c), X(0x3e5df866), X(0x3e7e3cf2), X(0x3e9e8106),
745 X(0x3ebec497), X(0x3edf079b), X(0x3eff4a09), X(0x3f1f8bd7),
746 X(0x3f3fccfa), X(0x3f600d69), X(0x3f804d1a), X(0x3fa08c02),
747 X(0x3fc0ca19), X(0x3fe10753), X(0x400143a7), X(0x40217f0a),
748 X(0x4041b974), X(0x4061f2da), X(0x40822b32), X(0x40a26272),
749 X(0x40c29891), X(0x40e2cd83), X(0x41030140), X(0x412333bd),
750 X(0x414364f1), X(0x416394d2), X(0x4183c355), X(0x41a3f070),
751 X(0x41c41c1b), X(0x41e4464a), X(0x42046ef4), X(0x42249610),
752 X(0x4244bb92), X(0x4264df72), X(0x428501a5), X(0x42a52222),
753 X(0x42c540de), X(0x42e55dd0), X(0x430578ed), X(0x4325922d),
754 X(0x4345a985), X(0x4365beeb), X(0x4385d255), X(0x43a5e3ba),
755 X(0x43c5f30f), X(0x43e6004b), X(0x44060b65), X(0x44261451),
756 X(0x44461b07), X(0x44661f7c), X(0x448621a7), X(0x44a6217d),
757 X(0x44c61ef6), X(0x44e61a07), X(0x450612a6), X(0x452608ca),
758 X(0x4545fc69), X(0x4565ed79), X(0x4585dbf1), X(0x45a5c7c6),
759 X(0x45c5b0ef), X(0x45e59761), X(0x46057b15), X(0x46255bfe),
760 X(0x46453a15), X(0x4665154f), X(0x4684eda2), X(0x46a4c305),
761 X(0x46c4956e), X(0x46e464d3), X(0x4704312b), X(0x4723fa6c),
762 X(0x4743c08d), X(0x47638382), X(0x47834344), X(0x47a2ffc9),
763 X(0x47c2b906), X(0x47e26ef2), X(0x48022183), X(0x4821d0b1),
764 X(0x48417c71), X(0x486124b9), X(0x4880c981), X(0x48a06abe),
765 X(0x48c00867), X(0x48dfa272), X(0x48ff38d6), X(0x491ecb8a),
766 X(0x493e5a84), X(0x495de5b9), X(0x497d6d22), X(0x499cf0b4),
767 X(0x49bc7066), X(0x49dbec2e), X(0x49fb6402), X(0x4a1ad7db),
768 X(0x4a3a47ad), X(0x4a59b370), X(0x4a791b1a), X(0x4a987ea1),
769 X(0x4ab7ddfd), X(0x4ad73924), X(0x4af6900c), X(0x4b15e2ad),
770 X(0x4b3530fc), X(0x4b547af1), X(0x4b73c082), X(0x4b9301a6),
771 X(0x4bb23e53), X(0x4bd17681), X(0x4bf0aa25), X(0x4c0fd937),
772 X(0x4c2f03ae), X(0x4c4e297f), X(0x4c6d4aa3), X(0x4c8c670f),
773 X(0x4cab7eba), X(0x4cca919c), X(0x4ce99fab), X(0x4d08a8de),
774 X(0x4d27ad2c), X(0x4d46ac8b), X(0x4d65a6f3), X(0x4d849c5a),
775 X(0x4da38cb7), X(0x4dc27802), X(0x4de15e31), X(0x4e003f3a),
776 X(0x4e1f1b16), X(0x4e3df1ba), X(0x4e5cc31e), X(0x4e7b8f3a),
777 X(0x4e9a5603), X(0x4eb91771), X(0x4ed7d37b), X(0x4ef68a18),
778 X(0x4f153b3f), X(0x4f33e6e7), X(0x4f528d08), X(0x4f712d97),
779 X(0x4f8fc88e), X(0x4fae5de1), X(0x4fcced8a), X(0x4feb777f),
780 X(0x5009fbb6), X(0x50287a28), X(0x5046f2cc), X(0x50656598),
781 X(0x5083d284), X(0x50a23988), X(0x50c09a9a), X(0x50def5b1),
782 X(0x50fd4ac7), X(0x511b99d0), X(0x5139e2c5), X(0x5158259e),
783 X(0x51766251), X(0x519498d6), X(0x51b2c925), X(0x51d0f334),
784 X(0x51ef16fb), X(0x520d3473), X(0x522b4b91), X(0x52495c4e),
785 X(0x526766a2), X(0x52856a83), X(0x52a367e9), X(0x52c15ecd),
786 X(0x52df4f24), X(0x52fd38e8), X(0x531b1c10), X(0x5338f892),
787 X(0x5356ce68), X(0x53749d89), X(0x539265eb), X(0x53b02788),
788 X(0x53cde257), X(0x53eb964f), X(0x54094369), X(0x5426e99c),
789 X(0x544488df), X(0x5462212c), X(0x547fb279), X(0x549d3cbe),
790 X(0x54babff4), X(0x54d83c12), X(0x54f5b110), X(0x55131ee7),
791 X(0x5530858d), X(0x554de4fc), X(0x556b3d2a), X(0x55888e11),
792 X(0x55a5d7a8), X(0x55c319e7), X(0x55e054c7), X(0x55fd883f),
793 X(0x561ab447), X(0x5637d8d8), X(0x5654f5ea), X(0x56720b75),
794 X(0x568f1971), X(0x56ac1fd7), X(0x56c91e9e), X(0x56e615c0),
795 X(0x57030534), X(0x571fecf2), X(0x573cccf3), X(0x5759a530),
796 X(0x577675a0), X(0x57933e3c), X(0x57affefd), X(0x57ccb7db),
797 X(0x57e968ce), X(0x580611cf), X(0x5822b2d6), X(0x583f4bdd),
798 X(0x585bdcdb), X(0x587865c9), X(0x5894e69f), X(0x58b15f57),
799 X(0x58cdcfe9), X(0x58ea384e), X(0x5906987d), X(0x5922f071),
800 X(0x593f4022), X(0x595b8788), X(0x5977c69c), X(0x5993fd57),
801 X(0x59b02bb2), X(0x59cc51a6), X(0x59e86f2c), X(0x5a04843c),
802 X(0x5a2090d0), X(0x5a3c94e0), X(0x5a589065), X(0x5a748359),
803 X(0x5a906db4), X(0x5aac4f70), X(0x5ac82884), X(0x5ae3f8ec),
804 X(0x5affc09f), X(0x5b1b7f97), X(0x5b3735cd), X(0x5b52e33a),
805 X(0x5b6e87d8), X(0x5b8a239f), X(0x5ba5b689), X(0x5bc1408f),
806 X(0x5bdcc1aa), X(0x5bf839d5), X(0x5c13a907), X(0x5c2f0f3b),
807 X(0x5c4a6c6a), X(0x5c65c08d), X(0x5c810b9e), X(0x5c9c4d97),
808 X(0x5cb78670), X(0x5cd2b623), X(0x5ceddcaa), X(0x5d08f9ff),
809 X(0x5d240e1b), X(0x5d3f18f8), X(0x5d5a1a8f), X(0x5d7512da),
810 X(0x5d9001d3), X(0x5daae773), X(0x5dc5c3b5), X(0x5de09692),
811 X(0x5dfb6004), X(0x5e162004), X(0x5e30d68d), X(0x5e4b8399),
812 X(0x5e662721), X(0x5e80c11f), X(0x5e9b518e), X(0x5eb5d867),
813 X(0x5ed055a4), X(0x5eeac940), X(0x5f053334), X(0x5f1f937b),
814 X(0x5f39ea0f), X(0x5f5436ea), X(0x5f6e7a06), X(0x5f88b35d),
815 X(0x5fa2e2e9), X(0x5fbd08a6), X(0x5fd7248d), X(0x5ff13698),
816 X(0x600b3ec2), X(0x60253d05), X(0x603f315b), X(0x60591bc0),
817 X(0x6072fc2d), X(0x608cd29e), X(0x60a69f0b), X(0x60c06171),
818 X(0x60da19ca), X(0x60f3c80f), X(0x610d6c3d), X(0x6127064d),
819 X(0x6140963a), X(0x615a1bff), X(0x61739797), X(0x618d08fc),
820 X(0x61a67029), X(0x61bfcd1a), X(0x61d91fc8), X(0x61f2682f),
821 X(0x620ba64a), X(0x6224da13), X(0x623e0386), X(0x6257229d),
822 X(0x62703754), X(0x628941a6), X(0x62a2418e), X(0x62bb3706),
823 X(0x62d4220a), X(0x62ed0296), X(0x6305d8a3), X(0x631ea42f),
824 X(0x63376533), X(0x63501bab), X(0x6368c793), X(0x638168e5),
825 X(0x6399ff9e), X(0x63b28bb8), X(0x63cb0d2f), X(0x63e383ff),
826 X(0x63fbf022), X(0x64145195), X(0x642ca853), X(0x6444f457),
827 X(0x645d359e), X(0x64756c22), X(0x648d97e0), X(0x64a5b8d3),
828 X(0x64bdcef6), X(0x64d5da47), X(0x64eddabf), X(0x6505d05c),
829 X(0x651dbb19), X(0x65359af2), X(0x654d6fe3), X(0x656539e7),
830 X(0x657cf8fb), X(0x6594ad1b), X(0x65ac5643), X(0x65c3f46e),
831 X(0x65db8799), X(0x65f30fc0), X(0x660a8ce0), X(0x6621fef3),
832 X(0x663965f7), X(0x6650c1e7), X(0x666812c1), X(0x667f5880),
833 X(0x66969320), X(0x66adc29e), X(0x66c4e6f7), X(0x66dc0026),
834 X(0x66f30e28), X(0x670a10fa), X(0x67210898), X(0x6737f4ff),
835 X(0x674ed62b), X(0x6765ac19), X(0x677c76c5), X(0x6793362c),
836 X(0x67a9ea4b), X(0x67c0931f), X(0x67d730a3), X(0x67edc2d6),
837 X(0x680449b3), X(0x681ac538), X(0x68313562), X(0x68479a2d),
838 X(0x685df396), X(0x6874419b), X(0x688a8438), X(0x68a0bb6a),
839 X(0x68b6e72e), X(0x68cd0782), X(0x68e31c63), X(0x68f925cd),
840 X(0x690f23be), X(0x69251633), X(0x693afd29), X(0x6950d89e),
841 X(0x6966a88f), X(0x697c6cf8), X(0x699225d9), X(0x69a7d32d),
842 X(0x69bd74f3), X(0x69d30b27), X(0x69e895c8), X(0x69fe14d2),
843 X(0x6a138844), X(0x6a28f01b), X(0x6a3e4c54), X(0x6a539ced),
844 X(0x6a68e1e4), X(0x6a7e1b37), X(0x6a9348e3), X(0x6aa86ae6),
845 X(0x6abd813d), X(0x6ad28be7), X(0x6ae78ae2), X(0x6afc7e2b),
846 X(0x6b1165c0), X(0x6b26419f), X(0x6b3b11c7), X(0x6b4fd634),
847 X(0x6b648ee6), X(0x6b793bda), X(0x6b8ddd0e), X(0x6ba27281),
848 X(0x6bb6fc31), X(0x6bcb7a1b), X(0x6bdfec3e), X(0x6bf45299),
849 X(0x6c08ad29), X(0x6c1cfbed), X(0x6c313ee4), X(0x6c45760a),
850 X(0x6c59a160), X(0x6c6dc0e4), X(0x6c81d493), X(0x6c95dc6d),
851 X(0x6ca9d86f), X(0x6cbdc899), X(0x6cd1acea), X(0x6ce5855f),
852 X(0x6cf951f7), X(0x6d0d12b1), X(0x6d20c78c), X(0x6d347087),
853 X(0x6d480da0), X(0x6d5b9ed6), X(0x6d6f2427), X(0x6d829d94),
854 X(0x6d960b1a), X(0x6da96cb9), X(0x6dbcc270), X(0x6dd00c3c),
855 X(0x6de34a1f), X(0x6df67c16), X(0x6e09a221), X(0x6e1cbc3f),
856 X(0x6e2fca6e), X(0x6e42ccaf), X(0x6e55c300), X(0x6e68ad60),
857 X(0x6e7b8bd0), X(0x6e8e5e4d), X(0x6ea124d8), X(0x6eb3df70),
858 X(0x6ec68e13), X(0x6ed930c3), X(0x6eebc77d), X(0x6efe5242),
859 X(0x6f10d111), X(0x6f2343e9), X(0x6f35aacb), X(0x6f4805b5),
860 X(0x6f5a54a8), X(0x6f6c97a2), X(0x6f7ecea4), X(0x6f90f9ae),
861 X(0x6fa318be), X(0x6fb52bd6), X(0x6fc732f4), X(0x6fd92e19),
862 X(0x6feb1d44), X(0x6ffd0076), X(0x700ed7ad), X(0x7020a2eb),
863 X(0x7032622f), X(0x7044157a), X(0x7055bcca), X(0x70675821),
864 X(0x7078e77e), X(0x708a6ae2), X(0x709be24c), X(0x70ad4dbd),
865 X(0x70bead36), X(0x70d000b5), X(0x70e1483d), X(0x70f283cc),
866 X(0x7103b363), X(0x7114d704), X(0x7125eead), X(0x7136fa60),
867 X(0x7147fa1c), X(0x7158ede4), X(0x7169d5b6), X(0x717ab193),
868 X(0x718b817d), X(0x719c4573), X(0x71acfd76), X(0x71bda988),
869 X(0x71ce49a8), X(0x71deddd7), X(0x71ef6617), X(0x71ffe267),
870 X(0x721052ca), X(0x7220b73e), X(0x72310fc6), X(0x72415c62),
871 X(0x72519d14), X(0x7261d1db), X(0x7271faba), X(0x728217b1),
872 X(0x729228c0), X(0x72a22dea), X(0x72b22730), X(0x72c21491),
873 X(0x72d1f611), X(0x72e1cbaf), X(0x72f1956c), X(0x7301534c),
874 X(0x7311054d), X(0x7320ab72), X(0x733045bc), X(0x733fd42d),
875 X(0x734f56c5), X(0x735ecd86), X(0x736e3872), X(0x737d9789),
876 X(0x738ceacf), X(0x739c3243), X(0x73ab6de7), X(0x73ba9dbe),
877 X(0x73c9c1c8), X(0x73d8da08), X(0x73e7e67f), X(0x73f6e72e),
878 X(0x7405dc17), X(0x7414c53c), X(0x7423a29f), X(0x74327442),
879 X(0x74413a26), X(0x744ff44d), X(0x745ea2b9), X(0x746d456c),
880 X(0x747bdc68), X(0x748a67ae), X(0x7498e741), X(0x74a75b23),
881 X(0x74b5c356), X(0x74c41fdb), X(0x74d270b6), X(0x74e0b5e7),
882 X(0x74eeef71), X(0x74fd1d57), X(0x750b3f9a), X(0x7519563c),
883 X(0x75276140), X(0x753560a8), X(0x75435477), X(0x75513cae),
884 X(0x755f1951), X(0x756cea60), X(0x757aafdf), X(0x758869d1),
885 X(0x75961837), X(0x75a3bb14), X(0x75b1526a), X(0x75bede3c),
886 X(0x75cc5e8d), X(0x75d9d35f), X(0x75e73cb5), X(0x75f49a91),
887 X(0x7601ecf6), X(0x760f33e6), X(0x761c6f65), X(0x76299f74),
888 X(0x7636c417), X(0x7643dd51), X(0x7650eb24), X(0x765ded93),
889 X(0x766ae4a0), X(0x7677d050), X(0x7684b0a4), X(0x7691859f),
890 X(0x769e4f45), X(0x76ab0d98), X(0x76b7c09c), X(0x76c46852),
891 X(0x76d104bf), X(0x76dd95e6), X(0x76ea1bc9), X(0x76f6966b),
892 X(0x770305d0), X(0x770f69fb), X(0x771bc2ef), X(0x772810af),
893 X(0x7734533e), X(0x77408aa0), X(0x774cb6d7), X(0x7758d7e8),
894 X(0x7764edd5), X(0x7770f8a2), X(0x777cf852), X(0x7788ece8),
895 X(0x7794d668), X(0x77a0b4d5), X(0x77ac8833), X(0x77b85085),
896 X(0x77c40dce), X(0x77cfc013), X(0x77db6756), X(0x77e7039b),
897 X(0x77f294e6), X(0x77fe1b3b), X(0x7809969c), X(0x7815070e),
898 X(0x78206c93), X(0x782bc731), X(0x783716ea), X(0x78425bc3),
899 X(0x784d95be), X(0x7858c4e1), X(0x7863e92d), X(0x786f02a8),
900 X(0x787a1156), X(0x78851539), X(0x78900e56), X(0x789afcb1),
901 X(0x78a5e04d), X(0x78b0b92f), X(0x78bb875b), X(0x78c64ad4),
902 X(0x78d1039e), X(0x78dbb1be), X(0x78e65537), X(0x78f0ee0e),
903 X(0x78fb7c46), X(0x7905ffe4), X(0x791078ec), X(0x791ae762),
904 X(0x79254b4a), X(0x792fa4a7), X(0x7939f380), X(0x794437d7),
905 X(0x794e71b0), X(0x7958a111), X(0x7962c5fd), X(0x796ce078),
906 X(0x7976f087), X(0x7980f62f), X(0x798af173), X(0x7994e258),
907 X(0x799ec8e2), X(0x79a8a515), X(0x79b276f7), X(0x79bc3e8b),
908 X(0x79c5fbd6), X(0x79cfaedc), X(0x79d957a2), X(0x79e2f62c),
909 X(0x79ec8a7f), X(0x79f6149f), X(0x79ff9492), X(0x7a090a5a),
910 X(0x7a1275fe), X(0x7a1bd781), X(0x7a252ee9), X(0x7a2e7c39),
911 X(0x7a37bf77), X(0x7a40f8a7), X(0x7a4a27ce), X(0x7a534cf0),
912 X(0x7a5c6813), X(0x7a65793b), X(0x7a6e806d), X(0x7a777dad),
913 X(0x7a807100), X(0x7a895a6b), X(0x7a9239f4), X(0x7a9b0f9e),
914 X(0x7aa3db6f), X(0x7aac9d6b), X(0x7ab55597), X(0x7abe03f9),
915 X(0x7ac6a895), X(0x7acf4370), X(0x7ad7d48f), X(0x7ae05bf6),
916 X(0x7ae8d9ac), X(0x7af14db5), X(0x7af9b815), X(0x7b0218d2),
917 X(0x7b0a6ff2), X(0x7b12bd78), X(0x7b1b016a), X(0x7b233bce),
918 X(0x7b2b6ca7), X(0x7b3393fc), X(0x7b3bb1d1), X(0x7b43c62c),
919 X(0x7b4bd111), X(0x7b53d286), X(0x7b5bca90), X(0x7b63b935),
920 X(0x7b6b9e78), X(0x7b737a61), X(0x7b7b4cf3), X(0x7b831634),
921 X(0x7b8ad629), X(0x7b928cd8), X(0x7b9a3a45), X(0x7ba1de77),
922 X(0x7ba97972), X(0x7bb10b3c), X(0x7bb893d9), X(0x7bc01350),
923 X(0x7bc789a6), X(0x7bcef6e0), X(0x7bd65b03), X(0x7bddb616),
924 X(0x7be5081c), X(0x7bec511c), X(0x7bf3911b), X(0x7bfac81f),
925 X(0x7c01f62c), X(0x7c091b49), X(0x7c10377b), X(0x7c174ac7),
926 X(0x7c1e5532), X(0x7c2556c4), X(0x7c2c4f80), X(0x7c333f6c),
927 X(0x7c3a268e), X(0x7c4104ec), X(0x7c47da8a), X(0x7c4ea76f),
928 X(0x7c556ba1), X(0x7c5c2724), X(0x7c62d9fe), X(0x7c698435),
929 X(0x7c7025cf), X(0x7c76bed0), X(0x7c7d4f40), X(0x7c83d723),
930 X(0x7c8a567f), X(0x7c90cd5a), X(0x7c973bb9), X(0x7c9da1a2),
931 X(0x7ca3ff1b), X(0x7caa542a), X(0x7cb0a0d3), X(0x7cb6e51e),
932 X(0x7cbd210f), X(0x7cc354ac), X(0x7cc97ffc), X(0x7ccfa304),
933 X(0x7cd5bdc9), X(0x7cdbd051), X(0x7ce1daa3), X(0x7ce7dcc3),
934 X(0x7cedd6b8), X(0x7cf3c888), X(0x7cf9b238), X(0x7cff93cf),
935 X(0x7d056d51), X(0x7d0b3ec5), X(0x7d110830), X(0x7d16c99a),
936 X(0x7d1c8306), X(0x7d22347c), X(0x7d27de00), X(0x7d2d7f9a),
937 X(0x7d33194f), X(0x7d38ab24), X(0x7d3e351f), X(0x7d43b748),
938 X(0x7d4931a2), X(0x7d4ea435), X(0x7d540f06), X(0x7d59721b),
939 X(0x7d5ecd7b), X(0x7d64212a), X(0x7d696d2f), X(0x7d6eb190),
940 X(0x7d73ee53), X(0x7d79237e), X(0x7d7e5117), X(0x7d837723),
941 X(0x7d8895a9), X(0x7d8dacae), X(0x7d92bc3a), X(0x7d97c451),
942 X(0x7d9cc4f9), X(0x7da1be39), X(0x7da6b017), X(0x7dab9a99),
943 X(0x7db07dc4), X(0x7db5599e), X(0x7dba2e2f), X(0x7dbefb7b),
944 X(0x7dc3c189), X(0x7dc8805e), X(0x7dcd3802), X(0x7dd1e879),
945 X(0x7dd691ca), X(0x7ddb33fb), X(0x7ddfcf12), X(0x7de46315),
946 X(0x7de8f00a), X(0x7ded75f8), X(0x7df1f4e3), X(0x7df66cd3),
947 X(0x7dfaddcd), X(0x7dff47d7), X(0x7e03aaf8), X(0x7e080735),
948 X(0x7e0c5c95), X(0x7e10ab1e), X(0x7e14f2d5), X(0x7e1933c1),
949 X(0x7e1d6de8), X(0x7e21a150), X(0x7e25cdff), X(0x7e29f3fc),
950 X(0x7e2e134c), X(0x7e322bf5), X(0x7e363dfd), X(0x7e3a496b),
951 X(0x7e3e4e45), X(0x7e424c90), X(0x7e464454), X(0x7e4a3595),
952 X(0x7e4e205a), X(0x7e5204aa), X(0x7e55e289), X(0x7e59b9ff),
953 X(0x7e5d8b12), X(0x7e6155c7), X(0x7e651a24), X(0x7e68d831),
954 X(0x7e6c8ff2), X(0x7e70416e), X(0x7e73ecac), X(0x7e7791b0),
955 X(0x7e7b3082), X(0x7e7ec927), X(0x7e825ba6), X(0x7e85e804),
956 X(0x7e896e48), X(0x7e8cee77), X(0x7e906899), X(0x7e93dcb2),
957 X(0x7e974aca), X(0x7e9ab2e5), X(0x7e9e150b), X(0x7ea17141),
958 X(0x7ea4c78e), X(0x7ea817f7), X(0x7eab6283), X(0x7eaea737),
959 X(0x7eb1e61a), X(0x7eb51f33), X(0x7eb85285), X(0x7ebb8019),
960 X(0x7ebea7f4), X(0x7ec1ca1d), X(0x7ec4e698), X(0x7ec7fd6d),
961 X(0x7ecb0ea1), X(0x7ece1a3a), X(0x7ed1203f), X(0x7ed420b6),
962 X(0x7ed71ba4), X(0x7eda110f), X(0x7edd00ff), X(0x7edfeb78),
963 X(0x7ee2d081), X(0x7ee5b01f), X(0x7ee88a5a), X(0x7eeb5f36),
964 X(0x7eee2eba), X(0x7ef0f8ed), X(0x7ef3bdd3), X(0x7ef67d73),
965 X(0x7ef937d3), X(0x7efbecf9), X(0x7efe9ceb), X(0x7f0147ae),
966 X(0x7f03ed4a), X(0x7f068dc4), X(0x7f092922), X(0x7f0bbf69),
967 X(0x7f0e50a1), X(0x7f10dcce), X(0x7f1363f7), X(0x7f15e622),
968 X(0x7f186355), X(0x7f1adb95), X(0x7f1d4ee9), X(0x7f1fbd57),
969 X(0x7f2226e4), X(0x7f248b96), X(0x7f26eb74), X(0x7f294683),
970 X(0x7f2b9cc9), X(0x7f2dee4d), X(0x7f303b13), X(0x7f328322),
971 X(0x7f34c680), X(0x7f370533), X(0x7f393f40), X(0x7f3b74ad),
972 X(0x7f3da581), X(0x7f3fd1c1), X(0x7f41f972), X(0x7f441c9c),
973 X(0x7f463b43), X(0x7f48556d), X(0x7f4a6b21), X(0x7f4c7c64),
974 X(0x7f4e893c), X(0x7f5091ae), X(0x7f5295c1), X(0x7f54957a),
975 X(0x7f5690e0), X(0x7f5887f7), X(0x7f5a7ac5), X(0x7f5c6951),
976 X(0x7f5e53a0), X(0x7f6039b8), X(0x7f621b9e), X(0x7f63f958),
977 X(0x7f65d2ed), X(0x7f67a861), X(0x7f6979ba), X(0x7f6b46ff),
978 X(0x7f6d1034), X(0x7f6ed560), X(0x7f709687), X(0x7f7253b1),
979 X(0x7f740ce1), X(0x7f75c21f), X(0x7f777370), X(0x7f7920d8),
980 X(0x7f7aca5f), X(0x7f7c7008), X(0x7f7e11db), X(0x7f7fafdd),
981 X(0x7f814a13), X(0x7f82e082), X(0x7f847331), X(0x7f860224),
982 X(0x7f878d62), X(0x7f8914f0), X(0x7f8a98d4), X(0x7f8c1912),
983 X(0x7f8d95b0), X(0x7f8f0eb5), X(0x7f908425), X(0x7f91f605),
984 X(0x7f93645c), X(0x7f94cf2f), X(0x7f963683), X(0x7f979a5d),
985 X(0x7f98fac4), X(0x7f9a57bb), X(0x7f9bb14a), X(0x7f9d0775),
986 X(0x7f9e5a41), X(0x7f9fa9b4), X(0x7fa0f5d3), X(0x7fa23ea4),
987 X(0x7fa3842b), X(0x7fa4c66f), X(0x7fa60575), X(0x7fa74141),
988 X(0x7fa879d9), X(0x7fa9af42), X(0x7faae182), X(0x7fac109e),
989 X(0x7fad3c9a), X(0x7fae657d), X(0x7faf8b4c), X(0x7fb0ae0b),
990 X(0x7fb1cdc0), X(0x7fb2ea70), X(0x7fb40420), X(0x7fb51ad5),
991 X(0x7fb62e95), X(0x7fb73f64), X(0x7fb84d48), X(0x7fb95846),
992 X(0x7fba6062), X(0x7fbb65a2), X(0x7fbc680c), X(0x7fbd67a3),
993 X(0x7fbe646d), X(0x7fbf5e70), X(0x7fc055af), X(0x7fc14a31),
994 X(0x7fc23bf9), X(0x7fc32b0d), X(0x7fc41773), X(0x7fc5012e),
995 X(0x7fc5e844), X(0x7fc6ccba), X(0x7fc7ae94), X(0x7fc88dd8),
996 X(0x7fc96a8a), X(0x7fca44af), X(0x7fcb1c4c), X(0x7fcbf167),
997 X(0x7fccc403), X(0x7fcd9425), X(0x7fce61d3), X(0x7fcf2d11),
998 X(0x7fcff5e3), X(0x7fd0bc4f), X(0x7fd1805a), X(0x7fd24207),
999 X(0x7fd3015c), X(0x7fd3be5d), X(0x7fd47910), X(0x7fd53178),
1000 X(0x7fd5e79b), X(0x7fd69b7c), X(0x7fd74d21), X(0x7fd7fc8e),
1001 X(0x7fd8a9c8), X(0x7fd954d4), X(0x7fd9fdb5), X(0x7fdaa471),
1002 X(0x7fdb490b), X(0x7fdbeb89), X(0x7fdc8bef), X(0x7fdd2a42),
1003 X(0x7fddc685), X(0x7fde60be), X(0x7fdef8f0), X(0x7fdf8f20),
1004 X(0x7fe02353), X(0x7fe0b58d), X(0x7fe145d3), X(0x7fe1d428),
1005 X(0x7fe26091), X(0x7fe2eb12), X(0x7fe373b0), X(0x7fe3fa6f),
1006 X(0x7fe47f53), X(0x7fe50260), X(0x7fe5839b), X(0x7fe60308),
1007 X(0x7fe680ab), X(0x7fe6fc88), X(0x7fe776a4), X(0x7fe7ef02),
1008 X(0x7fe865a7), X(0x7fe8da97), X(0x7fe94dd6), X(0x7fe9bf68),
1009 X(0x7fea2f51), X(0x7fea9d95), X(0x7feb0a39), X(0x7feb7540),
1010 X(0x7febdeae), X(0x7fec4687), X(0x7fecaccf), X(0x7fed118b),
1011 X(0x7fed74be), X(0x7fedd66c), X(0x7fee3698), X(0x7fee9548),
1012 X(0x7feef27e), X(0x7fef4e3f), X(0x7fefa88e), X(0x7ff0016f),
1013 X(0x7ff058e7), X(0x7ff0aef8), X(0x7ff103a6), X(0x7ff156f6),
1014 X(0x7ff1a8eb), X(0x7ff1f988), X(0x7ff248d2), X(0x7ff296cc),
1015 X(0x7ff2e37a), X(0x7ff32edf), X(0x7ff378ff), X(0x7ff3c1de),
1016 X(0x7ff4097e), X(0x7ff44fe5), X(0x7ff49515), X(0x7ff4d911),
1017 X(0x7ff51bde), X(0x7ff55d7f), X(0x7ff59df7), X(0x7ff5dd4a),
1018 X(0x7ff61b7b), X(0x7ff6588d), X(0x7ff69485), X(0x7ff6cf65),
1019 X(0x7ff70930), X(0x7ff741eb), X(0x7ff77998), X(0x7ff7b03b),
1020 X(0x7ff7e5d7), X(0x7ff81a6f), X(0x7ff84e06), X(0x7ff880a1),
1021 X(0x7ff8b241), X(0x7ff8e2ea), X(0x7ff912a0), X(0x7ff94165),
1022 X(0x7ff96f3d), X(0x7ff99c2b), X(0x7ff9c831), X(0x7ff9f354),
1023 X(0x7ffa1d95), X(0x7ffa46f9), X(0x7ffa6f81), X(0x7ffa9731),
1024 X(0x7ffabe0d), X(0x7ffae416), X(0x7ffb0951), X(0x7ffb2dbf),
1025 X(0x7ffb5164), X(0x7ffb7442), X(0x7ffb965d), X(0x7ffbb7b8),
1026 X(0x7ffbd854), X(0x7ffbf836), X(0x7ffc175f), X(0x7ffc35d3),
1027 X(0x7ffc5394), X(0x7ffc70a5), X(0x7ffc8d09), X(0x7ffca8c2),
1028 X(0x7ffcc3d4), X(0x7ffcde3f), X(0x7ffcf809), X(0x7ffd1132),
1029 X(0x7ffd29be), X(0x7ffd41ae), X(0x7ffd5907), X(0x7ffd6fc9),
1030 X(0x7ffd85f9), X(0x7ffd9b97), X(0x7ffdb0a7), X(0x7ffdc52b),
1031 X(0x7ffdd926), X(0x7ffdec99), X(0x7ffdff88), X(0x7ffe11f4),
1032 X(0x7ffe23e0), X(0x7ffe354f), X(0x7ffe4642), X(0x7ffe56bc),
1033 X(0x7ffe66bf), X(0x7ffe764e), X(0x7ffe856a), X(0x7ffe9416),
1034 X(0x7ffea254), X(0x7ffeb026), X(0x7ffebd8e), X(0x7ffeca8f),
1035 X(0x7ffed72a), X(0x7ffee362), X(0x7ffeef38), X(0x7ffefaaf),
1036 X(0x7fff05c9), X(0x7fff1087), X(0x7fff1aec), X(0x7fff24f9),
1037 X(0x7fff2eb1), X(0x7fff3816), X(0x7fff4128), X(0x7fff49eb),
1038 X(0x7fff5260), X(0x7fff5a88), X(0x7fff6266), X(0x7fff69fc),
1039 X(0x7fff714b), X(0x7fff7854), X(0x7fff7f1a), X(0x7fff859f),
1040 X(0x7fff8be3), X(0x7fff91ea), X(0x7fff97b3), X(0x7fff9d41),
1041 X(0x7fffa296), X(0x7fffa7b3), X(0x7fffac99), X(0x7fffb14b),
1042 X(0x7fffb5c9), X(0x7fffba15), X(0x7fffbe31), X(0x7fffc21d),
1043 X(0x7fffc5dc), X(0x7fffc96f), X(0x7fffccd8), X(0x7fffd016),
1044 X(0x7fffd32d), X(0x7fffd61c), X(0x7fffd8e7), X(0x7fffdb8d),
1045 X(0x7fffde0f), X(0x7fffe071), X(0x7fffe2b1), X(0x7fffe4d2),
1046 X(0x7fffe6d5), X(0x7fffe8bb), X(0x7fffea85), X(0x7fffec34),
1047 X(0x7fffedc9), X(0x7fffef45), X(0x7ffff0aa), X(0x7ffff1f7),
1048 X(0x7ffff330), X(0x7ffff453), X(0x7ffff562), X(0x7ffff65f),
1049 X(0x7ffff749), X(0x7ffff823), X(0x7ffff8ec), X(0x7ffff9a6),
1050 X(0x7ffffa51), X(0x7ffffaee), X(0x7ffffb7e), X(0x7ffffc02),
1051 X(0x7ffffc7a), X(0x7ffffce7), X(0x7ffffd4a), X(0x7ffffda3),
1052 X(0x7ffffdf4), X(0x7ffffe3c), X(0x7ffffe7c), X(0x7ffffeb6),
1053 X(0x7ffffee8), X(0x7fffff15), X(0x7fffff3c), X(0x7fffff5e),
1054 X(0x7fffff7b), X(0x7fffff95), X(0x7fffffaa), X(0x7fffffbc),
1055 X(0x7fffffcb), X(0x7fffffd7), X(0x7fffffe2), X(0x7fffffea),
1056 X(0x7ffffff0), X(0x7ffffff5), X(0x7ffffff9), X(0x7ffffffb),
1057 X(0x7ffffffd), X(0x7ffffffe), X(0x7fffffff), X(0x7fffffff),
1058 X(0x7fffffff), X(0x7fffffff), X(0x7fffffff), X(0x7fffffff),
1059};
1060
1061static LOOKUP_T vwin8192[4096] = {
1062 X(0x0000007c), X(0x0000045c), X(0x00000c1d), X(0x000017bd),
1063 X(0x0000273e), X(0x00003a9f), X(0x000051e0), X(0x00006d02),
1064 X(0x00008c03), X(0x0000aee5), X(0x0000d5a7), X(0x00010049),
1065 X(0x00012ecb), X(0x0001612d), X(0x00019770), X(0x0001d193),
1066 X(0x00020f96), X(0x00025178), X(0x0002973c), X(0x0002e0df),
1067 X(0x00032e62), X(0x00037fc5), X(0x0003d509), X(0x00042e2c),
1068 X(0x00048b30), X(0x0004ec13), X(0x000550d7), X(0x0005b97a),
1069 X(0x000625fe), X(0x00069661), X(0x00070aa4), X(0x000782c8),
1070 X(0x0007fecb), X(0x00087eae), X(0x00090271), X(0x00098a14),
1071 X(0x000a1597), X(0x000aa4f9), X(0x000b383b), X(0x000bcf5d),
1072 X(0x000c6a5f), X(0x000d0941), X(0x000dac02), X(0x000e52a3),
1073 X(0x000efd23), X(0x000fab84), X(0x00105dc3), X(0x001113e3),
1074 X(0x0011cde2), X(0x00128bc0), X(0x00134d7e), X(0x0014131b),
1075 X(0x0014dc98), X(0x0015a9f4), X(0x00167b30), X(0x0017504a),
1076 X(0x00182945), X(0x0019061e), X(0x0019e6d7), X(0x001acb6f),
1077 X(0x001bb3e6), X(0x001ca03c), X(0x001d9071), X(0x001e8485),
1078 X(0x001f7c79), X(0x0020784b), X(0x002177fc), X(0x00227b8c),
1079 X(0x002382fb), X(0x00248e49), X(0x00259d76), X(0x0026b081),
1080 X(0x0027c76b), X(0x0028e234), X(0x002a00dc), X(0x002b2361),
1081 X(0x002c49c6), X(0x002d7409), X(0x002ea22a), X(0x002fd42a),
1082 X(0x00310a08), X(0x003243c5), X(0x00338160), X(0x0034c2d9),
1083 X(0x00360830), X(0x00375165), X(0x00389e78), X(0x0039ef6a),
1084 X(0x003b4439), X(0x003c9ce6), X(0x003df971), X(0x003f59da),
1085 X(0x0040be20), X(0x00422645), X(0x00439247), X(0x00450226),
1086 X(0x004675e3), X(0x0047ed7e), X(0x004968f5), X(0x004ae84b),
1087 X(0x004c6b7d), X(0x004df28d), X(0x004f7d7a), X(0x00510c44),
1088 X(0x00529eeb), X(0x00543570), X(0x0055cfd1), X(0x00576e0f),
1089 X(0x00591029), X(0x005ab621), X(0x005c5ff5), X(0x005e0da6),
1090 X(0x005fbf33), X(0x0061749d), X(0x00632de4), X(0x0064eb06),
1091 X(0x0066ac05), X(0x006870e0), X(0x006a3998), X(0x006c062b),
1092 X(0x006dd69b), X(0x006faae6), X(0x0071830d), X(0x00735f10),
1093 X(0x00753eef), X(0x007722a9), X(0x00790a3f), X(0x007af5b1),
1094 X(0x007ce4fe), X(0x007ed826), X(0x0080cf29), X(0x0082ca08),
1095 X(0x0084c8c2), X(0x0086cb57), X(0x0088d1c7), X(0x008adc11),
1096 X(0x008cea37), X(0x008efc37), X(0x00911212), X(0x00932bc7),
1097 X(0x00954957), X(0x00976ac2), X(0x00999006), X(0x009bb925),
1098 X(0x009de61e), X(0x00a016f1), X(0x00a24b9e), X(0x00a48425),
1099 X(0x00a6c086), X(0x00a900c0), X(0x00ab44d4), X(0x00ad8cc2),
1100 X(0x00afd889), X(0x00b22829), X(0x00b47ba2), X(0x00b6d2f5),
1101 X(0x00b92e21), X(0x00bb8d26), X(0x00bdf004), X(0x00c056ba),
1102 X(0x00c2c149), X(0x00c52fb1), X(0x00c7a1f1), X(0x00ca180a),
1103 X(0x00cc91fb), X(0x00cf0fc5), X(0x00d19166), X(0x00d416df),
1104 X(0x00d6a031), X(0x00d92d5a), X(0x00dbbe5b), X(0x00de5333),
1105 X(0x00e0ebe3), X(0x00e3886b), X(0x00e628c9), X(0x00e8ccff),
1106 X(0x00eb750c), X(0x00ee20f0), X(0x00f0d0ab), X(0x00f3843d),
1107 X(0x00f63ba5), X(0x00f8f6e4), X(0x00fbb5fa), X(0x00fe78e5),
1108 X(0x01013fa7), X(0x01040a3f), X(0x0106d8ae), X(0x0109aaf2),
1109 X(0x010c810c), X(0x010f5afb), X(0x011238c0), X(0x01151a5b),
1110 X(0x0117ffcb), X(0x011ae910), X(0x011dd62a), X(0x0120c719),
1111 X(0x0123bbdd), X(0x0126b476), X(0x0129b0e4), X(0x012cb126),
1112 X(0x012fb53c), X(0x0132bd27), X(0x0135c8e6), X(0x0138d879),
1113 X(0x013bebdf), X(0x013f031a), X(0x01421e28), X(0x01453d0a),
1114 X(0x01485fbf), X(0x014b8648), X(0x014eb0a4), X(0x0151ded2),
1115 X(0x015510d4), X(0x015846a8), X(0x015b8050), X(0x015ebdc9),
1116 X(0x0161ff15), X(0x01654434), X(0x01688d24), X(0x016bd9e6),
1117 X(0x016f2a7b), X(0x01727ee1), X(0x0175d718), X(0x01793321),
1118 X(0x017c92fc), X(0x017ff6a7), X(0x01835e24), X(0x0186c972),
1119 X(0x018a3890), X(0x018dab7f), X(0x0191223f), X(0x01949ccf),
1120 X(0x01981b2f), X(0x019b9d5f), X(0x019f235f), X(0x01a2ad2f),
1121 X(0x01a63acf), X(0x01a9cc3e), X(0x01ad617c), X(0x01b0fa8a),
1122 X(0x01b49767), X(0x01b83813), X(0x01bbdc8d), X(0x01bf84d6),
1123 X(0x01c330ee), X(0x01c6e0d4), X(0x01ca9488), X(0x01ce4c0b),
1124 X(0x01d2075b), X(0x01d5c679), X(0x01d98964), X(0x01dd501d),
1125 X(0x01e11aa3), X(0x01e4e8f6), X(0x01e8bb17), X(0x01ec9104),
1126 X(0x01f06abd), X(0x01f44844), X(0x01f82996), X(0x01fc0eb5),
1127 X(0x01fff7a0), X(0x0203e456), X(0x0207d4d9), X(0x020bc926),
1128 X(0x020fc140), X(0x0213bd24), X(0x0217bcd4), X(0x021bc04e),
1129 X(0x021fc793), X(0x0223d2a3), X(0x0227e17d), X(0x022bf421),
1130 X(0x02300a90), X(0x023424c8), X(0x023842ca), X(0x023c6495),
1131 X(0x02408a2a), X(0x0244b389), X(0x0248e0b0), X(0x024d11a0),
1132 X(0x02514659), X(0x02557eda), X(0x0259bb24), X(0x025dfb35),
1133 X(0x02623f0f), X(0x026686b1), X(0x026ad21a), X(0x026f214b),
1134 X(0x02737443), X(0x0277cb02), X(0x027c2588), X(0x028083d5),
1135 X(0x0284e5e9), X(0x02894bc2), X(0x028db562), X(0x029222c8),
1136 X(0x029693f4), X(0x029b08e6), X(0x029f819d), X(0x02a3fe19),
1137 X(0x02a87e5b), X(0x02ad0261), X(0x02b18a2c), X(0x02b615bb),
1138 X(0x02baa50f), X(0x02bf3827), X(0x02c3cf03), X(0x02c869a3),
1139 X(0x02cd0807), X(0x02d1aa2d), X(0x02d65017), X(0x02daf9c4),
1140 X(0x02dfa734), X(0x02e45866), X(0x02e90d5b), X(0x02edc612),
1141 X(0x02f2828b), X(0x02f742c6), X(0x02fc06c3), X(0x0300ce80),
1142 X(0x030599ff), X(0x030a6940), X(0x030f3c40), X(0x03141302),
1143 X(0x0318ed84), X(0x031dcbc6), X(0x0322adc8), X(0x0327938a),
1144 X(0x032c7d0c), X(0x03316a4c), X(0x03365b4d), X(0x033b500c),
1145 X(0x03404889), X(0x034544c6), X(0x034a44c0), X(0x034f4879),
1146 X(0x03544ff0), X(0x03595b24), X(0x035e6a16), X(0x03637cc5),
1147 X(0x03689331), X(0x036dad5a), X(0x0372cb40), X(0x0377ece2),
1148 X(0x037d1240), X(0x03823b5a), X(0x03876830), X(0x038c98c1),
1149 X(0x0391cd0e), X(0x03970516), X(0x039c40d8), X(0x03a18055),
1150 X(0x03a6c38d), X(0x03ac0a7f), X(0x03b1552b), X(0x03b6a390),
1151 X(0x03bbf5af), X(0x03c14b88), X(0x03c6a519), X(0x03cc0263),
1152 X(0x03d16366), X(0x03d6c821), X(0x03dc3094), X(0x03e19cc0),
1153 X(0x03e70ca2), X(0x03ec803d), X(0x03f1f78e), X(0x03f77296),
1154 X(0x03fcf155), X(0x040273cb), X(0x0407f9f7), X(0x040d83d9),
1155 X(0x04131170), X(0x0418a2bd), X(0x041e37c0), X(0x0423d077),
1156 X(0x04296ce4), X(0x042f0d04), X(0x0434b0da), X(0x043a5863),
1157 X(0x044003a0), X(0x0445b290), X(0x044b6534), X(0x04511b8b),
1158 X(0x0456d595), X(0x045c9352), X(0x046254c1), X(0x046819e1),
1159 X(0x046de2b4), X(0x0473af39), X(0x04797f6e), X(0x047f5355),
1160 X(0x04852aec), X(0x048b0635), X(0x0490e52d), X(0x0496c7d6),
1161 X(0x049cae2e), X(0x04a29836), X(0x04a885ed), X(0x04ae7753),
1162 X(0x04b46c68), X(0x04ba652b), X(0x04c0619d), X(0x04c661bc),
1163 X(0x04cc658a), X(0x04d26d04), X(0x04d8782c), X(0x04de8701),
1164 X(0x04e49983), X(0x04eaafb0), X(0x04f0c98a), X(0x04f6e710),
1165 X(0x04fd0842), X(0x05032d1e), X(0x050955a6), X(0x050f81d8),
1166 X(0x0515b1b5), X(0x051be53d), X(0x05221c6e), X(0x05285748),
1167 X(0x052e95cd), X(0x0534d7fa), X(0x053b1dd0), X(0x0541674e),
1168 X(0x0547b475), X(0x054e0544), X(0x055459bb), X(0x055ab1d9),
1169 X(0x05610d9e), X(0x05676d0a), X(0x056dd01c), X(0x057436d5),
1170 X(0x057aa134), X(0x05810f38), X(0x058780e2), X(0x058df631),
1171 X(0x05946f25), X(0x059aebbe), X(0x05a16bfa), X(0x05a7efdb),
1172 X(0x05ae775f), X(0x05b50287), X(0x05bb9152), X(0x05c223c0),
1173 X(0x05c8b9d0), X(0x05cf5382), X(0x05d5f0d6), X(0x05dc91cc),
1174 X(0x05e33663), X(0x05e9de9c), X(0x05f08a75), X(0x05f739ee),
1175 X(0x05fded07), X(0x0604a3c0), X(0x060b5e19), X(0x06121c11),
1176 X(0x0618dda8), X(0x061fa2dd), X(0x06266bb1), X(0x062d3822),
1177 X(0x06340831), X(0x063adbde), X(0x0641b328), X(0x06488e0e),
1178 X(0x064f6c91), X(0x06564eaf), X(0x065d346a), X(0x06641dc0),
1179 X(0x066b0ab1), X(0x0671fb3d), X(0x0678ef64), X(0x067fe724),
1180 X(0x0686e27f), X(0x068de173), X(0x0694e400), X(0x069bea27),
1181 X(0x06a2f3e6), X(0x06aa013d), X(0x06b1122c), X(0x06b826b3),
1182 X(0x06bf3ed1), X(0x06c65a86), X(0x06cd79d1), X(0x06d49cb3),
1183 X(0x06dbc32b), X(0x06e2ed38), X(0x06ea1adb), X(0x06f14c13),
1184 X(0x06f880df), X(0x06ffb940), X(0x0706f535), X(0x070e34bd),
1185 X(0x071577d9), X(0x071cbe88), X(0x072408c9), X(0x072b569d),
1186 X(0x0732a802), X(0x0739fcf9), X(0x07415582), X(0x0748b19b),
1187 X(0x07501145), X(0x0757747f), X(0x075edb49), X(0x076645a3),
1188 X(0x076db38c), X(0x07752503), X(0x077c9a09), X(0x0784129e),
1189 X(0x078b8ec0), X(0x07930e70), X(0x079a91ac), X(0x07a21876),
1190 X(0x07a9a2cc), X(0x07b130ad), X(0x07b8c21b), X(0x07c05714),
1191 X(0x07c7ef98), X(0x07cf8ba6), X(0x07d72b3f), X(0x07dece62),
1192 X(0x07e6750e), X(0x07ee1f43), X(0x07f5cd01), X(0x07fd7e48),
1193 X(0x08053316), X(0x080ceb6d), X(0x0814a74a), X(0x081c66af),
1194 X(0x0824299a), X(0x082bf00c), X(0x0833ba03), X(0x083b8780),
1195 X(0x08435882), X(0x084b2d09), X(0x08530514), X(0x085ae0a3),
1196 X(0x0862bfb6), X(0x086aa24c), X(0x08728865), X(0x087a7201),
1197 X(0x08825f1e), X(0x088a4fbe), X(0x089243de), X(0x089a3b80),
1198 X(0x08a236a2), X(0x08aa3545), X(0x08b23767), X(0x08ba3d09),
1199 X(0x08c2462a), X(0x08ca52c9), X(0x08d262e7), X(0x08da7682),
1200 X(0x08e28d9c), X(0x08eaa832), X(0x08f2c645), X(0x08fae7d4),
1201 X(0x09030cdf), X(0x090b3566), X(0x09136168), X(0x091b90e5),
1202 X(0x0923c3dc), X(0x092bfa4d), X(0x09343437), X(0x093c719b),
1203 X(0x0944b277), X(0x094cf6cc), X(0x09553e99), X(0x095d89dd),
1204 X(0x0965d899), X(0x096e2acb), X(0x09768073), X(0x097ed991),
1205 X(0x09873625), X(0x098f962e), X(0x0997f9ac), X(0x09a0609e),
1206 X(0x09a8cb04), X(0x09b138dd), X(0x09b9aa29), X(0x09c21ee8),
1207 X(0x09ca9719), X(0x09d312bc), X(0x09db91d0), X(0x09e41456),
1208 X(0x09ec9a4b), X(0x09f523b1), X(0x09fdb087), X(0x0a0640cc),
1209 X(0x0a0ed47f), X(0x0a176ba2), X(0x0a200632), X(0x0a28a42f),
1210 X(0x0a31459a), X(0x0a39ea72), X(0x0a4292b5), X(0x0a4b3e65),
1211 X(0x0a53ed80), X(0x0a5ca006), X(0x0a6555f7), X(0x0a6e0f51),
1212 X(0x0a76cc16), X(0x0a7f8c44), X(0x0a884fda), X(0x0a9116d9),
1213 X(0x0a99e140), X(0x0aa2af0e), X(0x0aab8043), X(0x0ab454df),
1214 X(0x0abd2ce1), X(0x0ac60849), X(0x0acee716), X(0x0ad7c948),
1215 X(0x0ae0aedf), X(0x0ae997d9), X(0x0af28437), X(0x0afb73f7),
1216 X(0x0b04671b), X(0x0b0d5da0), X(0x0b165788), X(0x0b1f54d0),
1217 X(0x0b285579), X(0x0b315983), X(0x0b3a60ec), X(0x0b436bb5),
1218 X(0x0b4c79dd), X(0x0b558b63), X(0x0b5ea048), X(0x0b67b88a),
1219 X(0x0b70d429), X(0x0b79f324), X(0x0b83157c), X(0x0b8c3b30),
1220 X(0x0b95643f), X(0x0b9e90a8), X(0x0ba7c06c), X(0x0bb0f38a),
1221 X(0x0bba2a01), X(0x0bc363d1), X(0x0bcca0f9), X(0x0bd5e17a),
1222 X(0x0bdf2552), X(0x0be86c81), X(0x0bf1b706), X(0x0bfb04e2),
1223 X(0x0c045613), X(0x0c0daa99), X(0x0c170274), X(0x0c205da3),
1224 X(0x0c29bc25), X(0x0c331dfb), X(0x0c3c8323), X(0x0c45eb9e),
1225 X(0x0c4f576a), X(0x0c58c688), X(0x0c6238f6), X(0x0c6baeb5),
1226 X(0x0c7527c3), X(0x0c7ea421), X(0x0c8823cd), X(0x0c91a6c8),
1227 X(0x0c9b2d10), X(0x0ca4b6a6), X(0x0cae4389), X(0x0cb7d3b8),
1228 X(0x0cc16732), X(0x0ccafdf8), X(0x0cd49809), X(0x0cde3564),
1229 X(0x0ce7d609), X(0x0cf179f7), X(0x0cfb212e), X(0x0d04cbad),
1230 X(0x0d0e7974), X(0x0d182a83), X(0x0d21ded8), X(0x0d2b9673),
1231 X(0x0d355154), X(0x0d3f0f7b), X(0x0d48d0e6), X(0x0d529595),
1232 X(0x0d5c5d88), X(0x0d6628be), X(0x0d6ff737), X(0x0d79c8f2),
1233 X(0x0d839dee), X(0x0d8d762c), X(0x0d9751aa), X(0x0da13068),
1234 X(0x0dab1266), X(0x0db4f7a3), X(0x0dbee01e), X(0x0dc8cbd8),
1235 X(0x0dd2bace), X(0x0ddcad02), X(0x0de6a272), X(0x0df09b1e),
1236 X(0x0dfa9705), X(0x0e049627), X(0x0e0e9883), X(0x0e189e19),
1237 X(0x0e22a6e8), X(0x0e2cb2f0), X(0x0e36c230), X(0x0e40d4a8),
1238 X(0x0e4aea56), X(0x0e55033b), X(0x0e5f1f56), X(0x0e693ea7),
1239 X(0x0e73612c), X(0x0e7d86e5), X(0x0e87afd3), X(0x0e91dbf3),
1240 X(0x0e9c0b47), X(0x0ea63dcc), X(0x0eb07383), X(0x0ebaac6b),
1241 X(0x0ec4e883), X(0x0ecf27cc), X(0x0ed96a44), X(0x0ee3afea),
1242 X(0x0eedf8bf), X(0x0ef844c2), X(0x0f0293f2), X(0x0f0ce64e),
1243 X(0x0f173bd6), X(0x0f21948a), X(0x0f2bf069), X(0x0f364f72),
1244 X(0x0f40b1a5), X(0x0f4b1701), X(0x0f557f86), X(0x0f5feb32),
1245 X(0x0f6a5a07), X(0x0f74cc02), X(0x0f7f4124), X(0x0f89b96b),
1246 X(0x0f9434d8), X(0x0f9eb369), X(0x0fa9351e), X(0x0fb3b9f7),
1247 X(0x0fbe41f3), X(0x0fc8cd11), X(0x0fd35b51), X(0x0fddecb2),
1248 X(0x0fe88134), X(0x0ff318d6), X(0x0ffdb397), X(0x10085177),
1249 X(0x1012f275), X(0x101d9691), X(0x10283dca), X(0x1032e81f),
1250 X(0x103d9591), X(0x1048461e), X(0x1052f9c5), X(0x105db087),
1251 X(0x10686a62), X(0x10732756), X(0x107de763), X(0x1088aa87),
1252 X(0x109370c2), X(0x109e3a14), X(0x10a9067c), X(0x10b3d5f9),
1253 X(0x10bea88b), X(0x10c97e31), X(0x10d456eb), X(0x10df32b8),
1254 X(0x10ea1197), X(0x10f4f387), X(0x10ffd889), X(0x110ac09b),
1255 X(0x1115abbe), X(0x112099ef), X(0x112b8b2f), X(0x11367f7d),
1256 X(0x114176d9), X(0x114c7141), X(0x11576eb6), X(0x11626f36),
1257 X(0x116d72c1), X(0x11787957), X(0x118382f6), X(0x118e8f9e),
1258 X(0x11999f4f), X(0x11a4b208), X(0x11afc7c7), X(0x11bae08e),
1259 X(0x11c5fc5a), X(0x11d11b2c), X(0x11dc3d02), X(0x11e761dd),
1260 X(0x11f289ba), X(0x11fdb49b), X(0x1208e27e), X(0x12141362),
1261 X(0x121f4748), X(0x122a7e2d), X(0x1235b812), X(0x1240f4f6),
1262 X(0x124c34d9), X(0x125777b9), X(0x1262bd96), X(0x126e0670),
1263 X(0x12795245), X(0x1284a115), X(0x128ff2e0), X(0x129b47a5),
1264 X(0x12a69f63), X(0x12b1fa19), X(0x12bd57c7), X(0x12c8b86c),
1265 X(0x12d41c08), X(0x12df829a), X(0x12eaec21), X(0x12f6589d),
1266 X(0x1301c80c), X(0x130d3a6f), X(0x1318afc4), X(0x1324280b),
1267 X(0x132fa344), X(0x133b216d), X(0x1346a286), X(0x1352268e),
1268 X(0x135dad85), X(0x1369376a), X(0x1374c43c), X(0x138053fb),
1269 X(0x138be6a5), X(0x13977c3b), X(0x13a314bc), X(0x13aeb026),
1270 X(0x13ba4e79), X(0x13c5efb5), X(0x13d193d9), X(0x13dd3ae4),
1271 X(0x13e8e4d6), X(0x13f491ad), X(0x1400416a), X(0x140bf40b),
1272 X(0x1417a98f), X(0x142361f7), X(0x142f1d41), X(0x143adb6d),
1273 X(0x14469c7a), X(0x14526067), X(0x145e2734), X(0x1469f0df),
1274 X(0x1475bd69), X(0x14818cd0), X(0x148d5f15), X(0x14993435),
1275 X(0x14a50c31), X(0x14b0e708), X(0x14bcc4b8), X(0x14c8a542),
1276 X(0x14d488a5), X(0x14e06edf), X(0x14ec57f1), X(0x14f843d9),
1277 X(0x15043297), X(0x1510242b), X(0x151c1892), X(0x15280fcd),
1278 X(0x153409dc), X(0x154006bc), X(0x154c066e), X(0x155808f1),
1279 X(0x15640e44), X(0x15701666), X(0x157c2157), X(0x15882f16),
1280 X(0x15943fa2), X(0x15a052fb), X(0x15ac691f), X(0x15b8820f),
1281 X(0x15c49dc8), X(0x15d0bc4c), X(0x15dcdd98), X(0x15e901ad),
1282 X(0x15f52888), X(0x1601522b), X(0x160d7e93), X(0x1619adc1),
1283 X(0x1625dfb3), X(0x16321469), X(0x163e4be2), X(0x164a861d),
1284 X(0x1656c31a), X(0x166302d8), X(0x166f4555), X(0x167b8a92),
1285 X(0x1687d28e), X(0x16941d47), X(0x16a06abe), X(0x16acbaf0),
1286 X(0x16b90ddf), X(0x16c56388), X(0x16d1bbeb), X(0x16de1708),
1287 X(0x16ea74dd), X(0x16f6d56a), X(0x170338ae), X(0x170f9ea8),
1288 X(0x171c0758), X(0x172872bd), X(0x1734e0d6), X(0x174151a2),
1289 X(0x174dc520), X(0x175a3b51), X(0x1766b432), X(0x17732fc4),
1290 X(0x177fae05), X(0x178c2ef4), X(0x1798b292), X(0x17a538dd),
1291 X(0x17b1c1d4), X(0x17be4d77), X(0x17cadbc5), X(0x17d76cbc),
1292 X(0x17e4005e), X(0x17f096a7), X(0x17fd2f98), X(0x1809cb31),
1293 X(0x1816696f), X(0x18230a53), X(0x182faddc), X(0x183c5408),
1294 X(0x1848fcd8), X(0x1855a849), X(0x1862565d), X(0x186f0711),
1295 X(0x187bba64), X(0x18887057), X(0x189528e9), X(0x18a1e418),
1296 X(0x18aea1e3), X(0x18bb624b), X(0x18c8254e), X(0x18d4eaeb),
1297 X(0x18e1b321), X(0x18ee7df1), X(0x18fb4b58), X(0x19081b57),
1298 X(0x1914edec), X(0x1921c317), X(0x192e9ad6), X(0x193b7529),
1299 X(0x19485210), X(0x19553189), X(0x19621393), X(0x196ef82e),
1300 X(0x197bdf59), X(0x1988c913), X(0x1995b55c), X(0x19a2a432),
1301 X(0x19af9595), X(0x19bc8983), X(0x19c97ffd), X(0x19d67900),
1302 X(0x19e3748e), X(0x19f072a3), X(0x19fd7341), X(0x1a0a7665),
1303 X(0x1a177c10), X(0x1a248440), X(0x1a318ef4), X(0x1a3e9c2c),
1304 X(0x1a4babe7), X(0x1a58be24), X(0x1a65d2e2), X(0x1a72ea20),
1305 X(0x1a8003de), X(0x1a8d201a), X(0x1a9a3ed5), X(0x1aa7600c),
1306 X(0x1ab483bf), X(0x1ac1a9ee), X(0x1aced297), X(0x1adbfdba),
1307 X(0x1ae92b56), X(0x1af65b69), X(0x1b038df4), X(0x1b10c2f5),
1308 X(0x1b1dfa6b), X(0x1b2b3456), X(0x1b3870b5), X(0x1b45af87),
1309 X(0x1b52f0ca), X(0x1b60347f), X(0x1b6d7aa4), X(0x1b7ac339),
1310 X(0x1b880e3c), X(0x1b955bad), X(0x1ba2ab8b), X(0x1baffdd5),
1311 X(0x1bbd528a), X(0x1bcaa9a9), X(0x1bd80332), X(0x1be55f24),
1312 X(0x1bf2bd7d), X(0x1c001e3d), X(0x1c0d8164), X(0x1c1ae6ef),
1313 X(0x1c284edf), X(0x1c35b932), X(0x1c4325e7), X(0x1c5094fe),
1314 X(0x1c5e0677), X(0x1c6b7a4f), X(0x1c78f086), X(0x1c86691b),
1315 X(0x1c93e40d), X(0x1ca1615c), X(0x1caee107), X(0x1cbc630c),
1316 X(0x1cc9e76b), X(0x1cd76e23), X(0x1ce4f733), X(0x1cf2829a),
1317 X(0x1d001057), X(0x1d0da06a), X(0x1d1b32d1), X(0x1d28c78c),
1318 X(0x1d365e9a), X(0x1d43f7f9), X(0x1d5193a9), X(0x1d5f31aa),
1319 X(0x1d6cd1f9), X(0x1d7a7497), X(0x1d881982), X(0x1d95c0ba),
1320 X(0x1da36a3d), X(0x1db1160a), X(0x1dbec422), X(0x1dcc7482),
1321 X(0x1dda272b), X(0x1de7dc1a), X(0x1df59350), X(0x1e034ccb),
1322 X(0x1e11088a), X(0x1e1ec68c), X(0x1e2c86d1), X(0x1e3a4958),
1323 X(0x1e480e20), X(0x1e55d527), X(0x1e639e6d), X(0x1e7169f1),
1324 X(0x1e7f37b2), X(0x1e8d07b0), X(0x1e9ad9e8), X(0x1ea8ae5b),
1325 X(0x1eb68507), X(0x1ec45dec), X(0x1ed23908), X(0x1ee0165b),
1326 X(0x1eedf5e4), X(0x1efbd7a1), X(0x1f09bb92), X(0x1f17a1b6),
1327 X(0x1f258a0d), X(0x1f337494), X(0x1f41614b), X(0x1f4f5032),
1328 X(0x1f5d4147), X(0x1f6b3489), X(0x1f7929f7), X(0x1f872192),
1329 X(0x1f951b56), X(0x1fa31744), X(0x1fb1155b), X(0x1fbf159a),
1330 X(0x1fcd17ff), X(0x1fdb1c8b), X(0x1fe9233b), X(0x1ff72c0f),
1331 X(0x20053706), X(0x20134420), X(0x2021535a), X(0x202f64b4),
1332 X(0x203d782e), X(0x204b8dc6), X(0x2059a57c), X(0x2067bf4e),
1333 X(0x2075db3b), X(0x2083f943), X(0x20921964), X(0x20a03b9e),
1334 X(0x20ae5fef), X(0x20bc8657), X(0x20caaed5), X(0x20d8d967),
1335 X(0x20e7060e), X(0x20f534c7), X(0x21036592), X(0x2111986e),
1336 X(0x211fcd59), X(0x212e0454), X(0x213c3d5d), X(0x214a7873),
1337 X(0x2158b594), X(0x2166f4c1), X(0x217535f8), X(0x21837938),
1338 X(0x2191be81), X(0x21a005d0), X(0x21ae4f26), X(0x21bc9a81),
1339 X(0x21cae7e0), X(0x21d93743), X(0x21e788a8), X(0x21f5dc0e),
1340 X(0x22043174), X(0x221288da), X(0x2220e23e), X(0x222f3da0),
1341 X(0x223d9afe), X(0x224bfa58), X(0x225a5bac), X(0x2268bef9),
1342 X(0x2277243f), X(0x22858b7d), X(0x2293f4b0), X(0x22a25fda),
1343 X(0x22b0ccf8), X(0x22bf3c09), X(0x22cdad0d), X(0x22dc2002),
1344 X(0x22ea94e8), X(0x22f90bbe), X(0x23078482), X(0x2315ff33),
1345 X(0x23247bd1), X(0x2332fa5b), X(0x23417acf), X(0x234ffd2c),
1346 X(0x235e8173), X(0x236d07a0), X(0x237b8fb4), X(0x238a19ae),
1347 X(0x2398a58c), X(0x23a7334d), X(0x23b5c2f1), X(0x23c45477),
1348 X(0x23d2e7dd), X(0x23e17d22), X(0x23f01446), X(0x23fead47),
1349 X(0x240d4825), X(0x241be4dd), X(0x242a8371), X(0x243923dd),
1350 X(0x2447c622), X(0x24566a3e), X(0x24651031), X(0x2473b7f8),
1351 X(0x24826194), X(0x24910d03), X(0x249fba44), X(0x24ae6957),
1352 X(0x24bd1a39), X(0x24cbccea), X(0x24da816a), X(0x24e937b7),
1353 X(0x24f7efcf), X(0x2506a9b3), X(0x25156560), X(0x252422d6),
1354 X(0x2532e215), X(0x2541a31a), X(0x255065e4), X(0x255f2a74),
1355 X(0x256df0c7), X(0x257cb8dd), X(0x258b82b4), X(0x259a4e4c),
1356 X(0x25a91ba4), X(0x25b7eaba), X(0x25c6bb8e), X(0x25d58e1e),
1357 X(0x25e46269), X(0x25f3386e), X(0x2602102d), X(0x2610e9a4),
1358 X(0x261fc4d3), X(0x262ea1b7), X(0x263d8050), X(0x264c609e),
1359 X(0x265b429e), X(0x266a2650), X(0x26790bb3), X(0x2687f2c6),
1360 X(0x2696db88), X(0x26a5c5f7), X(0x26b4b213), X(0x26c39fda),
1361 X(0x26d28f4c), X(0x26e18067), X(0x26f0732b), X(0x26ff6796),
1362 X(0x270e5da7), X(0x271d555d), X(0x272c4eb7), X(0x273b49b5),
1363 X(0x274a4654), X(0x27594495), X(0x27684475), X(0x277745f4),
1364 X(0x27864910), X(0x27954dc9), X(0x27a4541e), X(0x27b35c0d),
1365 X(0x27c26596), X(0x27d170b7), X(0x27e07d6f), X(0x27ef8bbd),
1366 X(0x27fe9ba0), X(0x280dad18), X(0x281cc022), X(0x282bd4be),
1367 X(0x283aeaeb), X(0x284a02a7), X(0x28591bf2), X(0x286836cb),
1368 X(0x28775330), X(0x28867120), X(0x2895909b), X(0x28a4b19e),
1369 X(0x28b3d42a), X(0x28c2f83d), X(0x28d21dd5), X(0x28e144f3),
1370 X(0x28f06d94), X(0x28ff97b8), X(0x290ec35d), X(0x291df082),
1371 X(0x292d1f27), X(0x293c4f4a), X(0x294b80eb), X(0x295ab407),
1372 X(0x2969e89e), X(0x29791eaf), X(0x29885639), X(0x29978f3b),
1373 X(0x29a6c9b3), X(0x29b605a0), X(0x29c54302), X(0x29d481d7),
1374 X(0x29e3c21e), X(0x29f303d6), X(0x2a0246fd), X(0x2a118b94),
1375 X(0x2a20d198), X(0x2a301909), X(0x2a3f61e6), X(0x2a4eac2c),
1376 X(0x2a5df7dc), X(0x2a6d44f4), X(0x2a7c9374), X(0x2a8be359),
1377 X(0x2a9b34a2), X(0x2aaa8750), X(0x2ab9db60), X(0x2ac930d1),
1378 X(0x2ad887a3), X(0x2ae7dfd3), X(0x2af73962), X(0x2b06944e),
1379 X(0x2b15f096), X(0x2b254e38), X(0x2b34ad34), X(0x2b440d89),
1380 X(0x2b536f34), X(0x2b62d236), X(0x2b72368d), X(0x2b819c38),
1381 X(0x2b910336), X(0x2ba06b86), X(0x2bafd526), X(0x2bbf4015),
1382 X(0x2bceac53), X(0x2bde19de), X(0x2bed88b5), X(0x2bfcf8d7),
1383 X(0x2c0c6a43), X(0x2c1bdcf7), X(0x2c2b50f3), X(0x2c3ac635),
1384 X(0x2c4a3cbd), X(0x2c59b488), X(0x2c692d97), X(0x2c78a7e7),
1385 X(0x2c882378), X(0x2c97a049), X(0x2ca71e58), X(0x2cb69da4),
1386 X(0x2cc61e2c), X(0x2cd59ff0), X(0x2ce522ed), X(0x2cf4a723),
1387 X(0x2d042c90), X(0x2d13b334), X(0x2d233b0d), X(0x2d32c41a),
1388 X(0x2d424e5a), X(0x2d51d9cc), X(0x2d61666e), X(0x2d70f440),
1389 X(0x2d808340), X(0x2d90136e), X(0x2d9fa4c7), X(0x2daf374c),
1390 X(0x2dbecafa), X(0x2dce5fd1), X(0x2dddf5cf), X(0x2ded8cf4),
1391 X(0x2dfd253d), X(0x2e0cbeab), X(0x2e1c593b), X(0x2e2bf4ed),
1392 X(0x2e3b91c0), X(0x2e4b2fb1), X(0x2e5acec1), X(0x2e6a6eee),
1393 X(0x2e7a1037), X(0x2e89b29b), X(0x2e995618), X(0x2ea8faad),
1394 X(0x2eb8a05a), X(0x2ec8471c), X(0x2ed7eef4), X(0x2ee797df),
1395 X(0x2ef741dc), X(0x2f06eceb), X(0x2f16990a), X(0x2f264639),
1396 X(0x2f35f475), X(0x2f45a3bd), X(0x2f555412), X(0x2f650570),
1397 X(0x2f74b7d8), X(0x2f846b48), X(0x2f941fbe), X(0x2fa3d53a),
1398 X(0x2fb38bbb), X(0x2fc3433f), X(0x2fd2fbc5), X(0x2fe2b54c),
1399 X(0x2ff26fd3), X(0x30022b58), X(0x3011e7db), X(0x3021a55a),
1400 X(0x303163d4), X(0x30412348), X(0x3050e3b5), X(0x3060a519),
1401 X(0x30706773), X(0x30802ac3), X(0x308fef06), X(0x309fb43d),
1402 X(0x30af7a65), X(0x30bf417d), X(0x30cf0985), X(0x30ded27a),
1403 X(0x30ee9c5d), X(0x30fe672b), X(0x310e32e3), X(0x311dff85),
1404 X(0x312dcd0f), X(0x313d9b80), X(0x314d6ad7), X(0x315d3b12),
1405 X(0x316d0c30), X(0x317cde31), X(0x318cb113), X(0x319c84d4),
1406 X(0x31ac5974), X(0x31bc2ef1), X(0x31cc054b), X(0x31dbdc7f),
1407 X(0x31ebb48e), X(0x31fb8d74), X(0x320b6733), X(0x321b41c7),
1408 X(0x322b1d31), X(0x323af96e), X(0x324ad67e), X(0x325ab45f),
1409 X(0x326a9311), X(0x327a7291), X(0x328a52e0), X(0x329a33fb),
1410 X(0x32aa15e1), X(0x32b9f892), X(0x32c9dc0c), X(0x32d9c04d),
1411 X(0x32e9a555), X(0x32f98b22), X(0x330971b4), X(0x33195909),
1412 X(0x3329411f), X(0x333929f6), X(0x3349138c), X(0x3358fde1),
1413 X(0x3368e8f2), X(0x3378d4c0), X(0x3388c147), X(0x3398ae89),
1414 X(0x33a89c82), X(0x33b88b32), X(0x33c87a98), X(0x33d86ab2),
1415 X(0x33e85b80), X(0x33f84d00), X(0x34083f30), X(0x34183210),
1416 X(0x3428259f), X(0x343819db), X(0x34480ec3), X(0x34580455),
1417 X(0x3467fa92), X(0x3477f176), X(0x3487e902), X(0x3497e134),
1418 X(0x34a7da0a), X(0x34b7d384), X(0x34c7cda0), X(0x34d7c85e),
1419 X(0x34e7c3bb), X(0x34f7bfb7), X(0x3507bc50), X(0x3517b985),
1420 X(0x3527b756), X(0x3537b5c0), X(0x3547b4c3), X(0x3557b45d),
1421 X(0x3567b48d), X(0x3577b552), X(0x3587b6aa), X(0x3597b895),
1422 X(0x35a7bb12), X(0x35b7be1e), X(0x35c7c1b9), X(0x35d7c5e1),
1423 X(0x35e7ca96), X(0x35f7cfd6), X(0x3607d5a0), X(0x3617dbf3),
1424 X(0x3627e2cd), X(0x3637ea2d), X(0x3647f212), X(0x3657fa7b),
1425 X(0x36680366), X(0x36780cd2), X(0x368816bf), X(0x3698212b),
1426 X(0x36a82c14), X(0x36b83779), X(0x36c8435a), X(0x36d84fb4),
1427 X(0x36e85c88), X(0x36f869d2), X(0x37087793), X(0x371885c9),
1428 X(0x37289473), X(0x3738a38f), X(0x3748b31d), X(0x3758c31a),
1429 X(0x3768d387), X(0x3778e461), X(0x3788f5a7), X(0x37990759),
1430 X(0x37a91975), X(0x37b92bf9), X(0x37c93ee4), X(0x37d95236),
1431 X(0x37e965ed), X(0x37f97a08), X(0x38098e85), X(0x3819a363),
1432 X(0x3829b8a2), X(0x3839ce3f), X(0x3849e43a), X(0x3859fa91),
1433 X(0x386a1143), X(0x387a284f), X(0x388a3fb4), X(0x389a5770),
1434 X(0x38aa6f83), X(0x38ba87ea), X(0x38caa0a5), X(0x38dab9b2),
1435 X(0x38ead311), X(0x38faecbf), X(0x390b06bc), X(0x391b2107),
1436 X(0x392b3b9e), X(0x393b5680), X(0x394b71ac), X(0x395b8d20),
1437 X(0x396ba8dc), X(0x397bc4dd), X(0x398be124), X(0x399bfdae),
1438 X(0x39ac1a7a), X(0x39bc3788), X(0x39cc54d5), X(0x39dc7261),
1439 X(0x39ec902a), X(0x39fcae2f), X(0x3a0ccc70), X(0x3a1ceaea),
1440 X(0x3a2d099c), X(0x3a3d2885), X(0x3a4d47a5), X(0x3a5d66f9),
1441 X(0x3a6d8680), X(0x3a7da63a), X(0x3a8dc625), X(0x3a9de63f),
1442 X(0x3aae0688), X(0x3abe26fe), X(0x3ace47a0), X(0x3ade686d),
1443 X(0x3aee8963), X(0x3afeaa82), X(0x3b0ecbc7), X(0x3b1eed32),
1444 X(0x3b2f0ec2), X(0x3b3f3075), X(0x3b4f524a), X(0x3b5f7440),
1445 X(0x3b6f9656), X(0x3b7fb889), X(0x3b8fdada), X(0x3b9ffd46),
1446 X(0x3bb01fce), X(0x3bc0426e), X(0x3bd06526), X(0x3be087f6),
1447 X(0x3bf0aada), X(0x3c00cdd4), X(0x3c10f0e0), X(0x3c2113fe),
1448 X(0x3c31372d), X(0x3c415a6b), X(0x3c517db7), X(0x3c61a110),
1449 X(0x3c71c475), X(0x3c81e7e4), X(0x3c920b5c), X(0x3ca22edc),
1450 X(0x3cb25262), X(0x3cc275ee), X(0x3cd2997e), X(0x3ce2bd11),
1451 X(0x3cf2e0a6), X(0x3d03043b), X(0x3d1327cf), X(0x3d234b61),
1452 X(0x3d336ef0), X(0x3d43927a), X(0x3d53b5ff), X(0x3d63d97c),
1453 X(0x3d73fcf1), X(0x3d84205c), X(0x3d9443bd), X(0x3da46711),
1454 X(0x3db48a58), X(0x3dc4ad91), X(0x3dd4d0ba), X(0x3de4f3d1),
1455 X(0x3df516d7), X(0x3e0539c9), X(0x3e155ca6), X(0x3e257f6d),
1456 X(0x3e35a21d), X(0x3e45c4b4), X(0x3e55e731), X(0x3e660994),
1457 X(0x3e762bda), X(0x3e864e03), X(0x3e96700d), X(0x3ea691f7),
1458 X(0x3eb6b3bf), X(0x3ec6d565), X(0x3ed6f6e8), X(0x3ee71845),
1459 X(0x3ef7397c), X(0x3f075a8c), X(0x3f177b73), X(0x3f279c30),
1460 X(0x3f37bcc2), X(0x3f47dd27), X(0x3f57fd5f), X(0x3f681d68),
1461 X(0x3f783d40), X(0x3f885ce7), X(0x3f987c5c), X(0x3fa89b9c),
1462 X(0x3fb8baa7), X(0x3fc8d97c), X(0x3fd8f819), X(0x3fe9167e),
1463 X(0x3ff934a8), X(0x40095296), X(0x40197049), X(0x40298dbd),
1464 X(0x4039aaf2), X(0x4049c7e7), X(0x4059e49a), X(0x406a010a),
1465 X(0x407a1d36), X(0x408a391d), X(0x409a54bd), X(0x40aa7015),
1466 X(0x40ba8b25), X(0x40caa5ea), X(0x40dac063), X(0x40eada90),
1467 X(0x40faf46e), X(0x410b0dfe), X(0x411b273d), X(0x412b402a),
1468 X(0x413b58c4), X(0x414b710a), X(0x415b88fa), X(0x416ba093),
1469 X(0x417bb7d5), X(0x418bcebe), X(0x419be54c), X(0x41abfb7e),
1470 X(0x41bc1153), X(0x41cc26ca), X(0x41dc3be2), X(0x41ec5099),
1471 X(0x41fc64ef), X(0x420c78e1), X(0x421c8c6f), X(0x422c9f97),
1472 X(0x423cb258), X(0x424cc4b2), X(0x425cd6a2), X(0x426ce827),
1473 X(0x427cf941), X(0x428d09ee), X(0x429d1a2c), X(0x42ad29fb),
1474 X(0x42bd3959), X(0x42cd4846), X(0x42dd56bf), X(0x42ed64c3),
1475 X(0x42fd7252), X(0x430d7f6a), X(0x431d8c0a), X(0x432d9831),
1476 X(0x433da3dd), X(0x434daf0d), X(0x435db9c0), X(0x436dc3f5),
1477 X(0x437dcdab), X(0x438dd6df), X(0x439ddf92), X(0x43ade7c1),
1478 X(0x43bdef6c), X(0x43cdf691), X(0x43ddfd2f), X(0x43ee0345),
1479 X(0x43fe08d2), X(0x440e0dd4), X(0x441e124b), X(0x442e1634),
1480 X(0x443e198f), X(0x444e1c5a), X(0x445e1e95), X(0x446e203e),
1481 X(0x447e2153), X(0x448e21d5), X(0x449e21c0), X(0x44ae2115),
1482 X(0x44be1fd1), X(0x44ce1df4), X(0x44de1b7d), X(0x44ee186a),
1483 X(0x44fe14ba), X(0x450e106b), X(0x451e0b7e), X(0x452e05ef),
1484 X(0x453dffbf), X(0x454df8eb), X(0x455df173), X(0x456de956),
1485 X(0x457de092), X(0x458dd726), X(0x459dcd10), X(0x45adc251),
1486 X(0x45bdb6e5), X(0x45cdaacd), X(0x45dd9e06), X(0x45ed9091),
1487 X(0x45fd826a), X(0x460d7392), X(0x461d6407), X(0x462d53c8),
1488 X(0x463d42d4), X(0x464d3129), X(0x465d1ec6), X(0x466d0baa),
1489 X(0x467cf7d3), X(0x468ce342), X(0x469ccdf3), X(0x46acb7e7),
1490 X(0x46bca11c), X(0x46cc8990), X(0x46dc7143), X(0x46ec5833),
1491 X(0x46fc3e5f), X(0x470c23c6), X(0x471c0867), X(0x472bec40),
1492 X(0x473bcf50), X(0x474bb196), X(0x475b9311), X(0x476b73c0),
1493 X(0x477b53a1), X(0x478b32b4), X(0x479b10f6), X(0x47aaee67),
1494 X(0x47bacb06), X(0x47caa6d1), X(0x47da81c7), X(0x47ea5be7),
1495 X(0x47fa3530), X(0x480a0da1), X(0x4819e537), X(0x4829bbf3),
1496 X(0x483991d3), X(0x484966d6), X(0x48593afb), X(0x48690e3f),
1497 X(0x4878e0a3), X(0x4888b225), X(0x489882c4), X(0x48a8527e),
1498 X(0x48b82153), X(0x48c7ef41), X(0x48d7bc47), X(0x48e78863),
1499 X(0x48f75396), X(0x49071ddc), X(0x4916e736), X(0x4926afa2),
1500 X(0x4936771f), X(0x49463dac), X(0x49560347), X(0x4965c7ef),
1501 X(0x49758ba4), X(0x49854e63), X(0x4995102c), X(0x49a4d0fe),
1502 X(0x49b490d7), X(0x49c44fb6), X(0x49d40d9a), X(0x49e3ca82),
1503 X(0x49f3866c), X(0x4a034159), X(0x4a12fb45), X(0x4a22b430),
1504 X(0x4a326c19), X(0x4a4222ff), X(0x4a51d8e1), X(0x4a618dbd),
1505 X(0x4a714192), X(0x4a80f45f), X(0x4a90a623), X(0x4aa056dd),
1506 X(0x4ab0068b), X(0x4abfb52c), X(0x4acf62c0), X(0x4adf0f44),
1507 X(0x4aeebab9), X(0x4afe651c), X(0x4b0e0e6c), X(0x4b1db6a9),
1508 X(0x4b2d5dd1), X(0x4b3d03e2), X(0x4b4ca8dd), X(0x4b5c4cbf),
1509 X(0x4b6bef88), X(0x4b7b9136), X(0x4b8b31c8), X(0x4b9ad13d),
1510 X(0x4baa6f93), X(0x4bba0ccb), X(0x4bc9a8e2), X(0x4bd943d7),
1511 X(0x4be8dda9), X(0x4bf87658), X(0x4c080de1), X(0x4c17a444),
1512 X(0x4c27397f), X(0x4c36cd92), X(0x4c46607b), X(0x4c55f239),
1513 X(0x4c6582cb), X(0x4c75122f), X(0x4c84a065), X(0x4c942d6c),
1514 X(0x4ca3b942), X(0x4cb343e6), X(0x4cc2cd57), X(0x4cd25594),
1515 X(0x4ce1dc9c), X(0x4cf1626d), X(0x4d00e707), X(0x4d106a68),
1516 X(0x4d1fec8f), X(0x4d2f6d7a), X(0x4d3eed2a), X(0x4d4e6b9d),
1517 X(0x4d5de8d1), X(0x4d6d64c5), X(0x4d7cdf79), X(0x4d8c58eb),
1518 X(0x4d9bd11a), X(0x4dab4804), X(0x4dbabdaa), X(0x4dca3209),
1519 X(0x4dd9a520), X(0x4de916ef), X(0x4df88774), X(0x4e07f6ae),
1520 X(0x4e17649c), X(0x4e26d13c), X(0x4e363c8f), X(0x4e45a692),
1521 X(0x4e550f44), X(0x4e6476a4), X(0x4e73dcb2), X(0x4e83416c),
1522 X(0x4e92a4d1), X(0x4ea206df), X(0x4eb16796), X(0x4ec0c6f5),
1523 X(0x4ed024fa), X(0x4edf81a5), X(0x4eeedcf3), X(0x4efe36e5),
1524 X(0x4f0d8f79), X(0x4f1ce6ad), X(0x4f2c3c82), X(0x4f3b90f4),
1525 X(0x4f4ae405), X(0x4f5a35b1), X(0x4f6985fa), X(0x4f78d4dc),
1526 X(0x4f882257), X(0x4f976e6a), X(0x4fa6b914), X(0x4fb60254),
1527 X(0x4fc54a28), X(0x4fd49090), X(0x4fe3d58b), X(0x4ff31917),
1528 X(0x50025b33), X(0x50119bde), X(0x5020db17), X(0x503018dd),
1529 X(0x503f552f), X(0x504e900b), X(0x505dc971), X(0x506d0160),
1530 X(0x507c37d7), X(0x508b6cd3), X(0x509aa055), X(0x50a9d25b),
1531 X(0x50b902e4), X(0x50c831ef), X(0x50d75f7b), X(0x50e68b87),
1532 X(0x50f5b612), X(0x5104df1a), X(0x5114069f), X(0x51232ca0),
1533 X(0x5132511a), X(0x5141740f), X(0x5150957b), X(0x515fb55f),
1534 X(0x516ed3b8), X(0x517df087), X(0x518d0bca), X(0x519c257f),
1535 X(0x51ab3da7), X(0x51ba543f), X(0x51c96947), X(0x51d87cbd),
1536 X(0x51e78ea1), X(0x51f69ef1), X(0x5205adad), X(0x5214bad3),
1537 X(0x5223c662), X(0x5232d05a), X(0x5241d8b9), X(0x5250df7d),
1538 X(0x525fe4a7), X(0x526ee835), X(0x527dea26), X(0x528cea78),
1539 X(0x529be92c), X(0x52aae63f), X(0x52b9e1b0), X(0x52c8db80),
1540 X(0x52d7d3ac), X(0x52e6ca33), X(0x52f5bf15), X(0x5304b251),
1541 X(0x5313a3e5), X(0x532293d0), X(0x53318212), X(0x53406ea8),
1542 X(0x534f5993), X(0x535e42d2), X(0x536d2a62), X(0x537c1043),
1543 X(0x538af475), X(0x5399d6f6), X(0x53a8b7c4), X(0x53b796e0),
1544 X(0x53c67447), X(0x53d54ffa), X(0x53e429f6), X(0x53f3023b),
1545 X(0x5401d8c8), X(0x5410ad9c), X(0x541f80b5), X(0x542e5213),
1546 X(0x543d21b5), X(0x544bef9a), X(0x545abbc0), X(0x54698627),
1547 X(0x54784ece), X(0x548715b3), X(0x5495dad6), X(0x54a49e35),
1548 X(0x54b35fd0), X(0x54c21fa6), X(0x54d0ddb5), X(0x54df99fd),
1549 X(0x54ee547c), X(0x54fd0d32), X(0x550bc41d), X(0x551a793d),
1550 X(0x55292c91), X(0x5537de16), X(0x55468dce), X(0x55553bb6),
1551 X(0x5563e7cd), X(0x55729213), X(0x55813a87), X(0x558fe127),
1552 X(0x559e85f2), X(0x55ad28e9), X(0x55bbca08), X(0x55ca6950),
1553 X(0x55d906c0), X(0x55e7a257), X(0x55f63c13), X(0x5604d3f4),
1554 X(0x561369f8), X(0x5621fe1f), X(0x56309067), X(0x563f20d1),
1555 X(0x564daf5a), X(0x565c3c02), X(0x566ac6c7), X(0x56794faa),
1556 X(0x5687d6a8), X(0x56965bc1), X(0x56a4def4), X(0x56b36040),
1557 X(0x56c1dfa4), X(0x56d05d1f), X(0x56ded8af), X(0x56ed5255),
1558 X(0x56fbca0f), X(0x570a3fdc), X(0x5718b3bc), X(0x572725ac),
1559 X(0x573595ad), X(0x574403bd), X(0x57526fdb), X(0x5760da07),
1560 X(0x576f423f), X(0x577da883), X(0x578c0cd1), X(0x579a6f29),
1561 X(0x57a8cf8a), X(0x57b72df2), X(0x57c58a61), X(0x57d3e4d6),
1562 X(0x57e23d50), X(0x57f093cd), X(0x57fee84e), X(0x580d3ad1),
1563 X(0x581b8b54), X(0x5829d9d8), X(0x5838265c), X(0x584670dd),
1564 X(0x5854b95c), X(0x5862ffd8), X(0x5871444f), X(0x587f86c1),
1565 X(0x588dc72c), X(0x589c0591), X(0x58aa41ed), X(0x58b87c40),
1566 X(0x58c6b489), X(0x58d4eac7), X(0x58e31ef9), X(0x58f1511f),
1567 X(0x58ff8137), X(0x590daf40), X(0x591bdb3a), X(0x592a0524),
1568 X(0x59382cfc), X(0x594652c2), X(0x59547675), X(0x59629815),
1569 X(0x5970b79f), X(0x597ed513), X(0x598cf071), X(0x599b09b7),
1570 X(0x59a920e5), X(0x59b735f9), X(0x59c548f4), X(0x59d359d2),
1571 X(0x59e16895), X(0x59ef753b), X(0x59fd7fc4), X(0x5a0b882d),
1572 X(0x5a198e77), X(0x5a2792a0), X(0x5a3594a9), X(0x5a43948e),
1573 X(0x5a519251), X(0x5a5f8df0), X(0x5a6d876a), X(0x5a7b7ebe),
1574 X(0x5a8973ec), X(0x5a9766f2), X(0x5aa557d0), X(0x5ab34685),
1575 X(0x5ac1330f), X(0x5acf1d6f), X(0x5add05a3), X(0x5aeaebaa),
1576 X(0x5af8cf84), X(0x5b06b12f), X(0x5b1490ab), X(0x5b226df7),
1577 X(0x5b304912), X(0x5b3e21fc), X(0x5b4bf8b2), X(0x5b59cd35),
1578 X(0x5b679f84), X(0x5b756f9e), X(0x5b833d82), X(0x5b91092e),
1579 X(0x5b9ed2a3), X(0x5bac99e0), X(0x5bba5ee3), X(0x5bc821ac),
1580 X(0x5bd5e23a), X(0x5be3a08c), X(0x5bf15ca1), X(0x5bff1679),
1581 X(0x5c0cce12), X(0x5c1a836c), X(0x5c283686), X(0x5c35e760),
1582 X(0x5c4395f7), X(0x5c51424c), X(0x5c5eec5e), X(0x5c6c942b),
1583 X(0x5c7a39b4), X(0x5c87dcf7), X(0x5c957df3), X(0x5ca31ca8),
1584 X(0x5cb0b915), X(0x5cbe5338), X(0x5ccbeb12), X(0x5cd980a1),
1585 X(0x5ce713e5), X(0x5cf4a4dd), X(0x5d023387), X(0x5d0fbfe4),
1586 X(0x5d1d49f2), X(0x5d2ad1b1), X(0x5d38571f), X(0x5d45da3c),
1587 X(0x5d535b08), X(0x5d60d981), X(0x5d6e55a7), X(0x5d7bcf78),
1588 X(0x5d8946f5), X(0x5d96bc1c), X(0x5da42eec), X(0x5db19f65),
1589 X(0x5dbf0d86), X(0x5dcc794e), X(0x5dd9e2bd), X(0x5de749d1),
1590 X(0x5df4ae8a), X(0x5e0210e7), X(0x5e0f70e7), X(0x5e1cce8a),
1591 X(0x5e2a29ce), X(0x5e3782b4), X(0x5e44d93a), X(0x5e522d5f),
1592 X(0x5e5f7f23), X(0x5e6cce85), X(0x5e7a1b85), X(0x5e876620),
1593 X(0x5e94ae58), X(0x5ea1f42a), X(0x5eaf3797), X(0x5ebc789d),
1594 X(0x5ec9b73c), X(0x5ed6f372), X(0x5ee42d41), X(0x5ef164a5),
1595 X(0x5efe999f), X(0x5f0bcc2f), X(0x5f18fc52), X(0x5f262a09),
1596 X(0x5f335553), X(0x5f407e2f), X(0x5f4da49d), X(0x5f5ac89b),
1597 X(0x5f67ea29), X(0x5f750946), X(0x5f8225f2), X(0x5f8f402b),
1598 X(0x5f9c57f2), X(0x5fa96d44), X(0x5fb68023), X(0x5fc3908c),
1599 X(0x5fd09e7f), X(0x5fdda9fc), X(0x5feab302), X(0x5ff7b990),
1600 X(0x6004bda5), X(0x6011bf40), X(0x601ebe62), X(0x602bbb09),
1601 X(0x6038b534), X(0x6045ace4), X(0x6052a216), X(0x605f94cb),
1602 X(0x606c8502), X(0x607972b9), X(0x60865df2), X(0x609346aa),
1603 X(0x60a02ce1), X(0x60ad1096), X(0x60b9f1c9), X(0x60c6d079),
1604 X(0x60d3aca5), X(0x60e0864d), X(0x60ed5d70), X(0x60fa320d),
1605 X(0x61070424), X(0x6113d3b4), X(0x6120a0bc), X(0x612d6b3c),
1606 X(0x613a3332), X(0x6146f89f), X(0x6153bb82), X(0x61607bd9),
1607 X(0x616d39a5), X(0x6179f4e5), X(0x6186ad98), X(0x619363bd),
1608 X(0x61a01753), X(0x61acc85b), X(0x61b976d3), X(0x61c622bc),
1609 X(0x61d2cc13), X(0x61df72d8), X(0x61ec170c), X(0x61f8b8ad),
1610 X(0x620557ba), X(0x6211f434), X(0x621e8e18), X(0x622b2568),
1611 X(0x6237ba21), X(0x62444c44), X(0x6250dbd0), X(0x625d68c4),
1612 X(0x6269f320), X(0x62767ae2), X(0x6283000b), X(0x628f829a),
1613 X(0x629c028e), X(0x62a87fe6), X(0x62b4faa2), X(0x62c172c2),
1614 X(0x62cde844), X(0x62da5b29), X(0x62e6cb6e), X(0x62f33915),
1615 X(0x62ffa41c), X(0x630c0c83), X(0x63187248), X(0x6324d56d),
1616 X(0x633135ef), X(0x633d93ce), X(0x6349ef0b), X(0x635647a3),
1617 X(0x63629d97), X(0x636ef0e6), X(0x637b418f), X(0x63878f92),
1618 X(0x6393daef), X(0x63a023a4), X(0x63ac69b1), X(0x63b8ad15),
1619 X(0x63c4edd1), X(0x63d12be3), X(0x63dd674b), X(0x63e9a008),
1620 X(0x63f5d61a), X(0x64020980), X(0x640e3a39), X(0x641a6846),
1621 X(0x642693a5), X(0x6432bc56), X(0x643ee258), X(0x644b05ab),
1622 X(0x6457264e), X(0x64634441), X(0x646f5f83), X(0x647b7814),
1623 X(0x64878df3), X(0x6493a120), X(0x649fb199), X(0x64abbf5f),
1624 X(0x64b7ca71), X(0x64c3d2ce), X(0x64cfd877), X(0x64dbdb69),
1625 X(0x64e7dba6), X(0x64f3d92b), X(0x64ffd3fa), X(0x650bcc11),
1626 X(0x6517c16f), X(0x6523b415), X(0x652fa402), X(0x653b9134),
1627 X(0x65477bad), X(0x6553636a), X(0x655f486d), X(0x656b2ab3),
1628 X(0x65770a3d), X(0x6582e70a), X(0x658ec11a), X(0x659a986d),
1629 X(0x65a66d00), X(0x65b23ed5), X(0x65be0deb), X(0x65c9da41),
1630 X(0x65d5a3d7), X(0x65e16aac), X(0x65ed2ebf), X(0x65f8f011),
1631 X(0x6604aea1), X(0x66106a6e), X(0x661c2377), X(0x6627d9be),
1632 X(0x66338d40), X(0x663f3dfd), X(0x664aebf5), X(0x66569728),
1633 X(0x66623f95), X(0x666de53b), X(0x6679881b), X(0x66852833),
1634 X(0x6690c583), X(0x669c600b), X(0x66a7f7ca), X(0x66b38cc0),
1635 X(0x66bf1eec), X(0x66caae4f), X(0x66d63ae6), X(0x66e1c4b3),
1636 X(0x66ed4bb4), X(0x66f8cfea), X(0x67045153), X(0x670fcfef),
1637 X(0x671b4bbe), X(0x6726c4bf), X(0x67323af3), X(0x673dae58),
1638 X(0x67491eee), X(0x67548cb5), X(0x675ff7ab), X(0x676b5fd2),
1639 X(0x6776c528), X(0x678227ad), X(0x678d8761), X(0x6798e443),
1640 X(0x67a43e52), X(0x67af958f), X(0x67bae9f9), X(0x67c63b8f),
1641 X(0x67d18a52), X(0x67dcd640), X(0x67e81f59), X(0x67f3659d),
1642 X(0x67fea90c), X(0x6809e9a5), X(0x68152768), X(0x68206254),
1643 X(0x682b9a68), X(0x6836cfa6), X(0x6842020b), X(0x684d3199),
1644 X(0x68585e4d), X(0x68638829), X(0x686eaf2b), X(0x6879d354),
1645 X(0x6884f4a2), X(0x68901316), X(0x689b2eb0), X(0x68a6476d),
1646 X(0x68b15d50), X(0x68bc7056), X(0x68c78080), X(0x68d28dcd),
1647 X(0x68dd983e), X(0x68e89fd0), X(0x68f3a486), X(0x68fea65d),
1648 X(0x6909a555), X(0x6914a16f), X(0x691f9aa9), X(0x692a9104),
1649 X(0x69358480), X(0x6940751b), X(0x694b62d5), X(0x69564daf),
1650 X(0x696135a7), X(0x696c1abe), X(0x6976fcf3), X(0x6981dc46),
1651 X(0x698cb8b6), X(0x69979243), X(0x69a268ed), X(0x69ad3cb4),
1652 X(0x69b80d97), X(0x69c2db96), X(0x69cda6b0), X(0x69d86ee5),
1653 X(0x69e33436), X(0x69edf6a1), X(0x69f8b626), X(0x6a0372c5),
1654 X(0x6a0e2c7e), X(0x6a18e350), X(0x6a23973c), X(0x6a2e4840),
1655 X(0x6a38f65d), X(0x6a43a191), X(0x6a4e49de), X(0x6a58ef42),
1656 X(0x6a6391be), X(0x6a6e3151), X(0x6a78cdfa), X(0x6a8367ba),
1657 X(0x6a8dfe90), X(0x6a98927c), X(0x6aa3237d), X(0x6aadb194),
1658 X(0x6ab83cc0), X(0x6ac2c500), X(0x6acd4a55), X(0x6ad7ccbf),
1659 X(0x6ae24c3c), X(0x6aecc8cd), X(0x6af74271), X(0x6b01b929),
1660 X(0x6b0c2cf4), X(0x6b169dd1), X(0x6b210bc1), X(0x6b2b76c2),
1661 X(0x6b35ded6), X(0x6b4043fc), X(0x6b4aa632), X(0x6b55057a),
1662 X(0x6b5f61d3), X(0x6b69bb3d), X(0x6b7411b7), X(0x6b7e6541),
1663 X(0x6b88b5db), X(0x6b930385), X(0x6b9d4e3f), X(0x6ba79607),
1664 X(0x6bb1dadf), X(0x6bbc1cc6), X(0x6bc65bbb), X(0x6bd097bf),
1665 X(0x6bdad0d0), X(0x6be506f0), X(0x6bef3a1d), X(0x6bf96a58),
1666 X(0x6c0397a0), X(0x6c0dc1f5), X(0x6c17e957), X(0x6c220dc6),
1667 X(0x6c2c2f41), X(0x6c364dc9), X(0x6c40695c), X(0x6c4a81fc),
1668 X(0x6c5497a7), X(0x6c5eaa5d), X(0x6c68ba1f), X(0x6c72c6eb),
1669 X(0x6c7cd0c3), X(0x6c86d7a6), X(0x6c90db92), X(0x6c9adc8a),
1670 X(0x6ca4da8b), X(0x6caed596), X(0x6cb8cdab), X(0x6cc2c2ca),
1671 X(0x6cccb4f2), X(0x6cd6a424), X(0x6ce0905e), X(0x6cea79a1),
1672 X(0x6cf45fee), X(0x6cfe4342), X(0x6d0823a0), X(0x6d120105),
1673 X(0x6d1bdb73), X(0x6d25b2e8), X(0x6d2f8765), X(0x6d3958ea),
1674 X(0x6d432777), X(0x6d4cf30a), X(0x6d56bba5), X(0x6d608147),
1675 X(0x6d6a43f0), X(0x6d7403a0), X(0x6d7dc056), X(0x6d877a13),
1676 X(0x6d9130d6), X(0x6d9ae4a0), X(0x6da4956f), X(0x6dae4345),
1677 X(0x6db7ee20), X(0x6dc19601), X(0x6dcb3ae7), X(0x6dd4dcd3),
1678 X(0x6dde7bc4), X(0x6de817bb), X(0x6df1b0b6), X(0x6dfb46b7),
1679 X(0x6e04d9bc), X(0x6e0e69c7), X(0x6e17f6d5), X(0x6e2180e9),
1680 X(0x6e2b0801), X(0x6e348c1d), X(0x6e3e0d3d), X(0x6e478b62),
1681 X(0x6e51068a), X(0x6e5a7eb7), X(0x6e63f3e7), X(0x6e6d661b),
1682 X(0x6e76d552), X(0x6e80418e), X(0x6e89aacc), X(0x6e93110f),
1683 X(0x6e9c7454), X(0x6ea5d49d), X(0x6eaf31e9), X(0x6eb88c37),
1684 X(0x6ec1e389), X(0x6ecb37de), X(0x6ed48936), X(0x6eddd790),
1685 X(0x6ee722ee), X(0x6ef06b4d), X(0x6ef9b0b0), X(0x6f02f315),
1686 X(0x6f0c327c), X(0x6f156ee6), X(0x6f1ea852), X(0x6f27dec1),
1687 X(0x6f311232), X(0x6f3a42a5), X(0x6f43701a), X(0x6f4c9a91),
1688 X(0x6f55c20a), X(0x6f5ee686), X(0x6f680803), X(0x6f712682),
1689 X(0x6f7a4203), X(0x6f835a86), X(0x6f8c700b), X(0x6f958291),
1690 X(0x6f9e921a), X(0x6fa79ea4), X(0x6fb0a830), X(0x6fb9aebd),
1691 X(0x6fc2b24c), X(0x6fcbb2dd), X(0x6fd4b06f), X(0x6fddab03),
1692 X(0x6fe6a299), X(0x6fef9730), X(0x6ff888c9), X(0x70017763),
1693 X(0x700a62ff), X(0x70134b9c), X(0x701c313b), X(0x702513dc),
1694 X(0x702df37e), X(0x7036d021), X(0x703fa9c6), X(0x7048806d),
1695 X(0x70515415), X(0x705a24bf), X(0x7062f26b), X(0x706bbd17),
1696 X(0x707484c6), X(0x707d4976), X(0x70860b28), X(0x708ec9dc),
1697 X(0x70978591), X(0x70a03e48), X(0x70a8f400), X(0x70b1a6bb),
1698 X(0x70ba5677), X(0x70c30335), X(0x70cbacf5), X(0x70d453b6),
1699 X(0x70dcf77a), X(0x70e59840), X(0x70ee3607), X(0x70f6d0d1),
1700 X(0x70ff689d), X(0x7107fd6b), X(0x71108f3b), X(0x71191e0d),
1701 X(0x7121a9e2), X(0x712a32b9), X(0x7132b892), X(0x713b3b6e),
1702 X(0x7143bb4c), X(0x714c382d), X(0x7154b211), X(0x715d28f7),
1703 X(0x71659ce0), X(0x716e0dcc), X(0x71767bbb), X(0x717ee6ac),
1704 X(0x71874ea1), X(0x718fb399), X(0x71981594), X(0x71a07493),
1705 X(0x71a8d094), X(0x71b1299a), X(0x71b97fa2), X(0x71c1d2af),
1706 X(0x71ca22bf), X(0x71d26fd2), X(0x71dab9ea), X(0x71e30106),
1707 X(0x71eb4526), X(0x71f3864a), X(0x71fbc472), X(0x7203ff9e),
1708 X(0x720c37cf), X(0x72146d05), X(0x721c9f3f), X(0x7224ce7e),
1709 X(0x722cfac2), X(0x7235240b), X(0x723d4a59), X(0x72456dad),
1710 X(0x724d8e05), X(0x7255ab63), X(0x725dc5c7), X(0x7265dd31),
1711 X(0x726df1a0), X(0x72760315), X(0x727e1191), X(0x72861d12),
1712 X(0x728e259a), X(0x72962b28), X(0x729e2dbd), X(0x72a62d59),
1713 X(0x72ae29fc), X(0x72b623a5), X(0x72be1a56), X(0x72c60e0e),
1714 X(0x72cdfece), X(0x72d5ec95), X(0x72ddd764), X(0x72e5bf3b),
1715 X(0x72eda41a), X(0x72f58601), X(0x72fd64f1), X(0x730540e9),
1716 X(0x730d19e9), X(0x7314eff3), X(0x731cc305), X(0x73249321),
1717 X(0x732c6046), X(0x73342a75), X(0x733bf1ad), X(0x7343b5ef),
1718 X(0x734b773b), X(0x73533591), X(0x735af0f2), X(0x7362a95d),
1719 X(0x736a5ed3), X(0x73721153), X(0x7379c0df), X(0x73816d76),
1720 X(0x73891719), X(0x7390bdc7), X(0x73986181), X(0x73a00247),
1721 X(0x73a7a01a), X(0x73af3af8), X(0x73b6d2e4), X(0x73be67dc),
1722 X(0x73c5f9e1), X(0x73cd88f3), X(0x73d51513), X(0x73dc9e40),
1723 X(0x73e4247c), X(0x73eba7c5), X(0x73f3281c), X(0x73faa582),
1724 X(0x74021ff7), X(0x7409977b), X(0x74110c0d), X(0x74187daf),
1725 X(0x741fec61), X(0x74275822), X(0x742ec0f3), X(0x743626d5),
1726 X(0x743d89c7), X(0x7444e9c9), X(0x744c46dd), X(0x7453a101),
1727 X(0x745af837), X(0x74624c7f), X(0x74699dd8), X(0x7470ec44),
1728 X(0x747837c2), X(0x747f8052), X(0x7486c5f5), X(0x748e08ac),
1729 X(0x74954875), X(0x749c8552), X(0x74a3bf43), X(0x74aaf648),
1730 X(0x74b22a62), X(0x74b95b90), X(0x74c089d2), X(0x74c7b52a),
1731 X(0x74cedd97), X(0x74d6031a), X(0x74dd25b2), X(0x74e44561),
1732 X(0x74eb6226), X(0x74f27c02), X(0x74f992f5), X(0x7500a6ff),
1733 X(0x7507b820), X(0x750ec659), X(0x7515d1aa), X(0x751cda14),
1734 X(0x7523df96), X(0x752ae231), X(0x7531e1e5), X(0x7538deb2),
1735 X(0x753fd89a), X(0x7546cf9b), X(0x754dc3b7), X(0x7554b4ed),
1736 X(0x755ba33e), X(0x75628eaa), X(0x75697732), X(0x75705cd5),
1737 X(0x75773f95), X(0x757e1f71), X(0x7584fc6a), X(0x758bd67f),
1738 X(0x7592adb2), X(0x75998203), X(0x75a05371), X(0x75a721fe),
1739 X(0x75adeda9), X(0x75b4b673), X(0x75bb7c5c), X(0x75c23f65),
1740 X(0x75c8ff8d), X(0x75cfbcd6), X(0x75d6773f), X(0x75dd2ec8),
1741 X(0x75e3e373), X(0x75ea953f), X(0x75f1442d), X(0x75f7f03d),
1742 X(0x75fe996f), X(0x76053fc5), X(0x760be33d), X(0x761283d8),
1743 X(0x76192197), X(0x761fbc7b), X(0x76265482), X(0x762ce9af),
1744 X(0x76337c01), X(0x763a0b78), X(0x76409814), X(0x764721d7),
1745 X(0x764da8c1), X(0x76542cd1), X(0x765aae08), X(0x76612c67),
1746 X(0x7667a7ee), X(0x766e209d), X(0x76749675), X(0x767b0975),
1747 X(0x7681799f), X(0x7687e6f3), X(0x768e5170), X(0x7694b918),
1748 X(0x769b1deb), X(0x76a17fe9), X(0x76a7df13), X(0x76ae3b68),
1749 X(0x76b494ea), X(0x76baeb98), X(0x76c13f74), X(0x76c7907c),
1750 X(0x76cddeb3), X(0x76d42a18), X(0x76da72ab), X(0x76e0b86d),
1751 X(0x76e6fb5e), X(0x76ed3b7f), X(0x76f378d0), X(0x76f9b352),
1752 X(0x76ffeb05), X(0x77061fe8), X(0x770c51fe), X(0x77128145),
1753 X(0x7718adbf), X(0x771ed76c), X(0x7724fe4c), X(0x772b225f),
1754 X(0x773143a7), X(0x77376223), X(0x773d7dd3), X(0x774396ba),
1755 X(0x7749acd5), X(0x774fc027), X(0x7755d0af), X(0x775bde6f),
1756 X(0x7761e965), X(0x7767f193), X(0x776df6fa), X(0x7773f998),
1757 X(0x7779f970), X(0x777ff681), X(0x7785f0cd), X(0x778be852),
1758 X(0x7791dd12), X(0x7797cf0d), X(0x779dbe43), X(0x77a3aab6),
1759 X(0x77a99465), X(0x77af7b50), X(0x77b55f79), X(0x77bb40e0),
1760 X(0x77c11f85), X(0x77c6fb68), X(0x77ccd48a), X(0x77d2aaec),
1761 X(0x77d87e8d), X(0x77de4f6f), X(0x77e41d92), X(0x77e9e8f5),
1762 X(0x77efb19b), X(0x77f57782), X(0x77fb3aad), X(0x7800fb1a),
1763 X(0x7806b8ca), X(0x780c73bf), X(0x78122bf7), X(0x7817e175),
1764 X(0x781d9438), X(0x78234440), X(0x7828f18f), X(0x782e9c25),
1765 X(0x78344401), X(0x7839e925), X(0x783f8b92), X(0x78452b46),
1766 X(0x784ac844), X(0x7850628b), X(0x7855fa1c), X(0x785b8ef8),
1767 X(0x7861211e), X(0x7866b090), X(0x786c3d4d), X(0x7871c757),
1768 X(0x78774ead), X(0x787cd351), X(0x78825543), X(0x7887d483),
1769 X(0x788d5111), X(0x7892caef), X(0x7898421c), X(0x789db69a),
1770 X(0x78a32868), X(0x78a89787), X(0x78ae03f8), X(0x78b36dbb),
1771 X(0x78b8d4d1), X(0x78be393a), X(0x78c39af6), X(0x78c8fa06),
1772 X(0x78ce566c), X(0x78d3b026), X(0x78d90736), X(0x78de5b9c),
1773 X(0x78e3ad58), X(0x78e8fc6c), X(0x78ee48d7), X(0x78f3929b),
1774 X(0x78f8d9b7), X(0x78fe1e2c), X(0x79035ffb), X(0x79089f24),
1775 X(0x790ddba8), X(0x79131587), X(0x79184cc2), X(0x791d8159),
1776 X(0x7922b34d), X(0x7927e29e), X(0x792d0f4d), X(0x7932395a),
1777 X(0x793760c6), X(0x793c8591), X(0x7941a7bd), X(0x7946c749),
1778 X(0x794be435), X(0x7950fe84), X(0x79561634), X(0x795b2b47),
1779 X(0x79603dbc), X(0x79654d96), X(0x796a5ad4), X(0x796f6576),
1780 X(0x79746d7e), X(0x797972eb), X(0x797e75bf), X(0x798375f9),
1781 X(0x7988739b), X(0x798d6ea5), X(0x79926717), X(0x79975cf2),
1782 X(0x799c5037), X(0x79a140e6), X(0x79a62f00), X(0x79ab1a85),
1783 X(0x79b00376), X(0x79b4e9d3), X(0x79b9cd9d), X(0x79beaed4),
1784 X(0x79c38d79), X(0x79c8698d), X(0x79cd4310), X(0x79d21a03),
1785 X(0x79d6ee66), X(0x79dbc03a), X(0x79e08f7f), X(0x79e55c36),
1786 X(0x79ea265f), X(0x79eeedfc), X(0x79f3b30c), X(0x79f87590),
1787 X(0x79fd3589), X(0x7a01f2f7), X(0x7a06addc), X(0x7a0b6636),
1788 X(0x7a101c08), X(0x7a14cf52), X(0x7a198013), X(0x7a1e2e4d),
1789 X(0x7a22da01), X(0x7a27832f), X(0x7a2c29d7), X(0x7a30cdfa),
1790 X(0x7a356f99), X(0x7a3a0eb4), X(0x7a3eab4c), X(0x7a434561),
1791 X(0x7a47dcf5), X(0x7a4c7207), X(0x7a510498), X(0x7a5594a9),
1792 X(0x7a5a223a), X(0x7a5ead4d), X(0x7a6335e0), X(0x7a67bbf6),
1793 X(0x7a6c3f8f), X(0x7a70c0ab), X(0x7a753f4b), X(0x7a79bb6f),
1794 X(0x7a7e3519), X(0x7a82ac48), X(0x7a8720fe), X(0x7a8b933b),
1795 X(0x7a9002ff), X(0x7a94704b), X(0x7a98db20), X(0x7a9d437e),
1796 X(0x7aa1a967), X(0x7aa60cd9), X(0x7aaa6dd7), X(0x7aaecc61),
1797 X(0x7ab32877), X(0x7ab7821b), X(0x7abbd94b), X(0x7ac02e0a),
1798 X(0x7ac48058), X(0x7ac8d035), X(0x7acd1da3), X(0x7ad168a1),
1799 X(0x7ad5b130), X(0x7ad9f751), X(0x7ade3b05), X(0x7ae27c4c),
1800 X(0x7ae6bb27), X(0x7aeaf796), X(0x7aef319a), X(0x7af36934),
1801 X(0x7af79e64), X(0x7afbd12c), X(0x7b00018a), X(0x7b042f81),
1802 X(0x7b085b10), X(0x7b0c8439), X(0x7b10aafc), X(0x7b14cf5a),
1803 X(0x7b18f153), X(0x7b1d10e8), X(0x7b212e1a), X(0x7b2548e9),
1804 X(0x7b296155), X(0x7b2d7761), X(0x7b318b0b), X(0x7b359c55),
1805 X(0x7b39ab3f), X(0x7b3db7cb), X(0x7b41c1f8), X(0x7b45c9c8),
1806 X(0x7b49cf3b), X(0x7b4dd251), X(0x7b51d30b), X(0x7b55d16b),
1807 X(0x7b59cd70), X(0x7b5dc71b), X(0x7b61be6d), X(0x7b65b366),
1808 X(0x7b69a608), X(0x7b6d9653), X(0x7b718447), X(0x7b756fe5),
1809 X(0x7b79592e), X(0x7b7d4022), X(0x7b8124c3), X(0x7b850710),
1810 X(0x7b88e70a), X(0x7b8cc4b3), X(0x7b90a00a), X(0x7b947911),
1811 X(0x7b984fc8), X(0x7b9c242f), X(0x7b9ff648), X(0x7ba3c612),
1812 X(0x7ba79390), X(0x7bab5ec1), X(0x7baf27a5), X(0x7bb2ee3f),
1813 X(0x7bb6b28e), X(0x7bba7493), X(0x7bbe344e), X(0x7bc1f1c1),
1814 X(0x7bc5acec), X(0x7bc965cf), X(0x7bcd1c6c), X(0x7bd0d0c3),
1815 X(0x7bd482d4), X(0x7bd832a1), X(0x7bdbe02a), X(0x7bdf8b70),
1816 X(0x7be33473), X(0x7be6db34), X(0x7bea7fb4), X(0x7bee21f4),
1817 X(0x7bf1c1f3), X(0x7bf55fb3), X(0x7bf8fb35), X(0x7bfc9479),
1818 X(0x7c002b7f), X(0x7c03c04a), X(0x7c0752d8), X(0x7c0ae32b),
1819 X(0x7c0e7144), X(0x7c11fd23), X(0x7c1586c9), X(0x7c190e36),
1820 X(0x7c1c936c), X(0x7c20166b), X(0x7c239733), X(0x7c2715c6),
1821 X(0x7c2a9224), X(0x7c2e0c4e), X(0x7c318444), X(0x7c34fa07),
1822 X(0x7c386d98), X(0x7c3bdef8), X(0x7c3f4e26), X(0x7c42bb25),
1823 X(0x7c4625f4), X(0x7c498e95), X(0x7c4cf507), X(0x7c50594c),
1824 X(0x7c53bb65), X(0x7c571b51), X(0x7c5a7913), X(0x7c5dd4aa),
1825 X(0x7c612e17), X(0x7c64855b), X(0x7c67da76), X(0x7c6b2d6a),
1826 X(0x7c6e7e37), X(0x7c71ccdd), X(0x7c75195e), X(0x7c7863ba),
1827 X(0x7c7babf1), X(0x7c7ef206), X(0x7c8235f7), X(0x7c8577c6),
1828 X(0x7c88b774), X(0x7c8bf502), X(0x7c8f306f), X(0x7c9269bd),
1829 X(0x7c95a0ec), X(0x7c98d5fe), X(0x7c9c08f2), X(0x7c9f39cb),
1830 X(0x7ca26887), X(0x7ca59528), X(0x7ca8bfb0), X(0x7cabe81d),
1831 X(0x7caf0e72), X(0x7cb232af), X(0x7cb554d4), X(0x7cb874e2),
1832 X(0x7cbb92db), X(0x7cbeaebe), X(0x7cc1c88d), X(0x7cc4e047),
1833 X(0x7cc7f5ef), X(0x7ccb0984), X(0x7cce1b08), X(0x7cd12a7b),
1834 X(0x7cd437dd), X(0x7cd74330), X(0x7cda4c74), X(0x7cdd53aa),
1835 X(0x7ce058d3), X(0x7ce35bef), X(0x7ce65cff), X(0x7ce95c04),
1836 X(0x7cec58ff), X(0x7cef53f0), X(0x7cf24cd7), X(0x7cf543b7),
1837 X(0x7cf8388f), X(0x7cfb2b60), X(0x7cfe1c2b), X(0x7d010af1),
1838 X(0x7d03f7b2), X(0x7d06e26f), X(0x7d09cb29), X(0x7d0cb1e0),
1839 X(0x7d0f9696), X(0x7d12794b), X(0x7d1559ff), X(0x7d1838b4),
1840 X(0x7d1b156a), X(0x7d1df022), X(0x7d20c8dd), X(0x7d239f9b),
1841 X(0x7d26745e), X(0x7d294725), X(0x7d2c17f1), X(0x7d2ee6c4),
1842 X(0x7d31b39f), X(0x7d347e81), X(0x7d37476b), X(0x7d3a0e5f),
1843 X(0x7d3cd35d), X(0x7d3f9665), X(0x7d425779), X(0x7d451699),
1844 X(0x7d47d3c6), X(0x7d4a8f01), X(0x7d4d484b), X(0x7d4fffa3),
1845 X(0x7d52b50c), X(0x7d556885), X(0x7d581a0f), X(0x7d5ac9ac),
1846 X(0x7d5d775c), X(0x7d60231f), X(0x7d62ccf6), X(0x7d6574e3),
1847 X(0x7d681ae6), X(0x7d6abeff), X(0x7d6d612f), X(0x7d700178),
1848 X(0x7d729fd9), X(0x7d753c54), X(0x7d77d6e9), X(0x7d7a6f9a),
1849 X(0x7d7d0666), X(0x7d7f9b4f), X(0x7d822e55), X(0x7d84bf79),
1850 X(0x7d874ebc), X(0x7d89dc1e), X(0x7d8c67a1), X(0x7d8ef144),
1851 X(0x7d91790a), X(0x7d93fef2), X(0x7d9682fd), X(0x7d99052d),
1852 X(0x7d9b8581), X(0x7d9e03fb), X(0x7da0809b), X(0x7da2fb62),
1853 X(0x7da57451), X(0x7da7eb68), X(0x7daa60a8), X(0x7dacd413),
1854 X(0x7daf45a9), X(0x7db1b56a), X(0x7db42357), X(0x7db68f71),
1855 X(0x7db8f9b9), X(0x7dbb6230), X(0x7dbdc8d6), X(0x7dc02dac),
1856 X(0x7dc290b3), X(0x7dc4f1eb), X(0x7dc75156), X(0x7dc9aef4),
1857 X(0x7dcc0ac5), X(0x7dce64cc), X(0x7dd0bd07), X(0x7dd31379),
1858 X(0x7dd56821), X(0x7dd7bb01), X(0x7dda0c1a), X(0x7ddc5b6b),
1859 X(0x7ddea8f7), X(0x7de0f4bd), X(0x7de33ebe), X(0x7de586fc),
1860 X(0x7de7cd76), X(0x7dea122e), X(0x7dec5525), X(0x7dee965a),
1861 X(0x7df0d5d0), X(0x7df31386), X(0x7df54f7e), X(0x7df789b8),
1862 X(0x7df9c235), X(0x7dfbf8f5), X(0x7dfe2dfa), X(0x7e006145),
1863 X(0x7e0292d5), X(0x7e04c2ac), X(0x7e06f0cb), X(0x7e091d32),
1864 X(0x7e0b47e1), X(0x7e0d70db), X(0x7e0f981f), X(0x7e11bdaf),
1865 X(0x7e13e18a), X(0x7e1603b3), X(0x7e182429), X(0x7e1a42ed),
1866 X(0x7e1c6001), X(0x7e1e7b64), X(0x7e209518), X(0x7e22ad1d),
1867 X(0x7e24c375), X(0x7e26d81f), X(0x7e28eb1d), X(0x7e2afc70),
1868 X(0x7e2d0c17), X(0x7e2f1a15), X(0x7e31266a), X(0x7e333115),
1869 X(0x7e353a1a), X(0x7e374177), X(0x7e39472e), X(0x7e3b4b3f),
1870 X(0x7e3d4dac), X(0x7e3f4e75), X(0x7e414d9a), X(0x7e434b1e),
1871 X(0x7e4546ff), X(0x7e474140), X(0x7e4939e0), X(0x7e4b30e2),
1872 X(0x7e4d2644), X(0x7e4f1a09), X(0x7e510c30), X(0x7e52fcbc),
1873 X(0x7e54ebab), X(0x7e56d900), X(0x7e58c4bb), X(0x7e5aaedd),
1874 X(0x7e5c9766), X(0x7e5e7e57), X(0x7e6063b2), X(0x7e624776),
1875 X(0x7e6429a5), X(0x7e660a3f), X(0x7e67e945), X(0x7e69c6b8),
1876 X(0x7e6ba299), X(0x7e6d7ce7), X(0x7e6f55a5), X(0x7e712cd3),
1877 X(0x7e730272), X(0x7e74d682), X(0x7e76a904), X(0x7e7879f9),
1878 X(0x7e7a4962), X(0x7e7c173f), X(0x7e7de392), X(0x7e7fae5a),
1879 X(0x7e817799), X(0x7e833f50), X(0x7e85057f), X(0x7e86ca27),
1880 X(0x7e888d49), X(0x7e8a4ee5), X(0x7e8c0efd), X(0x7e8dcd91),
1881 X(0x7e8f8aa1), X(0x7e914630), X(0x7e93003c), X(0x7e94b8c8),
1882 X(0x7e966fd4), X(0x7e982560), X(0x7e99d96e), X(0x7e9b8bfe),
1883 X(0x7e9d3d10), X(0x7e9eeca7), X(0x7ea09ac2), X(0x7ea24762),
1884 X(0x7ea3f288), X(0x7ea59c35), X(0x7ea7446a), X(0x7ea8eb27),
1885 X(0x7eaa906c), X(0x7eac343c), X(0x7eadd696), X(0x7eaf777b),
1886 X(0x7eb116ed), X(0x7eb2b4eb), X(0x7eb45177), X(0x7eb5ec91),
1887 X(0x7eb7863b), X(0x7eb91e74), X(0x7ebab53e), X(0x7ebc4a99),
1888 X(0x7ebdde87), X(0x7ebf7107), X(0x7ec1021b), X(0x7ec291c3),
1889 X(0x7ec42001), X(0x7ec5acd5), X(0x7ec7383f), X(0x7ec8c241),
1890 X(0x7eca4adb), X(0x7ecbd20d), X(0x7ecd57da), X(0x7ecedc41),
1891 X(0x7ed05f44), X(0x7ed1e0e2), X(0x7ed3611d), X(0x7ed4dff6),
1892 X(0x7ed65d6d), X(0x7ed7d983), X(0x7ed95438), X(0x7edacd8f),
1893 X(0x7edc4586), X(0x7eddbc20), X(0x7edf315c), X(0x7ee0a53c),
1894 X(0x7ee217c1), X(0x7ee388ea), X(0x7ee4f8b9), X(0x7ee6672f),
1895 X(0x7ee7d44c), X(0x7ee94012), X(0x7eeaaa80), X(0x7eec1397),
1896 X(0x7eed7b59), X(0x7eeee1c6), X(0x7ef046df), X(0x7ef1aaa5),
1897 X(0x7ef30d18), X(0x7ef46e39), X(0x7ef5ce09), X(0x7ef72c88),
1898 X(0x7ef889b8), X(0x7ef9e599), X(0x7efb402c), X(0x7efc9972),
1899 X(0x7efdf16b), X(0x7eff4818), X(0x7f009d79), X(0x7f01f191),
1900 X(0x7f03445f), X(0x7f0495e4), X(0x7f05e620), X(0x7f073516),
1901 X(0x7f0882c5), X(0x7f09cf2d), X(0x7f0b1a51), X(0x7f0c6430),
1902 X(0x7f0daccc), X(0x7f0ef425), X(0x7f103a3b), X(0x7f117f11),
1903 X(0x7f12c2a5), X(0x7f1404fa), X(0x7f15460f), X(0x7f1685e6),
1904 X(0x7f17c47f), X(0x7f1901db), X(0x7f1a3dfb), X(0x7f1b78e0),
1905 X(0x7f1cb28a), X(0x7f1deafa), X(0x7f1f2231), X(0x7f20582f),
1906 X(0x7f218cf5), X(0x7f22c085), X(0x7f23f2de), X(0x7f252401),
1907 X(0x7f2653f0), X(0x7f2782ab), X(0x7f28b032), X(0x7f29dc87),
1908 X(0x7f2b07aa), X(0x7f2c319c), X(0x7f2d5a5e), X(0x7f2e81f0),
1909 X(0x7f2fa853), X(0x7f30cd88), X(0x7f31f18f), X(0x7f33146a),
1910 X(0x7f343619), X(0x7f35569c), X(0x7f3675f6), X(0x7f379425),
1911 X(0x7f38b12c), X(0x7f39cd0a), X(0x7f3ae7c0), X(0x7f3c0150),
1912 X(0x7f3d19ba), X(0x7f3e30fe), X(0x7f3f471e), X(0x7f405c1a),
1913 X(0x7f416ff3), X(0x7f4282a9), X(0x7f43943e), X(0x7f44a4b2),
1914 X(0x7f45b405), X(0x7f46c239), X(0x7f47cf4e), X(0x7f48db45),
1915 X(0x7f49e61f), X(0x7f4aefdc), X(0x7f4bf87e), X(0x7f4d0004),
1916 X(0x7f4e0670), X(0x7f4f0bc2), X(0x7f500ffb), X(0x7f51131c),
1917 X(0x7f521525), X(0x7f531618), X(0x7f5415f4), X(0x7f5514bb),
1918 X(0x7f56126e), X(0x7f570f0c), X(0x7f580a98), X(0x7f590511),
1919 X(0x7f59fe78), X(0x7f5af6ce), X(0x7f5bee14), X(0x7f5ce44a),
1920 X(0x7f5dd972), X(0x7f5ecd8b), X(0x7f5fc097), X(0x7f60b296),
1921 X(0x7f61a389), X(0x7f629370), X(0x7f63824e), X(0x7f647021),
1922 X(0x7f655ceb), X(0x7f6648ad), X(0x7f673367), X(0x7f681d19),
1923 X(0x7f6905c6), X(0x7f69ed6d), X(0x7f6ad40f), X(0x7f6bb9ad),
1924 X(0x7f6c9e48), X(0x7f6d81e0), X(0x7f6e6475), X(0x7f6f460a),
1925 X(0x7f70269d), X(0x7f710631), X(0x7f71e4c6), X(0x7f72c25c),
1926 X(0x7f739ef4), X(0x7f747a8f), X(0x7f75552e), X(0x7f762ed1),
1927 X(0x7f770779), X(0x7f77df27), X(0x7f78b5db), X(0x7f798b97),
1928 X(0x7f7a605a), X(0x7f7b3425), X(0x7f7c06fa), X(0x7f7cd8d9),
1929 X(0x7f7da9c2), X(0x7f7e79b7), X(0x7f7f48b8), X(0x7f8016c5),
1930 X(0x7f80e3e0), X(0x7f81b009), X(0x7f827b40), X(0x7f834588),
1931 X(0x7f840edf), X(0x7f84d747), X(0x7f859ec1), X(0x7f86654d),
1932 X(0x7f872aec), X(0x7f87ef9e), X(0x7f88b365), X(0x7f897641),
1933 X(0x7f8a3832), X(0x7f8af93a), X(0x7f8bb959), X(0x7f8c7890),
1934 X(0x7f8d36df), X(0x7f8df448), X(0x7f8eb0ca), X(0x7f8f6c67),
1935 X(0x7f90271e), X(0x7f90e0f2), X(0x7f9199e2), X(0x7f9251f0),
1936 X(0x7f93091b), X(0x7f93bf65), X(0x7f9474ce), X(0x7f952958),
1937 X(0x7f95dd01), X(0x7f968fcd), X(0x7f9741ba), X(0x7f97f2ca),
1938 X(0x7f98a2fd), X(0x7f995254), X(0x7f9a00d0), X(0x7f9aae71),
1939 X(0x7f9b5b38), X(0x7f9c0726), X(0x7f9cb23b), X(0x7f9d5c78),
1940 X(0x7f9e05de), X(0x7f9eae6e), X(0x7f9f5627), X(0x7f9ffd0b),
1941 X(0x7fa0a31b), X(0x7fa14856), X(0x7fa1ecbf), X(0x7fa29054),
1942 X(0x7fa33318), X(0x7fa3d50b), X(0x7fa4762c), X(0x7fa5167e),
1943 X(0x7fa5b601), X(0x7fa654b5), X(0x7fa6f29b), X(0x7fa78fb3),
1944 X(0x7fa82bff), X(0x7fa8c77f), X(0x7fa96234), X(0x7fa9fc1e),
1945 X(0x7faa953e), X(0x7fab2d94), X(0x7fabc522), X(0x7fac5be8),
1946 X(0x7facf1e6), X(0x7fad871d), X(0x7fae1b8f), X(0x7faeaf3b),
1947 X(0x7faf4222), X(0x7fafd445), X(0x7fb065a4), X(0x7fb0f641),
1948 X(0x7fb1861b), X(0x7fb21534), X(0x7fb2a38c), X(0x7fb33124),
1949 X(0x7fb3bdfb), X(0x7fb44a14), X(0x7fb4d56f), X(0x7fb5600c),
1950 X(0x7fb5e9ec), X(0x7fb6730f), X(0x7fb6fb76), X(0x7fb78323),
1951 X(0x7fb80a15), X(0x7fb8904d), X(0x7fb915cc), X(0x7fb99a92),
1952 X(0x7fba1ea0), X(0x7fbaa1f7), X(0x7fbb2497), X(0x7fbba681),
1953 X(0x7fbc27b5), X(0x7fbca835), X(0x7fbd2801), X(0x7fbda719),
1954 X(0x7fbe257e), X(0x7fbea331), X(0x7fbf2032), X(0x7fbf9c82),
1955 X(0x7fc01821), X(0x7fc09311), X(0x7fc10d52), X(0x7fc186e4),
1956 X(0x7fc1ffc8), X(0x7fc277ff), X(0x7fc2ef89), X(0x7fc36667),
1957 X(0x7fc3dc9a), X(0x7fc45221), X(0x7fc4c6ff), X(0x7fc53b33),
1958 X(0x7fc5aebe), X(0x7fc621a0), X(0x7fc693db), X(0x7fc7056f),
1959 X(0x7fc7765c), X(0x7fc7e6a3), X(0x7fc85645), X(0x7fc8c542),
1960 X(0x7fc9339b), X(0x7fc9a150), X(0x7fca0e63), X(0x7fca7ad3),
1961 X(0x7fcae6a2), X(0x7fcb51cf), X(0x7fcbbc5c), X(0x7fcc2649),
1962 X(0x7fcc8f97), X(0x7fccf846), X(0x7fcd6058), X(0x7fcdc7cb),
1963 X(0x7fce2ea2), X(0x7fce94dd), X(0x7fcefa7b), X(0x7fcf5f7f),
1964 X(0x7fcfc3e8), X(0x7fd027b7), X(0x7fd08aed), X(0x7fd0ed8b),
1965 X(0x7fd14f90), X(0x7fd1b0fd), X(0x7fd211d4), X(0x7fd27214),
1966 X(0x7fd2d1bf), X(0x7fd330d4), X(0x7fd38f55), X(0x7fd3ed41),
1967 X(0x7fd44a9a), X(0x7fd4a761), X(0x7fd50395), X(0x7fd55f37),
1968 X(0x7fd5ba48), X(0x7fd614c9), X(0x7fd66eba), X(0x7fd6c81b),
1969 X(0x7fd720ed), X(0x7fd77932), X(0x7fd7d0e8), X(0x7fd82812),
1970 X(0x7fd87eae), X(0x7fd8d4bf), X(0x7fd92a45), X(0x7fd97f40),
1971 X(0x7fd9d3b0), X(0x7fda2797), X(0x7fda7af5), X(0x7fdacdca),
1972 X(0x7fdb2018), X(0x7fdb71dd), X(0x7fdbc31c), X(0x7fdc13d5),
1973 X(0x7fdc6408), X(0x7fdcb3b6), X(0x7fdd02df), X(0x7fdd5184),
1974 X(0x7fdd9fa5), X(0x7fdded44), X(0x7fde3a60), X(0x7fde86fb),
1975 X(0x7fded314), X(0x7fdf1eac), X(0x7fdf69c4), X(0x7fdfb45d),
1976 X(0x7fdffe76), X(0x7fe04811), X(0x7fe0912e), X(0x7fe0d9ce),
1977 X(0x7fe121f0), X(0x7fe16996), X(0x7fe1b0c1), X(0x7fe1f770),
1978 X(0x7fe23da4), X(0x7fe2835f), X(0x7fe2c89f), X(0x7fe30d67),
1979 X(0x7fe351b5), X(0x7fe3958c), X(0x7fe3d8ec), X(0x7fe41bd4),
1980 X(0x7fe45e46), X(0x7fe4a042), X(0x7fe4e1c8), X(0x7fe522da),
1981 X(0x7fe56378), X(0x7fe5a3a1), X(0x7fe5e358), X(0x7fe6229b),
1982 X(0x7fe6616d), X(0x7fe69fcc), X(0x7fe6ddbb), X(0x7fe71b39),
1983 X(0x7fe75847), X(0x7fe794e5), X(0x7fe7d114), X(0x7fe80cd5),
1984 X(0x7fe84827), X(0x7fe8830c), X(0x7fe8bd84), X(0x7fe8f78f),
1985 X(0x7fe9312f), X(0x7fe96a62), X(0x7fe9a32b), X(0x7fe9db8a),
1986 X(0x7fea137e), X(0x7fea4b09), X(0x7fea822b), X(0x7feab8e5),
1987 X(0x7feaef37), X(0x7feb2521), X(0x7feb5aa4), X(0x7feb8fc1),
1988 X(0x7febc478), X(0x7febf8ca), X(0x7fec2cb6), X(0x7fec603e),
1989 X(0x7fec9363), X(0x7fecc623), X(0x7fecf881), X(0x7fed2a7c),
1990 X(0x7fed5c16), X(0x7fed8d4e), X(0x7fedbe24), X(0x7fedee9b),
1991 X(0x7fee1eb1), X(0x7fee4e68), X(0x7fee7dc0), X(0x7feeacb9),
1992 X(0x7feedb54), X(0x7fef0991), X(0x7fef3771), X(0x7fef64f5),
1993 X(0x7fef921d), X(0x7fefbee8), X(0x7fefeb59), X(0x7ff0176f),
1994 X(0x7ff0432a), X(0x7ff06e8c), X(0x7ff09995), X(0x7ff0c444),
1995 X(0x7ff0ee9c), X(0x7ff1189b), X(0x7ff14243), X(0x7ff16b94),
1996 X(0x7ff1948e), X(0x7ff1bd32), X(0x7ff1e581), X(0x7ff20d7b),
1997 X(0x7ff2351f), X(0x7ff25c70), X(0x7ff2836d), X(0x7ff2aa17),
1998 X(0x7ff2d06d), X(0x7ff2f672), X(0x7ff31c24), X(0x7ff34185),
1999 X(0x7ff36695), X(0x7ff38b55), X(0x7ff3afc4), X(0x7ff3d3e4),
2000 X(0x7ff3f7b4), X(0x7ff41b35), X(0x7ff43e69), X(0x7ff4614e),
2001 X(0x7ff483e6), X(0x7ff4a631), X(0x7ff4c82f), X(0x7ff4e9e1),
2002 X(0x7ff50b47), X(0x7ff52c62), X(0x7ff54d33), X(0x7ff56db9),
2003 X(0x7ff58df5), X(0x7ff5ade7), X(0x7ff5cd90), X(0x7ff5ecf1),
2004 X(0x7ff60c09), X(0x7ff62ada), X(0x7ff64963), X(0x7ff667a5),
2005 X(0x7ff685a1), X(0x7ff6a357), X(0x7ff6c0c7), X(0x7ff6ddf1),
2006 X(0x7ff6fad7), X(0x7ff71778), X(0x7ff733d6), X(0x7ff74fef),
2007 X(0x7ff76bc6), X(0x7ff78759), X(0x7ff7a2ab), X(0x7ff7bdba),
2008 X(0x7ff7d888), X(0x7ff7f315), X(0x7ff80d61), X(0x7ff8276c),
2009 X(0x7ff84138), X(0x7ff85ac4), X(0x7ff87412), X(0x7ff88d20),
2010 X(0x7ff8a5f0), X(0x7ff8be82), X(0x7ff8d6d7), X(0x7ff8eeef),
2011 X(0x7ff906c9), X(0x7ff91e68), X(0x7ff935cb), X(0x7ff94cf2),
2012 X(0x7ff963dd), X(0x7ff97a8f), X(0x7ff99105), X(0x7ff9a742),
2013 X(0x7ff9bd45), X(0x7ff9d30f), X(0x7ff9e8a0), X(0x7ff9fdf9),
2014 X(0x7ffa131a), X(0x7ffa2803), X(0x7ffa3cb4), X(0x7ffa512f),
2015 X(0x7ffa6573), X(0x7ffa7981), X(0x7ffa8d59), X(0x7ffaa0fc),
2016 X(0x7ffab46a), X(0x7ffac7a3), X(0x7ffadaa8), X(0x7ffaed78),
2017 X(0x7ffb0015), X(0x7ffb127f), X(0x7ffb24b6), X(0x7ffb36bb),
2018 X(0x7ffb488d), X(0x7ffb5a2e), X(0x7ffb6b9d), X(0x7ffb7cdb),
2019 X(0x7ffb8de9), X(0x7ffb9ec6), X(0x7ffbaf73), X(0x7ffbbff1),
2020 X(0x7ffbd03f), X(0x7ffbe05e), X(0x7ffbf04f), X(0x7ffc0012),
2021 X(0x7ffc0fa6), X(0x7ffc1f0d), X(0x7ffc2e47), X(0x7ffc3d54),
2022 X(0x7ffc4c35), X(0x7ffc5ae9), X(0x7ffc6971), X(0x7ffc77ce),
2023 X(0x7ffc8600), X(0x7ffc9407), X(0x7ffca1e4), X(0x7ffcaf96),
2024 X(0x7ffcbd1f), X(0x7ffcca7e), X(0x7ffcd7b4), X(0x7ffce4c1),
2025 X(0x7ffcf1a5), X(0x7ffcfe62), X(0x7ffd0af6), X(0x7ffd1763),
2026 X(0x7ffd23a9), X(0x7ffd2fc8), X(0x7ffd3bc1), X(0x7ffd4793),
2027 X(0x7ffd533f), X(0x7ffd5ec5), X(0x7ffd6a27), X(0x7ffd7563),
2028 X(0x7ffd807a), X(0x7ffd8b6e), X(0x7ffd963d), X(0x7ffda0e8),
2029 X(0x7ffdab70), X(0x7ffdb5d5), X(0x7ffdc017), X(0x7ffdca36),
2030 X(0x7ffdd434), X(0x7ffdde0f), X(0x7ffde7c9), X(0x7ffdf161),
2031 X(0x7ffdfad8), X(0x7ffe042f), X(0x7ffe0d65), X(0x7ffe167b),
2032 X(0x7ffe1f71), X(0x7ffe2848), X(0x7ffe30ff), X(0x7ffe3997),
2033 X(0x7ffe4211), X(0x7ffe4a6c), X(0x7ffe52a9), X(0x7ffe5ac8),
2034 X(0x7ffe62c9), X(0x7ffe6aae), X(0x7ffe7275), X(0x7ffe7a1f),
2035 X(0x7ffe81ad), X(0x7ffe891f), X(0x7ffe9075), X(0x7ffe97b0),
2036 X(0x7ffe9ece), X(0x7ffea5d2), X(0x7ffeacbb), X(0x7ffeb38a),
2037 X(0x7ffeba3e), X(0x7ffec0d8), X(0x7ffec758), X(0x7ffecdbf),
2038 X(0x7ffed40d), X(0x7ffeda41), X(0x7ffee05d), X(0x7ffee660),
2039 X(0x7ffeec4b), X(0x7ffef21f), X(0x7ffef7da), X(0x7ffefd7e),
2040 X(0x7fff030b), X(0x7fff0881), X(0x7fff0de0), X(0x7fff1328),
2041 X(0x7fff185b), X(0x7fff1d77), X(0x7fff227e), X(0x7fff276f),
2042 X(0x7fff2c4b), X(0x7fff3112), X(0x7fff35c4), X(0x7fff3a62),
2043 X(0x7fff3eeb), X(0x7fff4360), X(0x7fff47c2), X(0x7fff4c0f),
2044 X(0x7fff504a), X(0x7fff5471), X(0x7fff5885), X(0x7fff5c87),
2045 X(0x7fff6076), X(0x7fff6452), X(0x7fff681d), X(0x7fff6bd6),
2046 X(0x7fff6f7d), X(0x7fff7313), X(0x7fff7698), X(0x7fff7a0c),
2047 X(0x7fff7d6f), X(0x7fff80c2), X(0x7fff8404), X(0x7fff8736),
2048 X(0x7fff8a58), X(0x7fff8d6b), X(0x7fff906e), X(0x7fff9362),
2049 X(0x7fff9646), X(0x7fff991c), X(0x7fff9be3), X(0x7fff9e9c),
2050 X(0x7fffa146), X(0x7fffa3e2), X(0x7fffa671), X(0x7fffa8f1),
2051 X(0x7fffab65), X(0x7fffadca), X(0x7fffb023), X(0x7fffb26f),
2052 X(0x7fffb4ae), X(0x7fffb6e0), X(0x7fffb906), X(0x7fffbb20),
2053 X(0x7fffbd2e), X(0x7fffbf30), X(0x7fffc126), X(0x7fffc311),
2054 X(0x7fffc4f1), X(0x7fffc6c5), X(0x7fffc88f), X(0x7fffca4d),
2055 X(0x7fffcc01), X(0x7fffcdab), X(0x7fffcf4a), X(0x7fffd0e0),
2056 X(0x7fffd26b), X(0x7fffd3ec), X(0x7fffd564), X(0x7fffd6d2),
2057 X(0x7fffd838), X(0x7fffd993), X(0x7fffdae6), X(0x7fffdc31),
2058 X(0x7fffdd72), X(0x7fffdeab), X(0x7fffdfdb), X(0x7fffe104),
2059 X(0x7fffe224), X(0x7fffe33c), X(0x7fffe44d), X(0x7fffe556),
2060 X(0x7fffe657), X(0x7fffe751), X(0x7fffe844), X(0x7fffe930),
2061 X(0x7fffea15), X(0x7fffeaf3), X(0x7fffebca), X(0x7fffec9b),
2062 X(0x7fffed66), X(0x7fffee2a), X(0x7fffeee8), X(0x7fffefa0),
2063 X(0x7ffff053), X(0x7ffff0ff), X(0x7ffff1a6), X(0x7ffff247),
2064 X(0x7ffff2e4), X(0x7ffff37a), X(0x7ffff40c), X(0x7ffff499),
2065 X(0x7ffff520), X(0x7ffff5a3), X(0x7ffff621), X(0x7ffff69b),
2066 X(0x7ffff710), X(0x7ffff781), X(0x7ffff7ee), X(0x7ffff857),
2067 X(0x7ffff8bb), X(0x7ffff91c), X(0x7ffff979), X(0x7ffff9d2),
2068 X(0x7ffffa27), X(0x7ffffa79), X(0x7ffffac8), X(0x7ffffb13),
2069 X(0x7ffffb5b), X(0x7ffffba0), X(0x7ffffbe2), X(0x7ffffc21),
2070 X(0x7ffffc5d), X(0x7ffffc96), X(0x7ffffccd), X(0x7ffffd01),
2071 X(0x7ffffd32), X(0x7ffffd61), X(0x7ffffd8e), X(0x7ffffdb8),
2072 X(0x7ffffde0), X(0x7ffffe07), X(0x7ffffe2b), X(0x7ffffe4d),
2073 X(0x7ffffe6d), X(0x7ffffe8b), X(0x7ffffea8), X(0x7ffffec3),
2074 X(0x7ffffedc), X(0x7ffffef4), X(0x7fffff0a), X(0x7fffff1f),
2075 X(0x7fffff33), X(0x7fffff45), X(0x7fffff56), X(0x7fffff66),
2076 X(0x7fffff75), X(0x7fffff82), X(0x7fffff8f), X(0x7fffff9a),
2077 X(0x7fffffa5), X(0x7fffffaf), X(0x7fffffb8), X(0x7fffffc0),
2078 X(0x7fffffc8), X(0x7fffffce), X(0x7fffffd5), X(0x7fffffda),
2079 X(0x7fffffdf), X(0x7fffffe4), X(0x7fffffe8), X(0x7fffffeb),
2080 X(0x7fffffef), X(0x7ffffff1), X(0x7ffffff4), X(0x7ffffff6),
2081 X(0x7ffffff8), X(0x7ffffff9), X(0x7ffffffb), X(0x7ffffffc),
2082 X(0x7ffffffd), X(0x7ffffffd), X(0x7ffffffe), X(0x7fffffff),
2083 X(0x7fffffff), X(0x7fffffff), X(0x7fffffff), X(0x7fffffff),
2084 X(0x7fffffff), X(0x7fffffff), X(0x7fffffff), X(0x7fffffff),
2085 X(0x7fffffff), X(0x7fffffff), X(0x7fffffff), X(0x7fffffff),
2086};
2087