Index: trunk/AUTHORS
===================================================================
--- trunk/AUTHORS	(revision 1)
+++ trunk/AUTHORS	(revision 3)
@@ -1,3 +1,3 @@
-libmusepack is the result of the work of many people:
+libmpcdec is the result of the work of many people:
 
 * Andree Buschmann and Frank Klemm
Index: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	(revision 1)
+++ trunk/ChangeLog	(revision 3)
@@ -1,2 +1,13 @@
+1.2
+    * 1.1.1 broke the API (BOOL type changed to mpc_bool_t). Version bumped to 1.2 to reflect the major change. Sorry to those who were caught by this error
+    * Fixed relative/absolute includes (#include "stuff.h" in /include/mpcdec, #include <mpcdec/stuff> in src/)
+    * Added msvc project files
+    * Changed mpc_reader_t structure, any specific data of the reader's
+    implementations should be hidden behind the (void*) data pointer. (example
+    in default implementation mpc_reader_file)
+    * Renamed to libmpcdec (to make room for libmpcenc)
+
+1.1.1
+    * fix for fixed-point mode bug
 
 1.1
Index: trunk/INSTALL
===================================================================
--- trunk/INSTALL	(revision 1)
+++ trunk/INSTALL	(revision 3)
@@ -1,3 +1,3 @@
-How to install libmusepack:
-"./configure && make" as a regular user
+How to install libmpcdec:
+"./configure [--prefix=/usr] && make" as a regular user
 "make install" as root
Index: trunk/README
===================================================================
--- trunk/README	(revision 1)
+++ trunk/README	(revision 3)
@@ -1,3 +1,3 @@
-Musepack Decoder Library 1.1:
+Musepack Decoder Library 1.2:
 
 run "./configure; make"
Index: trunk/configure.ac
===================================================================
--- trunk/configure.ac	(revision 3)
+++ trunk/configure.ac	(revision 3)
@@ -0,0 +1,202 @@
+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)
+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: trunk/configure.in
===================================================================
--- trunk/configure.in	(revision 1)
+++ 	(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(libmusepack,1.1)
-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/musepack/config_types.h)
-AC_MSG_RESULT([ libmusepack $VERSION configured successfully.])
Index: trunk/docs/Doxyfile
===================================================================
--- trunk/docs/Doxyfile	(revision 1)
+++ trunk/docs/Doxyfile	(revision 3)
@@ -18,5 +18,5 @@
 # by quotes) that should identify the project.
 
-PROJECT_NAME           = libmusepack
+PROJECT_NAME           = libmpcdec
 
 # The PROJECT_NUMBER tag can be used to enter a project or revision number. 
@@ -24,5 +24,5 @@
 # if some version control system is used.
 
-PROJECT_NUMBER         = 1.1
+PROJECT_NUMBER         = 1.2
 
 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
Index: trunk/include/Makefile.am
===================================================================
--- trunk/include/Makefile.am	(revision 1)
+++ trunk/include/Makefile.am	(revision 3)
@@ -4,10 +4,10 @@
 
 nobase_include_HEADERS = \
-	musepack/config_types.h \
-	musepack/decoder.h \
-	musepack/huffman.h \
-	musepack/math.h \
-	musepack/musepack.h \
-	musepack/reader.h \
-	musepack/requant.h \
-	musepack/streaminfo.h
+	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: trunk/include/config.h.in
===================================================================
--- trunk/include/config.h.in	(revision 1)
+++ trunk/include/config.h.in	(revision 3)
@@ -1,3 +1,3 @@
-/* include/config.h.in.  Generated from configure.in by autoheader.  */
+/* include/config.h.in.  Generated from configure.ac by autoheader.  */
 
 /* Define to 1 if you have the <dlfcn.h> header file. */
@@ -92,7 +92,9 @@
 #undef const
 
