Index: libmpcdec/branches/zorg/src/mpc_decoder.c
===================================================================
--- libmpcdec/branches/zorg/src/mpc_decoder.c	(revision 63)
+++ libmpcdec/branches/zorg/src/mpc_decoder.c	(revision 68)
@@ -32,30 +32,19 @@
   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
-
 /// \file mpc_decoder.c
 /// Core decoding routines and logic.
-
+#include <string.h>
 #include <mpcdec/mpcdec.h>
-#include <mpcdec/internal.h>
-#include <mpcdec/requant.h>
-#include <mpcdec/huffman.h>
+#include "decoder.h"
+#include "huffman.h"
+#include "internal.h"
+#include "math.h"
+#include "requant.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
+extern const mpc_huffman*   mpc_table_HuffQ [2] [8];
+extern const mpc_huffman    mpc_table_HuffHdr  [10];
+extern const mpc_huffman    mpc_table_HuffSCFI [ 4];
+extern const mpc_huffman    mpc_table_HuffDSCF [16];
 
 #ifndef MPC_LITTLE_ENDIAN
@@ -69,20 +58,19 @@
 //------------------------------------------------------------------------------
 enum
-    {
-        EQ_TAP = 13,                        // length of FIR filter for EQ
-        DELAY = ((EQ_TAP + 1) / 2),         // delay of FIR
-        FIR_BANDS = 4,                      // number of subbands to be FIR filtered
-        MEMSIZE = MPC_DECODER_MEMSIZE,      // overall buffer size
-        MEMSIZE2 = (MEMSIZE/2),             // size of one buffer
-        MEMMASK = (MEMSIZE-1)
-    };
+{
+    EQ_TAP    = 13,                  // length of FIR filter for EQ
+    DELAY     = ((EQ_TAP + 1) / 2),  // delay of FIR
+    FIR_BANDS = 4,                   // number of subbands to be FIR filtered
+    MEMSIZE   = MPC_DECODER_MEMSIZE, // overall buffer size
+    MEMSIZE2  = (MEMSIZE/2),         // size of one buffer
+    MEMMASK   = (MEMSIZE-1)
+};
 
 //------------------------------------------------------------------------------
 // forward declarations
 //------------------------------------------------------------------------------
-void mpc_decoder_read_bitstream_sv6(mpc_decoder *d, mpc_bool_t seeking);
-void mpc_decoder_read_bitstream_sv7(mpc_decoder *d, mpc_bool_t seeking);
-mpc_bool_t mpc_decoder_seek_sample(mpc_decoder *d, mpc_int64_t destsample);
-void mpc_decoder_requantisierung(mpc_decoder *d, const mpc_int32_t Last_Band);
+static void mpc_decoder_read_bitstream_sv6(mpc_decoder *d, mpc_bool_t seeking);
+static void mpc_decoder_read_bitstream_sv7(mpc_decoder *d, mpc_bool_t seeking);
+static void mpc_decoder_requantisierung(mpc_decoder *d, const mpc_int32_t Last_Band);
 
 //------------------------------------------------------------------------------
@@ -183,5 +171,5 @@
 // works with maximum lengths up to max_length
 static mpc_int32_t
