Index: bmpcdec/branches/zorg/INSTALL
===================================================================
--- /libmpcdec/branches/zorg/INSTALL	(revision 67)
+++ 	(revision )
@@ -1,3 +1,0 @@
-How to install libmpcdec:
-"./configure [--prefix=/usr] && make" as a regular user
-"make install" as root
Index: bmpcdec/branches/zorg/Makefile.am
===================================================================
--- /libmpcdec/branches/zorg/Makefile.am	(revision 67)
+++ 	(revision )
@@ -1,5 +1,0 @@
-## Process this file with automake to produce Makefile.in
-
-AUTOMAKE_OPTIONS = foreign
-
-SUBDIRS = src include
Index: bmpcdec/branches/zorg/autogen.sh
===================================================================
--- /libmpcdec/branches/zorg/autogen.sh	(revision 67)
+++ 	(revision )
@@ -1,7 +1,0 @@
-#! /bin/sh
-
-libtoolize --copy --force
-aclocal
-autoheader
-automake --gnu --add-missing --copy
-autoconf
Index: bmpcdec/branches/zorg/configure.ac
===================================================================
--- /libmpcdec/branches/zorg/configure.ac	(revision 67)
+++ 	(revision )
@@ -1,202 +1,0 @@
-dnl Process this file with autoconf to produce a configure script.
-AC_INIT(src/mpc_decoder.c)
-AC_CONFIG_AUX_DIR(config)
-AM_INIT_AUTOMAKE(libmpcdec,1.2.3)
-AM_CONFIG_HEADER(include/config.h)
-
-AM_PROG_LIBTOOL
-
-CFLAGS="$CFLAGS -O3 -fomit-frame-pointer -fPIC"
-
-AC_C_BIGENDIAN(,CFLAGS="$CFLAGS -DMPC_LITTLE_ENDIAN",)
-
-AC_HEADER_STDC
-AC_CHECK_HEADERS([inttypes.h string.h])
-
-AC_HEADER_STDBOOL
-AC_C_CONST
-AC_C_INLINE
-AC_TYPE_OFF_T
-AC_TYPE_SIZE_T
-AC_CHECK_TYPES([ptrdiff_t])
-
-AC_FUNC_MEMCMP
-AC_CHECK_FUNCS([memmove memset sqrt])
-
-AC_MSG_CHECKING(for int16_t)
-AC_CACHE_VAL(has_int16_t,
-[AC_TRY_RUN([
-int16_t foo;
-int main() {return 0;}
-],
-has_int16_t=yes,
-has_int16_t=no,
-has_int16_t=no
-)])
-AC_MSG_RESULT($has_int16_t)
-
-AC_MSG_CHECKING(for int32_t)
-AC_CACHE_VAL(has_int32_t,
-[AC_TRY_RUN([
-int32_t foo;
-int main() {return 0;}
-],
-has_int32_t=yes,
-has_int32_t=no,
-has_int32_t=no
-)])
-AC_MSG_RESULT($has_int32_t)
-
-AC_MSG_CHECKING(for uint32_t)
-AC_CACHE_VAL(has_uint32_t,
-[AC_TRY_RUN([
-uint32_t foo;
-int main() {return 0;}
-],
-has_uint32_t=yes,
-has_uint32_t=no,
-has_uint32_t=no
-)])
-AC_MSG_RESULT($has_uint32_t)
-
-AC_MSG_CHECKING(for uint16_t)
-AC_CACHE_VAL(has_uint16_t,
-[AC_TRY_RUN([
-uint16_t foo;
-int main() {return 0;}
-],
-has_uint16_t=yes,
-has_uint16_t=no,
-has_uint16_t=no
-)])
-AC_MSG_RESULT($has_uint16_t)
-
-AC_MSG_CHECKING(for u_int32_t)
-AC_CACHE_VAL(has_u_int32_t,
-[AC_TRY_RUN([
-u_int32_t foo;
-int main() {return 0;}
-],
-has_u_int32_t=yes,
-has_u_int32_t=no,
-has_u_int32_t=no
-)])
-AC_MSG_RESULT($has_u_int32_t)
-
-AC_MSG_CHECKING(for u_int16_t)
-AC_CACHE_VAL(has_u_int16_t,
-[AC_TRY_RUN([
-u_int16_t foo;
-int main() {return 0;}
-],
-has_u_int16_t=yes,
-has_u_int16_t=no,
-has_u_int16_t=no
-)])
-AC_MSG_RESULT($has_u_int16_t)
-
-AC_MSG_CHECKING(for int64_t)
-AC_CACHE_VAL(has_int64_t,
-[AC_TRY_RUN([
-int64_t foo;
-int main() {return 0;}
-],
-has_int64_t=yes,
-has_int64_t=no,
-has_int64_t=no
-)])
-AC_MSG_RESULT($has_int64_t)
-
-AC_CHECK_SIZEOF(short)
-AC_CHECK_SIZEOF(int)
-AC_CHECK_SIZEOF(long)
-AC_CHECK_SIZEOF(long long)
-
-
-if test x$has_int16_t = "xyes" ; then
-        SIZE16="int16_t"
-else
-        case 2 in
-                $ac_cv_sizeof_short) SIZE16="short";;
-                $ac_cv_sizeof_int) SIZE16="int";;
-        esac
-fi
-
-if test x$has_int32_t = "xyes" ; then
-        SIZE32="int32_t"
-else
-        case 4 in
-                $ac_cv_sizeof_short) SIZE32="short";;
-                $ac_cv_sizeof_int) SIZE32="int";;
-                $ac_cv_sizeof_long) SIZE32="long";;
-        esac
-fi
-
-if test x$has_uint32_t = "xyes" ; then
-        USIZE32="uint32_t"
-else
-        if test x$has_u_int32_t = "xyes" ; then
-                USIZE32="u_int32_t"
-        else
-                case 4 in
-                        $ac_cv_sizeof_short) USIZE32="unsigned short";;
-                        $ac_cv_sizeof_int) USIZE32="unsigned int";;
-                        $ac_cv_sizeof_long) USIZE32="unsigned long";;
-                esac
-        fi
-fi
-
-if test x$has_uint16_t = "xyes" ; then
-        USIZE16="uint16_t"
-else
-        if test x$has_u_int16_t = "xyes" ; then
-                USIZE16="u_int16_t"
-        else
-                case 2 in
-                        $ac_cv_sizeof_short) USIZE16="unsigned short";;
-                        $ac_cv_sizeof_int) USIZE16="unsigned int";;
-                        $ac_cv_sizeof_long) USIZE16="unsigned long";;
-                esac
-        fi
-fi
-
-if test x$has_int64_t = "xyes" ; then
-        SIZE64="int64_t"
-else
-case 8 in
-        $ac_cv_sizeof_int) SIZE64="int";;
-        $ac_cv_sizeof_long) SIZE64="long";;
-        $ac_cv_sizeof_long_long) SIZE64="long long";;
-esac
-fi
-
-if test -z "$SIZE16"; then
-        AC_MSG_ERROR(No 16 bit type found on this platform!)
-fi
-if test -z "$USIZE16"; then
-        AC_MSG_ERROR(No unsigned 16 bit type found on this platform!)
-fi
-if test -z "$SIZE32"; then
-        AC_MSG_ERROR(No 32 bit type found on this platform!)
-fi
-if test -z "$USIZE32"; then
-        AC_MSG_ERROR(No unsigned 32 bit type found on this platform!)
-fi
-if test -z "$SIZE64"; then
-        AC_MSG_WARN(No 64 bit type found on this platform!)
-fi
-
-dnl Make substitutions
-
-AC_SUBST(VERSION)
-AC_SUBST(LIBTOOL_DEPS)
-AC_SUBST(SIZE16)
-AC_SUBST(USIZE16)
-AC_SUBST(SIZE32)
-AC_SUBST(USIZE32)
-AC_SUBST(SIZE64)
-AC_SUBST(OPT)
-AC_SUBST(LIBS)
-
-AC_OUTPUT(Makefile src/Makefile include/Makefile include/mpcdec/config_types.h)
-AC_MSG_RESULT([=> libmpcdec $VERSION configured successfully])
Index: /libmpcdec/branches/zorg/docs/mainpage.txt
===================================================================
--- /libmpcdec/branches/zorg/docs/mainpage.txt	(revision 68)
+++ /libmpcdec/branches/zorg/docs/mainpage.txt	(revision 68)
@@ -0,0 +1,38 @@
+/**
+   \mainpage libmpcdec documentation
+
+   \section whats what is libmpcdec
+   libmpcdec is a library that decodes musepack compressed audio data.  Musepack
+   is a free, high performance, high quality lossy audio compression codec.  For
+   more information on musepack visit http://www.musepack.net.
+
+   \section using using libmpcdec
+
+   Using libmpcdec is very straightforward.  There are typically four things you must
+   do to use libmpcdec in your application.
+
+   \subsection step1 step 1: implement an mpc_reader to provide raw data to the decoder library
+   The role of the mpc_reader is to provide raw mpc stream data to the mpc decoding library.
+   This data can come from a file, a network socket, or any other source you wish.
+
+   See the documentation of 
+   \link mpc_reader_t mpc_reader \endlink 
+   for more information.
+
+   \subsection step2 step2: read the streaminfo properties structure from the stream
+   This is a simple matter of calling the streaminfo_init() and streaminfo_read() functions, 
+   supplying your mpc_reader as a source of raw data.  This reads the stream properties header from the 
+   mpc stream.  This information will be used to prime the decoder for decoding in
+   the next step.
+
+   \subsection step3 step 3: initialize an mpc_decoder with your mpc_reader source
+   This is just a matter of calling the mpc_decoder_setup() and mpc_decoder_initialize()
+   functions with your mpc_decoder, mpc_reader data source and streaminfo information.
+
+   \subsection step4 step 4: iteratively read raw sample data from the mpc decoder
+   Once you've initialized the decoding library you just iteratively call the 
+   mpc_decoder_decode routine until it indicates that the entire stream has been read.
+
+   For a simple example of all of these steps see the sample application distributed with
+   libmpcdec in src/sample.cpp.
+*/
Index: bmpcdec/branches/zorg/include/Makefile.am
===================================================================
--- /libmpcdec/branches/zorg/include/Makefile.am	(revision 67)
+++ 	(revision )
@@ -1,13 +1,0 @@
-## Process this file with automake to produce Makefile.in
-
-AUTOMAKE_OPTIONS = foreign
-
-nobase_include_HEADERS = \
-	mpcdec/config_types.h \
-	mpcdec/decoder.h \
-	mpcdec/huffman.h \
-	mpcdec/math.h \
-	mpcdec/mpcdec.h \
-	mpcdec/reader.h \
-	mpcdec/requant.h \
-	mpcdec/streaminfo.h
Index: bmpcdec/branches/zorg/include/config.h.in
===================================================================
--- /libmpcdec/branches/zorg/include/config.h.in	(revision 67)
+++ 	(revision )
@@ -1,104 +1,0 @@
-/* include/config.h.in.  Generated from configure.ac by autoheader.  */
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#undef HAVE_DLFCN_H
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
-
-/* Define to 1 if you have the `memmove' function. */
-#undef HAVE_MEMMOVE
-
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* Define to 1 if you have the `memset' function. */
-#undef HAVE_MEMSET
-
-/* Define to 1 if the system has the type `ptrdiff_t'. */
-#undef HAVE_PTRDIFF_T
-
-/* Define to 1 if you have the `sqrt' function. */
-#undef HAVE_SQRT
-
-/* Define to 1 if stdbool.h conforms to C99. */
-#undef HAVE_STDBOOL_H
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
-
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#undef HAVE_STRING_H
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#undef HAVE_SYS_STAT_H
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#undef HAVE_SYS_TYPES_H
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
-
-/* Define to 1 if the system has the type `_Bool'. */
-#undef HAVE__BOOL
-
-/* Name of package */
-#undef PACKAGE
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
-/* The size of a `int', as computed by sizeof. */
-#undef SIZEOF_INT
-
-/* The size of a `long', as computed by sizeof. */
-#undef SIZEOF_LONG
-
-/* The size of a `long long', as computed by sizeof. */
-#undef SIZEOF_LONG_LONG
-
-/* The size of a `short', as computed by sizeof. */
-#undef SIZEOF_SHORT
-
-/* Define to 1 if you have the ANSI C header files. */
-#undef STDC_HEADERS
-
-/* Version number of package */
-#undef VERSION
-
-/* Define to 1 if your processor stores words with the most significant byte
-   first (like Motorola and SPARC, unlike Intel and VAX). */
-#undef WORDS_BIGENDIAN
-
-/* Define to empty if `const' does not conform to ANSI C. */
-#undef const
-
-/* Define to `__inline__' or `__inline' if that's what the C compiler
-   calls it, or to nothing if 'inline' is not supported under any name.  */
-#ifndef __cplusplus
-#undef inline
-#endif
-
-/* Define to `long' if <sys/types.h> does not define. */
-#undef off_t
-
-/* Define to `unsigned' if <sys/types.h> does not define. */
-#undef size_t
Index: bmpcdec/branches/zorg/include/mainpage.h
===================================================================
--- /libmpcdec/branches/zorg/include/mainpage.h	(revision 67)
+++ 	(revision )
@@ -1,38 +1,0 @@
-/**
-   \mainpage libmpcdec documentation
-
-   \section whats what is libmpcdec
-   libmpcdec is a library that decodes musepack compressed audio data.  Musepack
-   is a free, high performance, high quality lossy audio compression codec.  For
-   more information on musepack visit http://www.musepack.net.
-
-   \section using using libmpcdec
-
-   Using libmpcdec is very straightforward.  There are typically four things you must
-   do to use libmpcdec in your application.
-
-   \subsection step1 step 1: implement an mpc_reader to provide raw data to the decoder library
-   The role of the mpc_reader is to provide raw mpc stream data to the mpc decoding library.
-   This data can come from a file, a network socket, or any other source you wish.
-
-   See the documentation of 
-   \link mpc_reader_t mpc_reader \endlink 
-   for more information.
-
-   \subsection step2 step2: read the streaminfo properties structure from the stream
-   This is a simple matter of calling the streaminfo_init() and streaminfo_read() functions, 
-   supplying your mpc_reader as a source of raw data.  This reads the stream properties header from the 
-   mpc stream.  This information will be used to prime the decoder for decoding in
-   the next step.
-
-   \subsection step3 step 3: initialize an mpc_decoder with your mpc_reader source
-   This is just a matter of calling the mpc_decoder_setup() and mpc_decoder_initialize()
-   functions with your mpc_decoder, mpc_reader data source and streaminfo information.
-
-   \subsection step4 step 4: iteratively read raw sample data from the mpc decoder
-   Once you've initialized the decoding library you just iteratively call the 
-   mpc_decoder_decode routine until it indicates that the entire stream has been read.
-
-   For a simple example of all of these steps see the sample application distributed with
-   libmpcdec in src/sample.cpp.
-*/
Index: bmpcdec/branches/zorg/include/mpcdec/config_types.h.in
===================================================================
--- /libmpcdec/branches/zorg/include/mpcdec/config_types.h.in	(revision 67)
+++ 	(revision )
@@ -1,48 +1,0 @@
-/*
-  Copyright (c) 2005, The Musepack Development Team
-  All rights reserved.
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions are
-  met:
-
-  * Redistributions of source code must retain the above copyright
-  notice, this list of conditions and the following disclaimer.
-
-  * Redistributions in binary form must reproduce the above
-  copyright notice, this list of conditions and the following
-  disclaimer in the documentation and/or other materials provided
-  with the distribution.
-
-  * Neither the name of the The Musepack Development Team nor the
-  names of its contributors may be used to endorse or promote
-  products derived from this software without specific prior
-  written permission.
-
-  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef __MUSEPACK_CONFIG_TYPES_H__
-#define __MUSEPACK_CONFIG_TYPES_H__
-
-typedef unsigned char mpc_bool_t;
-#define TRUE  1
-#define FALSE 0
-
-typedef @SIZE16@ mpc_int16_t;
-typedef @USIZE16@ mpc_uint16_t;
-typedef @SIZE32@ mpc_int32_t;
-typedef @USIZE32@ mpc_uint32_t;
-typedef @SIZE64@ mpc_int64_t;
-
-#endif // __MUSEPACK_CONFIG_TYPES_H__
Index: bmpcdec/branches/zorg/include/mpcdec/config_win32.h
===================================================================
--- /libmpcdec/branches/zorg/include/mpcdec/config_win32.h	(revision 67)
+++ 	(revision )
@@ -1,52 +1,0 @@
-/*
-  Copyright (c) 2005, The Musepack Development Team
-  All rights reserved.
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions are
-  met:
-
-  * Redistributions of source code must retain the above copyright
-  notice, this list of conditions and the following disclaimer.
-
-  * Redistributions in binary form must reproduce the above
-  copyright notice, this list of conditions and the following
-  disclaimer in the documentation and/or other materials provided
-  with the distribution.
-
-  * Neither the name of the The Musepack Development Team nor the
-  names of its contributors may be used to endorse or promote
-  products derived from this software without specific prior
-  written permission.
-
-  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef __MUSEPACK_CONFIG_WIN32_H__
-#define __MUSEPACK_CONFIG_WIN32_H__
-
-typedef unsigned char mpc_bool_t;
-#define TRUE  1
-#define FALSE 0
-
-typedef __int8           mpc_int8_t;
-typedef unsigned __int8  mpc_uint8_t;
-typedef __int16          mpc_int16_t;
-typedef unsigned __int16 mpc_uint16_t;
-typedef __int32          mpc_int32_t;
-typedef unsigned __int32 mpc_uint32_t;
-typedef __int64          mpc_int64_t;
-
-#define MPC_LITTLE_ENDIAN
-
-#endif // __MUSEPACK_CONFIG_WIN32_H__
Index: bmpcdec/branches/zorg/include/mpcdec/decoder.h
===================================================================
--- /libmpcdec/branches/zorg/include/mpcdec/decoder.h	(revision 67)
+++ 	(revision )
@@ -1,124 +1,0 @@
-/*
-  Copyright (c) 2005, The Musepack Development Team
-  All rights reserved.
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions are
-  met:
-
-  * Redistributions of source code must retain the above copyright
-  notice, this list of conditions and the following disclaimer.
-
-  * Redistributions in binary form must reproduce the above
-  copyright notice, this list of conditions and the following
-  disclaimer in the documentation and/or other materials provided
-  with the distribution.
-
-  * Neither the name of the The Musepack Development Team nor the
-  names of its contributors may be used to endorse or promote
-  products derived from this software without specific prior
-  written permission.
-
-  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/// \file decoder.h
-
-#ifndef _mpcdec_decoder_h_
-#define _mpcdec_decoder_h_
-
-#include "huffman.h"
-#include "math.h"
-#include "mpcdec.h"
-#include "reader.h"
-#include "streaminfo.h"
-
-#define MPC_SUPPORT_SV456
-
-#define SEEKING_TABLE_SIZE  256u
-// set it to SLOW_SEEKING_WINDOW to not use fast seeking
-#define FAST_SEEKING_WINDOW 32
-// set it to FAST_SEEKING_WINDOW to only use fast seeking
-#define SLOW_SEEKING_WINDOW 0x80000000
-
-enum {
-    MPC_V_MEM = 2304,
-    MPC_DECODER_MEMSIZE = 16384,  // overall buffer size
-};
-
-typedef struct {
-    mpc_int32_t  L [36];
-    mpc_int32_t  R [36];
-} QuantTyp;
-
-typedef struct mpc_decoder_t {
-    mpc_reader *r;
-
-    /// @name internal state variables
-    //@{
-
-    mpc_uint32_t  dword; /// currently decoded 32bit-word
-    mpc_uint32_t  pos;   /// bit-position within dword
-    mpc_uint32_t  Speicher[MPC_DECODER_MEMSIZE]; /// read-buffer
-    mpc_uint32_t  Zaehler; /// actual index within read-buffer
-
-    mpc_uint32_t  samples_to_skip;
-
-    mpc_uint32_t  DecodedFrames;
-    mpc_uint32_t  OverallFrames;
-    mpc_int32_t   SampleRate;                 // Sample frequency
-
-    mpc_uint32_t  StreamVersion;              // version of bitstream
-    mpc_int32_t   Max_Band;
-    mpc_uint32_t  MPCHeaderPos;               // AB: needed to support ID3v2
-
-    mpc_uint32_t  FrameWasValid;
-    mpc_uint32_t  MS_used;                    // MS-coding used ?
-    mpc_uint32_t  TrueGaplessPresent;
-
-    mpc_uint32_t  WordsRead;                  // counts amount of decoded dwords
-
-    // randomizer state variables
-    mpc_uint32_t  __r1; 
-    mpc_uint32_t  __r2; 
-
-    // seeking
-    mpc_uint32_t  seeking_table[SEEKING_TABLE_SIZE];
-    mpc_uint32_t  seeking_pwr;                // distance between 2 frames in seeking_table = 2^seeking_pwr
-    mpc_uint32_t  seeking_table_frames;       // last frame in seaking table
-    mpc_uint32_t  seeking_window;             // number of frames to look for scalefactors
-
-    mpc_int32_t   SCF_Index_L [32] [3];
-    mpc_int32_t   SCF_Index_R [32] [3];       // holds scalefactor-indices
-    QuantTyp      Q [32];                     // holds quantized samples
-    mpc_int32_t   Res_L [32];
-    mpc_int32_t   Res_R [32];                 // holds the chosen quantizer for each subband
-    mpc_bool_t    DSCF_Flag_L [32];
-    mpc_bool_t    DSCF_Flag_R [32];           // differential SCF used?
-    mpc_int32_t   SCFI_L [32];
-    mpc_int32_t   SCFI_R [32];                // describes order of transmitted SCF
-    mpc_bool_t    MS_Flag[32];                // MS used?
-#ifdef MPC_FIXED_POINT
-    unsigned char SCF_shift[256];
-#endif
-
-    MPC_SAMPLE_FORMAT V_L[MPC_V_MEM + 960];
-    MPC_SAMPLE_FORMAT V_R[MPC_V_MEM + 960];
-    MPC_SAMPLE_FORMAT Y_L[36][32];
-    MPC_SAMPLE_FORMAT Y_R[36][32];
-    MPC_SAMPLE_FORMAT SCF[256]; ///< holds adapted scalefactors (for clipping prevention)
-    //@}
-
-} mpc_decoder;
-
-#endif // _mpc_decoder_h
Index: bmpcdec/branches/zorg/include/mpcdec/huffman.h
===================================================================
--- /libmpcdec/branches/zorg/include/mpcdec/huffman.h	(revision 67)
+++ 	(revision )
@@ -1,58 +1,0 @@
-/*
-  Copyright (c) 2005, The Musepack Development Team
-  All rights reserved.
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions are
-  met:
-
-  * Redistributions of source code must retain the above copyright
-  notice, this list of conditions and the following disclaimer.
-
-  * Redistributions in binary form must reproduce the above
-  copyright notice, this list of conditions and the following
-  disclaimer in the documentation and/or other materials provided
-  with the distribution.
-
-  * Neither the name of the The Musepack Development Team nor the
-  names of its contributors may be used to endorse or promote
-  products derived from this software without specific prior
-  written permission.
-
-  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/// \file huffman.h
-/// Data structures and functions for huffman coding.
-
-#ifndef _mpcdec_huffman_h_
-#define _mpcdec_huffman_h_
-
-#ifndef WIN32
-#include "mpcdec/config_types.h"
-#else
-#include "mpcdec/config_win32.h"
-#endif
-
-#include "decoder.h"
-
-struct mpc_decoder_t; // forward declare to break circular dependencies
-
-/// Huffman table entry.
-typedef struct huffman_type_t {
-    mpc_uint32_t  Code;
-    mpc_uint16_t  Length;
-    mpc_int16_t   Value;
-} HuffmanTyp;
-
-#endif // _mpcdec_huffman_h_
Index: bmpcdec/branches/zorg/include/mpcdec/internal.h
===================================================================
--- /libmpcdec/branches/zorg/include/mpcdec/internal.h	(revision 67)
+++ 	(revision )
@@ -1,65 +1,0 @@
-/*
-  Copyright (c) 2005, The Musepack Development Team
-  All rights reserved.
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions are
-  met:
-
-  * Redistributions of source code must retain the above copyright
-  notice, this list of conditions and the following disclaimer.
-
-  * Redistributions in binary form must reproduce the above
-  copyright notice, this list of conditions and the following
-  disclaimer in the documentation and/or other materials provided
-  with the distribution.
-
-  * Neither the name of the The Musepack Development Team nor the
-  names of its contributors may be used to endorse or promote
-  products derived from this software without specific prior
-  written permission.
-
-  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/// \file internal.h
-/// Definitions and structures used only internally by the libmpcdec.
-
-#ifndef _mpcdec_internal_h
-#define _mpcdec_internal_h
-
-
-enum {
-    MPC_DECODER_SYNTH_DELAY = 481
-};
-
-/// Big/little endian 32 bit byte swapping routine.
-static __inline
-mpc_uint32_t mpc_swap32(mpc_uint32_t val) {
-    return (((val & 0xff000000) >> 24) | ((val & 0x00ff0000) >> 8) |
-            ((val & 0x0000ff00) <<  8) | ((val & 0x000000ff) << 24));
-}
-
-/// Searches for a ID3v2-tag and reads the length (in bytes) of it.
-/// \param reader supplying raw stream data
-/// \return size of tag, in bytes
-/// \return -1 on errors of any kind
-mpc_int32_t JumpID3v2(mpc_reader* fp);
-
-/// helper functions used by multiple files
-mpc_uint32_t mpc_random_int(mpc_decoder *d); // in synth_filter.c
-void mpc_decoder_initialisiere_quantisierungstabellen(mpc_decoder *d, double scale_factor);
-void mpc_decoder_synthese_filter_float(mpc_decoder *d, MPC_SAMPLE_FORMAT* OutData);
-
-#endif // _mpcdec_internal_h
-
Index: bmpcdec/branches/zorg/include/mpcdec/math.h
===================================================================
--- /libmpcdec/branches/zorg/include/mpcdec/math.h	(revision 67)
+++ 	(revision )
@@ -1,144 +1,0 @@
-/*
-  Copyright (c) 2005, The Musepack Development Team
-  All rights reserved.
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions are
-  met:
-
-  * Redistributions of source code must retain the above copyright
-  notice, this list of conditions and the following disclaimer.
-
-  * Redistributions in binary form must reproduce the above
-  copyright notice, this list of conditions and the following
-  disclaimer in the documentation and/or other materials provided
-  with the distribution.
-
-  * Neither the name of the The Musepack Development Team nor the
-  names of its contributors may be used to endorse or promote
-  products derived from this software without specific prior
-  written permission.
-
-  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/// \file math.h
-/// Libmpcdec internal math routines.  
-
-#ifndef _mpcdec_math_h_
-#define _mpcdec_math_h_
-
-//#define MPC_FIXED_POINT
-
-#define MPC_FIXED_POINT_SHIFT 16
-
-#ifdef MPC_FIXED_POINT
-
-
-#ifdef _WIN32_WCE
-
-#include <cmnintrin.h>
-
-#define MPC_HAVE_MULHIGH
-
-#endif
-
-
-#define MPC_FIXED_POINT_SCALE_SHIFT (MPC_FIXED_POINT_SHIFT + MPC_FIXED_POINT_FRACTPART)
-#define MPC_FIXED_POINT_SCALE (1 << (MPC_FIXED_POINT_SCALE_SHIFT - 1))
-
-
-//in fixedpoint mode, results in decode output buffer are in -MPC_FIXED_POINT_SCALE ... MPC_FIXED_POINT_SCALE range
-
-#define MPC_FIXED_POINT_FRACTPART 14
-typedef mpc_int32_t MPC_SAMPLE_FORMAT;
-
-typedef mpc_int64_t MPC_SAMPLE_FORMAT_MULTIPLY;
-
-#define MAKE_MPC_SAMPLE(X) (MPC_SAMPLE_FORMAT)((double)(X) * (double)(((mpc_int64_t)1)<<MPC_FIXED_POINT_FRACTPART))
-#define MAKE_MPC_SAMPLE_EX(X,Y) (MPC_SAMPLE_FORMAT)((double)(X) * (double)(((mpc_int64_t)1)<<(Y)))
-
-#define MPC_MULTIPLY_NOTRUNCATE(X,Y) \
-	(((MPC_SAMPLE_FORMAT_MULTIPLY)(X) * (MPC_SAMPLE_FORMAT_MULTIPLY)(Y)) >> MPC_FIXED_POINT_FRACTPART)
-
-#define MPC_MULTIPLY_EX_NOTRUNCATE(X,Y,Z) \
-	(((MPC_SAMPLE_FORMAT_MULTIPLY)(X) * (MPC_SAMPLE_FORMAT_MULTIPLY)(Y)) >> (Z))
-
-#ifdef _DEBUG
-static inline MPC_SAMPLE_FORMAT MPC_MULTIPLY(MPC_SAMPLE_FORMAT item1,MPC_SAMPLE_FORMAT item2)
-{
-	MPC_SAMPLE_FORMAT_MULTIPLY temp = MPC_MULTIPLY_NOTRUNCATE(item1,item2);
-	assert(temp == (MPC_SAMPLE_FORMAT_MULTIPLY)(MPC_SAMPLE_FORMAT)temp);
-	return (MPC_SAMPLE_FORMAT)temp;
-}
-
-static inline MPC_SAMPLE_FORMAT MPC_MULTIPLY_EX(MPC_SAMPLE_FORMAT item1,MPC_SAMPLE_FORMAT item2,unsigned shift)
-{
-	MPC_SAMPLE_FORMAT_MULTIPLY temp = MPC_MULTIPLY_EX_NOTRUNCATE(item1,item2,shift);
-	assert(temp == (MPC_SAMPLE_FORMAT_MULTIPLY)(MPC_SAMPLE_FORMAT)temp);
-	return (MPC_SAMPLE_FORMAT)temp;
-}
-
-#else
-
-#define MPC_MULTIPLY(X,Y) ((MPC_SAMPLE_FORMAT)MPC_MULTIPLY_NOTRUNCATE(X,Y))
-#define MPC_MULTIPLY_EX(X,Y,Z) ((MPC_SAMPLE_FORMAT)MPC_MULTIPLY_EX_NOTRUNCATE(X,Y,Z))
-
-#endif
-
-#ifdef MPC_HAVE_MULHIGH
-#define MPC_MULTIPLY_FRACT(X,Y) _MulHigh(X,Y)
-#else
-#define MPC_MULTIPLY_FRACT(X,Y) MPC_MULTIPLY_EX(X,Y,32)
-#endif
-
-#define MPC_MAKE_FRACT_CONST(X) (MPC_SAMPLE_FORMAT)((X) * (double)(((mpc_int64_t)1)<<32) )
-#define MPC_MULTIPLY_FRACT_CONST(X,Y) MPC_MULTIPLY_FRACT(X,MPC_MAKE_FRACT_CONST(Y))
-#define MPC_MULTIPLY_FRACT_CONST_FIX(X,Y,Z) ( MPC_MULTIPLY_FRACT(X,MPC_MAKE_FRACT_CONST( Y / (1<<(Z)) )) << (Z) )
-#define MPC_MULTIPLY_FRACT_CONST_SHR(X,Y,Z) MPC_MULTIPLY_FRACT(X,MPC_MAKE_FRACT_CONST( Y / (1<<(Z)) ))
-
-#define MPC_MULTIPLY_FLOAT_INT(X,Y) ((X)*(Y))
-#define MPC_SCALE_CONST(X,Y,Z) MPC_MULTIPLY_EX(X,MAKE_MPC_SAMPLE_EX(Y,Z),(Z))
-#define MPC_SCALE_CONST_SHL(X,Y,Z,S) MPC_MULTIPLY_EX(X,MAKE_MPC_SAMPLE_EX(Y,Z),(Z)-(S))
-#define MPC_SCALE_CONST_SHR(X,Y,Z,S) MPC_MULTIPLY_EX(X,MAKE_MPC_SAMPLE_EX(Y,Z),(Z)+(S))
-#define MPC_SHR(X,Y) ((X)>>(Y))
-#define MPC_SHL(X,Y) ((X)<<(Y))
-
-#else
-
-//in floating-point mode, decoded samples are in -1...1 range
-
-typedef float MPC_SAMPLE_FORMAT;
-
-#define MAKE_MPC_SAMPLE(X) ((MPC_SAMPLE_FORMAT)(X))
-#define MAKE_MPC_SAMPLE_EX(X,Y) ((MPC_SAMPLE_FORMAT)(X))
-
-#define MPC_MULTIPLY_FRACT(X,Y) ((X)*(Y))
-#define MPC_MAKE_FRACT_CONST(X) (X)
-#define MPC_MULTIPLY_FRACT_CONST(X,Y) MPC_MULTPLY_FRACT(X,MPC_MAKE_FRACT_CONST(Y))
-#define MPC_MULTIPLY_FRACT_CONST_SHR(X,Y,Z) MPC_MULTIPLY_FRACT(X,MPC_MAKE_FRACT_CONST( Y ))
-#define MPC_MULTIPLY_FRACT_CONST_FIX(X,Y,Z) MPC_MULTIPLY_FRACT(X,MPC_MAKE_FRACT_CONST( Y ))
-
-#define MPC_MULTIPLY_FLOAT_INT(X,Y) ((X)*(Y))
-#define MPC_MULTIPLY(X,Y) ((X)*(Y))
-#define MPC_MULTIPLY_EX(X,Y,Z) ((X)*(Y))
-#define MPC_SCALE_CONST(X,Y,Z) ((X)*(Y))
-#define MPC_SCALE_CONST_SHL(X,Y,Z,S) ((X)*(Y))
-#define MPC_SCALE_CONST_SHR(X,Y,Z,S) ((X)*(Y))
-#define MPC_SHR(X,Y) (X)
-#define MPC_SHL(X,Y) (X)
-
-#endif
-
-#endif // _mpcdec_math_h_
-
Index: /libmpcdec/branches/zorg/include/mpcdec/mpc_types.h
===================================================================
--- /libmpcdec/branches/zorg/include/mpcdec/mpc_types.h	(revision 68)
+++ /libmpcdec/branches/zorg/include/mpcdec/mpc_types.h	(revision 68)
@@ -0,0 +1,96 @@
+/*
+  Copyright (c) 2005, The Musepack Development Team
+  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions are
+  met:
+
+  * Redistributions of source code must retain the above copyright
+  notice, this list of conditions and the following disclaimer.
+
+  * Redistributions in binary form must reproduce the above
+  copyright notice, this list of conditions and the following
+  disclaimer in the documentation and/or other materials provided
+  with the distribution.
+
+  * Neither the name of the The Musepack Development Team nor the
+  names of its contributors may be used to endorse or promote
+  products derived from this software without specific prior
+  written permission.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+#ifndef _MPC_TYPES_H_
+#define _MPC_TYPES_H_
+#ifdef WIN32
+#pragma once
+#endif
+
+#include <stdlib.h>
+#include <memory.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef WIN32
+typedef __int8           mpc_int8_t;
+typedef unsigned __int8  mpc_uint8_t;
+typedef __int16          mpc_int16_t;
+typedef unsigned __int16 mpc_uint16_t;
+typedef __int32          mpc_int32_t;
+typedef unsigned __int32 mpc_uint32_t;
+typedef __int64          mpc_int64_t;
+#define mpc_inline __inline
+#define MPC_LITTLE_ENDIAN
+#else
+#include <stdint.h>
+typedef int8_t   mpc_int8_t;
+typedef uint8_t  mpc_uint8_t;
+typedef int16_t  mpc_int16_t;
+typedef uint16_t mpc_uint16_t;
+typedef int32_t  mpc_int32_t;
+typedef uint32_t mpc_uint32_t;
+typedef int64_t  mpc_int64_t;
+#define mpc_inline inline
+#endif
+
+/// Libmpcdec error codes
+typedef enum mpc_status {
+    MPC_STATUS_OK        =  0,
+    MPC_STATUS_FILE      = -1,
+    MPC_STATUS_SV7BETA   = -2,
+    MPC_STATUS_CBR       = -3,
+    MPC_STATUS_IS        = -4,
+    MPC_STATUS_BLOCKSIZE = -5,
+    MPC_STATUS_INVALIDSV = -6
+} mpc_status;
+
+#ifdef MPC_FIXED_POINT
+typedef mpc_int32_t MPC_SAMPLE_FORMAT;
+#else
+typedef float       MPC_SAMPLE_FORMAT;
+#endif
+
+typedef mpc_uint8_t mpc_bool_t;
+
+enum {
+    FALSE = 0,
+    TRUE  = !FALSE
+};
+
+#ifdef __cplusplus
+}
+#endif
+#endif
Index: /libmpcdec/branches/zorg/include/mpcdec/mpcdec.h
===================================================================
--- /libmpcdec/branches/zorg/include/mpcdec/mpcdec.h	(revision 67)
+++ /libmpcdec/branches/zorg/include/mpcdec/mpcdec.h	(revision 68)
@@ -32,10 +32,13 @@
   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
-
 /// \file mpcdec.h
 /// Top level include file for libmpcdec.
+#ifndef _MPCDEC_H_
+#define _MPCDEC_H_
+#ifdef WIN32
+#pragma once
+#endif
 
-#ifndef _mpcdec_h_
-#define _mpcdec_h_
+#include "streaminfo.h"
 
 #ifdef __cplusplus
@@ -43,73 +46,30 @@
 #endif
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifndef WIN32
-#include "mpcdec/config_types.h"
-#else
-#include "mpcdec/config_win32.h"
-#endif
-
-#include "decoder.h"
-#include "math.h"
-#include "reader.h"
-#include "streaminfo.h"
-    
-enum {
-    MPC_FRAME_LENGTH = (36 * 32),    /// samples per mpc frame
-    MPC_DECODER_BUFFER_LENGTH = 4 * MPC_FRAME_LENGTH /// required buffer size for decoder
-};
-
-// error codes
-#define ERROR_CODE_OK            0
-#define ERROR_CODE_FILE         -1
-#define ERROR_CODE_SV7BETA       1
-#define ERROR_CODE_CBR           2
-#define ERROR_CODE_IS            3
-#define ERROR_CODE_BLOCKSIZE     4
-#define ERROR_CODE_INVALIDSV     5
-
-/// Initializes a streaminfo structure.
-/// \param si streaminfo structure to initialize
-void mpc_streaminfo_init(mpc_streaminfo *si);
-
-/// Reads streaminfo header from the mpc stream supplied by r.
-/// \param si streaminfo pointer to which info will be written
-/// \param r stream reader to supply raw data
-/// \return error code
-mpc_int32_t mpc_streaminfo_read(mpc_streaminfo *si, mpc_reader *r);
-
-/// Gets length of stream si, in seconds.
-/// \return length of stream in seconds
-double mpc_streaminfo_get_length(mpc_streaminfo *si);
-
-/// Returns length of stream si, in samples.
-/// \return length of stream in samples
-mpc_int64_t mpc_streaminfo_get_length_samples(mpc_streaminfo *si);
+typedef struct mpc_decoder_t mpc_decoder;
 
 /// Sets up decoder library.
 /// Call this first when preparing to decode an mpc stream.
-/// \param r reader that will supply raw data to the decoder
-void mpc_decoder_setup(mpc_decoder *d, mpc_reader *r);
+/// \param p_reader reader that will supply raw data to the decoder
+void mpc_decoder_setup(mpc_decoder *p_dec, mpc_reader *p_reader);
 
 /// Initializes mpc decoder with the supplied stream info parameters.
-/// Call this next after calling mpc_decoder_setup.
 /// \param si streaminfo structure indicating format of source stream
 /// \return TRUE if decoder was initalized successfully, FALSE otherwise    
-mpc_bool_t mpc_decoder_initialize(mpc_decoder *d, mpc_streaminfo *si);
+mpc_status mpc_init_decoder(mpc_decoder **p_dec, mpc_streaminfo *si);
+
+/// Releases input mpc decoder 
+void mpc_exit_decoder(mpc_decoder *p_dec);
 
 /// Call this next after calling mpc_decoder_setup.
 /// \param si streaminfo structure indicating format of source stream
 /// \param fast_seeking boolean 0 = use fast seeking if safe, 1 = force fast seeking
-void mpc_decoder_set_seeking(mpc_decoder *d, mpc_streaminfo *si, mpc_bool_t fast_seeking);
+void mpc_decoder_set_seeking(mpc_decoder *p_dec, mpc_streaminfo *si, mpc_bool_t fast_seeking);
 
-void mpc_decoder_set_streaminfo(mpc_decoder *d, mpc_streaminfo *si);
+void mpc_decoder_set_streaminfo(mpc_decoder *p_dec, mpc_streaminfo *si);
 
 /// Sets decoder sample scaling factor.  All decoded samples will be multiplied
 /// by this factor.
 /// \param scale_factor multiplicative scaling factor
-void mpc_decoder_scale_output(mpc_decoder *d, double scale_factor);
+void mpc_decoder_scale_output(mpc_decoder *p_dec, double scale_factor);
 
 /// Actually reads data from previously initialized stream.  Call
@@ -122,24 +82,23 @@
 /// \return > 0 to indicate the number of bytes that were actually read from the stream.
 mpc_uint32_t mpc_decoder_decode(
-    mpc_decoder *d,
+    mpc_decoder       *p_dec,
     MPC_SAMPLE_FORMAT *buffer, 
-    mpc_uint32_t *vbr_update_acc, 
-    mpc_uint32_t *vbr_update_bits);
+    mpc_uint32_t      *vbr_update_acc, 
+    mpc_uint32_t      *vbr_update_bits);
 
 mpc_uint32_t mpc_decoder_decode_frame(
-    mpc_decoder *d,
-    mpc_uint32_t *in_buffer,
-    mpc_uint32_t in_len,
+    mpc_decoder       *p_dec,
+    mpc_uint32_t      *in_buffer,
+    mpc_uint32_t      in_len,
     MPC_SAMPLE_FORMAT *out_buffer);
 
 /// Seeks to the specified sample in the source stream.
-mpc_bool_t mpc_decoder_seek_sample(mpc_decoder *d, mpc_int64_t destsample);
+mpc_bool_t mpc_decoder_seek_sample(mpc_decoder *p_dec, mpc_int64_t destsample);
 
 /// Seeks to specified position in seconds in the source stream.
-mpc_bool_t mpc_decoder_seek_seconds(mpc_decoder *d, double seconds);
+mpc_bool_t mpc_decoder_seek_seconds(mpc_decoder *p_dec, double seconds);
 
 #ifdef __cplusplus
 }
-#endif // __cplusplus
-
-#endif // _mpcdec_h_
+#endif
+#endif
Index: /libmpcdec/branches/zorg/include/mpcdec/reader.h
===================================================================
--- /libmpcdec/branches/zorg/include/mpcdec/reader.h	(revision 67)
+++ /libmpcdec/branches/zorg/include/mpcdec/reader.h	(revision 68)
@@ -32,9 +32,17 @@
   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
+/// \file reader.h
+#ifndef _MPCDEC_READER_H_
+#define _MPCDEC_READER_H_
+#ifdef WIN32
+#pragma once
+#endif
 
-/// \file reader.h
+#include "mpc_types.h"
 
-#ifndef _mpcdec_reader_h_
-#define _mpcdec_reader_h_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 
 /// \brief Stream reader interface structure.
@@ -43,40 +51,40 @@
 /// to feed it with raw data.  Implement the five member functions to provide
 /// a functional reader.
-typedef struct mpc_reader_t {
+typedef struct mpc_reader_t mpc_reader;
+struct mpc_reader_t {
     /// Reads size bytes of data into buffer at ptr.
-	mpc_int32_t (*read)(void *t, void *ptr, mpc_int32_t size);
+	mpc_int32_t (*read)(mpc_reader *p_reader, void *ptr, mpc_int32_t size);
 
     /// Seeks to byte position offset.
-	mpc_bool_t (*seek)(void *t, mpc_int32_t offset);
+	mpc_bool_t (*seek)(mpc_reader *p_reader, mpc_int32_t offset);
 
     /// Returns the current byte offset in the stream.
-	mpc_int32_t (*tell)(void *t);
+	mpc_int32_t (*tell)(mpc_reader *p_reader);
 
     /// Returns the total length of the source stream, in bytes.
-	mpc_int32_t (*get_size)(void *t);
+	mpc_int32_t (*get_size)(mpc_reader *p_reader);
 
     /// True if the stream is a seekable stream.
-	mpc_bool_t (*canseek)(void *t);
+	mpc_bool_t (*canseek)(mpc_reader *p_reader);
 
     /// Field that can be used to identify a particular instance of
     /// reader or carry along data associated with that reader.
     void *data;
-
-} mpc_reader;
-
-typedef struct mpc_reader_file_t {
-	mpc_reader reader;
-
-    FILE *file;
-    long file_size;
-    mpc_bool_t is_seekable;
-} mpc_reader_file;
+};
 
 /// Initializes reader with default stdio file reader implementation.  Use
 /// this if you're just reading from a plain file.
 ///
-/// \param r reader struct to initalize
-/// \param input input stream to attach to the reader
-void mpc_reader_setup_file_reader(mpc_reader_file *r, FILE *input);
+/// \param r p_reader handle to initialize
+/// \param filename input filename to attach to the reader
+mpc_status mpc_init_stdio_reader(mpc_reader *p_reader, char *filename);
 
-#endif // _mpcdec_reader_h_
+/// Release reader with default stdio file reader implementation.
+///
+/// \param r reader handle to release
+void mpc_exit_stdio_reader(mpc_reader *p_reader);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
Index: bmpcdec/branches/zorg/include/mpcdec/requant.h
===================================================================
--- /libmpcdec/branches/zorg/include/mpcdec/requant.h	(revision 67)
+++ 	(revision )
@@ -1,51 +1,0 @@
-/*
-  Copyright (c) 2005, The Musepack Development Team
-  All rights reserved.
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions are
-  met:
-
-  * Redistributions of source code must retain the above copyright
-  notice, this list of conditions and the following disclaimer.
-
-  * Redistributions in binary form must reproduce the above
-  copyright notice, this list of conditions and the following
-  disclaimer in the documentation and/or other materials provided
-  with the distribution.
-
-  * Neither the name of the The Musepack Development Team nor the
-  names of its contributors may be used to endorse or promote
-  products derived from this software without specific prior
-  written permission.
-
-  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/// \file requant.h
-/// Requantization function definitions.
-
-#ifndef _mpcdec_requant_h
-#define _mpcdec_requant_h_
-
-#include "mpcdec.h"
-
-/* C O N S T A N T S */
-extern const mpc_uint32_t Res_bit [18];         // bits per sample for chosen quantizer
-extern const MPC_SAMPLE_FORMAT __Cc    [1 + 18];     // coefficients for requantization
-extern const mpc_int32_t          __Dc    [1 + 18];     // offset for requantization
-
-#define Cc      (__Cc + 1)
-#define Dc      (__Dc + 1)
-
-#endif // _mpcdec_requant_h_
Index: /libmpcdec/branches/zorg/include/mpcdec/streaminfo.h
===================================================================
--- /libmpcdec/branches/zorg/include/mpcdec/streaminfo.h	(revision 67)
+++ /libmpcdec/branches/zorg/include/mpcdec/streaminfo.h	(revision 68)
@@ -32,9 +32,18 @@
   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