-/* Define as `__inline' if that's what the C compiler calls it, or to nothing
-   if it is not supported. */
+/* 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. */
Index: trunk/include/mainpage.h
===================================================================
--- trunk/include/mainpage.h	(revision 1)
+++ trunk/include/mainpage.h	(revision 3)
@@ -1,14 +1,14 @@
 /**
-   \mainpage libmusepack documentation
+   \mainpage libmpcdec documentation
 
-   \section whats what is libmusepack
-   libmusepack is a library that decodes musepack compressed audio data.  Musepack
+   \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 libmusepack
+   \section using using libmpcdec
 
-   Using libmusepack is very straightforward.  There are typically four things you must
-   do to use libmusepack in your application.
+   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
@@ -35,4 +35,4 @@
 
    For a simple example of all of these steps see the sample application distributed with
-   libmusepack in src/sample.cpp.
+   libmpcdec in src/sample.cpp.
 */
Index: trunk/include/mpcdec/config_types.h.in
===================================================================
--- trunk/include/mpcdec/config_types.h.in	(revision 3)
+++ trunk/include/mpcdec/config_types.h.in	(revision 3)
@@ -0,0 +1,48 @@
+/*
+  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: trunk/include/mpcdec/config_win32.h
===================================================================
--- trunk/include/mpcdec/config_win32.h	(revision 3)
+++ trunk/include/mpcdec/config_win32.h	(revision 3)
@@ -0,0 +1,48 @@
+/*
+  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 __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;
+
+#endif // __MUSEPACK_CONFIG_WIN32_H__
Index: trunk/include/mpcdec/decoder.h
===================================================================
--- trunk/include/mpcdec/decoder.h	(revision 3)
+++ trunk/include/mpcdec/decoder.h	(revision 3)
@@ -0,0 +1,148 @@
+/*
+  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"
+
+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; /// actually 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  FwdJumpInfo;
+    mpc_uint32_t  ActDecodePos;
+    mpc_uint32_t  FrameWasValid;
+
+    mpc_uint32_t  DecodedFrames;
+    mpc_uint32_t  OverallFrames;
+    mpc_int32_t   SampleRate;                 // Sample frequency
+
+    mpc_uint32_t  StreamVersion;              // version of bitstream
+    mpc_uint32_t  MS_used;                    // MS-coding used ?
+    mpc_int32_t   Max_Band;
+    mpc_uint32_t  MPCHeaderPos;               // AB: needed to support ID3v2
+    mpc_uint32_t  LastValidSamples;
+    mpc_uint32_t  TrueGaplessPresent;
+
+    mpc_uint32_t  EQ_activated;
+
+    mpc_uint32_t  WordsRead;                  // counts amount of decoded dwords
+
+    // randomizer state variables
+    mpc_uint32_t  __r1; 
+    mpc_uint32_t  __r2; 
+
+    mpc_uint32_t  Q_bit [32];     
+    mpc_uint32_t  Q_res [32][16];
+
+    // huffman table stuff
+    HuffmanTyp    HuffHdr  [10];
+    HuffmanTyp    HuffSCFI [ 4];
+    HuffmanTyp    HuffDSCF [16];
+    HuffmanTyp*   HuffQ [2] [8];
+
+    HuffmanTyp    HuffQ1 [2] [3*3*3];
+    HuffmanTyp    HuffQ2 [2] [5*5];
+    HuffmanTyp    HuffQ3 [2] [ 7];
+    HuffmanTyp    HuffQ4 [2] [ 9];
+    HuffmanTyp    HuffQ5 [2] [15];
+    HuffmanTyp    HuffQ6 [2] [31];
+    HuffmanTyp    HuffQ7 [2] [63];
+    const HuffmanTyp* SampleHuff [18];
+    HuffmanTyp    SCFI_Bundle   [ 8];
+    HuffmanTyp    DSCF_Entropie [13];
+    HuffmanTyp    Region_A [16];
+    HuffmanTyp    Region_B [ 8];
+    HuffmanTyp    Region_C [ 4];
+
+    HuffmanTyp    Entropie_1 [ 3];
+    HuffmanTyp    Entropie_2 [ 5];
+    HuffmanTyp    Entropie_3 [ 7];
+    HuffmanTyp    Entropie_4 [ 9];
+    HuffmanTyp    Entropie_5 [15];
+    HuffmanTyp    Entropie_6 [31];
+    HuffmanTyp    Entropie_7 [63];
+
+    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_int32_t   DSCF_Flag_L [32];
+    mpc_int32_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_int32_t   DSCF_Reference_L [32];
+    mpc_int32_t   DSCF_Reference_R [32];      // holds last frames SCF
+    mpc_int32_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: trunk/include/mpcdec/huffman.h
===================================================================
--- trunk/include/mpcdec/huffman.h	(revision 3)
+++ trunk/include/mpcdec/huffman.h	(revision 3)
@@ -0,0 +1,80 @@
+/*
+  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_uint32_t  Length;
+    mpc_int32_t   Value;
+} HuffmanTyp;
+
+//! \brief Sorts huffman-tables by codeword.
+//!
+//! offset resulting value.
+//! \param elements
+//! \param Table table to sort
+//! \param offset offset of resulting sort
+void
+mpc_decoder_resort_huff_tables(
+    const mpc_uint32_t elements, HuffmanTyp *Table, const mpc_int32_t offset);
+
+/// Initializes sv6 huffman decoding structures.
+void mpc_decoder_init_huffman_sv6(struct mpc_decoder_t *d);
+
+/// Initializes sv6 huffman decoding tables.
+void mpc_decoder_init_huffman_sv6_tables(struct mpc_decoder_t *d);
+
+/// Initializes sv7 huffman decoding structures.
+void mpc_decoder_init_huffman_sv7(struct mpc_decoder_t *d);
+
+/// Initializes sv7 huffman decoding tables.
+void mpc_decoder_init_huffman_sv7_tables(struct mpc_decoder_t *d);
+
+#endif // _mpcdec_huffman_h_
Index: trunk/include/mpcdec/internal.h
===================================================================
--- trunk/include/mpcdec/internal.h	(revision 3)
+++ trunk/include/mpcdec/internal.h	(revision 3)
@@ -0,0 +1,67 @@
+/*
+  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 swap32(mpc_uint32_t val) {
+    const unsigned char* src = (const unsigned char*)&val;
+    return 
+        (mpc_uint32_t)src[0] | 
+        ((mpc_uint32_t)src[1] << 8) | ((mpc_uint32_t)src[2] << 16) | ((mpc_uint32_t)src[3] << 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: trunk/include/mpcdec/math.h
===================================================================
--- trunk/include/mpcdec/math.h	(revision 3)
+++ trunk/include/mpcdec/math.h	(revision 3)
@@ -0,0 +1,144 @@
+/*
+  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: trunk/include/mpcdec/musepack.h
===================================================================
--- trunk/include/mpcdec/musepack.h	(revision 3)
+++ trunk/include/mpcdec/musepack.h	(revision 3)
@@ -0,0 +1,128 @@
+/*
+  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 musepack.h
+/// Top level include file for libmusepack.
+
+#ifndef _musepack_h_
+#define _musepack_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#include "musepack/config_types.h"
+#include "musepack/decoder.h"
+#include "musepack/math.h"
+#include "musepack/reader.h"
+#include "musepack/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);
+
+/// 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);
+
+/// 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    
+BOOL mpc_decoder_initialize(mpc_decoder *d, 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);
+
+/// Actually reads data from previously initialized stream.  Call
+/// this iteratively to decode the mpc stream.
+/// \param buffer destination buffer for decoded samples
+/// \param vbr_update_acc \todo document me
+/// \param vbr_update_bits \todo document me
+/// \return -1 if an error is encountered
+/// \return 0 if the stream has been completely decoded successfully and there are no more samples
+/// \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_SAMPLE_FORMAT *buffer, 
+    mpc_uint32_t *vbr_update_acc, 
+    mpc_uint32_t *vbr_update_bits);
+
+/// Seeks to the specified sample in the source stream.
+BOOL mpc_decoder_seek_sample(mpc_decoder *d, mpc_int64_t destsample);
+
+/// Seeks to specified position in seconds in the source stream.
+BOOL mpc_decoder_seek_seconds(mpc_decoder *d, double seconds);
+
+#ifdef __cplusplus
+}
+#endif // __cplusplus
+
+#endif // _musepack_h_
Index: trunk/include/mpcdec/reader.h
===================================================================
--- trunk/include/mpcdec/reader.h	(revision 3)
+++ trunk/include/mpcdec/reader.h	(revision 3)
@@ -0,0 +1,82 @@
+/*
+  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 reader.h
+
+#ifndef _mpcdec_reader_h_
+#define _mpcdec_reader_h_
+
+/// \brief Stream reader interface structure.
+///
+/// This is the structure you must supply to the musepack decoding library
+/// to feed it with raw data.  Implement the five member functions to provide
+/// a functional reader.
+typedef 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);
+
+    /// Seeks to byte position offset.
+	mpc_bool_t (*seek)(void *t, mpc_int32_t offset);
+
+    /// Returns the current byte offset in the stream.
+	mpc_int32_t (*tell)(void *t);
+
+    /// Returns the total length of the source stream, in bytes.
+	mpc_int32_t (*get_size)(void *t);
+
+    /// True if the stream is a seekable stream.
+	mpc_bool_t (*canseek)(void *t);
+
+    /// 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);
+
+#endif // _mpcdec_reader_h_
Index: trunk/include/mpcdec/requant.h
===================================================================
--- trunk/include/mpcdec/requant.h	(revision 3)
+++ trunk/include/mpcdec/requant.h	(revision 3)
@@ -0,0 +1,51 @@
+/*
+  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: trunk/include/mpcdec/streaminfo.h
===================================================================
--- trunk/include/mpcdec/streaminfo.h	(revision 3)
+++ trunk/include/mpcdec/streaminfo.h	(revision 3)
@@ -0,0 +1,86 @@
+/*
+  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 streaminfo.h
+
+#ifndef _mpcdec_streaminfo_h_
+#define _mpcdec_streaminfo_h_
+
+typedef mpc_int32_t mpc_streaminfo_off_t;
+
+/// \brief mpc stream properties structure
+///
+/// Structure containing all the properties of an mpc stream.  Populated
+/// by the streaminfo_read function.
+typedef struct mpc_streaminfo {
+    /// @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
+    //@}
+
+    /// @name replaygain related fields
+    //@{
+    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
+    //@{
+    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_streaminfo_off_t tag_offset;         ///< offset to file tags
+    mpc_streaminfo_off_t total_file_length;  ///< total length of underlying file
+    //@}
+} mpc_streaminfo;
+
+#endif // _mpcdec_streaminfo_h_
Index: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am	(revision 1)
+++ trunk/src/Makefile.am	(revision 3)
@@ -3,9 +3,7 @@
 AUTOMAKE_OPTIONS = foreign
 
-INCLUDES = -I$(top_builddir)/include
+lib_LTLIBRARIES = libmpcdec.la
 
-lib_LTLIBRARIES = libmusepack.la
-
-libmusepack_la_SOURCES = \
+libmpcdec_la_SOURCES = \
 	huffsv46.c \
 	huffsv7.c \
@@ -16,8 +14,8 @@
 	streaminfo.c \
 	synth_filter.c
-libmusepack_la_LDFLAGS = -no-undefined -version-info 2:0:0
+libmpcdec_la_LDFLAGS = -no-undefined -version-info 3:0:0
 
 noinst_PROGRAMS = sample
 sample_SOURCES = sample.cpp
-sample_LDADD = libmusepack.la
+sample_LDADD = libmpcdec.la
 
Index: trunk/src/huffsv46.c
===================================================================
--- trunk/src/huffsv46.c	(revision 1)
+++ trunk/src/huffsv46.c	(revision 3)
@@ -36,7 +36,7 @@
 /// Implementations of huffman decoding for streamversions < 7.
 
-#include "musepack/musepack.h"
-#include "musepack/requant.h"
-#include "musepack/huffman.h"
+#include <mpcdec/mpcdec.h>
+#include <mpcdec/requant.h>
+#include <mpcdec/huffman.h>
 
 void
Index: trunk/src/huffsv7.c
===================================================================
--- trunk/src/huffsv7.c	(revision 1)
+++ trunk/src/huffsv7.c	(revision 3)
@@ -36,7 +36,7 @@
 /// Implementations of sv7 huffman decoding functions.
 
-#include "musepack/musepack.h"
-#include "musepack/huffman.h"
-#include "musepack/requant.h"
+#include <mpcdec/mpcdec.h>
+#include <mpcdec/huffman.h>
+#include <mpcdec/requant.h>
 
 void
Index: trunk/src/idtag.c
===================================================================
--- trunk/src/idtag.c	(revision 1)
+++ trunk/src/idtag.c	(revision 3)
@@ -37,6 +37,6 @@
 /// if present.
 
-#include "musepack/musepack.h"
-#include "musepack/internal.h"
+#include <mpcdec/mpcdec.h>
+#include <mpcdec/internal.h>
 
 mpc_int32_t
Index: trunk/src/mpc_decoder.c
===================================================================
--- trunk/src/mpc_decoder.c	(revision 1)
+++ trunk/src/mpc_decoder.c	(revision 3)
@@ -36,8 +36,8 @@
 /// Core decoding routines and logic.
 
-#include "musepack/musepack.h"
-#include "musepack/internal.h"
-#include "musepack/requant.h"
-#include "musepack/huffman.h"
+#include <mpcdec/mpcdec.h>
+#include <mpcdec/internal.h>
+#include <mpcdec/requant.h>
+#include <mpcdec/huffman.h>
 
 //------------------------------------------------------------------------------
@@ -62,5 +62,5 @@
 void mpc_decoder_read_bitstream_sv7(mpc_decoder *d);
 void mpc_decoder_update_buffer(mpc_decoder *d, mpc_uint32_t RING);
-BOOL mpc_decoder_seek_sample(mpc_decoder *d, mpc_int64_t destsample);
+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);
 
@@ -73,5 +73,5 @@
 };
 
-static BOOL f_seek(mpc_decoder *d, mpc_int32_t offset) 
+static mpc_bool_t f_seek(mpc_decoder *d, mpc_int32_t offset) 
 { 
     return d->r->seek(d->r->data, offset); 
@@ -992,5 +992,5 @@
         case -1:
             for (k=0; k<36; k++ ) {
-                tmp  = random_int(d);
+                tmp  = mpc_random_int(d);
                 *L++ = ((tmp >> 24) & 0xFF) + ((tmp >> 16) & 0xFF) + ((tmp >>  8) & 0xFF) + ((tmp >>  0) & 0xFF) - 510;
             }
@@ -1052,5 +1052,5 @@
         case -1:
                 for (k=0; k<36; k++ ) {
-                    tmp  = random_int(d);
+                    tmp  = mpc_random_int(d);
                     *R++ = ((tmp >> 24) & 0xFF) + ((tmp >> 16) & 0xFF) + ((tmp >>  8) & 0xFF) + ((tmp >>  0) & 0xFF) - 510;
                 }
@@ -1192,5 +1192,5 @@
 }
 
-BOOL mpc_decoder_initialize(mpc_decoder *d, mpc_streaminfo *si) 
+mpc_bool_t mpc_decoder_initialize(mpc_decoder *d, mpc_streaminfo *si) 
 {
     mpc_decoder_set_streaminfo(d, si);
@@ -1265,10 +1265,10 @@
 }
 
-BOOL mpc_decoder_seek_seconds(mpc_decoder *d, double seconds) 
+mpc_bool_t mpc_decoder_seek_seconds(mpc_decoder *d, double seconds) 
 {
     return mpc_decoder_seek_sample(d, (mpc_int64_t)(seconds * (double)d->SampleRate + 0.5));
 }
 
-BOOL mpc_decoder_seek_sample(mpc_decoder *d, mpc_int64_t destsample) 
+mpc_bool_t mpc_decoder_seek_sample(mpc_decoder *d, mpc_int64_t destsample) 
 {
     mpc_uint32_t fpos;
Index: trunk/src/mpc_reader.c
===================================================================
--- trunk/src/mpc_reader.c	(revision 1)
+++ trunk/src/mpc_reader.c	(revision 3)
@@ -36,5 +36,5 @@
 /// Contains implementations for simple file-based mpc_reader
 
-#include "musepack/musepack.h"
+#include <mpcdec/mpcdec.h>
 
 /// mpc_reader callback implementations
@@ -42,13 +42,13 @@
 read_impl(void *data, void *ptr, mpc_int32_t size)
 {
-    mpc_reader *d = (mpc_reader *) data;
+    mpc_reader_file *d = (mpc_reader_file *) data;
 
     return fread(ptr, 1, size, d->file);
 }
 
-static BOOL
-seek_impl(void *data, int offset)
+static mpc_bool_t
+seek_impl(void *data, mpc_int32_t offset)
 {
-    mpc_reader *d = (mpc_reader *) data;
+    mpc_reader_file *d = (mpc_reader_file *) data;
 
     return d->is_seekable ? !fseek(d->file, offset, SEEK_SET) : FALSE;
@@ -58,5 +58,5 @@
 tell_impl(void *data)
 {
-    mpc_reader *d = (mpc_reader *) data;
+    mpc_reader_file *d = (mpc_reader_file *) data;
 
     return ftell(d->file);
@@ -66,13 +66,13 @@
 get_size_impl(void *data)
 {
-    mpc_reader *d = (mpc_reader *) data;
+    mpc_reader_file *d = (mpc_reader_file *) data;
 
     return d->file_size;
 }
 
-static BOOL
+static mpc_bool_t
 canseek_impl(void *data)
 {
-    mpc_reader *d = (mpc_reader *) data;
+    mpc_reader_file *d = (mpc_reader_file *) data;
 
     return d->is_seekable;
@@ -80,17 +80,17 @@
 
 void
-mpc_reader_setup_file_reader(mpc_reader *reader, FILE *input)
+mpc_reader_setup_file_reader(mpc_reader_file *p_reader, FILE *input)
 {
-    reader->seek = seek_impl;
-    reader->read = read_impl;
-    reader->tell = tell_impl;
-    reader->get_size = get_size_impl;
-    reader->canseek = canseek_impl;
-    reader->data = reader; // point back to ourselves
+    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
 
-    reader->file = input;
-    reader->is_seekable = TRUE;
-    fseek(reader->file, 0, SEEK_END);
-    reader->file_size = ftell(reader->file);
-    fseek(reader->file, 0, SEEK_SET);
+    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);
 }
Index: trunk/src/requant.c
===================================================================
--- trunk/src/requant.c	(revision 1)
+++ trunk/src/requant.c	(revision 3)
@@ -37,6 +37,6 @@
 /// \todo document me
 
-#include "musepack/musepack.h"
-#include "musepack/internal.h"
+#include <mpcdec/mpcdec.h>
+#include <mpcdec/internal.h>
 
 /* C O N S T A N T S */