-mpc_decoder_huffman_decode(mpc_decoder *d, const HuffmanTyp *Table,
+mpc_decoder_huffman_decode(mpc_decoder *d, const mpc_huffman *Table,
                            const mpc_uint32_t max_length)
 {
@@ -205,5 +193,5 @@
 // decode SCFI-bundle (sv4,5,6)
 static void
-mpc_decoder_scfi_bundle_read(mpc_decoder *d, const HuffmanTyp* Table,
+mpc_decoder_scfi_bundle_read(mpc_decoder *d, const mpc_huffman* Table,
                              mpc_int32_t* SCFI, mpc_bool_t* DSCF)
 {
@@ -267,11 +255,4 @@
   d->dword = SWAP(d->Speicher[0]);
   switch (d->StreamVersion) {
-#ifdef MPC_SUPPORT_SV456
-    case 0x04:
-    case 0x05:
-    case 0x06:
-        mpc_decoder_read_bitstream_sv6(d, FALSE);
-        break;
-#endif
     case 0x07:
     case 0x17:
@@ -310,11 +291,4 @@
     FrameBitCnt = mpc_decoder_bits_read(d);
     switch (d->StreamVersion) {
-#ifdef MPC_SUPPORT_SV456
-    case 0x04:
-    case 0x05:
-    case 0x06:
-        mpc_decoder_read_bitstream_sv6(d, FALSE);
-        break;
-#endif
     case 0x07:
     case 0x17:
@@ -461,18 +435,18 @@
             if ( d->Res_L [Band] ) {
                 if ( d->Res_R [Band] ) {    // M!=0, S!=0
-                    facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (unsigned char)d->SCF_Index_L[Band][0]);
-                    facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (unsigned char)d->SCF_Index_R[Band][0]);
+                    facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (mpc_uint8_t) d->SCF_Index_L[Band][0]);
+                    facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (mpc_uint8_t) d->SCF_Index_R[Band][0]);
                     for ( n = 0; n < 12; n++, YL += 32, YR += 32 ) {
                         *YL   = (templ = MPC_MULTIPLY_FLOAT_INT(facL,*L++))+(tempr = MPC_MULTIPLY_FLOAT_INT(facR,*R++));
                         *YR   = templ - tempr;
                     }
-                    facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (unsigned char)d->SCF_Index_L[Band][1]);
-                    facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (unsigned char)d->SCF_Index_R[Band][1]);
+                    facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (mpc_uint8_t) d->SCF_Index_L[Band][1]);
+                    facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (mpc_uint8_t) d->SCF_Index_R[Band][1]);
                     for ( ; n < 24; n++, YL += 32, YR += 32 ) {
                         *YL   = (templ = MPC_MULTIPLY_FLOAT_INT(facL,*L++))+(tempr = MPC_MULTIPLY_FLOAT_INT(facR,*R++));
                         *YR   = templ - tempr;
                     }
-                    facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (unsigned char)d->SCF_Index_L[Band][2]);
-                    facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (unsigned char)d->SCF_Index_R[Band][2]);
+                    facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (mpc_uint8_t) d->SCF_Index_L[Band][2]);
+                    facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (mpc_uint8_t) d->SCF_Index_R[Band][2]);
                     for ( ; n < 36; n++, YL += 32, YR += 32 ) {
                         *YL   = (templ = MPC_MULTIPLY_FLOAT_INT(facL,*L++))+(tempr = MPC_MULTIPLY_FLOAT_INT(facR,*R++));
@@ -480,13 +454,13 @@
                     }
                 } else {    // M!=0, S==0
-                    facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (unsigned char)d->SCF_Index_L[Band][0]);
+                    facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (mpc_uint8_t) d->SCF_Index_L[Band][0]);
                     for ( n = 0; n < 12; n++, YL += 32, YR += 32 ) {
                         *YR = *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++);
                     }
-                    facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (unsigned char)d->SCF_Index_L[Band][1]);
+                    facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (mpc_uint8_t) d->SCF_Index_L[Band][1]);
                     for ( ; n < 24; n++, YL += 32, YR += 32 ) {
                         *YR = *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++);
                     }
-                    facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (unsigned char)d->SCF_Index_L[Band][2]);
+                    facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (mpc_uint8_t) d->SCF_Index_L[Band][2]);
                     for ( ; n < 36; n++, YL += 32, YR += 32 ) {
                         *YR = *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++);
@@ -496,13 +470,13 @@
                 if (d->Res_R[Band])    // M==0, S!=0
                 {
-                    facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (unsigned char)d->SCF_Index_R[Band][0]);
+                    facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (mpc_uint8_t) d->SCF_Index_R[Band][0]);
                     for ( n = 0; n < 12; n++, YL += 32, YR += 32 ) {
                         *YR = - (*YL = MPC_MULTIPLY_FLOAT_INT(facR,*(R++)));
                     }
-                    facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (unsigned char)d->SCF_Index_R[Band][1]);
+                    facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (mpc_uint8_t) d->SCF_Index_R[Band][1]);
                     for ( ; n < 24; n++, YL += 32, YR += 32 ) {
                         *YR = - (*YL = MPC_MULTIPLY_FLOAT_INT(facR,*(R++)));
                     }