+/// \file streaminfo.h
+#ifndef _MPCDEC_STREAMINFO_H_
+#define _MPCDEC_STREAMINFO_H_
+#ifdef WIN32
+#pragma once
+#endif
 
-/// \file streaminfo.h
+#include "mpc_types.h"
+#include "reader.h"
 
-#ifndef _mpcdec_streaminfo_h_
-#define _mpcdec_streaminfo_h_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 
 typedef mpc_int32_t mpc_streaminfo_off_t;
@@ -45,47 +54,64 @@
 /// by the streaminfo_read function.
 typedef struct mpc_streaminfo {
-    /// @name core mpc stream properties
+    /// @name Core mpc stream properties
     //@{
-    mpc_uint32_t         sample_freq;        ///< sample frequency of stream
-    mpc_uint32_t         channels;           ///< number of channels in stream
-    mpc_streaminfo_off_t header_position;    ///< byte offset of position of header in stream
-    mpc_uint32_t         stream_version;     ///< streamversion of stream
-    mpc_uint32_t         bitrate;            ///< bitrate of stream file (in bps)
-    double               average_bitrate;    ///< average bitrate of stream (in bits/sec)
-    mpc_uint32_t         frames;             ///< number of frames in stream
-    mpc_int64_t          pcm_samples;
-    mpc_uint32_t         max_band;           ///< maximum band-index used in stream (0...31)
-    mpc_uint32_t         is;                 ///< intensity stereo (0: off, 1: on)
-    mpc_uint32_t         ms;                 ///< mid/side stereo (0: off, 1: on)
-    mpc_uint32_t         block_size;         ///< only needed for SV4...SV6 -> not supported
-    mpc_uint32_t         profile;            ///< quality profile of stream
-    const char*          profile_name;       ///< name of profile used by stream
+    mpc_uint32_t         sample_freq;        ///< Sample frequency of stream
+    mpc_uint32_t         channels;           ///< Number of channels in stream
+    mpc_streaminfo_off_t header_position;    ///< Byte offset of position of header in stream
+    mpc_uint32_t         stream_version;     ///< Streamversion of stream
+    mpc_uint32_t         bitrate;            ///< Bitrate of stream file (in bps)
+    double               average_bitrate;    ///< Average bitrate of stream (in bits/sec)
+    mpc_uint32_t         frames;             ///< Number of frames in stream
+    mpc_int64_t          pcm_samples;        ///< Approximate number of pcm samples in stream
+    mpc_uint32_t         max_band;           ///< Maximum band-index used in stream (0...31)
+    mpc_uint32_t         is;                 ///< Intensity stereo (0: off, 1: on)
+    mpc_uint32_t         ms;                 ///< Mid/side stereo (0: off, 1: on)
+    mpc_uint32_t         block_size;         ///< Only needed for SV4...SV6 -> not supported
+    mpc_uint32_t         profile;            ///< Quality profile of stream
+    const char*          profile_name;       ///< Name of profile used by stream
+    mpc_uint32_t         fast_seek;          ///< True if stream supports fast-seeking
     //@}
 
-    /// @name replaygain related fields
+    /// @name Replaygain properties
     //@{
-    mpc_int16_t         gain_title;          ///< replaygain title value 
-    mpc_int16_t         gain_album;          ///< replaygain album value
-    mpc_uint16_t        peak_album;          ///< peak album loudness level
-    mpc_uint16_t        peak_title;          ///< peak title loudness level
+    mpc_int16_t          gain_title;         ///< Replaygain title value 
+    mpc_int16_t          gain_album;         ///< Replaygain album value
+    mpc_uint16_t         peak_album;         ///< Peak album loudness level
+    mpc_uint16_t         peak_title;         ///< Peak title loudness level
     //@}
 
-    /// @name true gapless support data
+    /// @name True gapless properties
     //@{
-    mpc_uint32_t        is_true_gapless;     ///< true gapless? (0: no, 1: yes)
-    mpc_uint32_t        last_frame_samples;  ///< number of valid samples within last frame
+    mpc_uint32_t         is_true_gapless;    ///< True gapless? (0: no, 1: yes)
+    mpc_uint32_t         last_frame_samples; ///< Number of valid samples within last frame
 
-    mpc_uint32_t        encoder_version;     ///< version of encoder used
-    char                encoder[256];        ///< encoder name
+    mpc_uint32_t         encoder_version;    ///< Version of encoder used
+    char                 encoder[256];       ///< Encoder name
 
-    mpc_streaminfo_off_t tag_offset;         ///< offset to file tags
-    mpc_streaminfo_off_t total_file_length;  ///< total length of underlying file
-    //@}
-
-    /// @name fast seeking support
-    //@{
-    mpc_uint32_t        fast_seek;           ///< support fast seeking ? (0: no, 1: yes)
+    mpc_streaminfo_off_t tag_offset;         ///< Ofset to file tags
+    mpc_streaminfo_off_t total_file_length;  ///< Total length of underlying file
     //@}
 } mpc_streaminfo;
 