@@ -84,5 +84,5 @@
 /* F U N C T I O N S */
 
-#define SET_SCF(N,X) d->SCF[N] = MAKE_MPC_SAMPLE_EX(X,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] = (unsigned char)find_shift(X));
 
 void
Index: trunk/src/sample.cpp
===================================================================
--- trunk/src/sample.cpp	(revision 1)
+++ trunk/src/sample.cpp	(revision 3)
@@ -37,5 +37,5 @@
 #include <time.h>
 
-#include "musepack/musepack.h"
+#include <mpcdec/mpcdec.h>
 
 /*
@@ -46,5 +46,5 @@
     FILE *file;
     long size;
-    BOOL seekable;
+    mpc_bool_t seekable;
 } reader_data;
 
@@ -59,5 +59,5 @@
 }
 
-BOOL
+mpc_bool_t
 seek_impl(void *data, mpc_int32_t offset)
 {
@@ -80,5 +80,5 @@
 }
 
-BOOL
+mpc_bool_t
 canseek_impl(void *data)
 {
@@ -133,5 +133,5 @@
 
         m_data_bytes_written = 0;
-    } BOOL WriteSamples(const MPC_SAMPLE_FORMAT * p_buffer, unsigned p_size) {
+    } mpc_bool_t WriteSamples(const MPC_SAMPLE_FORMAT * p_buffer, unsigned p_size) {
         unsigned n;
         int clip_min = -1 << (m_bps - 1),
@@ -172,21 +172,21 @@
   private:
 
-    BOOL Seek(unsigned p_offset) {
+    mpc_bool_t Seek(unsigned p_offset) {
         return !fseek(m_file, p_offset, SEEK_SET);
     }
 
-    BOOL WriteRaw(const void *p_buffer, unsigned p_bytes) {
+    mpc_bool_t WriteRaw(const void *p_buffer, unsigned p_bytes) {
         return fwrite(p_buffer, 1, p_bytes, m_file) == p_bytes;
     }
 
-    BOOL WriteDword(unsigned long p_val) {
+    mpc_bool_t WriteDword(unsigned long p_val) {
         return WriteInt(p_val, 32);
     }
-    BOOL WriteWord(unsigned short p_val) {
+    mpc_bool_t WriteWord(unsigned short p_val) {
         return WriteInt(p_val, 16);
     }
 
     // write a little-endian number properly
-    BOOL WriteInt(unsigned int p_val, unsigned p_width_bits) {
+    mpc_bool_t WriteInt(unsigned int p_val, unsigned p_width_bits) {
         unsigned char temp;
         unsigned shift = 0;
@@ -284,5 +284,5 @@
     begin = clock();
     unsigned total_samples = 0;
-    BOOL successful = FALSE;
+    mpc_bool_t successful = FALSE;
     for (;;) {
         unsigned status = mpc_decoder_decode(&decoder, sample_buffer, 0, 0);
Index: trunk/src/streaminfo.c
===================================================================
--- trunk/src/streaminfo.c	(revision 1)
+++ trunk/src/streaminfo.c	(revision 3)
@@ -36,6 +36,6 @@
 /// Implementation of streaminfo reading functions.
 
-#include "musepack/musepack.h"
-#include "musepack/internal.h"
+#include <mpcdec/mpcdec.h>
+#include <mpcdec/internal.h>
 
 static const char *
Index: trunk/src/synth_filter.c
===================================================================
--- trunk/src/synth_filter.c	(revision 1)
+++ trunk/src/synth_filter.c	(revision 3)
@@ -37,6 +37,6 @@
 /// \todo document me
 
-#include "musepack/musepack.h"
-#include "musepack/internal.h"
+#include <mpcdec/mpcdec.h>
+#include <mpcdec/internal.h>
 
 typedef mpc_int32_t ptrdiff_t;
@@ -425,5 +425,5 @@
  */
 mpc_uint32_t
