shithub: aacdec

Download patch

ref: 283d7384fb6480fdfa6ef47cf28bfb83d5d7329b
parent: 8890a518126adebba303763033fcd6de015a0305
author: menno <menno>
date: Fri Feb 15 15:52:10 EST 2002

- complete new huffman decoding routines
- complete new bitstream reading routines

diff: cannot open b/libfaad/codebook//null: file does not exist: 'b/libfaad/codebook//null'
--- a/libfaad/bits.c
+++ b/libfaad/bits.c
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: bits.c,v 1.3 2002/01/19 16:19:54 menno Exp $
+** $Id: bits.c,v 1.4 2002/02/15 20:52:09 menno Exp $
 **/
 
 #include "bits.h"
@@ -23,28 +23,41 @@
 
 
 /* initialize buffer, call once before first getbits or showbits */
-void faad_initbits(bitfile *ld, unsigned char *buffer)
+void faad_initbits(bitfile *ld, void *buffer)
 {
-    ld->incnt = 0;
-    ld->framebits = 0;
-    ld->bitcnt = 0;
-    ld->rdptr = buffer;
+    unsigned long tmp;
+
+    ld->start = (unsigned long*)buffer;
+
+    tmp = *(unsigned long*)buffer;
+#ifndef ARCH_IS_BIG_ENDIAN
+    BSWAP(tmp);
+#endif
+    ld->bufa = tmp;
+
+    tmp = *((unsigned long*)buffer + 1);
+#ifndef ARCH_IS_BIG_ENDIAN
+    BSWAP(tmp);
+#endif
+    ld->bufb = tmp;
+
+    ld->pos = 0;
+    ld->tail = ((unsigned long*)buffer + 2);
 }
 
 int faad_get_processed_bits(bitfile *ld)
 {
-    return (ld->framebits);
+    return 8 * (4*(ld->tail - ld->start) - 4) - (32 - ld->pos);
 }
 
 unsigned int faad_byte_align(bitfile *ld)
 {
-    int i = 0;
+    unsigned long remainder = ld->pos % 8;
 
-    while (ld->framebits%8 != 0)
+    if (remainder)
     {
-        faad_get1bit(ld DEBUGVAR(1,135,"faad_byte_align(): get bit until aligned"));
-        i++;
+        faad_flushbits(ld, 8 - remainder);
+        return (8 - remainder);
     }
-
-    return(i);
+    return 0;
 }
--- a/libfaad/bits.h
+++ b/libfaad/bits.h
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: bits.h,v 1.3 2002/01/22 09:11:24 menno Exp $
+** $Id: bits.h,v 1.4 2002/02/15 20:52:09 menno Exp $
 **/
 
 #ifndef __BITS_H__
@@ -34,118 +34,83 @@
 #define BYTE_NUMBIT 8
 #define bit2byte(a) ((a)/BYTE_NUMBIT)
 
-/* to mask the n least significant bits of an integer */
-static unsigned int msk[33] =
-{
-    0x00000000, 0x00000001, 0x00000003, 0x00000007,
-    0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f,
-    0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff,
-    0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff,
-    0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff,
-    0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff,
-    0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff,
-    0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff,
-    0xffffffff
-};
-
 typedef struct _bitfile
 {
     /* bit input */
-    unsigned char *rdptr;
-    int incnt;
-    int bitcnt;
-    int framebits;
+	unsigned long bufa;
+	unsigned long bufb;
+	unsigned long pos;
+	unsigned long *tail;
+	unsigned long *start;
 } bitfile;
 
 
-#if defined(LINUX) && defined(ARM__)
-#define bits_inline
-#define _SWAP(a,b) { register unsigned int temp; \
-	b = *(int*)(a); \
-	__asm__ ( " EOR %0, %1, %2, ROR #16" : "=r" (temp) : "r" (b), "r" (b)); \
-	__asm__ ( " BIC %0, %1, #0x00FF0000" : "=r" (temp) : "r" (temp)); \
-	__asm__ ( " MOV %0, %1, ROR #8"      : "=r" (b) : "r" (b)); \
-	__asm__ ( " EOR %0, %1, %2, LSR #8"  : "=r" (b) : "r" (b), "r" (temp)); \
-	}
-#elif defined(LINUX)
-#define bits_inline inline
-#define _SWAP(a,b)	\
-	b=*(int*)a; \
-	__asm__ ( "bswapl %0\n" : "=r" (b) : "0" (b) )
-#elif defined(WIN32)
+#if defined _WIN32
 #define bits_inline __inline
-#define _SWAP(a,b) \
-	{	\
-	register unsigned int * c = &b;	\
-	b=*(int*)a; __asm mov ecx, c __asm mov eax, [ecx] __asm bswap eax __asm mov [ecx], eax	\
-	}
+#define BSWAP(a) __asm mov eax,a __asm bswap eax __asm mov a, eax
+#elif defined(LINUX) || defined(DJGPP)
+#define bits_inline inline
+#define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) )
 #else
 #define bits_inline
-#define _SWAP(a,b) (b=((a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3]))
+#define BSWAP(a) \
+	 ((a) = ( ((a)&0xff)<<24) | (((a)&0xff00)<<8) | (((a)>>8)&0xff00) | (((a)>>24)&0xff))
 #endif
 
 
-void faad_initbits(bitfile *ld, unsigned char *buffer);
+void faad_initbits(bitfile *ld, void *buffer);
 unsigned int faad_byte_align(bitfile *ld);
 int faad_get_processed_bits(bitfile *ld);
 
 
-static bits_inline unsigned int faad_showbits(bitfile *ld, int n)
+static bits_inline unsigned int faad_showbits(bitfile *ld, int bits)
 {
-    unsigned char *v = ld->rdptr;
-    int rbit = 32 - ld->bitcnt;
-    unsigned int b;
-
-    _SWAP(v, b);
-    return ((b & msk[rbit]) >> (rbit-n));
+    int nbit = (bits + ld->pos) - 32;
+    if (nbit > 0) 
+    {
+        return ((ld->bufa & (0xffffffff >> ld->pos)) << nbit) |
+            (ld->bufb >> (32 - nbit));
+    } else {
+        return (ld->bufa & (0xffffffff >> ld->pos)) >> (32 - ld->pos - bits);
+    }
 }
 
-static bits_inline void faad_flushbits(bitfile *ld, int n)
+static bits_inline void faad_flushbits(bitfile *ld, int bits)
 {
-    ld->bitcnt += n;
+	ld->pos += bits;
 
-    if (ld->bitcnt >= 8)
-    {
-        ld->rdptr += (ld->bitcnt>>3);
-        ld->bitcnt &= 7;
-    }
+	if (ld->pos >= 32) 
+	{
+		unsigned long tmp;
 
-    ld->framebits += n;
+		ld->bufa = ld->bufb;
+		tmp = *(unsigned long*)ld->tail;
+#ifndef ARCH_IS_BIG_ENDIAN
+		BSWAP(tmp);
+#endif
+		ld->bufb = tmp;
+		ld->tail++;
+		ld->pos -= 32;
+	}
 }
 
 /* return next n bits (right adjusted) */
 static bits_inline unsigned int faad_getbits(bitfile *ld, int n DEBUGDEC)
 {
-    long l;
+	unsigned long ret = faad_showbits(ld, n);
+	faad_flushbits(ld, n);
 
-    l = faad_showbits(ld, n);
-    faad_flushbits(ld, n);
-
 #ifdef ANALYSIS
     if (print)
-        fprintf(stdout, "%4d %2d bits, val: %4d, variable: %d %s\n", dbg_count++, n, l, var, dbg);
+        fprintf(stdout, "%4d %2d bits, val: %4d, variable: %d %s\n", dbg_count++, n, ret, var, dbg);
 #endif
 
-    return l;
+	return ret;
 }
 
 static bits_inline unsigned int faad_get1bit(bitfile *ld DEBUGDEC)
 {
-    unsigned char l;
-
-    l = *ld->rdptr << ld->bitcnt;
-
-    ld->bitcnt++;
-    ld->framebits++;
-    ld->rdptr += (ld->bitcnt>>3);
-    ld->bitcnt &= 7;
-
-#ifdef ANALYSIS
-    if (print)
-        fprintf(stdout, "%4d  1 bits, val: %4d, variable: %d %s\n", dbg_count++, l>>7, var, dbg);
-#endif
-
-    return l>>7;
+    return faad_getbits(ld, 1 DEBUGVAR(print,var,dbg));
 }
 
 #ifdef __cplusplus
