Index: trunk/src/mpc_decoder.c
===================================================================
--- trunk/src/mpc_decoder.c	(revision 7)
+++ trunk/src/mpc_decoder.c	(revision 10)
@@ -41,4 +41,22 @@
 #include <mpcdec/huffman.h>
 
+//SV7 tables
+extern const HuffmanTyp*   mpc_table_HuffQ [2] [8];
+extern const HuffmanTyp    mpc_table_HuffHdr  [10];
+extern const HuffmanTyp    mpc_table_HuffSCFI [ 4];
+extern const HuffmanTyp    mpc_table_HuffDSCF [16];
+
+
+#ifdef MPC_SUPPORT_SV456
+//SV4/5/6 tables
+extern const HuffmanTyp*   mpc_table_SampleHuff [18];
+extern const HuffmanTyp    mpc_table_SCFI_Bundle   [ 8];
+extern const HuffmanTyp    mpc_table_DSCF_Entropie [13];
+extern const HuffmanTyp    mpc_table_Region_A [16];
+extern const HuffmanTyp    mpc_table_Region_B [ 8];
+extern const HuffmanTyp    mpc_table_Region_C [ 4];
+
+#endif
+
 //------------------------------------------------------------------------------
 // types
@@ -57,6 +75,4 @@
 // forward declarations
 //------------------------------------------------------------------------------
-void mpc_decoder_init_huffman_sv6(mpc_decoder *d);
-void mpc_decoder_init_huffman_sv7(mpc_decoder *d);
 void mpc_decoder_read_bitstream_sv6(mpc_decoder *d);
 void mpc_decoder_read_bitstream_sv7(mpc_decoder *d);
@@ -152,5 +168,5 @@
 mpc_decoder_scfi_bundle_read(
     mpc_decoder *d,
-    HuffmanTyp* Table, mpc_int32_t* SCFI, mpc_int32_t* DSCF) 
+    const HuffmanTyp* Table, mpc_int32_t* SCFI, mpc_bool_t* DSCF) 
 {
     // load preview and decode
@@ -172,27 +188,4 @@
     *SCFI = Table->Value >> 1;
     *DSCF = Table->Value &  1;
-}
-
-static int
-mpc_decoder_huffman_typ_cmpfn(const void* p1, const void* p2)
-{
-    if (((HuffmanTyp*) p1)->Code < ((HuffmanTyp*) p2)->Code ) return +1;
-    if (((HuffmanTyp*) p1)->Code > ((HuffmanTyp*) p2)->Code ) return -1;
-    return 0;
-}
-
-// sort huffman-tables by codeword
-// offset resulting value
-void
-mpc_decoder_resort_huff_tables(
-    const mpc_uint32_t elements, HuffmanTyp* Table, const mpc_int32_t offset ) 
-{
-    mpc_uint32_t  i;
-
-    for ( i = 0; i < elements; i++ ) {
-        Table[i].Code <<= 32 - Table[i].Length;
-        Table[i].Value  =  i - offset;
-    }
-    qsort(Table, elements, sizeof(*Table), mpc_decoder_huffman_typ_cmpfn);
 }
 