-random_int(mpc_decoder *d) 
+mpc_random_int(mpc_decoder *d) 
 {
 #if 1
Index: trunk/win32/libmpcdec.dsp
===================================================================
--- trunk/win32/libmpcdec.dsp	(revision 3)
+++ trunk/win32/libmpcdec.dsp	(revision 3)
@@ -0,0 +1,233 @@
+# Microsoft Developer Studio Project File - Name="libmpcdec" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
+
+CFG=libmpcdec - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "libmpcdec.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "libmpcdec.mak" CFG="libmpcdec - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "libmpcdec - Win32 Release" (based on "Win32 (x86) Static Library")
+!MESSAGE "libmpcdec - Win32 Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=xicl6.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "libmpcdec - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "LibRelease"
+# PROP Intermediate_Dir "LibRelease"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /W3 /O2 /I "..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "MPC_LITTLE_ENDIAN" /FR /FD /c
+# ADD BASE RSC /l 0x40c /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=xilink6.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ELSEIF  "$(CFG)" == "libmpcdec - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "LibDebug"
+# PROP Intermediate_Dir "LibDebug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "MPC_LITTLE_ENDIAN" /FD /GZ /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x40c /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=xilink6.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ENDIF 
+
+# Begin Target
+
+# Name "libmpcdec - Win32 Release"
+# Name "libmpcdec - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\src\huffsv46.c
+
+!IF  "$(CFG)" == "libmpcdec - Win32 Release"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF  "$(CFG)" == "libmpcdec - Win32 Debug"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\src\huffsv7.c
+
+!IF  "$(CFG)" == "libmpcdec - Win32 Release"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF  "$(CFG)" == "libmpcdec - Win32 Debug"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\src\idtag.c
+
+!IF  "$(CFG)" == "libmpcdec - Win32 Release"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF  "$(CFG)" == "libmpcdec - Win32 Debug"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\src\mpc_decoder.c
+
+!IF  "$(CFG)" == "libmpcdec - Win32 Release"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF  "$(CFG)" == "libmpcdec - Win32 Debug"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\src\mpc_reader.c
+
+!IF  "$(CFG)" == "libmpcdec - Win32 Release"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF  "$(CFG)" == "libmpcdec - Win32 Debug"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\src\requant.c
+
+!IF  "$(CFG)" == "libmpcdec - Win32 Release"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF  "$(CFG)" == "libmpcdec - Win32 Debug"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\src\streaminfo.c
+
+!IF  "$(CFG)" == "libmpcdec - Win32 Release"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF  "$(CFG)" == "libmpcdec - Win32 Debug"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\src\synth_filter.c
+
+!IF  "$(CFG)" == "libmpcdec - Win32 Release"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF  "$(CFG)" == "libmpcdec - Win32 Debug"
+
+!ENDIF 
+
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\include\mpcdec\config_win32.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\include\mpcdec\decoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\include\mpcdec\huffman.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\include\mpcdec\internal.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\include\mpcdec\math.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\include\mpcdec\mpcdec.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\include\mpcdec\reader.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\include\mpcdec\requant.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\include\mpcdec\streaminfo.h
+# End Source File
+# End Group
+# End Target
+# End Project
Index: trunk/win32/libmpcdec.dsw
===================================================================
--- trunk/win32/libmpcdec.dsw	(revision 3)
+++ trunk/win32/libmpcdec.dsw	(revision 3)
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "libmpcdec"=".\libmpcdec.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
Index: trunk/win32/sample.dsp
===================================================================
--- trunk/win32/sample.dsp	(revision 3)
+++ trunk/win32/sample.dsp	(revision 3)
@@ -0,0 +1,102 @@
+# Microsoft Developer Studio Project File - Name="sample" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=sample - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "sample.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "sample.mak" CFG="sample - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "sample - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "sample - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=xicl6.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "sample - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "sample___Win32_Release"
+# PROP BASE Intermediate_Dir "sample___Win32_Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "SampleRelease"
+# PROP Intermediate_Dir "SampleRelease"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x40c /d "NDEBUG"
+# ADD RSC /l 0x40c /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=xilink6.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libmpcdec.lib /nologo /subsystem:console /machine:I386 /libpath:"libRelease"
+
+!ELSEIF  "$(CFG)" == "sample - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "sample___Win32_Debug"
+# PROP BASE Intermediate_Dir "sample___Win32_Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "SampleDebug"
+# PROP Intermediate_Dir "SampleDebug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "MPC_LITTLE_ENDIAN" /YX /FD /GZ /c
+# ADD BASE RSC /l 0x40c /d "_DEBUG"
+# ADD RSC /l 0x40c /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=xilink6.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libmpcdec.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"libDebug"
+# SUBTRACT LINK32 /nodefaultlib
+
+!ENDIF 
+
+# Begin Target
+
+# Name "sample - Win32 Release"
+# Name "sample - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\src\sample.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
Index: trunk/win32/sample.dsw
===================================================================
--- trunk/win32/sample.dsw	(revision 3)
+++ trunk/win32/sample.dsw	(revision 3)
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "sample"=".\sample.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
