shithub: aacenc

Download patch

ref: abe8e167487822dd932fe4f312fbbd4cd3d6ffcd
parent: 772aa2cee4fda55e2104240bf4d58f389c6f1f90
author: Krzysztof Nikiel <knik@users.sourceforge.net>
date: Sat Oct 14 08:19:15 EDT 2017

removed old huffman code

--- a/libfaac/huffman.c
+++ /dev/null
@@ -1,1244 +1,0 @@
-/***********
-
-This software module was originally developed by Dolby
-Laboratories and edited by Sony Corporation
-in the course of development of the MPEG-2 NBC/MPEG-4
-Audio standard ISO/IEC13818-7, 14496-1, 2 and 3. This software module is an
-implementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio tools as
-specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC  gives users of the
-MPEG-2NBC/MPEG-4 Audio standards free license to this software module
-or modifications thereof for use in hardware or software products
-claiming conformance to the MPEG-2 NBC/MPEG-4 Audio  standards. Those
-intending to use this software module in hardware or software products
-are advised that this use may infringe existing patents. The original
-developer of this software module, the subsequent
-editors and their companies, and ISO/IEC have no liability for use of
-this software module or modifications thereof in an
-implementation. Copyright is not released for non MPEG-2 NBC/MPEG-4
-Audio conforming products. The original developer retains full right to
-use the code for the developer's own purpose, assign or donate the code to a
-third party and to inhibit third party from using the code for non
-MPEG-2 NBC/MPEG-4 Audio conforming products. This copyright notice
-must be included in all copies or derivative works. Copyright 1996.
-
-***********/
-/*
- * $Id: huffman.c,v 1.12 2009/06/05 16:16:06 menno Exp $
- */
-
-#include <math.h>
-#include <stdlib.h>
-
-#include "huffman.h"
-#include "coder.h"
-#include "bitstream.h"
-#include "util.h"
-
-#include "hufftab.h"
-
-void HuffmanInit(CoderInfo *coderInfo, unsigned int numChannels)
-{
-    unsigned int channel;
-
-    for (channel = 0; channel < numChannels; channel++) {
-        coderInfo[channel].data = (int*)AllocMemory(5*FRAME_LEN*sizeof(int));
-        coderInfo[channel].len = (int*)AllocMemory(5*FRAME_LEN*sizeof(int));
-
-#ifdef DRM
-        coderInfo[channel].num_data_cw = (int*)AllocMemory(FRAME_LEN*sizeof(int));
-#endif
-    }
-}
-
-void HuffmanEnd(CoderInfo *coderInfo, unsigned int numChannels)
-{
-    unsigned int channel;
-
-    for (channel = 0; channel < numChannels; channel++) {
-        if (coderInfo[channel].data) FreeMemory(coderInfo[channel].data);
-        if (coderInfo[channel].len) FreeMemory(coderInfo[channel].len);
-
-#ifdef DRM
-        if (coderInfo[channel].num_data_cw) FreeMemory(coderInfo[channel].num_data_cw);
-#endif
-    }
-}
-
-int BitSearch(CoderInfo *coderInfo,
-              int *quant)  /* Quantized spectral values */
-  /*
-  This function inputs a vector of quantized spectral data, quant[][], and returns a vector,
-  'book_vector[]' that describes how to group together the scalefactor bands into a smaller
-  number of sections.  There are MAX_SCFAC_BANDS elements in book_vector (equal to 49 in the
-  case of long blocks and 112 for short blocks), and each element has a huffman codebook
-  number assigned to it.
-
-  For a quick and simple algorithm, this function performs a binary
-  search across the sfb's (scale factor bands).  On the first approach, it calculates the
-  needed amount of bits if every sfb were its own section and transmitted its own huffman
-  codebook value side information (equal to 9 bits for a long block, 7 for a short).  The
-  next iteration combines adjacent sfb's, and calculates the bit rate for length two sfb
-  sections.  If any wider two-sfb section requires fewer bits than the sum of the two
-  single-sfb sections (below it in the binary tree), then the wider section will be chosen.
-  This process occurs until the sections are split into three uniform parts, each with an
-  equal amount of sfb's contained.
-
-  The binary tree is stored as a two-dimensional array.  Since this tree is not full, (there
-  are only 49 nodes, not 2^6 = 64), the numbering is a little complicated.  If the tree were
-  full, the top node would be 1.  It's children would be 2 and 3.  But, since this tree
-  is not full, the top row of three nodes are numbered {4,5,6}.  The row below it is
-  {8,9,10,11,12,13}, and so on.
-
-  The binary tree is called bit_stats[112][3].  There are 112 total nodes (some are not
-  used since it's not full).  bit_stats[x][0] holds the bit totals needed for the sfb sectioning
-  strategy represented by the node x in the tree.  bit_stats[x][1] holds the optimal huffman
-  codebook table that minimizes the bit rate, given the sectioning boundaries dictated by node x.
-*/
-
-{
-    int i,j,k;
-    int hop;
-    int min_book_choice[112][3];
-    int bit_stats[240][3];
-    int total_bit_count;
-    int levels;
-    int pow2levels;
-    int fracpow2lev;
-
-    /* Set local pointer to coderInfo book_vector */
-    int* book_vector = coderInfo -> book_vector;
-
-    levels = (int) ((log((double)coderInfo->sfbn)/log((double)2.0))+1);
-
-/* #define SLOW */
-
-#ifdef SLOW
-    for(i = 0; i < 5; i++) {
-#else
-        i = 0;
-#endif
-        hop = 1 << i;
-
-        NoiselessBitCount(coderInfo, quant, hop, min_book_choice);
-
-        /* load up the (not-full) binary search tree with the min_book_choice values */
-        k=0;
-        total_bit_count = 0;
-
-        pow2levels = 1 << (levels - i);
-        fracpow2lev = pow2levels + (coderInfo->sfbn >> i);
-
-        for (j=pow2levels; j < fracpow2lev; j++)
-        {
-            bit_stats[j][0] = min_book_choice[k][0]; /* the minimum bit cost for this section */
-            bit_stats[j][1] = min_book_choice[k][1]; /* used with this huffman book number */
-
-#ifdef SLOW
-            if (i>0){  /* not on the lowest level, grouping more than one signle scalefactor band per section*/
-                if  (bit_stats[j][0] < bit_stats[2*j][0] + bit_stats[2*j+1][0]){
-
-                    /* it is cheaper to combine surrounding sfb secionts into one larger huffman book section */
-                    for(n=k;n<k+hop;n++) { /* write the optimal huffman book value for the new larger section */
-                        if ( (book_vector[n]!=INTENSITY_HCB)&&(book_vector[n]!=INTENSITY_HCB2) ) { /* Don't merge with IS bands */
-                            book_vector[n] = bit_stats[j][1];
-                        }
-                    }
-                } else {  /* it was cheaper to transmit the smaller huffman table sections */
-                    bit_stats[j][0] = bit_stats[2*j][0] + bit_stats[2*j+1][0];
-                }
-	    } else
-#endif
-	    {  /* during the first stage of the iteration, all sfb's are individual sections */
-                if ( (book_vector[k]!=INTENSITY_HCB)&&(book_vector[k]!=INTENSITY_HCB2) ) {
-                    book_vector[k] = bit_stats[j][1];  /* initially, set all sfb's to their own optimal section table values */
-                }
-            }
-            total_bit_count = total_bit_count +  bit_stats[j][0];
-            k=k+hop;
-        }
-#ifdef SLOW
-    }
-#endif
-    /*   book_vector[k] = book_vector[k-1]; */
-    return(total_bit_count);
-}
-
-
-int NoiselessBitCount(CoderInfo *coderInfo,
-                      int *quant,
-                      int hop,
-                      int min_book_choice[112][3])
-{
-  int i,j,k;
-
-  /*
-     This function inputs:
-     - the quantized spectral data, 'quant[]';
-     - all of the huffman codebooks, 'huff[][]';
-     - the size of the sections, in scalefactor bands (SFB's), 'hop';
-     - an empty matrix, min_book_choice[][] passed to it;
-
-     This function outputs:
-     - the matrix, min_book_choice.  It is a two dimensional matrix, with its
-     rows corresponding to spectral sections.  The 0th column corresponds to
-     the bits needed to code a section with 'hop' scalefactors bands wide, all using
-     the same huffman codebook.  The 1st column contains the huffman codebook number
-     that allows the minimum number of bits to be used.
-
-     Other notes:
-     - Initally, the dynamic range is calculated for each spectral section.  The section
-     can only be entropy coded with books that have an equal or greater dynamic range
-     than the section's spectral data.  The exception to this is for the 11th ESC codebook.
-     If the dynamic range is larger than 16, then an escape code is appended after the
-     table 11 codeword which encodes the larger value explicity in a pseudo-non-uniform
-     quantization method.
-
-     */
-
-    int max_sb_coeff;
-    int book_choice[12][2];
-    int total_bits_cost = 0;
-    int offset, length, end;
-    int q;
-
-    /* set local pointer to sfb_offset */
-    int *sfb_offset = coderInfo->sfb_offset;
-    int sfbn = coderInfo->sfbn;
-
-    /* each section is 'hop' scalefactor bands wide */
-    for (i = 0; i < sfbn; i = i + hop){
-#ifdef SLOW
-        if ((i+hop) > nr_of_sfb)
-            q = nr_of_sfb;
-        else
-#endif
-            q = i+hop;
-
-        {
-
-            /* find the maximum absolute value in the current spectral section, to see what tables are available to use */
-            max_sb_coeff = 0;
-            for (j=sfb_offset[i]; j<sfb_offset[q]; j++){  /* snl */
-                if (ABS(quant[j]) > max_sb_coeff)
-                    max_sb_coeff = ABS(quant[j]);
-            }
-
-            j = 0;
-            offset = sfb_offset[i];
-#ifdef SLOW
-            if ((i+hop) > nr_of_sfb){
-                end = sfb_offset[nr_of_sfb];
-            } else
-#endif
-                end = sfb_offset[q];
-            length = end - offset;
-
-            /* all spectral coefficients in this section are zero */
-            if (max_sb_coeff == 0) {
-                book_choice[j][0] = CalcBits(coderInfo,0,quant,offset,length);
-                book_choice[j++][1] = 0;
-
-            }
-            else {  /* if the section does have non-zero coefficients */
-                if(max_sb_coeff < 2){
-                    book_choice[j][0] = CalcBits(coderInfo,1,quant,offset,length);
-                    book_choice[j++][1] = 1;
-                    book_choice[j][0] = CalcBits(coderInfo,2,quant,offset,length);
-                    book_choice[j++][1] = 2;
-                    book_choice[j][0] = CalcBits(coderInfo,3,quant,offset,length);
-                    book_choice[j++][1] = 3;
-                }
-                else if (max_sb_coeff < 3){
-                    book_choice[j][0] = CalcBits(coderInfo,3,quant,offset,length);
-                    book_choice[j++][1] = 3;
-                    book_choice[j][0] = CalcBits(coderInfo,4,quant,offset,length);
-                    book_choice[j++][1] = 4;
-                    book_choice[j][0] = CalcBits(coderInfo,5,quant,offset,length);
-                    book_choice[j++][1] = 5;
-                }
-                else if (max_sb_coeff < 5){
-                    book_choice[j][0] = CalcBits(coderInfo,5,quant,offset,length);
-                    book_choice[j++][1] = 5;
-                    book_choice[j][0] = CalcBits(coderInfo,6,quant,offset,length);
-                    book_choice[j++][1] = 6;
-                    book_choice[j][0] = CalcBits(coderInfo,7,quant,offset,length);
-                    book_choice[j++][1] = 7;
-                }
-                else if (max_sb_coeff < 8){
-                    book_choice[j][0] = CalcBits(coderInfo,7,quant,offset,length);
-                    book_choice[j++][1] = 7;
-                    book_choice[j][0] = CalcBits(coderInfo,8,quant,offset,length);
-                    book_choice[j++][1] = 8;
-                    book_choice[j][0] = CalcBits(coderInfo,9,quant,offset,length);
-                    book_choice[j++][1] = 9;
-                }
-                else if (max_sb_coeff < 13){
-                    book_choice[j][0] = CalcBits(coderInfo,9,quant,offset,length);
-                    book_choice[j++][1] = 9;
-                    book_choice[j][0] = CalcBits(coderInfo,10,quant,offset,length);
-                    book_choice[j++][1] = 10;
-                }
-                /* (max_sb_coeff >= 13), choose table 11 */
-                else {
-                    book_choice[j][0] = CalcBits(coderInfo,11,quant,offset,length);
-                    book_choice[j++][1] = 11;
-                }
-            }
-
-            /* find the minimum bit cost and table number for huffman coding this scalefactor section */
-            min_book_choice[i][1] = book_choice[0][1];
-            min_book_choice[i][0] = book_choice[0][0];
-
-            for(k=1;k<j;k++){
-                if (book_choice[k][0] < min_book_choice[i][0]){
-                    min_book_choice[i][1] = book_choice[k][1];
-                    min_book_choice[i][0] = book_choice[k][0];
-                }
-            }
-            total_bits_cost += min_book_choice[i][0];
-        }
-    }
-    return(total_bits_cost);
-}
-
-
-
-static int CalculateEscSequence(int input, int *len_esc_sequence)
-/*
-   This function takes an element that is larger than 16 and generates the base10 value of the
-   equivalent escape sequence.  It returns the escape sequence in the variable, 'output'.  It
-   also passed the length of the escape sequence through the parameter, 'len_esc_sequence'.
-*/
-
-{
-    float x,y;
-    int output;
-    int N;
-
-    N = -1;
-    y = (float)ABS(input);
-    x = y / 16;
-
-    while (x >= 1) {
-        N++;
-        x = x/2;
-    }
-
-    *len_esc_sequence = 2*N + 5;  /* the length of the escape sequence in bits */
-
-    output = (int)((pow(2,N) - 1)*pow(2,N+5) + y - pow(2,N+4));
-    return(output);
-}
-
-int OutputBits(CoderInfo *coderInfo,
-#ifdef DRM
-               int *book, /* we need to change book for VCB11 */
-#else
-               int book,
-#endif
-               int *quant,
-               int offset,
-               int length)
-{
-  /*
-     This function inputs
-     - a specific codebook number, 'book'
-     - the quantized spectral data, 'quant[][]'
-     - the offset into the spectral data to begin scanning, 'offset'
-     - the 'length' of the segment to huffman code
-     -> therefore, the segment quant[offset] to quant[offset+length-1]
-     is huffman coded.
-
-     This function outputs
-     - the number of bits required, 'bits'  using the prescribed codebook, book applied to
-     the given segment of spectral data.
-
-     There are three parameters that are passed back and forth into this function.  data[]
-     and len[] are one-dimensional arrays that store the codebook values and their respective
-     bit lengths.  These are used when packing the data for the bitstream in OutputBits().  The
-     index into these arrays is 'coderInfo->spectral_count''.  It gets incremented internally in this
-     function as counter, then passed to the outside through outside_counter.  The next time
-     OutputBits() is called, counter starts at the value it left off from the previous call.
-
-   */
-    int esc_sequence;
-    int len_esc;
-    int index;
-    int bits=0;
-    int tmp;
-    int codebook,i,j;
-    int counter;
-
-    /* Set up local pointers to coderInfo elements data and len */
-    int* data=      coderInfo->data;
-    int* len=       coderInfo->len;
-#ifdef DRM
-    int* num_data = coderInfo->num_data_cw;
-    int cur_cw_len;
-    int max_esc_sequ = 0;
-#endif
-
-    counter = coderInfo->spectral_count;
-
-#ifdef DRM
-    switch (*book) {
-#else
-    switch (book) {
-#endif
-    case 0:
-    case INTENSITY_HCB2:
-    case INTENSITY_HCB:
-#ifdef DRM
-        for(i=offset;i<offset+length;i=i+4){
-#endif
-        /* This case also applies to intensity stereo encoding */
-        coderInfo->data[counter] = 0;
-        coderInfo->len[counter++] = 0;
-        coderInfo->spectral_count = counter;  /* send the current count back to the outside world */
-
-#ifdef DRM
-        num_data[coderInfo->cur_cw++] = 1;
-        }
-#endif
-        return(bits);
-    case 1:
-        for(i=offset;i<offset+length;i=i+4){
-            index = 27*quant[i] + 9*quant[i+1] + 3*quant[i+2] + quant[i+3] + 40;
-            codebook = huff1[index][LASTINTAB];
-            tmp = huff1[index][FIRSTINTAB];
-            bits += tmp;
-            data[counter] = codebook;
-            len[counter++] = tmp;
-#ifdef DRM
-            num_data[coderInfo->cur_cw++] = 1;
-            coderInfo->iLenReordSpData += tmp;
-            if (tmp > coderInfo->iLenLongestCW)
-                coderInfo->iLenLongestCW = tmp;
-#endif
-        }
-        coderInfo->spectral_count = counter;  /* send the current count back to the outside world */
-        return(bits);
-    case 2:
-        for(i=offset;i<offset+length;i=i+4){
-            index = 27*quant[i] + 9*quant[i+1] + 3*quant[i+2] + quant[i+3] + 40;
-            codebook = huff2[index][LASTINTAB];
-            tmp = huff2[index][FIRSTINTAB];
-            bits += tmp;
-            data[counter] = codebook;
-            len[counter++] = tmp;
-#ifdef DRM
-            num_data[coderInfo->cur_cw++] = 1;
-            coderInfo->iLenReordSpData += tmp;
-            if (tmp > coderInfo->iLenLongestCW)
-                coderInfo->iLenLongestCW = tmp;
-#endif
-        }
-        coderInfo->spectral_count = counter;  /* send the current count back to the outside world */
-        return(bits);
-    case 3:
-        for(i=offset;i<offset+length;i=i+4){
-            index = 27*ABS(quant[i]) + 9*ABS(quant[i+1]) + 3*ABS(quant[i+2]) + ABS(quant[i+3]);
-            codebook = huff3[index][LASTINTAB];
-            tmp = huff3[index][FIRSTINTAB];
-            bits = bits + tmp;
-            data[counter] = codebook;
-            len[counter++] = tmp;
-#ifdef DRM
-            num_data[coderInfo->cur_cw] = 1;
-            cur_cw_len = tmp;
-#endif
-            for(j=0;j<4;j++){
-                if(quant[i+j] > 0) {  /* send out '0' if a positive value */
-                    data[counter] = 0;
-                    len[counter++] = 1;
-                    bits += 1;
-#ifdef DRM
-                    num_data[coderInfo->cur_cw]++;
-                    cur_cw_len += 1;
-#endif
-                } else
-                if(quant[i+j] < 0) {  /* send out '1' if a negative value */
-                    data[counter] = 1;
-                    len[counter++] = 1;
-                    bits += 1;
-#ifdef DRM
-                    num_data[coderInfo->cur_cw]++;
-                    cur_cw_len += 1;
-#endif
-                }
-            }
-#ifdef DRM
-            coderInfo->iLenReordSpData += cur_cw_len;
-            if (cur_cw_len > coderInfo->iLenLongestCW)
-                coderInfo->iLenLongestCW = cur_cw_len;
-
-            coderInfo->cur_cw++;
-#endif
-        }
-        coderInfo->spectral_count = counter;  /* send the current count back to the outside world */
-        return(bits);
-    case 4:
-        for(i=offset;i<offset+length;i=i+4){
-            index = 27*ABS(quant[i]) + 9*ABS(quant[i+1]) + 3*ABS(quant[i+2]) + ABS(quant[i+3]);
-            codebook = huff4[index][LASTINTAB];
-            tmp = huff4[index][FIRSTINTAB];
-            bits = bits + tmp;
-            data[counter] = codebook;
-            len[counter++] = tmp;
-#ifdef DRM
-            num_data[coderInfo->cur_cw] = 1;
-            cur_cw_len = tmp;
-#endif
-            for(j=0;j<4;j++){
-                if(quant[i+j] > 0) {  /* send out '0' if a positive value */
-                    data[counter] = 0;
-                    len[counter++] = 1;
-                    bits += 1;
-#ifdef DRM
-                    num_data[coderInfo->cur_cw]++;
-                    cur_cw_len += 1;
-#endif
-                } else
-                if(quant[i+j] < 0) {  /* send out '1' if a negative value */
-                    data[counter] = 1;
-                    len[counter++] = 1;
-                    bits += 1;
-#ifdef DRM
-                    num_data[coderInfo->cur_cw]++;
-                    cur_cw_len += 1;
-#endif
-                }
-            }
-#ifdef DRM
-            coderInfo->iLenReordSpData += cur_cw_len;
-            if (cur_cw_len > coderInfo->iLenLongestCW)
-                coderInfo->iLenLongestCW = cur_cw_len;
-
-            coderInfo->cur_cw++;
-#endif
-        }
-        coderInfo->spectral_count = counter;  /* send the current count back to the outside world */
-        return(bits);
-    case 5:
-        for(i=offset;i<offset+length;i=i+2){
-            index = 9*(quant[i]) + (quant[i+1]) + 40;
-            codebook = huff5[index][LASTINTAB];
-            tmp = huff5[index][FIRSTINTAB];
-            bits = bits + tmp;
-            data[counter] = codebook;
-            len[counter++] = tmp;
-#ifdef DRM
-            num_data[coderInfo->cur_cw++] = 1;
-            coderInfo->iLenReordSpData += tmp;
-            if (tmp > coderInfo->iLenLongestCW)
-                coderInfo->iLenLongestCW = tmp;
-#endif
-        }
-        coderInfo->spectral_count = counter;  /* send the current count back to the outside world */
-        return(bits);
-    case 6:
-        for(i=offset;i<offset+length;i=i+2){
-            index = 9*(quant[i]) + (quant[i+1]) + 40;
-            codebook = huff6[index][LASTINTAB];
-            tmp = huff6[index][FIRSTINTAB];
-            bits = bits + tmp;
-            data[counter] = codebook;
-            len[counter++] = tmp;
-#ifdef DRM
-            num_data[coderInfo->cur_cw++] = 1;
-            coderInfo->iLenReordSpData += tmp;
-            if (tmp > coderInfo->iLenLongestCW)
-                coderInfo->iLenLongestCW = tmp;
-#endif
-        }
-        coderInfo->spectral_count = counter;  /* send the current count back to the outside world */
-        return(bits);
-    case 7:
-        for(i=offset;i<offset+length;i=i+2){
-            index = 8*ABS(quant[i]) + ABS(quant[i+1]);
-            codebook = huff7[index][LASTINTAB];
-            tmp = huff7[index][FIRSTINTAB];
-            bits = bits + tmp;
-            data[counter] = codebook;
-            len[counter++] = tmp;
-#ifdef DRM
-            num_data[coderInfo->cur_cw] = 1;
-            cur_cw_len = tmp;
-#endif
-            for(j=0;j<2;j++){
-                if(quant[i+j] > 0) {  /* send out '0' if a positive value */
-                    data[counter] = 0;
-                    len[counter++] = 1;
-                    bits += 1;
-#ifdef DRM
-                    num_data[coderInfo->cur_cw]++;
-                    cur_cw_len += 1;
-#endif
-                } else
-                if(quant[i+j] < 0) {  /* send out '1' if a negative value */
-                    data[counter] = 1;
-                    len[counter++] = 1;
-                    bits += 1;
-#ifdef DRM
-                    num_data[coderInfo->cur_cw]++;
-                    cur_cw_len += 1;
-#endif
-                }
-            }
-#ifdef DRM
-            coderInfo->iLenReordSpData += cur_cw_len;
-            if (cur_cw_len > coderInfo->iLenLongestCW)
-                coderInfo->iLenLongestCW = cur_cw_len;
-
-            coderInfo->cur_cw++;
-#endif
-        }
-        coderInfo->spectral_count = counter;  /* send the current count back to the outside world */
-        return(bits);
-    case 8:
-        for(i=offset;i<offset+length;i=i+2){
-            index = 8*ABS(quant[i]) + ABS(quant[i+1]);
-            codebook = huff8[index][LASTINTAB];
-            tmp = huff8[index][FIRSTINTAB];
-            bits = bits + tmp;
-            data[counter] = codebook;
-            len[counter++] = tmp;
-#ifdef DRM
-            num_data[coderInfo->cur_cw] = 1;
-            cur_cw_len = tmp;
-#endif
-            for(j=0;j<2;j++){
-                if(quant[i+j] > 0) {  /* send out '0' if a positive value */
-                    data[counter] = 0;
-                    len[counter++] = 1;
-                    bits += 1;
-#ifdef DRM
-                    num_data[coderInfo->cur_cw]++;
-                    cur_cw_len += 1;
-#endif
-                } else
-                if(quant[i+j] < 0) {  /* send out '1' if a negative value */
-                    data[counter] = 1;
-                    len[counter++] = 1;
-                    bits += 1;
-#ifdef DRM
-                    num_data[coderInfo->cur_cw]++;
-                    cur_cw_len += 1;
-#endif
-                }
-            }
-#ifdef DRM
-            coderInfo->iLenReordSpData += cur_cw_len;
-            if (cur_cw_len > coderInfo->iLenLongestCW)
-                coderInfo->iLenLongestCW = cur_cw_len;
-
-            coderInfo->cur_cw++;
-#endif
-        }
-        coderInfo->spectral_count = counter;  /* send the current count back to the outside world */
-        return(bits);
-    case 9:
-        for(i=offset;i<offset+length;i=i+2){
-            index = 13*ABS(quant[i]) + ABS(quant[i+1]);
-            codebook = huff9[index][LASTINTAB];
-            tmp = huff9[index][FIRSTINTAB];
-            bits = bits + tmp;
-            data[counter] = codebook;
-            len[counter++] = tmp;
-#ifdef DRM
-            num_data[coderInfo->cur_cw] = 1;
-            cur_cw_len = tmp;
-#endif
-            for(j=0;j<2;j++){
-                if(quant[i+j] > 0) {  /* send out '0' if a positive value */
-                    data[counter] = 0;
-                    len[counter++] = 1;
-                    bits += 1;
-#ifdef DRM
-                    num_data[coderInfo->cur_cw]++;
-                    cur_cw_len += 1;
-#endif
-                } else
-                if(quant[i+j] < 0) {  /* send out '1' if a negative value */
-                    data[counter] = 1;
-                    len[counter++] = 1;
-                    bits += 1;
-#ifdef DRM
-                    num_data[coderInfo->cur_cw]++;
-                    cur_cw_len += 1;
-#endif
-                }
-            }
-#ifdef DRM
-            coderInfo->iLenReordSpData += cur_cw_len;
-            if (cur_cw_len > coderInfo->iLenLongestCW)
-                coderInfo->iLenLongestCW = cur_cw_len;
-
-            coderInfo->cur_cw++;
-#endif
-        }
-        coderInfo->spectral_count = counter;  /* send the current count back to the outside world */
-        return(bits);
-    case 10:
-        for(i=offset;i<offset+length;i=i+2){
-            index = 13*ABS(quant[i]) + ABS(quant[i+1]);
-            codebook = huff10[index][LASTINTAB];
-            tmp = huff10[index][FIRSTINTAB];
-            bits = bits + tmp;
-            data[counter] = codebook;
-            len[counter++] = tmp;
-#ifdef DRM
-            num_data[coderInfo->cur_cw] = 1;
-            cur_cw_len = tmp;
-#endif
-            for(j=0;j<2;j++){
-                if(quant[i+j] > 0) {  /* send out '0' if a positive value */
-                    data[counter] = 0;
-                    len[counter++] = 1;
-                    bits += 1;
-#ifdef DRM
-                    num_data[coderInfo->cur_cw]++;
-                    cur_cw_len += 1;
-#endif
-                } else
-                if(quant[i+j] < 0) {  /* send out '1' if a negative value */
-                    data[counter] = 1;
-                    len[counter++] = 1;
-                    bits += 1;
-#ifdef DRM
-                    num_data[coderInfo->cur_cw]++;
-                    cur_cw_len += 1;
-#endif
-                }
-            }
-#ifdef DRM
-            coderInfo->iLenReordSpData += cur_cw_len;
-            if (cur_cw_len > coderInfo->iLenLongestCW)
-                coderInfo->iLenLongestCW = cur_cw_len;
-
-            coderInfo->cur_cw++;
-#endif
-        }
-        coderInfo->spectral_count = counter;  /* send the current count back to the outside world */
-        return(bits);
-    case 11:
-        /* First, calculate the indecies into the huffman tables */
-        for(i=offset;i<offset+length;i=i+2){
-            if ((ABS(quant[i]) >= 16) && (ABS(quant[i+1]) >= 16)) {  /* both codewords were above 16 */
-                /* first, code the orignal pair, with the larger value saturated to +/- 16 */
-                index = 17*16 + 16;
-            }
-            else if (ABS(quant[i]) >= 16) {  /* the first codeword was above 16, not the second one */
-                /* first, code the orignal pair, with the larger value saturated to +/- 16 */
-                index = 17*16 + ABS(quant[i+1]);
-            }
-            else if (ABS(quant[i+1]) >= 16) { /* the second codeword was above 16, not the first one */
-                index = 17*ABS(quant[i]) + 16;
-            }
-            else {  /* there were no values above 16, so no escape sequences */
-                index = 17*ABS(quant[i]) + ABS(quant[i+1]);
-            }
-
-            /* write out the codewords */
-            tmp = huff11[index][FIRSTINTAB];
-            codebook = huff11[index][LASTINTAB];
-            bits += tmp;
-            data[counter] = codebook;
-            len[counter++] = tmp;
-#ifdef DRM
-            num_data[coderInfo->cur_cw] = 1;
-            cur_cw_len = tmp;
-#endif
-
-            /* Take care of the sign bits */
-            for(j=0;j<2;j++){
-                if(quant[i+j] > 0) {  /* send out '0' if a positive value */
-                    data[counter] = 0;
-                    len[counter++] = 1;
-                    bits += 1;
-#ifdef DRM
-                    num_data[coderInfo->cur_cw]++;
-                    cur_cw_len += 1;
-#endif
-                } else
-                if(quant[i+j] < 0) {  /* send out '1' if a negative value */
-                    data[counter] = 1;
-                    len[counter++] = 1;
-                    bits += 1;
-#ifdef DRM
-                    num_data[coderInfo->cur_cw]++;
-                    cur_cw_len += 1;
-#endif
-                }
-            }
-
-            /* write out the escape sequences */
-            if ((ABS(quant[i]) >= 16) && (ABS(quant[i+1]) >= 16)) {  /* both codewords were above 16 */
-                /* code and transmit the first escape_sequence */
-                esc_sequence = CalculateEscSequence(quant[i],&len_esc);
-                bits += len_esc;
-                data[counter] = esc_sequence;
-                len[counter++] = len_esc;
-#ifdef DRM
-                num_data[coderInfo->cur_cw]++;
-                cur_cw_len += len_esc;
-
-                if (esc_sequence > max_esc_sequ)
-                    max_esc_sequ = esc_sequence;
-#endif
-
-                /* then code and transmit the second escape_sequence */
-                esc_sequence = CalculateEscSequence(quant[i+1],&len_esc);
-                bits += len_esc;
-                data[counter] = esc_sequence;
-                len[counter++] = len_esc;
-#ifdef DRM
-                num_data[coderInfo->cur_cw]++;
-                cur_cw_len += len_esc;
-
-                if (esc_sequence > max_esc_sequ)
-                    max_esc_sequ = esc_sequence;
-#endif
-            }
-            else if (ABS(quant[i]) >= 16) {  /* the first codeword was above 16, not the second one */
-                /* code and transmit the escape_sequence */
-                esc_sequence = CalculateEscSequence(quant[i],&len_esc);
-                bits += len_esc;
-                data[counter] = esc_sequence;
-                len[counter++] = len_esc;
-#ifdef DRM
-                num_data[coderInfo->cur_cw]++;
-                cur_cw_len += len_esc;
-
-                if (esc_sequence > max_esc_sequ)
-                    max_esc_sequ = esc_sequence;
-#endif
-            }
-            else if (ABS(quant[i+1]) >= 16) { /* the second codeword was above 16, not the first one */
-                /* code and transmit the escape_sequence */
-                esc_sequence = CalculateEscSequence(quant[i+1],&len_esc);
-                bits += len_esc;
-                data[counter] = esc_sequence;
-                len[counter++] = len_esc;
-#ifdef DRM
-                num_data[coderInfo->cur_cw]++;
-                cur_cw_len += len_esc;
-
-                if (esc_sequence > max_esc_sequ)
-                    max_esc_sequ = esc_sequence;
-#endif
-            }
-#ifdef DRM
-            coderInfo->iLenReordSpData += cur_cw_len;
-            if (cur_cw_len > coderInfo->iLenLongestCW)
-                coderInfo->iLenLongestCW = cur_cw_len;
-
-            coderInfo->cur_cw++;
-#endif
-        }
-        coderInfo->spectral_count = counter;  /* send the current count back to the outside world */
-
-#ifdef DRM
-        /* VCB11: check which codebook should be used using max escape sequence */
-        /* 8.5.3.1.3, table 157 */
-        if (max_esc_sequ <= 15)
-            *book = 16;
-        else if (max_esc_sequ <= 31)
-            *book = 17;
-        else if (max_esc_sequ <= 47)
-            *book = 18;
-        else if (max_esc_sequ <= 63)
-            *book = 19;
-        else if (max_esc_sequ <= 95)
-            *book = 20;
-        else if (max_esc_sequ <= 127)
-            *book = 21;
-        else if (max_esc_sequ <= 159)
-            *book = 22;
-        else if (max_esc_sequ <= 191)
-            *book = 23;
-        else if (max_esc_sequ <= 223)
-            *book = 24;
-        else if (max_esc_sequ <= 255)
-            *book = 25;
-        else if (max_esc_sequ <= 319)
-            *book = 26;
-        else if (max_esc_sequ <= 383)
-            *book = 27;
-        else if (max_esc_sequ <= 511)
-            *book = 28;
-        else if (max_esc_sequ <= 767)
-            *book = 29;
-        else if (max_esc_sequ <= 1023)
-            *book = 30;
-        else if (max_esc_sequ <= 2047)
-            *book = 31;
-        /* else: codebook 11 -> it is already 11 */
-#endif
-
-        return(bits);
-    }
-    return 0;
-}
-
-int CalcBits(CoderInfo *coderInfo,
-             int book,
-             int *quant,
-             int offset,
-             int length)
-{
-  /*
-     This function inputs
-     - a specific codebook number, 'book'
-     - the quantized spectral data, 'quant[]'
-     - the offset into the spectral data to begin scanning, 'offset'
-     - the 'length' of the segment to huffman code
-     -> therefore, the segment quant[offset] to quant[offset+length-1]
-     is huffman coded.
-
-     This function outputs
-     - the number of bits required, 'bits'  using the prescribed codebook, book applied to
-     the given segment of spectral data.
-
-   */
-
-    int len_esc;
-    int index;
-    int bits = 0;
-    int i, j;
-
-    switch (book) {
-    case 1:
-        for(i=offset;i<offset+length;i=i+4){
-            index = 27*quant[i] + 9*quant[i+1] + 3*quant[i+2] + quant[i+3] + 40;
-            bits += huff1[index][FIRSTINTAB];
-        }
-        return (bits);
-    case 2:
-        for(i=offset;i<offset+length;i=i+4){
-            index = 27*quant[i] + 9*quant[i+1] + 3*quant[i+2] + quant[i+3] + 40;
-            bits += huff2[index][FIRSTINTAB];
-        }
-        return (bits);
-    case 3:
-        for(i=offset;i<offset+length;i=i+4){
-            index = 27*ABS(quant[i]) + 9*ABS(quant[i+1]) + 3*ABS(quant[i+2]) + ABS(quant[i+3]);
-            bits += huff3[index][FIRSTINTAB];
-            for(j=0;j<4;j++){
-                if(quant[i+j] != 0) bits += 1; /* only for non-zero spectral coefficients */
-            }
-        }
-        return (bits);
-    case 4:
-        for(i=offset;i<offset+length;i=i+4){
-            index = 27*ABS(quant[i]) + 9*ABS(quant[i+1]) + 3*ABS(quant[i+2]) + ABS(quant[i+3]);
-            bits += huff4[index][FIRSTINTAB];
-            for(j=0;j<4;j++){
-                if(quant[i+j] != 0) bits += 1; /* only for non-zero spectral coefficients */
-            }
-        }
-        return (bits);
-    case 5:
-        for(i=offset;i<offset+length;i=i+2){
-            index = 9*(quant[i]) + (quant[i+1]) + 40;
-            bits += huff5[index][FIRSTINTAB];
-        }
-        return (bits);
-    case 6:
-        for(i=offset;i<offset+length;i=i+2){
-            index = 9*(quant[i]) + (quant[i+1]) + 40;
-            bits += huff6[index][FIRSTINTAB];
-        }
-        return (bits);
-    case 7:
-        for(i=offset;i<offset+length;i=i+2){
-            index = 8*ABS(quant[i]) + ABS(quant[i+1]);
-            bits += huff7[index][FIRSTINTAB];
-            for(j=0;j<2;j++){
-                if(quant[i+j] != 0) bits += 1; /* only for non-zero spectral coefficients */
-            }
-        }
-        return (bits);
-    case 8:
-        for(i=offset;i<offset+length;i=i+2){
-            index = 8*ABS(quant[i]) + ABS(quant[i+1]);
-            bits += huff8[index][FIRSTINTAB];
-            for(j=0;j<2;j++){
-                if(quant[i+j] != 0) bits += 1; /* only for non-zero spectral coefficients */
-            }
-        }
-        return (bits);
-    case 9:
-        for(i=offset;i<offset+length;i=i+2){
-            index = 13*ABS(quant[i]) + ABS(quant[i+1]);
-            bits += huff9[index][FIRSTINTAB];
-            for(j=0;j<2;j++){
-                if(quant[i+j] != 0) bits += 1; /* only for non-zero spectral coefficients */
-            }
-        }
-        return (bits);
-    case 10:
-        for(i=offset;i<offset+length;i=i+2){
-            index = 13*ABS(quant[i]) + ABS(quant[i+1]);
-            bits += huff10[index][FIRSTINTAB];
-            for(j=0;j<2;j++){
-                if(quant[i+j] != 0) bits += 1; /* only for non-zero spectral coefficients */
-            }
-        }
-        return (bits);
-    case 11:
-        /* First, calculate the indecies into the huffman tables */
-        for(i=offset;i<offset+length;i=i+2){
-            if ((ABS(quant[i]) >= 16) && (ABS(quant[i+1]) >= 16)) {  /* both codewords were above 16 */
-                /* first, code the orignal pair, with the larger value saturated to +/- 16 */
-                index = 17*16 + 16;
-            } else if (ABS(quant[i]) >= 16) {  /* the first codeword was above 16, not the second one */
-                /* first, code the orignal pair, with the larger value saturated to +/- 16 */
-                index = 17*16 + ABS(quant[i+1]);
-            } else if (ABS(quant[i+1]) >= 16) { /* the second codeword was above 16, not the first one */
-                index = 17*ABS(quant[i]) + 16;
-            } else {  /* there were no values above 16, so no escape sequences */
-                index = 17*ABS(quant[i]) + ABS(quant[i+1]);
-            }
-
-            /* write out the codewords */
-            bits += huff11[index][FIRSTINTAB];
-
-            /* Take care of the sign bits */
-            for(j=0;j<2;j++){
-                if(quant[i+j] != 0) bits += 1; /* only for non-zero spectral coefficients */
-            }
-
-            /* write out the escape sequences */
-            if ((ABS(quant[i]) >= 16) && (ABS(quant[i+1]) >= 16)) {  /* both codewords were above 16 */
-                /* code and transmit the first escape_sequence */
-                CalculateEscSequence(quant[i],&len_esc);
-                bits += len_esc;
-
-                /* then code and transmit the second escape_sequence */
-                CalculateEscSequence(quant[i+1],&len_esc);
-                bits += len_esc;
-            } else if (ABS(quant[i]) >= 16) {  /* the first codeword was above 16, not the second one */
-                /* code and transmit the escape_sequence */
-                CalculateEscSequence(quant[i],&len_esc);
-                bits += len_esc;
-            } else if (ABS(quant[i+1]) >= 16) { /* the second codeword was above 16, not the first one */
-                /* code and transmit the escape_sequence */
-                CalculateEscSequence(quant[i+1],&len_esc);
-                bits += len_esc;
-            }
-        }
-        return (bits);
-    }
-    return 0;
-}
-
-int SortBookNumbers(CoderInfo *coderInfo,
-                    BitStream *bitStream,
-                    int writeFlag)
-{
-  /*
-    This function inputs the vector, 'book_vector[]', which is of length MAX_SCFAC_BANDS,
-    and contains the optimal huffman tables of each sfb.  It returns the vector, 'output_book_vector[]', which
-    has it's elements formatted for the encoded bit stream.  It's syntax is:
-
-    {sect_cb[0], length_segment[0], ... ,sect_cb[num_of_sections], length_segment[num_of_sections]}
-
-    The above syntax is true, unless there is an escape sequence.  An
-    escape sequence occurs when a section is longer than 2 ^ (bit_len)
-    long in units of scalefactor bands.  Also, the integer returned from
-    this function is the number of bits written in the bitstream,
-    'bit_count'.
-
-    This function supports both long and short blocks.
-    */
-
-    int i;
-    int repeat_counter;
-    int bit_count = 0;
-    int previous;
-    int max, bit_len/*,sfbs*/;
-    int g,band;
-    int sect_cb_bits = 4;
-
-    /* Set local pointers to coderInfo elements */
-    int* book_vector = coderInfo->book_vector;
-
-#ifdef DRM
-    sect_cb_bits = 5; /* 5 bits in case of VCB11 */
-#endif
-
-    if (coderInfo->block_type == ONLY_SHORT_WINDOW){
-        max = 7;
-        bit_len = 3;
-    } else {  /* the block_type is a long,start, or stop window */
-        max = 31;
-        bit_len = 5;
-    }
-
-    for (g = 0; g < coderInfo->groups.n; g++) {
-        band = g * coderInfo->sfbn;
-
-        repeat_counter=1;
-
-        previous = book_vector[band];
-        if (writeFlag) {
-            PutBit(bitStream,book_vector[band],sect_cb_bits);
-        }
-        bit_count += sect_cb_bits;
-
-        for (i = band + 1; i < (band + coderInfo->sfbn); i++) {
-#ifdef DRM
-            /* sect_len is not transmitted in case the codebook for a */
-            /* section is 11 or in the range of 16 and 31 */
-            if ((previous == 11) ||
-                ((previous >= 16) && (previous <= 32)))
-            {
-                if (writeFlag)
-                    PutBit(bitStream,book_vector[i],sect_cb_bits);
-                bit_count += sect_cb_bits;
-                previous = book_vector[i];
-                repeat_counter=1;
-
-            } else
-#endif
-            if( (book_vector[i] != previous)) {
-                if (writeFlag) {
-                    PutBit(bitStream,repeat_counter,bit_len);
-                }
-                bit_count += bit_len;
-
-                if (repeat_counter == max){  /* in case you need to terminate an escape sequence */
-                    if (writeFlag)
-                        PutBit(bitStream,0,bit_len);
-                    bit_count += bit_len;
-                }
-
-                if (writeFlag)
-                    PutBit(bitStream,book_vector[i],sect_cb_bits);
-                bit_count += sect_cb_bits;
-                previous = book_vector[i];
-                repeat_counter=1;
-            }
-            /* if the length of the section is longer than the amount of bits available in */
-            /* the bitsream, "max", then start up an escape sequence */
-            else if ((book_vector[i] == previous) && (repeat_counter == max)) {
-                if (writeFlag) {
-                    PutBit(bitStream,repeat_counter,bit_len);
-                }
-                bit_count += bit_len;
-                repeat_counter = 1;
-            }
-            else {
-                repeat_counter++;
-            }
-        }
-
-#ifdef DRM
-        if (!((previous == 11) || ((previous >= 16) && (previous <= 32))))
-#endif
-        {
-            if (writeFlag)
-                PutBit(bitStream,repeat_counter,bit_len);
-            bit_count += bit_len;
-
-            if (repeat_counter == max) {  /* special case if the last section length is an */
-                /* escape sequence */
-                if (writeFlag)
-                    PutBit(bitStream,0,bit_len);
-                bit_count += bit_len;
-            }
-        }
-    }  /* Bottom of group iteration */
-
-    return bit_count;
-}
-
-int WriteScalefactors(CoderInfo *coderInfo,
-                      BitStream *bitStream,
-                      int writeFlag)
-
-{
-    /* this function takes care of counting the number of bits necessary */
-    /* to encode the scalefactors.  In addition, if the writeFlag == 1, */
-    /* then the scalefactors are written out the bitStream output bit */
-    /* stream.  it returns k, the number of bits written to the bitstream*/
-
-    int i,j,bit_count=0;
-    int diff,length,codeword;
-    int previous_scale_factor;
-    int previous_is_factor;       /* Intensity stereo */
-    int index = 0;
-    int nr_of_sfb_per_group;
-
-    /* set local pointer to coderInfo elements */
-    int* scale_factors = coderInfo->scale_factor;
-
-    if (coderInfo->block_type == ONLY_SHORT_WINDOW) { /* short windows */
-        nr_of_sfb_per_group = coderInfo->sfbn;
-    } else {
-        nr_of_sfb_per_group = coderInfo->sfbn;
-        coderInfo->groups.n = 1;
-        coderInfo->groups.len[0] = 1;
-    }
-
-    previous_scale_factor = coderInfo->global_gain;
-    previous_is_factor = 0;
-
-    for(j=0; j<coderInfo->groups.n; j++){
-        for(i=0;i<nr_of_sfb_per_group;i++) {
-            /* test to see if any codebooks in a group are zero */
-            if ( (coderInfo->book_vector[index]==INTENSITY_HCB) ||
-                (coderInfo->book_vector[index]==INTENSITY_HCB2) ) {
-                /* only send scalefactors if using non-zero codebooks */
-                diff = scale_factors[index] - previous_is_factor;
-                if ((diff <= 60)&&(diff >= -60))
-				{
-					length = huff12[diff+60][FIRSTINTAB];
-				}
-                else if ( diff > 60 ) // frank 30.Oct.2007 added this because faad2 decoder and QuickTime choke when nothing is written and the codebook says a number is expected.
-				{
-					diff = 60;
-					length = huff12[120][FIRSTINTAB]; //max
-				}
-                else 
-				{
-					diff = -60;
-					length = huff12[0][FIRSTINTAB]; // min
-				}
-                bit_count+=length;
-                previous_is_factor += diff;
-                if (writeFlag == 1 ) {
-                    codeword = huff12[diff+60][LASTINTAB];
-                    PutBit(bitStream,codeword,length);
-                }
-            } else if (coderInfo->book_vector[index]) {
-                /* only send scalefactors if using non-zero codebooks */
-                diff = scale_factors[index] - previous_scale_factor;
-                if ((diff <= 60)&&(diff >= -60))
-				{
-					length = huff12[diff+60][FIRSTINTAB];
-				}
-                else if ( diff > 60 ) // frank 30.Oct.2007 added this because faad2 decoder and QuickTime choke when nothing is written and the codebook says a number is expected.
-				{
-					diff = 60;
-					length = huff12[120][FIRSTINTAB]; //max
-				}
-                else 
-				{
-					diff = -60;
-					length = huff12[0][FIRSTINTAB]; //min
-				}
-                bit_count+=length;
-                previous_scale_factor += diff;
-                if (writeFlag == 1 ) {
-                    codeword = huff12[diff+60][LASTINTAB];
-                    PutBit(bitStream,codeword,length);
-                }
-            }
-            index++;
-        }
-    }
-    return bit_count;
-}
-
--- a/libfaac/huffman.h
+++ /dev/null
@@ -1,91 +1,0 @@
-/***********
-
-This software module was originally developed by Dolby
-Laboratories in the course of development of the MPEG-2 AAC/MPEG-4
-Audio standard ISO/IEC13818-7, 14496-1, 2 and 3. This software module is an implementation of a part
-of one or more MPEG-2 AAC/MPEG-4 Audio tools as specified by the
-MPEG-2 aac/MPEG-4 Audio standard. ISO/IEC  gives users of the
-MPEG-2aac/MPEG-4 Audio standards free license to this software module
-or modifications thereof for use in hardware or software products
-claiming conformance to the MPEG-2 aac/MPEG-4 Audio  standards. Those
-intending to use this software module in hardware or software products
-are advised that this use may infringe existing patents. The original
-developer of this software module, the subsequent
-editors and their companies, and ISO/IEC have no liability for use of
-this software module or modifications thereof in an
-implementation. Copyright is not released for non MPEG-2 aac/MPEG-4
-Audio conforming products. The original developer retains full right to
-use the code for the developer's own purpose, assign or donate the code to a
-third party and to inhibit third party from using the code for non
-MPEG-2 aac/MPEG-4 Audio conforming products. This copyright notice
-must be included in all copies or derivative works. Copyright 1996.
-
-***********/
-/*
- * $Id: huffman.h,v 1.7 2012/03/01 18:34:17 knik Exp $
- */
-
-#ifndef HUFFMAN_H
-#define HUFFMAN_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-#include "bitstream.h"
-#include "coder.h"
-
-/* Huffman tables */
-#define MAXINDEX 289
-#define NUMINTAB 2
-#define FIRSTINTAB 0
-#define LASTINTAB 1
-
-#define INTENSITY_HCB 15
-#define INTENSITY_HCB2 14
-
-
-#define ABS(A) ((A) < 0 ? (-A) : (A))
-
-#include <faac.h>
-
-void HuffmanInit(CoderInfo *coderInfo, unsigned int numChannels);
-void HuffmanEnd(CoderInfo *coderInfo, unsigned int numChannels);
-
-int BitSearch(CoderInfo *coderInfo,
-              int *quant);
-
-int NoiselessBitCount(CoderInfo *coderInfo,
-                      int *quant,
-                      int hop,
-                      int min_book_choice[112][3]);
-
-int CalcBits(CoderInfo *coderInfo,
-             int book,
-             int *quant,
-             int offset,
-             int length);
-
-int OutputBits(CoderInfo *coderInfo,
-#ifdef DRM
-               int *book, /* we need to change book for VCB11 */
-#else
-               int book,
-#endif
-               int *quant,
-               int offset,
-               int length);
-
-int SortBookNumbers(CoderInfo *coderInfo,
-                    BitStream *bitStream,
-                    int writeFlag);
-
-int WriteScalefactors(CoderInfo *coderInfo,
-                      BitStream *bitStream,
-                      int writeFlag);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* HUFFMAN_H */
--- a/libfaac/hufftab.h
+++ /dev/null
@@ -1,331 +1,0 @@
-/*
- * FAAC - Freeware Advanced Audio Coder
- * Copyright (C) 2001 Menno Bakker
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * $Id: hufftab.h,v 1.3 2001/06/08 18:01:09 menno Exp $
- */
-
-unsigned short huff1[][2] = {
-        { 11,  2040},
-        { 9,  497},{ 11,  2045},{ 10,  1013},{ 7,  104},{ 10,  1008},
-        { 11,  2039},{ 9,  492},{ 11,  2037},{ 10,  1009},{ 7,  114},
-        { 10,  1012},{ 7,  116},{ 5,  17},{ 7,  118},{ 9,  491},
-        { 7,  108},{ 10,  1014},{ 11,  2044},{ 9,  481},{ 11,  2033},
-        { 9,  496},{ 7,  97},{ 9,  502},{ 11,  2034},{ 9,  490},
-        { 11,  2043},{ 9,  498},{ 7,  105},{ 9,  493},{ 7,  119},
-        { 5,  23},{ 7,  111},{ 9,  486},{ 7,  100},{ 9,  485},
-        { 7,  103},{ 5,  21},{ 7,  98},{ 5,  18},{ 1,  0},
-        { 5,  20},{ 7,  101},{ 5,  22},{ 7,  109},{ 9,  489},
-        { 7,  99},{ 9,  484},{ 7,  107},{ 5,  19},{ 7,  113},
-        { 9,  483},{ 7,  112},{ 9,  499},{ 11,  2046},{ 9,  487},
-        { 11,  2035},{ 9,  495},{ 7,  96},{ 9,  494},{ 11,  2032},
-        { 9,  482},{ 11,  2042},{ 10,  1011},{ 7,  106},{ 9,  488},
-        { 7,  117},{ 5,  16},{ 7,  115},{ 9,  500},{ 7,  110},
-        { 10,  1015},{ 11,  2038},{ 9,  480},{ 11,  2041},{ 10,  1010},
-        { 7,  102},{ 9,  501},{ 11,  2047},{ 9,  503},{ 11,  2036}
-    };
-unsigned short huff2[][2] = {
-    { 9,  499},
-        { 7,  111},{ 9,  509},{ 8,  235},{ 6,  35},{ 8,  234},
-        { 9,  503},{ 8,  232},{ 9,  506},{ 8,  242},{ 6,  45},
-        { 7,  112},{ 6,  32},{ 5,  6},{ 6,  43},{ 7,  110},
-        { 6,  40},{ 8,  233},{ 9,  505},{ 7,  102},{ 8,  248},
-        { 8,  231},{ 6,  27},{ 8,  241},{ 9,  500},{ 7,  107},
-        { 9,  501},{ 8,  236},{ 6,  42},{ 7,  108},{ 6,  44},
-        { 5,  10},{ 6,  39},{ 7,  103},{ 6,  26},{ 8,  245},
-        { 6,  36},{ 5,  8},{ 6,  31},{ 5,  9},{ 3,  0},
-        { 5,  7},{ 6,  29},{ 5,  11},{ 6,  48},{ 8,  239},
-        { 6,  28},{ 7,  100},{ 6,  30},{ 5,  12},{ 6,  41},
-        { 8,  243},{ 6,  47},{ 8,  240},{ 9,  508},{ 7,  113},
-        { 9,  498},{ 8,  244},{ 6,  33},{ 8,  230},{ 8,  247},
-        { 7,  104},{ 9,  504},{ 8,  238},{ 6,  34},{ 7,  101},
-        { 6,  49},{ 4,  2},{ 6,  38},{ 8,  237},{ 6,  37},
-        { 7,  106},{ 9,  507},{ 7,  114},{ 9,  510},{ 7,  105},
-        { 6,  46},{ 8,  246},{ 9,  511},{ 7,  109},{ 9,  502}
-    };
-unsigned short huff3[][2] = {
-        { 1,  0},
-        { 4,  9},{ 8,  239},{ 4,  11},{ 5,  25},{ 8,  240},
-        { 9,  491},{ 9,  486},{ 10,  1010},{ 4,  10},{ 6,  53},
-        { 9,  495},{ 6,  52},{ 6,  55},{ 9,  489},{ 9,  493},
-        { 9,  487},{ 10,  1011},{ 9,  494},{ 10,  1005},{ 13,  8186},
-        { 9,  492},{ 9,  498},{ 11,  2041},{ 11,  2040},{ 10,  1016},
-        { 12,  4088},{ 4,  8},{ 6,  56},{ 10,  1014},{ 6,  54},
-        { 7,  117},{ 10,  1009},{ 10,  1003},{ 10,  1004},{ 12,  4084},
-        { 5,  24},{ 7,  118},{ 11,  2036},{ 6,  57},{ 7,  116},
-        { 10,  1007},{ 9,  499},{ 9,  500},{ 11,  2038},{ 9,  488},
-        { 10,  1002},{ 13,  8188},{ 8,  242},{ 9,  497},{ 12,  4091},
-        { 10,  1013},{ 11,  2035},{ 12,  4092},{ 8,  238},{ 10,  1015},
-        { 15,  32766},{ 9,  496},{ 11,  2037},{ 15,  32765},{ 13,  8187},
-        { 14,  16378},{ 16,  65535},{ 8,  241},{ 10,  1008},{ 14,  16380},
-        { 9,  490},{ 10,  1006},{ 14,  16379},{ 12,  4086},{ 12,  4090},
-        { 15,  32764},{ 11,  2034},{ 12,  4085},{ 16,  65534},{ 10,  1012},
-        { 11,  2039},{ 15,  32763},{ 12,  4087},{ 12,  4089},{ 15,  32762}
-    };
-unsigned short huff4[][2] = {
-        { 4,  7},
-        { 5,  22},{ 8,  246},{ 5,  24},{ 4,  8},{ 8,  239},
-        { 9,  495},{ 8,  243},{ 11,  2040},{ 5,  25},{ 5,  23},
-        { 8,  237},{ 5,  21},{ 4,  1},{ 8,  226},{ 8,  240},
-        { 7,  112},{ 10,  1008},{ 9,  494},{ 8,  241},{ 11,  2042},
-        { 8,  238},{ 8,  228},{ 10,  1010},{ 11,  2038},{ 10,  1007},
-        { 11,  2045},{ 4,  5},{ 5,  20},{ 8,  242},{ 4,  9},
-        { 4,  4},{ 8,  229},{ 8,  244},{ 8,  232},{ 10,  1012},
-        { 4,  6},{ 4,  2},{ 8,  231},{ 4,  3},{ 4,  0},
-        { 7,  107},{ 8,  227},{ 7,  105},{ 9,  499},{ 8,  235},
-        { 8,  230},{ 10,  1014},{ 7,  110},{ 7,  106},{ 9,  500},
-        { 10,  1004},{ 9,  496},{ 10,  1017},{ 8,  245},{ 8,  236},
-        { 11,  2043},{ 8,  234},{ 7,  111},{ 10,  1015},{ 11,  2041},
-        { 10,  1011},{ 12,  4095},{ 8,  233},{ 7,  109},{ 10,  1016},
-        { 7,  108},{ 7,  104},{ 9,  501},{ 10,  1006},{ 9,  498},
-        { 11,  2036},{ 11,  2039},{ 10,  1009},{ 12,  4094},{ 10,  1005},
-        { 9,  497},{ 11,  2037},{ 11,  2046},{ 10,  1013},{ 11,  2044}
-    };
-unsigned short huff5[][2] = {
-        { 13,  8191},
-        { 12,  4087},{ 11,  2036},{ 11,  2024},{ 10,  1009},{ 11,  2030},
-        { 11,  2041},{ 12,  4088},{ 13,  8189},{ 12,  4093},{ 11,  2033},
-        { 10,  1000},{ 9,  488},{ 8,  240},{ 9,  492},{ 10,  1006},
-        { 11,  2034},{ 12,  4090},{ 12,  4084},{ 10,  1007},{ 9,  498},
-        { 8,  232},{ 7,  112},{ 8,  236},{ 9,  496},{ 10,  1002},
-        { 11,  2035},{ 11,  2027},{ 9,  491},{ 8,  234},{ 5,  26},
-        { 4,  8},{ 5,  25},{ 8,  238},{ 9,  495},{ 11,  2029},
-        { 10,  1008},{ 8,  242},{ 7,  115},{ 4,  11},{ 1,  0},
-        { 4,  10},{ 7,  113},{ 8,  243},{ 11,  2025},{ 11,  2031},
-        { 9,  494},{ 8,  239},{ 5,  24},{ 4,  9},{ 5,  27},
-        { 8,  235},{ 9,  489},{ 11,  2028},{ 11,  2038},{ 10,  1003},
-        { 9,  499},{ 8,  237},{ 7,  114},{ 8,  233},{ 9,  497},
-        { 10,  1005},{ 11,  2039},{ 12,  4086},{ 11,  2032},{ 10,  1001},
-        { 9,  493},{ 8,  241},{ 9,  490},{ 10,  1004},{ 11,  2040},
-        { 12,  4089},{ 13,  8188},{ 12,  4092},{ 12,  4085},{ 11,  2026},
-        { 10,  1011},{ 10,  1010},{ 11,  2037},{ 12,  4091},{ 13,  8190}
-    };
-unsigned short huff6[][2] = {
-        { 11,  2046},
-        { 10,  1021},{ 9,  497},{ 9,  491},{ 9,  500},{ 9,  490},
-        { 9,  496},{ 10,  1020},{ 11,  2045},{ 10,  1014},{ 9,  485},
-        { 8,  234},{ 7,  108},{ 7,  113},{ 7,  104},{ 8,  240},
-        { 9,  486},{ 10,  1015},{ 9,  499},{ 8,  239},{ 6,  50},
-        { 6,  39},{ 6,  40},{ 6,  38},{ 6,  49},{ 8,  235},
-        { 9,  503},{ 9,  488},{ 7,  111},{ 6,  46},{ 4,  8},
-        { 4,  4},{ 4,  6},{ 6,  41},{ 7,  107},{ 9,  494},
-        { 9,  495},{ 7,  114},{ 6,  45},{ 4,  2},{ 4,  0},
-        { 4,  3},{ 6,  47},{ 7,  115},{ 9,  506},{ 9,  487},
-        { 7,  110},{ 6,  43},{ 4,  7},{ 4,  1},{ 4,  5},
-        { 6,  44},{ 7,  109},{ 9,  492},{ 9,  505},{ 8,  238},
-        { 6,  48},{ 6,  36},{ 6,  42},{ 6,  37},{ 6,  51},
-        { 8,  236},{ 9,  498},{ 10,  1016},{ 9,  484},{ 8,  237},
-        { 7,  106},{ 7,  112},{ 7,  105},{ 7,  116},{ 8,  241},
-        { 10,  1018},{ 11,  2047},{ 10,  1017},{ 9,  502},{ 9,  493},
-        { 9,  504},{ 9,  489},{ 9,  501},{ 10,  1019},{ 11,  2044}
-    };
-unsigned short huff7[][2] = {
-        { 1,  0},
-        { 3,  5},{ 6,  55},{ 7,  116},{ 8,  242},{ 9,  491},
-        { 10,  1005},{ 11,  2039},{ 3,  4},{ 4,  12},{ 6,  53},
-        { 7,  113},{ 8,  236},{ 8,  238},{ 9,  494},{ 9,  501},
-        { 6,  54},{ 6,  52},{ 7,  114},{ 8,  234},{ 8,  241},
-        { 9,  489},{ 9,  499},{ 10,  1013},{ 7,  115},{ 7,  112},
-        { 8,  235},{ 8,  240},{ 9,  497},{ 9,  496},{ 10,  1004},
-        { 10,  1018},{ 8,  243},{ 8,  237},{ 9,  488},{ 9,  495},
-        { 10,  1007},{ 10,  1009},{ 10,  1017},{ 11,  2043},{ 9,  493},
-        { 8,  239},{ 9,  490},{ 9,  498},{ 10,  1011},{ 10,  1016},
-        { 11,  2041},{ 11,  2044},{ 10,  1006},{ 9,  492},{ 9,  500},
-        { 10,  1012},{ 10,  1015},{ 11,  2040},{ 12,  4093},{ 12,  4094},
-        { 11,  2038},{ 10,  1008},{ 10,  1010},{ 10,  1014},{ 11,  2042},
-        { 11,  2045},{ 12,  4092},{ 12,  4095}
-    };
-unsigned short huff8[][2] = {
-        { 5,  14},
-        { 4,  5},{ 5,  16},{ 6,  48},{ 7,  111},{ 8,  241},
-        { 9,  506},{ 10,  1022},{ 4,  3},{ 3,  0},{ 4,  4},
-        { 5,  18},{ 6,  44},{ 7,  106},{ 7,  117},{ 8,  248},
-        { 5,  15},{ 4,  2},{ 4,  6},{ 5,  20},{ 6,  46},
-        { 7,  105},{ 7,  114},{ 8,  245},{ 6,  47},{ 5,  17},
-        { 5,  19},{ 6,  42},{ 6,  50},{ 7,  108},{ 8,  236},
-        { 8,  250},{ 7,  113},{ 6,  43},{ 6,  45},{ 6,  49},
-        { 7,  109},{ 7,  112},{ 8,  242},{ 9,  505},{ 8,  239},
-        { 7,  104},{ 6,  51},{ 7,  107},{ 7,  110},{ 8,  238},
-        { 8,  249},{ 10,  1020},{ 9,  504},{ 7,  116},{ 7,  115},
-        { 8,  237},{ 8,  240},{ 8,  246},{ 9,  502},{ 9,  509},
-        { 10,  1021},{ 8,  243},{ 8,  244},{ 8,  247},{ 9,  503},
-        { 9,  507},{ 9,  508},{ 10,  1023}
-    };
-unsigned short huff9[][2] = {
-        { 1,  0},
-        { 3,  5},{ 6,  55},{ 8,  231},{ 9,  478},{ 10,  974},
-        { 10,  985},{ 11,  1992},{ 11,  1997},{ 12,  4040},{ 12,  4061},
-        { 13,  8164},{ 13,  8172},{ 3,  4},{ 4,  12},{ 6,  53},
-        { 7,  114},{ 8,  234},{ 8,  237},{ 9,  482},{ 10,  977},
-        { 10,  979},{ 10,  992},{ 11,  2008},{ 12,  4047},{ 12,  4053},
-        { 6,  54},{ 6,  52},{ 7,  113},{ 8,  232},{ 8,  236},
-        { 9,  481},{ 10,  975},{ 10,  989},{ 10,  987},{ 11,  2000},
-        { 12,  4039},{ 12,  4052},{ 12,  4068},{ 8,  230},{ 7,  112},
-        { 8,  233},{ 9,  477},{ 9,  483},{ 10,  978},{ 10,  988},
-        { 11,  1996},{ 11,  1994},{ 11,  2014},{ 12,  4056},{ 12,  4074},
-        { 13,  8155},{ 9,  479},{ 8,  235},{ 9,  476},{ 9,  486},
-        { 10,  981},{ 10,  990},{ 11,  1995},{ 11,  2013},{ 11,  2012},
-        { 12,  4045},{ 12,  4066},{ 12,  4071},{ 13,  8161},{ 10,  976},
-        { 9,  480},{ 9,  484},{ 10,  982},{ 11,  1989},{ 11,  2001},
-        { 11,  2011},{ 12,  4050},{ 11,  2016},{ 12,  4057},{ 12,  4075},
-        { 13,  8163},{ 13,  8169},{ 11,  1988},{ 9,  485},{ 10,  983},
-        { 11,  1990},{ 11,  1999},{ 11,  2010},{ 12,  4043},{ 12,  4058},
-        { 12,  4067},{ 12,  4073},{ 13,  8166},{ 13,  8179},{ 13,  8183},
-        { 11,  2003},{ 10,  984},{ 10,  993},{ 11,  2004},{ 11,  2009},
-        { 12,  4051},{ 12,  4062},{ 13,  8157},{ 13,  8153},{ 13,  8162},
-        { 13,  8170},{ 13,  8177},{ 13,  8182},{ 11,  2002},{ 10,  980},
-        { 10,  986},{ 11,  1991},{ 11,  2007},{ 11,  2018},{ 12,  4046},
-        { 12,  4059},{ 13,  8152},{ 13,  8174},{ 14,  16368},{ 13,  8180},
-        { 14,  16370},{ 11,  2017},{ 10,  991},{ 11,  1993},{ 11,  2006},
-        { 12,  4042},{ 12,  4048},{ 12,  4069},{ 12,  4070},{ 13,  8171},
-        { 13,  8175},{ 14,  16371},{ 14,  16372},{ 14,  16373},{ 12,  4064},
-        { 11,  1998},{ 11,  2005},{ 12,  4038},{ 12,  4049},{ 12,  4065},
-        { 13,  8160},{ 13,  8168},{ 13,  8176},{ 14,  16369},{ 14,  16376},
-        { 14,  16374},{ 15,  32764},{ 12,  4072},{ 11,  2015},{ 12,  4041},
-        { 12,  4055},{ 12,  4060},{ 13,  8156},{ 13,  8159},{ 13,  8173},
-        { 13,  8181},{ 14,  16377},{ 14,  16379},{ 15,  32765},{ 15,  32766},
-        { 13,  8167},{ 12,  4044},{ 12,  4054},{ 12,  4063},{ 13,  8158},
-        { 13,  8154},{ 13,  8165},{ 13,  8178},{ 14,  16378},{ 14,  16375},
-        { 14,  16380},{ 14,  16381},{ 15,  32767}
-    };
-unsigned short huff10[][2] = {
-        { 6,  34},
-        { 5,  8},{ 6,  29},{ 6,  38},{ 7,  95},{ 8,  211},
-        { 9,  463},{ 10,  976},{ 10,  983},{ 10,  1005},{ 11,  2032},
-        { 11,  2038},{ 12,  4093},{ 5,  7},{ 4,  0},{ 4,  1},
-        { 5,  9},{ 6,  32},{ 7,  84},{ 7,  96},{ 8,  213},
-        { 8,  220},{ 9,  468},{ 10,  973},{ 10,  990},{ 11,  2023},
-        { 6,  28},{ 4,  2},{ 5,  6},{ 5,  12},{ 6,  30},
-        { 6,  40},{ 7,  91},{ 8,  205},{ 8,  217},{ 9,  462},
-        { 9,  476},{ 10,  985},{ 10,  1009},{ 6,  37},{ 5,  11},
-        { 5,  10},{ 5,  13},{ 6,  36},{ 7,  87},{ 7,  97},
-        { 8,  204},{ 8,  221},{ 9,  460},{ 9,  478},{ 10,  979},
-        { 10,  999},{ 7,  93},{ 6,  33},{ 6,  31},{ 6,  35},
-        { 6,  39},{ 7,  89},{ 7,  100},{ 8,  216},{ 8,  223},
-        { 9,  466},{ 9,  482},{ 10,  989},{ 10,  1006},{ 8,  209},
-        { 7,  85},{ 6,  41},{ 7,  86},{ 7,  88},{ 7,  98},
-        { 8,  206},{ 8,  224},{ 8,  226},{ 9,  474},{ 10,  980},
-        { 10,  995},{ 11,  2027},{ 9,  457},{ 7,  94},{ 7,  90},
-        { 7,  92},{ 7,  99},{ 8,  202},{ 8,  218},{ 9,  455},
-        { 9,  458},{ 9,  480},{ 10,  987},{ 10,  1000},{ 11,  2028},
-        { 9,  483},{ 8,  210},{ 8,  203},{ 8,  208},{ 8,  215},
-        { 8,  219},{ 9,  454},{ 9,  469},{ 9,  472},{ 10,  970},
-        { 10,  986},{ 11,  2026},{ 11,  2033},{ 9,  481},{ 8,  212},
-        { 8,  207},{ 8,  214},{ 8,  222},{ 8,  225},{ 9,  464},
-        { 9,  470},{ 10,  977},{ 10,  981},{ 10,  1010},{ 11,  2030},
-        { 11,  2043},{ 10,  1001},{ 9,  461},{ 9,  456},{ 9,  459},
-        { 9,  465},{ 9,  471},{ 9,  479},{ 10,  975},{ 10,  992},
-        { 10,  1007},{ 11,  2022},{ 11,  2040},{ 12,  4090},{ 10,  1003},
-        { 9,  477},{ 9,  467},{ 9,  473},{ 9,  475},{ 10,  978},
-        { 10,  972},{ 10,  988},{ 10,  1002},{ 11,  2029},{ 11,  2035},
-        { 11,  2041},{ 12,  4089},{ 11,  2034},{ 10,  974},{ 9,  484},
-        { 10,  971},{ 10,  984},{ 10,  982},{ 10,  994},{ 10,  997},
-        { 11,  2024},{ 11,  2036},{ 11,  2037},{ 11,  2039},{ 12,  4091},
-        { 11,  2042},{ 10,  1004},{ 10,  991},{ 10,  993},{ 10,  996},
-        { 10,  998},{ 10,  1008},{ 11,  2025},{ 11,  2031},{ 12,  4088},
-        { 12,  4094},{ 12,  4092},{ 12,  4095}
-    };
-unsigned short huff11[][2] = {
-        { 4,  0},
-        { 5,  6},{ 6,  25},{ 7,  61},{ 8,  156},{ 8,  198},
-        { 9,  423},{ 10,  912},{ 10,  962},{ 10,  991},{ 11,  2022},
-        { 11,  2035},{ 12,  4091},{ 11,  2028},{ 12,  4090},{ 12,  4094},
-        { 10,  910},{ 5,  5},{ 4,  1},{ 5,  8},{ 6,  20},
-        { 7,  55},{ 7,  66},{ 8,  146},{ 8,  175},{ 9,  401},
-        { 9,  421},{ 9,  437},{ 10,  926},{ 10,  960},{ 10,  930},
-        { 10,  973},{ 11,  2006},{ 8,  174},{ 6,  23},{ 5,  7},
-        { 5,  9},{ 6,  24},{ 7,  57},{ 7,  64},{ 8,  142},
-        { 8,  163},{ 8,  184},{ 9,  409},{ 9,  428},{ 9,  449},
-        { 10,  945},{ 10,  918},{ 10,  958},{ 10,  970},{ 8,  157},
-        { 7,  60},{ 6,  21},{ 6,  22},{ 6,  26},{ 7,  59},
-        { 7,  68},{ 8,  145},{ 8,  165},{ 8,  190},{ 9,  406},
-        { 9,  430},{ 9,  441},{ 10,  929},{ 10,  913},{ 10,  933},
-        { 10,  981},{ 8,  148},{ 8,  154},{ 7,  54},{ 7,  56},
-        { 7,  58},{ 7,  65},{ 8,  140},{ 8,  155},{ 8,  176},
-        { 8,  195},{ 9,  414},{ 9,  427},{ 9,  444},{ 10,  927},
-        { 10,  911},{ 10,  937},{ 10,  975},{ 8,  147},{ 8,  191},
-        { 7,  62},{ 7,  63},{ 7,  67},{ 7,  69},{ 8,  158},
-        { 8,  167},{ 8,  185},{ 9,  404},{ 9,  418},{ 9,  442},
-        { 9,  451},{ 10,  934},{ 10,  935},{ 10,  955},{ 10,  980},
-        { 8,  159},{ 9,  416},{ 8,  143},{ 8,  141},{ 8,  144},
-        { 8,  152},{ 8,  166},{ 8,  182},{ 8,  196},{ 9,  415},
-        { 9,  431},{ 9,  447},{ 10,  921},{ 10,  959},{ 10,  948},
-        { 10,  969},{ 10,  999},{ 8,  168},{ 9,  438},{ 8,  171},
-        { 8,  164},{ 8,  170},{ 8,  178},{ 8,  194},{ 8,  197},
-        { 9,  408},{ 9,  420},{ 9,  440},{ 10,  908},{ 10,  932},
-        { 10,  964},{ 10,  966},{ 10,  989},{ 10,  1000},{ 8,  173},
-        { 10,  943},{ 9,  402},{ 8,  189},{ 8,  188},{ 9,  398},
-        { 9,  407},{ 9,  410},{ 9,  419},{ 9,  433},{ 10,  909},
-        { 10,  920},{ 10,  951},{ 10,  979},{ 10,  977},{ 10,  987},
-        { 11,  2013},{ 8,  180},{ 10,  990},{ 9,  425},{ 9,  411},
-        { 9,  412},{ 9,  417},{ 9,  426},{ 9,  429},{ 9,  435},
-        { 10,  907},{ 10,  946},{ 10,  952},{ 10,  974},{ 10,  993},
-        { 10,  992},{ 11,  2002},{ 11,  2021},{ 8,  183},{ 11,  2019},
-        { 9,  443},{ 9,  424},{ 9,  422},{ 9,  432},{ 9,  434},
-        { 9,  439},{ 10,  923},{ 10,  922},{ 10,  954},{ 10,  949},
-        { 10,  982},{ 11,  2007},{ 10,  996},{ 11,  2008},{ 11,  2026},
-        { 8,  186},{ 11,  2024},{ 10,  928},{ 9,  445},{ 9,  436},
-        { 10,  906},{ 9,  452},{ 10,  914},{ 10,  938},{ 10,  944},
-        { 10,  956},{ 10,  983},{ 11,  2004},{ 11,  2012},{ 11,  2011},
-        { 11,  2005},{ 11,  2032},{ 8,  193},{ 11,  2043},{ 10,  968},
-        { 10,  931},{ 10,  917},{ 10,  925},{ 10,  940},{ 10,  942},
-        { 10,  965},{ 10,  984},{ 10,  994},{ 10,  998},{ 11,  2020},
-        { 11,  2023},{ 11,  2016},{ 11,  2025},{ 11,  2039},{ 9,  400},
-        { 11,  2034},{ 10,  915},{ 9,  446},{ 9,  448},{ 10,  916},
-        { 10,  919},{ 10,  941},{ 10,  963},{ 10,  961},{ 10,  978},
-        { 11,  2010},{ 11,  2009},{ 11,  2015},{ 11,  2027},{ 11,  2036},
-        { 11,  2042},{ 9,  405},{ 11,  2040},{ 10,  957},{ 10,  924},
-        { 10,  939},{ 10,  936},{ 10,  947},{ 10,  953},{ 10,  976},
-        { 10,  995},{ 10,  997},{ 11,  2018},{ 11,  2014},{ 11,  2029},
-        { 11,  2033},{ 11,  2041},{ 11,  2044},{ 9,  403},{ 12,  4093},
-        { 10,  988},{ 10,  950},{ 10,  967},{ 10,  972},{ 10,  971},
-        { 10,  985},{ 10,  986},{ 11,  2003},{ 11,  2017},{ 11,  2030},
-        { 11,  2031},{ 11,  2037},{ 11,  2038},{ 12,  4092},{ 12,  4095},
-        { 9,  413},{ 9,  450},{ 8,  181},{ 8,  161},{ 8,  150},
-        { 8,  151},{ 8,  149},{ 8,  153},{ 8,  160},{ 8,  162},
-        { 8,  172},{ 8,  169},{ 8,  177},{ 8,  179},{ 8,  187},
-        { 8,  192},{ 9,  399},{ 5,  4}
-    };
-unsigned int huff12[][2] = {
-        { 18,  262120},
-        { 18,  262118},{ 18,  262119},{ 18,  262117},{ 19,  524277},{ 19,  524273},
-        { 19,  524269},{ 19,  524278},{ 19,  524270},{ 19,  524271},{ 19,  524272},
-        { 19,  524284},{ 19,  524285},{ 19,  524287},{ 19,  524286},{ 19,  524279},
-        { 19,  524280},{ 19,  524283},{ 19,  524281},{ 18,  262116},{ 19,  524282},
-        { 18,  262115},{ 17,  131055},{ 17,  131056},{ 16,  65525},{ 17,  131054},
-        { 16,  65522},{ 16,  65523},{ 16,  65524},{ 16,  65521},{ 15,  32758},
-        { 15,  32759},{ 14,  16377},{ 14,  16373},{ 14,  16375},{ 14,  16371},
-        { 14,  16374},{ 14,  16370},{ 13,  8183},{ 13,  8181},{ 12,  4089},
-        { 12,  4087},{ 12,  4086},{ 11,  2041},{ 12,  4084},{ 11,  2040},
-        { 10,  1017},{ 10,  1015},{ 10,  1013},{ 9,  504},{ 9,  503},
-        { 8,  250},{ 8,  248},{ 8,  246},{ 7,  121},{ 6,  58},
-        { 6,  56},{ 5,  26},{ 4,  11},{ 3,  4},{ 1,  0},
-        { 4,  10},{ 4,  12},{ 5,  27},{ 6,  57},{ 6,  59},
-        { 7,  120},{ 7,  122},{ 8,  247},{ 8,  249},{ 9,  502},
-        { 9,  505},{ 10,  1012},{ 10,  1014},{ 10,  1016},{ 11,  2037},
-        { 11,  2036},{ 11,  2038},{ 11,  2039},{ 12,  4085},{ 12,  4088},
-        { 13,  8180},{ 13,  8182},{ 13,  8184},{ 14,  16376},{ 14,  16372},
-        { 16,  65520},{ 15,  32756},{ 16,  65526},{ 15,  32757},{ 18,  262114},
-        { 19,  524249},{ 19,  524250},{ 19,  524251},{ 19,  524252},{ 19,  524253},
-        { 19,  524254},{ 19,  524248},{ 19,  524242},{ 19,  524243},{ 19,  524244},
-        { 19,  524245},{ 19,  524246},{ 19,  524274},{ 19,  524255},{ 19,  524263},
-        { 19,  524264},{ 19,  524265},{ 19,  524266},{ 19,  524267},{ 19,  524262},
-        { 19,  524256},{ 19,  524257},{ 19,  524258},{ 19,  524259},{ 19,  524260},
-        { 19,  524261},{ 19,  524247},{ 19,  524268},{ 19,  524276},{ 19,  524275}
-    };
-
-