@@ -328,4 +321,5 @@
   d->dword = d->Speicher[0];
   switch (d->StreamVersion) {
+#ifdef MPC_SUPPORT_SV456
     case 0x04:
     case 0x05:
@@ -333,4 +327,5 @@
         mpc_decoder_read_bitstream_sv6(d);
         break;
+#endif
     case 0x07:
     case 0x17:
@@ -364,4 +359,5 @@
     FrameBitCnt = mpc_decoder_bits_read(d);
     switch (d->StreamVersion) {
+#ifdef MPC_SUPPORT_SV456
     case 0x04:
     case 0x05:
@@ -369,4 +365,5 @@
         mpc_decoder_read_bitstream_sv6(d);
         break;
+#endif
     case 0x07:
     case 0x17:
@@ -402,24 +399,10 @@
         // additional FilterDecay samples are needed for decay of synthesis filter
         if (MPC_DECODER_SYNTH_DELAY + mod_block >= MPC_FRAME_LENGTH) {
-
-            // **********************************************************************
-            // Rhoades 4/16/2002
-            // Commented out are blocks of code which cause gapless playback to fail.
-            // Temporary fix...
-            // **********************************************************************
-
             if (!d->TrueGaplessPresent) {
                 mpc_decoder_reset_y(d);
-            } 
-            else {
-                //if ( MPC_FRAME_LENGTH != d->LastValidSamples ) {
+            } else {
                 mpc_decoder_bitstream_read(d, 20);
                 mpc_decoder_read_bitstream_sv7(d);
                 mpc_decoder_requantisierung(d, d->Max_Band);
-                //FilterDecay = d->LastValidSamples;
-                //}
-                //else {
-                //FilterDecay = 0;
-                //}
             }
 
@@ -652,4 +635,40 @@
 }
 
+#ifdef MPC_SUPPORT_SV456
+static const unsigned char Q_res[32][16] = {
+{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
+{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
+{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
+{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
+{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
+{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
+{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
+{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
+{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
+{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
+{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
+{0,1,2,3,4,5,6,17,0,0,0,0,0,0,0,0},
+{0,1,2,3,4,5,6,17,0,0,0,0,0,0,0,0},
+{0,1,2,3,4,5,6,17,0,0,0,0,0,0,0,0},
+{0,1,2,3,4,5,6,17,0,0,0,0,0,0,0,0},
+{0,1,2,3,4,5,6,17,0,0,0,0,0,0,0,0},
+{0,1,2,3,4,5,6,17,0,0,0,0,0,0,0,0},
+{0,1,2,3,4,5,6,17,0,0,0,0,0,0,0,0},
+{0,1,2,3,4,5,6,17,0,0,0,0,0,0,0,0},
+{0,1,2,3,4,5,6,17,0,0,0,0,0,0,0,0},
+{0,1,2,3,4,5,6,17,0,0,0,0,0,0,0,0},
+{0,1,2,3,4,5,6,17,0,0,0,0,0,0,0,0},
+{0,1,2,3,4,5,6,17,0,0,0,0,0,0,0,0},
+{0,1,2,17,0,0,0,0,0,0,0,0,0,0,0,0},
+{0,1,2,17,0,0,0,0,0,0,0,0,0,0,0,0},
+{0,1,2,17,0,0,0,0,0,0,0,0,0,0,0,0},
+{0,1,2,17,0,0,0,0,0,0,0,0,0,0,0,0},
+{0,1,2,17,0,0,0,0,0,0,0,0,0,0,0,0},
+{0,1,2,17,0,0,0,0,0,0,0,0,0,0,0,0},
+{0,1,2,17,0,0,0,0,0,0,0,0,0,0,0,0},
+{0,1,2,17,0,0,0,0,0,0,0,0,0,0,0,0},
+{0,1,2,17,0,0,0,0,0,0,0,0,0,0,0,0},
+};
+
 /****************************************** SV 6 ******************************************/
 void
@@ -658,5 +677,5 @@
     mpc_int32_t n,k;
     mpc_int32_t Max_used_Band=0;
-    HuffmanTyp *Table;
+    const HuffmanTyp *Table;
     const HuffmanTyp *x1;
     const HuffmanTyp *x2;
@@ -671,13 +690,13 @@
     for (n=0; n <= d->Max_Band; ++n, ++ResL, ++ResR)
     {
-        if      (n<11)           Table = d->Region_A;
-        else if (n>=11 && n<=22) Table = d->Region_B;
-        else /*if (n>=23)*/      Table = d->Region_C;
-
-        *ResL = d->Q_res[n][mpc_decoder_huffman_decode(d, Table)];
+        if      (n<11)           Table = mpc_table_Region_A;
+        else if (n>=11 && n<=22) Table = mpc_table_Region_B;
+        else /*if (n>=23)*/      Table = mpc_table_Region_C;
+
+        *ResL = Q_res[n][mpc_decoder_huffman_decode(d, Table)];
         if (d->MS_used) {
             d->MS_Flag[n] = mpc_decoder_bitstream_read(d,  1);
         }
-        *ResR = d->Q_res[n][mpc_decoder_huffman_decode(d, Table)];
+        *ResR = Q_res[n][mpc_decoder_huffman_decode(d, Table)];
 
         // only perform the following procedure up to the maximum non-zero subband
@@ -689,6 +708,6 @@
     ResR = d->Res_R;
     for (n=0; n<=Max_used_Band; ++n, ++ResL, ++ResR) {
-        if (*ResL) mpc_decoder_scfi_bundle_read(d, d->SCFI_Bundle, &(d->SCFI_L[n]), &(d->DSCF_Flag_L[n]));
-        if (*ResR) mpc_decoder_scfi_bundle_read(d, d->SCFI_Bundle, &(d->SCFI_R[n]), &(d->DSCF_Flag_R[n]));
+        if (*ResL) mpc_decoder_scfi_bundle_read(d, mpc_table_SCFI_Bundle, &(d->SCFI_L[n]), &(d->DSCF_Flag_L[n]));
+        if (*ResR) mpc_decoder_scfi_bundle_read(d, mpc_table_SCFI_Bundle, &(d->SCFI_R[n]), &(d->DSCF_Flag_R[n]));
     }
 
@@ -709,22 +728,22 @@
                 {
                 case 3:
-                    L[0] = L[2] + mpc_decoder_huffman_decode_fast(d,  d->DSCF_Entropie);
+                    L[0] = L[2] + mpc_decoder_huffman_decode_fast(d,  mpc_table_DSCF_Entropie);
                     L[1] = L[0];
                     L[2] = L[1];
                     break;
                 case 1:
-                    L[0] = L[2] + mpc_decoder_huffman_decode_fast(d,  d->DSCF_Entropie);
-                    L[1] = L[0] + mpc_decoder_huffman_decode_fast(d,  d->DSCF_Entropie);
+                    L[0] = L[2] + mpc_decoder_huffman_decode_fast(d,  mpc_table_DSCF_Entropie);
+                    L[1] = L[0] + mpc_decoder_huffman_decode_fast(d,  mpc_table_DSCF_Entropie);
                     L[2] = L[1];
                     break;
                 case 2:
-                    L[0] = L[2] + mpc_decoder_huffman_decode_fast(d,  d->DSCF_Entropie);
+                    L[0] = L[2] + mpc_decoder_huffman_decode_fast(d,  mpc_table_DSCF_Entropie);
                     L[1] = L[0];
-                    L[2] = L[1] + mpc_decoder_huffman_decode_fast(d,  d->DSCF_Entropie);
+                    L[2] = L[1] + mpc_decoder_huffman_decode_fast(d,  mpc_table_DSCF_Entropie);
                     break;
                 case 0:
-                    L[0] = L[2] + mpc_decoder_huffman_decode_fast(d,  d->DSCF_Entropie);
-                    L[1] = L[0] + mpc_decoder_huffman_decode_fast(d,  d->DSCF_Entropie);
-                    L[2] = L[1] + mpc_decoder_huffman_decode_fast(d,  d->DSCF_Entropie);
+                    L[0] = L[2] + mpc_decoder_huffman_decode_fast(d,  mpc_table_DSCF_Entropie);
+                    L[1] = L[0] + mpc_decoder_huffman_decode_fast(d,  mpc_table_DSCF_Entropie);
+                    L[2] = L[1] + mpc_decoder_huffman_decode_fast(d,  mpc_table_DSCF_Entropie);
                     break;
                 default:
@@ -775,22 +794,22 @@
                 {
                 case 3:
-                    R[0] = R[2] + mpc_decoder_huffman_decode_fast(d,  d->DSCF_Entropie);
+                    R[0] = R[2] + mpc_decoder_huffman_decode_fast(d,  mpc_table_DSCF_Entropie);
                     R[1] = R[0];
                     R[2] = R[1];
                     break;
                 case 1:
-                    R[0] = R[2] + mpc_decoder_huffman_decode_fast(d,  d->DSCF_Entropie);
-                    R[1] = R[0] + mpc_decoder_huffman_decode_fast(d,  d->DSCF_Entropie);
+                    R[0] = R[2] + mpc_decoder_huffman_decode_fast(d,  mpc_table_DSCF_Entropie);
+                    R[1] = R[0] + mpc_decoder_huffman_decode_fast(d,  mpc_table_DSCF_Entropie);
                     R[2] = R[1];
                     break;
                 case 2:
-                    R[0] = R[2] + mpc_decoder_huffman_decode_fast(d,  d->DSCF_Entropie);
+                    R[0] = R[2] + mpc_decoder_huffman_decode_fast(d,  mpc_table_DSCF_Entropie);
                     R[1] = R[0];
-                    R[2] = R[1] + mpc_decoder_huffman_decode_fast(d,  d->DSCF_Entropie);
+                    R[2] = R[1] + mpc_decoder_huffman_decode_fast(d,  mpc_table_DSCF_Entropie);
                     break;
                 case 0:
-                    R[0] = R[2] + mpc_decoder_huffman_decode_fast(d,  d->DSCF_Entropie);
-                    R[1] = R[0] + mpc_decoder_huffman_decode_fast(d,  d->DSCF_Entropie);
-                    R[2] = R[1] + mpc_decoder_huffman_decode_fast(d,  d->DSCF_Entropie);
+                    R[0] = R[2] + mpc_decoder_huffman_decode_fast(d,  mpc_table_DSCF_Entropie);
+                    R[1] = R[0] + mpc_decoder_huffman_decode_fast(d,  mpc_table_DSCF_Entropie);
+                    R[2] = R[1] + mpc_decoder_huffman_decode_fast(d,  mpc_table_DSCF_Entropie);
                     break;
                 default:
@@ -840,6 +859,6 @@
     {
         // setting pointers
-        x1 = d->SampleHuff[*ResL];
-        x2 = d->SampleHuff[*ResR];
+        x1 = mpc_table_SampleHuff[*ResL];
+        x2 = mpc_table_SampleHuff[*ResR];
         L = d->Q[n].L;
         R = d->Q[n].R;
@@ -860,5 +879,5 @@
     }
 }
-
+#endif //MPC_SUPPORT_SV456
 /****************************************** SV 7 ******************************************/
 void
@@ -895,8 +914,8 @@
     for (n=1; n <= d->Max_Band; ++n, ++ResL, ++ResR)
     {
-        idx   = mpc_decoder_huffman_decode_fast(d, d->HuffHdr);
+        idx   = mpc_decoder_huffman_decode_fast(d, mpc_table_HuffHdr);
         *ResL = (idx!=4) ? *(ResL-1) + idx : (int) mpc_decoder_bitstream_read(d, 4);
 
-        idx   = mpc_decoder_huffman_decode_fast(d, d->HuffHdr);
+        idx   = mpc_decoder_huffman_decode_fast(d, mpc_table_HuffHdr);
         *ResR = (idx!=4) ? *(ResR-1) + idx : (int) mpc_decoder_bitstream_read(d, 4);
 
@@ -916,6 +935,6 @@
     ResR  = d->Res_R;
     for (n=0; n <= Max_used_Band; ++n, ++L, ++R, ++ResL, ++ResR) {
-        if (*ResL) *L = mpc_decoder_huffman_decode_faster(d, d->HuffSCFI);
-        if (*ResR) *R = mpc_decoder_huffman_decode_faster(d, d->HuffSCFI);
+        if (*ResL) *L = mpc_decoder_huffman_decode_faster(d, mpc_table_HuffSCFI);
+        if (*ResR) *R = mpc_decoder_huffman_decode_faster(d, mpc_table_HuffSCFI);
     }
 
@@ -932,12 +951,12 @@
             {
             case 1:
-                idx  = mpc_decoder_huffman_decode_fast(d, d->HuffDSCF);
+                idx  = mpc_decoder_huffman_decode_fast(d, mpc_table_HuffDSCF);
                 L[0] = (idx!=8) ? L[2] + idx : (int) mpc_decoder_bitstream_read(d, 6);
-                idx  = mpc_decoder_huffman_decode_fast(d, d->HuffDSCF);
+                idx  = mpc_decoder_huffman_decode_fast(d, mpc_table_HuffDSCF);
                 L[1] = (idx!=8) ? L[0] + idx : (int) mpc_decoder_bitstream_read(d, 6);
                 L[2] = L[1];
                 break;
             case 3:
-                idx  = mpc_decoder_huffman_decode_fast(d,  d->HuffDSCF);
+                idx  = mpc_decoder_huffman_decode_fast(d,  mpc_table_HuffDSCF);
                 L[0] = (idx!=8) ? L[2] + idx : (int) mpc_decoder_bitstream_read(d, 6);
                 L[1] = L[0];
@@ -945,16 +964,16 @@
                 break;
             case 2:
-                idx  = mpc_decoder_huffman_decode_fast(d,  d->HuffDSCF);
+                idx  = mpc_decoder_huffman_decode_fast(d,  mpc_table_HuffDSCF);
                 L[0] = (idx!=8) ? L[2] + idx : (int) mpc_decoder_bitstream_read(d, 6);
                 L[1] = L[0];
-                idx  = mpc_decoder_huffman_decode_fast(d,  d->HuffDSCF);
+                idx  = mpc_decoder_huffman_decode_fast(d,  mpc_table_HuffDSCF);
                 L[2] = (idx!=8) ? L[1] + idx : (int) mpc_decoder_bitstream_read(d, 6);
                 break;
             case 0:
-                idx  = mpc_decoder_huffman_decode_fast(d,  d->HuffDSCF);
+                idx  = mpc_decoder_huffman_decode_fast(d,  mpc_table_HuffDSCF);
                 L[0] = (idx!=8) ? L[2] + idx : (int) mpc_decoder_bitstream_read(d, 6);
-                idx  = mpc_decoder_huffman_decode_fast(d,  d->HuffDSCF);
+                idx  = mpc_decoder_huffman_decode_fast(d,  mpc_table_HuffDSCF);
                 L[1] = (idx!=8) ? L[0] + idx : (int) mpc_decoder_bitstream_read(d, 6);
-                idx  = mpc_decoder_huffman_decode_fast(d,  d->HuffDSCF);
+                idx  = mpc_decoder_huffman_decode_fast(d,  mpc_table_HuffDSCF);
                 L[2] = (idx!=8) ? L[1] + idx : (int) mpc_decoder_bitstream_read(d, 6);
                 break;
@@ -972,12 +991,12 @@
             {
             case 1:
-                idx  = mpc_decoder_huffman_decode_fast(d,  d->HuffDSCF);
+                idx  = mpc_decoder_huffman_decode_fast(d,  mpc_table_HuffDSCF);
                 R[0] = (idx!=8) ? R[2] + idx : (int) mpc_decoder_bitstream_read(d, 6);
-                idx  = mpc_decoder_huffman_decode_fast(d,  d->HuffDSCF);
+                idx  = mpc_decoder_huffman_decode_fast(d,  mpc_table_HuffDSCF);
                 R[1] = (idx!=8) ? R[0] + idx : (int) mpc_decoder_bitstream_read(d, 6);
                 R[2] = R[1];
                 break;
             case 3:
-                idx  = mpc_decoder_huffman_decode_fast(d,  d->HuffDSCF);
+                idx  = mpc_decoder_huffman_decode_fast(d,  mpc_table_HuffDSCF);
                 R[0] = (idx!=8) ? R[2] + idx : (int) mpc_decoder_bitstream_read(d, 6);
                 R[1] = R[0];
@@ -985,16 +1004,16 @@
                 break;
             case 2:
-                idx  = mpc_decoder_huffman_decode_fast(d,  d->HuffDSCF);
+                idx  = mpc_decoder_huffman_decode_fast(d,  mpc_table_HuffDSCF);
                 R[0] = (idx!=8) ? R[2] + idx : (int) mpc_decoder_bitstream_read(d, 6);
                 R[1] = R[0];
-                idx  = mpc_decoder_huffman_decode_fast(d,  d->HuffDSCF);
+                idx  = mpc_decoder_huffman_decode_fast(d,  mpc_table_HuffDSCF);
                 R[2] = (idx!=8) ? R[1] + idx : (int) mpc_decoder_bitstream_read(d, 6);
                 break;
             case 0:
-                idx  = mpc_decoder_huffman_decode_fast(d,  d->HuffDSCF);
+                idx  = mpc_decoder_huffman_decode_fast(d,  mpc_table_HuffDSCF);
                 R[0] = (idx!=8) ? R[2] + idx : (int) mpc_decoder_bitstream_read(d, 6);
-                idx  = mpc_decoder_huffman_decode_fast(d,  d->HuffDSCF);
+                idx  = mpc_decoder_huffman_decode_fast(d,  mpc_table_HuffDSCF);
                 R[1] = (idx!=8) ? R[0] + idx : (int) mpc_decoder_bitstream_read(d, 6);
-                idx  = mpc_decoder_huffman_decode_fast(d,  d->HuffDSCF);
+                idx  = mpc_decoder_huffman_decode_fast(d,  mpc_table_HuffDSCF);
                 R[2] = (idx!=8) ? R[1] + idx : (int) mpc_decoder_bitstream_read(d, 6);
                 break;
@@ -1031,5 +1050,5 @@
             break;
         case 1:
-            Table = d->HuffQ[mpc_decoder_bitstream_read(d, 1)][1];
+            Table = mpc_table_HuffQ[mpc_decoder_bitstream_read(d, 1)][1];
             for (k=0; k<12; ++k)
             {
@@ -1041,5 +1060,5 @@
             break;
         case 2:
-            Table = d->HuffQ[mpc_decoder_bitstream_read(d, 1)][2];
+            Table = mpc_table_HuffQ[mpc_decoder_bitstream_read(d, 1)][2];
             for (k=0; k<18; ++k)
             {
@@ -1051,10 +1070,10 @@
         case 3:
         case 4:
-            Table = d->HuffQ[mpc_decoder_bitstream_read(d, 1)][*ResL];
+            Table = mpc_table_HuffQ[mpc_decoder_bitstream_read(d, 1)][*ResL];
             for (k=0; k<36; ++k)
                 *L++ = mpc_decoder_huffman_decode_faster(d, Table);
             break;
         case 5:
-            Table = d->HuffQ[mpc_decoder_bitstream_read(d, 1)][*ResL];
+            Table = mpc_table_HuffQ[mpc_decoder_bitstream_read(d, 1)][*ResL];
             for (k=0; k<36; ++k)
                 *L++ = mpc_decoder_huffman_decode_fast(d, Table);
@@ -1062,5 +1081,5 @@
         case 6:
         case 7:
-            Table = d->HuffQ[mpc_decoder_bitstream_read(d, 1)][*ResL];
+            Table = mpc_table_HuffQ[mpc_decoder_bitstream_read(d, 1)][*ResL];
             for (k=0; k<36; ++k)
                 *L++ = mpc_decoder_huffman_decode(d, Table);
@@ -1091,5 +1110,5 @@
                 break;
             case 1:
-                Table = d->HuffQ[mpc_decoder_bitstream_read(d, 1)][1];
+                Table = mpc_table_HuffQ[mpc_decoder_bitstream_read(d, 1)][1];
                 for (k=0; k<12; ++k)
                 {
@@ -1101,5 +1120,5 @@
                 break;
             case 2:
-                Table = d->HuffQ[mpc_decoder_bitstream_read(d, 1)][2];
+                Table = mpc_table_HuffQ[mpc_decoder_bitstream_read(d, 1)][2];
                 for (k=0; k<18; ++k)
                 {
@@ -1111,10 +1130,10 @@
             case 3:
             case 4:
-                Table = d->HuffQ[mpc_decoder_bitstream_read(d, 1)][*ResR];
+                Table = mpc_table_HuffQ[mpc_decoder_bitstream_read(d, 1)][*ResR];
                 for (k=0; k<36; ++k)
                     *R++ = mpc_decoder_huffman_decode_faster(d, Table);
                 break;
             case 5:
-                Table = d->HuffQ[mpc_decoder_bitstream_read(d, 1)][*ResR];
+                Table = mpc_table_HuffQ[mpc_decoder_bitstream_read(d, 1)][*ResR];
                 for (k=0; k<36; ++k)
                     *R++ = mpc_decoder_huffman_decode_fast(d, Table);
@@ -1122,5 +1141,5 @@
             case 6:
             case 7:
-                Table = d->HuffQ[mpc_decoder_bitstream_read(d, 1)][*ResR];
+                Table = mpc_table_HuffQ[mpc_decoder_bitstream_read(d, 1)][*ResR];
                 for (k=0; k<36; ++k)
                     *R++ = mpc_decoder_huffman_decode(d, Table);
@@ -1141,41 +1160,4 @@
   d->r = r;
 
-  d->HuffQ[0][0] = 0;
-  d->HuffQ[1][0] = 0;
-  d->HuffQ[0][1] = d->HuffQ1[0];
-  d->HuffQ[1][1] = d->HuffQ1[1];
-  d->HuffQ[0][2] = d->HuffQ2[0];
-  d->HuffQ[1][2] = d->HuffQ2[1];
-  d->HuffQ[0][3] = d->HuffQ3[0];
-  d->HuffQ[1][3] = d->HuffQ3[1];
-  d->HuffQ[0][4] = d->HuffQ4[0];
-  d->HuffQ[1][4] = d->HuffQ4[1];
-  d->HuffQ[0][5] = d->HuffQ5[0];
-  d->HuffQ[1][5] = d->HuffQ5[1];
-  d->HuffQ[0][6] = d->HuffQ6[0];
-  d->HuffQ[1][6] = d->HuffQ6[1];
-  d->HuffQ[0][7] = d->HuffQ7[0];
-  d->HuffQ[1][7] = d->HuffQ7[1];
-
-  d->SampleHuff[0] = NULL;
-  d->SampleHuff[1] = d->Entropie_1;
-  d->SampleHuff[2] = d->Entropie_2;
-  d->SampleHuff[3] = d->Entropie_3;
-  d->SampleHuff[4] = d->Entropie_4;
-  d->SampleHuff[5] = d->Entropie_5;
-  d->SampleHuff[6] = d->Entropie_6;
-  d->SampleHuff[7] = d->Entropie_7;
-  d->SampleHuff[8] = NULL;
-  d->SampleHuff[9] = NULL;
-  d->SampleHuff[10] = NULL;
-  d->SampleHuff[11] = NULL;
-  d->SampleHuff[12] = NULL;
-  d->SampleHuff[13] = NULL;
-  d->SampleHuff[14] = NULL;
-  d->SampleHuff[15] = NULL;
-  d->SampleHuff[16] = NULL;
-  d->SampleHuff[17] = NULL;
-
-  d->EQ_activated = 0;
   d->MPCHeaderPos = 0;
   d->StreamVersion = 0;
@@ -1186,10 +1168,8 @@
   d->OverallFrames = 0;
   d->DecodedFrames = 0;
-  d->LastValidSamples = 0;
   d->TrueGaplessPresent = 0;
   d->WordsRead = 0;
   d->Max_Band = 0;
   d->SampleRate = 0;
-//  clips = 0;
   d->__r1 = 1;
   d->__r2 = 1;
@@ -1202,6 +1182,8 @@
 
   mpc_decoder_initialisiere_quantisierungstabellen(d, 1.0f);
+#if 0
   mpc_decoder_init_huffman_sv6(d);
   mpc_decoder_init_huffman_sv7(d);
+#endif
 }
 
@@ -1216,5 +1198,4 @@
     d->OverallFrames      = si->frames;
     d->MPCHeaderPos       = si->header_position;
-    d->LastValidSamples   = si->last_frame_samples;
     d->TrueGaplessPresent = si->is_true_gapless;
     d->SampleRate         = (mpc_int32_t)si->sample_freq;
@@ -1353,5 +1334,9 @@
         }
         else {
+#ifdef MPC_SUPPORT_SV456
             mpc_decoder_read_bitstream_sv6(d);
+#else
+            return FALSE;
+#endif
         }
         if (mpc_decoder_bits_read(d) - FrameBitCnt != d->FwdJumpInfo ) {