-#endif // _mpcdec_streaminfo_h_
+/// Initializes a streaminfo structure.
+/// \param si streaminfo structure to initialize
+void mpc_streaminfo_init(mpc_streaminfo *si);
+
+/// Reads streaminfo header from the mpc stream supplied by r.
+/// \param si si pointer to which info will be written
+/// \param p_reader stream reader to supply raw data
+/// \return error code
+mpc_status mpc_streaminfo_read(mpc_streaminfo *si, mpc_reader *p_reader);
+
+/// Gets length of stream si, in seconds.
+/// \return length of stream in seconds
+double mpc_streaminfo_get_length(mpc_streaminfo *si);
+
+/// Returns length of stream si, in samples.
+/// \return length of stream in samples
+mpc_int64_t mpc_streaminfo_get_length_samples(mpc_streaminfo *si);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
Index: /libmpcdec/branches/zorg/libwavformat/input.c
===================================================================
--- /libmpcdec/branches/zorg/libwavformat/input.c	(revision 68)
+++ /libmpcdec/branches/zorg/libwavformat/input.c	(revision 68)
@@ -0,0 +1,463 @@
+#include "libwaveformat.h"
+
+typedef struct {
+	t_wav_uint8 m_data[4];
+} t_riff_header;
+
+static t_wav_uint32 riff_compare(t_riff_header p_chunk,t_wav_uint8 a,t_wav_uint8 b,t_wav_uint8 c,t_wav_uint8 d)
+{
+	return (p_chunk.m_data[0] == a && p_chunk.m_data[1] == b && p_chunk.m_data[2] == c && p_chunk.m_data[3] == d) ? 1 : 0;
+}
+
+
+static void g_convert_float32_to_float32(t_wav_uint8 const * p_input,t_wav_float32 * p_sample_buffer,t_wav_uint32 p_sample_count)
+{
+	t_wav_uint32 n;
+	for(n=0;n<p_sample_count;n++)
+	{
+		t_wav_uint32 temp;
+		
+		temp = (t_wav_uint32) (
+			( (t_wav_uint32)p_input[0] ) | 
+			( (t_wav_uint32)p_input[1] << 8) | 
+			( (t_wav_uint32)p_input[2] << 16) | 
+			( (t_wav_uint32)p_input[3] << 24) 
+			);
+
+		p_input += 4;
+
+		p_sample_buffer[n] = *(t_wav_float32*)&temp;
+	}
+}
+
+static void g_convert_float32_to_int16(t_wav_uint8 const * p_input,t_wav_int16 * p_sample_buffer,t_wav_uint32 p_sample_count)
+{
+	t_wav_uint32 n;
+	for(n=0;n<p_sample_count;n++)
+	{
+		t_wav_uint32 temp;
+		t_wav_int32 tempi;
+		temp = (t_wav_uint32) (
+			( (t_wav_uint32)p_input[0] ) | 
+			( (t_wav_uint32)p_input[1] << 8) | 
+			( (t_wav_uint32)p_input[2] << 16) | 
+			( (t_wav_uint32)p_input[3] << 24) 
+			);
+
+		p_input += 4;
+
+		tempi = (t_wav_int32)(*(t_wav_float32*)&temp * 0x8000);
+		if (tempi < -0x8000) tempi = -0x8000;
+		else if (tempi > 0x7FFF) tempi = 0x7FFF;
+
+		p_sample_buffer[n] = (t_wav_int16) tempi;
+	}
+}
+
+static void g_convert_int32_to_float32(t_wav_uint8 const * p_input,t_wav_float32 * p_sample_buffer,t_wav_uint32 p_sample_count)
+{
+	t_wav_uint32 n;
+	for(n=0;n<p_sample_count;n++)
+	{
+		t_wav_int32 temp = (t_wav_int32) (
+			( (t_wav_uint32)p_input[0] ) | 
+			( (t_wav_uint32)p_input[1] << 8) | 
+			( (t_wav_uint32)p_input[2] << 16) | 
+			( (t_wav_uint32)p_input[3] << 24) 
+			);
+
+		p_input += 4;
+
+		p_sample_buffer[n] = (t_wav_float32) temp / (t_wav_float32) 0x80000000 ;
+	}
+}
+
+static void g_convert_int32_to_int16(t_wav_uint8 const * p_input,t_wav_int16 * p_sample_buffer,t_wav_uint32 p_sample_count)
+{
+	t_wav_uint32 n;
+	for(n=0;n<p_sample_count;n++)
+	{
+		t_wav_int32 temp = (t_wav_int32) (
+			( (t_wav_uint32)p_input[0] ) | 
+			( (t_wav_uint32)p_input[1] << 8) | 
+			( (t_wav_uint32)p_input[2] << 16) | 
+			( (t_wav_uint32)p_input[3] << 24)
+			);
+
+		p_input += 4;
+
+		p_sample_buffer[n] = (t_wav_int16) ( temp >> 16 );
+	}
+}
+
+static void g_convert_int24_to_float32(t_wav_uint8 const * p_input,t_wav_float32 * p_sample_buffer,t_wav_uint32 p_sample_count)
+{
+	t_wav_uint32 n;
+	for(n=0;n<p_sample_count;n++)
+	{
+		t_wav_int32 temp = (t_wav_int32) (
+			( (t_wav_uint32)p_input[0] ) | 
+			( (t_wav_uint32)p_input[1] << 8) | 
+			( (t_wav_int32)(t_wav_int8)p_input[2] << 16)
+			);
+
+		p_input += 3;
+
+		p_sample_buffer[n] = (t_wav_float32) temp / (t_wav_float32) 0x800000 ;
+	}
+}
+
+static void g_convert_int24_to_int16(t_wav_uint8 const * p_input,t_wav_int16 * p_sample_buffer,t_wav_uint32 p_sample_count)
+{
+	t_wav_uint32 n;
+	for(n=0;n<p_sample_count;n++)
+	{
+		t_wav_int32 temp = (t_wav_int32) (
+			( (t_wav_uint32)p_input[0] ) | 
+			( (t_wav_uint32)p_input[1] << 8) | 
+			( (t_wav_int32)(t_wav_int8)p_input[2] << 16)
+			);
+
+		p_input += 3;
+
+		p_sample_buffer[n] = (t_wav_int16) ( temp >> 8 );
+	}
+}
+
+static void g_convert_int16_to_float32(t_wav_uint8 const * p_input,t_wav_float32 * p_sample_buffer,t_wav_uint32 p_sample_count)
+{
+	t_wav_uint32 n;
+	for(n=0;n<p_sample_count;n++)
+	{
+		t_wav_int16 temp = (t_wav_int16)
+			( 
+				(t_wav_uint16)p_input[0] |
+				( (t_wav_uint16)p_input[1] << 8 )
+			);
+
+		p_input += 2;
+
+		p_sample_buffer[n] = (t_wav_float32) temp / (t_wav_float32) 0x8000 ;
+	}
+}
+
+static void g_convert_int16_to_int16(t_wav_uint8 const * p_input,t_wav_int16 * p_sample_buffer,t_wav_uint32 p_sample_count)
+{
+	t_wav_uint32 n;
+	for(n=0;n<p_sample_count;n++)
+	{
+		t_wav_int16 temp = (t_wav_int16)
+			( 
+				(t_wav_uint16)p_input[0] |
+				( (t_wav_uint16)p_input[1] << 8 )
+			);
+
+		p_input += 2;
+
+		p_sample_buffer[n] = temp;
+	}
+}
+
+static void g_convert_uint8_to_float32(t_wav_uint8 const * p_input,t_wav_float32 * p_sample_buffer,t_wav_uint32 p_sample_count)
+{
+	t_wav_uint32 n;
+	for(n=0;n<p_sample_count;n++)
+	{
+		t_wav_int8 temp = (t_wav_int8)( *(p_input++) ^ 0x80 );
+		p_sample_buffer[n] = (t_wav_float32) temp / (t_wav_float32) 0x80;
+	}
+}
+
+static void g_convert_uint8_to_int16(t_wav_uint8 const * p_input,t_wav_int16 * p_sample_buffer,t_wav_uint32 p_sample_count)
+{
+	t_wav_uint32 n;
+	for(n=0;n<p_sample_count;n++)
+	{
+		t_wav_int8 temp = (t_wav_int8)( *(p_input++) ^ 0x80 );
+		p_sample_buffer[n] = (t_wav_int16) temp << 8;
+	}
+}
+
+static t_wav_input_handler g_input_handler_float32 = {g_convert_float32_to_float32,g_convert_float32_to_int16};
+static t_wav_input_handler g_input_handler_int32 = {g_convert_int32_to_float32,g_convert_int32_to_int16};
+static t_wav_input_handler g_input_handler_int24 = {g_convert_int24_to_float32,g_convert_int24_to_int16};
+static t_wav_input_handler g_input_handler_int16 = {g_convert_int16_to_float32,g_convert_int16_to_int16};
+static t_wav_input_handler g_input_handler_uint8 = {g_convert_uint8_to_float32,g_convert_uint8_to_int16};
+
+static t_wav_uint32 waveformat_read(t_wav_input_file * p_file,void * p_buffer,t_wav_uint32 p_bytes)
+{
+	return p_file->m_callback.m_read(p_file->m_callback.m_user_data,p_buffer,p_bytes);
+}
+
+static t_wav_uint32 waveformat_skip(t_wav_input_file * p_file,t_wav_uint32 p_bytes)
+{
+	t_wav_uint8 dummy[256];
+	t_wav_uint32 delta,done,delta_done;
+
+	done = 0;
+
+	while(done < p_bytes)
+	{
+		delta = p_bytes - done;
+		if (delta > sizeof(dummy)) delta = sizeof(dummy);
+		
+		delta_done = waveformat_read(p_file,dummy,delta);
+
+		done += delta_done;
+
+		if (delta_done != delta) break;
+	}
+
+	return done;
+}
+
+
+static t_wav_uint32 waveformat_read_riff(t_wav_input_file * p_file,t_riff_header * p_header)
+{
+	return waveformat_read(p_file,p_header,sizeof(t_riff_header)) / sizeof(t_riff_header);
+}
+
+static t_wav_uint32 waveformat_read_uint32(t_wav_input_file * p_file,t_wav_uint32 * p_value)
+{
+	t_wav_uint8 temp[4];
+	if (waveformat_read(p_file,&temp,sizeof(temp)) != sizeof(temp)) return 0;
+	* p_value = 
+		((t_wav_uint32)temp[0]) |
+		((t_wav_uint32)temp[1] << 8) |
+		((t_wav_uint32)temp[2] << 16) |
+		((t_wav_uint32)temp[3] << 24);
+	return 1;
+}
+
+static t_wav_uint32 waveformat_read_uint16(t_wav_input_file * p_file,t_wav_uint16 * p_value)
+{
+	t_wav_uint8 temp[2];
+	if (waveformat_read(p_file,&temp,sizeof(temp)) != sizeof(temp)) return 0;
+	* p_value = 
+		((t_wav_uint16)temp[0]) |
+		((t_wav_uint16)temp[1] << 8);
+	return 1;
+}
+
+t_wav_uint32 waveformat_input_open(t_wav_input_file * p_file,t_wav_input_file_callback p_callback)
+{
+	t_riff_header header;
+	t_wav_uint32 main_size,main_offset,chunk_size;
+	t_wav_uint8 found_fmt;
+
+	found_fmt = 0;
+
+	p_file->m_callback = p_callback;
+
+	if (waveformat_read_riff(p_file,&header) != 1) return 0;
+
+	if (!riff_compare(header,'R','I','F','F')) return 0;
+
+	if (waveformat_read_uint32(p_file,&main_size) != 1) return 0;
+
+	if (main_size < 4) return 0;
+
+
+	if (waveformat_read_riff(p_file,&header) != 1) return 0;
+
+	if (!riff_compare(header,'W','A','V','E')) return 0;
+
+	main_offset = 4;
+
+	for(;;)
+	{
+		if (main_size - main_offset < 8) return 0;
+
+		if (waveformat_read_riff(p_file,&header) != 1) return 0;
+		if (waveformat_read_uint32(p_file,&chunk_size) != 1) return 0;
+
+		main_offset += 8;
+
+		if (main_size - main_offset < chunk_size) return 0;
+
+
+
+		if (riff_compare(header,'f','m','t',' '))
+		{
+			t_wav_uint32 fmt_remaining;
+			if (found_fmt) return 0;//duplicate fmt chunk
+
+			fmt_remaining = chunk_size;
+
+			if (fmt_remaining < 2+2+4+4+2+2) return 0;
+
+			if (waveformat_read_uint16(p_file,&p_file->m_format_tag			) != 1) return 0;
+			if (waveformat_read_uint16(p_file,&p_file->m_channels			) != 1) return 0;
+			if (waveformat_read_uint32(p_file,&p_file->m_samples_per_sec	) != 1) return 0;
+			if (waveformat_read_uint32(p_file,&p_file->m_avg_bytes_per_sec	) != 1) return 0;
+			if (waveformat_read_uint16(p_file,&p_file->m_block_align		) != 1) return 0;
+			if (waveformat_read_uint16(p_file,&p_file->m_bits_per_sample	) != 1) return 0;
+
+			p_file->m_bytes_per_sample = p_file->m_bits_per_sample / 8;
+			
+			if (p_file->m_bytes_per_sample == 0) return 0;
+
+			p_file->m_buffer_size = sizeof(p_file->m_workbuffer) / p_file->m_bytes_per_sample;
+
+			fmt_remaining -= 2+2+4+4+2+2;
+
+			switch(p_file->m_format_tag)
+			{
+			case waveformat_tag_int:
+				switch(p_file->m_bits_per_sample)
+				{
+				case 8:
+					p_file->m_input_handler = g_input_handler_uint8;
+					break;
+				case 16:
+					p_file->m_input_handler = g_input_handler_int16;
+					break;
+				case 24:
+					p_file->m_input_handler = g_input_handler_int24;
+					break;
+				case 32:
+					p_file->m_input_handler = g_input_handler_int32;
+					break;
+				default:
+					//unsupported format
+					return 0;
+				}
+				break;
+			case waveformat_tag_float:
+				switch(p_file->m_bits_per_sample)
+				{
+				case 32:
+					p_file->m_input_handler = g_input_handler_float32;
+					break;
+#if 0
+				case 64:
+
+					break;
+#endif
+				default:
+					//unsupported format
+					return 0;
+				}
+				break;
+			default:
+				//unsupported format
+				return 0;
+			}
+
+			if (chunk_size & 1) fmt_remaining++;
+
+			if (fmt_remaining > 0)
+			{
+				if (waveformat_skip(p_file,fmt_remaining) != fmt_remaining) return 0;
+			}
+			
+			main_offset += chunk_size;
+			if (chunk_size & 1) main_offset++;
+
+			found_fmt = 1;
+		}
+		else if (riff_compare(header,'d','a','t','a'))
+		{
+			if (!found_fmt) return 0;//found data before fmt, don't know how to handle data
+			//found parsable data chunk, ok to proceed
+			p_file->m_data_size = chunk_size / p_file->m_bytes_per_sample;
+			p_file->m_data_position = 0;
+
+			break;
+		}
+		else
+		{//unknown chunk, let's skip over
+			t_wav_uint32 toskip = chunk_size;
+			if (toskip & 1) toskip++;
+
+			if (waveformat_skip(p_file,toskip) != toskip) return 0;
+			
+			main_offset += toskip;
+		}
+	}
+
+	return 1;
+}
+
+t_wav_uint32 waveformat_input_process_float32(t_wav_input_file * p_file,t_wav_float32 * p_sample_buffer,t_wav_uint32 p_sample_count)
+{
+	t_wav_uint32 samples_read;
+
+	samples_read = 0;
+
+	if (p_file->m_data_position + p_sample_count > p_file->m_data_size)
+		p_sample_count = p_file->m_data_size - p_file->m_data_position;
+
+	while(samples_read < p_sample_count)
+	{
+		t_wav_uint32 delta, deltaread;
+		
+		delta = p_sample_count - samples_read;
+		if (delta > p_file->m_buffer_size) delta = p_file->m_buffer_size;
+		
+		deltaread = waveformat_read(p_file,p_file->m_workbuffer,delta * p_file->m_bytes_per_sample) / p_file->m_bytes_per_sample;
+		
+		if (deltaread > 0)
+		{
+			p_file->m_input_handler.m_convert_float32(p_file->m_workbuffer,p_sample_buffer + samples_read,deltaread);
+			
+			samples_read += deltaread;
+		}
+
+		if (deltaread != delta) break;
+	}
+
+	p_file->m_data_position += samples_read;
+
+	return samples_read;
+}
+
+t_wav_uint32 waveformat_input_process_int16(t_wav_input_file * p_file,t_wav_int16 * p_sample_buffer,t_wav_uint32 p_sample_count)
+{
+	t_wav_uint32 samples_read;
+
+	samples_read = 0;
+
+	if (p_file->m_data_position + p_sample_count > p_file->m_data_size)
+		p_sample_count = p_file->m_data_size - p_file->m_data_position;
+
+	while(samples_read < p_sample_count)
+	{
+		t_wav_uint32 delta, deltaread;
+		
+		delta = p_sample_count - samples_read;
+		if (delta > p_file->m_buffer_size) delta = p_file->m_buffer_size;
+		
+		deltaread = waveformat_read(p_file,p_file->m_workbuffer,delta * p_file->m_bytes_per_sample) / p_file->m_bytes_per_sample;
+		
+		if (deltaread > 0)
+		{
+			p_file->m_input_handler.m_convert_int16(p_file->m_workbuffer,p_sample_buffer + samples_read,deltaread);
+			
+			samples_read += deltaread;
+		}
+
+		if (deltaread != delta) break;
+	}
+
+	p_file->m_data_position += samples_read;
+
+	return samples_read;
+}
+
+void waveformat_input_close(t_wav_input_file * p_file)
+{
+}
+
+t_wav_uint32 waveformat_input_query_sample_rate(t_wav_input_file * p_file)
+{
+	return p_file->m_samples_per_sec;
+}
+t_wav_uint32 waveformat_input_query_channels(t_wav_input_file * p_file)
+{
+	return p_file->m_channels;
+}
+t_wav_uint32 waveformat_input_query_length(t_wav_input_file * p_file)
+{
+	return p_file->m_data_size;
+}
Index: /libmpcdec/branches/zorg/libwavformat/libwaveformat.h
===================================================================
--- /libmpcdec/branches/zorg/libwavformat/libwaveformat.h	(revision 68)
+++ /libmpcdec/branches/zorg/libwavformat/libwaveformat.h	(revision 68)
@@ -0,0 +1,132 @@
+#ifndef __LIBWAVEFORMAT_H__
+#define __LIBWAVEFORMAT_H__
+#ifdef WIN32
+#pragma once
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//general declarations
+
+#ifdef WIN32
+typedef __int8 t_wav_int8;
+typedef unsigned __int8 t_wav_uint8;
+typedef __int16 t_wav_int16;
+typedef unsigned __int16 t_wav_uint16;
+typedef __int32 t_wav_int32;
+typedef unsigned __int32 t_wav_uint32;
+typedef __int64 t_wav_int64;
+typedef unsigned __int64 t_wav_uint64;
+typedef float t_wav_float32;
+typedef double t_wav_float64;
+#else
+#include <stdint.h>
+typedef int8_t t_wav_int8;
+typedef uint8_t t_wav_uint8;
+typedef int16_t t_wav_int16;
+typedef uint16_t t_wav_uint16;
+typedef int32_t t_wav_int32;
+typedef uint32_t t_wav_uint32;
+typedef int64_t t_wav_int64;
+typedef uint64_t t_wav_uint64;
+typedef float t_wav_float32;
+typedef double t_wav_float64;
+#endif
+
+#define waveformat_tag_int 1
+#define waveformat_tag_float 3
+
+//WAV file reader
+
+typedef struct
+{
+	t_wav_uint32 (*m_read)(void * p_user_data,void * p_buffer,t_wav_uint32 p_bytes);
+	void * m_user_data;
+} t_wav_input_file_callback;
+
+typedef struct
+{
+	void (*m_convert_float32)(t_wav_uint8 const * p_input,t_wav_float32 * p_sample_buffer,t_wav_uint32 p_sample_count);
+	void (*m_convert_int16)(t_wav_uint8 const * p_input,t_wav_int16 * p_sample_buffer,t_wav_uint32 p_sample_count);
+} t_wav_input_handler;
+
+typedef struct 
+{
+	t_wav_input_file_callback m_callback;
+
+	t_wav_input_handler m_input_handler;
+
+	t_wav_uint16 m_format_tag;
+	t_wav_uint16 m_channels;
+	t_wav_uint32 m_samples_per_sec;
+	t_wav_uint32 m_avg_bytes_per_sec;
+	t_wav_uint16 m_block_align;
+	t_wav_uint16 m_bits_per_sample;
+
+	t_wav_uint32 m_bytes_per_sample, m_buffer_size;
+
+	t_wav_uint32 m_data_size;
+	t_wav_uint32 m_data_position;
+
+	
+
+	t_wav_uint8 m_workbuffer[512];
+} t_wav_input_file;
+
+t_wav_uint32 waveformat_input_open(t_wav_input_file * p_file,t_wav_input_file_callback p_callback);
+
+t_wav_uint32 waveformat_input_process_float32(t_wav_input_file * p_file,t_wav_float32 * p_sample_buffer,t_wav_uint32 p_sample_count);
+t_wav_uint32 waveformat_input_process_int16(t_wav_input_file * p_file,t_wav_int16 * p_sample_buffer,t_wav_uint32 p_sample_count);
+
+void waveformat_input_close(t_wav_input_file * p_file);
+
+t_wav_uint32 waveformat_input_query_sample_rate(t_wav_input_file * p_file);
+t_wav_uint32 waveformat_input_query_channels(t_wav_input_file * p_file);
+t_wav_uint32 waveformat_input_query_length(t_wav_input_file * p_file);
+
+//WAV file writer
+
+typedef struct
+{
+	t_wav_uint32 (*m_write)(void * p_user_data,void const * p_buffer,t_wav_uint32 p_bytes);
+	t_wav_uint32 (*m_seek)(void * p_user_data,t_wav_uint32 p_position);
+	void * m_user_data;
+} t_wav_output_file_callback;
+
+typedef struct
+{
+	void (*m_convert_float32)(t_wav_float32 const * p_sample_buffer,t_wav_uint8 * p_output,t_wav_uint32 p_sample_count);
+	void (*m_convert_int16)(t_wav_int16 const * p_sample_buffer,t_wav_uint8 * p_output,t_wav_uint32 p_sample_count);
+} t_wav_output_handler;
+
+typedef struct
+{
+	t_wav_output_file_callback m_callback;
+
+	t_wav_output_handler m_output_handler;
+
+	t_wav_uint32 m_channels;
+	t_wav_uint32 m_bits_per_sample;
+	t_wav_uint32 m_float;
+	t_wav_uint32 m_sample_rate;
+	t_wav_uint32 m_samples_written,m_samples_written_expected;
+
+	t_wav_uint32 m_bytes_per_sample, m_buffer_size;
+
+	t_wav_uint8 m_workbuffer[512];
+} t_wav_output_file;
+
+t_wav_uint32 waveformat_output_open(t_wav_output_file * p_file,t_wav_output_file_callback p_callback,t_wav_uint32 p_channels,t_wav_uint32 p_bits_per_sample,t_wav_uint32 p_float,t_wav_uint32 p_sample_rate,t_wav_uint32 p_expected_samples);
+
+t_wav_uint32 waveformat_output_process_float32(t_wav_output_file * p_file,t_wav_float32 const * p_sample_buffer,t_wav_uint32 p_sample_count);
+t_wav_uint32 waveformat_output_process_int16(t_wav_output_file * p_file,t_wav_int16 const * p_sample_buffer,t_wav_uint32 p_sample_count);
+
+t_wav_uint32 waveformat_output_close(t_wav_output_file * p_file);
+
+#ifdef __cplusplus
+} //extern "C"
+#endif
+
+#endif //__LIBWAVEFORMAT_H__
Index: /libmpcdec/branches/zorg/libwavformat/output.c
===================================================================
--- /libmpcdec/branches/zorg/libwavformat/output.c	(revision 68)
+++ /libmpcdec/branches/zorg/libwavformat/output.c	(revision 68)
@@ -0,0 +1,337 @@
+#include "libwaveformat.h"
+
+__inline static void write_int24(t_wav_uint8 * p_output,t_wav_int32 p_value)
+{
+	p_output[0] = (t_wav_uint8)(p_value);
+	p_output[1] = (t_wav_uint8)(p_value>>8);
+	p_output[2] = (t_wav_uint8)(p_value>>16);
+}
+
+__inline static void write_int32(t_wav_uint8 * p_output,t_wav_int32 p_value)
+{
+	p_output[0] = (t_wav_uint8)(p_value);
+	p_output[1] = (t_wav_uint8)(p_value>>8);
+	p_output[2] = (t_wav_uint8)(p_value>>16);
+	p_output[3] = (t_wav_uint8)(p_value>>24);
+}
+
+__inline static void write_float(t_wav_uint8 * p_output,t_wav_float32 p_value)
+{
+	t_wav_uint32 bah = *(const t_wav_uint32*)&p_value;
+	p_output[0] = (t_wav_uint8)bah;
+	p_output[1] = (t_wav_uint8)(bah >> 8);
+	p_output[2] = (t_wav_uint8)(bah >> 16);
+	p_output[3] = (t_wav_uint8)(bah >> 24);
+}
+
+static void g_convert_float32_to_uint8(t_wav_float32 const * p_sample_buffer,t_wav_uint8 * p_output,t_wav_uint32 p_sample_count)
+{
+	t_wav_uint32 n;
+	for(n=0;n<p_sample_count;n++)
+	{
+		t_wav_int32 temp = (t_wav_int32) ( p_sample_buffer[n] * 0x80 );
+		if (temp < -0x80) temp = -0x80;
+		else if (temp > 0x7F) temp = 0x7F;
+		*(p_output++) = (t_wav_uint8)temp ^ 0x80;
+	}
+}
+
+static void g_convert_int16_to_uint8(t_wav_int16 const * p_sample_buffer,t_wav_uint8 * p_output,t_wav_uint32 p_sample_count)
+{
+	t_wav_uint32 n;
+	for(n=0;n<p_sample_count;n++)
+	{
+		*(p_output++) = (t_wav_uint8)(p_sample_buffer[n] >> 8) ^ 0x80;
+	}
+}
+
+static void g_convert_float32_to_int16(t_wav_float32 const * p_sample_buffer,t_wav_uint8 * p_output,t_wav_uint32 p_sample_count)
+{
+	t_wav_uint32 n;
+	for(n=0;n<p_sample_count;n++)
+	{
+		t_wav_int32 temp = (t_wav_int32) ( p_sample_buffer[n] * 0x8000 );
+		if (temp < -0x8000) temp = -0x8000;
+		else if (temp > 0x7FFF) temp = 0x7FFF;
+		*(p_output++) = (t_wav_uint8)((t_wav_uint32)temp);
+		*(p_output++) = (t_wav_uint8)((t_wav_uint32)temp >> 8);
+	}
+}
+
+static void g_convert_int16_to_int16(t_wav_int16 const * p_sample_buffer,t_wav_uint8 * p_output,t_wav_uint32 p_sample_count)
+{
+	t_wav_uint32 n;
+	for(n=0;n<p_sample_count;n++)
+	{
+		t_wav_int16 temp = p_sample_buffer[n];
+		*(p_output++) = (t_wav_uint8)((t_wav_uint16)temp);
+		*(p_output++) = (t_wav_uint8)((t_wav_uint16)temp >> 8);
+	}
+}
+
+static void g_convert_float32_to_int24(t_wav_float32 const * p_sample_buffer,t_wav_uint8 * p_output,t_wav_uint32 p_sample_count)
+{
+	t_wav_uint32 n;
+	for(n=0;n<p_sample_count;n++)
+	{
+		write_int24(p_output,(t_wav_int32) ( p_sample_buffer[n] * 0x800000 ));
+		p_output += 3;
+	}
+}
+
+static void g_convert_int16_to_int24(t_wav_int16 const * p_sample_buffer,t_wav_uint8 * p_output,t_wav_uint32 p_sample_count)
+{
+	t_wav_uint32 n;
+	for(n=0;n<p_sample_count;n++)
+	{
+		write_int24(p_output,(t_wav_int32) p_sample_buffer[n] << 8 );
+		p_output += 3;
+	}
+}
+
+static void g_convert_float32_to_int32(t_wav_float32 const * p_sample_buffer,t_wav_uint8 * p_output,t_wav_uint32 p_sample_count)
+{
+	t_wav_uint32 n;
+	for(n=0;n<p_sample_count;n++)
+	{
+		write_int32(p_output,(t_wav_int32) ( p_sample_buffer[n] * 0x80000000 ));
+		p_output += 4;
+	}
+}
+
+static void g_convert_int16_to_int32(t_wav_int16 const * p_sample_buffer,t_wav_uint8 * p_output,t_wav_uint32 p_sample_count)
+{
+	t_wav_uint32 n;
+	for(n=0;n<p_sample_count;n++)
+	{
+		write_int32(p_output,(t_wav_int32) p_sample_buffer[n] << 16 );
+		p_output += 4;
+	}
+}
+
+static void g_convert_float32_to_float32(t_wav_float32 const * p_sample_buffer,t_wav_uint8 * p_output,t_wav_uint32 p_sample_count)
+{
+	t_wav_uint32 n;
+	for(n=0;n<p_sample_count;n++)
+	{
+		write_float(p_output,p_sample_buffer[n]);
+		p_output += 4;
+	}
+}
+
+static void g_convert_int16_to_float32(t_wav_int16 const * p_sample_buffer,t_wav_uint8 * p_output,t_wav_uint32 p_sample_count)
+{
+	t_wav_uint32 n;
+	for(n=0;n<p_sample_count;n++)
+	{
+		write_float(p_output,(t_wav_float32)p_sample_buffer[n] / (t_wav_float32) 0x8000);
+		p_output += 4;
+	}
+}
+
+static const t_wav_output_handler g_wav_output_handler_uint8 = {g_convert_float32_to_uint8,g_convert_int16_to_uint8};
+static const t_wav_output_handler g_wav_output_handler_int16 = {g_convert_float32_to_int16,g_convert_int16_to_int16};
+static const t_wav_output_handler g_wav_output_handler_int24 = {g_convert_float32_to_int24,g_convert_int16_to_int24};
+static const t_wav_output_handler g_wav_output_handler_int32 = {g_convert_float32_to_int32,g_convert_int16_to_int32};
+static const t_wav_output_handler g_wav_output_handler_float32 = {g_convert_float32_to_float32,g_convert_int16_to_float32};
+
+typedef struct {
+	t_wav_uint8 m_data[4];
+} t_riff_header;
+
+static const t_riff_header g_header_riff = {'R','I','F','F'};
+static const t_riff_header g_header_wave = {'W','A','V','E'};
+static const t_riff_header g_header_data = {'d','a','t','a'};
+static const t_riff_header g_header_fmt  = {'f','m','t',' '};
+
+static t_wav_uint32 waveformat_write(t_wav_output_file * p_file,void const * p_buffer,t_wav_uint32 p_buffer_size)
+{
+	return p_file->m_callback.m_write(p_file->m_callback.m_user_data,p_buffer,p_buffer_size);
+}
+
+static t_wav_uint32 waveformat_seek(t_wav_output_file * p_file,t_wav_uint32 p_position)
+{
+	return p_file->m_callback.m_seek(p_file->m_callback.m_user_data,p_position);
+}
+
+static t_wav_uint32 waveformat_write_riff(t_wav_output_file * p_file,t_riff_header p_riff)
+{
+	return waveformat_write(p_file,&p_riff,sizeof(p_riff)) / sizeof(p_riff);
+}
+
+static t_wav_uint32 waveformat_write_uint32(t_wav_output_file * p_file,t_wav_uint32 p_val)
+{
+	t_wav_uint8 temp[4] = {
+		(t_wav_uint8)(p_val & 0xFF),
+		(t_wav_uint8)((p_val >> 8) & 0xFF),
+		(t_wav_uint8)((p_val >> 16) & 0xFF),
+		(t_wav_uint8)((p_val >> 24) & 0xFF)
+	};
+
+	return waveformat_write(p_file,temp,4) / 4;
+}
+
+static t_wav_uint32 waveformat_write_uint16(t_wav_output_file * p_file,t_wav_uint16 p_val)
+{
+	t_wav_uint8 temp[2] = {
+		(t_wav_uint8)(p_val & 0xFF),
+		(t_wav_uint8)((p_val >> 8) & 0xFF)
+	};
+
+	return waveformat_write(p_file,temp,2) / 2;
+}
+
+static t_wav_uint32 calculate_riff_size(t_wav_output_file * p_file,t_wav_uint32 p_samples_written)
+{
+	t_wav_uint32 bytes_written = p_samples_written * p_file->m_bytes_per_sample, bytes_written_padded = bytes_written;
+	if (bytes_written & 1)//padding
+		bytes_written_padded++;
+
+	return bytes_written_padded + 4 + 8 + 2+2+4+4+2+2 + 8;
+}
+
+static t_wav_uint32 calculate_data_size(t_wav_output_file * p_file,t_wav_uint32 p_samples_written)
+{
+	return p_samples_written * p_file->m_bytes_per_sample;
+}
+
+t_wav_uint32 waveformat_output_open(t_wav_output_file * p_file,t_wav_output_file_callback p_callback,t_wav_uint32 p_channels,t_wav_uint32 p_bits_per_sample,t_wav_uint32 p_float,t_wav_uint32 p_sample_rate,t_wav_uint32 p_samples_written_expected)
+{
+	p_file->m_callback = p_callback;
+	p_file->m_channels = p_channels;
+	p_file->m_bits_per_sample = p_bits_per_sample;
+	p_file->m_float = p_float;
+	p_file->m_sample_rate = p_sample_rate;
+	p_file->m_bytes_per_sample = p_bits_per_sample >> 3;
+	if (p_file->m_bytes_per_sample == 0) return 0;
+	p_file->m_buffer_size = sizeof(p_file->m_workbuffer) / p_file->m_bytes_per_sample;
+	p_file->m_samples_written_expected = p_samples_written_expected;
+
+	if (p_float)
+	{
+		switch(p_bits_per_sample)
+		{
+		case 32:
+			p_file->m_output_handler = g_wav_output_handler_float32;
+			break;
+		default:
+			return 0;
+		}
+	}
+	else
+	{
+		switch(p_bits_per_sample)
+		{
+		case 8:
+			p_file->m_output_handler = g_wav_output_handler_uint8;
+			break;
+		case 16:
+			p_file->m_output_handler = g_wav_output_handler_int16;
+			break;
+		case 24:
+			p_file->m_output_handler = g_wav_output_handler_int24;
+			break;
+		case 32:
+			p_file->m_output_handler = g_wav_output_handler_int32;
+			break;
+		default:
+			return 0;
+		}
+	}
+
+	if (waveformat_write_riff(p_file,g_header_riff) != 1) return 0;
+	if (waveformat_write_uint32(p_file,calculate_riff_size(p_file,p_file->m_samples_written_expected)) != 1) return 0; //to be possibly rewritten later, offset : 4
+	if (waveformat_write_riff(p_file,g_header_wave) != 1) return 0;
+//offset: 12
+	if (waveformat_write_riff(p_file,g_header_fmt) != 1) return 0;
+	if (waveformat_write_uint32(p_file,2+2+4+4+2+2) != 1) return 0;
+//offset: 12 + 8
+	if (waveformat_write_uint16(p_file,p_float ? waveformat_tag_float : waveformat_tag_int) != 1) return 0;
+	if (waveformat_write_uint16(p_file,(t_wav_uint16) p_channels) != 1) return 0;
+	if (waveformat_write_uint32(p_file,p_sample_rate) != 1) return 0;
+	if (waveformat_write_uint32(p_file,(t_wav_uint32)(p_sample_rate * p_file->m_bytes_per_sample * p_channels)) != 1) return 0;
+	if (waveformat_write_uint16(p_file,(t_wav_uint16)(p_file->m_bytes_per_sample * p_channels)) != 1) return 0;
+	if (waveformat_write_uint16(p_file,(t_wav_uint16)p_bits_per_sample) != 1) return 0;
+//offset: 12 + 8 + 2+2+4+4+2+2
+	if (waveformat_write_riff(p_file,g_header_data) != 1) return 0;
+	if (waveformat_write_uint32(p_file,calculate_data_size(p_file,p_file->m_samples_written_expected)) != 1) return 0; //to be possibly rewritten later, offset : 12 + 8 + 2+2+4+4+2+2 + 4
+//total header size: 12 + 8 + 2+2+4+4+2+2 + 8
+	p_file->m_samples_written = 0;
+
+	return 1;
+}
+
+
+t_wav_uint32 waveformat_output_process_float32(t_wav_output_file * p_file,t_wav_float32 const * p_sample_buffer,t_wav_uint32 p_sample_count)
+{
+	t_wav_uint32 samples_done;
+
+	samples_done = 0;
+
+	while(samples_done < p_sample_count)
+	{
+		t_wav_uint32 delta = p_sample_count - samples_done, delta_written;
+		if (delta > p_file->m_buffer_size) delta = p_file->m_buffer_size;
+
+		p_file->m_output_handler.m_convert_float32(p_sample_buffer + samples_done,p_file->m_workbuffer,delta);
+
+		delta_written = waveformat_write(p_file,p_file->m_workbuffer,delta * p_file->m_bytes_per_sample) / p_file->m_bytes_per_sample;
+		
+		if (delta_written > 0)
+		{
+			samples_done += delta_written;
+		}
+
+		if (delta_written != delta) break;
+	}
+
+	p_file->m_samples_written += samples_done;
+
+	return samples_done;
+}
+
+t_wav_uint32 waveformat_output_process_int16(t_wav_output_file * p_file,t_wav_int16 const * p_sample_buffer,t_wav_uint32 p_sample_count)
+{
+	t_wav_uint32 samples_done;
+
+	samples_done = 0;
+
+	while(samples_done < p_sample_count)
+	{
+		t_wav_uint32 delta = p_sample_count - samples_done, delta_written;
+		if (delta > p_file->m_buffer_size) delta = p_file->m_buffer_size;
+
+		p_file->m_output_handler.m_convert_int16(p_sample_buffer + samples_done,p_file->m_workbuffer,delta);
+
+		delta_written = waveformat_write(p_file,p_file->m_workbuffer,delta * p_file->m_bytes_per_sample) / p_file->m_bytes_per_sample;
+		
+		if (delta_written > 0)
+		{
+			samples_done += delta_written;
+		}
+
+		if (delta_written != delta) break;
+	}
+
+	p_file->m_samples_written += samples_done;
+
+	return samples_done;
+}
+
+t_wav_uint32 waveformat_output_close(t_wav_output_file * p_file)
+{
+	if ((p_file->m_samples_written * p_file->m_bytes_per_sample) & 1)//padding
+	{
+		t_wav_uint8 meh = 0;
+		if (waveformat_write(p_file,&meh,1) != 1) return 0;
+	}
+
+	if (p_file->m_samples_written != p_file->m_samples_written_expected)
+	{
+		if (!waveformat_seek(p_file,4)) return 0;
+		if (waveformat_write_uint32(p_file,calculate_riff_size(p_file,p_file->m_samples_written)) != 1) return 0;
+		if (!waveformat_seek(p_file,12 + 8 + 2+2+4+4+2+2 + 4)) return 0;
+		if (waveformat_write_uint32(p_file,calculate_data_size(p_file,p_file->m_samples_written)) != 1) return 0;
+	}
+	return 1;
+}
Index: /libmpcdec/branches/zorg/mpcdec/mpcdec.c
===================================================================
--- /libmpcdec/branches/zorg/mpcdec/mpcdec.c	(revision 68)
+++ /libmpcdec/branches/zorg/mpcdec/mpcdec.c	(revision 68)
@@ -0,0 +1,163 @@
+/*
+  Copyright (c) 2005, The Musepack Development Team
+  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions are
+  met:
+
+  * Redistributions of source code must retain the above copyright
+  notice, this list of conditions and the following disclaimer.
+
+  * Redistributions in binary form must reproduce the above
+  copyright notice, this list of conditions and the following
+  disclaimer in the documentation and/or other materials provided
+  with the distribution.
+
+  * Neither the name of the The Musepack Development Team nor the
+  names of its contributors may be used to endorse or promote
+  products derived from this software without specific prior
+  written permission.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+#include <stdio.h>
+#include <assert.h>
+#include <time.h>
+
+#include <mpcdec/mpcdec.h>
+#include <libwaveformat.h>
+
+static void
+usage(const char *exename)
+{
+    printf
+        ("Usage: %s <infile.mpc> [<outfile.wav>]\nIf <outfile.wav> is not specified, decoder will run in benchmark mode.\n",
+         exename);
+}
+
+int
+main(int argc, char **argv)
+{
+    mpc_reader reader; mpc_streaminfo si; mpc_decoder decoder; wavwriter
+
+    if (argc != 2 && argc != 3) {
+        if (argc > 0)
+            usage(argv[0]);
+        return 0;
+    }
+
+
+    FILE *input = fopen(argv[1], "rb");
+    FILE *output = 0;
+    if (input == 0) {
+        usage(argv[0]);
+        printf("Error opening input file: \"%s\"\n", argv[1]);
+        return 1;
+    }
+
+    if (argc == 3) {
+        output = fopen(argv[2], "wb");
+        if (output == 0) {
+            fclose(input);
+            usage(argv[0]);
+            printf("Error opening output file: \"%s\"\n", argv[2]);
+            return 1;
+        }
+    }
+
+    /* initialize our reader_data tag the reader will carry around with it */
+    reader_data data;
+    data.file = input;
+    data.seekable = true;
+    fseek(data.file, 0, SEEK_END);
+    data.size = ftell(data.file);
+    fseek(data.file, 0, SEEK_SET);
+
+    /* set up an mpc_reader linked to our function implementations */
+    mpc_decoder decoder;
+    mpc_reader reader;
+    reader.read = read_impl;
+    reader.seek = seek_impl;
+    reader.tell = tell_impl;
+    reader.get_size = get_size_impl;
+    reader.canseek = canseek_impl;
+    reader.data = &data;
+
+    /* read file's streaminfo data */
+    mpc_streaminfo info;
+    mpc_streaminfo_init(&info);
+    if (mpc_streaminfo_read(&info, &reader) != ERROR_CODE_OK) {
+        printf("Not a valid musepack file: \"%s\"\n", argv[1]);
+        return 1;
+    }
+
+    /* instantiate a decoder with our file reader */
+    mpc_decoder_setup(&decoder, &reader);
+    if (!mpc_decoder_initialize(&decoder, &info)) {
+        printf("Error initializing decoder.\n", argv[1]);
+        return 1;
+    }
+
+    /* decode the file */
+    printf("Decoding from:\n%s\nTo:\n%s\n", argv[1],
+           output ? argv[2] : "N/A");
+    WavWriter *wavwriter =
+        output ? new WavWriter(output, 2, 16, info.sample_freq) : 0;
+    MPC_SAMPLE_FORMAT sample_buffer[MPC_DECODER_BUFFER_LENGTH];
+    clock_t begin, end;
+    begin = clock();
+    unsigned total_samples = 0;
+    mpc_bool_t successful = FALSE;
+    for (;;) {
+        unsigned status = mpc_decoder_decode(&decoder, sample_buffer, 0, 0);
+        if (status == (unsigned)(-1)) {
+            //decode error
+            printf("Error decoding file.\n");
+            break;
+        }
+        else if (status == 0)   //EOF
+        {
+            successful = true;
+            break;
+        }
+        else                    //status>0
+        {
+            total_samples += status;
+            if (wavwriter) {
+                if (!wavwriter->
+                    WriteSamples(sample_buffer, status * /* stereo */ 2)) {
+                    printf("Write error.\n");
+                    break;
+                }
+            }
+        }
+    }
+
+    end = clock();
+
+    if (wavwriter) {
+        delete wavwriter;
+    }
+
+    if (successful) {
+        printf("\nFinished.\nTotal samples decoded: %u.\n", total_samples);
+        unsigned ms = (end - begin) * 1000 / CLOCKS_PER_SEC;
+        unsigned ratio =
+            (unsigned)((double)total_samples / (double)info.sample_freq /
+                       ((double)ms / 1000.0) * 100.0);
+        printf("Time: %u ms (%u.%02ux).\n", ms, ratio / 100, ratio % 100);
+    }
+
+    return 0;
+}
Index: bmpcdec/branches/zorg/src/Makefile.am
===================================================================
--- /libmpcdec/branches/zorg/src/Makefile.am	(revision 67)
+++ 	(revision )
@@ -1,22 +1,0 @@
-## Process this file with automake to produce Makefile.in
-
-AUTOMAKE_OPTIONS = foreign
-
-lib_LTLIBRARIES = libmpcdec.la
-
-libmpcdec_la_SOURCES = \
-	huffsv46.c \
-	huffsv7.c \
-	idtag.c \
-	mpc_decoder.c \
-	mpc_reader.c \
-	requant.c \
-	streaminfo.c \
-	synth_filter.c
-libmpcdec_la_LDFLAGS = -no-undefined -version-info 4:2:1
-
-noinst_PROGRAMS = sample
-sample_SOURCES = sample.cpp
-sample_LDADD = libmpcdec.la
-
-INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/src
Index: /libmpcdec/branches/zorg/src/decoder.h
===================================================================
--- /libmpcdec/branches/zorg/src/decoder.h	(revision 68)
+++ /libmpcdec/branches/zorg/src/decoder.h	(revision 68)
@@ -0,0 +1,126 @@
+/*
+  Copyright (c) 2005, The Musepack Development Team
+  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions are
+  met:
+
+  * Redistributions of source code must retain the above copyright
+  notice, this list of conditions and the following disclaimer.
+
+  * Redistributions in binary form must reproduce the above
+  copyright notice, this list of conditions and the following
+  disclaimer in the documentation and/or other materials provided
+  with the distribution.
+
+  * Neither the name of the The Musepack Development Team nor the
+  names of its contributors may be used to endorse or promote
+  products derived from this software without specific prior
+  written permission.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/// \file decoder.h
+#ifndef _MPCDEC_DECODER_H_
+#define _MPCDEC_DECODER_H_
+#ifdef WIN32
+#pragma once
+#endif
+
+#include <mpcdec/reader.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SEEKING_TABLE_SIZE  256u
+// set it to SLOW_SEEKING_WINDOW to not use fast seeking
+#define FAST_SEEKING_WINDOW 32
+// set it to FAST_SEEKING_WINDOW to only use fast seeking
+#define SLOW_SEEKING_WINDOW 0x80000000
+
+enum {
+    MPC_V_MEM           = 2304,
+    MPC_DECODER_MEMSIZE = 16384,  // overall buffer size
+};
+
+typedef struct mpc_quantizer {
+    mpc_int32_t  L [36];
+    mpc_int32_t  R [36];
+} mpc_quantizer;
+
+struct mpc_decoder_t {
+    mpc_reader *r;
+
+    /// @name internal state variables
+    //@{
+
+    mpc_uint32_t  dword; /// currently decoded 32bit-word
+    mpc_uint32_t  pos;   /// bit-position within dword
+    mpc_uint32_t  Speicher[MPC_DECODER_MEMSIZE]; /// read-buffer
+    mpc_uint32_t  Zaehler; /// actual index within read-buffer
+
+    mpc_uint32_t  samples_to_skip;
+
+    mpc_uint32_t  DecodedFrames;
+    mpc_uint32_t  OverallFrames;
+    mpc_int32_t   SampleRate;                 // Sample frequency
+
+    mpc_uint32_t  StreamVersion;              // version of bitstream
+    mpc_int32_t   Max_Band;
+    mpc_uint32_t  MPCHeaderPos;               // AB: needed to support ID3v2
+
+    mpc_uint32_t  FrameWasValid;
+    mpc_uint32_t  MS_used;                    // MS-coding used ?
+    mpc_uint32_t  TrueGaplessPresent;
+
+    mpc_uint32_t  WordsRead;                  // counts amount of decoded dwords
+
+    // randomizer state variables
+    mpc_uint32_t  __r1; 
+    mpc_uint32_t  __r2; 
+
+    // seeking
+    mpc_uint32_t  seeking_table[SEEKING_TABLE_SIZE];
+    mpc_uint32_t  seeking_pwr;                // distance between 2 frames in seeking_table = 2^seeking_pwr
+    mpc_uint32_t  seeking_table_frames;       // last frame in seaking table
+    mpc_uint32_t  seeking_window;             // number of frames to look for scalefactors
+
+    mpc_int32_t   SCF_Index_L [32] [3];
+    mpc_int32_t   SCF_Index_R [32] [3];       // holds scalefactor-indices
+    mpc_quantizer Q [32];                     // holds quantized samples
+    mpc_int32_t   Res_L [32];
+    mpc_int32_t   Res_R [32];                 // holds the chosen quantizer for each subband
+    mpc_bool_t    DSCF_Flag_L [32];
+    mpc_bool_t    DSCF_Flag_R [32];           // differential SCF used?
+    mpc_int32_t   SCFI_L [32];
+    mpc_int32_t   SCFI_R [32];                // describes order of transmitted SCF
+    mpc_bool_t    MS_Flag[32];                // MS used?
+#ifdef MPC_FIXED_POINT
+    mpc_uint8_t   SCF_shift[256];
+#endif
+
+    MPC_SAMPLE_FORMAT V_L[MPC_V_MEM + 960];
+    MPC_SAMPLE_FORMAT V_R[MPC_V_MEM + 960];
+    MPC_SAMPLE_FORMAT Y_L[36][32];
+    MPC_SAMPLE_FORMAT Y_R[36][32];
+    MPC_SAMPLE_FORMAT SCF[256]; ///< holds adapted scalefactors (for clipping prevention)
+    //@}
+
+};
+
+#ifdef __cplusplus
+}
+#endif
+#endif
Index: /libmpcdec/branches/zorg/src/huffman.c
===================================================================
--- /libmpcdec/branches/zorg/src/huffman.c	(revision 68)
+++ /libmpcdec/branches/zorg/src/huffman.c	(revision 68)
@@ -0,0 +1,77 @@
+/*
+  Copyright (c) 2005, The Musepack Development Team
+  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions are
+  met:
+
+  * Redistributions of source code must retain the above copyright
+  notice, this list of conditions and the following disclaimer.
+
+  * Redistributions in binary form must reproduce the above
+  copyright notice, this list of conditions and the following
+  disclaimer in the documentation and/or other materials provided
+  with the distribution.
+
+  * Neither the name of the The Musepack Development Team nor the
+  names of its contributors may be used to endorse or promote
+  products derived from this software without specific prior
+  written permission.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/// \file huffman.c
+/// Implementations of sv7 huffman decoding functions.
+#include "huffman.h"
+
+const mpc_huffman mpc_table_HuffHdr  [10] = 
+{{2147483648u,1,0},{1610612736u,3,1},{1577058304u,7,-4},{1568669696u,9,3},{1560281088u,9,4},{1543503872u,8,-5},{1476395008u,6,2},{1342177280u,5,-3},{1073741824u,4,-2},{0u,2,-1},};
+const mpc_huffman mpc_table_HuffSCFI [ 4] =
+{{2147483648u,1,1},{1610612736u,3,2},{1073741824u,3,0},{0u,2,3},};
+const mpc_huffman mpc_table_HuffDSCF [16] = 
+{{4160749568u,5,5},{4026531840u,5,-4},{3758096384u,4,3},{3489660928u,4,-3},{3221225472u,4,8},{2684354560u,3,1},{2415919104u,4,0},{2281701376u,5,-5},{2214592512u,6,7},{2147483648u,6,-7},{1610612736u,3,-1},{1073741824u,3,2},{805306368u,4,4},{671088640u,5,6},{536870912u,5,-6},{0u,3,-2},};
+
+static const mpc_huffman mpc_table_HuffQ1 [2] [3*3*3] = {
+	{{3758096384u,3,13},{3690987520u,6,26},{3623878656u,6,0},{3556769792u,6,20},{3489660928u,6,6},{3221225472u,4,14},{2952790016u,4,12},{2684354560u,4,4},{2415919104u,4,22},{2348810240u,6,8},{2281701376u,6,18},{2214592512u,6,24},{2147483648u,6,2},{1879048192u,4,16},{1610612736u,4,10},{1476395008u,5,17},{1342177280u,5,9},{1207959552u,5,1},{1073741824u,5,25},{939524096u,5,5},{805306368u,5,21},{671088640u,5,3},{536870912u,5,11},{402653184u,5,15},{268435456u,5,23},{134217728u,5,19},{0u,5,7},},
+	{{2147483648u,1,13},{2113929216u,7,15},{2080374784u,7,1},{2046820352u,7,11},{2013265920u,7,7},{1979711488u,7,17},{1946157056u,7,25},{1912602624u,7,19},{1904214016u,9,8},{1895825408u,9,18},{1887436800u,9,2},{1879048192u,9,24},{1845493760u,7,3},{1811939328u,7,23},{1778384896u,7,21},{1744830464u,7,5},{1728053248u,8,0},{1711276032u,8,26},{1694498816u,8,6},{1677721600u,8,20},{1610612736u,6,9},{1342177280u,4,14},{1073741824u,4,12},{805306368u,4,4},{536870912u,4,22},{268435456u,4,16},{0u,4,10},},
+};
+static const mpc_huffman mpc_table_HuffQ2 [2] [5*5] = {
+	{{4026531840u,4,13},{3758096384u,4,17},{3489660928u,4,7},{3221225472u,4,11},{3154116608u,6,1},{3087007744u,6,23},{3053453312u,7,4},{3019898880u,7,20},{2986344448u,7,0},{2952790016u,7,24},{2818572288u,5,22},{2684354560u,5,10},{2147483648u,3,12},{2013265920u,5,2},{1879048192u,5,14},{1610612736u,4,6},{1342177280u,4,18},{1073741824u,4,8},{805306368u,4,16},{671088640u,5,9},{536870912u,5,5},{402653184u,5,15},{268435456u,5,21},{134217728u,5,19},{0u,5,3},},
+	{{4160749568u,5,18},{4026531840u,5,6},{3892314112u,5,8},{3875536896u,8,3},{3871342592u,10,24},{3867148288u,10,4},{3862953984u,10,0},{3858759680u,10,20},{3825205248u,7,23},{3791650816u,7,1},{3758096384u,7,19},{3623878656u,5,16},{3590324224u,7,15},{3556769792u,7,21},{3523215360u,7,9},{3489660928u,7,5},{3422552064u,6,2},{3355443200u,6,10},{3288334336u,6,14},{3221225472u,6,22},{2147483648u,2,12},{1610612736u,3,13},{1073741824u,3,17},{536870912u,3,11},{0u,3,7},},
+};
+static const mpc_huffman mpc_table_HuffQ3 [2] [ 7] = {
+	{{3758096384u,3,1},{3489660928u,4,3},{3221225472u,4,-3},{2684354560u,3,2},{2147483648u,3,-2},{1073741824u,2,0},{0u,2,-1},},
+	{{3221225472u,2,0},{2147483648u,2,-1},{1073741824u,2,1},{805306368u,4,-2},{671088640u,5,3},{536870912u,5,-3},{0u,3,2},},
+};
+static const mpc_huffman mpc_table_HuffQ4 [2] [ 9] = {
+	{{3758096384u,3,0},{3221225472u,3,-1},{2684354560u,3,1},{2147483648u,3,-2},{1610612736u,3,2},{1342177280u,4,-4},{1073741824u,4,4},{536870912u,3,3},{0u,3,-3},},
+	{{3758096384u,3,1},{3489660928u,4,2},{3221225472u,4,-3},{2147483648u,2,0},{1610612736u,3,-2},{1342177280u,4,3},{1207959552u,5,-4},{1073741824u,5,4},{0u,2,-1},},
+};
+static const mpc_huffman mpc_table_HuffQ5 [2] [15] = {
+	{{4026531840u,4,2},{3892314112u,5,5},{3825205248u,6,-7},{3758096384u,6,7},{3489660928u,4,-3},{3221225472u,4,3},{3087007744u,5,-6},{2952790016u,5,6},{2684354560u,4,-4},{2415919104u,4,4},{2147483648u,4,-5},{1610612736u,3,0},{1073741824u,3,-1},{536870912u,3,1},{0u,3,-2},},
+	{{4026531840u,4,3},{3892314112u,5,4},{3858759680u,7,6},{3841982464u,8,-7},{3825205248u,8,7},{3758096384u,6,-6},{3221225472u,3,0},{2684354560u,3,-1},{2147483648u,3,1},{1610612736u,3,-2},{1073741824u,3,2},{939524096u,5,-5},{805306368u,5,5},{536870912u,4,-4},{0u,3,-3},},
+};
+static const mpc_huffman mpc_table_HuffQ6 [2] [31] = {
+	{{4160749568u,5,3},{4026531840u,5,-4},{3959422976u,6,-11},{3892314112u,6,12},{3758096384u,5,4},{3623878656u,5,6},{3489660928u,5,-5},{3355443200u,5,5},{3221225472u,5,7},{3087007744u,5,-7},{3019898880u,6,-12},{2952790016u,6,-13},{2818572288u,5,-6},{2684354560u,5,8},{2550136832u,5,-8},{2415919104u,5,9},{2281701376u,5,-9},{2214592512u,6,13},{2181038080u,7,-15},{2147483648u,7,15},{1879048192u,4,0},{1744830464u,5,-10},{1610612736u,5,10},{1342177280u,4,-1},{1073741824u,4,2},{805306368u,4,1},{536870912u,4,-2},{469762048u,6,14},{402653184u,6,-14},{268435456u,5,11},{0u,4,-3},},
+	{{4160749568u,5,-6},{4026531840u,5,6},{3758096384u,4,1},{3489660928u,4,-1},{3456106496u,7,10},{3422552064u,7,-10},{3405774848u,8,-11},{3397386240u,9,-12},{3395289088u,11,13},{3394764800u,13,15},{3394240512u,13,-14},{3393716224u,13,14},{3393191936u,13,-15},{3388997632u,10,-13},{3372220416u,8,11},{3355443200u,8,12},{3288334336u,6,-9},{3221225472u,6,9},{2952790016u,4,-2},{2684354560u,4,2},{2415919104u,4,3},{2147483648u,4,-3},{2013265920u,5,-7},{1879048192u,5,7},{1610612736u,4,-4},{1342177280u,4,4},{1207959552u,5,-8},{1073741824u,5,8},{805306368u,4,5},{536870912u,4,-5},{0u,3,0},},
+};
+static const mpc_huffman mpc_table_HuffQ7 [2] [63] = {
+	{{4227858432u,6,7},{4160749568u,6,8},{4093640704u,6,9},{4026531840u,6,-8},{3959422976u,6,11},{3925868544u,7,21},{3909091328u,8,-28},{3892314112u,8,28},{3825205248u,6,-9},{3791650816u,7,-22},{3758096384u,7,-21},{3690987520u,6,-10},{3623878656u,6,-11},{3556769792u,6,10},{3489660928u,6,12},{3422552064u,6,-13},{3388997632u,7,22},{3355443200u,7,23},{3288334336u,6,-12},{3221225472u,6,13},{3154116608u,6,14},{3087007744u,6,-14},{3053453312u,7,-23},{3036676096u,8,-29},{3019898880u,8,29},{2952790016u,6,-15},{2885681152u,6,15},{2818572288u,6,16},{2751463424u,6,-16},{2717908992u,7,-24},{2684354560u,7,24},{2617245696u,6,17},{2583691264u,7,-25},{2566914048u,8,-30},{2550136832u,8,30},{2483027968u,6,-17},{2415919104u,6,18},{2348810240u,6,-18},{2315255808u,7,25},{2281701376u,7,26},{2214592512u,6,19},{2181038080u,7,-26},{2147483648u,7,-27},{2013265920u,5,2},{1946157056u,6,-19},{1879048192u,6,20},{1744830464u,5,-1},{1728053248u,8,-31},{1711276032u,8,31},{1677721600u,7,27},{1610612736u,6,-20},{1476395008u,5,1},{1342177280u,5,-5},{1207959552u,5,-3},{1073741824u,5,3},{939524096u,5,0},{805306368u,5,-2},{671088640u,5,-4},{536870912u,5,4},{402653184u,5,5},{268435456u,5,-6},{134217728u,5,6},{0u,5,-7},},
+	{{4160749568u,5,-1},{4026531840u,5,2},{3892314112u,5,-2},{3758096384u,5,3},{3741319168u,8,-20},{3737124864u,10,24},{3736862720u,14,28},{3736600576u,14,-28},{3736338432u,14,-30},{3736076288u,14,30},{3735027712u,12,-27},{3734765568u,14,29},{3734503424u,14,-29},{3734241280u,14,31},{3733979136u,14,-31},{3732930560u,12,27},{3724541952u,9,-22},{3690987520u,7,-17},{3623878656u,6,-11},{3489660928u,5,-3},{3355443200u,5,4},{3221225472u,5,-4},{3187671040u,7,17},{3170893824u,8,20},{3162505216u,9,22},{3158310912u,10,-25},{3154116608u,10,-26},{3087007744u,6,12},{2952790016u,5,5},{2818572288u,5,-5},{2684354560u,5,6},{2550136832u,5,-6},{2483027968u,6,-12},{2449473536u,7,-18},{2415919104u,7,18},{2348810240u,6,13},{2281701376u,6,-13},{2147483648u,5,-7},{2080374784u,6,14},{2063597568u,8,21},{2046820352u,8,-21},{2013265920u,7,-19},{1879048192u,5,7},{1744830464u,5,8},{1677721600u,6,-14},{1610612736u,6,-15},{1476395008u,5,-8},{1409286144u,6,15},{1375731712u,7,19},{1371537408u,10,25},{1367343104u,10,26},{1358954496u,9,-23},{1350565888u,9,23},{1342177280u,9,-24},{1207959552u,5,-9},{1073741824u,5,9},{1006632960u,6,16},{939524096u,6,-16},{805306368u,5,10},{536870912u,4,0},{402653184u,5,-10},{268435456u,5,11},{0u,4,1},},
+};
+
+const mpc_huffman* mpc_table_HuffQ [2] [8] = {
+	{0,mpc_table_HuffQ1[0],mpc_table_HuffQ2[0],mpc_table_HuffQ3[0],mpc_table_HuffQ4[0],mpc_table_HuffQ5[0],mpc_table_HuffQ6[0],mpc_table_HuffQ7[0]},
+	{0,mpc_table_HuffQ1[1],mpc_table_HuffQ2[1],mpc_table_HuffQ3[1],mpc_table_HuffQ4[1],mpc_table_HuffQ5[1],mpc_table_HuffQ6[1],mpc_table_HuffQ7[1]},
+};
Index: /libmpcdec/branches/zorg/src/huffman.h
===================================================================
--- /libmpcdec/branches/zorg/src/huffman.h	(revision 68)
+++ /libmpcdec/branches/zorg/src/huffman.h	(revision 68)
@@ -0,0 +1,59 @@
+/*
+  Copyright (c) 2005, The Musepack Development Team
+  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions are
+  met:
+
+  * Redistributions of source code must retain the above copyright
+  notice, this list of conditions and the following disclaimer.
+
+  * Redistributions in binary form must reproduce the above
+  copyright notice, this list of conditions and the following
+  disclaimer in the documentation and/or other materials provided
+  with the distribution.
+
+  * Neither the name of the The Musepack Development Team nor the
+  names of its contributors may be used to endorse or promote
+  products derived from this software without specific prior
+  written permission.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/// \file huffman.h
+/// Data structures and functions for huffman coding.
+
+#ifndef _MPCDEC_HUFFMAN_H_
+#define _MPCDEC_HUFFMAN_H_
+#ifdef WIN32
+#pragma once
+#endif
+
+#include <mpcdec//mpc_types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/// Huffman table entry.
+typedef struct mpc_huffman_t {
+    mpc_uint32_t  Code;
+    mpc_uint16_t  Length;
+    mpc_int16_t   Value;
+} mpc_huffman;
+
+#ifdef __cplusplus
+}
+#endif
+#endif
Index: bmpcdec/branches/zorg/src/huffsv46.c
===================================================================
--- /libmpcdec/branches/zorg/src/huffsv46.c	(revision 67)
+++ 	(revision )
@@ -1,75 +1,0 @@
-/*
-  Copyright (c) 2005, The Musepack Development Team
-  All rights reserved.
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions are
-  met:
-
-  * Redistributions of source code must retain the above copyright
-  notice, this list of conditions and the following disclaimer.
-
-  * Redistributions in binary form must reproduce the above
-  copyright notice, this list of conditions and the following
-  disclaimer in the documentation and/or other materials provided
-  with the distribution.
-
-  * Neither the name of the The Musepack Development Team nor the
-  names of its contributors may be used to endorse or promote
-  products derived from this software without specific prior
-  written permission.
-
-  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/// \file huffsv46.c
-/// Implementations of huffman decoding for streamversions < 7.
-
-#include <mpcdec/mpcdec.h>
-#include <mpcdec/requant.h>
-#include <mpcdec/huffman.h>
-
-#ifdef MPC_SUPPORT_SV456
-
-
-const HuffmanTyp    mpc_table_SCFI_Bundle   [ 8] = 
-{{2147483648u,1,7},{1073741824u,2,3},{939524096u,5,1},{805306368u,5,2},{738197504u,6,0},{671088640u,6,6},{536870912u,5,4},{0u,3,5},};
-const HuffmanTyp    mpc_table_DSCF_Entropie [13] = 
-{{3758096384u,3,1},{3489660928u,4,3},{3355443200u,5,5},{3221225472u,5,-3},{2952790016u,4,-2},{2684354560u,4,4},{2147483648u,3,-1},{1610612736u,3,2},{1476395008u,5,-5},{1409286144u,6,6},{1342177280u,6,-6},{1073741824u,4,-4},{0u,2,0},};
-const HuffmanTyp    mpc_table_Region_A [16] =
-{{2147483648u,1,1},{2013265920u,5,3},{1946157056u,6,4},{1912602624u,7,7},{1895825408u,8,8},{1887436800u,9,9},{1883242496u,10,10},{1881145344u,11,11},{1880096768u,12,12},{1879572480u,13,13},{1879310336u,14,14},{1879048192u,14,15},{1744830464u,5,5},{1610612736u,5,6},{1073741824u,3,0},{0u,2,2},};
-const HuffmanTyp    mpc_table_Region_B [ 8] = 
-{{2147483648u,1,1},{1073741824u,2,0},{536870912u,3,2},{268435456u,4,3},{134217728u,5,4},{67108864u,6,5},{33554432u,7,6},{0u,7,7},};
-const HuffmanTyp    mpc_table_Region_C [ 4] = 
-{{2147483648u,1,0},{1073741824u,2,1},{536870912u,3,2},{0u,3,3},};
-
-static const HuffmanTyp    mpc_table_Entropie_1 [ 3] =
-{{2147483648u,1,0},{1073741824u,2,-1},{0u,2,1},};
-static const HuffmanTyp    mpc_table_Entropie_2 [ 5] = 
-{{3221225472u,2,0},{2684354560u,3,2},{2147483648u,3,-2},{1073741824u,2,1},{0u,2,-1},};
-static const HuffmanTyp    mpc_table_Entropie_3 [ 7] =
-{{3221225472u,2,0},{2684354560u,3,-2},{2415919104u,4,2},{2281701376u,5,-3},{2147483648u,5,3},{1073741824u,2,-1},{0u,2,1},};
-static const HuffmanTyp    mpc_table_Entropie_4 [ 9] = 
-{{4026531840u,4,3},{3758096384u,4,-3},{3221225472u,3,1},{2684354560u,3,-1},{2147483648u,3,2},{1610612736u,3,-2},{1342177280u,4,-4},{1073741824u,4,4},{0u,2,0},};
-static const HuffmanTyp    mpc_table_Entropie_5 [15] =
-{{4026531840u,4,-2},{3892314112u,5,-5},{3825205248u,6,-7},{3758096384u,6,7},{3489660928u,4,-3},{3221225472u,4,3},{3087007744u,5,-6},{2952790016u,5,6},{2684354560u,4,4},{2147483648u,3,0},{1610612736u,3,1},{1073741824u,3,-1},{805306368u,4,-4},{536870912u,4,5},{0u,3,2},};
-static const HuffmanTyp    mpc_table_Entropie_6 [31] =
-{{4160749568u,5,-4},{4026531840u,5,5},{3892314112u,5,-5},{3825205248u,6,10},{3758096384u,6,-10},{3623878656u,5,-6},{3489660928u,5,6},{3355443200u,5,7},{3221225472u,5,-7},{3087007744u,5,-8},{3019898880u,6,-11},{2986344448u,7,14},{2952790016u,7,-14},{2818572288u,5,8},{2751463424u,6,11},{2684354560u,6,-13},{2415919104u,4,0},{2147483648u,4,1},{1879048192u,4,-1},{1610612736u,4,3},{1342177280u,4,2},{1207959552u,5,-9},{1140850688u,6,12},{1073741824u,6,13},{805306368u,4,-3},{536870912u,4,-2},{402653184u,5,9},{335544320u,6,-12},{301989888u,7,15},{268435456u,7,-15},{0u,4,4},};
-static const HuffmanTyp    mpc_table_Entropie_7 [63] =
-{{4278190080u,8,28},{4261412864u,8,26},{4227858432u,7,-20},{4160749568u,6,8},{4093640704u,6,-8},{4026531840u,6,-9},{3959422976u,6,9},{3925868544u,7,20},{3892314112u,7,21},{3825205248u,6,-10},{3758096384u,6,-11},{3690987520u,6,10},{3623878656u,6,11},{3590324224u,7,-21},{3573547008u,8,29},{3556769792u,8,-29},{3489660928u,6,13},{3422552064u,6,-13},{3355443200u,6,-12},{3288334336u,6,12},{3254779904u,7,-22},{3221225472u,7,22},{3154116608u,6,14},{3087007744u,6,15},{3019898880u,6,-14},{2986344448u,7,-23},{2952790016u,7,23},{2885681152u,6,-15},{2818572288u,6,-16},{2751463424u,6,16},{2717908992u,7,27},{2684354560u,7,-27},{2617245696u,6,17},{2550136832u,6,-17},{2533359616u,8,-30},{2516582400u,8,30},{2483027968u,7,24},{2415919104u,6,-18},{2281701376u,5,-1},{2147483648u,5,1},{2113929216u,7,-24},{2080374784u,7,25},{2013265920u,6,18},{1879048192u,5,-3},{1744830464u,5,3},{1610612736u,5,5},{1476395008u,5,0},{1342177280u,5,-2},{1275068416u,6,19},{1207959552u,6,-19},{1073741824u,5,-5},{939524096u,5,-4},{805306368u,5,-7},{671088640u,5,2},{536870912u,5,4},{402653184u,5,7},{369098752u,7,-25},{335544320u,7,-26},{301989888u,7,-28},{285212672u,8,-31},{268435456u,8,31},{134217728u,5,6},{0u,5,-6},};
-
-const HuffmanTyp*   mpc_table_SampleHuff [18] = {
-	NULL,mpc_table_Entropie_1,mpc_table_Entropie_2,mpc_table_Entropie_3,mpc_table_Entropie_4,mpc_table_Entropie_5,mpc_table_Entropie_6,mpc_table_Entropie_7,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL
-};
-
-#endif //#ifdef MPC_SUPPORT_SV456
Index: bmpcdec/branches/zorg/src/huffsv7.c
===================================================================
--- /libmpcdec/branches/zorg/src/huffsv7.c	(revision 67)
+++ 	(revision )
@@ -1,81 +1,0 @@
-/*
-  Copyright (c) 2005, The Musepack Development Team
-  All rights reserved.
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions are
-  met:
-
-  * Redistributions of source code must retain the above copyright
-  notice, this list of conditions and the following disclaimer.
-
-  * Redistributions in binary form must reproduce the above
-  copyright notice, this list of conditions and the following
-  disclaimer in the documentation and/or other materials provided
-  with the distribution.
-
-  * Neither the name of the The Musepack Development Team nor the
-  names of its contributors may be used to endorse or promote
-  products derived from this software without specific prior
-  written permission.
-
-  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/// \file huffsv7.c
-/// Implementations of sv7 huffman decoding functions.
-
-#include <mpcdec/mpcdec.h>
-#include <mpcdec/huffman.h>
-#include <mpcdec/requant.h>
-
-const HuffmanTyp	mpc_table_HuffHdr  [10] = 
-{{2147483648u,1,0},{1610612736u,3,1},{1577058304u,7,-4},{1568669696u,9,3},{1560281088u,9,4},{1543503872u,8,-5},{1476395008u,6,2},{1342177280u,5,-3},{1073741824u,4,-2},{0u,2,-1},};
-const HuffmanTyp    mpc_table_HuffSCFI [ 4] =
-{{2147483648u,1,1},{1610612736u,3,2},{1073741824u,3,0},{0u,2,3},};
-const HuffmanTyp    mpc_table_HuffDSCF [16] = 
-{{4160749568u,5,5},{4026531840u,5,-4},{3758096384u,4,3},{3489660928u,4,-3},{3221225472u,4,8},{2684354560u,3,1},{2415919104u,4,0},{2281701376u,5,-5},{2214592512u,6,7},{2147483648u,6,-7},{1610612736u,3,-1},{1073741824u,3,2},{805306368u,4,4},{671088640u,5,6},{536870912u,5,-6},{0u,3,-2},};
-
-static const HuffmanTyp    mpc_table_HuffQ1 [2] [3*3*3] = {
-	{{3758096384u,3,13},{3690987520u,6,26},{3623878656u,6,0},{3556769792u,6,20},{3489660928u,6,6},{3221225472u,4,14},{2952790016u,4,12},{2684354560u,4,4},{2415919104u,4,22},{2348810240u,6,8},{2281701376u,6,18},{2214592512u,6,24},{2147483648u,6,2},{1879048192u,4,16},{1610612736u,4,10},{1476395008u,5,17},{1342177280u,5,9},{1207959552u,5,1},{1073741824u,5,25},{939524096u,5,5},{805306368u,5,21},{671088640u,5,3},{536870912u,5,11},{402653184u,5,15},{268435456u,5,23},{134217728u,5,19},{0u,5,7},},
-	{{2147483648u,1,13},{2113929216u,7,15},{2080374784u,7,1},{2046820352u,7,11},{2013265920u,7,7},{1979711488u,7,17},{1946157056u,7,25},{1912602624u,7,19},{1904214016u,9,8},{1895825408u,9,18},{1887436800u,9,2},{1879048192u,9,24},{1845493760u,7,3},{1811939328u,7,23},{1778384896u,7,21},{1744830464u,7,5},{1728053248u,8,0},{1711276032u,8,26},{1694498816u,8,6},{1677721600u,8,20},{1610612736u,6,9},{1342177280u,4,14},{1073741824u,4,12},{805306368u,4,4},{536870912u,4,22},{268435456u,4,16},{0u,4,10},},
-};
-static const HuffmanTyp    mpc_table_HuffQ2 [2] [5*5] = {
-	{{4026531840u,4,13},{3758096384u,4,17},{3489660928u,4,7},{3221225472u,4,11},{3154116608u,6,1},{3087007744u,6,23},{3053453312u,7,4},{3019898880u,7,20},{2986344448u,7,0},{2952790016u,7,24},{2818572288u,5,22},{2684354560u,5,10},{2147483648u,3,12},{2013265920u,5,2},{1879048192u,5,14},{1610612736u,4,6},{1342177280u,4,18},{1073741824u,4,8},{805306368u,4,16},{671088640u,5,9},{536870912u,5,5},{402653184u,5,15},{268435456u,5,21},{134217728u,5,19},{0u,5,3},},
-	{{4160749568u,5,18},{4026531840u,5,6},{3892314112u,5,8},{3875536896u,8,3},{3871342592u,10,24},{3867148288u,10,4},{3862953984u,10,0},{3858759680u,10,20},{3825205248u,7,23},{3791650816u,7,1},{3758096384u,7,19},{3623878656u,5,16},{3590324224u,7,15},{3556769792u,7,21},{3523215360u,7,9},{3489660928u,7,5},{3422552064u,6,2},{3355443200u,6,10},{3288334336u,6,14},{3221225472u,6,22},{2147483648u,2,12},{1610612736u,3,13},{1073741824u,3,17},{536870912u,3,11},{0u,3,7},},
-};
-static const HuffmanTyp    mpc_table_HuffQ3 [2] [ 7] = {
-	{{3758096384u,3,1},{3489660928u,4,3},{3221225472u,4,-3},{2684354560u,3,2},{2147483648u,3,-2},{1073741824u,2,0},{0u,2,-1},},
-	{{3221225472u,2,0},{2147483648u,2,-1},{1073741824u,2,1},{805306368u,4,-2},{671088640u,5,3},{536870912u,5,-3},{0u,3,2},},
-};
-static const HuffmanTyp    mpc_table_HuffQ4 [2] [ 9] = {
-	{{3758096384u,3,0},{3221225472u,3,-1},{2684354560u,3,1},{2147483648u,3,-2},{1610612736u,3,2},{1342177280u,4,-4},{1073741824u,4,4},{536870912u,3,3},{0u,3,-3},},
-	{{3758096384u,3,1},{3489660928u,4,2},{3221225472u,4,-3},{2147483648u,2,0},{1610612736u,3,-2},{1342177280u,4,3},{1207959552u,5,-4},{1073741824u,5,4},{0u,2,-1},},
-};
-static const HuffmanTyp    mpc_table_HuffQ5 [2] [15] = {
-	{{4026531840u,4,2},{3892314112u,5,5},{3825205248u,6,-7},{3758096384u,6,7},{3489660928u,4,-3},{3221225472u,4,3},{3087007744u,5,-6},{2952790016u,5,6},{2684354560u,4,-4},{2415919104u,4,4},{2147483648u,4,-5},{1610612736u,3,0},{1073741824u,3,-1},{536870912u,3,1},{0u,3,-2},},
-	{{4026531840u,4,3},{3892314112u,5,4},{3858759680u,7,6},{3841982464u,8,-7},{3825205248u,8,7},{3758096384u,6,-6},{3221225472u,3,0},{2684354560u,3,-1},{2147483648u,3,1},{1610612736u,3,-2},{1073741824u,3,2},{939524096u,5,-5},{805306368u,5,5},{536870912u,4,-4},{0u,3,-3},},
-};
-static const HuffmanTyp    mpc_table_HuffQ6 [2] [31] = {
-	{{4160749568u,5,3},{4026531840u,5,-4},{3959422976u,6,-11},{3892314112u,6,12},{3758096384u,5,4},{3623878656u,5,6},{3489660928u,5,-5},{3355443200u,5,5},{3221225472u,5,7},{3087007744u,5,-7},{3019898880u,6,-12},{2952790016u,6,-13},{2818572288u,5,-6},{2684354560u,5,8},{2550136832u,5,-8},{2415919104u,5,9},{2281701376u,5,-9},{2214592512u,6,13},{2181038080u,7,-15},{2147483648u,7,15},{1879048192u,4,0},{1744830464u,5,-10},{1610612736u,5,10},{1342177280u,4,-1},{1073741824u,4,2},{805306368u,4,1},{536870912u,4,-2},{469762048u,6,14},{402653184u,6,-14},{268435456u,5,11},{0u,4,-3},},
-	{{4160749568u,5,-6},{4026531840u,5,6},{3758096384u,4,1},{3489660928u,4,-1},{3456106496u,7,10},{3422552064u,7,-10},{3405774848u,8,-11},{3397386240u,9,-12},{3395289088u,11,13},{3394764800u,13,15},{3394240512u,13,-14},{3393716224u,13,14},{3393191936u,13,-15},{3388997632u,10,-13},{3372220416u,8,11},{3355443200u,8,12},{3288334336u,6,-9},{3221225472u,6,9},{2952790016u,4,-2},{2684354560u,4,2},{2415919104u,4,3},{2147483648u,4,-3},{2013265920u,5,-7},{1879048192u,5,7},{1610612736u,4,-4},{1342177280u,4,4},{1207959552u,5,-8},{1073741824u,5,8},{805306368u,4,5},{536870912u,4,-5},{0u,3,0},},
-};
-static const HuffmanTyp    mpc_table_HuffQ7 [2] [63] = {
-	{{4227858432u,6,7},{4160749568u,6,8},{4093640704u,6,9},{4026531840u,6,-8},{3959422976u,6,11},{3925868544u,7,21},{3909091328u,8,-28},{3892314112u,8,28},{3825205248u,6,-9},{3791650816u,7,-22},{3758096384u,7,-21},{3690987520u,6,-10},{3623878656u,6,-11},{3556769792u,6,10},{3489660928u,6,12},{3422552064u,6,-13},{3388997632u,7,22},{3355443200u,7,23},{3288334336u,6,-12},{3221225472u,6,13},{3154116608u,6,14},{3087007744u,6,-14},{3053453312u,7,-23},{3036676096u,8,-29},{3019898880u,8,29},{2952790016u,6,-15},{2885681152u,6,15},{2818572288u,6,16},{2751463424u,6,-16},{2717908992u,7,-24},{2684354560u,7,24},{2617245696u,6,17},{2583691264u,7,-25},{2566914048u,8,-30},{2550136832u,8,30},{2483027968u,6,-17},{2415919104u,6,18},{2348810240u,6,-18},{2315255808u,7,25},{2281701376u,7,26},{2214592512u,6,19},{2181038080u,7,-26},{2147483648u,7,-27},{2013265920u,5,2},{1946157056u,6,-19},{1879048192u,6,20},{1744830464u,5,-1},{1728053248u,8,-31},{1711276032u,8,31},{1677721600u,7,27},{1610612736u,6,-20},{1476395008u,5,1},{1342177280u,5,-5},{1207959552u,5,-3},{1073741824u,5,3},{939524096u,5,0},{805306368u,5,-2},{671088640u,5,-4},{536870912u,5,4},{402653184u,5,5},{268435456u,5,-6},{134217728u,5,6},{0u,5,-7},},
-	{{4160749568u,5,-1},{4026531840u,5,2},{3892314112u,5,-2},{3758096384u,5,3},{3741319168u,8,-20},{3737124864u,10,24},{3736862720u,14,28},{3736600576u,14,-28},{3736338432u,14,-30},{3736076288u,14,30},{3735027712u,12,-27},{3734765568u,14,29},{3734503424u,14,-29},{3734241280u,14,31},{3733979136u,14,-31},{3732930560u,12,27},{3724541952u,9,-22},{3690987520u,7,-17},{3623878656u,6,-11},{3489660928u,5,-3},{3355443200u,5,4},{3221225472u,5,-4},{3187671040u,7,17},{3170893824u,8,20},{3162505216u,9,22},{3158310912u,10,-25},{3154116608u,10,-26},{3087007744u,6,12},{2952790016u,5,5},{2818572288u,5,-5},{2684354560u,5,6},{2550136832u,5,-6},{2483027968u,6,-12},{2449473536u,7,-18},{2415919104u,7,18},{2348810240u,6,13},{2281701376u,6,-13},{2147483648u,5,-7},{2080374784u,6,14},{2063597568u,8,21},{2046820352u,8,-21},{2013265920u,7,-19},{1879048192u,5,7},{1744830464u,5,8},{1677721600u,6,-14},{1610612736u,6,-15},{1476395008u,5,-8},{1409286144u,6,15},{1375731712u,7,19},{1371537408u,10,25},{1367343104u,10,26},{1358954496u,9,-23},{1350565888u,9,23},{1342177280u,9,-24},{1207959552u,5,-9},{1073741824u,5,9},{1006632960u,6,16},{939524096u,6,-16},{805306368u,5,10},{536870912u,4,0},{402653184u,5,-10},{268435456u,5,11},{0u,4,1},},
-};
-
-const HuffmanTyp*   mpc_table_HuffQ [2] [8] = {
-	{0,mpc_table_HuffQ1[0],mpc_table_HuffQ2[0],mpc_table_HuffQ3[0],mpc_table_HuffQ4[0],mpc_table_HuffQ5[0],mpc_table_HuffQ6[0],mpc_table_HuffQ7[0]},
-	{0,mpc_table_HuffQ1[1],mpc_table_HuffQ2[1],mpc_table_HuffQ3[1],mpc_table_HuffQ4[1],mpc_table_HuffQ5[1],mpc_table_HuffQ6[1],mpc_table_HuffQ7[1]},
-};
Index: bmpcdec/branches/zorg/src/idtag.c
===================================================================
--- /libmpcdec/branches/zorg/src/idtag.c	(revision 67)
+++ 	(revision )
@@ -1,83 +1,0 @@
-/*
-  Copyright (c) 2005, The Musepack Development Team
-  All rights reserved.
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions are
-  met:
-
-  * Redistributions of source code must retain the above copyright
-  notice, this list of conditions and the following disclaimer.
-
-  * Redistributions in binary form must reproduce the above
-  copyright notice, this list of conditions and the following
-  disclaimer in the documentation and/or other materials provided
-  with the distribution.
-
-  * Neither the name of the The Musepack Development Team nor the
-  names of its contributors may be used to endorse or promote
-  products derived from this software without specific prior
-  written permission.
-
-  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/// \file idtag.c
-/// Rudimentary id3tag handling routines, just enough to skip id3v2 tags,
-/// if present.
-
-#include <mpcdec/mpcdec.h>
-#include <mpcdec/internal.h>
-
-mpc_int32_t
-JumpID3v2 (mpc_reader* r) {
-    unsigned char  tmp [10];
-    mpc_uint32_t   Unsynchronisation;   // ID3v2.4-flag
-    mpc_uint32_t   ExtHeaderPresent;    // ID3v2.4-flag
-    mpc_uint32_t   ExperimentalFlag;    // ID3v2.4-flag
-    mpc_uint32_t   FooterPresent;       // ID3v2.4-flag
-    mpc_int32_t    ret;
-
-    // seek to first byte of mpc data
-    if (!r->seek (r->data, 0)) {
-        return 0;  
-    }
-    
-    r->read(r->data, tmp, sizeof(tmp));
-
-    // check id3-tag
-    if ( 0 != memcmp ( tmp, "ID3", 3) )
-        return 0;
-
-    // read flags
-    Unsynchronisation = tmp[5] & 0x80;
-    ExtHeaderPresent  = tmp[5] & 0x40;
-    ExperimentalFlag  = tmp[5] & 0x20;
-    FooterPresent     = tmp[5] & 0x10;
-
-    if ( tmp[5] & 0x0F )
-        return -1;              // not (yet???) allowed
-    if ( (tmp[6] | tmp[7] | tmp[8] | tmp[9]) & 0x80 )
-        return -1;              // not allowed
-
-    // read HeaderSize (syncsave: 4 * $0xxxxxxx = 28 significant bits)
-    ret  = tmp[6] << 21;
-    ret += tmp[7] << 14;
-    ret += tmp[8] <<  7;
-    ret += tmp[9]      ;
-    ret += 10;
-    if ( FooterPresent )
-        ret += 10;
-
-    return ret;
-}
Index: /libmpcdec/branches/zorg/src/internal.h
===================================================================
--- /libmpcdec/branches/zorg/src/internal.h	(revision 68)
+++ /libmpcdec/branches/zorg/src/internal.h	(revision 68)
@@ -0,0 +1,75 @@
+/*
+  Copyright (c) 2005, The Musepack Development Team
+  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions are
+  met:
+
+  * Redistributions of source code must retain the above copyright
+  notice, this list of conditions and the following disclaimer.
+
+  * Redistributions in binary form must reproduce the above
+  copyright notice, this list of conditions and the following
+  disclaimer in the documentation and/or other materials provided
+  with the distribution.
+
+  * Neither the name of the The Musepack Development Team nor the
+  names of its contributors may be used to endorse or promote
+  products derived from this software without specific prior
+  written permission.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/// \file internal.h
+/// Definitions and structures used only internally by the libmpcdec.
+#ifndef _MPCDEC_INTERNAL_H_
+#define _MPCDEC_INTERNAL_H_
+#ifdef WIN32
+#pragma once
+#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <mpcdec/mpcdec.h>
+
+enum {
+    MPC_FRAME_LENGTH          = (36 * 32),              ///< Samples per mpc frame
+    MPC_DECODER_BUFFER_LENGTH = (MPC_FRAME_LENGTH * 4), ///< Required buffer size for decoder
+    MPC_DECODER_SYNTH_DELAY   = 481
+};
+
+/// Big/little endian 32 bit byte swapping routine.
+static mpc_inline
+mpc_uint32_t mpc_swap32(mpc_uint32_t val) {
+    return (((val & 0xFF000000) >> 24) | ((val & 0x00FF0000) >> 8)
+          | ((val & 0x0000FF00) <<  8) | ((val & 0x000000FF) << 24));
+}
+
+/// Searches for a ID3v2-tag and reads the length (in bytes) of it.
+///
+/// \param p_reader supplying raw stream data
+/// \return size of tag, in bytes
+/// \return MPC_STATUS_FILE on errors of any kind
+mpc_int32_t mpc_skip_id3v2(mpc_reader* p_reader);
+
+/// helper functions used by multiple files
+mpc_uint32_t mpc_random_int(mpc_decoder *d); // in synth_filter.c
+void mpc_decoder_initialisiere_quantisierungstabellen(mpc_decoder *d, double scale_factor);
+void mpc_decoder_synthese_filter_float(mpc_decoder *d, MPC_SAMPLE_FORMAT* OutData);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
Index: /libmpcdec/branches/zorg/src/math.h
===================================================================
--- /libmpcdec/branches/zorg/src/math.h	(revision 68)
+++ /libmpcdec/branches/zorg/src/math.h	(revision 68)
@@ -0,0 +1,143 @@
+/*
+  Copyright (c) 2005, The Musepack Development Team
+  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions are
+  met:
+
+  * Redistributions of source code must retain the above copyright
+  notice, this list of conditions and the following disclaimer.
+
+  * Redistributions in binary form must reproduce the above
+  copyright notice, this list of conditions and the following
+  disclaimer in the documentation and/or other materials provided
+  with the distribution.
+
+  * Neither the name of the The Musepack Development Team nor the
+  names of its contributors may be used to endorse or promote
+  products derived from this software without specific prior
+  written permission.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/// \file math.h
+/// Libmpcdec internal math routines.  
+#ifndef _MPCDEC_MATH_H_
+#define _MPCDEC_MATH_H_
+#ifdef WIN32
+#pragma once
+#endif
+
+#include <mpcdec/mpc_types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MPC_FIXED_POINT_SHIFT 16
+
+
+#ifdef MPC_FIXED_POINT
+
+#ifdef _WIN32_WCE
+#include <cmnintrin.h>
+#define MPC_HAVE_MULHIGH
+#endif
+
+#define MPC_FIXED_POINT_SCALE_SHIFT (MPC_FIXED_POINT_SHIFT + MPC_FIXED_POINT_FRACTPART)
+#define MPC_FIXED_POINT_SCALE (1 << (MPC_FIXED_POINT_SCALE_SHIFT - 1))
+
+//in fixedpoint mode, results in decode output buffer are in -MPC_FIXED_POINT_SCALE ... MPC_FIXED_POINT_SCALE range
+
+#define MPC_FIXED_POINT_FRACTPART 14
+
+typedef mpc_int64_t MPC_SAMPLE_FORMAT_MULTIPLY;
+
+#define MAKE_MPC_SAMPLE(X) (MPC_SAMPLE_FORMAT)((double)(X) * (double)(((mpc_int64_t)1)<<MPC_FIXED_POINT_FRACTPART))
+#define MAKE_MPC_SAMPLE_EX(X,Y) (MPC_SAMPLE_FORMAT)((double)(X) * (double)(((mpc_int64_t)1)<<(Y)))
+
+#define MPC_MULTIPLY_NOTRUNCATE(X,Y) \
+	(((MPC_SAMPLE_FORMAT_MULTIPLY)(X) * (MPC_SAMPLE_FORMAT_MULTIPLY)(Y)) >> MPC_FIXED_POINT_FRACTPART)
+
+#define MPC_MULTIPLY_EX_NOTRUNCATE(X,Y,Z) \
+	(((MPC_SAMPLE_FORMAT_MULTIPLY)(X) * (MPC_SAMPLE_FORMAT_MULTIPLY)(Y)) >> (Z))
+
+#ifdef _DEBUG
+static inline MPC_SAMPLE_FORMAT MPC_MULTIPLY(MPC_SAMPLE_FORMAT item1,MPC_SAMPLE_FORMAT item2)
+{
+	MPC_SAMPLE_FORMAT_MULTIPLY temp = MPC_MULTIPLY_NOTRUNCATE(item1,item2);
+	assert(temp == (MPC_SAMPLE_FORMAT_MULTIPLY)(MPC_SAMPLE_FORMAT)temp);
+	return (MPC_SAMPLE_FORMAT)temp;
+}
+
+static inline MPC_SAMPLE_FORMAT MPC_MULTIPLY_EX(MPC_SAMPLE_FORMAT item1,MPC_SAMPLE_FORMAT item2,unsigned shift)
+{
+	MPC_SAMPLE_FORMAT_MULTIPLY temp = MPC_MULTIPLY_EX_NOTRUNCATE(item1,item2,shift);
+	assert(temp == (MPC_SAMPLE_FORMAT_MULTIPLY)(MPC_SAMPLE_FORMAT)temp);
+	return (MPC_SAMPLE_FORMAT)temp;
+}
+
+#else
+
+#define MPC_MULTIPLY(X,Y) ((MPC_SAMPLE_FORMAT)MPC_MULTIPLY_NOTRUNCATE(X,Y))
+#define MPC_MULTIPLY_EX(X,Y,Z) ((MPC_SAMPLE_FORMAT)MPC_MULTIPLY_EX_NOTRUNCATE(X,Y,Z))
+
+#endif
+
+#ifdef MPC_HAVE_MULHIGH
+#define MPC_MULTIPLY_FRACT(X,Y) _MulHigh(X,Y)
+#else
+#define MPC_MULTIPLY_FRACT(X,Y) MPC_MULTIPLY_EX(X,Y,32)
+#endif
+
+#define MPC_MAKE_FRACT_CONST(X) (MPC_SAMPLE_FORMAT)((X) * (double)(((mpc_int64_t)1)<<32) )
+#define MPC_MULTIPLY_FRACT_CONST(X,Y) MPC_MULTIPLY_FRACT(X,MPC_MAKE_FRACT_CONST(Y))
+#define MPC_MULTIPLY_FRACT_CONST_FIX(X,Y,Z) ( MPC_MULTIPLY_FRACT(X,MPC_MAKE_FRACT_CONST( Y / (1<<(Z)) )) << (Z) )
+#define MPC_MULTIPLY_FRACT_CONST_SHR(X,Y,Z) MPC_MULTIPLY_FRACT(X,MPC_MAKE_FRACT_CONST( Y / (1<<(Z)) ))
+
+#define MPC_MULTIPLY_FLOAT_INT(X,Y) ((X)*(Y))
+#define MPC_SCALE_CONST(X,Y,Z) MPC_MULTIPLY_EX(X,MAKE_MPC_SAMPLE_EX(Y,Z),(Z))
+#define MPC_SCALE_CONST_SHL(X,Y,Z,S) MPC_MULTIPLY_EX(X,MAKE_MPC_SAMPLE_EX(Y,Z),(Z)-(S))
+#define MPC_SCALE_CONST_SHR(X,Y,Z,S) MPC_MULTIPLY_EX(X,MAKE_MPC_SAMPLE_EX(Y,Z),(Z)+(S))
+#define MPC_SHR(X,Y) ((X)>>(Y))
+#define MPC_SHL(X,Y) ((X)<<(Y))
+
+#else
+
+//in floating-point mode, decoded samples are in -1...1 range
+
+#define MAKE_MPC_SAMPLE(X) ((MPC_SAMPLE_FORMAT)(X))
+#define MAKE_MPC_SAMPLE_EX(X,Y) ((MPC_SAMPLE_FORMAT)(X))
+
+#define MPC_MULTIPLY_FRACT(X,Y) ((X)*(Y))
+#define MPC_MAKE_FRACT_CONST(X) (X)
+#define MPC_MULTIPLY_FRACT_CONST(X,Y) MPC_MULTPLY_FRACT(X,MPC_MAKE_FRACT_CONST(Y))
+#define MPC_MULTIPLY_FRACT_CONST_SHR(X,Y,Z) MPC_MULTIPLY_FRACT(X,MPC_MAKE_FRACT_CONST( Y ))
+#define MPC_MULTIPLY_FRACT_CONST_FIX(X,Y,Z) MPC_MULTIPLY_FRACT(X,MPC_MAKE_FRACT_CONST( Y ))
+
+#define MPC_MULTIPLY_FLOAT_INT(X,Y) ((X)*(Y))
+#define MPC_MULTIPLY(X,Y) ((X)*(Y))
+#define MPC_MULTIPLY_EX(X,Y,Z) ((X)*(Y))
+#define MPC_SCALE_CONST(X,Y,Z) ((X)*(Y))
+#define MPC_SCALE_CONST_SHL(X,Y,Z,S) ((X)*(Y))
+#define MPC_SCALE_CONST_SHR(X,Y,Z,S) ((X)*(Y))
+#define MPC_SHR(X,Y) (X)
+#define MPC_SHL(X,Y) (X)
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif
Index: /libmpcdec/branches/zorg/src/mpc_decoder.c
===================================================================
--- /libmpcdec/branches/zorg/src/mpc_decoder.c	(revision 67)
+++ /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));
Index: /libmpcdec/branches/zorg/src/mpc_reader.c
===================================================================
--- /libmpcdec/branches/zorg/src/mpc_reader.c	(revision 67)
+++ /libmpcdec/branches/zorg/src/mpc_reader.c	(revision 68)
@@ -32,65 +32,148 @@
   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
-
 /// \file mpc_reader.c
 /// Contains implementations for simple file-based mpc_reader
+#include <mpcdec/reader.h>
+#include "internal.h"
+#include <stdio.h>
 
-#include <mpcdec/mpcdec.h>
+#define STDIO_MAGIC 0xF34B963C ///< Just a random safe-check value...
+typedef struct mpc_reader_stdio_t {
+    FILE       *p_file;
+    int         file_size;
+    mpc_bool_t  is_seekable;
+    mpc_int32_t magic;
+} mpc_reader_stdio;
 
 /// mpc_reader callback implementations
 static mpc_int32_t
-read_impl(void *data, void *ptr, mpc_int32_t size)
+read_stdio(mpc_reader *p_reader, void *ptr, mpc_int32_t size)
 {
-    mpc_reader_file *d = (mpc_reader_file *) data;
-
-    return (mpc_int32_t) fread(ptr, 1, size, d->file);
+    mpc_reader_stdio *p_stdio = (mpc_reader_stdio*) p_reader->data;
+    if(p_stdio->magic != STDIO_MAGIC) return MPC_STATUS_FILE;
+    return (mpc_int32_t) fread(ptr, 1, size, p_stdio->p_file);
 }
 
 static mpc_bool_t
-seek_impl(void *data, mpc_int32_t offset)
+seek_stdio(mpc_reader *p_reader, mpc_int32_t offset)
 {
-    mpc_reader_file *d = (mpc_reader_file *) data;
-
-    return d->is_seekable ? fseek(d->file, offset, SEEK_SET) == 0 : FALSE;
+    mpc_reader_stdio *p_stdio = (mpc_reader_stdio*) p_reader->data;
+    if(p_stdio->magic != STDIO_MAGIC) return FALSE;
+    return p_stdio->is_seekable ? fseek(p_stdio->p_file, offset, SEEK_SET) == 0 : FALSE;
 }
 
 static mpc_int32_t
-tell_impl(void *data)
+tell_stdio(mpc_reader *p_reader)
 {
-    mpc_reader_file *d = (mpc_reader_file *) data;
-
-    return ftell(d->file);
+    mpc_reader_stdio *p_stdio = (mpc_reader_stdio*) p_reader->data;
+    if(p_stdio->magic != STDIO_MAGIC) return MPC_STATUS_FILE;
+    return ftell(p_stdio->p_file);
 }
 
 static mpc_int32_t
-get_size_impl(void *data)
+get_size_stdio(mpc_reader *p_reader)
 {
-    mpc_reader_file *d = (mpc_reader_file *) data;
-
-    return d->file_size;
+    mpc_reader_stdio *p_stdio = (mpc_reader_stdio*) p_reader->data;
+    if(p_stdio->magic != STDIO_MAGIC) return MPC_STATUS_FILE;
+    return p_stdio->file_size;
 }
 
 static mpc_bool_t
-canseek_impl(void *data)
+canseek_stdio(mpc_reader *p_reader)
 {
-    mpc_reader_file *d = (mpc_reader_file *) data;
+    mpc_reader_stdio *p_stdio = (mpc_reader_stdio*) p_reader->data;
+    if(p_stdio->magic != STDIO_MAGIC) return FALSE;
+    return p_stdio->is_seekable;
+}
 
-    return d->is_seekable;
+mpc_status
+mpc_reader_setup_file_reader(mpc_reader *p_reader, char *filename)
+{
+    mpc_reader tmp_reader; mpc_reader_stdio *p_stdio; int err;
+
+    p_stdio = NULL;
+    memset(&tmp_reader, 0, sizeof tmp_reader);
+    p_stdio = malloc(sizeof *p_stdio);
+    if(!p_stdio) return MPC_STATUS_FILE;
+    memset(p_stdio, 0, sizeof *p_stdio);
+
+    p_stdio->magic  = STDIO_MAGIC;
+    p_stdio->p_file = fopen(filename, "rb");
+    if(!p_stdio->p_file) goto clean;
+    p_stdio->is_seekable = TRUE;
+    err = fseek(p_stdio->p_file, 0, SEEK_END);
+    if(err < 0) goto clean;
+    err = ftell(p_stdio->p_file);
+    if(err < 0) goto clean;
+    p_stdio->file_size = err;
+    err = fseek(p_stdio->p_file, 0, SEEK_SET);
+    if(err < 0) goto clean;
+
+    tmp_reader.data     = p_stdio;
+    tmp_reader.canseek  = canseek_stdio;
+    tmp_reader.get_size = get_size_stdio;
+    tmp_reader.read     = read_stdio;
+    tmp_reader.seek     = seek_stdio;
+    tmp_reader.tell     = tell_stdio;
+
+    *p_reader = tmp_reader;
+    return MPC_STATUS_OK;
+clean:
+    if(p_stdio && p_stdio->p_file)
+        fclose(p_stdio->p_file);
+    free(p_stdio);
+    return MPC_STATUS_FILE;
 }
 
 void
-mpc_reader_setup_file_reader(mpc_reader_file *p_reader, FILE *input)
+mpc_exit_stdio_reader(mpc_reader *p_reader)
 {
-    p_reader->reader.seek = seek_impl;
-    p_reader->reader.read = read_impl;
-    p_reader->reader.tell = tell_impl;
-    p_reader->reader.get_size = get_size_impl;
-    p_reader->reader.canseek = canseek_impl;
-    p_reader->reader.data = p_reader; // point back to ourselves
+    mpc_reader_stdio *p_stdio = (mpc_reader_stdio*) p_reader->data;
+    if(p_stdio->magic != STDIO_MAGIC) return;
+    fclose(p_stdio->p_file);
+    free(p_stdio);
+    p_reader->data = NULL;
+}
 
-    p_reader->file = input;
-    p_reader->is_seekable = TRUE;
-    fseek(input, 0, SEEK_END);
-    p_reader->file_size = ftell(input);
-    fseek(input, 0, SEEK_SET);
+mpc_int32_t
+mpc_skip_id3v2(mpc_reader* p_reader)
+{
+    mpc_uint8_t  tmp [10];
+    mpc_uint32_t unsynchronisation; // ID3v2.4-flag
+    mpc_uint32_t extHeaderPresent;  // ID3v2.4-flag
+    mpc_uint32_t experimentalFlag;  // ID3v2.4-flag
+    mpc_uint32_t footerPresent;     // ID3v2.4-flag
+    mpc_int32_t  ret;
+
+    // seek to first byte of mpc data
+    ret = p_reader->seek(p_reader, 0);
+    if(!ret) return 0;
+    
+    p_reader->read(p_reader, tmp, sizeof tmp);
+
+    // check id3-tag
+    if ( 0 != memcmp( tmp, "ID3", 3 ) )
+        return 0;
+
+    // read flags
+    unsynchronisation = tmp[5] & 0x80;
+    extHeaderPresent  = tmp[5] & 0x40;
+    experimentalFlag  = tmp[5] & 0x20;
+    footerPresent     = tmp[5] & 0x10;
+
+    if ( tmp[5] & 0x0F )
+        return MPC_STATUS_FILE; // not (yet???) allowed
+    if ( (tmp[6] | tmp[7] | tmp[8] | tmp[9]) & 0x80 )
+        return MPC_STATUS_FILE; // not allowed
+
+    // read headerSize (syncsave: 4 * $0xxxxxxx = 28 significant bits)
+    ret  = tmp[6] << 21;
+    ret += tmp[7] << 14;
+    ret += tmp[8] <<  7;
+    ret += tmp[9];
+    ret += 10;
+    if ( footerPresent )
+        ret += 10;
+
+    return ret;
 }
Index: /libmpcdec/branches/zorg/src/requant.c
===================================================================
--- /libmpcdec/branches/zorg/src/requant.c	(revision 67)
+++ /libmpcdec/branches/zorg/src/requant.c	(revision 68)
@@ -32,19 +32,20 @@
   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
-
 /// \file requant.c
 /// Requantization function implementations.
 /// \todo document me
+#include <mpcdec/mpcdec.h>
 
-#include <mpcdec/mpcdec.h>
-#include <mpcdec/internal.h>
+#include "requant.h"
+#include "math.h"
+#include "decoder.h"
 
 /* C O N S T A N T S */