-                    facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (unsigned char)d->SCF_Index_R[Band][2]);
+                    facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (mpc_uint8_t) d->SCF_Index_R[Band][2]);
                     for ( ; n < 36; n++, YL += 32, YR += 32 ) {
                         *YR = - (*YL = MPC_MULTIPLY_FLOAT_INT(facR,*(R++)));
@@ -519,18 +493,18 @@
             if ( d->Res_L [Band] ) {
                 if ( d->Res_R [Band] ) {    // L!=0, R!=0
-                    facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (unsigned char)d->SCF_Index_L[Band][0]);
-                    facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (unsigned char)d->SCF_Index_R[Band][0]);
+                    facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (mpc_uint8_t) d->SCF_Index_L[Band][0]);
+                    facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (mpc_uint8_t) d->SCF_Index_R[Band][0]);
                     for (n = 0; n < 12; n++, YL += 32, YR += 32 ) {
                         *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++);
                         *YR = MPC_MULTIPLY_FLOAT_INT(facR,*R++);
                     }
-                    facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (unsigned char)d->SCF_Index_L[Band][1]);
-                    facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (unsigned char)d->SCF_Index_R[Band][1]);
+                    facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (mpc_uint8_t) d->SCF_Index_L[Band][1]);
+                    facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (mpc_uint8_t) d->SCF_Index_R[Band][1]);
                     for (; n < 24; n++, YL += 32, YR += 32 ) {
                         *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++);
                         *YR = MPC_MULTIPLY_FLOAT_INT(facR,*R++);
                     }
-                    facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (unsigned char)d->SCF_Index_L[Band][2]);
-                    facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (unsigned char)d->SCF_Index_R[Band][2]);
+                    facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (mpc_uint8_t) d->SCF_Index_L[Band][2]);
+                    facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (mpc_uint8_t) d->SCF_Index_R[Band][2]);
                     for (; n < 36; n++, YL += 32, YR += 32 ) {
                         *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++);
@@ -538,15 +512,15 @@
                     }
                 } else {     // L!=0, R==0
-                    facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (unsigned char)d->SCF_Index_L[Band][0]);
+                    facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (mpc_uint8_t) d->SCF_Index_L[Band][0]);
                     for ( n = 0; n < 12; n++, YL += 32, YR += 32 ) {
                         *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++);
                         *YR = 0;
                     }
-                    facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (unsigned char)d->SCF_Index_L[Band][1]);
+                    facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (mpc_uint8_t) d->SCF_Index_L[Band][1]);
                     for ( ; n < 24; n++, YL += 32, YR += 32 ) {
                         *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++);
                         *YR = 0;
                     }
-                    facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (unsigned char)d->SCF_Index_L[Band][2]);
+                    facL = MPC_MULTIPLY_SCF( Cc[d->Res_L[Band]] , (mpc_uint8_t) d->SCF_Index_L[Band][2]);
                     for ( ; n < 36; n++, YL += 32, YR += 32 ) {
                         *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++);
@@ -557,15 +531,15 @@
             else {
                 if ( d->Res_R [Band] ) {    // L==0, R!=0
-                    facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (unsigned char)d->SCF_Index_R[Band][0]);
+                    facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (mpc_uint8_t) d->SCF_Index_R[Band][0]);
                     for ( n = 0; n < 12; n++, YL += 32, YR += 32 ) {
                         *YL = 0;
                         *YR = MPC_MULTIPLY_FLOAT_INT(facR,*R++);
                     }
-                    facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (unsigned char)d->SCF_Index_R[Band][1]);
+                    facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (mpc_uint8_t) d->SCF_Index_R[Band][1]);
                     for ( ; n < 24; n++, YL += 32, YR += 32 ) {
                         *YL = 0;
                         *YR = MPC_MULTIPLY_FLOAT_INT(facR,*R++);
                     }
-                    facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (unsigned char)d->SCF_Index_R[Band][2]);
+                    facR = MPC_MULTIPLY_SCF( Cc[d->Res_R[Band]] , (mpc_uint8_t) d->SCF_Index_R[Band][2]);
                     for ( ; n < 36; n++, YL += 32, YR += 32 ) {
                         *YL = 0;
@@ -582,256 +556,4 @@
 }
 