--- /dev/null
+++ b/libfaad/codebook/hcb.h
@@ -1,0 +1,137 @@
+/*
+** FAAD - Freeware Advanced Audio Decoder
+** Copyright (C) 2002 M. Bakker
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+**
+** $Id: hcb.h,v 1.1 2002/02/15 20:52:10 menno Exp $
+**/
+
+#ifndef __HCB_H__
+#define __HCB_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ *  Optimal huffman decoding for AAC taken from:
+ *  "SELECTING AN OPTIMAL HUFFMAN DECODER FOR AAC" by
+ *  VLADIMIR Z. MESAROVIC , RAGHUNATH RAO, MIROSLAV V. DOKIC, and SACHIN DEO
+ *  AES paper 5436
+ *
+ *   2 methods are used for huffman decoding:
+ *   - binary search
+ *   - 2-step table lookup
+ *
+ *   The choice of the "optimal" method is based on the fact that if the
+ *   memory size for the Two-step is exorbitantly high then the decision
+ *   is Binary search for that codebook. However, for marginally more memory
+ *   size, if Twostep outperforms even the best case of Binary then the
+ *   decision is Two-step for that codebook.
+ *
+ *   The following methods are used for the different tables.
+ *   codebook   "optimal" method
+ *    HCB_1      2-Step
+ *    HCB_2      2-Step
+ *    HCB_3      Binary
+ *    HCB_4      2-Step
+ *    HCB_5      Binary
+ *    HCB_6      2-Step
+ *    HCB_7      Binary
+ *    HCB_8      2-Step
+ *    HCB_9      Binary
+ *    HCB_10     2-Step
+ *    HCB_11     2-Step
+ *    HCB_SF     Binary
+ *
+ */
+
+
+#define ZERO_HCB       0
+#define FIRST_PAIR_HCB 5
+#define ESC_HCB        11
+#define QUAD_LEN       4
+#define PAIR_LEN       2
+#define NSPECBOOKS     ESC_HCB + 1
+#define BOOKSCL        NSPECBOOKS
+#define NOISE_HCB      13
+#define INTENSITY_HCB2 14
+#define INTENSITY_HCB  15
+
+/* 1st step table */
+typedef struct
+{
+    unsigned char offset;
+    unsigned char extra_bits;
+} hcb;
+
+/* 2nd step table with quadruple data */
+typedef struct
+{
+    unsigned char bits;
+    char x;
+    char y;
+} hcb_2_pair;
+
+typedef struct
+{
+    unsigned char bits;
+    char x;
+    char y;
+    char v;
+    char w;
+} hcb_2_quad;
+
+/* binary search table */
+typedef struct
+{
+    unsigned char is_leaf;
+    char data[4];
+} hcb_bin_quad;
+
+typedef struct
+{
+    unsigned char is_leaf;
+    char data[2];
+} hcb_bin_pair;
+
+extern hcb hcb1_1[];
+extern hcb hcb2_1[];
+extern hcb hcb4_1[];
+extern hcb hcb6_1[];
+extern hcb hcb8_1[];
+extern hcb hcb10_1[];
+extern hcb hcb11_1[];
+
+extern hcb_2_quad hcb1_2[];
+extern hcb_2_quad hcb2_2[];
+extern hcb_2_quad hcb4_2[];
+extern hcb_2_pair hcb6_2[];
+extern hcb_2_pair hcb8_2[];
+extern hcb_2_pair hcb10_2[];
+extern hcb_2_pair hcb11_2[];
+
+extern hcb_bin_quad hcb3[];
+extern hcb_bin_pair hcb5[];
+extern hcb_bin_pair hcb7[];
+extern hcb_bin_pair hcb9[];
+
+extern char hcb_sf[][2];
+
+#ifdef __cplusplus
+}
+#endif
+#endif
--- /dev/null
+++ b/libfaad/codebook/hcb_1.c
@@ -1,0 +1,179 @@
+/*
+** FAAD - Freeware Advanced Audio Decoder
+** Copyright (C) 2002 M. Bakker
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+**
+** $Id: hcb_1.c,v 1.1 2002/02/15 20:52:10 menno Exp $
+**/
+
+#include "hcb.h"
+
+/* 2-step huffman table HCB_1 */
+
+
+/* 1st step: 5 bits
+ *           2^5 = 32 entries
+ *
+ * Used to find offset into 2nd step table and number of extra bits to get
+ */
+extern hcb hcb1_1[] = {
+    { /* 00000 */ 0, 0 },
+    { /*       */ 0, 0 },
+    { /*       */ 0, 0 },
+    { /*       */ 0, 0 },
+    { /*       */ 0, 0 },
+    { /*       */ 0, 0 },
+    { /*       */ 0, 0 },
+    { /*       */ 0, 0 },
+    { /*       */ 0, 0 },
+    { /*       */ 0, 0 },
+    { /*       */ 0, 0 },
+    { /*       */ 0, 0 },
+    { /*       */ 0, 0 },
+    { /*       */ 0, 0 },
+    { /*       */ 0, 0 },
+    { /*       */ 0, 0 },
+    { /* 10000 */ 1, 0 },
+    { /* 10001 */ 2, 0 },
+    { /* 10010 */ 3, 0 },
+    { /* 10011 */ 4, 0 },
+    { /* 10100 */ 5, 0 },
+    { /* 10101 */ 6, 0 },
+    { /* 10110 */ 7, 0 },
+    { /* 10111 */ 8, 0 },
+
+    /* 7 bit codewords */
+    { /* 11000 */ 9,  2 },
+    { /* 11001 */ 13, 2 },
+    { /* 11010 */ 17, 2 },
+    { /* 11011 */ 21, 2 },
+    { /* 11100 */ 25, 2 },
+    { /* 11101 */ 29, 2 },
+
+    /* 9 bit codewords */
+    { /* 11110 */ 33, 4 },
+
+    /* 9/10/11 bit codewords */
+    { /* 11111 */ 49, 6 }
+};
+
+/* 2nd step table
+ *
+ * Gives size of codeword and actual data (x,y,v,w)
+ */
+extern hcb_2_quad hcb1_2[] = {
+    /* 1 bit codeword */
+    { 1,  0,  0,  0,  0 },
+
+    /* 5 bit codewords */
+    { 5,  1,  0,  0,  0 },
+    { 5, -1,  0,  0,  0 },
+    { 5,  0,  0,  0, -1 },
+    { 5,  0,  1,  0,  0 },
+    { 5,  0,  0,  0,  1 },
+    { 5,  0,  0, -1,  0 },
+    { 5,  0,  0,  1,  0 },
+    { 5,  0, -1,  0,  0 },
+
+    /* 7 bit codewords */
+    /* first 5 bits: 11000 */
+    { 7,  1, -1,  0,  0 },
+    { 7, -1,  1,  0,  0 },
+    { 7,  0,  0, -1,  1 },
+    { 7,  0,  1, -1,  0 },
+    /* first 5 bits: 11001 */
+    { 7,  0, -1,  1,  0 },
+    { 7,  0,  0,  1, -1 },
+    { 7,  1,  1,  0,  0 },
+    { 7,  0,  0, -1, -1 },
+    /* first 5 bits: 11010 */
+    { 7, -1, -1,  0,  0 },
+    { 7,  0, -1, -1,  0 },
+    { 7,  1,  0, -1,  0 },
+    { 7,  0,  1,  0, -1 },
+    /* first 5 bits: 11011 */
+    { 7, -1,  0,  1,  0 },
+    { 7,  0,  0,  1,  1 },
+    { 7,  1,  0,  1,  0 },
+    { 7,  0, -1,  0,  1 },
+    /* first 5 bits: 11100 */
+    { 7,  0,  1,  1,  0 },
+    { 7,  0,  1,  0,  1 },
+    { 7, -1,  0, -1,  0 },
+    { 7,  1,  0,  0,  1 },
+    /* first 5 bits: 11101 */
+    { 7, -1,  0,  0, -1 },
+    { 7,  1,  0,  0, -1 },
+    { 7, -1,  0,  0,  1 },
+    { 7,  0, -1,  0, -1 },
+
+    /* 9 bit codeword */
+    /* first 5 bits: 11110 */
+    { 9,  1,  1, -1,  0 },
+    { 9, -1,  1, -1,  0 },
+    { 9,  1, -1,  1,  0 },
+    { 9,  0,  1,  1, -1 },
+    { 9,  0,  1, -1,  1 },
+    { 9,  0, -1,  1,  1 },
+    { 9,  0, -1,  1, -1 },
+    { 9,  1, -1, -1,  0 },
+    { 9,  1,  0, -1,  1 },
+    { 9,  0,  1, -1, -1 },
+    { 9, -1,  1,  1,  0 },
+    { 9, -1,  0,  1, -1 },
+    { 9, -1, -1,  1,  0 },
+    { 9,  0, -1, -1,  1 },
+    { 9,  1, -1,  0,  1 },
+    { 9,  1, -1,  0, -1 },
+
+    /* 9/10/11 bit codewords */
+    /* first 5 bits: 11111 */
+    /* 9 bit: reading 11 bits -> 2 too much so 4 entries for each codeword */
+    { 9, -1,  1,  0, -1 }, { 9, -1,  1,  0, -1 }, { 9, -1,  1,  0, -1 }, { 9, -1,  1,  0, -1 },
+    { 9, -1, -1, -1,  0 }, { 9, -1, -1, -1,  0 }, { 9, -1, -1, -1,  0 }, { 9, -1, -1, -1,  0 },
+    { 9,  0, -1, -1, -1 }, { 9,  0, -1, -1, -1 }, { 9,  0, -1, -1, -1 }, { 9,  0, -1, -1, -1 },
+    { 9,  0,  1,  1,  1 }, { 9,  0,  1,  1,  1 }, { 9,  0,  1,  1,  1 }, { 9,  0,  1,  1,  1 },
+    { 9,  1,  0,  1, -1 }, { 9,  1,  0,  1, -1 }, { 9,  1,  0,  1, -1 }, { 9,  1,  0,  1, -1 },
+    { 9,  1,  1,  0,  1 }, { 9,  1,  1,  0,  1 }, { 9,  1,  1,  0,  1 }, { 9,  1,  1,  0,  1 },
+    { 9, -1,  1,  0,  1 }, { 9, -1,  1,  0,  1 }, { 9, -1,  1,  0,  1 }, { 9, -1,  1,  0,  1 },
+    { 9,  1,  1,  1,  0 }, { 9,  1,  1,  1,  0 }, { 9,  1,  1,  1,  0 }, { 9,  1,  1,  1,  0 },
+    /* 10 bit: reading 11 bits -> 1 too much so 2 entries for each codeword */
+    { 10, -1, -1,  0,  1 }, { 10, -1, -1,  0,  1 },
+    { 10, -1,  0, -1, -1 }, { 10, -1,  0, -1, -1 },
+    { 10,  1,  1,  0, -1 }, { 10,  1,  1,  0, -1 },
+    { 10,  1,  0, -1, -1 }, { 10,  1,  0, -1, -1 },
+    { 10, -1,  0, -1,  1 }, { 10, -1,  0, -1,  1 },
+    { 10, -1, -1,  0, -1 }, { 10, -1, -1,  0, -1 },
+    { 10, -1,  0,  1,  1 }, { 10, -1,  0,  1,  1 },
+    { 10,  1,  0,  1,  1 }, { 10,  1,  0,  1,  1 },
+    /* 11 bit */
+    { 11,  1, -1,  1, -1 },
+    { 11, -1,  1, -1,  1 },
+    { 11, -1,  1,  1, -1 },
+    { 11,  1, -1, -1,  1 },
+    { 11,  1,  1,  1,  1 },
+    { 11, -1, -1,  1,  1 },
+    { 11,  1,  1, -1, -1 },
+    { 11, -1, -1,  1, -1 },
+    { 11, -1, -1, -1, -1 },
+    { 11,  1,  1, -1,  1 },
+    { 11,  1, -1,  1,  1 },
+    { 11, -1,  1,  1,  1 },
+    { 11, -1,  1, -1, -1 },
+    { 11, -1, -1, -1,  1 },
+    { 11,  1, -1, -1, -1 },
+    { 11,  1,  1,  1, -1 }
+};
--- /dev/null
+++ b/libfaad/codebook/hcb_10.c
@@ -1,0 +1,305 @@
+/*
+** FAAD - Freeware Advanced Audio Decoder
+** Copyright (C) 2002 M. Bakker
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+**
+** $Id: hcb_10.c,v 1.1 2002/02/15 20:52:10 menno Exp $
+**/
+
+#include "hcb.h"
+
+/* 2-step huffman table HCB_10 */
+
+
+/* 1st step: 6 bits
+ *           2^6 = 64 entries
+ *
+ * Used to find offset into 2nd step table and number of extra bits to get
+ */
+extern hcb hcb10_1[] = {
+    /* 4 bit codewords */
+    { /* 000000 */ 0, 0 },
+    { /*        */ 0, 0 },
+    { /*        */ 0, 0 },
+    { /*        */ 0, 0 },
+    { /* 000100 */ 1, 0 },
+    { /*        */ 1, 0 },
+    { /*        */ 1, 0 },
+    { /*        */ 1, 0 },
+    { /* 001000 */ 2, 0 },
+    { /*        */ 2, 0 },
+    { /*        */ 2, 0 },
+    { /*        */ 2, 0 },
+    /* 5 bit codewords */
+    { /* 001100 */ 3, 0 },
+    { /*        */ 3, 0 },
+    { /* 001110 */ 4, 0 },
+    { /*        */ 4, 0 },
+    { /* 010000 */ 5, 0 },
+    { /*        */ 5, 0 },
+    { /* 010010 */ 6, 0 },
+    { /*        */ 6, 0 },
+    { /* 010100 */ 7, 0 },
+    { /*        */ 7, 0 },
+    { /* 010110 */ 8, 0 },
+    { /*        */ 8, 0 },
+    { /* 011000 */ 9, 0 },
+    { /*        */ 9, 0 },
+    { /* 011010 */ 10, 0 },
+    { /*        */ 10, 0 },
+    /* 6 bit codewords */
+    { /* 011100 */ 11, 0 },
+    { /* 011101 */ 12, 0 },
+    { /* 011110 */ 13, 0 },
+    { /* 011111 */ 14, 0 },
+    { /* 100000 */ 15, 0 },
+    { /* 100001 */ 16, 0 },
+    { /* 100010 */ 17, 0 },
+    { /* 100011 */ 18, 0 },
+    { /* 100100 */ 19, 0 },
+    { /* 100101 */ 20, 0 },
+    { /* 100110 */ 21, 0 },
+    { /* 100111 */ 22, 0 },
+    { /* 101000 */ 23, 0 },
+    { /* 101001 */ 24, 0 },
+    /* 7 bit codewords */
+    { /* 101010 */ 25, 1 },
+    { /* 101011 */ 27, 1 },
+    { /* 101100 */ 29, 1 },
+    { /* 101101 */ 31, 1 },
+    { /* 101110 */ 33, 1 },
+    { /* 101111 */ 35, 1 },
+    { /* 110000 */ 37, 1 },
+    { /* 110001 */ 39, 1 },
+    /* 7/8 bit codewords */
+    { /* 110010 */ 41, 2 },
+    /* 8 bit codewords */
+    { /* 110011 */ 45, 2 },
+    { /* 110100 */ 49, 2 },
+    { /* 110101 */ 53, 2 },
+    { /* 110110 */ 57, 2 },
+    { /* 110111 */ 61, 2 },
+    /* 8/9 bit codewords */
+    { /* 111000 */ 65, 3 },
+    /* 9 bit codewords */
+    { /* 111001 */ 73, 3 },
+    { /* 111010 */ 81, 3 },
+    { /* 111011 */ 89, 3 },
+    /* 9/10 bit codewords */
+    { /* 111100 */ 97, 4 },
+    /* 10 bit codewords */
+    { /* 111101 */ 113, 4 },
+    { /* 111110 */ 129, 4 },
+    /* 10/11/12 bit codewords */
+    { /* 111111 */ 145, 6 }
+};
+
+/* 2nd step table
+ *
+ * Gives size of codeword and actual data (x,y,v,w)
+ */
+extern hcb_2_pair hcb10_2[] = {
+    /* 4 bit codewords */
+    { 4,  1,  1 },
+    { 4,  1,  2 },
+    { 4,  2,  1 },
+
+    /* 5 bit codewords */
+    { 5,  2,  2 },
+    { 5,  1,  0 },
+    { 5,  0,  1 },
+    { 5,  1,  3 },
+    { 5,  3,  2 },
+    { 5,  3,  1 },
+    { 5,  2,  3 },
+    { 5,  3,  3 },
+
+    /* 6 bit codewords */
+    { 6,  2,  0 },
+    { 6,  0,  2 },
+    { 6,  2,  4 },
+    { 6,  4,  2 },
+    { 6,  1,  4 },
+    { 6,  4,  1 },
+    { 6,  0,  0 },
+    { 6,  4,  3 },
+    { 6,  3,  4 },
+    { 6,  3,  0 },
+    { 6,  0,  3 },
+    { 6,  4,  4 },
+    { 6,  2,  5 },
+    { 6,  5,  2 },
+
+    /* 7 bit codewords */
+    { 7,  1,  5 },
+    { 7,  5,  1 },
+    { 7,  5,  3 },
+    { 7,  3,  5 },
+    { 7,  5,  4 },
+    { 7,  4,  5 },
+    { 7,  6,  2 },
+    { 7,  2,  6 },
+    { 7,  6,  3 },
+    { 7,  4,  0 },
+    { 7,  6,  1 },
+    { 7,  0,  4 },
+    { 7,  1,  6 },
+    { 7,  3,  6 },
+    { 7,  5,  5 },
+    { 7,  6,  4 },
+
+    /* 7/8 bit codewords */
+    { 7,  4,  6 }, { 7,  4,  6 },
+    { 8,  6,  5 },
+    { 8,  7,  2 },
+
+    /* 8 bit codewords */
+    { 8,  3,  7 },
+    { 8,  2,  7 },
+    { 8,  5,  6 },
+    { 8,  8,  2 },
+    { 8,  7,  3 },
+    { 8,  5,  0 },
+    { 8,  7,  1 },
+    { 8,  0,  5 },
+    { 8,  8,  1 },
+    { 8,  1,  7 },
+    { 8,  8,  3 },
+    { 8,  7,  4 },
+    { 8,  4,  7 },
+    { 8,  2,  8 },
+    { 8,  6,  6 },
+    { 8,  7,  5 },
+    { 8,  1,  8 },
+    { 8,  3,  8 },
+    { 8,  8,  4 },
+    { 8,  4,  8 },
+
+    /* 8/9 bit codewords */
+    { 8,  5,  7 }, { 8,  5,  7 },
+    { 8,  8,  5 }, { 8,  8,  5 },
+    { 8,  5,  8 }, { 8,  5,  8 },
+    { 9,  7,  6 },
+    { 9,  6,  7 },
+
+    /* 9 bit codewords */
+    { 9,  9,  2 },
+    { 9,  6,  0 },
+    { 9,  6,  8 },
+    { 9,  9,  3 },
+    { 9,  3,  9 },
+    { 9,  9,  1 },
+    { 9,  2,  9 },
+    { 9,  0,  6 },
+    { 9,  8,  6 },
+    { 9,  9,  4 },
+    { 9,  4,  9 },
+    { 9, 10,  2 },
+    { 9,  1,  9 },
+    { 9,  7,  7 },
+    { 9,  8,  7 },
+    { 9,  9,  5 },
+    { 9,  7,  8 },
+    { 9, 10,  3 },
+    { 9,  5,  9 },
+    { 9, 10,  4 },
+    { 9,  2, 10 },
+    { 9, 10,  1 },
+    { 9,  3, 10 },
+    { 9,  9,  6 },
+
+    /* 9/10 bit codewords */
+    { 9,  6,  9 }, { 9,  6,  9 },
+    { 9,  8,  0 }, { 9,  8,  0 },
+    { 9,  4, 10 }, { 9,  4, 10 },
+    { 9,  7,  0 }, { 9,  7,  0 },
+    { 9, 11,  2 }, { 9, 11,  2 },
+    { 10,  7,  9 },
+    { 10, 11,  3 },
+    { 10, 10,  6 },
+    { 10,  1, 10 },
+    { 10, 11,  1 },
+    { 10,  9,  7 },
+
+    /* 10 bit codewords */
+    { 10,  0,  7 },
+    { 10,  8,  8 },
+    { 10, 10,  5 },
+    { 10,  3, 11 },
+    { 10,  5, 10 },
+    { 10,  8,  9 },
+    { 10, 11,  5 },
+    { 10,  0,  8 },
+    { 10, 11,  4 },
+    { 10,  2, 11 },
+    { 10,  7, 10 },
+    { 10,  6, 10 },
+    { 10, 10,  7 },
+    { 10,  4, 11 },
+    { 10,  1, 11 },
+    { 10, 12,  2 },
+    { 10,  9,  8 },
+    { 10, 12,  3 },
+    { 10, 11,  6 },
+    { 10,  5, 11 },
+    { 10, 12,  4 },
+    { 10, 11,  7 },
+    { 10, 12,  5 },
+    { 10,  3, 12 },
+    { 10,  6, 11 },
+    { 10,  9,  0 },
+    { 10, 10,  8 },
+    { 10, 10,  0 },
+    { 10, 12,  1 },
+    { 10,  0,  9 },
+    { 10,  4, 12 },
+    { 10,  9,  9 },
+
+    /* 10/11/12 bit codewords */
+    { 10, 12,  6 }, { 10, 12,  6 }, { 10, 12,  6 }, { 10, 12,  6 },
+    { 10,  2, 12 }, { 10,  2, 12 }, { 10,  2, 12 }, { 10,  2, 12 },
+    { 10,  8, 10 }, { 10,  8, 10 }, { 10,  8, 10 }, { 10,  8, 10 },
+    { 11,  9, 10 }, { 11,  9, 10 },
+    { 11,  1, 12 }, { 11,  1, 12 },
+    { 11, 11,  8 }, { 11, 11,  8 },
+    { 11, 12,  7 }, { 11, 12,  7 },
+    { 11,  7, 11 }, { 11,  7, 11 },
+    { 11,  5, 12 }, { 11,  5, 12 },
+    { 11,  6, 12 }, { 11,  6, 12 },
+    { 11, 10,  9 }, { 11, 10,  9 },
+    { 11,  8, 11 }, { 11,  8, 11 },
+    { 11, 12,  8 }, { 11, 12,  8 },
+    { 11,  0, 10 }, { 11,  0, 10 },
+    { 11,  7, 12 }, { 11,  7, 12 },
+    { 11, 11,  0 }, { 11, 11,  0 },
+    { 11, 10, 10 }, { 11, 10, 10 },
+    { 11, 11,  9 }, { 11, 11,  9 },
+    { 11, 11, 10 }, { 11, 11, 10 },
+    { 11,  0, 11 }, { 11,  0, 11 },
+    { 11, 11, 11 }, { 11, 11, 11 },
+    { 11,  9, 11 }, { 11,  9, 11 },
+    { 11, 10, 11 }, { 11, 10, 11 },
+    { 11, 12,  0 }, { 11, 12,  0 },
+    { 11,  8, 12 }, { 11,  8, 12 },
+    { 12, 12,  9 },
+    { 12, 10, 12 },
+    { 12,  9, 12 },
+    { 12, 11, 12 },
+    { 12, 12, 11 },
+    { 12,  0, 12 },
+    { 12, 12, 10 },
+    { 12, 12, 12 }
+};
--- /dev/null
+++ b/libfaad/codebook/hcb_11.c
@@ -1,0 +1,408 @@
+/*
+** FAAD - Freeware Advanced Audio Decoder
+** Copyright (C) 2002 M. Bakker
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+**
+** $Id: hcb_11.c,v 1.1 2002/02/15 20:52:10 menno Exp $
+**/
+
+#include "hcb.h"
+
+/* 2-step huffman table HCB_11 */
+
+
+/* 1st step: 5 bits
+ *           2^5 = 32 entries
+ *
+ * Used to find offset into 2nd step table and number of extra bits to get
+ */
+extern hcb hcb11_1[] = {
+    /* 4 bits */
+    { /* 00000 */ 0, 0 },
+    { /*       */ 0, 0 },
+    { /* 00010 */ 1, 0 },
+    { /*       */ 1, 0 },
+
+    /* 5 bits */
+    { /* 00100 */ 2, 0 },
+    { /* 00101 */ 3, 0 },
+    { /* 00110 */ 4, 0 },
+    { /* 00111 */ 5, 0 },
+    { /* 01000 */ 6, 0 },
+    { /* 01001 */ 7, 0 },
+
+    /* 6 bits */
+    { /* 01010 */ 8,  1 },
+    { /* 01011 */ 10, 1 },
+    { /* 01100 */ 12, 1 },
+
+    /* 6/7 bits */
+    { /* 01101 */ 14, 2 },
+
+    /* 7 bits */
+    { /* 01110 */ 18, 2 },
+    { /* 01111 */ 22, 2 },
+    { /* 10000 */ 26, 2 },
+
+    /* 7/8 bits */
+    { /* 10001 */ 30, 3 },
+
+    /* 8 bits */
+    { /* 10010 */ 38, 3 },
+    { /* 10011 */ 46, 3 },
+    { /* 10100 */ 54, 3 },
+    { /* 10101 */ 62, 3 },
+    { /* 10110 */ 70, 3 },
+    { /* 10111 */ 78, 3 },
+
+    /* 8/9 bits */
+    { /* 11000 */ 86, 4 },
+
+    /* 9 bits */
+    { /* 11001 */ 102, 4 },
+    { /* 11010 */ 118, 4 },
+    { /* 11011 */ 134, 4 },
+
+    /* 9/10 bits */
+    { /* 11100 */ 150, 5 },
+
+    /* 10 bits */
+    { /* 11101 */ 182, 5 },
+    { /* 11110 */ 214, 5 },
+
+    /* 10/11/12 bits */
+    { /* 11111 */ 246, 7 }
+};
+
+/* 2nd step table
+ *
+ * Gives size of codeword and actual data (x,y,v,w)
+ */
+extern hcb_2_pair hcb11_2[] = {
+    /* 4 */
+    { 4,  0,  0 },
+    { 4,  1,  1 },
+
+    /* 5 */
+    { 5, 16, 16 },
+    { 5,  1,  0 },
+    { 5,  0,  1 },
+    { 5,  2,  1 },
+    { 5,  1,  2 },
+    { 5,  2,  2 },
+
+    /* 6 */
+    { 6,  1,  3 },
+    { 6,  3,  1 },
+    { 6,  3,  2 },
+    { 6,  2,  0 },
+    { 6,  2,  3 },
+    { 6,  0,  2 },
+
+    /* 6/7 */
+    { 6,  3,  3 }, { 6,  3,  3 },
+    { 7,  4,  1 },
+    { 7,  1,  4 },
+
+    /* 7 */
+    { 7,  4,  2 },
+    { 7,  2,  4 },
+    { 7,  4,  3 },
+    { 7,  3,  4 },
+    { 7,  3,  0 },
+    { 7,  0,  3 },
+    { 7,  5,  1 },
+    { 7,  5,  2 },
+    { 7,  2,  5 },
+    { 7,  4,  4 },
+    { 7,  1,  5 },
+    { 7,  5,  3 },
+
+    /* 7/8 */
+    { 7,  3,  5 }, { 7,  3,  5 },
+    { 7,  5,  4 }, { 7,  5,  4 },
+    { 8,  4,  5 },
+    { 8,  6,  2 },
+    { 8,  2,  6 },
+    { 8,  6,  1 },
+
+    /* 8 */
+    { 8,  6,  3 },
+    { 8,  3,  6 },
+    { 8,  1,  6 },
+    { 8,  4, 16 },
+    { 8,  3, 16 },
+    { 8, 16,  5 },
+    { 8, 16,  3 },
+    { 8, 16,  4 },
+    { 8,  6,  4 },
+    { 8, 16,  6 },
+    { 8,  4,  0 },
+    { 8,  4,  6 },
+    { 8,  0,  4 },
+    { 8,  2, 16 },
+    { 8,  5,  5 },
+    { 8,  5, 16 },
+    { 8, 16,  7 },
+    { 8, 16,  2 },
+    { 8, 16,  8 },
+    { 8,  2,  7 },
+    { 8,  7,  2 },
+    { 8,  3,  7 },
+    { 8,  6,  5 },
+    { 8,  5,  6 },
+    { 8,  6, 16 },
+    { 8, 16, 10 },
+    { 8,  7,  3 },
+    { 8,  7,  1 },
+    { 8, 16,  9 },
+    { 8,  7, 16 },
+    { 8,  1, 16 },
+    { 8,  1,  7 },
+    { 8,  4,  7 },
+    { 8, 16, 11 },
+    { 8,  7,  4 },
+    { 8, 16, 12 },
+    { 8,  8, 16 },
+    { 8, 16,  1 },
+    { 8,  6,  6 },
+    { 8,  9, 16 },
+    { 8,  2,  8 },
+    { 8,  5,  7 },
+    { 8, 10, 16 },
+    { 8, 16, 13 },
+    { 8,  8,  3 },
+    { 8,  8,  2 },
+    { 8,  3,  8 },
+    { 8,  5,  0 },
+
+    /* 8/9 */
+    { 8, 16, 14 }, { 8, 16, 14 },
+    { 8, 11, 16 }, { 8, 11, 16 },
+    { 8,  7,  5 }, { 8,  7,  5 },
+    { 8,  4,  8 }, { 8,  4,  8 },
+    { 8,  6,  7 }, { 8,  6,  7 },
+    { 8,  7,  6 }, { 8,  7,  6 },
+    { 8,  0,  5 }, { 8,  0,  5 },
+    { 9,  8,  4 },
+    { 9, 16, 15 },
+
+    /* 9 */
+    { 9, 12, 16 },
+    { 9,  1,  8 },
+    { 9,  8,  1 },
+    { 9, 14, 16 },
+    { 9,  5,  8 },
+    { 9, 13, 16 },
+    { 9,  3,  9 },
+    { 9,  8,  5 },
+    { 9,  7,  7 },
+    { 9,  2,  9 },
+    { 9,  8,  6 },
+    { 9,  9,  2 },
+    { 9,  9,  3 },
+    { 9, 15, 16 },
+    { 9,  4,  9 },
+    { 9,  6,  8 },
+    { 9,  6,  0 },
+    { 9,  9,  4 },
+    { 9,  5,  9 },
+    { 9,  8,  7 },
+    { 9,  7,  8 },
+    { 9,  1,  9 },
+    { 9, 10,  3 },
+    { 9,  0,  6 },
+    { 9, 10,  2 },
+    { 9,  9,  1 },
+    { 9,  9,  5 },
+    { 9,  4, 10 },
+    { 9,  2, 10 },
+    { 9,  9,  6 },
+    { 9,  3, 10 },
+    { 9,  6,  9 },
+    { 9, 10,  4 },
+    { 9,  8,  8 },
+    { 9, 10,  5 },
+    { 9,  9,  7 },
+    { 9, 11,  3 },
+    { 9,  1, 10 },
+    { 9,  7,  0 },
+    { 9, 10,  6 },
+    { 9,  7,  9 },
+    { 9,  3, 11 },
+    { 9,  5, 10 },
+    { 9, 10,  1 },
+    { 9,  4, 11 },
+    { 9, 11,  2 },
+    { 9, 13,  2 },
+    { 9,  6, 10 },
+
+    /* 9/10 */
+    { 9, 13,  3 }, { 9, 13,  3 },
+    { 9,  2, 11 }, { 9,  2, 11 },
+    { 9, 16,  0 }, { 9, 16,  0 },
+    { 9,  5, 11 }, { 9,  5, 11 },
+    { 9, 11,  5 }, { 9, 11,  5 },
+    { 10, 11,  4 },
+    { 10,  9,  8 },
+    { 10,  7, 10 },
+    { 10,  8,  9 },
+    { 10,  0, 16 },
+    { 10,  4, 13 },
+    { 10,  0,  7 },
+    { 10,  3, 13 },
+    { 10, 11,  6 },
+    { 10, 13,  1 },
+    { 10, 13,  4 },
+    { 10, 12,  3 },
+    { 10,  2, 13 },
+    { 10, 13,  5 },
+    { 10,  8, 10 },
+    { 10,  6, 11 },
+    { 10, 10,  8 },
+    { 10, 10,  7 },
+    { 10, 14,  2 },
+    { 10, 12,  4 },
+    { 10,  1, 11 },
+    { 10,  4, 12 },
+
+    /* 10 */
+    { 10, 11,  1 },
+    { 10,  3, 12 },
+    { 10,  1, 13 },
+    { 10, 12,  2 },
+    { 10,  7, 11 },
+    { 10,  3, 14 },
+    { 10,  5, 12 },
+    { 10,  5, 13 },
+    { 10, 14,  4 },
+    { 10,  4, 14 },
+    { 10, 11,  7 },
+    { 10, 14,  3 },
+    { 10, 12,  5 },
+    { 10, 13,  6 },
+    { 10, 12,  6 },
+    { 10,  8,  0 },
+    { 10, 11,  8 },
+    { 10,  2, 12 },
+    { 10,  9,  9 },
+    { 10, 14,  5 },
+    { 10,  6, 13 },
+    { 10, 10, 10 },
+    { 10, 15,  2 },
+    { 10,  8, 11 },
+    { 10,  9, 10 },
+    { 10, 14,  6 },
+    { 10, 10,  9 },
+    { 10,  5, 14 },
+    { 10, 11,  9 },
+    { 10, 14,  1 },
+    { 10,  2, 14 },
+    { 10,  6, 12 },
+    { 10,  1, 12 },
+    { 10, 13,  8 },
+    { 10,  0,  8 },
+    { 10, 13,  7 },
+    { 10,  7, 12 },
+    { 10, 12,  7 },
+    { 10,  7, 13 },
+    { 10, 15,  3 },
+    { 10, 12,  1 },
+    { 10,  6, 14 },
+    { 10,  2, 15 },
+    { 10, 15,  5 },
+    { 10, 15,  4 },
+    { 10,  1, 14 },
+    { 10,  9, 11 },
+    { 10,  4, 15 },
+    { 10, 14,  7 },
+    { 10,  8, 13 },
+    { 10, 13,  9 },
+    { 10,  8, 12 },
+    { 10,  5, 15 },
+    { 10,  3, 15 },
+    { 10, 10, 11 },
+    { 10, 11, 10 },
+    { 10, 12,  8 },
+    { 10, 15,  6 },
+    { 10, 15,  7 },
+    { 10,  8, 14 },
+    { 10, 15,  1 },
+    { 10,  7, 14 },
+    { 10,  9,  0 },
+    { 10,  0,  9 },
+
+    /* 10/11/12 */
+    { 10,  9, 13 }, { 10,  9, 13 }, { 10,  9, 13 }, { 10,  9, 13 },
+    { 10,  9, 12 }, { 10,  9, 12 }, { 10,  9, 12 }, { 10,  9, 12 },
+    { 10, 12,  9 }, { 10, 12,  9 }, { 10, 12,  9 }, { 10, 12,  9 },
+    { 10, 14,  8 }, { 10, 14,  8 }, { 10, 14,  8 }, { 10, 14,  8 },
+    { 10, 10, 13 }, { 10, 10, 13 }, { 10, 10, 13 }, { 10, 10, 13 },
+    { 10, 14,  9 }, { 10, 14,  9 }, { 10, 14,  9 }, { 10, 14,  9 },
+    { 10, 12, 10 }, { 10, 12, 10 }, { 10, 12, 10 }, { 10, 12, 10 },
+    { 10,  6, 15 }, { 10,  6, 15 }, { 10,  6, 15 }, { 10,  6, 15 },
+    { 10,  7, 15 }, { 10,  7, 15 }, { 10,  7, 15 }, { 10,  7, 15 },
+
+    { 11,  9, 14 }, { 11,  9, 14 },
+    { 11, 15,  8 }, { 11, 15,  8 },
+    { 11, 11, 11 }, { 11, 11, 11 },
+    { 11, 11, 14 }, { 11, 11, 14 },
+    { 11,  1, 15 }, { 11,  1, 15 },
+    { 11, 10, 12 }, { 11, 10, 12 },
+    { 11, 10, 14 }, { 11, 10, 14 },
+    { 11, 13, 11 }, { 11, 13, 11 },
+    { 11, 13, 10 }, { 11, 13, 10 },
+    { 11, 11, 13 }, { 11, 11, 13 },
+    { 11, 11, 12 }, { 11, 11, 12 },
+    { 11,  8, 15 }, { 11,  8, 15 },
+    { 11, 14, 11 }, { 11, 14, 11 },
+    { 11, 13, 12 }, { 11, 13, 12 },
+    { 11, 12, 13 }, { 11, 12, 13 },
+    { 11, 15,  9 }, { 11, 15,  9 },
+    { 11, 14, 10 }, { 11, 14, 10 },
+    { 11, 10,  0 }, { 11, 10,  0 },
+    { 11, 12, 11 }, { 11, 12, 11 },
+    { 11,  9, 15 }, { 11,  9, 15 },
+    { 11,  0, 10 }, { 11,  0, 10 },
+    { 11, 12, 12 }, { 11, 12, 12 },
+    { 11, 11,  0 }, { 11, 11,  0 },
+    { 11, 12, 14 }, { 11, 12, 14 },
+    { 11, 10, 15 }, { 11, 10, 15 },
+    { 11, 13, 13 }, { 11, 13, 13 },
+    { 11,  0, 13 }, { 11,  0, 13 },
+    { 11, 14, 12 }, { 11, 14, 12 },
+    { 11, 15, 10 }, { 11, 15, 10 },
+    { 11, 15, 11 }, { 11, 15, 11 },
+    { 11, 11, 15 }, { 11, 11, 15 },
+    { 11, 14, 13 }, { 11, 14, 13 },
+    { 11, 13,  0 }, { 11, 13,  0 },
+    { 11,  0, 11 }, { 11,  0, 11 },
+    { 11, 13, 14 }, { 11, 13, 14 },
+    { 11, 15, 12 }, { 11, 15, 12 },
+    { 11, 15, 13 }, { 11, 15, 13 },
+    { 11, 12, 15 }, { 11, 12, 15 },
+    { 11, 14,  0 }, { 11, 14,  0 },
+    { 11, 14, 14 }, { 11, 14, 14 },
+    { 11, 13, 15 }, { 11, 13, 15 },
+    { 11, 12,  0 }, { 11, 12,  0 },
+    { 11, 14, 15 }, { 11, 14, 15 },
+    { 12,  0, 14 },
+    { 12,  0, 12 },
+    { 12, 15, 14 },
+    { 12, 15,  0 },
+    { 12,  0, 15 },
+    { 12, 15, 15 }
+};
--- /dev/null
+++ b/libfaad/codebook/hcb_2.c
@@ -1,0 +1,178 @@
+/*
+** FAAD - Freeware Advanced Audio Decoder
+** Copyright (C) 2002 M. Bakker
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+**
+** $Id: hcb_2.c,v 1.1 2002/02/15 20:52:10 menno Exp $
+**/
+
+#include "hcb.h"
+
+/* 2-step huffman table HCB_2 */
+
+
+/* 1st step: 5 bits
+ *           2^5 = 32 entries
+ *
+ * Used to find offset into 2nd step table and number of extra bits to get
+ */
+extern hcb hcb2_1[] = {
+    { /* 00000 */ 0, 0 },
+    { /*       */ 0, 0 },
+    { /*       */ 0, 0 },
+    { /*       */ 0, 0 },
+    { /* 00100 */ 1, 0 },
+    { /*       */ 1, 0 },
+    { /* 00110 */ 2, 0 },
+    { /* 00111 */ 3, 0 },
+    { /* 01000 */ 4, 0 },
+    { /* 01001 */ 5, 0 },
+    { /* 01010 */ 6, 0 },
+    { /* 01011 */ 7, 0 },
+    { /* 01100 */ 8, 0 },
+
+    /* 6 bit codewords */
+    { /* 01101 */ 9,  1 },
+    { /* 01110 */ 11, 1 },
+    { /* 01111 */ 13, 1 },
+    { /* 10000 */ 15, 1 },
+    { /* 10001 */ 17, 1 },
+    { /* 10010 */ 19, 1 },
+    { /* 10011 */ 21, 1 },
+    { /* 10100 */ 23, 1 },
+    { /* 10101 */ 25, 1 },
+    { /* 10110 */ 27, 1 },
+    { /* 10111 */ 29, 1 },
+    { /* 11000 */ 31, 1 },
+
+    /* 7 bit codewords */
+    { /* 11001 */ 33, 2 },
+    { /* 11010 */ 37, 2 },
+    { /* 11011 */ 41, 2 },
+
+    /* 7/8 bit codewords */
+    { /* 11100 */ 45, 3 },
+
+    /* 8 bit codewords */
+    { /* 11101 */ 53, 3 },
+    { /* 11110 */ 61, 3 },
+
+    /* 8/9 bit codewords */
+    { /* 11111 */ 69, 4 }
+};
+
+/* 2nd step table
+ *
+ * Gives size of codeword and actual data (x,y,v,w)
+ */
+extern hcb_2_quad hcb2_2[] = {
+    /* 3 bit codeword */
+    { 3,  0,  0,  0,  0 },
+
+    /* 4 bit codeword */
+    { 4,  1,  0,  0,  0 },
+
+    /* 5 bit codewords */
+    { 5, -1,  0,  0,  0 },
+    { 5,  0,  0,  0,  1 },
+    { 5,  0,  0, -1,  0 },
+    { 5,  0,  0,  0, -1 },
+    { 5,  0, -1,  0,  0 },
+    { 5,  0,  0,  1,  0 },
+    { 5,  0,  1,  0,  0 },
+
+    /* 6 bit codewords */
+    { 6,  0, -1,  1,  0 },
+    { 6, -1,  1,  0,  0 },
+    { 6,  0,  1, -1,  0 },
+    { 6,  0,  0,  1, -1 },
+    { 6,  0,  1,  0, -1 },
+    { 6,  0,  0, -1,  1 },
+    { 6, -1,  0,  0, -1 },
+    { 6,  1, -1,  0,  0 },
+    { 6,  1,  0, -1,  0 },
+    { 6, -1, -1,  0,  0 },
+    { 6,  0,  0, -1, -1 },
+    { 6,  1,  0,  1,  0 },
+    { 6,  1,  0,  0,  1 },
+    { 6,  0, -1,  0,  1 },
+    { 6, -1,  0,  1,  0 },
+    { 6,  0,  1,  0,  1 },
+    { 6,  0, -1, -1,  0 },
+    { 6, -1,  0,  0,  1 },
+    { 6,  0, -1,  0, -1 },
+    { 6, -1,  0, -1,  0 },
+    { 6,  1,  1,  0,  0 },
+    { 6,  0,  1,  1,  0 },
+    { 6,  0,  0,  1,  1 },
+    { 6,  1,  0,  0, -1 },
+
+    /* 7 bit codewords */
+    { 7,  0,  1, -1,  1 },
+    { 7,  1,  0, -1,  1 },
+    { 7, -1,  1, -1,  0 },
+    { 7,  0, -1,  1, -1 },
+    { 7,  1, -1,  1,  0 },
+    { 7,  1,  1,  0, -1 },
+    { 7,  1,  0,  1,  1 },
+    { 7, -1,  1,  1,  0 },
+    { 7,  0, -1, -1,  1 },
+    { 7,  1,  1,  1,  0 },
+    { 7, -1,  0,  1, -1 },
+    { 7, -1, -1, -1,  0 },
+
+    /* 7/8 bit codewords */
+    { 7, -1,  0, -1,  1 }, { 7, -1,  0, -1,  1 },
+    { 7,  1, -1, -1,  0 }, { 7,  1, -1, -1,  0 },
+    { 7,  1,  1, -1,  0 }, { 7,  1,  1, -1,  0 },
+    { 8,  1, -1,  0,  1 },
+    { 8, -1,  1,  0, -1 },
+
+    /* 8 bit codewords */
+    { 8, -1, -1,  1,  0 },
+    { 8, -1,  0,  1,  1 },
+    { 8, -1, -1,  0,  1 },
+    { 8, -1, -1,  0, -1 },
+    { 8,  0, -1, -1, -1 },
+    { 8,  1,  0,  1, -1 },
+    { 8,  1,  0, -1, -1 },
+    { 8,  0,  1, -1, -1 },
+    { 8,  0,  1,  1,  1 },
+    { 8, -1,  1,  0,  1 },
+    { 8, -1,  0, -1, -1 },
+    { 8,  0,  1,  1, -1 },
+    { 8,  1, -1,  0, -1 },
+    { 8,  0, -1,  1,  1 },
+    { 8,  1,  1,  0,  1 },
+    { 8,  1, -1,  1, -1 },
+
+    /* 8/9 bit codewords */
+    { 8, -1,  1, -1,  1 }, { 8, -1,  1, -1,  1 },
+    { 9,  1, -1, -1,  1 },
+    { 9, -1, -1, -1, -1 },
+    { 9, -1,  1,  1, -1 },
+    { 9, -1,  1,  1,  1 },
+    { 9,  1,  1,  1,  1 },
+    { 9, -1, -1,  1, -1 },
+    { 9,  1, -1,  1,  1 },
+    { 9, -1,  1, -1, -1 },
+    { 9, -1, -1,  1,  1 },
+    { 9,  1,  1, -1, -1 },
+    { 9,  1, -1, -1, -1 },
+    { 9, -1, -1, -1,  1 },
+    { 9,  1,  1, -1,  1 },
+    { 9,  1,  1,  1, -1 }
+};
--- /dev/null
+++ b/libfaad/codebook/hcb_3.c
@@ -1,0 +1,189 @@
+/*
+** FAAD - Freeware Advanced Audio Decoder
+** Copyright (C) 2002 M. Bakker
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+**
+** $Id: hcb_3.c,v 1.1 2002/02/15 20:52:10 menno Exp $
+**/
+
+#include "hcb.h"
+
+/* Binary search huffman table HCB_3 */
+
+
+extern hcb_bin_quad hcb3[] = {
+    { /*  0 */ 0, {  1,  2, 0, 0 } },
+    { /*  1 */ 1, {  0,  0, 0, 0 } }, /* 0 */
+    { /*  2 */ 0, {  1,  2, 0, 0 } },
+    { /*  3 */ 0, {  2,  3, 0, 0 } },
+    { /*  4 */ 0, {  3,  4, 0, 0 } },
+    { /*  5 */ 0, {  4,  5, 0, 0 } },
+    { /*  6 */ 0, {  5,  6, 0, 0 } },
+    { /*  7 */ 0, {  6,  7, 0, 0 } },
+    { /*  8 */ 0, {  7,  8, 0, 0 } },
+    { /*  9 */ 1, {  1,  0, 0, 0 } }, /* 1000 */
+    { /* 10 */ 1, {  0,  0, 0, 1 } }, /* 1001 */
+    { /* 11 */ 1, {  0,  1, 0, 0 } }, /* 1010 */
+    { /* 12 */ 1, {  0,  0, 1, 0 } }, /* 1011 */
+    { /* 13 */ 0, {  4,  5, 0, 0 } },
+    { /* 14 */ 0, {  5,  6, 0, 0 } },
+    { /* 15 */ 0, {  6,  7, 0, 0 } },
+    { /* 16 */ 0, {  7,  8, 0, 0 } },
+    { /* 17 */ 1, {  1,  1, 0, 0 } },
+    { /* 18 */ 1, {  0,  0, 1, 1 } },
+    { /* 19 */ 0, {  6,  7, 0, 0 } },
+    { /* 20 */ 0, {  7,  8, 0, 0 } },
+    { /* 21 */ 0, {  8,  9, 0, 0 } },
+    { /* 22 */ 0, {  9, 10, 0, 0 } },
+    { /* 23 */ 0, { 10, 11, 0, 0 } },
+    { /* 24 */ 0, { 11, 12, 0, 0 } },
+    { /* 25 */ 1, {  0,  1, 1, 0 } }, /* 110100 */
+    { /* 26 */ 1, {  0,  1, 0, 1 } }, /* 110101 */
+    { /* 27 */ 1, {  1,  0, 1, 0 } }, /* 110110 */
+    { /* 28 */ 1, {  0,  1, 1, 1 } }, /* 110111 */
+    { /* 29 */ 1, {  1,  0, 0, 1 } }, /* 111000 */
+    { /* 30 */ 1, {  1,  1, 1, 0 } }, /* 111001 */
+    { /* 31 */ 0, {  6,  7, 0, 0 } },
+    { /* 32 */ 0, {  7,  8, 0, 0 } },
+    { /* 33 */ 0, {  8,  9, 0, 0 } },
+    { /* 34 */ 0, {  9, 10, 0, 0 } },
+    { /* 35 */ 0, { 10, 11, 0, 0 } },
+    { /* 36 */ 0, { 11, 12, 0, 0 } },
+    { /* 37 */ 1, {  1,  1, 1, 1 } }, /* 1110100 */
+    { /* 38 */ 1, {  1,  0, 1, 1 } }, /* 1110101 */
+    { /* 39 */ 1, {  1,  1, 0, 1 } }, /* 1110110 */
+    { /* 40 */ 0, {  9, 10, 0, 0 } },
+    { /* 41 */ 0, { 10, 11, 0, 0 } },
+    { /* 42 */ 0, { 11, 12, 0, 0 } },
+    { /* 43 */ 0, { 12, 13, 0, 0 } },
+    { /* 44 */ 0, { 13, 14, 0, 0 } },
+    { /* 45 */ 0, { 14, 15, 0, 0 } },
+    { /* 46 */ 0, { 15, 16, 0, 0 } },
+    { /* 47 */ 0, { 16, 17, 0, 0 } },
+    { /* 48 */ 0, { 17, 18, 0, 0 } },
+    { /* 49 */ 1, {  2,  0, 0, 0 } }, /* 11101110 */
+    { /* 50 */ 1, {  0,  0, 0, 2 } }, /* 11101111 */
+    { /* 51 */ 1, {  0,  0, 1, 2 } }, /* 11110000 */
+    { /* 52 */ 1, {  2,  1, 0, 0 } }, /* 11110001 */
+    { /* 53 */ 1, {  1,  2, 1, 0 } }, /* 11110010 */
+    { /* 54 */ 0, { 13, 14, 0, 0 } },
+    { /* 55 */ 0, { 14, 15, 0, 0 } },
+    { /* 56 */ 0, { 15, 16, 0, 0 } },
+    { /* 57 */ 0, { 16, 17, 0, 0 } },
+    { /* 58 */ 0, { 17, 18, 0, 0 } },
+    { /* 59 */ 0, { 18, 19, 0, 0 } },
+    { /* 60 */ 0, { 19, 20, 0, 0 } },
+    { /* 61 */ 0, { 20, 21, 0, 0 } },
+    { /* 62 */ 0, { 21, 22, 0, 0 } },
+    { /* 63 */ 0, { 22, 23, 0, 0 } },
+    { /* 64 */ 0, { 23, 24, 0, 0 } },
+    { /* 65 */ 0, { 24, 25, 0, 0 } },
+    { /* 66 */ 0, { 25, 26, 0, 0 } },
+    { /* 67 */ 1, {  0,  0, 2, 1 } },
+    { /* 68 */ 1, {  0,  1, 2, 1 } },
+    { /* 69 */ 1, {  1,  2, 0, 0 } },
+    { /* 70 */ 1, {  0,  1, 1, 2 } },
+    { /* 71 */ 1, {  2,  1, 1, 0 } },
+    { /* 72 */ 1, {  0,  0, 2, 0 } },
+    { /* 73 */ 1, {  0,  2, 1, 0 } },
+    { /* 74 */ 1, {  0,  1, 2, 0 } },
+    { /* 75 */ 1, {  0,  2, 0, 0 } },
+    { /* 76 */ 1, {  0,  1, 0, 2 } },
+    { /* 77 */ 1, {  2,  0, 1, 0 } },
+    { /* 78 */ 1, {  1,  2, 1, 1 } },
+    { /* 79 */ 1, {  0,  2, 1, 1 } },
+    { /* 80 */ 1, {  1,  1, 2, 0 } },
+    { /* 81 */ 1, {  1,  1, 2, 1 } },
+    { /* 82 */ 0, { 11, 12, 0, 0 } },
+    { /* 83 */ 0, { 12, 13, 0, 0 } },
+    { /* 84 */ 0, { 13, 14, 0, 0 } },
+    { /* 85 */ 0, { 14, 15, 0, 0 } },
+    { /* 86 */ 0, { 15, 16, 0, 0 } },
+    { /* 87 */ 0, { 16, 17, 0, 0 } },
+    { /* 88 */ 0, { 17, 18, 0, 0 } },
+    { /* 89 */ 0, { 18, 19, 0, 0 } },
+    { /* 90 */ 0, { 19, 20, 0, 0 } },
+    { /* 91 */ 0, { 20, 21, 0, 0 } },
+    { /* 92 */ 0, { 21, 22, 0, 0 } },
+    { /* 93 */ 1, {  1,  2,  0,  1 } }, /* 1111101010 */
+    { /* 94 */ 1, {  1,  0,  2,  0 } }, /* 1111101011 */
+    { /* 95 */ 1, {  1,  0,  2,  1 } }, /* 1111101100 */
+    { /* 96 */ 1, {  0,  2,  0,  1 } }, /* 1111101101 */
+    { /* 97 */ 1, {  2,  1,  1,  1 } }, /* 1111101110 */
+    { /* 98 */ 1, {  1,  1,  1,  2 } }, /* 1111101111 */
+    { /* 99 */ 1, {  2,  1,  0,  1 } }, /* 1111110000 */
+    { /* 00 */ 1, {  1,  0,  1,  2 } }, /* 1111110001 */
+    { /* 01 */ 1, {  0,  0,  2,  2 } }, /* 1111110010 */
+    { /* 02 */ 1, {  0,  1,  2,  2 } }, /* 1111110011 */
+    { /* 03 */ 1, {  2,  2,  1,  0 } }, /* 1111110100 */
+    { /* 04 */ 1, {  1,  2,  2,  0 } }, /* 1111110101 */
+    { /* 05 */ 1, {  1,  0,  0,  2 } }, /* 1111110110 */
+    { /* 06 */ 1, {  2,  0,  0,  1 } }, /* 1111110111 */
+    { /* 07 */ 1, {  0,  2,  2,  1 } }, /* 1111111000 */
+    { /* 08 */ 0, {  7,  8, 0, 0 } },
+    { /* 09 */ 0, {  8,  9, 0, 0 } },
+    { /* 10 */ 0, {  9, 10, 0, 0 } },
+    { /* 11 */ 0, { 10, 11, 0, 0 } },
+    { /* 12 */ 0, { 11, 12, 0, 0 } },
+    { /* 13 */ 0, { 12, 13, 0, 0 } },
+    { /* 14 */ 0, { 13, 14, 0, 0 } },
+    { /* 15 */ 1, {  2,  2,  0,  0 } }, /* 11111110010 */
+    { /* 16 */ 1, {  1,  2,  2,  1 } }, /* 11111110011 */
+    { /* 17 */ 1, {  1,  1,  0,  2 } }, /* 11111110100 */
+    { /* 18 */ 1, {  2,  0,  1,  1 } }, /* 11111110101 */
+    { /* 19 */ 1, {  1,  1,  2,  2 } }, /* 11111110110 */
+    { /* 20 */ 1, {  2,  2,  1,  1 } }, /* 11111110111 */
+    { /* 21 */ 1, {  0,  2,  2,  0 } }, /* 11111111000 */
+    { /* 22 */ 1, {  0,  2,  1,  2 } }, /* 11111111001 */
+    { /* 23 */ 0, {  6,  7, 0, 0 } },
+    { /* 24 */ 0, {  7,  8, 0, 0 } },
+    { /* 25 */ 0, {  8,  9, 0, 0 } },
+    { /* 26 */ 0, {  9, 10, 0, 0 } },
+    { /* 27 */ 0, { 10, 11, 0, 0 } },
+    { /* 28 */ 0, { 11, 12, 0, 0 } },
+    { /* 29 */ 1, {  1,  0,  2,  2 } }, /* 111111110100 */
+    { /* 30 */ 1, {  2,  2,  0,  1 } }, /* 111111110101 */
+    { /* 31 */ 1, {  2,  1,  2,  0 } }, /* 111111110110 */
+    { /* 32 */ 1, {  2,  2,  2,  0 } }, /* 111111110111 */
+    { /* 33 */ 1, {  0,  2,  2,  2 } }, /* 111111111000 */
+    { /* 34 */ 1, {  2,  2,  2,  1 } }, /* 111111111001 */
+    { /* 35 */ 1, {  2,  1,  2,  1 } }, /* 111111111010 */
+    { /* 36 */ 1, {  1,  2,  1,  2 } }, /* 111111111011 */
+    { /* 37 */ 1, {  1,  2,  2,  2 } }, /* 111111111100 */
+    { /* 38 */ 0, {  3,  4, 0, 0 } },
+    { /* 39 */ 0, {  4,  5, 0, 0 } },
+    { /* 40 */ 0, {  5,  6, 0, 0 } },
+    { /* 41 */ 1, {  0,  2,  0,  2 } }, /* 1111111111010 */
+    { /* 42 */ 1, {  2,  0,  2,  0 } }, /* 1111111111011 */
+    { /* 43 */ 1, {  1,  2,  0,  2 } }, /* 1111111111100 */
+    { /* 44 */ 0, {  3, 4, 0, 0 } },
+    { /* 45 */ 0, {  4, 5, 0, 0 } },
+    { /* 46 */ 0, {  5, 6, 0, 0 } },
+    { /* 47 */ 1, {  2,  0,  2,  1 } }, /* 11111111111010 */
+    { /* 48 */ 1, {  2,  1,  1,  2 } }, /* 11111111111011 */
+    { /* 49 */ 1, {  2,  1,  0,  2 } }, /* 11111111111100 */
+    { /* 50 */ 0, { 3, 4, 0, 0 } },
+    { /* 51 */ 0, { 4, 5, 0, 0 } },
+    { /* 52 */ 0, { 5, 6, 0, 0 } },
+    { /* 53 */ 1, {  2,  2,  2,  2 } }, /* 111111111111010 */
+    { /* 54 */ 1, {  2,  2,  1,  2 } }, /* 111111111111011 */
+    { /* 55 */ 1, {  2,  1,  2,  2 } }, /* 111111111111100 */
+    { /* 56 */ 1, {  2,  0,  1,  2 } }, /* 111111111111101 */
+    { /* 57 */ 1, {  2,  0,  0,  2 } }, /* 111111111111110 */
+    { /* 58 */ 0, { 1, 2, 0, 0 } },
+    { /* 59 */ 1, {  2,  2,  0,  2 } }, /* 1111111111111110 */
+    { /* 60 */ 1, {  2,  0,  2,  2 } }  /* 1111111111111111 */
+};
--- /dev/null
+++ b/libfaad/codebook/hcb_4.c
@@ -1,0 +1,192 @@
+/*
+** FAAD - Freeware Advanced Audio Decoder
+** Copyright (C) 2002 M. Bakker
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+**
+** $Id: hcb_4.c,v 1.1 2002/02/15 20:52:10 menno Exp $
+**/
+
+#include "hcb.h"
+
+/* 2-step huffman table HCB_4 */
+
+
+/* 1st step: 5 bits
+ *           2^5 = 32 entries
+ *
+ * Used to find offset into 2nd step table and number of extra bits to get
+ */
+extern hcb hcb4_1[] = {
+    /* 4 bit codewords */
+    { /* 00000 */ 0, 0 },
+    { /*       */ 0, 0 },
+    { /* 00010 */ 1, 0 },
+    { /*       */ 1, 0 },
+    { /* 00100 */ 2, 0 },
+    { /*       */ 2, 0 },
+    { /* 00110 */ 3, 0 },
+    { /*       */ 3, 0 },
+    { /* 01000 */ 4, 0 },
+    { /*       */ 4, 0 },
+    { /* 01010 */ 5, 0 },
+    { /*       */ 5, 0 },
+    { /* 01100 */ 6, 0 },
+    { /*       */ 6, 0 },
+    { /* 01110 */ 7, 0 },
+    { /*       */ 7, 0 },
+    { /* 10000 */ 8, 0 },
+    { /*       */ 8, 0 },
+    { /* 10010 */ 9, 0 },
+    { /*       */ 9, 0 },
+
+    /* 5 bit codewords */
+    { /* 10100 */ 10, 0 },
+    { /* 10101 */ 11, 0 },
+    { /* 10110 */ 12, 0 },
+    { /* 10111 */ 13, 0 },
+    { /* 11000 */ 14, 0 },
+    { /* 11001 */ 15, 0 },
+
+    /* 7 bit codewords */
+    { /* 11010 */ 16, 2 },
+    { /* 11011 */ 20, 2 },
+
+    /* 7/8 bit codewords */
+    { /* 11100 */ 24, 3 },
+
+    /* 8 bit codewords */
+    { /* 11101 */ 32, 3 },
+
+    /* 8/9 bit codewords */
+    { /* 11110 */ 40, 4 },
+
+    /* 9/10/11/12 bit codewords */
+    { /* 11111 */ 56, 7 }
+};
+
+/* 2nd step table
+ *
+ * Gives size of codeword and actual data (x,y,v,w)
+ */
+extern hcb_2_quad hcb4_2[] = {
+    /* 4 bit codewords */
+    { 4,  1,  1,  1,  1 },
+    { 4,  0,  1,  1,  1 },
+    { 4,  1,  1,  0,  1 },
+    { 4,  1,  1,  1,  0 },
+    { 4,  1,  0,  1,  1 },
+    { 4,  1,  0,  0,  0 },
+    { 4,  1,  1,  0,  0 },
+    { 4,  0,  0,  0,  0 },
+    { 4,  0,  0,  1,  1 },
+    { 4,  1,  0,  1,  0 },
+
+    /* 5 bit codewords */
+    { 5,  1,  0,  0,  1 },
+    { 5,  0,  1,  1,  0 },
+    { 5,  0,  0,  0,  1 },
+    { 5,  0,  1,  0,  1 },
+    { 5,  0,  0,  1,  0 },
+    { 5,  0,  1,  0,  0 },
+
+    /* 7 bit codewords */
+    /* first 5 bits: 11010 */
+    { 7,  2,  1,  1,  1 },
+    { 7,  1,  1,  2,  1 },
+    { 7,  1,  2,  1,  1 },
+    { 7,  1,  1,  1,  2 },
+    /* first 5 bits: 11011 */
+    { 7,  2,  1,  1,  0 },
+    { 7,  2,  1,  0,  1 },
+    { 7,  1,  2,  1,  0 },
+    { 7,  2,  0,  1,  1 },
+
+    /* 7/8 bit codewords */
+    /* first 5 bits: 11100 */
+    { 7,  0,  1,  2,  1 }, { 7,  0,  1,  2,  1 },
+    { 8,  0,  1,  1,  2 },
+    { 8,  1,  1,  2,  0 },
+    { 8,  0,  2,  1,  1 },
+    { 8,  1,  0,  1,  2 },
+    { 8,  1,  2,  0,  1 },
+    { 8,  1,  1,  0,  2 },
+
+    /* 8 bit codewords */
+    { 8,  1,  0,  2,  1 },
+    { 8,  2,  1,  0,  0 },
+    { 8,  2,  0,  1,  0 },
+    { 8,  1,  2,  0,  0 },
+    { 8,  2,  0,  0,  1 },
+    { 8,  0,  1,  0,  2 },
+    { 8,  0,  2,  1,  0 },
+    { 8,  0,  0,  1,  2 },
+
+    /* 8/9 bit codewords */
+    { 8,  0,  1,  2,  0 }, { 8,  0,  1,  2,  0 },
+    { 8,  0,  2,  0,  1 }, { 8,  0,  2,  0,  1 },
+    { 8,  1,  0,  0,  2 }, { 8,  1,  0,  0,  2 },
+    { 8,  0,  0,  2,  1 }, { 8,  0,  0,  2,  1 },
+    { 8,  1,  0,  2,  0 }, { 8,  1,  0,  2,  0 },
+    { 8,  2,  0,  0,  0 }, { 8,  2,  0,  0,  0 },
+    { 8,  0,  0,  0,  2 }, { 8,  0,  0,  0,  2 },
+    { 9,  0,  2,  0,  0 },
+    { 9,  0,  0,  2,  0 },
+
+    /* 9/10/11 bit codewords */
+    /* 9 bit codewords repeated 2^3 = 8 times */
+    { 9,  1,  2,  2,  1 }, { 9,  1,  2,  2,  1 }, { 9,  1,  2,  2,  1 }, { 9,  1,  2,  2,  1 },
+    { 9,  1,  2,  2,  1 }, { 9,  1,  2,  2,  1 }, { 9,  1,  2,  2,  1 }, { 9,  1,  2,  2,  1 },
+    { 9,  2,  2,  1,  1 }, { 9,  2,  2,  1,  1 }, { 9,  2,  2,  1,  1 }, { 9,  2,  2,  1,  1 },
+    { 9,  2,  2,  1,  1 }, { 9,  2,  2,  1,  1 }, { 9,  2,  2,  1,  1 }, { 9,  2,  2,  1,  1 },
+    { 9,  2,  1,  2,  1 }, { 9,  2,  1,  2,  1 }, { 9,  2,  1,  2,  1 }, { 9,  2,  1,  2,  1 },
+    { 9,  2,  1,  2,  1 }, { 9,  2,  1,  2,  1 }, { 9,  2,  1,  2,  1 }, { 9,  2,  1,  2,  1 },
+    { 9,  1,  1,  2,  2 }, { 9,  1,  1,  2,  2 }, { 9,  1,  1,  2,  2 }, { 9,  1,  1,  2,  2 },
+    { 9,  1,  1,  2,  2 }, { 9,  1,  1,  2,  2 }, { 9,  1,  1,  2,  2 }, { 9,  1,  1,  2,  2 },
+    { 9,  1,  2,  1,  2 }, { 9,  1,  2,  1,  2 }, { 9,  1,  2,  1,  2 }, { 9,  1,  2,  1,  2 },
+    { 9,  1,  2,  1,  2 }, { 9,  1,  2,  1,  2 }, { 9,  1,  2,  1,  2 }, { 9,  1,  2,  1,  2 },
+    { 9,  2,  1,  1,  2 }, { 9,  2,  1,  1,  2 }, { 9,  2,  1,  1,  2 }, { 9,  2,  1,  1,  2 },
+    { 9,  2,  1,  1,  2 }, { 9,  2,  1,  1,  2 }, { 9,  2,  1,  1,  2 }, { 9,  2,  1,  1,  2 },
+    /* 10 bit codewords repeated 2^2 = 4 times */
+    { 10,  1,  2,  2,  0 }, { 10,  1,  2,  2,  0 }, { 10,  1,  2,  2,  0 }, { 10,  1,  2,  2,  0 },
+    { 10,  2,  2,  1,  0 }, { 10,  2,  2,  1,  0 }, { 10,  2,  2,  1,  0 }, { 10,  2,  2,  1,  0 },
+    { 10,  2,  1,  2,  0 }, { 10,  2,  1,  2,  0 }, { 10,  2,  1,  2,  0 }, { 10,  2,  1,  2,  0 },
+    { 10,  0,  2,  2,  1 }, { 10,  0,  2,  2,  1 }, { 10,  0,  2,  2,  1 }, { 10,  0,  2,  2,  1 },
+    { 10,  0,  1,  2,  2 }, { 10,  0,  1,  2,  2 }, { 10,  0,  1,  2,  2 }, { 10,  0,  1,  2,  2 },
+    { 10,  2,  2,  0,  1 }, { 10,  2,  2,  0,  1 }, { 10,  2,  2,  0,  1 }, { 10,  2,  2,  0,  1 },
+    { 10,  0,  2,  1,  2 }, { 10,  0,  2,  1,  2 }, { 10,  0,  2,  1,  2 }, { 10,  0,  2,  1,  2 },
+    { 10,  2,  0,  2,  1 }, { 10,  2,  0,  2,  1 }, { 10,  2,  0,  2,  1 }, { 10,  2,  0,  2,  1 },
+    { 10,  1,  0,  2,  2 }, { 10,  1,  0,  2,  2 }, { 10,  1,  0,  2,  2 }, { 10,  1,  0,  2,  2 },
+    { 10,  2,  2,  2,  1 }, { 10,  2,  2,  2,  1 }, { 10,  2,  2,  2,  1 }, { 10,  2,  2,  2,  1 },
+    { 10,  1,  2,  0,  2 }, { 10,  1,  2,  0,  2 }, { 10,  1,  2,  0,  2 }, { 10,  1,  2,  0,  2 },
+    { 10,  2,  0,  1,  2 }, { 10,  2,  0,  1,  2 }, { 10,  2,  0,  1,  2 }, { 10,  2,  0,  1,  2 },
+    { 10,  2,  1,  0,  2 }, { 10,  2,  1,  0,  2 }, { 10,  2,  1,  0,  2 }, { 10,  2,  1,  0,  2 },
+    { 10,  1,  2,  2,  2 }, { 10,  1,  2,  2,  2 }, { 10,  1,  2,  2,  2 }, { 10,  1,  2,  2,  2 },
+    /* 11 bit codewords repeated 2^1 = 2 times */
+    { 11,  2,  1,  2,  2 }, { 11,  2,  1,  2,  2 },
+    { 11,  2,  2,  1,  2 }, { 11,  2,  2,  1,  2 },
+    { 11,  0,  2,  2,  0 }, { 11,  0,  2,  2,  0 },
+    { 11,  2,  2,  0,  0 }, { 11,  2,  2,  0,  0 },
+    { 11,  0,  0,  2,  2 }, { 11,  0,  0,  2,  2 },
+    { 11,  2,  0,  2,  0 }, { 11,  2,  0,  2,  0 },
+    { 11,  0,  2,  0,  2 }, { 11,  0,  2,  0,  2 },
+    { 11,  2,  0,  0,  2 }, { 11,  2,  0,  0,  2 },
+    { 11,  2,  2,  2,  2 }, { 11,  2,  2,  2,  2 },
+    { 11,  0,  2,  2,  2 }, { 11,  0,  2,  2,  2 },
+    { 11,  2,  2,  2,  0 }, { 11,  2,  2,  2,  0 },
+    /* 12 bit codewords */
+    { 12,  2,  2,  0,  2 },
+    { 12,  2,  0,  2,  2 },
+};
--- /dev/null
+++ b/libfaad/codebook/hcb_5.c
@@ -1,0 +1,189 @@
+/*
+** FAAD - Freeware Advanced Audio Decoder
+** Copyright (C) 2002 M. Bakker
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+**
+** $Id: hcb_5.c,v 1.1 2002/02/15 20:52:10 menno Exp $
+**/
+
+#include "hcb.h"
+
+/* Binary search huffman table HCB_5 */
+
+
+extern hcb_bin_pair hcb5[] = {
+    { /*  0 */ 0, {  1,  2 } },
+    { /*  1 */ 1, {  0,  0 } }, /* 0 */
+    { /*  2 */ 0, {  1,  2 } },
+    { /*  3 */ 0, {  2,  3 } },
+    { /*  4 */ 0, {  3,  4 } },
+    { /*  5 */ 0, {  4,  5 } },
+    { /*  6 */ 0, {  5,  6 } },
+    { /*  7 */ 0, {  6,  7 } },
+    { /*  8 */ 0, {  7,  8 } },
+    { /*  9 */ 1, { -1,  0 } }, /* 1000 */
+    { /* 10 */ 1, {  1,  0 } }, /* 1001 */
+    { /* 11 */ 1, {  0,  1 } }, /* 1010 */
+    { /* 12 */ 1, {  0, -1 } }, /* 1011 */
+    { /* 13 */ 0, {  4,  5 } },
+    { /* 14 */ 0, {  5,  6 } },
+    { /* 15 */ 0, {  6,  7 } },
+    { /* 16 */ 0, {  7,  8 } },
+    { /* 17 */ 1, {  1, -1 } },
+    { /* 18 */ 1, { -1,  1 } },
+    { /* 19 */ 1, { -1, -1 } },
+    { /* 20 */ 1, {  1,  1 } },
+    { /* 21 */ 0, {  4,  5 } },
+    { /* 22 */ 0, {  5,  6 } },
+    { /* 23 */ 0, {  6,  7 } },
+    { /* 24 */ 0, {  7,  8 } },
+    { /* 25 */ 0, {  8,  9 } },
+    { /* 26 */ 0, {  9, 10 } },
+    { /* 27 */ 0, { 10, 11 } },
+    { /* 28 */ 0, { 11, 12 } },
+    { /* 29 */ 0, { 12, 13 } },
+    { /* 30 */ 0, { 13, 14 } },
+    { /* 31 */ 0, { 14, 15 } },
+    { /* 32 */ 0, { 15, 16 } },
+    { /* 33 */ 1, { -2,  0 } },
+    { /* 34 */ 1, {  0,  2 } },
+    { /* 35 */ 1, {  2,  0 } },
+    { /* 36 */ 1, {  0, -2 } },
+    { /* 37 */ 0, { 12, 13 } },
+    { /* 38 */ 0, { 13, 14 } },
+    { /* 39 */ 0, { 14, 15 } },
+    { /* 40 */ 0, { 15, 16 } },
+    { /* 41 */ 0, { 16, 17 } },
+    { /* 42 */ 0, { 17, 18 } },
+    { /* 43 */ 0, { 18, 19 } },
+    { /* 44 */ 0, { 19, 20 } },
+    { /* 45 */ 0, { 20, 21 } },
+    { /* 46 */ 0, { 21, 22 } },
+    { /* 47 */ 0, { 22, 23 } },
+    { /* 48 */ 0, { 23, 24 } },
+    { /* 49 */ 1, { -2, -1 } },
+    { /* 50 */ 1, {  2,  1 } },
+    { /* 51 */ 1, { -1, -2 } },
+    { /* 52 */ 1, {  1,  2 } },
+    { /* 53 */ 1, { -2,  1 } },
+    { /* 54 */ 1, {  2, -1 } },
+    { /* 55 */ 1, { -1,  2 } },
+    { /* 56 */ 1, {  1, -2 } },
+    { /* 57 */ 1, { -3,  0 } },
+    { /* 58 */ 1, {  3,  0 } },
+    { /* 59 */ 1, {  0, -3 } },
+    { /* 60 */ 1, {  0,  3 } },
+    { /* 61 */ 0, { 12, 13 } },
+    { /* 62 */ 0, { 13, 14 } },
+    { /* 63 */ 0, { 14, 15 } },
+    { /* 64 */ 0, { 15, 16 } },
+    { /* 65 */ 0, { 16, 17 } },
+    { /* 66 */ 0, { 17, 18 } },
+    { /* 67 */ 0, { 18, 19 } },
+    { /* 68 */ 0, { 19, 20 } },
+    { /* 69 */ 0, { 20, 21 } },
+    { /* 70 */ 0, { 21, 22 } },
+    { /* 71 */ 0, { 22, 23 } },
+    { /* 72 */ 0, { 23, 24 } },
+    { /* 73 */ 1, { -3, -1 } },
+    { /* 74 */ 1, {  1,  3 } },
+    { /* 75 */ 1, {  3,  1 } },
+    { /* 76 */ 1, { -1, -3 } },
+    { /* 77 */ 1, { -3,  1 } },
+    { /* 78 */ 1, {  3, -1 } },
+    { /* 79 */ 1, {  1, -3 } },
+    { /* 80 */ 1, { -1,  3 } },
+    { /* 81 */ 1, { -2,  2 } },
+    { /* 82 */ 1, {  2,  2 } },
+    { /* 83 */ 1, { -2, -2 } },
+    { /* 84 */ 1, {  2, -2 } },
+    { /* 85 */ 0, { 12, 13 } },
+    { /* 86 */ 0, { 13, 14 } },
+    { /* 87 */ 0, { 14, 15 } },
+    { /* 88 */ 0, { 15, 16 } },
+    { /* 89 */ 0, { 16, 17 } },
+    { /* 90 */ 0, { 17, 18 } },
+    { /* 91 */ 0, { 18, 19 } },
+    { /* 92 */ 0, { 19, 20 } },
+    { /* 93 */ 0, { 20, 21 } },
+    { /* 94 */ 0, { 21, 22 } },
+    { /* 95 */ 0, { 22, 23 } },
+    { /* 96 */ 0, { 23, 24 } },
+    { /* 97 */ 1, { -3, -2 } },
+    { /* 98 */ 1, {  3, -2 } },
+    { /* 99 */ 1, { -2,  3 } },
+    { /* 00 */ 1, {  2, -3 } },
+    { /* 01 */ 1, {  3,  2 } },
+    { /* 02 */ 1, {  2,  3 } },
+    { /* 03 */ 1, { -3,  2 } },
+    { /* 04 */ 1, { -2, -3 } },
+    { /* 05 */ 1, {  0, -4 } },
+    { /* 06 */ 1, { -4,  0 } },
+    { /* 07 */ 1, {  4,  1 } },
+    { /* 08 */ 1, {  4,  0 } },
+    { /* 09 */ 0, { 12, 13 } },
+    { /* 10 */ 0, { 13, 14 } },
+    { /* 11 */ 0, { 14, 15 } },
+    { /* 12 */ 0, { 15, 16 } },
+    { /* 13 */ 0, { 16, 17 } },
+    { /* 14 */ 0, { 17, 18 } },
+    { /* 15 */ 0, { 18, 19 } },
+    { /* 16 */ 0, { 19, 20 } },
+    { /* 17 */ 0, { 20, 21 } },
+    { /* 18 */ 0, { 21, 22 } },
+    { /* 19 */ 0, { 22, 23 } },
+    { /* 20 */ 0, { 23, 24 } },
+    { /* 21 */ 1, { -4, -1 } },
+    { /* 22 */ 1, {  0,  4 } },
+    { /* 23 */ 1, {  4, -1 } },
+    { /* 24 */ 1, { -1, -4 } },
+    { /* 25 */ 1, {  1,  4 } },
+    { /* 26 */ 1, { -1,  4 } },
+    { /* 27 */ 1, { -4,  1 } },
+    { /* 28 */ 1, {  1, -4 } },
+    { /* 29 */ 1, {  3, -3 } },
+    { /* 30 */ 1, { -3, -3 } },
+    { /* 31 */ 1, { -3,  3 } },
+    { /* 32 */ 1, { -2,  4 } },
+    { /* 33 */ 1, { -4, -2 } },
+    { /* 34 */ 1, {  4,  2 } },
+    { /* 35 */ 1, {  2, -4 } },
+    { /* 36 */ 1, {  2,  4 } },
+    { /* 37 */ 1, {  3,  3 } },
+    { /* 38 */ 1, { -4,  2 } },
+    { /* 39 */ 0, { 6, 7 } },
+    { /* 40 */ 0, { 7, 8 } },
+    { /* 41 */ 0, { 8, 9 } },
+    { /* 42 */ 0, { 9, 10 } },
+    { /* 43 */ 0, { 10, 11 } },
+    { /* 44 */ 0, { 11, 12 } },
+    { /* 45 */ 1, { -2, -4 } },
+    { /* 46 */ 1, {  4, -2 } },
+    { /* 47 */ 1, {  3, -4 } },
+    { /* 48 */ 1, { -4, -3 } },
+    { /* 49 */ 1, { -4,  3 } },
+    { /* 50 */ 1, {  3,  4 } },
+    { /* 51 */ 1, { -3,  4 } },
+    { /* 52 */ 1, {  4,  3 } },
+    { /* 53 */ 1, {  4, -3 } },
+    { /* 54 */ 1, { -3, -4 } },
+    { /* 55 */ 0, { 2, 3 } },
+    { /* 56 */ 0, { 3, 4 } },
+    { /* 57 */ 1, {  4, -4 } },
+    { /* 58 */ 1, { -4,  4 } },
+    { /* 59 */ 1, {  4,  4 } },
+    { /* 60 */ 1, { -4, -4 } }
+};
--- /dev/null
+++ b/libfaad/codebook/hcb_6.c
@@ -1,0 +1,175 @@
+/*
+** FAAD - Freeware Advanced Audio Decoder
+** Copyright (C) 2002 M. Bakker
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+**
+** $Id: hcb_6.c,v 1.1 2002/02/15 20:52:10 menno Exp $
+**/
+
+#include "hcb.h"
+
+/* 2-step huffman table HCB_6 */
+
+
+/* 1st step: 5 bits
+ *           2^5 = 32 entries
+ *
+ * Used to find offset into 2nd step table and number of extra bits to get
+ */
+extern hcb hcb6_1[] = {
+    /* 4 bit codewords */
+    { /* 00000 */ 0, 0 },
+    { /*       */ 0, 0 },
+    { /* 00010 */ 1, 0 },
+    { /*       */ 1, 0 },
+    { /* 00100 */ 2, 0 },
+    { /*       */ 2, 0 },
+    { /* 00110 */ 3, 0 },
+    { /*       */ 3, 0 },
+    { /* 01000 */ 4, 0 },
+    { /*       */ 4, 0 },
+    { /* 01010 */ 5, 0 },
+    { /*       */ 5, 0 },
+    { /* 01100 */ 6, 0 },
+    { /*       */ 6, 0 },
+    { /* 01110 */ 7, 0 },
+    { /*       */ 7, 0 },
+    { /* 10000 */ 8, 0 },
+    { /*       */ 8, 0 },
+
+    /* 6 bit codewords */
+    { /* 10010 */ 9, 1 },
+    { /* 10011 */ 11, 1 },
+    { /* 10100 */ 13, 1 },
+    { /* 10101 */ 15, 1 },
+    { /* 10110 */ 17, 1 },
+    { /* 10111 */ 19, 1 },
+    { /* 11000 */ 21, 1 },
+    { /* 11001 */ 23, 1 },
+
+    /* 7 bit codewords */
+    { /* 11010 */ 25, 2 },
+    { /* 11011 */ 29, 2 },
+    { /* 11100 */ 33, 2 },
+
+    /* 7/8 bit codewords */
+    { /* 11101 */ 37, 3 },
+
+    /* 8/9 bit codewords */
+    { /* 11110 */ 45, 4 },
+
+    /* 9/10/11 bit codewords */
+    { /* 11111 */ 61, 6 }
+};
+
+/* 2nd step table
+ *
+ * Gives size of codeword and actual data (x,y,v,w)
+ */
+extern hcb_2_pair hcb6_2[] = {
+    /* 4 bit codewords */
+    { 4,  0,  0 },
+    { 4,  1,  0 },
+    { 4,  0, -1 },
+    { 4,  0,  1 },
+    { 4, -1,  0 },
+    { 4,  1,  1 },
+    { 4, -1,  1 },
+    { 4,  1, -1 },
+    { 4, -1, -1 },
+
+    /* 6 bit codewords */
+    { 6,  2, -1 },
+    { 6,  2,  1 },
+    { 6, -2,  1 },
+    { 6, -2, -1 },
+    { 6, -2,  0 },
+    { 6, -1,  2 },
+    { 6,  2,  0 },
+    { 6,  1, -2 },
+    { 6,  1,  2 },
+    { 6,  0, -2 },
+    { 6, -1, -2 },
+    { 6,  0,  2 },
+    { 6,  2, -2 },
+    { 6, -2,  2 },
+    { 6, -2, -2 },
+    { 6,  2,  2 },
+
+    /* 7 bit codewords */
+    { 7, -3,  1 },
+    { 7,  3,  1 },
+    { 7,  3, -1 },
+    { 7, -1,  3 },
+    { 7, -3, -1 },
+    { 7,  1,  3 },
+    { 7,  1, -3 },
+    { 7, -1, -3 },
+    { 7,  3,  0 },
+    { 7, -3,  0 },
+    { 7,  0, -3 },
+    { 7,  0,  3 },
+
+    /* 7/8 bit codewords */
+    { 7,  3,  2 }, { 7,  3,  2 },
+    { 8, -3, -2 },
+    { 8, -2,  3 },
+    { 8,  2,  3 },
+    { 8,  3, -2 },
+    { 8,  2, -3 },
+    { 8, -2, -3 },
+
+    /* 8 bit codewords */
+    { 8, -3,  2 }, { 8, -3,  2 },
+    { 8,  3,  3 }, { 8,  3,  3 },
+    { 9,  3, -3 },
+    { 9, -3, -3 },
+    { 9, -3,  3 },
+    { 9,  1, -4 },
+    { 9, -1, -4 },
+    { 9,  4,  1 },
+    { 9, -4,  1 },
+    { 9, -4, -1 },
+    { 9,  1,  4 },
+    { 9,  4, -1 },
+    { 9, -1,  4 },
+    { 9,  0, -4 },
+
+    /* 9/10/11 bit codewords */
+    { 9, -4,  2 }, { 9, -4,  2 }, { 9, -4,  2 }, { 9, -4,  2 },
+    { 9, -4, -2 }, { 9, -4, -2 }, { 9, -4, -2 }, { 9, -4, -2 },
+    { 9,  2,  4 }, { 9,  2,  4 }, { 9,  2,  4 }, { 9,  2,  4 },
+    { 9, -2, -4 }, { 9, -2, -4 }, { 9, -2, -4 }, { 9, -2, -4 },
+    { 9, -4,  0 }, { 9, -4,  0 }, { 9, -4,  0 }, { 9, -4,  0 },
+    { 9,  4,  2 }, { 9,  4,  2 }, { 9,  4,  2 }, { 9,  4,  2 },
+    { 9,  4, -2 }, { 9,  4, -2 }, { 9,  4, -2 }, { 9,  4, -2 },
+    { 9, -2,  4 }, { 9, -2,  4 }, { 9, -2,  4 }, { 9, -2,  4 },
+    { 9,  4,  0 }, { 9,  4,  0 }, { 9,  4,  0 }, { 9,  4,  0 },
+    { 9,  2, -4 }, { 9,  2, -4 }, { 9,  2, -4 }, { 9,  2, -4 },
+    { 9,  0,  4 }, { 9,  0,  4 }, { 9,  0,  4 }, { 9,  0,  4 },
+    { 10, -3, -4 }, { 10, -3, -4 },
+    { 10, -3,  4 }, { 10, -3,  4 },
+    { 10,  3, -4 }, { 10,  3, -4 },
+    { 10,  4, -3 }, { 10,  4, -3 },
+    { 10,  3,  4 }, { 10,  3,  4 },
+    { 10,  4,  3 }, { 10,  4,  3 },
+    { 10, -4,  3 }, { 10, -4,  3 },
+    { 10, -4, -3 }, { 10, -4, -3 },
+    { 11,  4,  4 },
+    { 11, -4,  4 },
+    { 11, -4, -4 },
+    { 11,  4, -4 }
+};
--- /dev/null
+++ b/libfaad/codebook/hcb_7.c
@@ -1,0 +1,155 @@
+/*
+** FAAD - Freeware Advanced Audio Decoder
+** Copyright (C) 2002 M. Bakker
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+**
+** $Id: hcb_7.c,v 1.1 2002/02/15 20:52:10 menno Exp $
+**/
+
+#include "hcb.h"
+
+/* Binary search huffman table HCB_7 */
+
+
+extern hcb_bin_pair hcb7[] = {
+    { /*  0 */ 0, { 1, 2 } },
+    { /*  1 */ 1, { 0, 0 } },
+    { /*  2 */ 0, { 1, 2 } },
+    { /*  3 */ 0, { 2, 3 } },
+    { /*  4 */ 0, { 3, 4 } },
+    { /*  5 */ 1, { 1, 0 } },
+    { /*  6 */ 1, { 0, 1 } },
+    { /*  7 */ 0, { 2, 3 } },
+    { /*  8 */ 0, { 3, 4 } },
+    { /*  9 */ 1, { 1,  1 } },
+    { /* 10 */ 0, { 3, 4 } },
+    { /* 11 */ 0, { 4, 5 } },
+    { /* 12 */ 0, { 5, 6 } },
+    { /* 13 */ 0, { 6, 7 } },
+    { /* 14 */ 0, { 7, 8 } },
+    { /* 15 */ 0, { 8, 9 } },
+    { /* 16 */ 0, { 9, 10 } },
+    { /* 17 */ 0, { 10, 11 } },
+    { /* 18 */ 0, { 11, 12 } },
+    { /* 19 */ 1, { 2,  1 } },
+    { /* 20 */ 1, { 1,  2 } },
+    { /* 21 */ 1, { 2,  0 } },
+    { /* 22 */ 1, { 0,  2 } },
+    { /* 23 */ 0, { 8, 9 } },
+    { /* 24 */ 0, { 9, 10 } },
+    { /* 25 */ 0, { 10, 11 } },
+    { /* 26 */ 0, { 11, 12 } },
+    { /* 27 */ 0, { 12, 13 } },
+    { /* 28 */ 0, { 13, 14 } },
+    { /* 29 */ 0, { 14, 15 } },
+    { /* 30 */ 0, { 15, 16 } },
+    { /* 31 */ 1, { 3,  1 } },
+    { /* 32 */ 1, { 1,  3 } },
+    { /* 33 */ 1, { 2,  2 } },
+    { /* 34 */ 1, { 3,  0 } },
+    { /* 35 */ 1, { 0,  3 } },
+    { /* 36 */ 0, { 11, 12 } },
+    { /* 37 */ 0, { 12, 13 } },
+    { /* 38 */ 0, { 13, 14 } },
+    { /* 39 */ 0, { 14, 15 } },
+    { /* 40 */ 0, { 15, 16 } },
+    { /* 41 */ 0, { 16, 17 } },
+    { /* 42 */ 0, { 17, 18 } },
+    { /* 43 */ 0, { 18, 19 } },
+    { /* 44 */ 0, { 19, 20 } },
+    { /* 45 */ 0, { 20, 21 } },
+    { /* 46 */ 0, { 21, 22 } },
+    { /* 47 */ 1, { 2,  3 } },
+    { /* 48 */ 1, { 3,  2 } },
+    { /* 49 */ 1, { 1,  4 } },
+    { /* 50 */ 1, { 4,  1 } },
+    { /* 51 */ 1, { 1,  5 } },
+    { /* 52 */ 1, { 5,  1 } },
+    { /* 53 */ 1, { 3,  3 } },
+    { /* 54 */ 1, { 2,  4 } },
+    { /* 55 */ 1, { 0,  4 } },
+    { /* 56 */ 1, { 4,  0 } },
+    { /* 57 */ 0, { 12, 13 } },
+    { /* 58 */ 0, { 13, 14 } },
+    { /* 59 */ 0, { 14, 15 } },
+    { /* 60 */ 0, { 15, 16 } },
+    { /* 61 */ 0, { 16, 17 } },
+    { /* 62 */ 0, { 17, 18 } },
+    { /* 63 */ 0, { 18, 19 } },
+    { /* 64 */ 0, { 19, 20 } },
+    { /* 65 */ 0, { 20, 21 } },
+    { /* 66 */ 0, { 21, 22 } },
+    { /* 67 */ 0, { 22, 23 } },
+    { /* 68 */ 0, { 23, 24 } },
+    { /* 69 */ 1, { 4,  2 } },
+    { /* 70 */ 1, { 2,  5 } },
+    { /* 71 */ 1, { 5,  2 } },
+    { /* 72 */ 1, { 0,  5 } },
+    { /* 73 */ 1, { 6,  1 } },
+    { /* 74 */ 1, { 5,  0 } },
+    { /* 75 */ 1, { 1,  6 } },
+    { /* 76 */ 1, { 4,  3 } },
+    { /* 77 */ 1, { 3,  5 } },
+    { /* 78 */ 1, { 3,  4 } },
+    { /* 79 */ 1, { 5,  3 } },
+    { /* 80 */ 1, { 2,  6 } },
+    { /* 81 */ 1, { 6,  2 } },
+    { /* 82 */ 1, { 1,  7 } },
+    { /* 83 */ 0, { 10, 11 } },
+    { /* 84 */ 0, { 11, 12 } },
+    { /* 85 */ 0, { 12, 13 } },
+    { /* 86 */ 0, { 13, 14 } },
+    { /* 87 */ 0, { 14, 15 } },
+    { /* 88 */ 0, { 15, 16 } },
+    { /* 89 */ 0, { 16, 17 } },
+    { /* 90 */ 0, { 17, 18 } },
+    { /* 91 */ 0, { 18, 19 } },
+    { /* 92 */ 0, { 19, 20 } },
+    { /* 93 */ 1, { 3,  6 } },
+    { /* 94 */ 1, { 0,  6 } },
+    { /* 95 */ 1, { 6,  0 } },
+    { /* 96 */ 1, { 4,  4 } },
+    { /* 97 */ 1, { 7,  1 } },
+    { /* 98 */ 1, { 4,  5 } },
+    { /* 99 */ 1, { 7,  2 } },
+    { /* 00 */ 1, { 5,  4 } },
+    { /* 01 */ 1, { 6,  3 } },
+    { /* 02 */ 1, { 2,  7 } },
+    { /* 03 */ 1, { 7,  3 } },
+    { /* 04 */ 1, { 6,  4 } },
+    { /* 05 */ 1, { 5,  5 } },
+    { /* 06 */ 1, { 4,  6 } },
+    { /* 07 */ 1, { 3,  7 } },
+    { /* 08 */ 0, { 5, 6 } },
+    { /* 09 */ 0, { 6, 7 } },
+    { /* 10 */ 0, { 7, 8 } },
+    { /* 11 */ 0, { 8, 9 } },
+    { /* 12 */ 0, { 9, 10 } },
+    { /* 13 */ 1, { 7,  0 } },
+    { /* 14 */ 1, { 0,  7 } },
+    { /* 15 */ 1, { 6,  5 } },
+    { /* 16 */ 1, { 5,  6 } },
+    { /* 17 */ 1, { 7,  4 } },
+    { /* 18 */ 1, { 4,  7 } },
+    { /* 19 */ 1, { 5,  7 } },
+    { /* 20 */ 1, { 7,  5 } },
+    { /* 21 */ 0, { 2, 3 } },
+    { /* 22 */ 0, { 3, 4 } },
+    { /* 23 */ 1, { 7,  6 } },
+    { /* 24 */ 1, { 6,  6 } },
+    { /* 25 */ 1, { 6,  7 } },
+    { /* 26 */ 1, { 7,  7 } }
+};
--- /dev/null
+++ b/libfaad/codebook/hcb_8.c
@@ -1,0 +1,166 @@
+/*
+** FAAD - Freeware Advanced Audio Decoder
+** Copyright (C) 2002 M. Bakker
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+**
+** $Id: hcb_8.c,v 1.1 2002/02/15 20:52:10 menno Exp $
+**/
+
+#include "hcb.h"
+
+/* 2-step huffman table HCB_8 */
+
+
+/* 1st step: 5 bits
+ *           2^5 = 32 entries
+ *
+ * Used to find offset into 2nd step table and number of extra bits to get
+ */
+extern hcb hcb8_1[] = {
+    /* 3 bit codeword */
+    { /* 00000 */ 0, 0 },
+    { /*       */ 0, 0 },
+    { /*       */ 0, 0 },
+    { /*       */ 0, 0 },
+
+    /* 4 bit codewords */
+    { /* 00100 */ 1, 0 },
+    { /*       */ 1, 0 },
+    { /* 00110 */ 2, 0 },
+    { /*       */ 2, 0 },
+    { /* 01000 */ 3, 0 },
+    { /*       */ 3, 0 },
+    { /* 01010 */ 4, 0 },
+    { /*       */ 4, 0 },
+    { /* 01100 */ 5, 0 },
+    { /*       */ 5, 0 },
+
+    /* 5 bit codewords */
+    { /* 01110 */ 6, 0 },
+    { /* 01111 */ 7, 0 },
+    { /* 10000 */ 8, 0 },
+    { /* 10001 */ 9, 0 },
+    { /* 10010 */ 10, 0 },
+    { /* 10011 */ 11, 0 },
+    { /* 10100 */ 12, 0 },
+
+    /* 6 bit codewords */
+    { /* 10101 */ 13, 1 },
+    { /* 10110 */ 15, 1 },
+    { /* 10111 */ 17, 1 },
+    { /* 11000 */ 19, 1 },
+    { /* 11001 */ 21, 1 },
+
+    /* 7 bit codewords */
+    { /* 11010 */ 23, 2 },
+    { /* 11011 */ 27, 2 },
+    { /* 11100 */ 31, 2 },
+
+    /* 7/8 bit codewords */
+    { /* 11101 */ 35, 3 },
+
+    /* 8 bit codewords */
+    { /* 11110 */ 43, 3 },
+
+    /* 8/9/10 bit codewords */
+    { /* 11111 */ 51, 5 }
+};
+
+/* 2nd step table
+ *
+ * Gives size of codeword and actual data (x,y,v,w)
+ */
+extern hcb_2_pair hcb8_2[] = {
+    /* 3 bit codeword */
+    { 3,  1,  1 },
+
+    /* 4 bit codewords */
+    { 4,  2,  1 },
+    { 4,  1,  0 },
+    { 4,  1,  2 },
+    { 4,  0,  1 },
+    { 4,  2,  2 },
+
+    /* 5 bit codewords */
+    { 5,  0,  0 },
+    { 5,  2,  0 },
+    { 5,  0,  2 },
+    { 5,  3,  1 },
+    { 5,  1,  3 },
+    { 5,  3,  2 },
+    { 5,  2,  3 },
+
+    /* 6 bit codewords */
+    { 6,  3,  3 },
+    { 6,  4,  1 },
+    { 6,  1,  4 },
+    { 6,  4,  2 },
+    { 6,  2,  4 },
+    { 6,  3,  0 },
+    { 6,  0,  3 },
+    { 6,  4,  3 },
+    { 6,  3,  4 },
+    { 6,  5,  2 },
+
+    /* 7 bit codewords */
+    { 7,  5,  1 },
+    { 7,  2,  5 },
+    { 7,  1,  5 },
+    { 7,  5,  3 },
+    { 7,  3,  5 },
+    { 7,  4,  4 },
+    { 7,  5,  4 },
+    { 7,  0,  4 },
+    { 7,  4,  5 },
+    { 7,  4,  0 },
+    { 7,  2,  6 },
+    { 7,  6,  2 },
+
+    /* 7/8 bit codewords */
+    { 7,  6,  1 }, { 7,  6,  1 },
+    { 7,  1,  6 }, { 7,  1,  6 },
+    { 8,  3,  6 },
+    { 8,  6,  3 },
+    { 8,  5,  5 },
+    { 8,  5,  0 },
+
+    /* 8 bit codewords */
+    { 8,  6,  4 },
+    { 8,  0,  5 },
+    { 8,  4,  6 },
+    { 8,  7,  1 },
+    { 8,  7,  2 },
+    { 8,  2,  7 },
+    { 8,  6,  5 },
+    { 8,  7,  3 },
+
+    /* 8/9/10 bit codewords */
+    { 8,  1,  7 }, { 8,  1,  7 }, { 8,  1,  7 }, { 8,  1,  7 },
+    { 8,  5,  6 }, { 8,  5,  6 }, { 8,  5,  6 }, { 8,  5,  6 },
+    { 8,  3,  7 }, { 8,  3,  7 }, { 8,  3,  7 }, { 8,  3,  7 },
+    { 9,  6,  6 }, { 9,  6,  6 },
+    { 9,  7,  4 }, { 9,  7,  4 },
+    { 9,  6,  0 }, { 9,  6,  0 },
+    { 9,  4,  7 }, { 9,  4,  7 },
+    { 9,  0,  6 }, { 9,  0,  6 },
+    { 9,  7,  5 }, { 9,  7,  5 },
+    { 9,  7,  6 }, { 9,  7,  6 },
+    { 9,  6,  7 }, { 9,  6,  7 },
+    { 10,  5,  7 },
+    { 10,  7,  0 },
+    { 10,  0,  7 },
+    { 10,  7,  7 }
+};
--- /dev/null
+++ b/libfaad/codebook/hcb_9.c
@@ -1,0 +1,365 @@
+/*
+** FAAD - Freeware Advanced Audio Decoder
+** Copyright (C) 2002 M. Bakker
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+**
+** $Id: hcb_9.c,v 1.1 2002/02/15 20:52:10 menno Exp $
+**/
+
+#include "hcb.h"
+
+/* Binary search huffman table HCB_9 */
+
+
+extern hcb_bin_pair hcb9[] = {
+    { /*  0 */ 0, { 1, 2 } },
+    { /*  1 */ 1, { 0, 0 } },
+    { /*  2 */ 0, { 1, 2 } },
+    { /*  3 */ 0, { 2, 3 } },
+    { /*  4 */ 0, { 3, 4 } },
+    { /*  5 */ 1, { 1,  0 } },
+    { /*  6 */ 1, { 0,  1 } },
+    { /*  7 */ 0, { 2, 3 } },
+    { /*  8 */ 0, { 3, 4 } },
+    { /*  9 */ 1, { 1,  1 } },
+    { /* 10 */ 0, { 3, 4 } },
+    { /* 11 */ 0, { 4, 5 } },
+    { /* 12 */ 0, { 5, 6 } },
+    { /* 13 */ 0, { 6, 7 } },
+    { /* 14 */ 0, { 7, 8 } },
+    { /* 15 */ 0, { 8, 9 } },
+    { /* 16 */ 0, { 9, 10 } },
+    { /* 17 */ 0, { 10, 11 } },
+    { /* 18 */ 0, { 11, 12 } },
+    { /* 19 */ 1, { 2,  1 } },
+    { /* 20 */ 1, { 1,  2 } },
+    { /* 21 */ 1, { 2,  0 } },
+    { /* 22 */ 1, { 0,  2 } },
+    { /* 23 */ 0, { 8, 9 } },
+    { /* 24 */ 0, { 9, 10 } },
+    { /* 25 */ 0, { 10, 11 } },
+    { /* 26 */ 0, { 11, 12 } },
+    { /* 27 */ 0, { 12, 13 } },
+    { /* 28 */ 0, { 13, 14 } },
+    { /* 29 */ 0, { 14, 15 } },
+    { /* 30 */ 0, { 15, 16 } },
+    { /* 31 */ 1, { 3,  1 } },
+    { /* 32 */ 1, { 2,  2 } },
+    { /* 33 */ 1, { 1,  3 } },
+    { /* 34 */ 0, { 13, 14 } },
+    { /* 35 */ 0, { 14, 15 } },
+    { /* 36 */ 0, { 15, 16 } },
+    { /* 37 */ 0, { 16, 17 } },
+    { /* 38 */ 0, { 17, 18 } },
+    { /* 39 */ 0, { 18, 19 } },
+    { /* 40 */ 0, { 19, 20 } },
+    { /* 41 */ 0, { 20, 21 } },
+    { /* 42 */ 0, { 21, 22 } },
+    { /* 43 */ 0, { 22, 23 } },
+    { /* 44 */ 0, { 23, 24 } },
+    { /* 45 */ 0, { 24, 25 } },
+    { /* 46 */ 0, { 25, 26 } },
+    { /* 47 */ 1, { 3,  0 } },
+    { /* 48 */ 1, { 0,  3 } },
+    { /* 49 */ 1, { 2,  3 } },
+    { /* 50 */ 1, { 3,  2 } },
+    { /* 51 */ 1, { 1,  4 } },
+    { /* 52 */ 1, { 4,  1 } },
+    { /* 53 */ 1, { 2,  4 } },
+    { /* 54 */ 1, { 1,  5 } },
+    { /* 55 */ 0, { 18, 19 } },
+    { /* 56 */ 0, { 19, 20 } },
+    { /* 57 */ 0, { 20, 21 } },
+    { /* 58 */ 0, { 21, 22 } },
+    { /* 59 */ 0, { 22, 23 } },
+    { /* 60 */ 0, { 23, 24 } },
+    { /* 61 */ 0, { 24, 25 } },
+    { /* 62 */ 0, { 25, 26 } },
+    { /* 63 */ 0, { 26, 27 } },
+    { /* 64 */ 0, { 27, 28 } },
+    { /* 65 */ 0, { 28, 29 } },
+    { /* 66 */ 0, { 29, 30 } },
+    { /* 67 */ 0, { 30, 31 } },
+    { /* 68 */ 0, { 31, 32 } },
+    { /* 69 */ 0, { 32, 33 } },
+    { /* 70 */ 0, { 33, 34 } },
+    { /* 71 */ 0, { 34, 35 } },
+    { /* 72 */ 0, { 35, 36 } },
+    { /* 73 */ 1, { 4,  2 } },
+    { /* 74 */ 1, { 3,  3 } },
+    { /* 75 */ 1, { 0,  4 } },
+    { /* 76 */ 1, { 4,  0 } },
+    { /* 77 */ 1, { 5,  1 } },
+    { /* 78 */ 1, { 2,  5 } },
+    { /* 79 */ 1, { 1,  6 } },
+    { /* 80 */ 1, { 3,  4 } },
+    { /* 81 */ 1, { 5,  2 } },
+    { /* 82 */ 1, { 6,  1 } },
+    { /* 83 */ 1, { 4,  3 } },
+    { /* 84 */ 0, { 25, 26 } },
+    { /* 85 */ 0, { 26, 27 } },
+    { /* 86 */ 0, { 27, 28 } },
+    { /* 87 */ 0, { 28, 29 } },
+    { /* 88 */ 0, { 29, 30 } },
+    { /* 89 */ 0, { 30, 31 } },
+    { /* 90 */ 0, { 31, 32 } },
+    { /* 91 */ 0, { 32, 33 } },
+    { /* 92 */ 0, { 33, 34 } },
+    { /* 93 */ 0, { 34, 35 } },
+    { /* 94 */ 0, { 35, 36 } },
+    { /* 95 */ 0, { 36, 37 } },
+    { /* 96 */ 0, { 37, 38 } },
+    { /* 97 */ 0, { 38, 39 } },
+    { /* 98 */ 0, { 39, 40 } },
+    { /* 99 */ 0, { 40, 41 } },
+    { /* 00 */ 0, { 41, 42 } },
+    { /* 01 */ 0, { 42, 43 } },
+    { /* 02 */ 0, { 43, 44 } },
+    { /* 03 */ 0, { 44, 45 } },
+    { /* 04 */ 0, { 45, 46 } },
+    { /* 05 */ 0, { 46, 47 } },
+    { /* 06 */ 0, { 47, 48 } },
+    { /* 07 */ 0, { 48, 49 } },
+    { /* 08 */ 0, { 49, 50 } },
+    { /* 09 */ 1, { 0,  5 } },
+    { /* 10 */ 1, { 2,  6 } },
+    { /* 11 */ 1, { 5,  0 } },
+    { /* 12 */ 1, { 1,  7 } },
+    { /* 13 */ 1, { 3,  5 } },
+    { /* 14 */ 1, { 1,  8 } },
+    { /* 15 */ 1, { 8,  1 } },
+    { /* 16 */ 1, { 4,  4 } },
+    { /* 17 */ 1, { 5,  3 } },
+    { /* 18 */ 1, { 6,  2 } },
+    { /* 19 */ 1, { 7,  1 } },
+    { /* 20 */ 1, { 0,  6 } },
+    { /* 21 */ 1, { 8,  2 } },
+    { /* 22 */ 1, { 2,  8 } },
+    { /* 23 */ 1, { 3,  6 } },
+    { /* 24 */ 1, { 2,  7 } },
+    { /* 25 */ 1, { 4,  5 } },
+    { /* 26 */ 1, { 9,  1 } },
+    { /* 27 */ 1, { 1,  9 } },
+    { /* 28 */ 1, { 7,  2 } },
+    { /* 29 */ 0, { 30, 31 } },
+    { /* 30 */ 0, { 31, 32 } },
+    { /* 31 */ 0, { 32, 33 } },
+    { /* 32 */ 0, { 33, 34 } },
+    { /* 33 */ 0, { 34, 35 } },
+    { /* 34 */ 0, { 35, 36 } },
+    { /* 35 */ 0, { 36, 37 } },
+    { /* 36 */ 0, { 37, 38 } },
+    { /* 37 */ 0, { 38, 39 } },
+    { /* 38 */ 0, { 39, 40 } },
+    { /* 39 */ 0, { 40, 41 } },
+    { /* 40 */ 0, { 41, 42 } },
+    { /* 41 */ 0, { 42, 43 } },
+    { /* 42 */ 0, { 43, 44 } },
+    { /* 43 */ 0, { 44, 45 } },
+    { /* 44 */ 0, { 45, 46 } },
+    { /* 45 */ 0, { 46, 47 } },
+    { /* 46 */ 0, { 47, 48 } },
+    { /* 47 */ 0, { 48, 49 } },
+    { /* 48 */ 0, { 49, 50 } },
+    { /* 49 */ 0, { 50, 51 } },
+    { /* 50 */ 0, { 51, 52 } },
+    { /* 51 */ 0, { 52, 53 } },
+    { /* 52 */ 0, { 53, 54 } },
+    { /* 53 */ 0, { 54, 55 } },
+    { /* 54 */ 0, { 55, 56 } },
+    { /* 55 */ 0, { 56, 57 } },
+    { /* 56 */ 0, { 57, 58 } },
+    { /* 57 */ 0, { 58, 59 } },
+    { /* 58 */ 0, { 59, 60 } },
+    { /* 59 */ 1, {  6,  0 } },
+    { /* 60 */ 1, {  5,  4 } },
+    { /* 61 */ 1, {  6,  3 } },
+    { /* 62 */ 1, {  8,  3 } },
+    { /* 63 */ 1, {  0,  7 } },
+    { /* 64 */ 1, {  9,  2 } },
+    { /* 65 */ 1, {  3,  8 } },
+    { /* 66 */ 1, {  4,  6 } },
+    { /* 67 */ 1, {  3,  7 } },
+    { /* 68 */ 1, {  0,  8 } },
+    { /* 69 */ 1, { 10,  1 } },
+    { /* 70 */ 1, {  6,  4 } },
+    { /* 71 */ 1, {  2,  9 } },
+    { /* 72 */ 1, {  5,  5 } },
+    { /* 73 */ 1, {  8,  0 } },
+    { /* 74 */ 1, {  7,  0 } },
+    { /* 75 */ 1, {  7,  3 } },
+    { /* 76 */ 1, { 10,  2 } },
+    { /* 77 */ 1, {  9,  3 } },
+    { /* 78 */ 1, {  8,  4 } },
+    { /* 79 */ 1, {  1, 10 } },
+    { /* 80 */ 1, {  7,  4 } },
+    { /* 81 */ 1, {  6,  5 } },
+    { /* 82 */ 1, {  5,  6 } },
+    { /* 83 */ 1, {  4,  8 } },
+    { /* 84 */ 1, {  4,  7 } },
+    { /* 85 */ 1, {  3,  9 } },
+    { /* 86 */ 1, { 11,  1 } },
+    { /* 87 */ 1, {  5,  8 } },
+    { /* 88 */ 1, {  9,  0 } },
+    { /* 89 */ 1, {  8,  5 } },
+    { /* 90 */ 0, { 29, 30 } },
+    { /* 91 */ 0, { 30, 31 } },
+    { /* 92 */ 0, { 31, 32 } },
+    { /* 93 */ 0, { 32, 33 } },
+    { /* 94 */ 0, { 33, 34 } },
+    { /* 95 */ 0, { 34, 35 } },
+    { /* 96 */ 0, { 35, 36 } },
+    { /* 97 */ 0, { 36, 37 } },
+    { /* 98 */ 0, { 37, 38 } },
+    { /* 99 */ 0, { 38, 39 } },
+    { /* 00 */ 0, { 39, 40 } },
+    { /* 01 */ 0, { 40, 41 } },
+    { /* 02 */ 0, { 41, 42 } },
+    { /* 03 */ 0, { 42, 43 } },
+    { /* 04 */ 0, { 43, 44 } },
+    { /* 05 */ 0, { 44, 45 } },
+    { /* 06 */ 0, { 45, 46 } },
+    { /* 07 */ 0, { 46, 47 } },
+    { /* 08 */ 0, { 47, 48 } },
+    { /* 09 */ 0, { 48, 49 } },
+    { /* 10 */ 0, { 49, 50 } },
+    { /* 11 */ 0, { 50, 51 } },
+    { /* 12 */ 0, { 51, 52 } },
+    { /* 13 */ 0, { 52, 53 } },
+    { /* 14 */ 0, { 53, 54 } },
+    { /* 15 */ 0, { 54, 55 } },
+    { /* 16 */ 0, { 55, 56 } },
+    { /* 17 */ 0, { 56, 57 } },
+    { /* 18 */ 0, { 57, 58 } },
+    { /* 19 */ 1, { 10,  3 } },
+    { /* 20 */ 1, {  2, 10 } },
+    { /* 21 */ 1, {  0,  9 } },
+    { /* 22 */ 1, { 11,  2 } },
+    { /* 23 */ 1, {  9,  4 } },
+    { /* 24 */ 1, {  6,  6 } },
+    { /* 25 */ 1, { 12,  1 } },
+    { /* 26 */ 1, {  4,  9 } },
+    { /* 27 */ 1, {  8,  6 } },
+    { /* 28 */ 1, {  1, 11 } },
+    { /* 29 */ 1, {  9,  5 } },
+    { /* 30 */ 1, { 10,  4 } },
+    { /* 31 */ 1, {  5,  7 } },
+    { /* 32 */ 1, {  7,  5 } },
+    { /* 33 */ 1, {  2, 11 } },
+    { /* 34 */ 1, {  1, 12 } },
+    { /* 35 */ 1, { 12,  2 } },
+    { /* 36 */ 1, { 11,  3 } },
+    { /* 37 */ 1, {  3, 10 } },
+    { /* 38 */ 1, {  5,  9 } },
+    { /* 39 */ 1, {  6,  7 } },
+    { /* 40 */ 1, {  8,  7 } },
+    { /* 41 */ 1, { 11,  4 } },
+    { /* 42 */ 1, {  0, 10 } },
+    { /* 43 */ 1, {  7,  6 } },
+    { /* 44 */ 1, { 12,  3 } },
+    { /* 45 */ 1, { 10,  0 } },
+    { /* 46 */ 1, { 10,  5 } },
+    { /* 47 */ 1, {  4, 10 } },
+    { /* 48 */ 1, {  6,  8 } },
+    { /* 49 */ 1, {  2, 12 } },
+    { /* 50 */ 1, {  9,  6 } },
+    { /* 51 */ 1, {  9,  7 } },
+    { /* 52 */ 1, {  4, 11 } },
+    { /* 53 */ 1, { 11,  0 } },
+    { /* 54 */ 1, {  6,  9 } },
+    { /* 55 */ 1, {  3, 11 } },
+    { /* 56 */ 1, {  5, 10 } },
+    { /* 57 */ 0, { 20, 21 } },
+    { /* 58 */ 0, { 21, 22 } },
+    { /* 59 */ 0, { 22, 23 } },
+    { /* 60 */ 0, { 23, 24 } },
+    { /* 61 */ 0, { 24, 25 } },
+    { /* 62 */ 0, { 25, 26 } },
+    { /* 63 */ 0, { 26, 27 } },
+    { /* 64 */ 0, { 27, 28 } },
+    { /* 65 */ 0, { 28, 29 } },
+    { /* 66 */ 0, { 29, 30 } },
+    { /* 67 */ 0, { 30, 31 } },
+    { /* 68 */ 0, { 31, 32 } },
+    { /* 69 */ 0, { 32, 33 } },
+    { /* 70 */ 0, { 33, 34 } },
+    { /* 71 */ 0, { 34, 35 } },
+    { /* 72 */ 0, { 35, 36 } },
+    { /* 73 */ 0, { 36, 37 } },
+    { /* 74 */ 0, { 37, 38 } },
+    { /* 75 */ 0, { 38, 39 } },
+    { /* 76 */ 0, { 39, 40 } },
+    { /* 77 */ 1, {  8,  8 } },
+    { /* 78 */ 1, {  7,  8 } },
+    { /* 79 */ 1, { 12,  5 } },
+    { /* 80 */ 1, {  3, 12 } },
+    { /* 81 */ 1, { 11,  5 } },
+    { /* 82 */ 1, {  7,  7 } },
+    { /* 83 */ 1, { 12,  4 } },
+    { /* 84 */ 1, { 11,  6 } },
+    { /* 85 */ 1, { 10,  6 } },
+    { /* 86 */ 1, {  4, 12 } },
+    { /* 87 */ 1, {  7,  9 } },
+    { /* 88 */ 1, {  5, 11 } },
+    { /* 89 */ 1, {  0, 11 } },
+    { /* 90 */ 1, { 12,  6 } },
+    { /* 91 */ 1, {  6, 10 } },
+    { /* 92 */ 1, { 12,  0 } },
+    { /* 93 */ 1, { 10,  7 } },
+    { /* 94 */ 1, {  5, 12 } },
+    { /* 95 */ 1, {  7, 10 } },
+    { /* 96 */ 1, {  9,  8 } },
+    { /* 97 */ 1, {  0, 12 } },
+    { /* 98 */ 1, { 11,  7 } },
+    { /* 99 */ 1, {  8,  9 } },
+    { /* 00 */ 1, {  9,  9 } },
+    { /* 01 */ 1, { 10,  8 } },
+    { /* 02 */ 1, {  7, 11 } },
+    { /* 03 */ 1, { 12,  7 } },
+    { /* 04 */ 1, {  6, 11 } },
+    { /* 05 */ 1, {  8, 11 } },
+    { /* 06 */ 1, { 11,  8 } },
+    { /* 07 */ 1, {  7, 12 } },
+    { /* 08 */ 1, {  6, 12 } },
+    { /* 09 */ 0, { 8, 9 } },
+    { /* 10 */ 0, { 9, 10 } },
+    { /* 11 */ 0, { 10, 11 } },
+    { /* 12 */ 0, { 11, 12 } },
+    { /* 13 */ 0, { 12, 13 } },
+    { /* 14 */ 0, { 13, 14 } },
+    { /* 15 */ 0, { 14, 15 } },
+    { /* 16 */ 0, { 15, 16 } },
+    { /* 17 */ 1, {  8, 10 } },
+    { /* 18 */ 1, { 10,  9 } },
+    { /* 19 */ 1, {  8, 12 } },
+    { /* 20 */ 1, {  9, 10 } },
+    { /* 21 */ 1, {  9, 11 } },
+    { /* 22 */ 1, {  9, 12 } },
+    { /* 23 */ 1, { 10, 11 } },
+    { /* 24 */ 1, { 12,  9 } },
+    { /* 25 */ 1, { 10, 10 } },
+    { /* 26 */ 1, { 11,  9 } },
+    { /* 27 */ 1, { 12,  8 } },
+    { /* 28 */ 1, { 11, 10 } },
+    { /* 29 */ 1, { 12, 10 } },
+    { /* 30 */ 1, { 12, 11 } },
+    { /* 31 */ 0, { 2, 3 } },
+    { /* 32 */ 0, { 3, 4 } },
+    { /* 33 */ 1, { 10, 12 } },
+    { /* 34 */ 1, { 11, 11 } },
+    { /* 35 */ 1, { 11, 12 } },
+    { /* 36 */ 1, { 12, 12 } }
+};
--- /dev/null
+++ b/libfaad/codebook/hcb_sf.c
@@ -1,0 +1,269 @@
+/*
+** FAAD - Freeware Advanced Audio Decoder
+** Copyright (C) 2002 M. Bakker
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+**
+** $Id: hcb_sf.c,v 1.1 2002/02/15 20:52:10 menno Exp $
+**/
+
+#include "hcb.h"
+
+/* Binary search huffman table HCB_SF */
+
+
+extern char hcb_sf[][2] = {
+    { /*  0 */  1, 2 },
+    { /*  1 */  60, 0 },
+    { /*  2 */  1, 2 },
+    { /*  3 */  2, 3 },
+    { /*  4 */  3, 4 },
+    { /*  5 */  59, 0 },
+    { /*  6 */  3, 4 },
+    { /*  7 */  4, 5 },
+    { /*  8 */  5, 6 },
+    { /*  9 */  61, 0 },
+    { /* 10 */  58, 0 },
+    { /* 11 */  62, 0 },
+    { /* 12 */  3, 4 },
+    { /* 13 */  4, 5 },
+    { /* 14 */  5, 6 },
+    { /* 15 */  57, 0 },
+    { /* 16 */  63, 0 },
+    { /* 17 */  4, 5 },
+    { /* 18 */  5, 6 },
+    { /* 19 */  6, 7 },
+    { /* 20 */  7, 8 },
+    { /* 21 */  56, 0 },
+    { /* 22 */  64, 0 },
+    { /* 23 */  55, 0 },
+    { /* 24 */  65, 0 },
+    { /* 25 */  4, 5 },
+    { /* 26 */  5, 6 },
+    { /* 27 */  6, 7 },
+    { /* 28 */  7, 8 },
+    { /* 29 */  66, 0 },
+    { /* 30 */  54, 0 },
+    { /* 31 */  67, 0 },
+    { /* 32 */  5, 6 },
+    { /* 33 */  6, 7 },
+    { /* 34 */  7, 8 },
+    { /* 35 */  8, 9 },
+    { /* 36 */  9, 10 },
+    { /* 37 */  53, 0 },
+    { /* 38 */  68, 0 },
+    { /* 39 */  52, 0 },
+    { /* 40 */  69, 0 },
+    { /* 41 */  51, 0 },
+    { /* 42 */  5, 6 },
+    { /* 43 */  6, 7 },
+    { /* 44 */  7, 8 },
+    { /* 45 */  8, 9 },
+    { /* 46 */  9, 10 },
+    { /* 47 */  70, 0 },
+    { /* 48 */  50, 0 },
+    { /* 49 */  49, 0 },
+    { /* 50 */  71, 0 },
+    { /* 51 */  6, 7 },
+    { /* 52 */  7, 8 },
+    { /* 53 */  8, 9 },
+    { /* 54 */  9, 10 },
+    { /* 55 */  10, 11 },
+    { /* 56 */  11, 12 },
+    { /* 57 */  72, 0 },
+    { /* 58 */  48, 0 },
+    { /* 59 */  73, 0 },
+    { /* 60 */  47, 0 },
+    { /* 61 */  74, 0 },
+    { /* 62 */  46, 0 },
+    { /* 63 */  6, 7 },
+    { /* 64 */  7, 8 },
+    { /* 65 */  8, 9 },
+    { /* 66 */  9, 10 },
+    { /* 67 */  10, 11 },
+    { /* 68 */  11, 12 },
+    { /* 69 */  76, 0 },
+    { /* 70 */  75, 0 },
+    { /* 71 */  77, 0 },
+    { /* 72 */  78, 0 },
+    { /* 73 */  45, 0 },
+    { /* 74 */  43, 0 },
+    { /* 75 */  6, 7 },
+    { /* 76 */  7, 8 },
+    { /* 77 */  8, 9 },
+    { /* 78 */  9, 10 },
+    { /* 79 */  10, 11 },
+    { /* 80 */  11, 12 },
+    { /* 81 */  44, 0 },
+    { /* 82 */  79, 0 },
+    { /* 83 */  42, 0 },
+    { /* 84 */  41, 0 },
+    { /* 85 */  80, 0 },
+    { /* 86 */  40, 0 },
+    { /* 87 */  6, 7 },
+    { /* 88 */  7, 8 },
+    { /* 89 */  8, 9 },
+    { /* 90 */  9, 10 },
+    { /* 91 */  10, 11 },
+    { /* 92 */  11, 12 },
+    { /* 93 */  81, 0 },
+    { /* 94 */  39, 0 },
+    { /* 95 */  82, 0 },
+    { /* 96 */  38, 0 },
+    { /* 97 */  83, 0 },
+    { /* 98 */  7, 8 },
+    { /* 99 */  8, 9 },
+    { /* 00 */  9, 10 },
+    { /* 01 */  10, 11 },
+    { /* 02 */  11, 12 },
+    { /* 03 */  12, 13 },
+    { /* 04 */  13, 14 },
+    { /* 05 */  37, 0 },
+    { /* 06 */  35, 0 },
+    { /* 07 */  85, 0 },
+    { /* 08 */  33, 0 },
+    { /* 09 */  36, 0 },
+    { /* 10 */  34, 0 },
+    { /* 11 */  84, 0 },
+    { /* 12 */  32, 0 },
+    { /* 13 */  6, 7 },
+    { /* 14 */  7, 8 },
+    { /* 15 */  8, 9 },
+    { /* 16 */  9, 10 },
+    { /* 17 */  10, 11 },
+    { /* 18 */  11, 12 },
+    { /* 19 */  87, 0 },
+    { /* 20 */  89, 0 },
+    { /* 21 */  30, 0 },
+    { /* 22 */  31, 0 },
+    { /* 23 */  8, 9 },
+    { /* 24 */  9, 10 },
+    { /* 25 */  10, 11 },
+    { /* 26 */  11, 12 },
+    { /* 27 */  12, 13 },
+    { /* 28 */  13, 14 },
+    { /* 29 */  14, 15 },
+    { /* 30 */  15, 16 },
+    { /* 31 */  86, 0 },
+    { /* 32 */  29, 0 },
+    { /* 33 */  26, 0 },
+    { /* 34 */  27, 0 },
+    { /* 35 */  28, 0 },
+    { /* 36 */  24, 0 },
+    { /* 37 */  88, 0 },
+    { /* 38 */  9, 10 },
+    { /* 39 */  10, 11 },
+    { /* 40 */  11, 12 },
+    { /* 41 */  12, 13 },
+    { /* 42 */  13, 14 },
+    { /* 43 */  14, 15 },
+    { /* 44 */  15, 16 },
+    { /* 45 */  16, 17 },
+    { /* 46 */  17, 18 },
+    { /* 47 */  25, 0 },
+    { /* 48 */  22, 0 },
+    { /* 49 */  23, 0 },
+    { /* 50 */  15, 16 },
+    { /* 51 */  16, 17 },
+    { /* 52 */  17, 18 },
+    { /* 53 */  18, 19 },
+    { /* 54 */  19, 20 },
+    { /* 55 */  20, 21 },
+    { /* 56 */  21, 22 },
+    { /* 57 */  22, 23 },
+    { /* 58 */  23, 24 },
+    { /* 59 */  24, 25 },
+    { /* 60 */  25, 26 },
+    { /* 61 */  26, 27 },
+    { /* 62 */  27, 28 },
+    { /* 63 */  28, 29 },
+    { /* 64 */  29, 30 },
+    { /* 65 */  90, 0 },
+    { /* 66 */  21, 0 },
+    { /* 67 */  19, 0 },
+    { /* 68 */   3, 0 },
+    { /* 69 */   1, 0 },
+    { /* 70 */   2, 0 },
+    { /* 71 */   0, 0 },
+    { /* 72 */  23, 24 },
+    { /* 73 */  24, 25 },
+    { /* 74 */  25, 26 },
+    { /* 75 */  26, 27 },
+    { /* 76 */  27, 28 },
+    { /* 77 */  28, 29 },
+    { /* 78 */  29, 30 },
+    { /* 79 */  30, 31 },
+    { /* 80 */  31, 32 },
+    { /* 81 */  32, 33 },
+    { /* 82 */  33, 34 },
+    { /* 83 */  34, 35 },
+    { /* 84 */  35, 36 },
+    { /* 85 */  36, 37 },
+    { /* 86 */  37, 38 },
+    { /* 87 */  38, 39 },
+    { /* 88 */  39, 40 },
+    { /* 89 */  40, 41 },
+    { /* 90 */  41, 42 },
+    { /* 91 */  42, 43 },
+    { /* 92 */  43, 44 },
+    { /* 93 */  44, 45 },
+    { /* 94 */  45, 46 },
+    { /* 95 */   98, 0 },
+    { /* 96 */   99, 0 },
+    { /* 97 */  100, 0 },
+    { /* 98 */  101, 0 },
+    { /* 99 */  102, 0 },
+    { /* 00 */  117, 0 },
+    { /* 01 */   97, 0 },
+    { /* 02 */   91, 0 },
+    { /* 03 */   92, 0 },
+    { /* 04 */   93, 0 },
+    { /* 05 */   94, 0 },
+    { /* 06 */   95, 0 },
+    { /* 07 */   96, 0 },
+    { /* 08 */  104, 0 },
+    { /* 09 */  111, 0 },
+    { /* 10 */  112, 0 },
+    { /* 11 */  113, 0 },
+    { /* 12 */  114, 0 },
+    { /* 13 */  115, 0 },
+    { /* 14 */  116, 0 },
+    { /* 15 */  110, 0 },
+    { /* 16 */  105, 0 },
+    { /* 17 */  106, 0 },
+    { /* 18 */  107, 0 },
+    { /* 19 */  108, 0 },
+    { /* 20 */  109, 0 },
+    { /* 21 */  118, 0 },
+    { /* 22 */    6, 0 },
+    { /* 23 */    8, 0 },
+    { /* 24 */    9, 0 },
+    { /* 25 */   10, 0 },
+    { /* 26 */    5, 0 },
+    { /* 27 */  103, 0 },
+    { /* 28 */  120, 0 },
+    { /* 29 */  119, 0 },
+    { /* 30 */    4, 0 },
+    { /* 31 */    7, 0 },
+    { /* 32 */   15, 0 },
+    { /* 33 */   16, 0 },
+    { /* 34 */   18, 0 },
+    { /* 35 */   20, 0 },
+    { /* 36 */   17, 0 },
+    { /* 37 */   11, 0 },
+    { /* 38 */   12, 0 },
+    { /* 39 */   14, 0 },
+    { /* 40 */   13, 0 }
+};
--- a/libfaad/huffman.c
+++ /dev/null
@@ -1,1433 +1,0 @@
-/*
-** FAAD - Freeware Advanced Audio Decoder
-** Copyright (C) 2002 M. Bakker
-**  
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-** 
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-** GNU General Public License for more details.
-** 
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software 
-** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-**
-** $Id: huffman.c,v 1.2 2002/01/19 09:39:41 menno Exp $
-**/
-
-#include "syntax.h"
-#include "huffman.h"
-
-extern codebook book1[] = {
-      /* idx             codeword   len  codew   x   y   v   w */
-    { /*   0:                   0 */  1,     0,  0,  0,  0,  0 },
-    { /*   1:              1 0000 */  5,    16,  1,  0,  0,  0 },
-    { /*   2:              1 0001 */  5,    17, -1,  0,  0,  0 },
-    { /*   3:              1 0010 */  5,    18,  0,  0,  0, -1 },
-    { /*   4:              1 0011 */  5,    19,  0,  1,  0,  0 },
-    { /*   5:              1 0100 */  5,    20,  0,  0,  0,  1 },
-    { /*   6:              1 0101 */  5,    21,  0,  0, -1,  0 },
-    { /*   7:              1 0110 */  5,    22,  0,  0,  1,  0 },
-    { /*   8:              1 0111 */  5,    23,  0, -1,  0,  0 },
-    { /*   9:            110 0000 */  7,    96,  1, -1,  0,  0 },
-    { /*  10:            110 0001 */  7,    97, -1,  1,  0,  0 },
-    { /*  11:            110 0010 */  7,    98,  0,  0, -1,  1 },
-    { /*  12:            110 0011 */  7,    99,  0,  1, -1,  0 },
-    { /*  13:            110 0100 */  7,   100,  0, -1,  1,  0 },
-    { /*  14:            110 0101 */  7,   101,  0,  0,  1, -1 },
-    { /*  15:            110 0110 */  7,   102,  1,  1,  0,  0 },
-    { /*  16:            110 0111 */  7,   103,  0,  0, -1, -1 },
-    { /*  17:            110 1000 */  7,   104, -1, -1,  0,  0 },
-    { /*  18:            110 1001 */  7,   105,  0, -1, -1,  0 },
-    { /*  19:            110 1010 */  7,   106,  1,  0, -1,  0 },
-    { /*  20:            110 1011 */  7,   107,  0,  1,  0, -1 },
-    { /*  21:            110 1100 */  7,   108, -1,  0,  1,  0 },
-    { /*  22:            110 1101 */  7,   109,  0,  0,  1,  1 },
-    { /*  23:            110 1110 */  7,   110,  1,  0,  1,  0 },
-    { /*  24:            110 1111 */  7,   111,  0, -1,  0,  1 },
-    { /*  25:            111 0000 */  7,   112,  0,  1,  1,  0 },
-    { /*  26:            111 0001 */  7,   113,  0,  1,  0,  1 },
-    { /*  27:            111 0010 */  7,   114, -1,  0, -1,  0 },
-    { /*  28:            111 0011 */  7,   115,  1,  0,  0,  1 },
-    { /*  29:            111 0100 */  7,   116, -1,  0,  0, -1 },
-    { /*  30:            111 0101 */  7,   117,  1,  0,  0, -1 },
-    { /*  31:            111 0110 */  7,   118, -1,  0,  0,  1 },
-    { /*  32:            111 0111 */  7,   119,  0, -1,  0, -1 },
-    { /*  33:         1 1110 0000 */  9,   480,  1,  1, -1,  0 },
-    { /*  34:         1 1110 0001 */  9,   481, -1,  1, -1,  0 },
-    { /*  35:         1 1110 0010 */  9,   482,  1, -1,  1,  0 },
-    { /*  36:         1 1110 0011 */  9,   483,  0,  1,  1, -1 },
-    { /*  37:         1 1110 0100 */  9,   484,  0,  1, -1,  1 },
-    { /*  38:         1 1110 0101 */  9,   485,  0, -1,  1,  1 },
-    { /*  39:         1 1110 0110 */  9,   486,  0, -1,  1, -1 },
-    { /*  40:         1 1110 0111 */  9,   487,  1, -1, -1,  0 },
-    { /*  41:         1 1110 1000 */  9,   488,  1,  0, -1,  1 },
-    { /*  42:         1 1110 1001 */  9,   489,  0,  1, -1, -1 },
-    { /*  43:         1 1110 1010 */  9,   490, -1,  1,  1,  0 },
-    { /*  44:         1 1110 1011 */  9,   491, -1,  0,  1, -1 },
-    { /*  45:         1 1110 1100 */  9,   492, -1, -1,  1,  0 },
-    { /*  46:         1 1110 1101 */  9,   493,  0, -1, -1,  1 },
-    { /*  47:         1 1110 1110 */  9,   494,  1, -1,  0,  1 },
-    { /*  48:         1 1110 1111 */  9,   495,  1, -1,  0, -1 },
-    { /*  49:         1 1111 0000 */  9,   496, -1,  1,  0, -1 },
-    { /*  50:         1 1111 0001 */  9,   497, -1, -1, -1,  0 },
-    { /*  51:         1 1111 0010 */  9,   498,  0, -1, -1, -1 },
-    { /*  52:         1 1111 0011 */  9,   499,  0,  1,  1,  1 },
-    { /*  53:         1 1111 0100 */  9,   500,  1,  0,  1, -1 },
-    { /*  54:         1 1111 0101 */  9,   501,  1,  1,  0,  1 },
-    { /*  55:         1 1111 0110 */  9,   502, -1,  1,  0,  1 },
-    { /*  56:         1 1111 0111 */  9,   503,  1,  1,  1,  0 },
-    { /*  57:        11 1111 0000 */ 10,  1008, -1, -1,  0,  1 },
-    { /*  58:        11 1111 0001 */ 10,  1009, -1,  0, -1, -1 },
-    { /*  59:        11 1111 0010 */ 10,  1010,  1,  1,  0, -1 },
-    { /*  60:        11 1111 0011 */ 10,  1011,  1,  0, -1, -1 },
-    { /*  61:        11 1111 0100 */ 10,  1012, -1,  0, -1,  1 },
-    { /*  62:        11 1111 0101 */ 10,  1013, -1, -1,  0, -1 },
-    { /*  63:        11 1111 0110 */ 10,  1014, -1,  0,  1,  1 },
-    { /*  64:        11 1111 0111 */ 10,  1015,  1,  0,  1,  1 },
-    { /*  65:       111 1111 0000 */ 11,  2032,  1, -1,  1, -1 },
-    { /*  66:       111 1111 0001 */ 11,  2033, -1,  1, -1,  1 },
-    { /*  67:       111 1111 0010 */ 11,  2034, -1,  1,  1, -1 },
-    { /*  68:       111 1111 0011 */ 11,  2035,  1, -1, -1,  1 },
-    { /*  69:       111 1111 0100 */ 11,  2036,  1,  1,  1,  1 },
-    { /*  70:       111 1111 0101 */ 11,  2037, -1, -1,  1,  1 },
-    { /*  71:       111 1111 0110 */ 11,  2038,  1,  1, -1, -1 },
-    { /*  72:       111 1111 0111 */ 11,  2039, -1, -1,  1, -1 },
-    { /*  73:       111 1111 1000 */ 11,  2040, -1, -1, -1, -1 },
-    { /*  74:       111 1111 1001 */ 11,  2041,  1,  1, -1,  1 },
-    { /*  75:       111 1111 1010 */ 11,  2042,  1, -1,  1,  1 },
-    { /*  76:       111 1111 1011 */ 11,  2043, -1,  1,  1,  1 },
-    { /*  77:       111 1111 1100 */ 11,  2044, -1,  1, -1, -1 },
-    { /*  78:       111 1111 1101 */ 11,  2045, -1, -1, -1,  1 },
-    { /*  79:       111 1111 1110 */ 11,  2046,  1, -1, -1, -1 },
-    { /*  80:       111 1111 1111 */ 11,  2047,  1,  1,  1, -1 }
-};
-
-extern codebook book2[] = {
-      /* idx             codeword   len  codew   x   y   v   w */
-    { /*   0:                 000 */  3,     0,  0,  0,  0,  0 },
-    { /*   1:                0010 */  4,     2,  1,  0,  0,  0 },
-    { /*   2:              0 0110 */  5,     6, -1,  0,  0,  0 },
-    { /*   3:              0 0111 */  5,     7,  0,  0,  0,  1 },
-    { /*   4:              0 1000 */  5,     8,  0,  0, -1,  0 },
-    { /*   5:              0 1001 */  5,     9,  0,  0,  0, -1 },
-    { /*   6:              0 1010 */  5,    10,  0, -1,  0,  0 },
-    { /*   7:              0 1011 */  5,    11,  0,  0,  1,  0 },
-    { /*   8:              0 1100 */  5,    12,  0,  1,  0,  0 },
-    { /*   9:             01 1010 */  6,    26,  0, -1,  1,  0 },
-    { /*  10:             01 1011 */  6,    27, -1,  1,  0,  0 },
-    { /*  11:             01 1100 */  6,    28,  0,  1, -1,  0 },
-    { /*  12:             01 1101 */  6,    29,  0,  0,  1, -1 },
-    { /*  13:             01 1110 */  6,    30,  0,  1,  0, -1 },
-    { /*  14:             01 1111 */  6,    31,  0,  0, -1,  1 },
-    { /*  15:             10 0000 */  6,    32, -1,  0,  0, -1 },
-    { /*  16:             10 0001 */  6,    33,  1, -1,  0,  0 },
-    { /*  17:             10 0010 */  6,    34,  1,  0, -1,  0 },
-    { /*  18:             10 0011 */  6,    35, -1, -1,  0,  0 },
-    { /*  19:             10 0100 */  6,    36,  0,  0, -1, -1 },
-    { /*  20:             10 0101 */  6,    37,  1,  0,  1,  0 },
-    { /*  21:             10 0110 */  6,    38,  1,  0,  0,  1 },
-    { /*  22:             10 0111 */  6,    39,  0, -1,  0,  1 },
-    { /*  23:             10 1000 */  6,    40, -1,  0,  1,  0 },
-    { /*  24:             10 1001 */  6,    41,  0,  1,  0,  1 },
-    { /*  25:             10 1010 */  6,    42,  0, -1, -1,  0 },
-    { /*  26:             10 1011 */  6,    43, -1,  0,  0,  1 },
-    { /*  27:             10 1100 */  6,    44,  0, -1,  0, -1 },
-    { /*  28:             10 1101 */  6,    45, -1,  0, -1,  0 },
-    { /*  29:             10 1110 */  6,    46,  1,  1,  0,  0 },
-    { /*  30:             10 1111 */  6,    47,  0,  1,  1,  0 },
-    { /*  31:             11 0000 */  6,    48,  0,  0,  1,  1 },
-    { /*  32:             11 0001 */  6,    49,  1,  0,  0, -1 },
-    { /*  33:            110 0100 */  7,   100,  0,  1, -1,  1 },
-    { /*  34:            110 0101 */  7,   101,  1,  0, -1,  1 },
-    { /*  35:            110 0110 */  7,   102, -1,  1, -1,  0 },
-    { /*  36:            110 0111 */  7,   103,  0, -1,  1, -1 },
-    { /*  37:            110 1000 */  7,   104,  1, -1,  1,  0 },
-    { /*  38:            110 1001 */  7,   105,  1,  1,  0, -1 },
-    { /*  39:            110 1010 */  7,   106,  1,  0,  1,  1 },
-    { /*  40:            110 1011 */  7,   107, -1,  1,  1,  0 },
-    { /*  41:            110 1100 */  7,   108,  0, -1, -1,  1 },
-    { /*  42:            110 1101 */  7,   109,  1,  1,  1,  0 },
-    { /*  43:            110 1110 */  7,   110, -1,  0,  1, -1 },
-    { /*  44:            110 1111 */  7,   111, -1, -1, -1,  0 },
-    { /*  45:            111 0000 */  7,   112, -1,  0, -1,  1 },
-    { /*  46:            111 0001 */  7,   113,  1, -1, -1,  0 },
-    { /*  47:            111 0010 */  7,   114,  1,  1, -1,  0 },
-    { /*  48:           1110 0110 */  8,   230,  1, -1,  0,  1 },
-    { /*  49:           1110 0111 */  8,   231, -1,  1,  0, -1 },
-    { /*  50:           1110 1000 */  8,   232, -1, -1,  1,  0 },
-    { /*  51:           1110 1001 */  8,   233, -1,  0,  1,  1 },
-    { /*  52:           1110 1010 */  8,   234, -1, -1,  0,  1 },
-    { /*  53:           1110 1011 */  8,   235, -1, -1,  0, -1 },
-    { /*  54:           1110 1100 */  8,   236,  0, -1, -1, -1 },
-    { /*  55:           1110 1101 */  8,   237,  1,  0,  1, -1 },
-    { /*  56:           1110 1110 */  8,   238,  1,  0, -1, -1 },
-    { /*  57:           1110 1111 */  8,   239,  0,  1, -1, -1 },
-    { /*  58:           1111 0000 */  8,   240,  0,  1,  1,  1 },
-    { /*  59:           1111 0001 */  8,   241, -1,  1,  0,  1 },
-    { /*  60:           1111 0010 */  8,   242, -1,  0, -1, -1 },
-    { /*  61:           1111 0011 */  8,   243,  0,  1,  1, -1 },
-    { /*  62:           1111 0100 */  8,   244,  1, -1,  0, -1 },
-    { /*  63:           1111 0101 */  8,   245,  0, -1,  1,  1 },
-    { /*  64:           1111 0110 */  8,   246,  1,  1,  0,  1 },
-    { /*  65:           1111 0111 */  8,   247,  1, -1,  1, -1 },
-    { /*  66:           1111 1000 */  8,   248, -1,  1, -1,  1 },
-    { /*  67:         1 1111 0010 */  9,   498,  1, -1, -1,  1 },
-    { /*  68:         1 1111 0011 */  9,   499, -1, -1, -1, -1 },
-    { /*  69:         1 1111 0100 */  9,   500, -1,  1,  1, -1 },
-    { /*  70:         1 1111 0101 */  9,   501, -1,  1,  1,  1 },
-    { /*  71:         1 1111 0110 */  9,   502,  1,  1,  1,  1 },
-    { /*  72:         1 1111 0111 */  9,   503, -1, -1,  1, -1 },
-    { /*  73:         1 1111 1000 */  9,   504,  1, -1,  1,  1 },
-    { /*  74:         1 1111 1001 */  9,   505, -1,  1, -1, -1 },
-    { /*  75:         1 1111 1010 */  9,   506, -1, -1,  1,  1 },
-    { /*  76:         1 1111 1011 */  9,   507,  1,  1, -1, -1 },
-    { /*  77:         1 1111 1100 */  9,   508,  1, -1, -1, -1 },
-    { /*  78:         1 1111 1101 */  9,   509, -1, -1, -1,  1 },
-    { /*  79:         1 1111 1110 */  9,   510,  1,  1, -1,  1 },
-    { /*  80:         1 1111 1111 */  9,   511,  1,  1,  1, -1 }
-};
-
-extern codebook book3[] = {
-      /* idx             codeword   len  codew   x   y   v   w */
-    { /*   0:                   0 */  1,     0,  0,  0,  0,  0 },
-    { /*   1:                1000 */  4,     8,  1,  0,  0,  0 },
-    { /*   2:                1001 */  4,     9,  0,  0,  0,  1 },
-    { /*   3:                1010 */  4,    10,  0,  1,  0,  0 },
-    { /*   4:                1011 */  4,    11,  0,  0,  1,  0 },
-    { /*   5:              1 1000 */  5,    24,  1,  1,  0,  0 },
-    { /*   6:              1 1001 */  5,    25,  0,  0,  1,  1 },
-    { /*   7:             11 0100 */  6,    52,  0,  1,  1,  0 },
-    { /*   8:             11 0101 */  6,    53,  0,  1,  0,  1 },
-    { /*   9:             11 0110 */  6,    54,  1,  0,  1,  0 },
-    { /*  10:             11 0111 */  6,    55,  0,  1,  1,  1 },
-    { /*  11:             11 1000 */  6,    56,  1,  0,  0,  1 },
-    { /*  12:             11 1001 */  6,    57,  1,  1,  1,  0 },
-    { /*  13:            111 0100 */  7,   116,  1,  1,  1,  1 },
-    { /*  14:            111 0101 */  7,   117,  1,  0,  1,  1 },
-    { /*  15:            111 0110 */  7,   118,  1,  1,  0,  1 },
-    { /*  16:           1110 1110 */  8,   238,  2,  0,  0,  0 },
-    { /*  17:           1110 1111 */  8,   239,  0,  0,  0,  2 },
-    { /*  18:           1111 0000 */  8,   240,  0,  0,  1,  2 },
-    { /*  19:           1111 0001 */  8,   241,  2,  1,  0,  0 },
-    { /*  20:           1111 0010 */  8,   242,  1,  2,  1,  0 },
-    { /*  21:         1 1110 0110 */  9,   486,  0,  0,  2,  1 },
-    { /*  22:         1 1110 0111 */  9,   487,  0,  1,  2,  1 },
-    { /*  23:         1 1110 1000 */  9,   488,  1,  2,  0,  0 },
-    { /*  24:         1 1110 1001 */  9,   489,  0,  1,  1,  2 },
-    { /*  25:         1 1110 1010 */  9,   490,  2,  1,  1,  0 },
-    { /*  26:         1 1110 1011 */  9,   491,  0,  0,  2,  0 },
-    { /*  27:         1 1110 1100 */  9,   492,  0,  2,  1,  0 },
-    { /*  28:         1 1110 1101 */  9,   493,  0,  1,  2,  0 },
-    { /*  29:         1 1110 1110 */  9,   494,  0,  2,  0,  0 },
-    { /*  30:         1 1110 1111 */  9,   495,  0,  1,  0,  2 },
-    { /*  31:         1 1111 0000 */  9,   496,  2,  0,  1,  0 },
-    { /*  32:         1 1111 0001 */  9,   497,  1,  2,  1,  1 },
-    { /*  33:         1 1111 0010 */  9,   498,  0,  2,  1,  1 },
-    { /*  34:         1 1111 0011 */  9,   499,  1,  1,  2,  0 },
-    { /*  35:         1 1111 0100 */  9,   500,  1,  1,  2,  1 },
-    { /*  36:        11 1110 1010 */ 10,  1002,  1,  2,  0,  1 },
-    { /*  37:        11 1110 1011 */ 10,  1003,  1,  0,  2,  0 },
-    { /*  38:        11 1110 1100 */ 10,  1004,  1,  0,  2,  1 },
-    { /*  39:        11 1110 1101 */ 10,  1005,  0,  2,  0,  1 },
-    { /*  40:        11 1110 1110 */ 10,  1006,  2,  1,  1,  1 },
-    { /*  41:        11 1110 1111 */ 10,  1007,  1,  1,  1,  2 },
-    { /*  42:        11 1111 0000 */ 10,  1008,  2,  1,  0,  1 },
-    { /*  43:        11 1111 0001 */ 10,  1009,  1,  0,  1,  2 },
-    { /*  44:        11 1111 0010 */ 10,  1010,  0,  0,  2,  2 },
-    { /*  45:        11 1111 0011 */ 10,  1011,  0,  1,  2,  2 },
-    { /*  46:        11 1111 0100 */ 10,  1012,  2,  2,  1,  0 },
-    { /*  47:        11 1111 0101 */ 10,  1013,  1,  2,  2,  0 },
-    { /*  48:        11 1111 0110 */ 10,  1014,  1,  0,  0,  2 },
-    { /*  49:        11 1111 0111 */ 10,  1015,  2,  0,  0,  1 },
-    { /*  50:        11 1111 1000 */ 10,  1016,  0,  2,  2,  1 },
-    { /*  51:       111 1111 0010 */ 11,  2034,  2,  2,  0,  0 },
-    { /*  52:       111 1111 0011 */ 11,  2035,  1,  2,  2,  1 },
-    { /*  53:       111 1111 0100 */ 11,  2036,  1,  1,  0,  2 },
-    { /*  54:       111 1111 0101 */ 11,  2037,  2,  0,  1,  1 },
-    { /*  55:       111 1111 0110 */ 11,  2038,  1,  1,  2,  2 },
-    { /*  56:       111 1111 0111 */ 11,  2039,  2,  2,  1,  1 },
-    { /*  57:       111 1111 1000 */ 11,  2040,  0,  2,  2,  0 },
-    { /*  58:       111 1111 1001 */ 11,  2041,  0,  2,  1,  2 },
-    { /*  59:      1111 1111 0100 */ 12,  4084,  1,  0,  2,  2 },
-    { /*  60:      1111 1111 0101 */ 12,  4085,  2,  2,  0,  1 },
-    { /*  61:      1111 1111 0110 */ 12,  4086,  2,  1,  2,  0 },
-    { /*  62:      1111 1111 0111 */ 12,  4087,  2,  2,  2,  0 },
-    { /*  63:      1111 1111 1000 */ 12,  4088,  0,  2,  2,  2 },
-    { /*  64:      1111 1111 1001 */ 12,  4089,  2,  2,  2,  1 },
-    { /*  65:      1111 1111 1010 */ 12,  4090,  2,  1,  2,  1 },
-    { /*  66:      1111 1111 1011 */ 12,  4091,  1,  2,  1,  2 },
-    { /*  67:      1111 1111 1100 */ 12,  4092,  1,  2,  2,  2 },
-    { /*  68:    1 1111 1111 1010 */ 13,  8186,  0,  2,  0,  2 },
-    { /*  69:    1 1111 1111 1011 */ 13,  8187,  2,  0,  2,  0 },
-    { /*  70:    1 1111 1111 1100 */ 13,  8188,  1,  2,  0,  2 },
-    { /*  71:   11 1111 1111 1010 */ 14, 16378,  2,  0,  2,  1 },
-    { /*  72:   11 1111 1111 1011 */ 14, 16379,  2,  1,  1,  2 },
-    { /*  73:   11 1111 1111 1100 */ 14, 16380,  2,  1,  0,  2 },
-    { /*  74:  111 1111 1111 1010 */ 15, 32762,  2,  2,  2,  2 },
-    { /*  75:  111 1111 1111 1011 */ 15, 32763,  2,  2,  1,  2 },
-    { /*  76:  111 1111 1111 1100 */ 15, 32764,  2,  1,  2,  2 },
-    { /*  77:  111 1111 1111 1101 */ 15, 32765,  2,  0,  1,  2 },
-    { /*  78:  111 1111 1111 1110 */ 15, 32766,  2,  0,  0,  2 },
-    { /*  79: 1111 1111 1111 1110 */ 16, 65534,  2,  2,  0,  2 },
-    { /*  80: 1111 1111 1111 1111 */ 16, 65535,  2,  0,  2,  2 }
-};
-
-extern codebook book4[] = {
-      /* idx             codeword   len  codew   x   y   v   w */
-    { /*   0:                0000 */  4,     0,  1,  1,  1,  1 },
-    { /*   1:                0001 */  4,     1,  0,  1,  1,  1 },
-    { /*   2:                0010 */  4,     2,  1,  1,  0,  1 },
-    { /*   3:                0011 */  4,     3,  1,  1,  1,  0 },
-    { /*   4:                0100 */  4,     4,  1,  0,  1,  1 },
-    { /*   5:                0101 */  4,     5,  1,  0,  0,  0 },
-    { /*   6:                0110 */  4,     6,  1,  1,  0,  0 },
-    { /*   7:                0111 */  4,     7,  0,  0,  0,  0 },
-    { /*   8:                1000 */  4,     8,  0,  0,  1,  1 },
-    { /*   9:                1001 */  4,     9,  1,  0,  1,  0 },
-    { /*  10:              1 0100 */  5,    20,  1,  0,  0,  1 },
-    { /*  11:              1 0101 */  5,    21,  0,  1,  1,  0 },
-    { /*  12:              1 0110 */  5,    22,  0,  0,  0,  1 },
-    { /*  13:              1 0111 */  5,    23,  0,  1,  0,  1 },
-    { /*  14:              1 1000 */  5,    24,  0,  0,  1,  0 },
-    { /*  15:              1 1001 */  5,    25,  0,  1,  0,  0 },
-    { /*  16:            110 1000 */  7,   104,  2,  1,  1,  1 },
-    { /*  17:            110 1001 */  7,   105,  1,  1,  2,  1 },
-    { /*  18:            110 1010 */  7,   106,  1,  2,  1,  1 },
-    { /*  19:            110 1011 */  7,   107,  1,  1,  1,  2 },
-    { /*  20:            110 1100 */  7,   108,  2,  1,  1,  0 },
-    { /*  21:            110 1101 */  7,   109,  2,  1,  0,  1 },
-    { /*  22:            110 1110 */  7,   110,  1,  2,  1,  0 },
-    { /*  23:            110 1111 */  7,   111,  2,  0,  1,  1 },
-    { /*  24:            111 0000 */  7,   112,  0,  1,  2,  1 },
-    { /*  25:           1110 0010 */  8,   226,  0,  1,  1,  2 },
-    { /*  26:           1110 0011 */  8,   227,  1,  1,  2,  0 },
-    { /*  27:           1110 0100 */  8,   228,  0,  2,  1,  1 },
-    { /*  28:           1110 0101 */  8,   229,  1,  0,  1,  2 },
-    { /*  29:           1110 0110 */  8,   230,  1,  2,  0,  1 },
-    { /*  30:           1110 0111 */  8,   231,  1,  1,  0,  2 },
-    { /*  31:           1110 1000 */  8,   232,  1,  0,  2,  1 },
-    { /*  32:           1110 1001 */  8,   233,  2,  1,  0,  0 },
-    { /*  33:           1110 1010 */  8,   234,  2,  0,  1,  0 },
-    { /*  34:           1110 1011 */  8,   235,  1,  2,  0,  0 },
-    { /*  35:           1110 1100 */  8,   236,  2,  0,  0,  1 },
-    { /*  36:           1110 1101 */  8,   237,  0,  1,  0,  2 },
-    { /*  37:           1110 1110 */  8,   238,  0,  2,  1,  0 },
-    { /*  38:           1110 1111 */  8,   239,  0,  0,  1,  2 },
-    { /*  39:           1111 0000 */  8,   240,  0,  1,  2,  0 },
-    { /*  40:           1111 0001 */  8,   241,  0,  2,  0,  1 },
-    { /*  41:           1111 0010 */  8,   242,  1,  0,  0,  2 },
-    { /*  42:           1111 0011 */  8,   243,  0,  0,  2,  1 },
-    { /*  43:           1111 0100 */  8,   244,  1,  0,  2,  0 },
-    { /*  44:           1111 0101 */  8,   245,  2,  0,  0,  0 },
-    { /*  45:           1111 0110 */  8,   246,  0,  0,  0,  2 },
-    { /*  46:         1 1110 1110 */  9,   494,  0,  2,  0,  0 },
-    { /*  47:         1 1110 1111 */  9,   495,  0,  0,  2,  0 },
-    { /*  48:         1 1111 0000 */  9,   496,  1,  2,  2,  1 },
-    { /*  49:         1 1111 0001 */  9,   497,  2,  2,  1,  1 },
-    { /*  50:         1 1111 0010 */  9,   498,  2,  1,  2,  1 },
-    { /*  51:         1 1111 0011 */  9,   499,  1,  1,  2,  2 },
-    { /*  52:         1 1111 0100 */  9,   500,  1,  2,  1,  2 },
-    { /*  53:         1 1111 0101 */  9,   501,  2,  1,  1,  2 },
-    { /*  54:        11 1110 1100 */ 10,  1004,  1,  2,  2,  0 },
-    { /*  55:        11 1110 1101 */ 10,  1005,  2,  2,  1,  0 },
-    { /*  56:        11 1110 1110 */ 10,  1006,  2,  1,  2,  0 },
-    { /*  57:        11 1110 1111 */ 10,  1007,  0,  2,  2,  1 },
-    { /*  58:        11 1111 0000 */ 10,  1008,  0,  1,  2,  2 },
-    { /*  59:        11 1111 0001 */ 10,  1009,  2,  2,  0,  1 },
-    { /*  60:        11 1111 0010 */ 10,  1010,  0,  2,  1,  2 },
-    { /*  61:        11 1111 0011 */ 10,  1011,  2,  0,  2,  1 },
-    { /*  62:        11 1111 0100 */ 10,  1012,  1,  0,  2,  2 },
-    { /*  63:        11 1111 0101 */ 10,  1013,  2,  2,  2,  1 },
-    { /*  64:        11 1111 0110 */ 10,  1014,  1,  2,  0,  2 },
-    { /*  65:        11 1111 0111 */ 10,  1015,  2,  0,  1,  2 },
-    { /*  66:        11 1111 1000 */ 10,  1016,  2,  1,  0,  2 },
-    { /*  67:        11 1111 1001 */ 10,  1017,  1,  2,  2,  2 },
-    { /*  68:       111 1111 0100 */ 11,  2036,  2,  1,  2,  2 },
-    { /*  69:       111 1111 0101 */ 11,  2037,  2,  2,  1,  2 },
-    { /*  70:       111 1111 0110 */ 11,  2038,  0,  2,  2,  0 },
-    { /*  71:       111 1111 0111 */ 11,  2039,  2,  2,  0,  0 },
-    { /*  72:       111 1111 1000 */ 11,  2040,  0,  0,  2,  2 },
-    { /*  73:       111 1111 1001 */ 11,  2041,  2,  0,  2,  0 },
-    { /*  74:       111 1111 1010 */ 11,  2042,  0,  2,  0,  2 },
-    { /*  75:       111 1111 1011 */ 11,  2043,  2,  0,  0,  2 },
-    { /*  76:       111 1111 1100 */ 11,  2044,  2,  2,  2,  2 },
-    { /*  77:       111 1111 1101 */ 11,  2045,  0,  2,  2,  2 },
-    { /*  78:       111 1111 1110 */ 11,  2046,  2,  2,  2,  0 },
-    { /*  79:      1111 1111 1110 */ 12,  4094,  2,  2,  0,  2 },
-    { /*  80:      1111 1111 1111 */ 12,  4095,  2,  0,  2,  2 }
-};
-
-extern codebook book5[] = {
-      /* idx             codeword   len  codew   x   y   v   w */
-    { /*   0:                   0 */  1,     0,  0,  0,  0,  0 },
-    { /*   1:                1000 */  4,     8, -1,  0,  0,  0 },
-    { /*   2:                1001 */  4,     9,  1,  0,  0,  0 },
-    { /*   3:                1010 */  4,    10,  0,  1,  0,  0 },
-    { /*   4:                1011 */  4,    11,  0, -1,  0,  0 },
-    { /*   5:              1 1000 */  5,    24,  1, -1,  0,  0 },
-    { /*   6:              1 1001 */  5,    25, -1,  1,  0,  0 },
-    { /*   7:              1 1010 */  5,    26, -1, -1,  0,  0 },
-    { /*   8:              1 1011 */  5,    27,  1,  1,  0,  0 },
-    { /*   9:            111 0000 */  7,   112, -2,  0,  0,  0 },
-    { /*  10:            111 0001 */  7,   113,  0,  2,  0,  0 },
-    { /*  11:            111 0010 */  7,   114,  2,  0,  0,  0 },
-    { /*  12:            111 0011 */  7,   115,  0, -2,  0,  0 },
-    { /*  13:           1110 1000 */  8,   232, -2, -1,  0,  0 },
-    { /*  14:           1110 1001 */  8,   233,  2,  1,  0,  0 },
-    { /*  15:           1110 1010 */  8,   234, -1, -2,  0,  0 },
-    { /*  16:           1110 1011 */  8,   235,  1,  2,  0,  0 },
-    { /*  17:           1110 1100 */  8,   236, -2,  1,  0,  0 },
-    { /*  18:           1110 1101 */  8,   237,  2, -1,  0,  0 },
-    { /*  19:           1110 1110 */  8,   238, -1,  2,  0,  0 },
-    { /*  20:           1110 1111 */  8,   239,  1, -2,  0,  0 },
-    { /*  21:           1111 0000 */  8,   240, -3,  0,  0,  0 },
-    { /*  22:           1111 0001 */  8,   241,  3,  0,  0,  0 },
-    { /*  23:           1111 0010 */  8,   242,  0, -3,  0,  0 },
-    { /*  24:           1111 0011 */  8,   243,  0,  3,  0,  0 },
-    { /*  25:         1 1110 1000 */  9,   488, -3, -1,  0,  0 },
-    { /*  26:         1 1110 1001 */  9,   489,  1,  3,  0,  0 },
-    { /*  27:         1 1110 1010 */  9,   490,  3,  1,  0,  0 },
-    { /*  28:         1 1110 1011 */  9,   491, -1, -3,  0,  0 },
-    { /*  29:         1 1110 1100 */  9,   492, -3,  1,  0,  0 },
-    { /*  30:         1 1110 1101 */  9,   493,  3, -1,  0,  0 },
-    { /*  31:         1 1110 1110 */  9,   494,  1, -3,  0,  0 },
-    { /*  32:         1 1110 1111 */  9,   495, -1,  3,  0,  0 },
-    { /*  33:         1 1111 0000 */  9,   496, -2,  2,  0,  0 },
-    { /*  34:         1 1111 0001 */  9,   497,  2,  2,  0,  0 },
-    { /*  35:         1 1111 0010 */  9,   498, -2, -2,  0,  0 },
-    { /*  36:         1 1111 0011 */  9,   499,  2, -2,  0,  0 },
-    { /*  37:        11 1110 1000 */ 10,  1000, -3, -2,  0,  0 },
-    { /*  38:        11 1110 1001 */ 10,  1001,  3, -2,  0,  0 },
-    { /*  39:        11 1110 1010 */ 10,  1002, -2,  3,  0,  0 },
-    { /*  40:        11 1110 1011 */ 10,  1003,  2, -3,  0,  0 },
-    { /*  41:        11 1110 1100 */ 10,  1004,  3,  2,  0,  0 },
-    { /*  42:        11 1110 1101 */ 10,  1005,  2,  3,  0,  0 },
-    { /*  43:        11 1110 1110 */ 10,  1006, -3,  2,  0,  0 },
-    { /*  44:        11 1110 1111 */ 10,  1007, -2, -3,  0,  0 },
-    { /*  45:        11 1111 0000 */ 10,  1008,  0, -4,  0,  0 },
-    { /*  46:        11 1111 0001 */ 10,  1009, -4,  0,  0,  0 },
-    { /*  47:        11 1111 0010 */ 10,  1010,  4,  1,  0,  0 },
-    { /*  48:        11 1111 0011 */ 10,  1011,  4,  0,  0,  0 },
-    { /*  49:       111 1110 1000 */ 11,  2024, -4, -1,  0,  0 },
-    { /*  50:       111 1110 1001 */ 11,  2025,  0,  4,  0,  0 },
-    { /*  51:       111 1110 1010 */ 11,  2026,  4, -1,  0,  0 },
-    { /*  52:       111 1110 1011 */ 11,  2027, -1, -4,  0,  0 },
-    { /*  53:       111 1110 1100 */ 11,  2028,  1,  4,  0,  0 },
-    { /*  54:       111 1110 1101 */ 11,  2029, -1,  4,  0,  0 },
-    { /*  55:       111 1110 1110 */ 11,  2030, -4,  1,  0,  0 },
-    { /*  56:       111 1110 1111 */ 11,  2031,  1, -4,  0,  0 },
-    { /*  57:       111 1111 0000 */ 11,  2032,  3, -3,  0,  0 },
-    { /*  58:       111 1111 0001 */ 11,  2033, -3, -3,  0,  0 },
-    { /*  59:       111 1111 0010 */ 11,  2034, -3,  3,  0,  0 },
-    { /*  60:       111 1111 0011 */ 11,  2035, -2,  4,  0,  0 },
-    { /*  61:       111 1111 0100 */ 11,  2036, -4, -2,  0,  0 },
-    { /*  62:       111 1111 0101 */ 11,  2037,  4,  2,  0,  0 },
-    { /*  63:       111 1111 0110 */ 11,  2038,  2, -4,  0,  0 },
-    { /*  64:       111 1111 0111 */ 11,  2039,  2,  4,  0,  0 },
-    { /*  65:       111 1111 1000 */ 11,  2040,  3,  3,  0,  0 },
-    { /*  66:       111 1111 1001 */ 11,  2041, -4,  2,  0,  0 },
-    { /*  67:      1111 1111 0100 */ 12,  4084, -2, -4,  0,  0 },
-    { /*  68:      1111 1111 0101 */ 12,  4085,  4, -2,  0,  0 },
-    { /*  69:      1111 1111 0110 */ 12,  4086,  3, -4,  0,  0 },
-    { /*  70:      1111 1111 0111 */ 12,  4087, -4, -3,  0,  0 },
-    { /*  71:      1111 1111 1000 */ 12,  4088, -4,  3,  0,  0 },
-    { /*  72:      1111 1111 1001 */ 12,  4089,  3,  4,  0,  0 },
-    { /*  73:      1111 1111 1010 */ 12,  4090, -3,  4,  0,  0 },
-    { /*  74:      1111 1111 1011 */ 12,  4091,  4,  3,  0,  0 },
-    { /*  75:      1111 1111 1100 */ 12,  4092,  4, -3,  0,  0 },
-    { /*  76:      1111 1111 1101 */ 12,  4093, -3, -4,  0,  0 },
-    { /*  77:    1 1111 1111 1100 */ 13,  8188,  4, -4,  0,  0 },
-    { /*  78:    1 1111 1111 1101 */ 13,  8189, -4,  4,  0,  0 },
-    { /*  79:    1 1111 1111 1110 */ 13,  8190,  4,  4,  0,  0 },
-    { /*  80:    1 1111 1111 1111 */ 13,  8191, -4, -4,  0,  0 }
-};
-
-extern codebook book6[] = {
-      /* idx             codeword   len  codew   x   y   v   w */
-    { /*   0:                0000 */  4,     0,  0,  0,  0,  0 },
-    { /*   1:                0001 */  4,     1,  1,  0,  0,  0 },
-    { /*   2:                0010 */  4,     2,  0, -1,  0,  0 },
-    { /*   3:                0011 */  4,     3,  0,  1,  0,  0 },
-    { /*   4:                0100 */  4,     4, -1,  0,  0,  0 },
-    { /*   5:                0101 */  4,     5,  1,  1,  0,  0 },
-    { /*   6:                0110 */  4,     6, -1,  1,  0,  0 },
-    { /*   7:                0111 */  4,     7,  1, -1,  0,  0 },
-    { /*   8:                1000 */  4,     8, -1, -1,  0,  0 },
-    { /*   9:             10 0100 */  6,    36,  2, -1,  0,  0 },
-    { /*  10:             10 0101 */  6,    37,  2,  1,  0,  0 },
-    { /*  11:             10 0110 */  6,    38, -2,  1,  0,  0 },
-    { /*  12:             10 0111 */  6,    39, -2, -1,  0,  0 },
-    { /*  13:             10 1000 */  6,    40, -2,  0,  0,  0 },
-    { /*  14:             10 1001 */  6,    41, -1,  2,  0,  0 },
-    { /*  15:             10 1010 */  6,    42,  2,  0,  0,  0 },
-    { /*  16:             10 1011 */  6,    43,  1, -2,  0,  0 },
-    { /*  17:             10 1100 */  6,    44,  1,  2,  0,  0 },
-    { /*  18:             10 1101 */  6,    45,  0, -2,  0,  0 },
-    { /*  19:             10 1110 */  6,    46, -1, -2,  0,  0 },
-    { /*  20:             10 1111 */  6,    47,  0,  2,  0,  0 },
-    { /*  21:             11 0000 */  6,    48,  2, -2,  0,  0 },
-    { /*  22:             11 0001 */  6,    49, -2,  2,  0,  0 },
-    { /*  23:             11 0010 */  6,    50, -2, -2,  0,  0 },
-    { /*  24:             11 0011 */  6,    51,  2,  2,  0,  0 },
-    { /*  25:            110 1000 */  7,   104, -3,  1,  0,  0 },
-    { /*  26:            110 1001 */  7,   105,  3,  1,  0,  0 },
-    { /*  27:            110 1010 */  7,   106,  3, -1,  0,  0 },
-    { /*  28:            110 1011 */  7,   107, -1,  3,  0,  0 },
-    { /*  29:            110 1100 */  7,   108, -3, -1,  0,  0 },
-    { /*  30:            110 1101 */  7,   109,  1,  3,  0,  0 },
-    { /*  31:            110 1110 */  7,   110,  1, -3,  0,  0 },
-    { /*  32:            110 1111 */  7,   111, -1, -3,  0,  0 },
-    { /*  33:            111 0000 */  7,   112,  3,  0,  0,  0 },
-    { /*  34:            111 0001 */  7,   113, -3,  0,  0,  0 },
-    { /*  35:            111 0010 */  7,   114,  0, -3,  0,  0 },
-    { /*  36:            111 0011 */  7,   115,  0,  3,  0,  0 },
-    { /*  37:            111 0100 */  7,   116,  3,  2,  0,  0 },
-    { /*  38:           1110 1010 */  8,   234, -3, -2,  0,  0 },
-    { /*  39:           1110 1011 */  8,   235, -2,  3,  0,  0 },
-    { /*  40:           1110 1100 */  8,   236,  2,  3,  0,  0 },
-    { /*  41:           1110 1101 */  8,   237,  3, -2,  0,  0 },
-    { /*  42:           1110 1110 */  8,   238,  2, -3,  0,  0 },
-    { /*  43:           1110 1111 */  8,   239, -2, -3,  0,  0 },
-    { /*  44:           1111 0000 */  8,   240, -3,  2,  0,  0 },
-    { /*  45:           1111 0001 */  8,   241,  3,  3,  0,  0 },
-    { /*  46:         1 1110 0100 */  9,   484,  3, -3,  0,  0 },
-    { /*  47:         1 1110 0101 */  9,   485, -3, -3,  0,  0 },
-    { /*  48:         1 1110 0110 */  9,   486, -3,  3,  0,  0 },
-    { /*  49:         1 1110 0111 */  9,   487,  1, -4,  0,  0 },
-    { /*  50:         1 1110 1000 */  9,   488, -1, -4,  0,  0 },
-    { /*  51:         1 1110 1001 */  9,   489,  4,  1,  0,  0 },
-    { /*  52:         1 1110 1010 */  9,   490, -4,  1,  0,  0 },
-    { /*  53:         1 1110 1011 */  9,   491, -4, -1,  0,  0 },
-    { /*  54:         1 1110 1100 */  9,   492,  1,  4,  0,  0 },
-    { /*  55:         1 1110 1101 */  9,   493,  4, -1,  0,  0 },
-    { /*  56:         1 1110 1110 */  9,   494, -1,  4,  0,  0 },
-    { /*  57:         1 1110 1111 */  9,   495,  0, -4,  0,  0 },
-    { /*  58:         1 1111 0000 */  9,   496, -4,  2,  0,  0 },
-    { /*  59:         1 1111 0001 */  9,   497, -4, -2,  0,  0 },
-    { /*  60:         1 1111 0010 */  9,   498,  2,  4,  0,  0 },
-    { /*  61:         1 1111 0011 */  9,   499, -2, -4,  0,  0 },
-    { /*  62:         1 1111 0100 */  9,   500, -4,  0,  0,  0 },
-    { /*  63:         1 1111 0101 */  9,   501,  4,  2,  0,  0 },
-    { /*  64:         1 1111 0110 */  9,   502,  4, -2,  0,  0 },
-    { /*  65:         1 1111 0111 */  9,   503, -2,  4,  0,  0 },
-    { /*  66:         1 1111 1000 */  9,   504,  4,  0,  0,  0 },
-    { /*  67:         1 1111 1001 */  9,   505,  2, -4,  0,  0 },
-    { /*  68:         1 1111 1010 */  9,   506,  0,  4,  0,  0 },
-    { /*  69:        11 1111 0110 */ 10,  1014, -3, -4,  0,  0 },
-    { /*  70:        11 1111 0111 */ 10,  1015, -3,  4,  0,  0 },
-    { /*  71:        11 1111 1000 */ 10,  1016,  3, -4,  0,  0 },
-    { /*  72:        11 1111 1001 */ 10,  1017,  4, -3,  0,  0 },
-    { /*  73:        11 1111 1010 */ 10,  1018,  3,  4,  0,  0 },
-    { /*  74:        11 1111 1011 */ 10,  1019,  4,  3,  0,  0 },
-    { /*  75:        11 1111 1100 */ 10,  1020, -4,  3,  0,  0 },
-    { /*  76:        11 1111 1101 */ 10,  1021, -4, -3,  0,  0 },
-    { /*  77:       111 1111 1100 */ 11,  2044,  4,  4,  0,  0 },
-    { /*  78:       111 1111 1101 */ 11,  2045, -4,  4,  0,  0 },
-    { /*  79:       111 1111 1110 */ 11,  2046, -4, -4,  0,  0 },
-    { /*  80:       111 1111 1111 */ 11,  2047,  4, -4,  0,  0 }
-};
-
-extern codebook book7[] = {
-      /* idx             codeword   len  codew   x   y   v   w */
-    { /*   0:                   0 */  1,     0,  0,  0,  0,  0 },
-    { /*   1:                 100 */  3,     4,  1,  0,  0,  0 },
-    { /*   2:                 101 */  3,     5,  0,  1,  0,  0 },
-    { /*   3:                1100 */  4,    12,  1,  1,  0,  0 },
-    { /*   4:             11 0100 */  6,    52,  2,  1,  0,  0 },
-    { /*   5:             11 0101 */  6,    53,  1,  2,  0,  0 },
-    { /*   6:             11 0110 */  6,    54,  2,  0,  0,  0 },
-    { /*   7:             11 0111 */  6,    55,  0,  2,  0,  0 },
-    { /*   8:            111 0000 */  7,   112,  3,  1,  0,  0 },
-    { /*   9:            111 0001 */  7,   113,  1,  3,  0,  0 },
-    { /*  10:            111 0010 */  7,   114,  2,  2,  0,  0 },
-    { /*  11:            111 0011 */  7,   115,  3,  0,  0,  0 },
-    { /*  12:            111 0100 */  7,   116,  0,  3,  0,  0 },
-    { /*  13:           1110 1010 */  8,   234,  2,  3,  0,  0 },
-    { /*  14:           1110 1011 */  8,   235,  3,  2,  0,  0 },
-    { /*  15:           1110 1100 */  8,   236,  1,  4,  0,  0 },
-    { /*  16:           1110 1101 */  8,   237,  4,  1,  0,  0 },
-    { /*  17:           1110 1110 */  8,   238,  1,  5,  0,  0 },
-    { /*  18:           1110 1111 */  8,   239,  5,  1,  0,  0 },
-    { /*  19:           1111 0000 */  8,   240,  3,  3,  0,  0 },
-    { /*  20:           1111 0001 */  8,   241,  2,  4,  0,  0 },
-    { /*  21:           1111 0010 */  8,   242,  0,  4,  0,  0 },
-    { /*  22:           1111 0011 */  8,   243,  4,  0,  0,  0 },
-    { /*  23:         1 1110 1000 */  9,   488,  4,  2,  0,  0 },
-    { /*  24:         1 1110 1001 */  9,   489,  2,  5,  0,  0 },
-    { /*  25:         1 1110 1010 */  9,   490,  5,  2,  0,  0 },
-    { /*  26:         1 1110 1011 */  9,   491,  0,  5,  0,  0 },
-    { /*  27:         1 1110 1100 */  9,   492,  6,  1,  0,  0 },
-    { /*  28:         1 1110 1101 */  9,   493,  5,  0,  0,  0 },
-    { /*  29:         1 1110 1110 */  9,   494,  1,  6,  0,  0 },
-    { /*  30:         1 1110 1111 */  9,   495,  4,  3,  0,  0 },
-    { /*  31:         1 1111 0000 */  9,   496,  3,  5,  0,  0 },
-    { /*  32:         1 1111 0001 */  9,   497,  3,  4,  0,  0 },
-    { /*  33:         1 1111 0010 */  9,   498,  5,  3,  0,  0 },
-    { /*  34:         1 1111 0011 */  9,   499,  2,  6,  0,  0 },
-    { /*  35:         1 1111 0100 */  9,   500,  6,  2,  0,  0 },
-    { /*  36:         1 1111 0101 */  9,   501,  1,  7,  0,  0 },
-    { /*  37:        11 1110 1100 */ 10,  1004,  3,  6,  0,  0 },
-    { /*  38:        11 1110 1101 */ 10,  1005,  0,  6,  0,  0 },
-    { /*  39:        11 1110 1110 */ 10,  1006,  6,  0,  0,  0 },
-    { /*  40:        11 1110 1111 */ 10,  1007,  4,  4,  0,  0 },
-    { /*  41:        11 1111 0000 */ 10,  1008,  7,  1,  0,  0 },
-    { /*  42:        11 1111 0001 */ 10,  1009,  4,  5,  0,  0 },
-    { /*  43:        11 1111 0010 */ 10,  1010,  7,  2,  0,  0 },
-    { /*  44:        11 1111 0011 */ 10,  1011,  5,  4,  0,  0 },
-    { /*  45:        11 1111 0100 */ 10,  1012,  6,  3,  0,  0 },
-    { /*  46:        11 1111 0101 */ 10,  1013,  2,  7,  0,  0 },
-    { /*  47:        11 1111 0110 */ 10,  1014,  7,  3,  0,  0 },
-    { /*  48:        11 1111 0111 */ 10,  1015,  6,  4,  0,  0 },
-    { /*  49:        11 1111 1000 */ 10,  1016,  5,  5,  0,  0 },
-    { /*  50:        11 1111 1001 */ 10,  1017,  4,  6,  0,  0 },
-    { /*  51:        11 1111 1010 */ 10,  1018,  3,  7,  0,  0 },
-    { /*  52:       111 1111 0110 */ 11,  2038,  7,  0,  0,  0 },
-    { /*  53:       111 1111 0111 */ 11,  2039,  0,  7,  0,  0 },
-    { /*  54:       111 1111 1000 */ 11,  2040,  6,  5,  0,  0 },
-    { /*  55:       111 1111 1001 */ 11,  2041,  5,  6,  0,  0 },
-    { /*  56:       111 1111 1010 */ 11,  2042,  7,  4,  0,  0 },
-    { /*  57:       111 1111 1011 */ 11,  2043,  4,  7,  0,  0 },
-    { /*  58:       111 1111 1100 */ 11,  2044,  5,  7,  0,  0 },
-    { /*  59:       111 1111 1101 */ 11,  2045,  7,  5,  0,  0 },
-    { /*  60:      1111 1111 1100 */ 12,  4092,  7,  6,  0,  0 },
-    { /*  61:      1111 1111 1101 */ 12,  4093,  6,  6,  0,  0 },
-    { /*  62:      1111 1111 1110 */ 12,  4094,  6,  7,  0,  0 },
-    { /*  63:      1111 1111 1111 */ 12,  4095,  7,  7,  0,  0 }
-};
-
-extern codebook book8[] = {
-      /* idx             codeword   len  codew   x   y   v   w */
-    { /*   0:                 000 */  3,     0,  1,  1,  0,  0 },
-    { /*   1:                0010 */  4,     2,  2,  1,  0,  0 },
-    { /*   2:                0011 */  4,     3,  1,  0,  0,  0 },
-    { /*   3:                0100 */  4,     4,  1,  2,  0,  0 },
-    { /*   4:                0101 */  4,     5,  0,  1,  0,  0 },
-    { /*   5:                0110 */  4,     6,  2,  2,  0,  0 },
-    { /*   6:              0 1110 */  5,    14,  0,  0,  0,  0 },
-    { /*   7:              0 1111 */  5,    15,  2,  0,  0,  0 },
-    { /*   8:              1 0000 */  5,    16,  0,  2,  0,  0 },
-    { /*   9:              1 0001 */  5,    17,  3,  1,  0,  0 },
-    { /*  10:              1 0010 */  5,    18,  1,  3,  0,  0 },
-    { /*  11:              1 0011 */  5,    19,  3,  2,  0,  0 },
-    { /*  12:              1 0100 */  5,    20,  2,  3,  0,  0 },
-    { /*  13:             10 1010 */  6,    42,  3,  3,  0,  0 },
-    { /*  14:             10 1011 */  6,    43,  4,  1,  0,  0 },
-    { /*  15:             10 1100 */  6,    44,  1,  4,  0,  0 },
-    { /*  16:             10 1101 */  6,    45,  4,  2,  0,  0 },
-    { /*  17:             10 1110 */  6,    46,  2,  4,  0,  0 },
-    { /*  18:             10 1111 */  6,    47,  3,  0,  0,  0 },
-    { /*  19:             11 0000 */  6,    48,  0,  3,  0,  0 },
-    { /*  20:             11 0001 */  6,    49,  4,  3,  0,  0 },
-    { /*  21:             11 0010 */  6,    50,  3,  4,  0,  0 },
-    { /*  22:             11 0011 */  6,    51,  5,  2,  0,  0 },
-    { /*  23:            110 1000 */  7,   104,  5,  1,  0,  0 },
-    { /*  24:            110 1001 */  7,   105,  2,  5,  0,  0 },
-    { /*  25:            110 1010 */  7,   106,  1,  5,  0,  0 },
-    { /*  26:            110 1011 */  7,   107,  5,  3,  0,  0 },
-    { /*  27:            110 1100 */  7,   108,  3,  5,  0,  0 },
-    { /*  28:            110 1101 */  7,   109,  4,  4,  0,  0 },
-    { /*  29:            110 1110 */  7,   110,  5,  4,  0,  0 },
-    { /*  30:            110 1111 */  7,   111,  0,  4,  0,  0 },
-    { /*  31:            111 0000 */  7,   112,  4,  5,  0,  0 },
-    { /*  32:            111 0001 */  7,   113,  4,  0,  0,  0 },
-    { /*  33:            111 0010 */  7,   114,  2,  6,  0,  0 },
-    { /*  34:            111 0011 */  7,   115,  6,  2,  0,  0 },
-    { /*  35:            111 0100 */  7,   116,  6,  1,  0,  0 },
-    { /*  36:            111 0101 */  7,   117,  1,  6,  0,  0 },
-    { /*  37:           1110 1100 */  8,   236,  3,  6,  0,  0 },
-    { /*  38:           1110 1101 */  8,   237,  6,  3,  0,  0 },
-    { /*  39:           1110 1110 */  8,   238,  5,  5,  0,  0 },
-    { /*  40:           1110 1111 */  8,   239,  5,  0,  0,  0 },
-    { /*  41:           1111 0000 */  8,   240,  6,  4,  0,  0 },
-    { /*  42:           1111 0001 */  8,   241,  0,  5,  0,  0 },
-    { /*  43:           1111 0010 */  8,   242,  4,  6,  0,  0 },
-    { /*  44:           1111 0011 */  8,   243,  7,  1,  0,  0 },
-    { /*  45:           1111 0100 */  8,   244,  7,  2,  0,  0 },
-    { /*  46:           1111 0101 */  8,   245,  2,  7,  0,  0 },
-    { /*  47:           1111 0110 */  8,   246,  6,  5,  0,  0 },
-    { /*  48:           1111 0111 */  8,   247,  7,  3,  0,  0 },
-    { /*  49:           1111 1000 */  8,   248,  1,  7,  0,  0 },
-    { /*  50:           1111 1001 */  8,   249,  5,  6,  0,  0 },
-    { /*  51:           1111 1010 */  8,   250,  3,  7,  0,  0 },
-    { /*  52:         1 1111 0110 */  9,   502,  6,  6,  0,  0 },
-    { /*  53:         1 1111 0111 */  9,   503,  7,  4,  0,  0 },
-    { /*  54:         1 1111 1000 */  9,   504,  6,  0,  0,  0 },
-    { /*  55:         1 1111 1001 */  9,   505,  4,  7,  0,  0 },
-    { /*  56:         1 1111 1010 */  9,   506,  0,  6,  0,  0 },
-    { /*  57:         1 1111 1011 */  9,   507,  7,  5,  0,  0 },
-    { /*  58:         1 1111 1100 */  9,   508,  7,  6,  0,  0 },
-    { /*  59:         1 1111 1101 */  9,   509,  6,  7,  0,  0 },
-    { /*  60:        11 1111 1100 */ 10,  1020,  5,  7,  0,  0 },
-    { /*  61:        11 1111 1101 */ 10,  1021,  7,  0,  0,  0 },
-    { /*  62:        11 1111 1110 */ 10,  1022,  0,  7,  0,  0 },
-    { /*  63:        11 1111 1111 */ 10,  1023,  7,  7,  0,  0 }
-};
-
-extern codebook book9[] = {
-      /* idx             codeword   len  codew   x   y   v   w */
-    { /*   0:                   0 */  1,     0,  0,  0,  0,  0 },
-    { /*   1:                 100 */  3,     4,  1,  0,  0,  0 },
-    { /*   2:                 101 */  3,     5,  0,  1,  0,  0 },
-    { /*   3:                1100 */  4,    12,  1,  1,  0,  0 },
-    { /*   4:             11 0100 */  6,    52,  2,  1,  0,  0 },
-    { /*   5:             11 0101 */  6,    53,  1,  2,  0,  0 },
-    { /*   6:             11 0110 */  6,    54,  2,  0,  0,  0 },
-    { /*   7:             11 0111 */  6,    55,  0,  2,  0,  0 },
-    { /*   8:            111 0000 */  7,   112,  3,  1,  0,  0 },
-    { /*   9:            111 0001 */  7,   113,  2,  2,  0,  0 },
-    { /*  10:            111 0010 */  7,   114,  1,  3,  0,  0 },
-    { /*  11:           1110 0110 */  8,   230,  3,  0,  0,  0 },
-    { /*  12:           1110 0111 */  8,   231,  0,  3,  0,  0 },
-    { /*  13:           1110 1000 */  8,   232,  2,  3,  0,  0 },
-    { /*  14:           1110 1001 */  8,   233,  3,  2,  0,  0 },
-    { /*  15:           1110 1010 */  8,   234,  1,  4,  0,  0 },
-    { /*  16:           1110 1011 */  8,   235,  4,  1,  0,  0 },
-    { /*  17:           1110 1100 */  8,   236,  2,  4,  0,  0 },
-    { /*  18:           1110 1101 */  8,   237,  1,  5,  0,  0 },
-    { /*  19:         1 1101 1100 */  9,   476,  4,  2,  0,  0 },
-    { /*  20:         1 1101 1101 */  9,   477,  3,  3,  0,  0 },
-    { /*  21:         1 1101 1110 */  9,   478,  0,  4,  0,  0 },
-    { /*  22:         1 1101 1111 */  9,   479,  4,  0,  0,  0 },
-    { /*  23:         1 1110 0000 */  9,   480,  5,  1,  0,  0 },
-    { /*  24:         1 1110 0001 */  9,   481,  2,  5,  0,  0 },
-    { /*  25:         1 1110 0010 */  9,   482,  1,  6,  0,  0 },
-    { /*  26:         1 1110 0011 */  9,   483,  3,  4,  0,  0 },
-    { /*  27:         1 1110 0100 */  9,   484,  5,  2,  0,  0 },
-    { /*  28:         1 1110 0101 */  9,   485,  6,  1,  0,  0 },
-    { /*  29:         1 1110 0110 */  9,   486,  4,  3,  0,  0 },
-    { /*  30:        11 1100 1110 */ 10,   974,  0,  5,  0,  0 },
-    { /*  31:        11 1100 1111 */ 10,   975,  2,  6,  0,  0 },
-    { /*  32:        11 1101 0000 */ 10,   976,  5,  0,  0,  0 },
-    { /*  33:        11 1101 0001 */ 10,   977,  1,  7,  0,  0 },
-    { /*  34:        11 1101 0010 */ 10,   978,  3,  5,  0,  0 },
-    { /*  35:        11 1101 0011 */ 10,   979,  1,  8,  0,  0 },
-    { /*  36:        11 1101 0100 */ 10,   980,  8,  1,  0,  0 },
-    { /*  37:        11 1101 0101 */ 10,   981,  4,  4,  0,  0 },
-    { /*  38:        11 1101 0110 */ 10,   982,  5,  3,  0,  0 },
-    { /*  39:        11 1101 0111 */ 10,   983,  6,  2,  0,  0 },
-    { /*  40:        11 1101 1000 */ 10,   984,  7,  1,  0,  0 },
-    { /*  41:        11 1101 1001 */ 10,   985,  0,  6,  0,  0 },
-    { /*  42:        11 1101 1010 */ 10,   986,  8,  2,  0,  0 },
-    { /*  43:        11 1101 1011 */ 10,   987,  2,  8,  0,  0 },
-    { /*  44:        11 1101 1100 */ 10,   988,  3,  6,  0,  0 },
-    { /*  45:        11 1101 1101 */ 10,   989,  2,  7,  0,  0 },
-    { /*  46:        11 1101 1110 */ 10,   990,  4,  5,  0,  0 },
-    { /*  47:        11 1101 1111 */ 10,   991,  9,  1,  0,  0 },
-    { /*  48:        11 1110 0000 */ 10,   992,  1,  9,  0,  0 },
-    { /*  49:        11 1110 0001 */ 10,   993,  7,  2,  0,  0 },
-    { /*  50:       111 1100 0100 */ 11,  1988,  6,  0,  0,  0 },
-    { /*  51:       111 1100 0101 */ 11,  1989,  5,  4,  0,  0 },
-    { /*  52:       111 1100 0110 */ 11,  1990,  6,  3,  0,  0 },
-    { /*  53:       111 1100 0111 */ 11,  1991,  8,  3,  0,  0 },
-    { /*  54:       111 1100 1000 */ 11,  1992,  0,  7,  0,  0 },
-    { /*  55:       111 1100 1001 */ 11,  1993,  9,  2,  0,  0 },
-    { /*  56:       111 1100 1010 */ 11,  1994,  3,  8,  0,  0 },
-    { /*  57:       111 1100 1011 */ 11,  1995,  4,  6,  0,  0 },
-    { /*  58:       111 1100 1100 */ 11,  1996,  3,  7,  0,  0 },
-    { /*  59:       111 1100 1101 */ 11,  1997,  0,  8,  0,  0 },
-    { /*  60:       111 1100 1110 */ 11,  1998, 10,  1,  0,  0 },
-    { /*  61:       111 1100 1111 */ 11,  1999,  6,  4,  0,  0 },
-    { /*  62:       111 1101 0000 */ 11,  2000,  2,  9,  0,  0 },
-    { /*  63:       111 1101 0001 */ 11,  2001,  5,  5,  0,  0 },
-    { /*  64:       111 1101 0010 */ 11,  2002,  8,  0,  0,  0 },
-    { /*  65:       111 1101 0011 */ 11,  2003,  7,  0,  0,  0 },
-    { /*  66:       111 1101 0100 */ 11,  2004,  7,  3,  0,  0 },
-    { /*  67:       111 1101 0101 */ 11,  2005, 10,  2,  0,  0 },
-    { /*  68:       111 1101 0110 */ 11,  2006,  9,  3,  0,  0 },
-    { /*  69:       111 1101 0111 */ 11,  2007,  8,  4,  0,  0 },
-    { /*  70:       111 1101 1000 */ 11,  2008,  1, 10,  0,  0 },
-    { /*  71:       111 1101 1001 */ 11,  2009,  7,  4,  0,  0 },
-    { /*  72:       111 1101 1010 */ 11,  2010,  6,  5,  0,  0 },
-    { /*  73:       111 1101 1011 */ 11,  2011,  5,  6,  0,  0 },
-    { /*  74:       111 1101 1100 */ 11,  2012,  4,  8,  0,  0 },
-    { /*  75:       111 1101 1101 */ 11,  2013,  4,  7,  0,  0 },
-    { /*  76:       111 1101 1110 */ 11,  2014,  3,  9,  0,  0 },
-    { /*  77:       111 1101 1111 */ 11,  2015, 11,  1,  0,  0 },
-    { /*  78:       111 1110 0000 */ 11,  2016,  5,  8,  0,  0 },
-    { /*  79:       111 1110 0001 */ 11,  2017,  9,  0,  0,  0 },
-    { /*  80:       111 1110 0010 */ 11,  2018,  8,  5,  0,  0 },
-    { /*  81:      1111 1100 0110 */ 12,  4038, 10,  3,  0,  0 },
-    { /*  82:      1111 1100 0111 */ 12,  4039,  2, 10,  0,  0 },
-    { /*  83:      1111 1100 1000 */ 12,  4040,  0,  9,  0,  0 },
-    { /*  84:      1111 1100 1001 */ 12,  4041, 11,  2,  0,  0 },
-    { /*  85:      1111 1100 1010 */ 12,  4042,  9,  4,  0,  0 },
-    { /*  86:      1111 1100 1011 */ 12,  4043,  6,  6,  0,  0 },
-    { /*  87:      1111 1100 1100 */ 12,  4044, 12,  1,  0,  0 },
-    { /*  88:      1111 1100 1101 */ 12,  4045,  4,  9,  0,  0 },
-    { /*  89:      1111 1100 1110 */ 12,  4046,  8,  6,  0,  0 },
-    { /*  90:      1111 1100 1111 */ 12,  4047,  1, 11,  0,  0 },
-    { /*  91:      1111 1101 0000 */ 12,  4048,  9,  5,  0,  0 },
-    { /*  92:      1111 1101 0001 */ 12,  4049, 10,  4,  0,  0 },
-    { /*  93:      1111 1101 0010 */ 12,  4050,  5,  7,  0,  0 },
-    { /*  94:      1111 1101 0011 */ 12,  4051,  7,  5,  0,  0 },
-    { /*  95:      1111 1101 0100 */ 12,  4052,  2, 11,  0,  0 },
-    { /*  96:      1111 1101 0101 */ 12,  4053,  1, 12,  0,  0 },
-    { /*  97:      1111 1101 0110 */ 12,  4054, 12,  2,  0,  0 },
-    { /*  98:      1111 1101 0111 */ 12,  4055, 11,  3,  0,  0 },
-    { /*  99:      1111 1101 1000 */ 12,  4056,  3, 10,  0,  0 },
-    { /* 100:      1111 1101 1001 */ 12,  4057,  5,  9,  0,  0 },
-    { /* 101:      1111 1101 1010 */ 12,  4058,  6,  7,  0,  0 },
-    { /* 102:      1111 1101 1011 */ 12,  4059,  8,  7,  0,  0 },
-    { /* 103:      1111 1101 1100 */ 12,  4060, 11,  4,  0,  0 },
-    { /* 104:      1111 1101 1101 */ 12,  4061,  0, 10,  0,  0 },
-    { /* 105:      1111 1101 1110 */ 12,  4062,  7,  6,  0,  0 },
-    { /* 106:      1111 1101 1111 */ 12,  4063, 12,  3,  0,  0 },
-    { /* 107:      1111 1110 0000 */ 12,  4064, 10,  0,  0,  0 },
-    { /* 108:      1111 1110 0001 */ 12,  4065, 10,  5,  0,  0 },
-    { /* 109:      1111 1110 0010 */ 12,  4066,  4, 10,  0,  0 },
-    { /* 110:      1111 1110 0011 */ 12,  4067,  6,  8,  0,  0 },
-    { /* 111:      1111 1110 0100 */ 12,  4068,  2, 12,  0,  0 },
-    { /* 112:      1111 1110 0101 */ 12,  4069,  9,  6,  0,  0 },
-    { /* 113:      1111 1110 0110 */ 12,  4070,  9,  7,  0,  0 },
-    { /* 114:      1111 1110 0111 */ 12,  4071,  4, 11,  0,  0 },
-    { /* 115:      1111 1110 1000 */ 12,  4072, 11,  0,  0,  0 },
-    { /* 116:      1111 1110 1001 */ 12,  4073,  6,  9,  0,  0 },
-    { /* 117:      1111 1110 1010 */ 12,  4074,  3, 11,  0,  0 },
-    { /* 118:      1111 1110 1011 */ 12,  4075,  5, 10,  0,  0 },
-    { /* 119:    1 1111 1101 1000 */ 13,  8152,  8,  8,  0,  0 },
-    { /* 120:    1 1111 1101 1001 */ 13,  8153,  7,  8,  0,  0 },
-    { /* 121:    1 1111 1101 1010 */ 13,  8154, 12,  5,  0,  0 },
-    { /* 122:    1 1111 1101 1011 */ 13,  8155,  3, 12,  0,  0 },
-    { /* 123:    1 1111 1101 1100 */ 13,  8156, 11,  5,  0,  0 },
-    { /* 124:    1 1111 1101 1101 */ 13,  8157,  7,  7,  0,  0 },
-    { /* 125:    1 1111 1101 1110 */ 13,  8158, 12,  4,  0,  0 },
-    { /* 126:    1 1111 1101 1111 */ 13,  8159, 11,  6,  0,  0 },
-    { /* 127:    1 1111 1110 0000 */ 13,  8160, 10,  6,  0,  0 },
-    { /* 128:    1 1111 1110 0001 */ 13,  8161,  4, 12,  0,  0 },
-    { /* 129:    1 1111 1110 0010 */ 13,  8162,  7,  9,  0,  0 },
-    { /* 130:    1 1111 1110 0011 */ 13,  8163,  5, 11,  0,  0 },
-    { /* 131:    1 1111 1110 0100 */ 13,  8164,  0, 11,  0,  0 },
-    { /* 132:    1 1111 1110 0101 */ 13,  8165, 12,  6,  0,  0 },
-    { /* 133:    1 1111 1110 0110 */ 13,  8166,  6, 10,  0,  0 },
-    { /* 134:    1 1111 1110 0111 */ 13,  8167, 12,  0,  0,  0 },
-    { /* 135:    1 1111 1110 1000 */ 13,  8168, 10,  7,  0,  0 },
-    { /* 136:    1 1111 1110 1001 */ 13,  8169,  5, 12,  0,  0 },
-    { /* 137:    1 1111 1110 1010 */ 13,  8170,  7, 10,  0,  0 },
-    { /* 138:    1 1111 1110 1011 */ 13,  8171,  9,  8,  0,  0 },
-    { /* 139:    1 1111 1110 1100 */ 13,  8172,  0, 12,  0,  0 },
-    { /* 140:    1 1111 1110 1101 */ 13,  8173, 11,  7,  0,  0 },
-    { /* 141:    1 1111 1110 1110 */ 13,  8174,  8,  9,  0,  0 },
-    { /* 142:    1 1111 1110 1111 */ 13,  8175,  9,  9,  0,  0 },
-    { /* 143:    1 1111 1111 0000 */ 13,  8176, 10,  8,  0,  0 },
-    { /* 144:    1 1111 1111 0001 */ 13,  8177,  7, 11,  0,  0 },
-    { /* 145:    1 1111 1111 0010 */ 13,  8178, 12,  7,  0,  0 },
-    { /* 146:    1 1111 1111 0011 */ 13,  8179,  6, 11,  0,  0 },
-    { /* 147:    1 1111 1111 0100 */ 13,  8180,  8, 11,  0,  0 },
-    { /* 148:    1 1111 1111 0101 */ 13,  8181, 11,  8,  0,  0 },
-    { /* 149:    1 1111 1111 0110 */ 13,  8182,  7, 12,  0,  0 },
-    { /* 150:    1 1111 1111 0111 */ 13,  8183,  6, 12,  0,  0 },
-    { /* 151:   11 1111 1111 0000 */ 14, 16368,  8, 10,  0,  0 },
-    { /* 152:   11 1111 1111 0001 */ 14, 16369, 10,  9,  0,  0 },
-    { /* 153:   11 1111 1111 0010 */ 14, 16370,  8, 12,  0,  0 },
-    { /* 154:   11 1111 1111 0011 */ 14, 16371,  9, 10,  0,  0 },
-    { /* 155:   11 1111 1111 0100 */ 14, 16372,  9, 11,  0,  0 },
-    { /* 156:   11 1111 1111 0101 */ 14, 16373,  9, 12,  0,  0 },
-    { /* 157:   11 1111 1111 0110 */ 14, 16374, 10, 11,  0,  0 },
-    { /* 158:   11 1111 1111 0111 */ 14, 16375, 12,  9,  0,  0 },
-    { /* 159:   11 1111 1111 1000 */ 14, 16376, 10, 10,  0,  0 },
-    { /* 160:   11 1111 1111 1001 */ 14, 16377, 11,  9,  0,  0 },
-    { /* 161:   11 1111 1111 1010 */ 14, 16378, 12,  8,  0,  0 },
-    { /* 162:   11 1111 1111 1011 */ 14, 16379, 11, 10,  0,  0 },
-    { /* 163:   11 1111 1111 1100 */ 14, 16380, 12, 10,  0,  0 },
-    { /* 164:   11 1111 1111 1101 */ 14, 16381, 12, 11,  0,  0 },
-    { /* 165:  111 1111 1111 1100 */ 15, 32764, 10, 12,  0,  0 },
-    { /* 166:  111 1111 1111 1101 */ 15, 32765, 11, 11,  0,  0 },
-    { /* 167:  111 1111 1111 1110 */ 15, 32766, 11, 12,  0,  0 },
-    { /* 168:  111 1111 1111 1111 */ 15, 32767, 12, 12,  0,  0 }
-};
-
-extern codebook book10[] = {
-      /* idx             codeword   len  codew   x   y   v   w */
-    { /*   0:                0000 */  4,     0,  1,  1,  0,  0 },
-    { /*   1:                0001 */  4,     1,  1,  2,  0,  0 },
-    { /*   2:                0010 */  4,     2,  2,  1,  0,  0 },
-    { /*   3:              0 0110 */  5,     6,  2,  2,  0,  0 },
-    { /*   4:              0 0111 */  5,     7,  1,  0,  0,  0 },
-    { /*   5:              0 1000 */  5,     8,  0,  1,  0,  0 },
-    { /*   6:              0 1001 */  5,     9,  1,  3,  0,  0 },
-    { /*   7:              0 1010 */  5,    10,  3,  2,  0,  0 },
-    { /*   8:              0 1011 */  5,    11,  3,  1,  0,  0 },
-    { /*   9:              0 1100 */  5,    12,  2,  3,  0,  0 },
-    { /*  10:              0 1101 */  5,    13,  3,  3,  0,  0 },
-    { /*  11:             01 1100 */  6,    28,  2,  0,  0,  0 },
-    { /*  12:             01 1101 */  6,    29,  0,  2,  0,  0 },
-    { /*  13:             01 1110 */  6,    30,  2,  4,  0,  0 },
-    { /*  14:             01 1111 */  6,    31,  4,  2,  0,  0 },
-    { /*  15:             10 0000 */  6,    32,  1,  4,  0,  0 },
-    { /*  16:             10 0001 */  6,    33,  4,  1,  0,  0 },
-    { /*  17:             10 0010 */  6,    34,  0,  0,  0,  0 },
-    { /*  18:             10 0011 */  6,    35,  4,  3,  0,  0 },
-    { /*  19:             10 0100 */  6,    36,  3,  4,  0,  0 },
-    { /*  20:             10 0101 */  6,    37,  3,  0,  0,  0 },
-    { /*  21:             10 0110 */  6,    38,  0,  3,  0,  0 },
-    { /*  22:             10 0111 */  6,    39,  4,  4,  0,  0 },
-    { /*  23:             10 1000 */  6,    40,  2,  5,  0,  0 },
-    { /*  24:             10 1001 */  6,    41,  5,  2,  0,  0 },
-    { /*  25:            101 0100 */  7,    84,  1,  5,  0,  0 },
-    { /*  26:            101 0101 */  7,    85,  5,  1,  0,  0 },
-    { /*  27:            101 0110 */  7,    86,  5,  3,  0,  0 },
-    { /*  28:            101 0111 */  7,    87,  3,  5,  0,  0 },
-    { /*  29:            101 1000 */  7,    88,  5,  4,  0,  0 },
-    { /*  30:            101 1001 */  7,    89,  4,  5,  0,  0 },
-    { /*  31:            101 1010 */  7,    90,  6,  2,  0,  0 },
-    { /*  32:            101 1011 */  7,    91,  2,  6,  0,  0 },
-    { /*  33:            101 1100 */  7,    92,  6,  3,  0,  0 },
-    { /*  34:            101 1101 */  7,    93,  4,  0,  0,  0 },
-    { /*  35:            101 1110 */  7,    94,  6,  1,  0,  0 },
-    { /*  36:            101 1111 */  7,    95,  0,  4,  0,  0 },
-    { /*  37:            110 0000 */  7,    96,  1,  6,  0,  0 },
-    { /*  38:            110 0001 */  7,    97,  3,  6,  0,  0 },
-    { /*  39:            110 0010 */  7,    98,  5,  5,  0,  0 },
-    { /*  40:            110 0011 */  7,    99,  6,  4,  0,  0 },
-    { /*  41:            110 0100 */  7,   100,  4,  6,  0,  0 },
-    { /*  42:           1100 1010 */  8,   202,  6,  5,  0,  0 },
-    { /*  43:           1100 1011 */  8,   203,  7,  2,  0,  0 },
-    { /*  44:           1100 1100 */  8,   204,  3,  7,  0,  0 },
-    { /*  45:           1100 1101 */  8,   205,  2,  7,  0,  0 },
-    { /*  46:           1100 1110 */  8,   206,  5,  6,  0,  0 },
-    { /*  47:           1100 1111 */  8,   207,  8,  2,  0,  0 },
-    { /*  48:           1101 0000 */  8,   208,  7,  3,  0,  0 },
-    { /*  49:           1101 0001 */  8,   209,  5,  0,  0,  0 },
-    { /*  50:           1101 0010 */  8,   210,  7,  1,  0,  0 },
-    { /*  51:           1101 0011 */  8,   211,  0,  5,  0,  0 },
-    { /*  52:           1101 0100 */  8,   212,  8,  1,  0,  0 },
-    { /*  53:           1101 0101 */  8,   213,  1,  7,  0,  0 },
-    { /*  54:           1101 0110 */  8,   214,  8,  3,  0,  0 },
-    { /*  55:           1101 0111 */  8,   215,  7,  4,  0,  0 },
-    { /*  56:           1101 1000 */  8,   216,  4,  7,  0,  0 },
-    { /*  57:           1101 1001 */  8,   217,  2,  8,  0,  0 },
-    { /*  58:           1101 1010 */  8,   218,  6,  6,  0,  0 },
-    { /*  59:           1101 1011 */  8,   219,  7,  5,  0,  0 },
-    { /*  60:           1101 1100 */  8,   220,  1,  8,  0,  0 },
-    { /*  61:           1101 1101 */  8,   221,  3,  8,  0,  0 },
-    { /*  62:           1101 1110 */  8,   222,  8,  4,  0,  0 },
-    { /*  63:           1101 1111 */  8,   223,  4,  8,  0,  0 },
-    { /*  64:           1110 0000 */  8,   224,  5,  7,  0,  0 },
-    { /*  65:           1110 0001 */  8,   225,  8,  5,  0,  0 },
-    { /*  66:           1110 0010 */  8,   226,  5,  8,  0,  0 },
-    { /*  67:         1 1100 0110 */  9,   454,  7,  6,  0,  0 },
-    { /*  68:         1 1100 0111 */  9,   455,  6,  7,  0,  0 },
-    { /*  69:         1 1100 1000 */  9,   456,  9,  2,  0,  0 },
-    { /*  70:         1 1100 1001 */  9,   457,  6,  0,  0,  0 },
-    { /*  71:         1 1100 1010 */  9,   458,  6,  8,  0,  0 },
-    { /*  72:         1 1100 1011 */  9,   459,  9,  3,  0,  0 },
-    { /*  73:         1 1100 1100 */  9,   460,  3,  9,  0,  0 },
-    { /*  74:         1 1100 1101 */  9,   461,  9,  1,  0,  0 },
-    { /*  75:         1 1100 1110 */  9,   462,  2,  9,  0,  0 },
-    { /*  76:         1 1100 1111 */  9,   463,  0,  6,  0,  0 },
-    { /*  77:         1 1101 0000 */  9,   464,  8,  6,  0,  0 },
-    { /*  78:         1 1101 0001 */  9,   465,  9,  4,  0,  0 },
-    { /*  79:         1 1101 0010 */  9,   466,  4,  9,  0,  0 },
-    { /*  80:         1 1101 0011 */  9,   467, 10,  2,  0,  0 },
-    { /*  81:         1 1101 0100 */  9,   468,  1,  9,  0,  0 },
-    { /*  82:         1 1101 0101 */  9,   469,  7,  7,  0,  0 },
-    { /*  83:         1 1101 0110 */  9,   470,  8,  7,  0,  0 },
-    { /*  84:         1 1101 0111 */  9,   471,  9,  5,  0,  0 },
-    { /*  85:         1 1101 1000 */  9,   472,  7,  8,  0,  0 },
-    { /*  86:         1 1101 1001 */  9,   473, 10,  3,  0,  0 },
-    { /*  87:         1 1101 1010 */  9,   474,  5,  9,  0,  0 },
-    { /*  88:         1 1101 1011 */  9,   475, 10,  4,  0,  0 },
-    { /*  89:         1 1101 1100 */  9,   476,  2, 10,  0,  0 },
-    { /*  90:         1 1101 1101 */  9,   477, 10,  1,  0,  0 },
-    { /*  91:         1 1101 1110 */  9,   478,  3, 10,  0,  0 },
-    { /*  92:         1 1101 1111 */  9,   479,  9,  6,  0,  0 },
-    { /*  93:         1 1110 0000 */  9,   480,  6,  9,  0,  0 },
-    { /*  94:         1 1110 0001 */  9,   481,  8,  0,  0,  0 },
-    { /*  95:         1 1110 0010 */  9,   482,  4, 10,  0,  0 },
-    { /*  96:         1 1110 0011 */  9,   483,  7,  0,  0,  0 },
-    { /*  97:         1 1110 0100 */  9,   484, 11,  2,  0,  0 },
-    { /*  98:        11 1100 1010 */ 10,   970,  7,  9,  0,  0 },
-    { /*  99:        11 1100 1011 */ 10,   971, 11,  3,  0,  0 },
-    { /* 100:        11 1100 1100 */ 10,   972, 10,  6,  0,  0 },
-    { /* 101:        11 1100 1101 */ 10,   973,  1, 10,  0,  0 },
-    { /* 102:        11 1100 1110 */ 10,   974, 11,  1,  0,  0 },
-    { /* 103:        11 1100 1111 */ 10,   975,  9,  7,  0,  0 },
-    { /* 104:        11 1101 0000 */ 10,   976,  0,  7,  0,  0 },
-    { /* 105:        11 1101 0001 */ 10,   977,  8,  8,  0,  0 },
-    { /* 106:        11 1101 0010 */ 10,   978, 10,  5,  0,  0 },
-    { /* 107:        11 1101 0011 */ 10,   979,  3, 11,  0,  0 },
-    { /* 108:        11 1101 0100 */ 10,   980,  5, 10,  0,  0 },
-    { /* 109:        11 1101 0101 */ 10,   981,  8,  9,  0,  0 },
-    { /* 110:        11 1101 0110 */ 10,   982, 11,  5,  0,  0 },
-    { /* 111:        11 1101 0111 */ 10,   983,  0,  8,  0,  0 },
-    { /* 112:        11 1101 1000 */ 10,   984, 11,  4,  0,  0 },
-    { /* 113:        11 1101 1001 */ 10,   985,  2, 11,  0,  0 },
-    { /* 114:        11 1101 1010 */ 10,   986,  7, 10,  0,  0 },
-    { /* 115:        11 1101 1011 */ 10,   987,  6, 10,  0,  0 },
-    { /* 116:        11 1101 1100 */ 10,   988, 10,  7,  0,  0 },
-    { /* 117:        11 1101 1101 */ 10,   989,  4, 11,  0,  0 },
-    { /* 118:        11 1101 1110 */ 10,   990,  1, 11,  0,  0 },
-    { /* 119:        11 1101 1111 */ 10,   991, 12,  2,  0,  0 },
-    { /* 120:        11 1110 0000 */ 10,   992,  9,  8,  0,  0 },
-    { /* 121:        11 1110 0001 */ 10,   993, 12,  3,  0,  0 },
-    { /* 122:        11 1110 0010 */ 10,   994, 11,  6,  0,  0 },
-    { /* 123:        11 1110 0011 */ 10,   995,  5, 11,  0,  0 },
-    { /* 124:        11 1110 0100 */ 10,   996, 12,  4,  0,  0 },
-    { /* 125:        11 1110 0101 */ 10,   997, 11,  7,  0,  0 },
-    { /* 126:        11 1110 0110 */ 10,   998, 12,  5,  0,  0 },
-    { /* 127:        11 1110 0111 */ 10,   999,  3, 12,  0,  0 },
-    { /* 128:        11 1110 1000 */ 10,  1000,  6, 11,  0,  0 },
-    { /* 129:        11 1110 1001 */ 10,  1001,  9,  0,  0,  0 },
-    { /* 130:        11 1110 1010 */ 10,  1002, 10,  8,  0,  0 },
-    { /* 131:        11 1110 1011 */ 10,  1003, 10,  0,  0,  0 },
-    { /* 132:        11 1110 1100 */ 10,  1004, 12,  1,  0,  0 },
-    { /* 133:        11 1110 1101 */ 10,  1005,  0,  9,  0,  0 },
-    { /* 134:        11 1110 1110 */ 10,  1006,  4, 12,  0,  0 },
-    { /* 135:        11 1110 1111 */ 10,  1007,  9,  9,  0,  0 },
-    { /* 136:        11 1111 0000 */ 10,  1008, 12,  6,  0,  0 },
-    { /* 137:        11 1111 0001 */ 10,  1009,  2, 12,  0,  0 },
-    { /* 138:        11 1111 0010 */ 10,  1010,  8, 10,  0,  0 },
-    { /* 139:       111 1110 0110 */ 11,  2022,  9, 10,  0,  0 },
-    { /* 140:       111 1110 0111 */ 11,  2023,  1, 12,  0,  0 },
-    { /* 141:       111 1110 1000 */ 11,  2024, 11,  8,  0,  0 },
-    { /* 142:       111 1110 1001 */ 11,  2025, 12,  7,  0,  0 },
-    { /* 143:       111 1110 1010 */ 11,  2026,  7, 11,  0,  0 },
-    { /* 144:       111 1110 1011 */ 11,  2027,  5, 12,  0,  0 },
-    { /* 145:       111 1110 1100 */ 11,  2028,  6, 12,  0,  0 },
-    { /* 146:       111 1110 1101 */ 11,  2029, 10,  9,  0,  0 },
-    { /* 147:       111 1110 1110 */ 11,  2030,  8, 11,  0,  0 },
-    { /* 148:       111 1110 1111 */ 11,  2031, 12,  8,  0,  0 },
-    { /* 149:       111 1111 0000 */ 11,  2032,  0, 10,  0,  0 },
-    { /* 150:       111 1111 0001 */ 11,  2033,  7, 12,  0,  0 },
-    { /* 151:       111 1111 0010 */ 11,  2034, 11,  0,  0,  0 },
-    { /* 152:       111 1111 0011 */ 11,  2035, 10, 10,  0,  0 },
-    { /* 153:       111 1111 0100 */ 11,  2036, 11,  9,  0,  0 },
-    { /* 154:       111 1111 0101 */ 11,  2037, 11, 10,  0,  0 },
-    { /* 155:       111 1111 0110 */ 11,  2038,  0, 11,  0,  0 },
-    { /* 156:       111 1111 0111 */ 11,  2039, 11, 11,  0,  0 },
-    { /* 157:       111 1111 1000 */ 11,  2040,  9, 11,  0,  0 },
-    { /* 158:       111 1111 1001 */ 11,  2041, 10, 11,  0,  0 },
-    { /* 159:       111 1111 1010 */ 11,  2042, 12,  0,  0,  0 },
-    { /* 160:       111 1111 1011 */ 11,  2043,  8, 12,  0,  0 },
-    { /* 161:      1111 1111 1000 */ 12,  4088, 12,  9,  0,  0 },
-    { /* 162:      1111 1111 1001 */ 12,  4089, 10, 12,  0,  0 },
-    { /* 163:      1111 1111 1010 */ 12,  4090,  9, 12,  0,  0 },
-    { /* 164:      1111 1111 1011 */ 12,  4091, 11, 12,  0,  0 },
-    { /* 165:      1111 1111 1100 */ 12,  4092, 12, 11,  0,  0 },
-    { /* 166:      1111 1111 1101 */ 12,  4093,  0, 12,  0,  0 },
-    { /* 167:      1111 1111 1110 */ 12,  4094, 12, 10,  0,  0 },
-    { /* 168:      1111 1111 1111 */ 12,  4095, 12, 12,  0,  0 }
-};
-
-extern codebook book11[] = {
-      /* idx             codeword   len  codew   x   y   v   w */
-    { /*   0:                0000 */  4,     0,  0,  0,  0,  0 },
-    { /*   1:                0001 */  4,     1,  1,  1,  0,  0 },
-    { /*   2:              0 0100 */  5,     4, 16, 16,  0,  0 },
-    { /*   3:              0 0101 */  5,     5,  1,  0,  0,  0 },
-    { /*   4:              0 0110 */  5,     6,  0,  1,  0,  0 },
-    { /*   5:              0 0111 */  5,     7,  2,  1,  0,  0 },
-    { /*   6:              0 1000 */  5,     8,  1,  2,  0,  0 },
-    { /*   7:              0 1001 */  5,     9,  2,  2,  0,  0 },
-    { /*   8:             01 0100 */  6,    20,  1,  3,  0,  0 },
-    { /*   9:             01 0101 */  6,    21,  3,  1,  0,  0 },
-    { /*  10:             01 0110 */  6,    22,  3,  2,  0,  0 },
-    { /*  11:             01 0111 */  6,    23,  2,  0,  0,  0 },
-    { /*  12:             01 1000 */  6,    24,  2,  3,  0,  0 },
-    { /*  13:             01 1001 */  6,    25,  0,  2,  0,  0 },
-    { /*  14:             01 1010 */  6,    26,  3,  3,  0,  0 },
-    { /*  15:            011 0110 */  7,    54,  4,  1,  0,  0 },
-    { /*  16:            011 0111 */  7,    55,  1,  4,  0,  0 },
-    { /*  17:            011 1000 */  7,    56,  4,  2,  0,  0 },
-    { /*  18:            011 1001 */  7,    57,  2,  4,  0,  0 },
-    { /*  19:            011 1010 */  7,    58,  4,  3,  0,  0 },
-    { /*  20:            011 1011 */  7,    59,  3,  4,  0,  0 },
-    { /*  21:            011 1100 */  7,    60,  3,  0,  0,  0 },
-    { /*  22:            011 1101 */  7,    61,  0,  3,  0,  0 },
-    { /*  23:            011 1110 */  7,    62,  5,  1,  0,  0 },
-    { /*  24:            011 1111 */  7,    63,  5,  2,  0,  0 },
-    { /*  25:            100 0000 */  7,    64,  2,  5,  0,  0 },
-    { /*  26:            100 0001 */  7,    65,  4,  4,  0,  0 },
-    { /*  27:            100 0010 */  7,    66,  1,  5,  0,  0 },
-    { /*  28:            100 0011 */  7,    67,  5,  3,  0,  0 },
-    { /*  29:            100 0100 */  7,    68,  3,  5,  0,  0 },
-    { /*  30:            100 0101 */  7,    69,  5,  4,  0,  0 },
-    { /*  31:           1000 1100 */  8,   140,  4,  5,  0,  0 },
-    { /*  32:           1000 1101 */  8,   141,  6,  2,  0,  0 },
-    { /*  33:           1000 1110 */  8,   142,  2,  6,  0,  0 },
-    { /*  34:           1000 1111 */  8,   143,  6,  1,  0,  0 },
-    { /*  35:           1001 0000 */  8,   144,  6,  3,  0,  0 },
-    { /*  36:           1001 0001 */  8,   145,  3,  6,  0,  0 },
-    { /*  37:           1001 0010 */  8,   146,  1,  6,  0,  0 },
-    { /*  38:           1001 0011 */  8,   147,  4, 16,  0,  0 },
-    { /*  39:           1001 0100 */  8,   148,  3, 16,  0,  0 },
-    { /*  40:           1001 0101 */  8,   149, 16,  5,  0,  0 },
-    { /*  41:           1001 0110 */  8,   150, 16,  3,  0,  0 },
-    { /*  42:           1001 0111 */  8,   151, 16,  4,  0,  0 },
-    { /*  43:           1001 1000 */  8,   152,  6,  4,  0,  0 },
-    { /*  44:           1001 1001 */  8,   153, 16,  6,  0,  0 },
-    { /*  45:           1001 1010 */  8,   154,  4,  0,  0,  0 },
-    { /*  46:           1001 1011 */  8,   155,  4,  6,  0,  0 },
-    { /*  47:           1001 1100 */  8,   156,  0,  4,  0,  0 },
-    { /*  48:           1001 1101 */  8,   157,  2, 16,  0,  0 },
-    { /*  49:           1001 1110 */  8,   158,  5,  5,  0,  0 },
-    { /*  50:           1001 1111 */  8,   159,  5, 16,  0,  0 },
-    { /*  51:           1010 0000 */  8,   160, 16,  7,  0,  0 },
-    { /*  52:           1010 0001 */  8,   161, 16,  2,  0,  0 },
-    { /*  53:           1010 0010 */  8,   162, 16,  8,  0,  0 },
-    { /*  54:           1010 0011 */  8,   163,  2,  7,  0,  0 },
-    { /*  55:           1010 0100 */  8,   164,  7,  2,  0,  0 },
-    { /*  56:           1010 0101 */  8,   165,  3,  7,  0,  0 },
-    { /*  57:           1010 0110 */  8,   166,  6,  5,  0,  0 },
-    { /*  58:           1010 0111 */  8,   167,  5,  6,  0,  0 },
-    { /*  59:           1010 1000 */  8,   168,  6, 16,  0,  0 },
-    { /*  60:           1010 1001 */  8,   169, 16, 10,  0,  0 },
-    { /*  61:           1010 1010 */  8,   170,  7,  3,  0,  0 },
-    { /*  62:           1010 1011 */  8,   171,  7,  1,  0,  0 },
-    { /*  63:           1010 1100 */  8,   172, 16,  9,  0,  0 },
-    { /*  64:           1010 1101 */  8,   173,  7, 16,  0,  0 },
-    { /*  65:           1010 1110 */  8,   174,  1, 16,  0,  0 },
-    { /*  66:           1010 1111 */  8,   175,  1,  7,  0,  0 },
-    { /*  67:           1011 0000 */  8,   176,  4,  7,  0,  0 },
-    { /*  68:           1011 0001 */  8,   177, 16, 11,  0,  0 },
-    { /*  69:           1011 0010 */  8,   178,  7,  4,  0,  0 },
-    { /*  70:           1011 0011 */  8,   179, 16, 12,  0,  0 },
-    { /*  71:           1011 0100 */  8,   180,  8, 16,  0,  0 },
-    { /*  72:           1011 0101 */  8,   181, 16,  1,  0,  0 },
-    { /*  73:           1011 0110 */  8,   182,  6,  6,  0,  0 },
-    { /*  74:           1011 0111 */  8,   183,  9, 16,  0,  0 },
-    { /*  75:           1011 1000 */  8,   184,  2,  8,  0,  0 },
-    { /*  76:           1011 1001 */  8,   185,  5,  7,  0,  0 },
-    { /*  77:           1011 1010 */  8,   186, 10, 16,  0,  0 },
-    { /*  78:           1011 1011 */  8,   187, 16, 13,  0,  0 },
-    { /*  79:           1011 1100 */  8,   188,  8,  3,  0,  0 },
-    { /*  80:           1011 1101 */  8,   189,  8,  2,  0,  0 },
-    { /*  81:           1011 1110 */  8,   190,  3,  8,  0,  0 },
-    { /*  82:           1011 1111 */  8,   191,  5,  0,  0,  0 },
-    { /*  83:           1100 0000 */  8,   192, 16, 14,  0,  0 },
-    { /*  84:           1100 0001 */  8,   193, 11, 16,  0,  0 },
-    { /*  85:           1100 0010 */  8,   194,  7,  5,  0,  0 },
-    { /*  86:           1100 0011 */  8,   195,  4,  8,  0,  0 },
-    { /*  87:           1100 0100 */  8,   196,  6,  7,  0,  0 },
-    { /*  88:           1100 0101 */  8,   197,  7,  6,  0,  0 },
-    { /*  89:           1100 0110 */  8,   198,  0,  5,  0,  0 },
-    { /*  90:         1 1000 1110 */  9,   398,  8,  4,  0,  0 },
-    { /*  91:         1 1000 1111 */  9,   399, 16, 15,  0,  0 },
-    { /*  92:         1 1001 0000 */  9,   400, 12, 16,  0,  0 },
-    { /*  93:         1 1001 0001 */  9,   401,  1,  8,  0,  0 },
-    { /*  94:         1 1001 0010 */  9,   402,  8,  1,  0,  0 },
-    { /*  95:         1 1001 0011 */  9,   403, 14, 16,  0,  0 },
-    { /*  96:         1 1001 0100 */  9,   404,  5,  8,  0,  0 },
-    { /*  97:         1 1001 0101 */  9,   405, 13, 16,  0,  0 },
-    { /*  98:         1 1001 0110 */  9,   406,  3,  9,  0,  0 },
-    { /*  99:         1 1001 0111 */  9,   407,  8,  5,  0,  0 },
-    { /* 100:         1 1001 1000 */  9,   408,  7,  7,  0,  0 },
-    { /* 101:         1 1001 1001 */  9,   409,  2,  9,  0,  0 },
-    { /* 102:         1 1001 1010 */  9,   410,  8,  6,  0,  0 },
-    { /* 103:         1 1001 1011 */  9,   411,  9,  2,  0,  0 },
-    { /* 104:         1 1001 1100 */  9,   412,  9,  3,  0,  0 },
-    { /* 105:         1 1001 1101 */  9,   413, 15, 16,  0,  0 },
-    { /* 106:         1 1001 1110 */  9,   414,  4,  9,  0,  0 },
-    { /* 107:         1 1001 1111 */  9,   415,  6,  8,  0,  0 },
-    { /* 108:         1 1010 0000 */  9,   416,  6,  0,  0,  0 },
-    { /* 109:         1 1010 0001 */  9,   417,  9,  4,  0,  0 },
-    { /* 110:         1 1010 0010 */  9,   418,  5,  9,  0,  0 },
-    { /* 111:         1 1010 0011 */  9,   419,  8,  7,  0,  0 },
-    { /* 112:         1 1010 0100 */  9,   420,  7,  8,  0,  0 },
-    { /* 113:         1 1010 0101 */  9,   421,  1,  9,  0,  0 },
-    { /* 114:         1 1010 0110 */  9,   422, 10,  3,  0,  0 },
-    { /* 115:         1 1010 0111 */  9,   423,  0,  6,  0,  0 },
-    { /* 116:         1 1010 1000 */  9,   424, 10,  2,  0,  0 },
-    { /* 117:         1 1010 1001 */  9,   425,  9,  1,  0,  0 },
-    { /* 118:         1 1010 1010 */  9,   426,  9,  5,  0,  0 },
-    { /* 119:         1 1010 1011 */  9,   427,  4, 10,  0,  0 },
-    { /* 120:         1 1010 1100 */  9,   428,  2, 10,  0,  0 },
-    { /* 121:         1 1010 1101 */  9,   429,  9,  6,  0,  0 },
-    { /* 122:         1 1010 1110 */  9,   430,  3, 10,  0,  0 },
-    { /* 123:         1 1010 1111 */  9,   431,  6,  9,  0,  0 },
-    { /* 124:         1 1011 0000 */  9,   432, 10,  4,  0,  0 },
-    { /* 125:         1 1011 0001 */  9,   433,  8,  8,  0,  0 },
-    { /* 126:         1 1011 0010 */  9,   434, 10,  5,  0,  0 },
-    { /* 127:         1 1011 0011 */  9,   435,  9,  7,  0,  0 },
-    { /* 128:         1 1011 0100 */  9,   436, 11,  3,  0,  0 },
-    { /* 129:         1 1011 0101 */  9,   437,  1, 10,  0,  0 },
-    { /* 130:         1 1011 0110 */  9,   438,  7,  0,  0,  0 },
-    { /* 131:         1 1011 0111 */  9,   439, 10,  6,  0,  0 },
-    { /* 132:         1 1011 1000 */  9,   440,  7,  9,  0,  0 },
-    { /* 133:         1 1011 1001 */  9,   441,  3, 11,  0,  0 },
-    { /* 134:         1 1011 1010 */  9,   442,  5, 10,  0,  0 },
-    { /* 135:         1 1011 1011 */  9,   443, 10,  1,  0,  0 },
-    { /* 136:         1 1011 1100 */  9,   444,  4, 11,  0,  0 },
-    { /* 137:         1 1011 1101 */  9,   445, 11,  2,  0,  0 },
-    { /* 138:         1 1011 1110 */  9,   446, 13,  2,  0,  0 },
-    { /* 139:         1 1011 1111 */  9,   447,  6, 10,  0,  0 },
-    { /* 140:         1 1100 0000 */  9,   448, 13,  3,  0,  0 },
-    { /* 141:         1 1100 0001 */  9,   449,  2, 11,  0,  0 },
-    { /* 142:         1 1100 0010 */  9,   450, 16,  0,  0,  0 },
-    { /* 143:         1 1100 0011 */  9,   451,  5, 11,  0,  0 },
-    { /* 144:         1 1100 0100 */  9,   452, 11,  5,  0,  0 },
-    { /* 145:        11 1000 1010 */ 10,   906, 11,  4,  0,  0 },
-    { /* 146:        11 1000 1011 */ 10,   907,  9,  8,  0,  0 },
-    { /* 147:        11 1000 1100 */ 10,   908,  7, 10,  0,  0 },
-    { /* 148:        11 1000 1101 */ 10,   909,  8,  9,  0,  0 },
-    { /* 149:        11 1000 1110 */ 10,   910,  0, 16,  0,  0 },
-    { /* 150:        11 1000 1111 */ 10,   911,  4, 13,  0,  0 },
-    { /* 151:        11 1001 0000 */ 10,   912,  0,  7,  0,  0 },
-    { /* 152:        11 1001 0001 */ 10,   913,  3, 13,  0,  0 },
-    { /* 153:        11 1001 0010 */ 10,   914, 11,  6,  0,  0 },
-    { /* 154:        11 1001 0011 */ 10,   915, 13,  1,  0,  0 },
-    { /* 155:        11 1001 0100 */ 10,   916, 13,  4,  0,  0 },
-    { /* 156:        11 1001 0101 */ 10,   917, 12,  3,  0,  0 },
-    { /* 157:        11 1001 0110 */ 10,   918,  2, 13,  0,  0 },
-    { /* 158:        11 1001 0111 */ 10,   919, 13,  5,  0,  0 },
-    { /* 159:        11 1001 1000 */ 10,   920,  8, 10,  0,  0 },
-    { /* 160:        11 1001 1001 */ 10,   921,  6, 11,  0,  0 },
-    { /* 161:        11 1001 1010 */ 10,   922, 10,  8,  0,  0 },
-    { /* 162:        11 1001 1011 */ 10,   923, 10,  7,  0,  0 },
-    { /* 163:        11 1001 1100 */ 10,   924, 14,  2,  0,  0 },
-    { /* 164:        11 1001 1101 */ 10,   925, 12,  4,  0,  0 },
-    { /* 165:        11 1001 1110 */ 10,   926,  1, 11,  0,  0 },
-    { /* 166:        11 1001 1111 */ 10,   927,  4, 12,  0,  0 },
-    { /* 167:        11 1010 0000 */ 10,   928, 11,  1,  0,  0 },
-    { /* 168:        11 1010 0001 */ 10,   929,  3, 12,  0,  0 },
-    { /* 169:        11 1010 0010 */ 10,   930,  1, 13,  0,  0 },
-    { /* 170:        11 1010 0011 */ 10,   931, 12,  2,  0,  0 },
-    { /* 171:        11 1010 0100 */ 10,   932,  7, 11,  0,  0 },
-    { /* 172:        11 1010 0101 */ 10,   933,  3, 14,  0,  0 },
-    { /* 173:        11 1010 0110 */ 10,   934,  5, 12,  0,  0 },
-    { /* 174:        11 1010 0111 */ 10,   935,  5, 13,  0,  0 },
-    { /* 175:        11 1010 1000 */ 10,   936, 14,  4,  0,  0 },
-    { /* 176:        11 1010 1001 */ 10,   937,  4, 14,  0,  0 },
-    { /* 177:        11 1010 1010 */ 10,   938, 11,  7,  0,  0 },
-    { /* 178:        11 1010 1011 */ 10,   939, 14,  3,  0,  0 },
-    { /* 179:        11 1010 1100 */ 10,   940, 12,  5,  0,  0 },
-    { /* 180:        11 1010 1101 */ 10,   941, 13,  6,  0,  0 },
-    { /* 181:        11 1010 1110 */ 10,   942, 12,  6,  0,  0 },
-    { /* 182:        11 1010 1111 */ 10,   943,  8,  0,  0,  0 },
-    { /* 183:        11 1011 0000 */ 10,   944, 11,  8,  0,  0 },
-    { /* 184:        11 1011 0001 */ 10,   945,  2, 12,  0,  0 },
-    { /* 185:        11 1011 0010 */ 10,   946,  9,  9,  0,  0 },
-    { /* 186:        11 1011 0011 */ 10,   947, 14,  5,  0,  0 },
-    { /* 187:        11 1011 0100 */ 10,   948,  6, 13,  0,  0 },
-    { /* 188:        11 1011 0101 */ 10,   949, 10, 10,  0,  0 },
-    { /* 189:        11 1011 0110 */ 10,   950, 15,  2,  0,  0 },
-    { /* 190:        11 1011 0111 */ 10,   951,  8, 11,  0,  0 },
-    { /* 191:        11 1011 1000 */ 10,   952,  9, 10,  0,  0 },
-    { /* 192:        11 1011 1001 */ 10,   953, 14,  6,  0,  0 },
-    { /* 193:        11 1011 1010 */ 10,   954, 10,  9,  0,  0 },
-    { /* 194:        11 1011 1011 */ 10,   955,  5, 14,  0,  0 },
-    { /* 195:        11 1011 1100 */ 10,   956, 11,  9,  0,  0 },
-    { /* 196:        11 1011 1101 */ 10,   957, 14,  1,  0,  0 },
-    { /* 197:        11 1011 1110 */ 10,   958,  2, 14,  0,  0 },
-    { /* 198:        11 1011 1111 */ 10,   959,  6, 12,  0,  0 },
-    { /* 199:        11 1100 0000 */ 10,   960,  1, 12,  0,  0 },
-    { /* 200:        11 1100 0001 */ 10,   961, 13,  8,  0,  0 },
-    { /* 201:        11 1100 0010 */ 10,   962,  0,  8,  0,  0 },
-    { /* 202:        11 1100 0011 */ 10,   963, 13,  7,  0,  0 },
-    { /* 203:        11 1100 0100 */ 10,   964,  7, 12,  0,  0 },
-    { /* 204:        11 1100 0101 */ 10,   965, 12,  7,  0,  0 },
-    { /* 205:        11 1100 0110 */ 10,   966,  7, 13,  0,  0 },
-    { /* 206:        11 1100 0111 */ 10,   967, 15,  3,  0,  0 },
-    { /* 207:        11 1100 1000 */ 10,   968, 12,  1,  0,  0 },
-    { /* 208:        11 1100 1001 */ 10,   969,  6, 14,  0,  0 },
-    { /* 209:        11 1100 1010 */ 10,   970,  2, 15,  0,  0 },
-    { /* 210:        11 1100 1011 */ 10,   971, 15,  5,  0,  0 },
-    { /* 211:        11 1100 1100 */ 10,   972, 15,  4,  0,  0 },
-    { /* 212:        11 1100 1101 */ 10,   973,  1, 14,  0,  0 },
-    { /* 213:        11 1100 1110 */ 10,   974,  9, 11,  0,  0 },
-    { /* 214:        11 1100 1111 */ 10,   975,  4, 15,  0,  0 },
-    { /* 215:        11 1101 0000 */ 10,   976, 14,  7,  0,  0 },
-    { /* 216:        11 1101 0001 */ 10,   977,  8, 13,  0,  0 },
-    { /* 217:        11 1101 0010 */ 10,   978, 13,  9,  0,  0 },
-    { /* 218:        11 1101 0011 */ 10,   979,  8, 12,  0,  0 },
-    { /* 219:        11 1101 0100 */ 10,   980,  5, 15,  0,  0 },
-    { /* 220:        11 1101 0101 */ 10,   981,  3, 15,  0,  0 },
-    { /* 221:        11 1101 0110 */ 10,   982, 10, 11,  0,  0 },
-    { /* 222:        11 1101 0111 */ 10,   983, 11, 10,  0,  0 },
-    { /* 223:        11 1101 1000 */ 10,   984, 12,  8,  0,  0 },
-    { /* 224:        11 1101 1001 */ 10,   985, 15,  6,  0,  0 },
-    { /* 225:        11 1101 1010 */ 10,   986, 15,  7,  0,  0 },
-    { /* 226:        11 1101 1011 */ 10,   987,  8, 14,  0,  0 },
-    { /* 227:        11 1101 1100 */ 10,   988, 15,  1,  0,  0 },
-    { /* 228:        11 1101 1101 */ 10,   989,  7, 14,  0,  0 },
-    { /* 229:        11 1101 1110 */ 10,   990,  9,  0,  0,  0 },
-    { /* 230:        11 1101 1111 */ 10,   991,  0,  9,  0,  0 },
-    { /* 231:        11 1110 0000 */ 10,   992,  9, 13,  0,  0 },
-    { /* 232:        11 1110 0001 */ 10,   993,  9, 12,  0,  0 },
-    { /* 233:        11 1110 0010 */ 10,   994, 12,  9,  0,  0 },
-    { /* 234:        11 1110 0011 */ 10,   995, 14,  8,  0,  0 },
-    { /* 235:        11 1110 0100 */ 10,   996, 10, 13,  0,  0 },
-    { /* 236:        11 1110 0101 */ 10,   997, 14,  9,  0,  0 },
-    { /* 237:        11 1110 0110 */ 10,   998, 12, 10,  0,  0 },
-    { /* 238:        11 1110 0111 */ 10,   999,  6, 15,  0,  0 },
-    { /* 239:        11 1110 1000 */ 10,  1000,  7, 15,  0,  0 },
-    { /* 240:       111 1101 0010 */ 11,  2002,  9, 14,  0,  0 },
-    { /* 241:       111 1101 0011 */ 11,  2003, 15,  8,  0,  0 },
-    { /* 242:       111 1101 0100 */ 11,  2004, 11, 11,  0,  0 },
-    { /* 243:       111 1101 0101 */ 11,  2005, 11, 14,  0,  0 },
-    { /* 244:       111 1101 0110 */ 11,  2006,  1, 15,  0,  0 },
-    { /* 245:       111 1101 0111 */ 11,  2007, 10, 12,  0,  0 },
-    { /* 246:       111 1101 1000 */ 11,  2008, 10, 14,  0,  0 },
-    { /* 247:       111 1101 1001 */ 11,  2009, 13, 11,  0,  0 },
-    { /* 248:       111 1101 1010 */ 11,  2010, 13, 10,  0,  0 },
-    { /* 249:       111 1101 1011 */ 11,  2011, 11, 13,  0,  0 },
-    { /* 250:       111 1101 1100 */ 11,  2012, 11, 12,  0,  0 },
-    { /* 251:       111 1101 1101 */ 11,  2013,  8, 15,  0,  0 },
-    { /* 252:       111 1101 1110 */ 11,  2014, 14, 11,  0,  0 },
-    { /* 253:       111 1101 1111 */ 11,  2015, 13, 12,  0,  0 },
-    { /* 254:       111 1110 0000 */ 11,  2016, 12, 13,  0,  0 },
-    { /* 255:       111 1110 0001 */ 11,  2017, 15,  9,  0,  0 },
-    { /* 256:       111 1110 0010 */ 11,  2018, 14, 10,  0,  0 },
-    { /* 257:       111 1110 0011 */ 11,  2019, 10,  0,  0,  0 },
-    { /* 258:       111 1110 0100 */ 11,  2020, 12, 11,  0,  0 },
-    { /* 259:       111 1110 0101 */ 11,  2021,  9, 15,  0,  0 },
-    { /* 260:       111 1110 0110 */ 11,  2022,  0, 10,  0,  0 },
-    { /* 261:       111 1110 0111 */ 11,  2023, 12, 12,  0,  0 },
-    { /* 262:       111 1110 1000 */ 11,  2024, 11,  0,  0,  0 },
-    { /* 263:       111 1110 1001 */ 11,  2025, 12, 14,  0,  0 },
-    { /* 264:       111 1110 1010 */ 11,  2026, 10, 15,  0,  0 },
-    { /* 265:       111 1110 1011 */ 11,  2027, 13, 13,  0,  0 },
-    { /* 266:       111 1110 1100 */ 11,  2028,  0, 13,  0,  0 },
-    { /* 267:       111 1110 1101 */ 11,  2029, 14, 12,  0,  0 },
-    { /* 268:       111 1110 1110 */ 11,  2030, 15, 10,  0,  0 },
-    { /* 269:       111 1110 1111 */ 11,  2031, 15, 11,  0,  0 },
-    { /* 270:       111 1111 0000 */ 11,  2032, 11, 15,  0,  0 },
-    { /* 271:       111 1111 0001 */ 11,  2033, 14, 13,  0,  0 },
-    { /* 272:       111 1111 0010 */ 11,  2034, 13,  0,  0,  0 },
-    { /* 273:       111 1111 0011 */ 11,  2035,  0, 11,  0,  0 },
-    { /* 274:       111 1111 0100 */ 11,  2036, 13, 14,  0,  0 },
-    { /* 275:       111 1111 0101 */ 11,  2037, 15, 12,  0,  0 },
-    { /* 276:       111 1111 0110 */ 11,  2038, 15, 13,  0,  0 },
-    { /* 277:       111 1111 0111 */ 11,  2039, 12, 15,  0,  0 },
-    { /* 278:       111 1111 1000 */ 11,  2040, 14,  0,  0,  0 },
-    { /* 279:       111 1111 1001 */ 11,  2041, 14, 14,  0,  0 },
-    { /* 280:       111 1111 1010 */ 11,  2042, 13, 15,  0,  0 },
-    { /* 281:       111 1111 1011 */ 11,  2043, 12,  0,  0,  0 },
-    { /* 282:       111 1111 1100 */ 11,  2044, 14, 15,  0,  0 },
-    { /* 283:      1111 1111 1010 */ 12,  4090,  0, 14,  0,  0 },
-    { /* 284:      1111 1111 1011 */ 12,  4091,  0, 12,  0,  0 },
-    { /* 285:      1111 1111 1100 */ 12,  4092, 15, 14,  0,  0 },
-    { /* 286:      1111 1111 1101 */ 12,  4093, 15,  0,  0,  0 },
-    { /* 287:      1111 1111 1110 */ 12,  4094,  0, 15,  0,  0 },
-    { /* 288:      1111 1111 1111 */ 12,  4095, 15, 15,  0,  0 }
-};
-
-extern codebook_scl bookscl[] = {
-      /* idx                 codeword   len   codew  idx */
-    { /*   0:                       0 */  1,      0,  60 },
-    { /*   1:                     100 */  3,      4,  59 },
-    { /*   2:                    1010 */  4,     10,  61 },
-    { /*   3:                    1011 */  4,     11,  58 },
-    { /*   4:                    1100 */  4,     12,  62 },
-    { /*   5:                  1 1010 */  5,     26,  57 },
-    { /*   6:                  1 1011 */  5,     27,  63 },
-    { /*   7:                 11 1000 */  6,     56,  56 },
-    { /*   8:                 11 1001 */  6,     57,  64 },
-    { /*   9:                 11 1010 */  6,     58,  55 },
-    { /*  10:                 11 1011 */  6,     59,  65 },
-    { /*  11:                111 1000 */  7,    120,  66 },
-    { /*  12:                111 1001 */  7,    121,  54 },
-    { /*  13:                111 1010 */  7,    122,  67 },
-    { /*  14:               1111 0110 */  8,    246,  53 },
-    { /*  15:               1111 0111 */  8,    247,  68 },
-    { /*  16:               1111 1000 */  8,    248,  52 },
-    { /*  17:               1111 1001 */  8,    249,  69 },
-    { /*  18:               1111 1010 */  8,    250,  51 },
-    { /*  19:             1 1111 0110 */  9,    502,  70 },
-    { /*  20:             1 1111 0111 */  9,    503,  50 },
-    { /*  21:             1 1111 1000 */  9,    504,  49 },
-    { /*  22:             1 1111 1001 */  9,    505,  71 },
-    { /*  23:            11 1111 0100 */ 10,   1012,  72 },
-    { /*  24:            11 1111 0101 */ 10,   1013,  48 },
-    { /*  25:            11 1111 0110 */ 10,   1014,  73 },
-    { /*  26:            11 1111 0111 */ 10,   1015,  47 },
-    { /*  27:            11 1111 1000 */ 10,   1016,  74 },
-    { /*  28:            11 1111 1001 */ 10,   1017,  46 },
-    { /*  29:           111 1111 0100 */ 11,   2036,  76 },
-    { /*  30:           111 1111 0101 */ 11,   2037,  75 },
-    { /*  31:           111 1111 0110 */ 11,   2038,  77 },
-    { /*  32:           111 1111 0111 */ 11,   2039,  78 },
-    { /*  33:           111 1111 1000 */ 11,   2040,  45 },
-    { /*  34:           111 1111 1001 */ 11,   2041,  43 },
-    { /*  35:          1111 1111 0100 */ 12,   4084,  44 },
-    { /*  36:          1111 1111 0101 */ 12,   4085,  79 },
-    { /*  37:          1111 1111 0110 */ 12,   4086,  42 },
-    { /*  38:          1111 1111 0111 */ 12,   4087,  41 },
-    { /*  39:          1111 1111 1000 */ 12,   4088,  80 },
-    { /*  40:          1111 1111 1001 */ 12,   4089,  40 },
-    { /*  41:        1 1111 1111 0100 */ 13,   8180,  81 },
-    { /*  42:        1 1111 1111 0101 */ 13,   8181,  39 },
-    { /*  43:        1 1111 1111 0110 */ 13,   8182,  82 },
-    { /*  44:        1 1111 1111 0111 */ 13,   8183,  38 },
-    { /*  45:        1 1111 1111 1000 */ 13,   8184,  83 },
-    { /*  46:       11 1111 1111 0010 */ 14,  16370,  37 },
-    { /*  47:       11 1111 1111 0011 */ 14,  16371,  35 },
-    { /*  48:       11 1111 1111 0100 */ 14,  16372,  85 },
-    { /*  49:       11 1111 1111 0101 */ 14,  16373,  33 },
-    { /*  50:       11 1111 1111 0110 */ 14,  16374,  36 },
-    { /*  51:       11 1111 1111 0111 */ 14,  16375,  34 },
-    { /*  52:       11 1111 1111 1000 */ 14,  16376,  84 },
-    { /*  53:       11 1111 1111 1001 */ 14,  16377,  32 },
-    { /*  54:      111 1111 1111 0100 */ 15,  32756,  87 },
-    { /*  55:      111 1111 1111 0101 */ 15,  32757,  89 },
-    { /*  56:      111 1111 1111 0110 */ 15,  32758,  30 },
-    { /*  57:      111 1111 1111 0111 */ 15,  32759,  31 },
-    { /*  58:     1111 1111 1111 0000 */ 16,  65520,  86 },
-    { /*  59:     1111 1111 1111 0001 */ 16,  65521,  29 },
-    { /*  60:     1111 1111 1111 0010 */ 16,  65522,  26 },
-    { /*  61:     1111 1111 1111 0011 */ 16,  65523,  27 },
-    { /*  62:     1111 1111 1111 0100 */ 16,  65524,  28 },
-    { /*  63:     1111 1111 1111 0101 */ 16,  65525,  24 },
-    { /*  64:     1111 1111 1111 0110 */ 16,  65526,  88 },
-    { /*  65:   1 1111 1111 1110 1110 */ 17, 131054,  25 },
-    { /*  66:   1 1111 1111 1110 1111 */ 17, 131055,  22 },
-    { /*  67:   1 1111 1111 1111 0000 */ 17, 131056,  23 },
-    { /*  68:  11 1111 1111 1110 0010 */ 18, 262114,  90 },
-    { /*  69:  11 1111 1111 1110 0011 */ 18, 262115,  21 },
-    { /*  70:  11 1111 1111 1110 0100 */ 18, 262116,  19 },
-    { /*  71:  11 1111 1111 1110 0101 */ 18, 262117,   3 },
-    { /*  72:  11 1111 1111 1110 0110 */ 18, 262118,   1 },
-    { /*  73:  11 1111 1111 1110 0111 */ 18, 262119,   2 },
-    { /*  74:  11 1111 1111 1110 1000 */ 18, 262120,   0 },
-    { /*  75: 111 1111 1111 1101 0010 */ 19, 524242,  98 },
-    { /*  76: 111 1111 1111 1101 0011 */ 19, 524243,  99 },
-    { /*  77: 111 1111 1111 1101 0100 */ 19, 524244, 100 },
-    { /*  78: 111 1111 1111 1101 0101 */ 19, 524245, 101 },
-    { /*  79: 111 1111 1111 1101 0110 */ 19, 524246, 102 },
-    { /*  80: 111 1111 1111 1101 0111 */ 19, 524247, 117 },
-    { /*  81: 111 1111 1111 1101 1000 */ 19, 524248,  97 },
-    { /*  82: 111 1111 1111 1101 1001 */ 19, 524249,  91 },
-    { /*  83: 111 1111 1111 1101 1010 */ 19, 524250,  92 },
-    { /*  84: 111 1111 1111 1101 1011 */ 19, 524251,  93 },
-    { /*  85: 111 1111 1111 1101 1100 */ 19, 524252,  94 },
-    { /*  86: 111 1111 1111 1101 1101 */ 19, 524253,  95 },
-    { /*  87: 111 1111 1111 1101 1110 */ 19, 524254,  96 },
-    { /*  88: 111 1111 1111 1101 1111 */ 19, 524255, 104 },
-    { /*  89: 111 1111 1111 1110 0000 */ 19, 524256, 111 },
-    { /*  90: 111 1111 1111 1110 0001 */ 19, 524257, 112 },
-    { /*  91: 111 1111 1111 1110 0010 */ 19, 524258, 113 },
-    { /*  92: 111 1111 1111 1110 0011 */ 19, 524259, 114 },
-    { /*  93: 111 1111 1111 1110 0100 */ 19, 524260, 115 },
-    { /*  94: 111 1111 1111 1110 0101 */ 19, 524261, 116 },
-    { /*  95: 111 1111 1111 1110 0110 */ 19, 524262, 110 },
-    { /*  96: 111 1111 1111 1110 0111 */ 19, 524263, 105 },
-    { /*  97: 111 1111 1111 1110 1000 */ 19, 524264, 106 },
-    { /*  98: 111 1111 1111 1110 1001 */ 19, 524265, 107 },
-    { /*  99: 111 1111 1111 1110 1010 */ 19, 524266, 108 },
-    { /* 100: 111 1111 1111 1110 1011 */ 19, 524267, 109 },
-    { /* 101: 111 1111 1111 1110 1100 */ 19, 524268, 118 },
-    { /* 102: 111 1111 1111 1110 1101 */ 19, 524269,   6 },
-    { /* 103: 111 1111 1111 1110 1110 */ 19, 524270,   8 },
-    { /* 104: 111 1111 1111 1110 1111 */ 19, 524271,   9 },
-    { /* 105: 111 1111 1111 1111 0000 */ 19, 524272,  10 },
-    { /* 106: 111 1111 1111 1111 0001 */ 19, 524273,   5 },
-    { /* 107: 111 1111 1111 1111 0010 */ 19, 524274, 103 },
-    { /* 108: 111 1111 1111 1111 0011 */ 19, 524275, 120 },
-    { /* 109: 111 1111 1111 1111 0100 */ 19, 524276, 119 },
-    { /* 110: 111 1111 1111 1111 0101 */ 19, 524277,   4 },
-    { /* 111: 111 1111 1111 1111 0110 */ 19, 524278,   7 },
-    { /* 112: 111 1111 1111 1111 0111 */ 19, 524279,  15 },
-    { /* 113: 111 1111 1111 1111 1000 */ 19, 524280,  16 },
-    { /* 114: 111 1111 1111 1111 1001 */ 19, 524281,  18 },
-    { /* 115: 111 1111 1111 1111 1010 */ 19, 524282,  20 },
-    { /* 116: 111 1111 1111 1111 1011 */ 19, 524283,  17 },
-    { /* 117: 111 1111 1111 1111 1100 */ 19, 524284,  11 },
-    { /* 118: 111 1111 1111 1111 1101 */ 19, 524285,  12 },
-    { /* 119: 111 1111 1111 1111 1110 */ 19, 524286,  14 },
-    { /* 120: 111 1111 1111 1111 1111 */ 19, 524287,  13 }
-};
--- a/libfaad/huffman.h
+++ b/libfaad/huffman.h
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: huffman.h,v 1.3 2002/01/19 16:19:54 menno Exp $
+** $Id: huffman.h,v 1.4 2002/02/15 20:52:09 menno Exp $
 **/
 
 #ifndef __HUFFMAN_H__