-// bits per sample for chosen quantizer
+// Bits per sample for chosen quantizer
 const mpc_uint32_t  Res_bit [18] = {
     0,  0,  0,  0,  0,  0,  0,  0,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16
 };
 
-// coefficients for requantization
+// Requantization coefficients
 // 65536/step bzw. 65536/(2*D+1)
 
@@ -52,15 +53,15 @@
 
 const MPC_SAMPLE_FORMAT  __Cc [1 + 18] = {
-      _(111.285962475327f),                                        // 32768/2/255*sqrt(3)
+    _(111.285962475327f),   // 32768/2/255*sqrt(3)
     _(65536.000000000000f), _(21845.333333333332f), _(13107.200000000001f), _(9362.285714285713f),
-    _(7281.777777777777f),  _(4369.066666666666f),  _(2114.064516129032f), _(1040.253968253968f),
-     _(516.031496062992f),  _(257.003921568627f),   _(128.250489236790f),   _(64.062561094819f),
-       _(32.015632633121f),    _(16.003907203907f),     _(8.000976681723f),    _(4.000244155527f),
-        _(2.000061037018f),     _(1.000015259021f)
+    _(7281.777777777777f),  _(4369.066666666666f),  _(2114.064516129032f),  _(1040.253968253968f),
+    _(516.031496062992f),   _(257.003921568627f),   _(128.250489236790f),   _(64.062561094819f),
+    _(32.015632633121f),    _(16.003907203907f),    _(8.000976681723f),     _(4.000244155527f),
+    _(2.000061037018f),     _(1.000015259021f)
 };
 
 #undef _
 