-#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
-mpc_decoder_read_bitstream_sv6(mpc_decoder *d, mpc_bool_t seeking)
-{
-    mpc_int32_t n,k;
-    mpc_int32_t Max_used_Band=0;
-    const HuffmanTyp *Table;
-    const HuffmanTyp *x1;
-    const HuffmanTyp *x2;
-    mpc_int32_t *L;
-    mpc_int32_t *R;
-    mpc_int32_t *ResL = d->Res_L;
-    mpc_int32_t *ResR = d->Res_R;
-
-    /************************ HEADER **************************/
-    ResL = d->Res_L;
-    ResR = d->Res_R;
-    for (n=0; n <= d->Max_Band; ++n, ++ResL, ++ResR)
-    {
-        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, 14)];
-        if (d->MS_used) {
-            d->MS_Flag[n] = mpc_decoder_bitstream_read(d,  1);
-        }
-        *ResR = Q_res[n][mpc_decoder_huffman_decode(d, Table, 14)];
-
-        // only perform the following procedure up to the maximum non-zero subband
-        if (*ResL || *ResR) Max_used_Band = n;
-    }
-
-    /************************* SCFI-Bundle *****************************/
-    ResL = d->Res_L;
-    ResR = d->Res_R;
-    for (n=0; n<=Max_used_Band; ++n, ++ResL, ++ResR) {
-        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]));
-    }
-
-    /***************************** SCFI ********************************/
-    ResL = d->Res_L;
-    ResR = d->Res_R;
-    L    = d->SCF_Index_L[0];
-    R    = d->SCF_Index_R[0];
-    for (n=0; n <= Max_used_Band; ++n, ++ResL, ++ResR, L+=3, R+=3)
-    {
-        if (*ResL)
-        {
-            /*********** DSCF ************/
-            if (d->DSCF_Flag_L[n]==1)
-            {
-                switch (d->SCFI_L[n])
-                {
-                case 3:
-                    L[0] = L[2] + mpc_decoder_huffman_decode(d,  mpc_table_DSCF_Entropie, 6);
-                    L[1] = L[0];
-                    L[2] = L[1];
-                    break;
-                case 1:
-                    L[0] = L[2] + mpc_decoder_huffman_decode(d,  mpc_table_DSCF_Entropie, 6);
-                    L[1] = L[0] + mpc_decoder_huffman_decode(d,  mpc_table_DSCF_Entropie, 6);
-                    L[2] = L[1];
-                    break;
-                case 2:
-                    L[0] = L[2] + mpc_decoder_huffman_decode(d,  mpc_table_DSCF_Entropie, 6);
-                    L[1] = L[0];
-                    L[2] = L[1] + mpc_decoder_huffman_decode(d,  mpc_table_DSCF_Entropie, 6);
-                    break;
-                case 0:
-                    L[0] = L[2] + mpc_decoder_huffman_decode(d,  mpc_table_DSCF_Entropie, 6);
-                    L[1] = L[0] + mpc_decoder_huffman_decode(d,  mpc_table_DSCF_Entropie, 6);
-                    L[2] = L[1] + mpc_decoder_huffman_decode(d,  mpc_table_DSCF_Entropie, 6);
-                    break;
-                default:
-                    return;
-                }
-                if (L[0] > 1024)
-                    L[0] = 0x8080;
-                if (L[1] > 1024)
-                    L[1] = 0x8080;
-                if (L[2] > 1024)
-                    L[2] = 0x8080;
-            }
-            /************ SCF ************/
-            else
-            {
-                switch (d->SCFI_L[n])
-                {
-                case 3:
-                    L[0] = mpc_decoder_bitstream_read(d,  6);
-                    L[1] = L[0];
-                    L[2] = L[1];
-                    break;
-                case 1:
-                    L[0] = mpc_decoder_bitstream_read(d,  6);
-                    L[1] = mpc_decoder_bitstream_read(d,  6);
-                    L[2] = L[1];
-                    break;
-                case 2:
-                    L[0] = mpc_decoder_bitstream_read(d,  6);
-                    L[1] = L[0];
-                    L[2] = mpc_decoder_bitstream_read(d,  6);
-                    break;
-                case 0:
-                    L[0] = mpc_decoder_bitstream_read(d,  6);
-                    L[1] = mpc_decoder_bitstream_read(d,  6);
-                    L[2] = mpc_decoder_bitstream_read(d,  6);
-                    break;
-                default:
-                    return;
-                }
-            }
-        }
-        if (*ResR)
-        {
-            /*********** DSCF ************/
-            if (d->DSCF_Flag_R[n]==1)
-            {
-                switch (d->SCFI_R[n])
-                {
-                case 3:
-                    R[0] = R[2] + mpc_decoder_huffman_decode(d,  mpc_table_DSCF_Entropie, 6);
-                    R[1] = R[0];
-                    R[2] = R[1];
-                    break;
-                case 1:
-                    R[0] = R[2] + mpc_decoder_huffman_decode(d,  mpc_table_DSCF_Entropie, 6);
-                    R[1] = R[0] + mpc_decoder_huffman_decode(d,  mpc_table_DSCF_Entropie, 6);
-                    R[2] = R[1];
-                    break;
-                case 2:
-                    R[0] = R[2] + mpc_decoder_huffman_decode(d,  mpc_table_DSCF_Entropie, 6);
-                    R[1] = R[0];
-                    R[2] = R[1] + mpc_decoder_huffman_decode(d,  mpc_table_DSCF_Entropie, 6);
-                    break;
-                case 0:
-                    R[0] = R[2] + mpc_decoder_huffman_decode(d,  mpc_table_DSCF_Entropie, 6);
-                    R[1] = R[0] + mpc_decoder_huffman_decode(d,  mpc_table_DSCF_Entropie, 6);
-                    R[2] = R[1] + mpc_decoder_huffman_decode(d,  mpc_table_DSCF_Entropie, 6);
-                    break;
-                default:
-                    return;
-                }
-                if (R[0] > 1024)
-                    R[0] = 0x8080;
-                if (R[1] > 1024)
-                    R[1] = 0x8080;
-                if (R[2] > 1024)
-                    R[2] = 0x8080;
-            }
-            /************ SCF ************/
-            else
-            {
-                switch (d->SCFI_R[n])
-                {
-                case 3:
-                    R[0] = mpc_decoder_bitstream_read(d, 6);
-                    R[1] = R[0];
-                    R[2] = R[1];
-                    break;
-                case 1:
-                    R[0] = mpc_decoder_bitstream_read(d, 6);
-                    R[1] = mpc_decoder_bitstream_read(d, 6);
-                    R[2] = R[1];
-                    break;
-                case 2:
-                    R[0] = mpc_decoder_bitstream_read(d, 6);
-                    R[1] = R[0];
-                    R[2] = mpc_decoder_bitstream_read(d, 6);
-                    break;
-                case 0:
-                    R[0] = mpc_decoder_bitstream_read(d, 6);
-                    R[1] = mpc_decoder_bitstream_read(d, 6);
-                    R[2] = mpc_decoder_bitstream_read(d, 6);
-                    break;
-                default:
-                    return;
-                    break;
-                }
-            }
-        }
-    }
-
-    if (seeking == TRUE)
-        return;
-
-    /**************************** Samples ****************************/
-    ResL = d->Res_L;
-    ResR = d->Res_R;
-    for (n=0; n <= Max_used_Band; ++n, ++ResL, ++ResR)
-    {
-        // setting pointers
-        x1 = mpc_table_SampleHuff[*ResL];
-        x2 = mpc_table_SampleHuff[*ResR];
-        L = d->Q[n].L;
-        R = d->Q[n].R;
-
-        if (x1!=NULL || x2!=NULL)
-            for (k=0; k<36; ++k)
-            {
-                if (x1 != NULL) *L++ = mpc_decoder_huffman_decode(d,  x1, 8);
-                if (x2 != NULL) *R++ = mpc_decoder_huffman_decode(d,  x2, 8);
-            }
-
-        if (*ResL>7 || *ResR>7)
-            for (k=0; k<36; ++k)
-            {
-                if (*ResL>7) *L++ = (mpc_int32_t)mpc_decoder_bitstream_read(d,  Res_bit[*ResL]) - Dc[*ResL];
-                if (*ResR>7) *R++ = (mpc_int32_t)mpc_decoder_bitstream_read(d,  Res_bit[*ResR]) - Dc[*ResR];
-            }
-    }
-}
-#endif //MPC_SUPPORT_SV456
-/****************************************** SV 7 ******************************************/
 void
 mpc_decoder_read_bitstream_sv7(mpc_decoder *d, mpc_bool_t seeking)
@@ -846,5 +568,5 @@
     mpc_int32_t n,k;
     mpc_int32_t Max_used_Band=0;
-    const HuffmanTyp *Table;
+    const mpc_huffman *Table;
     mpc_int32_t idx;
     mpc_int32_t *L   ,*R;
@@ -1246,13 +968,8 @@
 
         if (fwd <= d->DecodedFrames + d->seeking_window) {
-            if (d->StreamVersion >= 7) {
+            if (d->StreamVersion >= 7)
                 mpc_decoder_read_bitstream_sv7(d, TRUE);
-            } else {
-#ifdef MPC_SUPPORT_SV456
-                mpc_decoder_read_bitstream_sv6(d, TRUE);
-#else
+            else
                 return FALSE;
-#endif
-            }
         }
         mpc_decoder_bitstream_jump(d, FwdJumpInfo - mpc_decoder_bits_read(d));