@@ -31,53 +31,12 @@
 #include <stdio.h>
 #endif
 #include "bits.h"
+#include "codebook/hcb.h"
 
 
-typedef struct
-{
-    short len;
-    unsigned long cw;
-    char x, y, v, w;
-} codebook;
-
-typedef struct
-{
-    short len;
-    unsigned long cw;
-    int scl;
-} codebook_scl;
-
-extern codebook book1[];
-extern codebook book2[];
-extern codebook book3[];
-extern codebook book4[];
-extern codebook book5[];
-extern codebook book6[];
-extern codebook book7[];
-extern codebook book8[];
-extern codebook book9[];
-extern codebook book10[];
-extern codebook book11[];
-extern codebook_scl bookscl[];
-
-static codebook *book_table[] = {
-    0,
-    book1,
-    book2,
-    book3,
-    book4,
-    book5,
-    book6,
-    book7,
-    book8,
-    book9,
-    book10,
-    book11
-};
-
 #if defined(LINUX)
 #define huff_inline inline
-#elif defined(WIN32)
+#elif defined(_WIN32)
 #define huff_inline __inline
 #else
 #define huff_inline
@@ -85,69 +44,120 @@
 
 static huff_inline int huffman_scale_factor(bitfile *ld)
 {
-    int i, j;
-    long cw;
-    codebook_scl *h = bookscl;
+    unsigned int offset = 0;
 
-    i = h->len;
-    cw = faad_getbits(ld, i);
-
-    while ((unsigned long)cw != h->cw)
+    while (hcb_sf[offset][1])
     {
-        h++;
-        j = h->len-i;
-        i = h->len;
-        if (j!=0) {
-            while (j--)
-                cw = (cw<<1) | faad_get1bit(ld);
-        }
+        int b = faad_get1bit(ld);
+        offset += hcb_sf[offset][b];
     }
+    return hcb_sf[offset][0];
+}
 