-// offset for requantization
+// Requantization offset
 // 2*D+1 = steps of quantizer
 const mpc_int32_t  __Dc [1 + 18] = {
@@ -73,9 +74,13 @@
 static mpc_uint32_t find_shift(double fval)
 {
-	mpc_int64_t  val = (mpc_int64_t)fval;
+	mpc_int64_t  val = (mpc_int64_t) fval;
 	mpc_uint32_t ptr = 0;
-	if (val<0) val = -val;
-	while(val) {val>>=1;ptr++;}
-
+	if(val<0)
+        val = -val;
+	while(val)
+    {
+        val >>= 1;
+        ptr++;
+    }
 	return ptr > 31 ? 0 : 31 - ptr;
 }
@@ -84,16 +89,15 @@
 /* F U N C T I O N S */
 
-#define SET_SCF(N,X) d->SCF[N] = MAKE_MPC_SAMPLE_EX(X,d->SCF_shift[N] = (unsigned char)find_shift(X));
+#define SET_SCF(N,X) d->SCF[N] = MAKE_MPC_SAMPLE_EX(X,d->SCF_shift[N] = (mpc_uint8_t) find_shift(X));
 
 void
 mpc_decoder_scale_output(mpc_decoder *d, double factor) 
 {
-    mpc_int32_t     n;
-    double  f1;
-    double  f2;
+    mpc_int32_t n; double f1, f2;
+
 #ifndef MPC_FIXED_POINT
-	factor *= 1.0 / (double)(1<<(MPC_FIXED_POINT_SHIFT-1));
+	factor *= 1.0 / (double) (1<<(MPC_FIXED_POINT_SHIFT-1));
 #else
-	factor *= 1.0 / (double)(1<<(16 - MPC_FIXED_POINT_SHIFT));
+	factor *= 1.0 / (double) (1<<(16-MPC_FIXED_POINT_SHIFT));
 #endif
     f1 = f2 = factor;
@@ -107,6 +111,6 @@
 
     for ( n = 1; n <= 128; n++ ) {
-		SET_SCF((unsigned char)(1+n),f1);
-		SET_SCF((unsigned char)(1-n),f2);
+		SET_SCF((mpc_uint8_t)(1+n),f1);
+		SET_SCF((mpc_uint8_t)(1-n),f2);
         f1 *=   0.83298066476582673961;
         f2 *= 1/0.83298066476582673961;
Index: /libmpcdec/branches/zorg/src/requant.h
===================================================================
--- /libmpcdec/branches/zorg/src/requant.h	(revision 68)
+++ /libmpcdec/branches/zorg/src/requant.h	(revision 68)
@@ -0,0 +1,61 @@
+/*
+  Copyright (c) 2005, The Musepack Development Team
+  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions are
+  met:
+
+  * Redistributions of source code must retain the above copyright
+  notice, this list of conditions and the following disclaimer.
+
+  * Redistributions in binary form must reproduce the above
+  copyright notice, this list of conditions and the following
+  disclaimer in the documentation and/or other materials provided
+  with the distribution.
+
+  * Neither the name of the The Musepack Development Team nor the
+  names of its contributors may be used to endorse or promote
+  products derived from this software without specific prior
+  written permission.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/// \file requant.h
+/// Requantization function definitions.
+#ifndef _MPCDEC_REQUANT_H_
+#define _MPCDEC_REQUANT_H_
+#ifdef WIN32
+#pragma once
+#endif
+
+#include <mpcdec/mpc_types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* C O N S T A N T S */
+const mpc_uint32_t      Res_bit [18];     ///< Bits per sample for chosen quantizer
+const MPC_SAMPLE_FORMAT __Cc    [1 + 18]; ///< Requantization coefficients
+const mpc_int32_t       __Dc    [1 + 18]; ///< Requantization offset
+
+#define Cc (__Cc + 1)
+#define Dc (__Dc + 1)
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
Index: bmpcdec/branches/zorg/src/sample.cpp
===================================================================
--- /libmpcdec/branches/zorg/src/sample.cpp	(revision 67)
+++ 	(revision )
@@ -1,328 +1,0 @@
-/*
-  Copyright (c) 2005, The Musepack Development Team
-  All rights reserved.
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions are
-  met:
-
-  * Redistributions of source code must retain the above copyright
-  notice, this list of conditions and the following disclaimer.
-
-  * Redistributions in binary form must reproduce the above
-  copyright notice, this list of conditions and the following
-  disclaimer in the documentation and/or other materials provided
-  with the distribution.
-
-  * Neither the name of the The Musepack Development Team nor the
-  names of its contributors may be used to endorse or promote
-  products derived from this software without specific prior
-  written permission.
-
-  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include <stdio.h>
-#include <assert.h>
-#include <time.h>
-
-#include <mpcdec/mpcdec.h>
-
-/*
-  The data bundle we pass around with our reader to store file
-  position and size etc. 
-*/
-typedef struct reader_data_t {
-    FILE *file;
-    long size;
-    mpc_bool_t seekable;
-} reader_data;
-
-/*
-  Our implementations of the mpc_reader callback functions.
-*/
-mpc_int32_t
-read_impl(void *data, void *ptr, mpc_int32_t size)
-{
-    reader_data *d = (reader_data *) data;
-    return fread(ptr, 1, size, d->file);
-}
-
-mpc_bool_t
-seek_impl(void *data, mpc_int32_t offset)
-{
-    reader_data *d = (reader_data *) data;
-    return d->seekable ? !fseek(d->file, offset, SEEK_SET) : false;
-}
-
-mpc_int32_t
-tell_impl(void *data)
-{
-    reader_data *d = (reader_data *) data;
-    return ftell(d->file);
-}
-
-mpc_int32_t
-get_size_impl(void *data)
-{
-    reader_data *d = (reader_data *) data;
-    return d->size;
-}
-
-mpc_bool_t
-canseek_impl(void *data)
-{
-    reader_data *d = (reader_data *) data;
-    return d->seekable;
-}
-
-#define WFX_SIZE (2+2+4+4+2+2)
-
-#ifdef MPC_FIXED_POINT
-static int
-shift_signed(MPC_SAMPLE_FORMAT val, int shift)
-{
-    if (shift > 0)
-        val <<= shift;
-    else if (shift < 0)
-        val >>= -shift;
-    return (int)val;
-}
-#endif
-
-class WavWriter {
-  public:
-    WavWriter(FILE * p_output, unsigned p_nch, unsigned p_bps,
-              unsigned p_srate)
-    : m_file(p_output), m_nch(p_nch), m_bps(p_bps), m_srate(p_srate) {
-        assert(m_bps == 16 || m_bps == 24);
-
-        WriteRaw("RIFF", 4);
-        WriteDword(0);          //fix this in destructor
-
-        WriteRaw("WAVE", 4);
-        WriteRaw("fmt ", 4);
-        WriteDword(WFX_SIZE);
-
-        WriteWord(1);           //WAVE_FORMAT_PCM
-        WriteWord(m_nch);
-        WriteDword(m_srate);
-        WriteDword(m_srate * m_nch * (m_bps >> 3));
-        WriteWord(m_nch * (m_bps >> 3));
-        WriteWord(m_bps);
-        /*
-           WORD  wFormatTag; 
-           WORD  nChannels; 
-           DWORD nSamplesPerSec; 
-           DWORD nAvgBytesPerSec; 
-           WORD  nBlockAlign; 
-           WORD  wBitsPerSample; 
-         */
-        WriteRaw("data", 4);
-        WriteDword(0);          //fix this in destructor
-
-        m_data_bytes_written = 0;
-    } mpc_bool_t WriteSamples(const MPC_SAMPLE_FORMAT * p_buffer, unsigned p_size) {
-        unsigned n;
-        int clip_min = -1 << (m_bps - 1),
-            clip_max = (1 << (m_bps - 1)) - 1, float_scale = 1 << (m_bps - 1);
-        for (n = 0; n < p_size; n++) {
-            int val;
-#ifdef MPC_FIXED_POINT
-            val =
-                shift_signed(p_buffer[n],
-                             m_bps - MPC_FIXED_POINT_SCALE_SHIFT);
-#else
-            val = (int)(p_buffer[n] * float_scale);
-#endif
-            if (val < clip_min)
-                val = clip_min;
-            else if (val > clip_max)
-                val = clip_max;
-            if (!WriteInt(val, m_bps))
-                return false;
-        }
-        m_data_bytes_written += p_size * (m_bps >> 3);
-        return true;
-    }
-
-    ~WavWriter() {
-        if (m_data_bytes_written & 1) {
-            char blah = 0;
-            WriteRaw(&blah, 1);
-            m_data_bytes_written++;
-        }
-        Seek(4);
-        WriteDword((unsigned long)(m_data_bytes_written + 4 + 8 + WFX_SIZE +
-                                   8));
-        Seek(8 + 4 + 8 + WFX_SIZE + 4);
-        WriteDword(m_data_bytes_written);
-    }
-
-  private:
-
-    mpc_bool_t Seek(unsigned p_offset) {
-        return !fseek(m_file, p_offset, SEEK_SET);
-    }
-
-    mpc_bool_t WriteRaw(const void *p_buffer, unsigned p_bytes) {
-        return fwrite(p_buffer, 1, p_bytes, m_file) == p_bytes;
-    }
-
-    mpc_bool_t WriteDword(unsigned long p_val) {
-        return WriteInt(p_val, 32);
-    }
-    mpc_bool_t WriteWord(unsigned short p_val) {
-        return WriteInt(p_val, 16);
-    }
-
-    // write a little-endian number properly
-    mpc_bool_t WriteInt(unsigned int p_val, unsigned p_width_bits) {
-        unsigned char temp;
-        unsigned shift = 0;
-        assert((p_width_bits % 8) == 0);
-        do {
-            temp = (unsigned char)((p_val >> shift) & 0xFF);
-            if (!WriteRaw(&temp, 1))
-                return false;
-            shift += 8;
-        } while (shift < p_width_bits);
-        return true;
-    }
-
-    unsigned m_nch, m_bps, m_srate;
-    FILE *m_file;
-    unsigned m_data_bytes_written;
-};
-
-
-static void
-usage(const char *exename)
-{
-    printf
-        ("Usage: %s <infile.mpc> [<outfile.wav>]\nIf <outfile.wav> is not specified, decoder will run in benchmark mode.\n",
-         exename);
-}
-
-int
-main(int argc, char **argv)
-{
-    if (argc != 2 && argc != 3) {
-        if (argc > 0)
-            usage(argv[0]);
-        return 0;
-    }
-
-    FILE *input = fopen(argv[1], "rb");
-    FILE *output = 0;
-    if (input == 0) {
-        usage(argv[0]);
-        printf("Error opening input file: \"%s\"\n", argv[1]);
-        return 1;
-    }
-
-    if (argc == 3) {
-        output = fopen(argv[2], "wb");
-        if (output == 0) {
-            fclose(input);
-            usage(argv[0]);
-            printf("Error opening output file: \"%s\"\n", argv[2]);
-            return 1;
-        }
-    }
-
-    /* initialize our reader_data tag the reader will carry around with it */
-    reader_data data;
-    data.file = input;
-    data.seekable = true;
-    fseek(data.file, 0, SEEK_END);
-    data.size = ftell(data.file);
-    fseek(data.file, 0, SEEK_SET);
-
-    /* set up an mpc_reader linked to our function implementations */
-    mpc_decoder decoder;
-    mpc_reader reader;
-    reader.read = read_impl;
-    reader.seek = seek_impl;
-    reader.tell = tell_impl;
-    reader.get_size = get_size_impl;
-    reader.canseek = canseek_impl;
-    reader.data = &data;
-
-    /* read file's streaminfo data */
-    mpc_streaminfo info;
-    mpc_streaminfo_init(&info);
-    if (mpc_streaminfo_read(&info, &reader) != ERROR_CODE_OK) {
-        printf("Not a valid musepack file: \"%s\"\n", argv[1]);
-        return 1;
-    }
-
-    /* instantiate a decoder with our file reader */
-    mpc_decoder_setup(&decoder, &reader);
-    if (!mpc_decoder_initialize(&decoder, &info)) {
-        printf("Error initializing decoder.\n", argv[1]);
-        return 1;
-    }
-
-    /* decode the file */
-    printf("Decoding from:\n%s\nTo:\n%s\n", argv[1],
-           output ? argv[2] : "N/A");
-    WavWriter *wavwriter =
-        output ? new WavWriter(output, 2, 16, info.sample_freq) : 0;
-    MPC_SAMPLE_FORMAT sample_buffer[MPC_DECODER_BUFFER_LENGTH];
-    clock_t begin, end;
-    begin = clock();
-    unsigned total_samples = 0;
-    mpc_bool_t successful = FALSE;
-    for (;;) {
-        unsigned status = mpc_decoder_decode(&decoder, sample_buffer, 0, 0);
-        if (status == (unsigned)(-1)) {
-            //decode error
-            printf("Error decoding file.\n");
-            break;
-        }
-        else if (status == 0)   //EOF
-        {
-            successful = true;
-            break;
-        }
-        else                    //status>0
-        {
-            total_samples += status;
-            if (wavwriter) {
-                if (!wavwriter->
-                    WriteSamples(sample_buffer, status * /* stereo */ 2)) {
-                    printf("Write error.\n");
-                    break;
-                }
-            }
-        }
-    }
-
-    end = clock();
-
-    if (wavwriter) {
-        delete wavwriter;
-    }
-
-    if (successful) {
-        printf("\nFinished.\nTotal samples decoded: %u.\n", total_samples);
-        unsigned ms = (end - begin) * 1000 / CLOCKS_PER_SEC;
-        unsigned ratio =
-            (unsigned)((double)total_samples / (double)info.sample_freq /
-                       ((double)ms / 1000.0) * 100.0);
-        printf("Time: %u ms (%u.%02ux).\n", ms, ratio / 100, ratio % 100);
-    }
-
-    return 0;
-}
Index: /libmpcdec/branches/zorg/src/streaminfo.c
===================================================================
--- /libmpcdec/branches/zorg/src/streaminfo.c	(revision 67)
+++ /libmpcdec/branches/zorg/src/streaminfo.c	(revision 68)
@@ -32,70 +32,61 @@
   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
-
 /// \file streaminfo.c
 /// Implementation of streaminfo reading functions.
 
-#include <mpcdec/mpcdec.h>
-#include <mpcdec/internal.h>
+#include <mpcdec/streaminfo.h>
+#include <stdio.h>
+#include "internal.h"
+
+static const char na[] = "n.a.";
+static const char *versionNames[] = {
+    na, "'Unstable/Experimental'", na, na, na, "'quality 0'", "'quality 1'", 
+    "'Telephone'", "'Thumb'", "'Radio'", "'Standard'", "'Extreme'", "'Insane'",
+    "'BrainDead'", "'quality 9'", "'quality 10'"
+};
+static const mpc_int32_t samplefreqs[4] = { 44100, 48000, 37800, 32000 };
 
 static const char *
-Stringify(mpc_uint32_t profile) // profile is 0...15, where 7...13 is used
+mpc_get_version_string(mpc_uint32_t profile) // profile is 0...15, where 7...13 is used
 {
-    static const char na[] = "n.a.";
-    static const char *Names[] = {
-        na, "'Unstable/Experimental'", na, na,
-        na, "'quality 0'", "'quality 1'", "'Telephone'",
-        "'Thumb'", "'Radio'", "'Standard'", "'Xtreme'",
-        "'Insane'", "'BrainDead'", "'quality 9'", "'quality 10'"
-    };
-
-    return profile >= sizeof(Names) / sizeof(*Names) ? na : Names[profile];
+    return profile >= sizeof versionNames / sizeof *versionNames ? na : versionNames[profile];
 }
 
 void
-mpc_streaminfo_init(mpc_streaminfo * si)
+mpc_streaminfo_init(mpc_streaminfo* si)
 {
-    memset(si, 0, sizeof(mpc_streaminfo));
+    memset(si, 0, sizeof *si);
 }
 
 /// Reads streaminfo from SV7 header. 
-static mpc_int32_t
-streaminfo_read_header_sv7(mpc_streaminfo * si, mpc_uint32_t HeaderData[8])
+static mpc_status
+streaminfo_read_header_sv7(mpc_streaminfo* si, mpc_uint32_t HeaderData[8])
 {
-    const mpc_int32_t samplefreqs[4] = { 44100, 48000, 37800, 32000 };
-
-    //mpc_uint32_t    HeaderData [8];
     mpc_uint16_t Estimatedpeak_title = 0;
 
     if (si->stream_version > 0x71) {
         //        Update (si->stream_version);
-        return 0;
+        return MPC_STATUS_OK;
     }
 
-    /*
-       if ( !fp->seek ( si->header_position ) )         // seek to header start
-       return ERROR_CODE_FILE;
-       if ( fp->read ( HeaderData, sizeof HeaderData) != sizeof HeaderData )
-       return ERROR_CODE_FILE;
-     */
-
-    si->bitrate = 0;
-    si->frames = HeaderData[1];
-    si->is = 0;
-    si->ms = (HeaderData[2] >> 30) & 0x0001;
-    si->max_band = (HeaderData[2] >> 24) & 0x003F;
-    si->block_size = 1;
-    si->profile = (HeaderData[2] << 8) >> 28;
-    si->profile_name = Stringify(si->profile);
-    si->sample_freq = samplefreqs[(HeaderData[2] >> 16) & 0x0003];
-    Estimatedpeak_title = (mpc_uint16_t) (HeaderData[2] & 0xFFFF);   // read the ReplayGain data
-    si->gain_title = (mpc_uint16_t) ((HeaderData[3] >> 16) & 0xFFFF);
-    si->peak_title = (mpc_uint16_t) (HeaderData[3] & 0xFFFF);
-    si->gain_album = (mpc_uint16_t) ((HeaderData[4] >> 16) & 0xFFFF);
-    si->peak_album = (mpc_uint16_t) (HeaderData[4] & 0xFFFF);
-    si->is_true_gapless = (HeaderData[5] >> 31) & 0x0001; // true gapless: used?
-    si->last_frame_samples = (HeaderData[5] >> 20) & 0x07FF;  // true gapless: valid samples for last frame
-    si->fast_seek = (HeaderData[5] >> 19) & 0x0001;  // fast seeking
-    si->encoder_version = (HeaderData[6] >> 24) & 0x00FF;
+    si->bitrate            = 0;
+    si->frames             = HeaderData[1];
+    si->is                 = 0;
+    si->ms                 = (HeaderData[2] >> 30) & 0x0001;
+    si->max_band           = (HeaderData[2] >> 24) & 0x003F;
+    si->block_size         = 1;
+    si->profile            = (HeaderData[2] << 8) >> 28;
+    si->profile_name       = mpc_get_version_string(si->profile);
+    si->sample_freq        = samplefreqs[(HeaderData[2] >> 16) & 0x0003];
+    Estimatedpeak_title    = (mpc_uint16_t) (HeaderData[2] & 0xFFFF);   // read the ReplayGain data
+    si->gain_title         = (mpc_uint16_t) ((HeaderData[3] >> 16) & 0xFFFF);
+    si->peak_title         = (mpc_uint16_t) (HeaderData[3] & 0xFFFF);
+    si->gain_album         = (mpc_uint16_t) ((HeaderData[4] >> 16) & 0xFFFF);
+    si->peak_album         = (mpc_uint16_t) (HeaderData[4] & 0xFFFF);
+    si->is_true_gapless    = (HeaderData[5] >> 31) & 0x0001; // true gapless: used?
+    si->last_frame_samples = (HeaderData[5] >> 20) & 0x07FF; // true gapless: valid samples for last frame
+    si->fast_seek          = (HeaderData[5] >> 19) & 0x0001; // fast seeking
+    si->encoder_version    = (HeaderData[6] >> 24) & 0x00FF;
+    si->channels           = 2;
 
     if (si->encoder_version == 0) {
@@ -108,8 +99,5 @@
                     si->encoder_version / 10 % 10);
             break;
-        case 2:
-        case 4:
-        case 6:
-        case 8:
+        case 2: case 4: case 6: case 8:
             sprintf(si->encoder, "Beta %u.%02u", si->encoder_version / 100,
                     si->encoder_version % 100);
@@ -122,138 +110,57 @@
     }
 
-    //    if ( si->peak_title == 0 )                                      // there is no correct peak_title contained within header
-    //        si->peak_title = (mpc_uint16_t)(Estimatedpeak_title * 1.18);
-    //    if ( si->peak_album == 0 )
-    //        si->peak_album = si->peak_title;                          // no correct peak_album, use peak_title
-
-    //si->sample_freq    = 44100;                                     // AB: used by all files up to SV7
-    si->channels = 2;
-
-    return ERROR_CODE_OK;
+    return MPC_STATUS_OK;
 }
 
-// read information from SV4-SV6 header
-#ifdef MPC_SUPPORT_SV456
-static mpc_int32_t
-streaminfo_read_header_sv6(mpc_streaminfo * si, mpc_uint32_t HeaderData[8])
+// reads file header and tags
+mpc_status
+mpc_streaminfo_read(mpc_streaminfo * si, mpc_reader *p_reader)
 {
-    //mpc_uint32_t    HeaderData [8];
-
-    /*
-       if ( !fp->seek (  si->header_position ) )         // seek to header start
-       return ERROR_CODE_FILE;
-       if ( fp->read ( HeaderData, sizeof HeaderData ) != sizeof HeaderData )
-       return ERROR_CODE_FILE;
-     */
-
-    si->bitrate = (HeaderData[0] >> 23) & 0x01FF;   // read the file-header (SV6 and below)
-    si->is = (HeaderData[0] >> 22) & 0x0001;
-    si->ms = (HeaderData[0] >> 21) & 0x0001;
-    si->stream_version = (HeaderData[0] >> 11) & 0x03FF;
-    si->max_band = (HeaderData[0] >> 6) & 0x001F;
-    si->block_size = (HeaderData[0]) & 0x003F;
-    si->profile = 0;
-    si->profile_name = Stringify((mpc_uint32_t) (-1));
-    if (si->stream_version >= 5)
-        si->frames = HeaderData[1]; // 32 bit
-    else
-        si->frames = (HeaderData[1] >> 16); // 16 bit
-
-    si->gain_title = 0;          // not supported
-    si->peak_title = 0;
-    si->gain_album = 0;
-    si->peak_album = 0;
-
-    si->last_frame_samples = 0;
-    si->is_true_gapless = 0;
-
-    si->encoder_version = 0;
-    si->encoder[0] = '\0';
-
-    if (si->stream_version == 7)
-        return ERROR_CODE_SV7BETA;  // are there any unsupported parameters used?
-    if (si->bitrate != 0)
-        return ERROR_CODE_CBR;
-    if (si->is != 0)
-        return ERROR_CODE_IS;
-    if (si->block_size != 1)
-        return ERROR_CODE_BLOCKSIZE;
-
-    if (si->stream_version < 6) // Bugfix: last frame was invalid for up to SV5
-        si->frames -= 1;
-
-    si->sample_freq = 44100;     // AB: used by all files up to SV7
-    si->channels = 2;
-
-    if (si->stream_version < 4 || si->stream_version > 7)
-        return ERROR_CODE_INVALIDSV;
-
-    return ERROR_CODE_OK;
-}
-#endif
-// reads file header and tags
-mpc_int32_t
-mpc_streaminfo_read(mpc_streaminfo * si, mpc_reader * r)
-{
-    mpc_uint32_t HeaderData[8];
-    mpc_int32_t Error = 0;
+    mpc_uint32_t headerData[8]; int err;
 
     // get header position
-    if ((si->header_position = JumpID3v2(r)) < 0) {
-        return ERROR_CODE_FILE;
+    err = si->header_position = mpc_skip_id3v2(p_reader);
+    if(err < 0) return MPC_STATUS_FILE;
+
+    // seek to first byte of mpc data
+    err = p_reader->seek(p_reader, si->header_position);
+    if(!err) return MPC_STATUS_FILE;
+    err = p_reader->read(p_reader, headerData, 8 * 4);
+    if(err != 8 * 4) return MPC_STATUS_FILE;
+    err = p_reader->seek(p_reader, si->header_position + 6 * 4);
+    if(!err) return MPC_STATUS_FILE;
+
+    err = p_reader->get_size(p_reader);
+    if(err < 0) return MPC_STATUS_FILE;
+    si->tag_offset = si->total_file_length = err;
+
+    err = memcmp(headerData, "MP+", 3);
+    if(!err) return MPC_STATUS_INVALIDSV;
+
+#ifndef MPC_LITTLE_ENDIAN
+    {
+        mpc_uint32_t ptr;
+        for (ptr = 0; ptr < 8; ptr++)
+            headerData[ptr] = mpc_swap32(headerData[ptr]);
     }
-    // seek to first byte of mpc data
-    if (!r->seek(r->data, si->header_position)) {
-        return ERROR_CODE_FILE;
-    }
-    if (r->read(r->data, HeaderData, 8 * 4) != 8 * 4) {
-        return ERROR_CODE_FILE;
-    }
-    if (!r->seek(r->data, si->header_position + 6 * 4)) {
-        return ERROR_CODE_FILE;
-    }
+#endif
+     si->stream_version = headerData[0] >> 24;
 
-    si->total_file_length = r->get_size(r->data);
-    si->tag_offset = si->total_file_length;
-    if (memcmp(HeaderData, "MP+", 3) == 0) {
-#ifndef MPC_LITTLE_ENDIAN
-        mpc_uint32_t ptr;
-        for (ptr = 0; ptr < 8; ptr++) {
-            HeaderData[ptr] = mpc_swap32(HeaderData[ptr]);
-        }
-#endif
-        si->stream_version = HeaderData[0] >> 24;
-
-        // stream version 8
-        if ((si->stream_version & 15) >= 8) {
-            return ERROR_CODE_INVALIDSV;
-        }
-        // stream version 7
-        else if ((si->stream_version & 15) == 7) {
-            Error = streaminfo_read_header_sv7(si, HeaderData);
-            if (Error != ERROR_CODE_OK) return Error;
-        }
-    } else {
-#ifdef MPC_SUPPORT_SV456
-        // stream version 4-6
-        Error = streaminfo_read_header_sv6(si, HeaderData);
-#else
-        return ERROR_CODE_INVALIDSV;
-#endif
-    }
+     if ((si->stream_version & 15) >= 8)
+        return MPC_STATUS_INVALIDSV;
+     else if ((si->stream_version & 15) == 7)
+     {
+        err = streaminfo_read_header_sv7(si, headerData);
+        if(err < 0) return err;
+     }
 
     // estimation, exact value needs too much time
-    si->pcm_samples = 1152 * si->frames - 576;
+    si->pcm_samples     = 1152 * si->frames - 576;
+    si->average_bitrate = 0;
+    if (si->pcm_samples > 0)
+        si->average_bitrate = (si->tag_offset  - si->header_position) * 8.0 
+                            *  si->sample_freq / si->pcm_samples;
 
-    if (si->pcm_samples > 0) {
-        si->average_bitrate =
-            (si->tag_offset -
-             si->header_position) * 8.0 * si->sample_freq / si->pcm_samples;
-    }
-    else {
-        si->average_bitrate = 0;
-    }
-
-    return ERROR_CODE_OK;
+    return MPC_STATUS_OK;
 }
 
@@ -261,6 +168,5 @@
 mpc_streaminfo_get_length(mpc_streaminfo * si)
 {
-    return (double)mpc_streaminfo_get_length_samples(si) /
-        (double)si->sample_freq;
+    return (double) mpc_streaminfo_get_length_samples(si) / si->sample_freq;
 }
 
@@ -269,10 +175,8 @@
 {
     mpc_int64_t samples = (mpc_int64_t) si->frames * MPC_FRAME_LENGTH;
-    if (si->is_true_gapless) {
+    if (si->is_true_gapless)
         samples -= (MPC_FRAME_LENGTH - si->last_frame_samples);
-    }
-    else {
+    else
         samples -= MPC_DECODER_SYNTH_DELAY;
-    }
     return samples;
 }
Index: /libmpcdec/branches/zorg/src/synth_filter.c
===================================================================
--- /libmpcdec/branches/zorg/src/synth_filter.c	(revision 67)
+++ /libmpcdec/branches/zorg/src/synth_filter.c	(revision 68)
@@ -32,17 +32,16 @@
   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
-
 /// \file synth_filter.c
 /// Synthesis functions.
 /// \todo document me
-
+#include <string.h>
 #include <mpcdec/mpcdec.h>
-#include <mpcdec/internal.h>
+#include "decoder.h"
+#include "math.h"
 
 /* C O N S T A N T S */
+#define MPC_FIXED_POINT_SYNTH_FIX 2
+
 #undef _
-
-#define MPC_FIXED_POINT_SYNTH_FIX 2
-
 #ifdef MPC_FIXED_POINT
 #define _(value)  MPC_MAKE_FRACT_CONST((double)value/(double)(0x40000))
@@ -89,29 +88,30 @@
 #undef  _
 
-static void Calculate_New_V ( const MPC_SAMPLE_FORMAT * Sample, MPC_SAMPLE_FORMAT * V )
+static void
+mpc_compute_new_V(const MPC_SAMPLE_FORMAT* p_sample, MPC_SAMPLE_FORMAT* pV)
 {
     // Calculating new V-buffer values for left channel
     // calculate new V-values (ISO-11172-3, p. 39)
     // based upon fast-MDCT algorithm by Byeong Gi Lee
-    /*static*/ MPC_SAMPLE_FORMAT A00, A01, A02, A03, A04, A05, A06, A07, A08, A09, A10, A11, A12, A13, A14, A15;
-    /*static*/ MPC_SAMPLE_FORMAT B00, B01, B02, B03, B04, B05, B06, B07, B08, B09, B10, B11, B12, B13, B14, B15;
+    MPC_SAMPLE_FORMAT A00, A01, A02, A03, A04, A05, A06, A07, A08, A09, A10, A11, A12, A13, A14, A15;
+    MPC_SAMPLE_FORMAT B00, B01, B02, B03, B04, B05, B06, B07, B08, B09, B10, B11, B12, B13, B14, B15;
     MPC_SAMPLE_FORMAT tmp;
 
-    A00 = Sample[ 0] + Sample[31];
-    A01 = Sample[ 1] + Sample[30];
-    A02 = Sample[ 2] + Sample[29];
-    A03 = Sample[ 3] + Sample[28];
-    A04 = Sample[ 4] + Sample[27];
-    A05 = Sample[ 5] + Sample[26];
-    A06 = Sample[ 6] + Sample[25];
-    A07 = Sample[ 7] + Sample[24];
-    A08 = Sample[ 8] + Sample[23];
-    A09 = Sample[ 9] + Sample[22];
-    A10 = Sample[10] + Sample[21];
-    A11 = Sample[11] + Sample[20];
-    A12 = Sample[12] + Sample[19];
-    A13 = Sample[13] + Sample[18];
-    A14 = Sample[14] + Sample[17];
-    A15 = Sample[15] + Sample[16];
+    A00 = p_sample[ 0] + p_sample[31];
+    A01 = p_sample[ 1] + p_sample[30];
+    A02 = p_sample[ 2] + p_sample[29];
+    A03 = p_sample[ 3] + p_sample[28];
+    A04 = p_sample[ 4] + p_sample[27];
+    A05 = p_sample[ 5] + p_sample[26];
+    A06 = p_sample[ 6] + p_sample[25];
+    A07 = p_sample[ 7] + p_sample[24];
+    A08 = p_sample[ 8] + p_sample[23];
+    A09 = p_sample[ 9] + p_sample[22];
+    A10 = p_sample[10] + p_sample[21];
+    A11 = p_sample[11] + p_sample[20];
+    A12 = p_sample[12] + p_sample[19];
+    A13 = p_sample[13] + p_sample[18];
+    A14 = p_sample[14] + p_sample[17];
+    A15 = p_sample[15] + p_sample[16];
 
     B00 = A00 + A15;
@@ -183,35 +183,35 @@
     A15 = MPC_MULTIPLY_FRACT_CONST_FIX((B14 - B15) , 0.7071067691f , 1);
 
-    V[48] = -A00;
-    V[ 0] =  A01;
-    V[40] = -A02 - (V[ 8] = A03);
-    V[36] = -((V[ 4] = A05 + (V[12] = A07)) + A06);
-    V[44] = - A04 - A06 - A07;
-    V[ 6] = (V[10] = A11 + (V[14] = A15)) + A13;
-    V[38] = (V[34] = -(V[ 2] = A09 + A13 + A15) - A14) + A09 - A10 - A11;
-    V[46] = (tmp = -(A12 + A14 + A15)) - A08;
-    V[42] = tmp - A10 - A11;
-
-    A00 = MPC_MULTIPLY_FRACT_CONST_SHR((Sample[ 0] - Sample[31]) , 0.5006030202f ,     MPC_FIXED_POINT_SYNTH_FIX);
-    A01 = MPC_MULTIPLY_FRACT_CONST_SHR((Sample[ 1] - Sample[30]) , 0.5054709315f ,     MPC_FIXED_POINT_SYNTH_FIX);
-    A02 = MPC_MULTIPLY_FRACT_CONST_SHR((Sample[ 2] - Sample[29]) , 0.5154473186f ,     MPC_FIXED_POINT_SYNTH_FIX);
-    A03 = MPC_MULTIPLY_FRACT_CONST_SHR((Sample[ 3] - Sample[28]) , 0.5310425758f ,     MPC_FIXED_POINT_SYNTH_FIX);
-    A04 = MPC_MULTIPLY_FRACT_CONST_SHR((Sample[ 4] - Sample[27]) , 0.5531039238f ,     MPC_FIXED_POINT_SYNTH_FIX);
-    A05 = MPC_MULTIPLY_FRACT_CONST_SHR((Sample[ 5] - Sample[26]) , 0.5829349756f ,     MPC_FIXED_POINT_SYNTH_FIX);
-    A06 = MPC_MULTIPLY_FRACT_CONST_SHR((Sample[ 6] - Sample[25]) , 0.6225041151f ,     MPC_FIXED_POINT_SYNTH_FIX);
-    A07 = MPC_MULTIPLY_FRACT_CONST_SHR((Sample[ 7] - Sample[24]) , 0.6748083234f ,     MPC_FIXED_POINT_SYNTH_FIX);
-    A08 = MPC_MULTIPLY_FRACT_CONST_SHR((Sample[ 8] - Sample[23]) , 0.7445362806f ,     MPC_FIXED_POINT_SYNTH_FIX);
-    A09 = MPC_MULTIPLY_FRACT_CONST_SHR((Sample[ 9] - Sample[22]) , 0.8393496275f ,     MPC_FIXED_POINT_SYNTH_FIX);
-    A10 = MPC_MULTIPLY_FRACT_CONST_SHR((Sample[10] - Sample[21]) , 0.9725682139f ,     MPC_FIXED_POINT_SYNTH_FIX);
+    pV[48] = -A00;
+    pV[ 0] =  A01;
+    pV[40] = -A02 - (pV[ 8] = A03);
+    pV[36] = -((pV[ 4] = A05 + (pV[12] = A07)) + A06);
+    pV[44] = - A04 - A06 - A07;
+    pV[ 6] = (pV[10] = A11 + (pV[14] = A15)) + A13;
+    pV[38] = (pV[34] = -(pV[ 2] = A09 + A13 + A15) - A14) + A09 - A10 - A11;
+    pV[46] = (tmp = -(A12 + A14 + A15)) - A08;
+    pV[42] = tmp - A10 - A11;
+
+    A00 = MPC_MULTIPLY_FRACT_CONST_SHR((p_sample[ 0] - p_sample[31]) , 0.5006030202f ,     MPC_FIXED_POINT_SYNTH_FIX);
+    A01 = MPC_MULTIPLY_FRACT_CONST_SHR((p_sample[ 1] - p_sample[30]) , 0.5054709315f ,     MPC_FIXED_POINT_SYNTH_FIX);
+    A02 = MPC_MULTIPLY_FRACT_CONST_SHR((p_sample[ 2] - p_sample[29]) , 0.5154473186f ,     MPC_FIXED_POINT_SYNTH_FIX);
+    A03 = MPC_MULTIPLY_FRACT_CONST_SHR((p_sample[ 3] - p_sample[28]) , 0.5310425758f ,     MPC_FIXED_POINT_SYNTH_FIX);
+    A04 = MPC_MULTIPLY_FRACT_CONST_SHR((p_sample[ 4] - p_sample[27]) , 0.5531039238f ,     MPC_FIXED_POINT_SYNTH_FIX);
+    A05 = MPC_MULTIPLY_FRACT_CONST_SHR((p_sample[ 5] - p_sample[26]) , 0.5829349756f ,     MPC_FIXED_POINT_SYNTH_FIX);
+    A06 = MPC_MULTIPLY_FRACT_CONST_SHR((p_sample[ 6] - p_sample[25]) , 0.6225041151f ,     MPC_FIXED_POINT_SYNTH_FIX);
+    A07 = MPC_MULTIPLY_FRACT_CONST_SHR((p_sample[ 7] - p_sample[24]) , 0.6748083234f ,     MPC_FIXED_POINT_SYNTH_FIX);
+    A08 = MPC_MULTIPLY_FRACT_CONST_SHR((p_sample[ 8] - p_sample[23]) , 0.7445362806f ,     MPC_FIXED_POINT_SYNTH_FIX);
+    A09 = MPC_MULTIPLY_FRACT_CONST_SHR((p_sample[ 9] - p_sample[22]) , 0.8393496275f ,     MPC_FIXED_POINT_SYNTH_FIX);
+    A10 = MPC_MULTIPLY_FRACT_CONST_SHR((p_sample[10] - p_sample[21]) , 0.9725682139f ,     MPC_FIXED_POINT_SYNTH_FIX);
 #if MPC_FIXED_POINT_SYNTH_FIX>=2
-    A11 = MPC_MULTIPLY_FRACT_CONST_SHR((Sample[11] - Sample[20]) , 1.1694399118f ,     MPC_FIXED_POINT_SYNTH_FIX);
-    A12 = MPC_MULTIPLY_FRACT_CONST_SHR((Sample[12] - Sample[19]) , 1.4841645956f ,     MPC_FIXED_POINT_SYNTH_FIX);
+    A11 = MPC_MULTIPLY_FRACT_CONST_SHR((p_sample[11] - p_sample[20]) , 1.1694399118f ,     MPC_FIXED_POINT_SYNTH_FIX);
+    A12 = MPC_MULTIPLY_FRACT_CONST_SHR((p_sample[12] - p_sample[19]) , 1.4841645956f ,     MPC_FIXED_POINT_SYNTH_FIX);
 #else
-    A11 = MPC_SCALE_CONST_SHR         ((Sample[11] - Sample[20]) , 1.1694399118f , 30, MPC_FIXED_POINT_SYNTH_FIX);
-    A12 = MPC_SCALE_CONST_SHR         ((Sample[12] - Sample[19]) , 1.4841645956f , 30, MPC_FIXED_POINT_SYNTH_FIX);
+    A11 = MPC_SCALE_CONST_SHR         ((p_sample[11] - p_sample[20]) , 1.1694399118f , 30, MPC_FIXED_POINT_SYNTH_FIX);
+    A12 = MPC_SCALE_CONST_SHR         ((p_sample[12] - p_sample[19]) , 1.4841645956f , 30, MPC_FIXED_POINT_SYNTH_FIX);
 #endif
-    A13 = MPC_SCALE_CONST_SHR         ((Sample[13] - Sample[18]) , 2.0577809811f , 29, MPC_FIXED_POINT_SYNTH_FIX);
-    A14 = MPC_SCALE_CONST_SHR         ((Sample[14] - Sample[17]) , 3.4076085091f , 29, MPC_FIXED_POINT_SYNTH_FIX);
-    A15 = MPC_SCALE_CONST_SHR         ((Sample[15] - Sample[16]) , 10.1900081635f, 27 ,MPC_FIXED_POINT_SYNTH_FIX);
+    A13 = MPC_SCALE_CONST_SHR         ((p_sample[13] - p_sample[18]) , 2.0577809811f , 29, MPC_FIXED_POINT_SYNTH_FIX);
+    A14 = MPC_SCALE_CONST_SHR         ((p_sample[14] - p_sample[17]) , 3.4076085091f , 29, MPC_FIXED_POINT_SYNTH_FIX);
+    A15 = MPC_SCALE_CONST_SHR         ((p_sample[15] - p_sample[16]) , 10.1900081635f, 27 ,MPC_FIXED_POINT_SYNTH_FIX);
 
     B00 =  A00 + A15;
@@ -284,97 +284,85 @@
 
     // mehrfach verwendete Ausdrücke: A04+A06+A07, A09+A13+A15
-    V[ 5] = (V[11] = (V[13] = A07 + (V[15] = A15)) + A11) + A05 + A13;
-    V[ 7] = (V[ 9] = A03 + A11 + A15) + A13;
-    V[33] = -(V[ 1] = A01 + A09 + A13 + A15) - A14;
-    V[35] = -(V[ 3] = A05 + A07 + A09 + A13 + A15) - A06 - A14;
-    V[37] = (tmp = -(A10 + A11 + A13 + A14 + A15)) - A05 - A06 - A07;
-    V[39] = tmp - A02 - A03;                      // abhängig vom Befehl drüber
-    V[41] = (tmp += A13 - A12) - A02 - A03;       // abhängig vom Befehl 2 drüber
-    V[43] = tmp - A04 - A06 - A07;                // abhängig von Befehlen 1 und 3 drüber
-    V[47] = (tmp = -(A08 + A12 + A14 + A15)) - A00;
-    V[45] = tmp - A04 - A06 - A07;                // abhängig vom Befehl drüber
-
-    V[32] = -V[ 0];
-    V[31] = -V[ 1];
-    V[30] = -V[ 2];
-    V[29] = -V[ 3];
-    V[28] = -V[ 4];
-    V[27] = -V[ 5];
-    V[26] = -V[ 6];
-    V[25] = -V[ 7];
-    V[24] = -V[ 8];
-    V[23] = -V[ 9];
-    V[22] = -V[10];
-    V[21] = -V[11];
-    V[20] = -V[12];
-    V[19] = -V[13];
-    V[18] = -V[14];
-    V[17] = -V[15];
-
-    V[63] =  V[33];
-    V[62] =  V[34];
-    V[61] =  V[35];
-    V[60] =  V[36];
-    V[59] =  V[37];
-    V[58] =  V[38];
-    V[57] =  V[39];
-    V[56] =  V[40];
-    V[55] =  V[41];
-    V[54] =  V[42];
-    V[53] =  V[43];
-    V[52] =  V[44];
-    V[51] =  V[45];
-    V[50] =  V[46];
-    V[49] =  V[47];
+    pV[ 5] = (pV[11] = (pV[13] = A07 + (pV[15] = A15)) + A11) + A05 + A13;
+    pV[ 7] = (pV[ 9] = A03 + A11 + A15) + A13;
+    pV[33] = -(pV[ 1] = A01 + A09 + A13 + A15) - A14;
+    pV[35] = -(pV[ 3] = A05 + A07 + A09 + A13 + A15) - A06 - A14;
+    pV[37] = (tmp = -(A10 + A11 + A13 + A14 + A15)) - A05 - A06 - A07;
+    pV[39] = tmp - A02 - A03;                      // abhängig vom Befehl drüber
+    pV[41] = (tmp += A13 - A12) - A02 - A03;       // abhängig vom Befehl 2 drüber
+    pV[43] = tmp - A04 - A06 - A07;                // abhängig von Befehlen 1 und 3 drüber
+    pV[47] = (tmp = -(A08 + A12 + A14 + A15)) - A00;
+    pV[45] = tmp - A04 - A06 - A07;                // abhängig vom Befehl drüber
+
+    pV[32] = -pV[ 0];
+    pV[31] = -pV[ 1];
+    pV[30] = -pV[ 2];
+    pV[29] = -pV[ 3];
+    pV[28] = -pV[ 4];
+    pV[27] = -pV[ 5];
+    pV[26] = -pV[ 6];
+    pV[25] = -pV[ 7];
+    pV[24] = -pV[ 8];
+    pV[23] = -pV[ 9];
+    pV[22] = -pV[10];
+    pV[21] = -pV[11];
+    pV[20] = -pV[12];
+    pV[19] = -pV[13];
+    pV[18] = -pV[14];
+    pV[17] = -pV[15];
+
+    pV[63] =  pV[33];
+    pV[62] =  pV[34];
+    pV[61] =  pV[35];
+    pV[60] =  pV[36];
+    pV[59] =  pV[37];
+    pV[58] =  pV[38];
+    pV[57] =  pV[39];
+    pV[56] =  pV[40];
+    pV[55] =  pV[41];
+    pV[54] =  pV[42];
+    pV[53] =  pV[43];
+    pV[52] =  pV[44];
+    pV[51] =  pV[45];
+    pV[50] =  pV[46];
+    pV[49] =  pV[47];
 }
 
-static void Synthese_Filter_float_internal(MPC_SAMPLE_FORMAT * OutData,MPC_SAMPLE_FORMAT * V,const MPC_SAMPLE_FORMAT * Y)
+static void 
+mpc_synthese_filter_float_internal(MPC_SAMPLE_FORMAT* p_out, MPC_SAMPLE_FORMAT* pV, const MPC_SAMPLE_FORMAT* pY)
 {
     mpc_uint32_t n;
-    for ( n = 0; n < 36; n++, Y += 32 ) {
-        V -= 64;
-        Calculate_New_V ( Y, V );
+    for ( n = 0; n < 36; n++, pY += 32 )
+    {
+        MPC_SAMPLE_FORMAT*       pData = p_out;
+        const MPC_SAMPLE_FORMAT* pD    = (const MPC_SAMPLE_FORMAT*) &Di_opt;
+        mpc_int32_t k;
+        pV -= 64;
+        mpc_compute_new_V( pY, pV );
+        for ( k = 0; k < 32; k++, pD += 16, pV++ )
         {
-            MPC_SAMPLE_FORMAT * Data = OutData;
-            const MPC_SAMPLE_FORMAT *  D = (const MPC_SAMPLE_FORMAT *) &Di_opt;
-            mpc_int32_t           k;
-            //mpc_int32_t           tmp;
-
-            
-            
-            for ( k = 0; k < 32; k++, D += 16, V++ ) {
-                *Data = MPC_SHL(
-                    MPC_MULTIPLY_FRACT(V[  0],D[ 0]) + MPC_MULTIPLY_FRACT(V[ 96],D[ 1]) + MPC_MULTIPLY_FRACT(V[128],D[ 2]) + MPC_MULTIPLY_FRACT(V[224],D[ 3])
-                    + MPC_MULTIPLY_FRACT(V[256],D[ 4]) + MPC_MULTIPLY_FRACT(V[352],D[ 5]) + MPC_MULTIPLY_FRACT(V[384],D[ 6]) + MPC_MULTIPLY_FRACT(V[480],D[ 7])
-                    + MPC_MULTIPLY_FRACT(V[512],D[ 8]) + MPC_MULTIPLY_FRACT(V[608],D[ 9]) + MPC_MULTIPLY_FRACT(V[640],D[10]) + MPC_MULTIPLY_FRACT(V[736],D[11])
-                    + MPC_MULTIPLY_FRACT(V[768],D[12]) + MPC_MULTIPLY_FRACT(V[864],D[13]) + MPC_MULTIPLY_FRACT(V[896],D[14]) + MPC_MULTIPLY_FRACT(V[992],D[15])
-                    , 2);
-                
-                Data += 2;
-            }
-            V -= 32;//bleh
-            OutData+=64;
+            *pData = MPC_SHL(
+                     MPC_MULTIPLY_FRACT(pV[  0], pD[ 0]) + MPC_MULTIPLY_FRACT(pV[ 96], pD[ 1]) + MPC_MULTIPLY_FRACT(pV[128], pD[ 2]) + MPC_MULTIPLY_FRACT(pV[224], pD[ 3])
+                   + MPC_MULTIPLY_FRACT(pV[256], pD[ 4]) + MPC_MULTIPLY_FRACT(pV[352], pD[ 5]) + MPC_MULTIPLY_FRACT(pV[384], pD[ 6]) + MPC_MULTIPLY_FRACT(pV[480], pD[ 7])
+                   + MPC_MULTIPLY_FRACT(pV[512], pD[ 8]) + MPC_MULTIPLY_FRACT(pV[608], pD[ 9]) + MPC_MULTIPLY_FRACT(pV[640], pD[10]) + MPC_MULTIPLY_FRACT(pV[736], pD[11])
+                   + MPC_MULTIPLY_FRACT(pV[768], pD[12]) + MPC_MULTIPLY_FRACT(pV[864], pD[13]) + MPC_MULTIPLY_FRACT(pV[896], pD[14]) + MPC_MULTIPLY_FRACT(pV[992], pD[15])
+                   , 2);
+            pData += 2;
         }
+        pV    -= 32; //bleh
+        p_out += 64;
     }
 }
 
 void
-mpc_decoder_synthese_filter_float(mpc_decoder *d, MPC_SAMPLE_FORMAT* OutData) 
+mpc_decoder_synthese_filter_float(mpc_decoder* p_dec, MPC_SAMPLE_FORMAT* p_out) 
 {
     /********* left channel ********/
-    memmove(d->V_L + MPC_V_MEM, d->V_L, 960 * sizeof(MPC_SAMPLE_FORMAT) );
-
-    Synthese_Filter_float_internal(
-        OutData,
-        (MPC_SAMPLE_FORMAT *)(d->V_L + MPC_V_MEM),
-        (MPC_SAMPLE_FORMAT *)(d->Y_L [0]));
+    memmove(&p_dec->V_L[MPC_V_MEM], p_dec->V_L, 960 * sizeof *p_dec->V_L);
+    mpc_synthese_filter_float_internal(p_out, &p_dec->V_L[MPC_V_MEM], p_dec->Y_L[0]);
 
     /******** right channel ********/
-    memmove(d->V_R + MPC_V_MEM, d->V_R, 960 * sizeof(MPC_SAMPLE_FORMAT) );
-
-    Synthese_Filter_float_internal(
-        OutData + 1,
-        (MPC_SAMPLE_FORMAT *)(d->V_R + MPC_V_MEM),
-        (MPC_SAMPLE_FORMAT *)(d->Y_R [0]));
+    memmove(&p_dec->V_R[MPC_V_MEM], p_dec->V_R, 960 * sizeof *p_dec->V_R);
+    mpc_synthese_filter_float_internal(p_out + 1, &p_dec->V_R[MPC_V_MEM], p_dec->Y_R[0]);
 }
 
@@ -385,5 +373,5 @@
 /*******************************************/
 
-static const unsigned char    Parity [256] = {  // parity
+static const mpc_uint8_t Parity [256] = {  // parity
     0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,
     1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,
@@ -423,18 +411,18 @@
  */
 mpc_uint32_t
-mpc_random_int(mpc_decoder *d) 
+mpc_random_int(mpc_decoder* p_dec) 
 {
 #if 1
     mpc_uint32_t  t1, t2, t3, t4;
 
-    t3   = t1 = d->__r1;   t4   = t2 = d->__r2;  // Parity calculation is done via table lookup, this is also available
-    t1  &= 0xF5;        t2 >>= 25;               // on CPUs without parity, can be implemented in C and avoid unpredictable
-    t1   = Parity [t1]; t2  &= 0x63;             // jumps and slow rotate through the carry flag operations.
-    t1 <<= 31;          t2   = Parity [t2];
-
-    return (d->__r1 = (t3 >> 1) | t1 ) ^ (d->__r2 = (t4 + t4) | t2 );
+    t3   = t1 = p_dec->__r1; t4   = t2 = p_dec->__r2; // Parity calculation is done via table lookup, this is also available
+    t1  &= 0xF5;             t2 >>= 25;               // on CPUs without parity, can be implemented in C and avoid unpredictable
+    t1   = Parity[t1];       t2  &= 0x63;             // jumps and slow rotate through the carry flag operations.
+    t1 <<= 31;               t2   = Parity[t2];
+
+    return (p_dec->__r1 = (t3 >> 1) | t1 ) ^ (p_dec->__r2 = (t4 + t4) | t2 );
 #else
-    return (d->__r1 = (d->__r1 >> 1) | ((mpc_uint32_t)Parity [d->__r1 & 0xF5] << 31) ) ^
-        (d->__r2 = (d->__r2 << 1) |  (mpc_uint32_t)Parity [(d->__r2 >> 25) & 0x63] );
+    return (p_dec->__r1 = (p_dec->__r1 >> 1) | ((mpc_uint32_t) Parity[ p_dec->__r1 & 0xF5] << 31))
+         ^ (p_dec->__r2 = (p_dec->__r2 << 1) |  (mpc_uint32_t) Parity[(p_dec->__r2 >> 25) & 0x63]);
 #endif
 }
Index: /libmpcdec/branches/zorg/win32/libmpcdec.sln
===================================================================
--- /libmpcdec/branches/zorg/win32/libmpcdec.sln	(revision 67)
+++ /libmpcdec/branches/zorg/win32/libmpcdec.sln	(revision 68)
@@ -4,8 +4,7 @@
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmpcdec", "libmpcdec.vcproj", "{4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}"
 EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sample", "sample.vcproj", "{E6B9828A-A74A-4D82-B1CA-2149E22EBF8C}"
-	ProjectSection(ProjectDependencies) = postProject
-		{4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3} = {4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}
-	EndProjectSection
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libwavformat", "libwavformat.vcproj", "{13D176A2-B6BB-403F-A816-AA1F388078B7}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpcdec", "mpcdec.vcproj", "{A527175B-22A9-41AB-B2E8-580F573CCAFB}"
 EndProject
 Global
@@ -19,8 +18,12 @@
 		{4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}.Release|Win32.ActiveCfg = Release|Win32
 		{4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}.Release|Win32.Build.0 = Release|Win32
-		{E6B9828A-A74A-4D82-B1CA-2149E22EBF8C}.Debug|Win32.ActiveCfg = Debug|Win32
-		{E6B9828A-A74A-4D82-B1CA-2149E22EBF8C}.Debug|Win32.Build.0 = Debug|Win32
-		{E6B9828A-A74A-4D82-B1CA-2149E22EBF8C}.Release|Win32.ActiveCfg = Release|Win32
-		{E6B9828A-A74A-4D82-B1CA-2149E22EBF8C}.Release|Win32.Build.0 = Release|Win32
+		{13D176A2-B6BB-403F-A816-AA1F388078B7}.Debug|Win32.ActiveCfg = Debug|Win32
+		{13D176A2-B6BB-403F-A816-AA1F388078B7}.Debug|Win32.Build.0 = Debug|Win32
+		{13D176A2-B6BB-403F-A816-AA1F388078B7}.Release|Win32.ActiveCfg = Release|Win32
+		{13D176A2-B6BB-403F-A816-AA1F388078B7}.Release|Win32.Build.0 = Release|Win32
+		{A527175B-22A9-41AB-B2E8-580F573CCAFB}.Debug|Win32.ActiveCfg = Debug|Win32
+		{A527175B-22A9-41AB-B2E8-580F573CCAFB}.Debug|Win32.Build.0 = Debug|Win32
+		{A527175B-22A9-41AB-B2E8-580F573CCAFB}.Release|Win32.ActiveCfg = Release|Win32
+		{A527175B-22A9-41AB-B2E8-580F573CCAFB}.Release|Win32.Build.0 = Release|Win32
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
Index: /libmpcdec/branches/zorg/win32/libmpcdec.vcproj
===================================================================
--- /libmpcdec/branches/zorg/win32/libmpcdec.vcproj	(revision 67)
+++ /libmpcdec/branches/zorg/win32/libmpcdec.vcproj	(revision 68)
@@ -140,64 +140,60 @@
 	<Files>
 		<Filter
-			Name="Source Files"
-			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
-			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
-			>
-			<File
-				RelativePath="..\src\huffsv46.c"
-				>
-			</File>
-			<File
-				RelativePath="..\src\huffsv7.c"
-				>
-			</File>
-			<File
-				RelativePath="..\src\idtag.c"
-				>
-			</File>
-			<File
-				RelativePath="..\src\mpc_decoder.c"
-				>
-			</File>
-			<File
-				RelativePath="..\src\mpc_reader.c"
-				>
-			</File>
-			<File
-				RelativePath="..\src\requant.c"
-				>
-			</File>
-			<File
-				RelativePath="..\src\streaminfo.c"
-				>
-			</File>
-			<File
-				RelativePath="..\src\synth_filter.c"
+			Name="Headers"
+			>
+			<File
+				RelativePath="..\src\decoder.h"
+				>
+			</File>
+			<File
+				RelativePath="..\src\huffman.h"
+				>
+			</File>
+			<File
+				RelativePath="..\src\internal.h"
+				>
+			</File>
+			<File
+				RelativePath="..\src\math.h"
+				>
+			</File>
+			<File
+				RelativePath="..\src\requant.h"
 				>
 			</File>
 		</Filter>
 		<Filter
-			Name="Header Files"
-			Filter="h;hpp;hxx;hm;inl;inc;xsd"
-			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
-			>
-			<File
-				RelativePath="..\include\mpcdec\config_win32.h"
-				>
-			</File>
-			<File
-				RelativePath="..\include\mpcdec\decoder.h"
-				>
-			</File>
-			<File
-				RelativePath="..\include\mpcdec\huffman.h"
-				>
-			</File>
-			<File
-				RelativePath="..\include\mpcdec\internal.h"
-				>
-			</File>
-			<File
-				RelativePath="..\include\mpcdec\math.h"
+			Name="Sources"
+			>
+			<File
+				RelativePath="..\src\huffman.c"
+				>
+			</File>
+			<File
+				RelativePath="..\src\mpc_decoder.c"
+				>
+			</File>
+			<File
+				RelativePath="..\src\mpc_reader.c"
+				>
+			</File>
+			<File
+				RelativePath="..\src\requant.c"
+				>
+			</File>
+			<File
+				RelativePath="..\src\streaminfo.c"
+				>
+			</File>
+			<File
+				RelativePath="..\src\synth_filter.c"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Interface"
+			>
+			<File
+				RelativePath="..\include\mpcdec\mpc_types.h"
 				>
 			</File>
@@ -208,8 +204,4 @@
 			<File
 				RelativePath="..\include\mpcdec\reader.h"
-				>
-			</File>
-			<File
-				RelativePath="..\include\mpcdec\requant.h"
 				>
 			</File>
Index: /libmpcdec/branches/zorg/win32/libwavformat.vcproj
===================================================================
--- /libmpcdec/branches/zorg/win32/libwavformat.vcproj	(revision 68)
+++ /libmpcdec/branches/zorg/win32/libwavformat.vcproj	(revision 68)
@@ -0,0 +1,167 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8,00"
+	Name="libwavformat"
+	ProjectGUID="{13D176A2-B6BB-403F-A816-AA1F388078B7}"
+	RootNamespace="libwavformat"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="4"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="4"
+			CharacterSet="1"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
+				RuntimeLibrary="0"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="0"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Headers"
+			>
+			<File
+				RelativePath="..\libwavformat\libwaveformat.h"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Sources"
+			>
+			<File
+				RelativePath="..\libwavformat\input.c"
+				>
+			</File>
+			<File
+				RelativePath="..\libwavformat\output.c"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /libmpcdec/branches/zorg/win32/mpcdec.vcproj
===================================================================
--- /libmpcdec/branches/zorg/win32/mpcdec.vcproj	(revision 68)
+++ /libmpcdec/branches/zorg/win32/mpcdec.vcproj	(revision 68)
@@ -0,0 +1,184 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8,00"
+	Name="mpcdec"
+	ProjectGUID="{A527175B-22A9-41AB-B2E8-580F573CCAFB}"
+	RootNamespace="mpcdec"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="../include,../libwavformat"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				LinkIncremental="2"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="1"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				LinkIncremental="1"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Sources"
+			>
+			<File
+				RelativePath="..\mpcdec\mpcdec.c"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: bmpcdec/branches/zorg/win32/sample.vcproj
===================================================================
--- /libmpcdec/branches/zorg/win32/sample.vcproj	(revision 67)
+++ 	(revision )
@@ -1,183 +1,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
-	ProjectType="Visual C++"
-	Version="8,00"
-	Name="sample"
-	ProjectGUID="{E6B9828A-A74A-4D82-B1CA-2149E22EBF8C}"
-	>
-	<Platforms>
-		<Platform
-			Name="Win32"
-		/>
-	</Platforms>
-	<ToolFiles>
-	</ToolFiles>
-	<Configurations>
-		<Configuration
-			Name="Debug|Win32"
-			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
-			IntermediateDirectory="$(ConfigurationName)"
-			ConfigurationType="1"
-			CharacterSet="1"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				AdditionalIncludeDirectories="../include"
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
-				RuntimeLibrary="1"
-				BrowseInformation="1"
-				WarningLevel="3"
-				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="1"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				GenerateManifest="false"
-				GenerateDebugInformation="true"
-				GenerateMapFile="true"
-				MapExports="true"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-				EmbedManifest="false"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Release|Win32"
-			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
-			IntermediateDirectory="$(ConfigurationName)"
-			ConfigurationType="1"
-			CharacterSet="1"
-			WholeProgramOptimization="1"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				AdditionalIncludeDirectories="../include"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
-				GenerateManifest="false"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-				EmbedManifest="false"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-	</Configurations>
-	<References>
-	</References>
-	<Files>
-		<Filter
-			Name="Source Files"
-			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
-			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
-			>
-			<File
-				RelativePath="..\src\sample.cpp"
-				>
-			</File>
-		</Filter>
-		<Filter
-			Name="Header Files"
-			Filter="h;hpp;hxx;hm;inl;inc;xsd"
-			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
-			>
-		</Filter>
-	</Files>
-	<Globals>
-	</Globals>
-</VisualStudioProject>