-#ifdef ANALYSIS
-    fprintf(stdout, "%4d %2d bits, huffman_scale_factor(): huffman codeword (scalefactor)\n",
-        dbg_count++, h->len);
-#endif
 
-    return h->scl;
-}
+static hcb *hcb_table[] = {
+    0, hcb1_1, hcb2_1, 0, hcb4_1, 0, hcb6_1, 0, hcb8_1, 0, hcb10_1, hcb11_1
+};
 
-static int codebookN[] = { 0, 7, 7, 9 };
+static hcb_2_quad *hcb_2_quad_table[] = {
+    0, hcb1_2, hcb2_2, 0, hcb4_2, 0, 0, 0, 0, 0, 0, 0
+};
 
+static hcb_2_pair *hcb_2_pair_table[] = {
+    0, 0, 0, 0, 0, 0, hcb6_2, 0, hcb8_2, 0, hcb10_2, hcb11_2
+};
+
+static hcb_bin_pair *hcb_bin_table[] = {
+    0, 0, 0, 0, 0, hcb5, 0, hcb7, 0, hcb9, 0, 0
+};
+
+static int hcbN[] = { 0, 5, 5, 0, 5, 0, 5, 0, 5, 0, 6, 5 };
+
+
 static huff_inline void huffman_spectral_data(int cb, bitfile *ld, short *sp)
 {
-    int i, j;
-    unsigned long cw;
-    codebook *h;
+    unsigned int cw;
+    unsigned int offset = 0;
+    unsigned int extra_bits;
 
-    h = book_table[cb];
-    i = h->len;
-    cw = faad_getbits(ld, i DEBUGVAR(0,0,""));
-
-    while (cw != h->cw)
+    switch (cb)
     {
-        h++;
-        j = h->len-i;
-        i = h->len;
-        if (j!=0) {
-            while (j--)
-                cw = (cw<<1) | faad_get1bit(ld DEBUGVAR(0,0,""));
+    case 1: /* 2-step method for data quadruples */
+    case 2:
+    case 4:
+
+        cw = faad_showbits(ld, hcbN[cb]);
+        offset = hcb_table[cb][cw].offset;
+        extra_bits = hcb_table[cb][cw].extra_bits;
+
+        if (extra_bits)
+        {
+            /* we know for sure it's more than hcbN[cb] bits long */
+            faad_flushbits(ld, hcbN[cb]);
+            offset += faad_showbits(ld, extra_bits);
+            faad_flushbits(ld, hcb_2_quad_table[cb][offset].bits - hcbN[cb]);
+        } else {
+            faad_flushbits(ld, hcb_2_quad_table[cb][offset].bits);
         }
-    }
 
-#ifdef ANALYSIS
-    fprintf(stdout, "%4d %2d bits, huffman_spectral_data(): huffman codeword\n",
-        dbg_count++, h->len);
-#endif
+        sp[0] = hcb_2_quad_table[cb][offset].x;
+        sp[1] = hcb_2_quad_table[cb][offset].y;
+        sp[2] = hcb_2_quad_table[cb][offset].v;
+        sp[3] = hcb_2_quad_table[cb][offset].w;
+        break;
 
-    if(cb < FIRST_PAIR_HCB)
-    {
-        sp[0] = h->x;
-        sp[1] = h->y;
-        sp[2] = h->v;
-        sp[3] = h->w;
-    } else {
-        sp[0] = h->x;
-        sp[1] = h->y;
+    case 6: /* 2-step method for data pairs */
+    case 8:
+    case 10:
+    case 11:
+
+        cw = faad_showbits(ld, hcbN[cb]);
+        offset = hcb_table[cb][cw].offset;
+        extra_bits = hcb_table[cb][cw].extra_bits;
+
+        if (extra_bits)
+        {
+            /* we know for sure it's more than hcbN[cb] bits long */
+            faad_flushbits(ld, hcbN[cb]);
+            offset += faad_showbits(ld, extra_bits);
+            faad_flushbits(ld, hcb_2_pair_table[cb][offset].bits - hcbN[cb]);
+        } else {
+            faad_flushbits(ld, hcb_2_pair_table[cb][offset].bits);
+        }
+
+        sp[0] = hcb_2_pair_table[cb][offset].x;
+        sp[1] = hcb_2_pair_table[cb][offset].y;
+        break;
+
+    case 3: /* binary search for data quadruples */
+
+        while (!hcb3[offset].is_leaf)
+        {
+            int b = faad_get1bit(ld);
+            offset += hcb3[offset].data[b];
+        }
+
+        sp[0] = hcb3[offset].data[0];
+        sp[1] = hcb3[offset].data[1];
+        sp[2] = hcb3[offset].data[2];
+        sp[3] = hcb3[offset].data[3];
+
+        break;
+
+    case 5: /* binary search for data pairs */
+    case 7:
+    case 9:
+
+        while (!hcb_bin_table[cb][offset].is_leaf)
+        {
+            int b = faad_get1bit(ld);
+            offset += hcb_bin_table[cb][offset].data[b];
+        }
+
+        sp[0] = hcb_bin_table[cb][offset].data[0];
+        sp[1] = hcb_bin_table[cb][offset].data[1];
+
+        break;
     }
 }
 
--- a/libfaad/libfaad.dsp
+++ b/libfaad/libfaad.dsp
@@ -83,8 +83,60 @@
 # Begin Group "Source Files"
 
 # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Group "codebook"
+
+# PROP Default_Filter ""
 # Begin Source File
 
+SOURCE=.\codebook\hcb_1.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\codebook\hcb_10.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\codebook\hcb_11.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\codebook\hcb_2.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\codebook\hcb_3.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\codebook\hcb_4.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\codebook\hcb_5.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\codebook\hcb_6.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\codebook\hcb_7.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\codebook\hcb_8.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\codebook\hcb_9.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\codebook\hcb_sf.c
+# End Source File
+# End Group
+# Begin Source File
+
 SOURCE=.\bits.c
 # End Source File
 # Begin Source File
@@ -109,10 +161,6 @@
 # End Source File
 # Begin Source File
 
-SOURCE=.\huffman.c
-# End Source File
-# Begin Source File
-
 SOURCE=.\ic_predict.c
 # End Source File
 # Begin Source File
@@ -190,6 +238,10 @@
 # Begin Source File
 
 SOURCE=.\filtbank.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\codebook\hcb.h
 # End Source File
 # Begin Source File