Index: libmpc/branches/r2d/libmpcdec/AUTHORS
===================================================================
--- libmpc/branches/r2d/libmpcdec/AUTHORS	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/AUTHORS	(revision 130)
@@ -0,0 +1,10 @@
+libmpcdec is the result of the work of many people:
+
+* Andree Buschmann and Frank Klemm
+  Original implementation and core development.
+
+* Peter Pawlowski and Benoit Amiaux
+  Portability and further optimizations.
+
+* Miles Egan
+  Port to pure C, documentation, and api refinements.
Index: libmpc/branches/r2d/libmpcdec/COPYING
===================================================================
--- libmpc/branches/r2d/libmpcdec/COPYING	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/COPYING	(revision 130)
@@ -0,0 +1,31 @@
+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.
Index: libmpc/branches/r2d/libmpcdec/ChangeLog
===================================================================
--- libmpc/branches/r2d/libmpcdec/ChangeLog	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/ChangeLog	(revision 130)
@@ -0,0 +1,36 @@
+1.2.3
+    * Reduced memory usage and code size. Patch by Peter Pawlowski
+
+1.2.2
+    * Fixed compilation under OpenBSD
+    * Unix EOF again
+
+1.2.1
+    * Warnings cleanup, patch by Tomas Salfischberger, Thom Johansen and
+    Daniel Stenberg (Rockbox)
+    * Mplayer interface, patch by Reimar Doffinger
+    * Unix EOF everywhere
+
+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
+    * add compliance & cleanup patches from Michael Roitzsch of xine project 	
+    * switch to BSD license
+    * port to pure C
+    * add doxygen documentation
+    * revise API somewhat
+	
+1.0.3			
+    * autotools build process
+    * sample binary added
+    * floating-point mode by default
Index: libmpc/branches/r2d/libmpcdec/README
===================================================================
--- libmpc/branches/r2d/libmpcdec/README	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/README	(revision 130)
@@ -0,0 +1,6 @@
+Musepack Decoder Library:
+
+run "./configure [--prefix=/usr]; make"
+
+To create a sample app using the musepack decoder library in src/
+Check src/sample.cpp for more details.
Index: libmpc/branches/r2d/libmpcdec/docs/Doxyfile
===================================================================
--- libmpc/branches/r2d/libmpcdec/docs/Doxyfile	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/docs/Doxyfile	(revision 130)
@@ -0,0 +1,1161 @@
+# Doxyfile 1.3.9.1
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+#       TAG = value [value, ...]
+# For lists items can also be appended using:
+#       TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded 
+# by quotes) that should identify the project.
+
+PROJECT_NAME           = libmpcdec
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number. 
+# This could be handy for archiving the generated documentation or 
+# if some version control system is used.
+
+PROJECT_NUMBER         = 1.2.2
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
+# base path where the generated documentation will be put. 
+# If a relative path is entered, it will be relative to the location 
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY       = docs
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 
+# 4096 sub-directories (in 2 levels) under the output directory of each output 
+# format and will distribute the generated files over these directories. 
+# Enabling this option can be useful when feeding doxygen a huge amount of source 
+# files, where putting all generated files in the same directory would otherwise 
+# cause performance problems for the file system.
+
+CREATE_SUBDIRS         = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all 
+# documentation generated by doxygen is written. Doxygen will use this 
+# information to generate all constant output in the proper language. 
+# The default language is English, other supported languages are: 
+# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, 
+# Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese, 
+# Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian, 
+# Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, 
+# Swedish, and Ukrainian.
+
+OUTPUT_LANGUAGE        = English
+
+# This tag can be used to specify the encoding used in the generated output. 
+# The encoding is not always determined by the language that is chosen, 
+# but also whether or not the output is meant for Windows or non-Windows users. 
+# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES 
+# forces the Windows encoding (this is the default for the Windows binary), 
+# whereas setting the tag to NO uses a Unix-style encoding (the default for 
+# all platforms other than Windows).
+
+USE_WINDOWS_ENCODING   = NO
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 
+# include brief member descriptions after the members that are listed in 
+# the file and class documentation (similar to JavaDoc). 
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC      = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend 
+# the brief description of a member or function before the detailed description. 
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF           = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator 
+# that is used to form the text in various listings. Each string 
+# in this list, if found as the leading text of the brief description, will be 
+# stripped from the text and the result after processing the whole list, is used 
+# as the annotated text. Otherwise, the brief description is used as-is. If left 
+# blank, the following values are used ("$name" is automatically replaced with the 
+# name of the entity): "The $name class" "The $name widget" "The $name file" 
+# "is" "provides" "specifies" "contains" "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF       = 
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 
+# Doxygen will generate a detailed section even if there is only a brief 
+# description.
+
+ALWAYS_DETAILED_SEC    = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited 
+# members of a class in the documentation of that class as if those members were 
+# ordinary class members. Constructors, destructors and assignment operators of 
+# the base classes will not be shown.
+
+INLINE_INHERITED_MEMB  = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full 
+# path before files name in the file list and in the header files. If set 
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES        = YES
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 
+# can be used to strip a user-defined part of the path. Stripping is 
+# only done if one of the specified strings matches the left-hand part of 
+# the path. The tag can be used to show relative paths in the file list. 
+# If left blank the directory from which doxygen is run is used as the 
+# path to strip.
+
+STRIP_FROM_PATH        = 
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of 
+# the path mentioned in the documentation of a class, which tells 
+# the reader which header file to include in order to use a class. 
+# If left blank only the name of the header file containing the class 
+# definition is used. Otherwise one should specify the include paths that 
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH    = 
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter 
+# (but less readable) file names. This can be useful is your file systems 
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES            = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 
+# will interpret the first line (until the first dot) of a JavaDoc-style 
+# comment as the brief description. If set to NO, the JavaDoc 
+# comments will behave just like the Qt-style comments (thus requiring an 
+# explicit @brief command for a brief description.
+
+JAVADOC_AUTOBRIEF      = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen 
+# treat a multi-line C++ special comment block (i.e. a block of //! or /// 
+# comments) as a brief description. This used to be the default behaviour. 
+# The new default is to treat a multi-line C++ comment block as a detailed 
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the DETAILS_AT_TOP tag is set to YES then Doxygen 
+# will output the detailed description near the top, like JavaDoc.
+# If set to NO, the detailed description appears after the member 
+# documentation.
+
+DETAILS_AT_TOP         = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented 
+# member inherits the documentation from any documented member that it 
+# re-implements.
+
+INHERIT_DOCS           = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 
+# tag is set to YES, then doxygen will reuse the documentation of the first 
+# member in the group (if any) for the other members of the group. By default 
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC   = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab. 
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE               = 8
+
+# This tag can be used to specify a number of aliases that acts 
+# as commands in the documentation. An alias has the form "name=value". 
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to 
+# put the command \sideeffect (or @sideeffect) in the documentation, which 
+# will result in a user-defined paragraph with heading "Side Effects:". 
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES                = 
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources 
+# only. Doxygen will then generate output that is more tailored for C. 
+# For instance, some of the names that are used will be different. The list 
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C  = NO
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources 
+# only. Doxygen will then generate output that is more tailored for Java. 
+# For instance, namespaces will be presented as packages, qualified scopes 
+# will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA   = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of 
+# the same type (for instance a group of public functions) to be put as a 
+# subgroup of that type (e.g. under the Public Functions section). Set it to 
+# NO to prevent subgrouping. Alternatively, this can be done per class using 
+# the \nosubgrouping command.
+
+SUBGROUPING            = YES
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 
+# documentation are documented, even if no documentation was available. 
+# Private class members and static file members will be hidden unless 
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL            = NO
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class 
+# will be included in the documentation.
+
+EXTRACT_PRIVATE        = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file 
+# will be included in the documentation.
+
+EXTRACT_STATIC         = NO
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) 
+# defined locally in source files will be included in the documentation. 
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES  = YES
+
+# This flag is only useful for Objective-C code. When set to YES local 
+# methods, which are defined in the implementation section but not in 
+# the interface are included in the documentation. 
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS  = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 
+# undocumented members of documented classes, files or namespaces. 
+# If set to NO (the default) these members will be included in the 
+# various overviews, but no documentation section is generated. 
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS     = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 
+# undocumented classes that are normally visible in the class hierarchy. 
+# If set to NO (the default) these classes will be included in the various 
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES     = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all 
+# friend (class|struct|union) declarations. 
+# If set to NO (the default) these declarations will be included in the 
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS  = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any 
+# documentation blocks found inside the body of a function. 
+# If set to NO (the default) these blocks will be appended to the 
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS      = NO
+
+# The INTERNAL_DOCS tag determines if documentation 
+# that is typed after a \internal command is included. If the tag is set 
+# to NO (the default) then the documentation will be excluded. 
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS          = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 
+# file names in lower-case letters. If set to YES upper-case letters are also 
+# allowed. This is useful if you have classes or files whose names only differ 
+# in case and if your file system supports case sensitive file names. Windows 
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES       = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen 
+# will show members with their full class and namespace scopes in the 
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES       = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen 
+# will put a list of the files that are included by a file in the documentation 
+# of that file.
+
+SHOW_INCLUDE_FILES     = YES
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] 
+# is inserted in the documentation for inline members.
+
+INLINE_INFO            = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen 
+# will sort the (detailed) documentation of file and class members 
+# alphabetically by member name. If set to NO the members will appear in 
+# declaration order.
+
+SORT_MEMBER_DOCS       = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the 
+# brief documentation of file, namespace and class members alphabetically 
+# by member name. If set to NO (the default) the members will appear in 
+# declaration order.
+
+SORT_BRIEF_DOCS        = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be 
+# sorted by fully-qualified names, including namespaces. If set to 
+# NO (the default), the class list will be sorted only by class name, 
+# not including the namespace part. 
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the 
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME     = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or 
+# disable (NO) the todo list. This list is created by putting \todo 
+# commands in the documentation.
+
+GENERATE_TODOLIST      = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or 
+# disable (NO) the test list. This list is created by putting \test 
+# commands in the documentation.
+
+GENERATE_TESTLIST      = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or 
+# disable (NO) the bug list. This list is created by putting \bug 
+# commands in the documentation.
+
+GENERATE_BUGLIST       = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or 
+# disable (NO) the deprecated list. This list is created by putting 
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional 
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS       = 
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines 
+# the initial value of a variable or define consists of for it to appear in 
+# the documentation. If the initializer consists of more lines than specified 
+# here it will be hidden. Use a value of 0 to hide initializers completely. 
+# The appearance of the initializer of individual variables and defines in the 
+# documentation can be controlled using \showinitializer or \hideinitializer 
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES  = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated 
+# at the bottom of the documentation of classes and structs. If set to YES the 
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES        = YES
+
+# If the sources in your project are distributed over multiple directories 
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy 
+# in the documentation.
+
+SHOW_DIRECTORIES       = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated 
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET                  = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are 
+# generated by doxygen. Possible values are YES and NO. If left blank 
+# NO is used.
+
+WARNINGS               = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings 
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will 
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED   = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for 
+# potential errors in the documentation, such as not documenting some 
+# parameters in a documented function, or documenting parameters that 
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR      = YES
+
+# The WARN_FORMAT tag determines the format of the warning messages that 
+# doxygen can produce. The string should contain the $file, $line, and $text 
+# tags, which will be replaced by the file and line number from which the 
+# warning originated and the warning text.
+
+WARN_FORMAT            = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning 
+# and error messages should be written. If left blank the output is written 
+# to stderr.
+
+WARN_LOGFILE           = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain 
+# documented source files. You may enter file names like "myfile.cpp" or 
+# directories like "/usr/src/myproject". Separate the files or directories 
+# with spaces.
+
+INPUT                  = include src
+
+# If the value of the INPUT tag contains directories, you can use the 
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank the following patterns are tested: 
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp 
+# *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm
+
+FILE_PATTERNS          = 
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories 
+# should be searched for input files as well. Possible values are YES and NO. 
+# If left blank NO is used.
+
+RECURSIVE              = YES
+
+# The EXCLUDE tag can be used to specify files and/or directories that should 
+# excluded from the INPUT source files. This way you can easily exclude a 
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE                = include/config.h
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories 
+# that are symbolic links (a Unix filesystem feature) are excluded from the input.
+
+EXCLUDE_SYMLINKS       = NO
+
+# If the value of the INPUT tag contains directories, you can use the 
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 
+# certain files from those directories.
+
+EXCLUDE_PATTERNS       = 
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or 
+# directories that contain example code fragments that are included (see 
+# the \include command).
+
+EXAMPLE_PATH           = 
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the 
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank all files are included.
+
+EXAMPLE_PATTERNS       = 
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be 
+# searched for input files to be used with the \include or \dontinclude 
+# commands irrespective of the value of the RECURSIVE tag. 
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE      = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or 
+# directories that contain image that are included in the documentation (see 
+# the \image command).
+
+IMAGE_PATH             = 
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should 
+# invoke to filter for each input file. Doxygen will invoke the filter program 
+# by executing (via popen()) the command <filter> <input-file>, where <filter> 
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an 
+# input file. Doxygen will then use the output that the filter program writes 
+# to standard output.  If FILTER_PATTERNS is specified, this tag will be 
+# ignored.
+
+INPUT_FILTER           = 
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern 
+# basis.  Doxygen will compare the file name with each pattern and apply the 
+# filter if there is a match.  The filters are a list of the form: 
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further 
+# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER 
+# is applied to all files.
+
+FILTER_PATTERNS        = 
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 
+# INPUT_FILTER) will be used to filter the input files when producing source 
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES    = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will 
+# be generated. Documented entities will be cross-referenced with these sources. 
+# Note: To get rid of all source code in the generated output, make sure also 
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER         = YES
+
+# Setting the INLINE_SOURCES tag to YES will include the body 
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES         = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 
+# doxygen to hide any special comment blocks from generated source code 
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS    = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES (the default) 
+# then for each documented function all documented 
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = YES
+
+# If the REFERENCES_RELATION tag is set to YES (the default) 
+# then for each documented function all documented entities 
+# called/used by that function will be listed.
+
+REFERENCES_RELATION    = YES
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 
+# will generate a verbatim copy of the header file for each class for 
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS       = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index 
+# of all compounds will be generated. Enable this if the project 
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX     = NO
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then 
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns 
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX    = 5
+
+# In case all classes in a project start with a common prefix, all 
+# classes will be put under the same header in the alphabetical index. 
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that 
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX          = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will 
+# generate HTML output.
+
+GENERATE_HTML          = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT            = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for 
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank 
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION    = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard header.
+
+HTML_HEADER            = 
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard footer.
+
+HTML_FOOTER            = 
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading 
+# style sheet that is used by each HTML page. It can be used to 
+# fine-tune the look of the HTML output. If the tag is left blank doxygen 
+# will generate a default style sheet. Note that doxygen will try to copy 
+# the style sheet file to the HTML output directory, so don't put your own 
+# stylesheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET        = docs/custom.css
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, 
+# files or namespaces will be aligned in HTML using tables. If set to 
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS     = YES
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files 
+# will be generated that can be used as input for tools like the 
+# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) 
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP      = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can 
+# be used to specify the file name of the resulting .chm file. You 
+# can add a path in front of the file if the result should not be 
+# written to the html output directory.
+
+CHM_FILE               = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can 
+# be used to specify the location (absolute path including file name) of 
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run 
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION           = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag 
+# controls if a separate .chi index file is generated (YES) or that 
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI           = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag 
+# controls whether a binary table of contents is generated (YES) or a 
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC             = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members 
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND             = NO
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at 
+# top of each HTML page. The value NO (the default) enables the index and 
+# the value YES disables it.
+
+DISABLE_INDEX          = NO
+
+# This tag can be used to set the number of enum values (range [1..20]) 
+# that doxygen will group on one line in the generated HTML documentation.
+
+ENUM_VALUES_PER_LINE   = 4
+
+# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
+# generated containing a tree-like index structure (just like the one that 
+# is generated for HTML Help). For this to work a browser that supports 
+# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, 
+# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are 
+# probably better off using the HTML help feature.
+
+GENERATE_TREEVIEW      = NO
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 
+# used to set the initial width (in pixels) of the frame in which the tree 
+# is shown.
+
+TREEVIEW_WIDTH         = 250
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 
+# generate Latex output.
+
+GENERATE_LATEX         = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT           = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be 
+# invoked. If left blank `latex' will be used as the default command name.
+
+LATEX_CMD_NAME         = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to 
+# generate index for LaTeX. If left blank `makeindex' will be used as the 
+# default command name.
+
+MAKEINDEX_CMD_NAME     = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact 
+# LaTeX documents. This may be useful for small projects and may help to 
+# save some trees in general.
+
+COMPACT_LATEX          = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used 
+# by the printer. Possible values are: a4, a4wide, letter, legal and 
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE             = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX 
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES         = 
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for 
+# the generated latex document. The header should contain everything until 
+# the first chapter. If it is left blank doxygen will generate a 
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER           = 
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated 
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will 
+# contain links (just like the HTML output) instead of page references 
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS         = NO
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of 
+# plain latex in the generated Makefile. Set this option to YES to get a 
+# higher quality PDF documentation.
+
+USE_PDFLATEX           = NO
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 
+# command to the generated LaTeX files. This will instruct LaTeX to keep 
+# running if errors occur, instead of asking the user for help. 
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE        = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not 
+# include the index chapters (such as File Index, Compound Index, etc.) 
+# in the output.
+
+LATEX_HIDE_INDICES     = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output 
+# The RTF output is optimized for Word 97 and may not look very pretty with 
+# other RTF readers or editors.
+
+GENERATE_RTF           = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT             = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact 
+# RTF documents. This may be useful for small projects and may help to 
+# save some trees in general.
+
+COMPACT_RTF            = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated 
+# will contain hyperlink fields. The RTF file will 
+# contain links (just like the HTML output) instead of page references. 
+# This makes the output suitable for online browsing using WORD or other 
+# programs which support those fields. 
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS         = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's 
+# config file, i.e. a series of assignments. You only have to provide 
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE    = 
+
+# Set optional variables used in the generation of an rtf document. 
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE    = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will 
+# generate man pages
+
+GENERATE_MAN           = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT             = man
+
+# The MAN_EXTENSION tag determines the extension that is added to 
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION          = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output, 
+# then it will generate one additional man file for each entity 
+# documented in the real man page(s). These additional files 
+# only source the real man page, but without them the man command 
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS              = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will 
+# generate an XML file that captures the structure of 
+# the code including all documentation.
+
+GENERATE_XML           = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT             = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema, 
+# which can be used by a validating XML parser to check the 
+# syntax of the XML files.
+
+XML_SCHEMA             = 
+
+# The XML_DTD tag can be used to specify an XML DTD, 
+# which can be used by a validating XML parser to check the 
+# syntax of the XML files.
+
+XML_DTD                = 
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will 
+# dump the program listings (including syntax highlighting 
+# and cross-referencing information) to the XML output. Note that 
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING     = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will 
+# generate an AutoGen Definitions (see autogen.sf.net) file 
+# that captures the structure of the code including all 
+# documentation. Note that this feature is still experimental 
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF   = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will 
+# generate a Perl module file that captures the structure of 
+# the code including all documentation. Note that this 
+# feature is still experimental and incomplete at the 
+# moment.
+
+GENERATE_PERLMOD       = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate 
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able 
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX          = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be 
+# nicely formatted so it can be parsed by a human reader.  This is useful 
+# if you want to understand what is going on.  On the other hand, if this 
+# tag is set to NO the size of the Perl module output will be much smaller 
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY         = YES
+
+# The names of the make variables in the generated doxyrules.make file 
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. 
+# This is useful so different doxyrules.make files included by the same 
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX = 
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor   
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will 
+# evaluate all C-preprocessor directives found in the sources and include 
+# files.
+
+ENABLE_PREPROCESSING   = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro 
+# names in the source code. If set to NO (the default) only conditional 
+# compilation will be performed. Macro expansion can be done in a controlled 
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION        = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 
+# then the macro expansion is limited to the macros specified with the 
+# PREDEFINED and EXPAND_AS_PREDEFINED tags.
+
+EXPAND_ONLY_PREDEF     = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+
+SEARCH_INCLUDES        = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that 
+# contain include files that are not input files but should be processed by 
+# the preprocessor.
+
+INCLUDE_PATH           = 
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 
+# patterns (like *.h and *.hpp) to filter out the header-files in the 
+# directories. If left blank, the patterns specified with FILE_PATTERNS will 
+# be used.
+
+INCLUDE_FILE_PATTERNS  = 
+
+# The PREDEFINED tag can be used to specify one or more macro names that 
+# are defined before the preprocessor is started (similar to the -D option of 
+# gcc). The argument of the tag is a list of macros of the form: name 
+# or name=definition (no spaces). If the definition and the = are 
+# omitted =1 is assumed. To prevent a macro definition from being 
+# undefined via #undef or recursively expanded use the := operator 
+# instead of the = operator.
+
+PREDEFINED             = 
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 
+# this tag can be used to specify a list of macro names that should be expanded. 
+# The macro definition that is found in the sources will be used. 
+# Use the PREDEFINED tag if you want to use a different macro definition.
+
+EXPAND_AS_DEFINED      = 
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 
+# doxygen's preprocessor will remove all function-like macros that are alone 
+# on a line, have an all uppercase name, and do not end with a semicolon. Such 
+# function macros are typically used for boiler-plate code, and will confuse the 
+# parser if not removed.
+
+SKIP_FUNCTION_MACROS   = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references   
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles. 
+# Optionally an initial location of the external documentation 
+# can be added for each tagfile. The format of a tag file without 
+# this location is as follows: 
+#   TAGFILES = file1 file2 ... 
+# Adding location for the tag files is done as follows: 
+#   TAGFILES = file1=loc1 "file2 = loc2" ... 
+# where "loc1" and "loc2" can be relative or absolute paths or 
+# URLs. If a location is present for each tag, the installdox tool 
+# does not have to be run to correct the links.
+# Note that each tag file must have a unique name
+# (where the name does NOT include the path)
+# If a tag file is not located in the directory in which doxygen 
+# is run, you must also specify the path to the tagfile here.
+
+TAGFILES               = 
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create 
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE       = 
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed 
+# in the class index. If set to NO only the inherited external classes 
+# will be listed.
+
+ALLEXTERNALS           = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed 
+# in the modules index. If set to NO, only the current project's groups will 
+# be listed.
+
+EXTERNAL_GROUPS        = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script 
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH              = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool   
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will 
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base or 
+# super classes. Setting the tag to NO turns the diagrams off. Note that this 
+# option is superseded by the HAVE_DOT option below. This is only a fallback. It is 
+# recommended to install and use dot, since it yields more powerful graphs.
+
+CLASS_DIAGRAMS         = YES
+
+# If set to YES, the inheritance and collaboration graphs will hide 
+# inheritance and usage relations if the target is undocumented 
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS   = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is 
+# available from the path. This tool is part of Graphviz, a graph visualization 
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section 
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT               = NO
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect inheritance relations. Setting this tag to YES will force the 
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH            = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect implementation dependencies (inheritance, containment, and 
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH    = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and 
+# collaboration diagrams in a style similar to the OMG's Unified Modeling 
+# Language.
+
+UML_LOOK               = NO
+
+# If set to YES, the inheritance and collaboration graphs will show the 
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS     = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT 
+# tags are set to YES then doxygen will generate a graph for each documented 
+# file showing the direct and indirect include dependencies of the file with 
+# other documented files.
+
+INCLUDE_GRAPH          = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and 
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each 
+# documented header file showing the documented files that directly or 
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH      = YES
+
+# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will 
+# generate a call dependency graph for every global function or class method. 
+# Note that enabling this option will significantly increase the time of a run. 
+# So in most cases it will be better to enable call graphs for selected 
+# functions only using the \callgraph command.
+
+CALL_GRAPH             = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 
+# will graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY    = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images 
+# generated by dot. Possible values are png, jpg, or gif
+# If left blank png will be used.
+
+DOT_IMAGE_FORMAT       = png
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be 
+# found. If left blank, it is assumed the dot tool can be found on the path.
+
+DOT_PATH               = 
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that 
+# contain dot files that are included in the documentation (see the 
+# \dotfile command).
+
+DOTFILE_DIRS           = 
+
+# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width 
+# (in pixels) of the graphs generated by dot. If a graph becomes larger than 
+# this value, doxygen will try to truncate the graph, so that it fits within 
+# the specified constraint. Beware that most browsers cannot cope with very 
+# large images.
+
+MAX_DOT_GRAPH_WIDTH    = 1024
+
+# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height 
+# (in pixels) of the graphs generated by dot. If a graph becomes larger than 
+# this value, doxygen will try to truncate the graph, so that it fits within 
+# the specified constraint. Beware that most browsers cannot cope with very 
+# large images.
+
+MAX_DOT_GRAPH_HEIGHT   = 1024
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the 
+# graphs generated by dot. A depth value of 3 means that only nodes reachable 
+# from the root by following a path via at most 3 edges will be shown. Nodes that 
+# lay further from the root node will be omitted. Note that setting this option to 
+# 1 or 2 may greatly reduce the computation time needed for large code bases. Also 
+# note that a graph may be further truncated if the graph's image dimensions are 
+# not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH and MAX_DOT_GRAPH_HEIGHT). 
+# If 0 is used for the depth value (the default), the graph is not depth-constrained.
+
+MAX_DOT_GRAPH_DEPTH    = 0
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will 
+# generate a legend page explaining the meaning of the various boxes and 
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND        = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will 
+# remove the intermediate dot files that are used to generate 
+# the various graphs.
+
+DOT_CLEANUP            = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to the search engine   
+#---------------------------------------------------------------------------
+
+# The SEARCHENGINE tag specifies whether or not a search engine should be 
+# used. If set to NO the values of all tags below this one will be ignored.
+
+SEARCHENGINE           = NO
Index: libmpc/branches/r2d/libmpcdec/docs/custom.css
===================================================================
--- libmpc/branches/r2d/libmpcdec/docs/custom.css	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/docs/custom.css	(revision 130)
@@ -0,0 +1,212 @@
+BODY,H1,H2,H3,H4,H5,H6,P,CENTER,TD,TH,UL,DL,DIV {
+	font-family: sans-serif;
+}
+h1 {
+	text-align: center;
+    text-transform: lowercase;
+    margin: 0.5em 0;
+}
+h2, h2 a { color: #f90; margin: 1em 0 0.25em 0; }
+h3, h3 a { color: #88f; margin: 1em 0 0.25em 0; }
+
+CAPTION { font-weight: bold }
+DIV.qindex {
+	width: 100%;
+	background-color: #eeeeff;
+	border: 1px solid #b0b0b0;
+	text-align: center;
+	margin: 2px;
+	padding: 2px;
+	line-height: 140%;
+}
+DIV.nav {
+	text-align: center;
+    padding: 0.25em 0;
+}
+A.qindex {
+    text-decoration: none;
+    font-weight: bold;
+    color: #1A419D;
+    text-transform: lowercase;
+}
+A.qindex:visited {
+    text-decoration: none;
+    font-weight: bold;
+    color: #1A419D
+}
+A.qindex:hover {
+	text-decoration: none;
+	background-color: #ddddff;
+}
+A.qindexHL {
+	text-decoration: none;
+	font-weight: bold;
+	background-color: #6666cc;
+	color: #ffffff;
+	border: 1px double #9295C2;
+    text-transform: lowercase;
+}
+A.qindexHL:hover {
+	text-decoration: none;
+	background-color: #6666cc;
+	color: #ffffff;
+}
+A.qindex, A.qindexHL { padding: 0.1em 0.5em; }
+A.qindexHL:visited { text-decoration: none; background-color: #6666cc; color: #ffffff }
+A.el { text-decoration: none; font-weight: bold; color: #d66; font-style: italic }
+A.elRef { font-weight: bold }
+A.code:link { text-decoration: none; font-weight: normal; color: #0000FF}
+A.code:visited { text-decoration: none; font-weight: normal; color: #0000FF}
+A.codeRef:link { font-weight: normal; color: #0000FF}
+A.codeRef:visited { font-weight: normal; color: #0000FF}
+A:hover { text-decoration: none; background-color: #f2f2ff }
+DL.el { margin-left: -1cm }
+.fragment {
+       font-family: monospace
+}
+PRE.fragment {
+	border: 1px solid #CCCCCC;
+	background-color: #f5f5f5;
+	margin-top: 4px;
+	margin-bottom: 4px;
+	margin-left: 2px;
+	margin-right: 8px;
+	padding-left: 6px;
+	padding-right: 6px;
+	padding-top: 4px;
+	padding-bottom: 4px;
+}
+hr { display: none }
+DIV.ah { background-color: black; font-weight: bold; color: #ffffff; margin-bottom: 3px; margin-top: 3px }
+TD.md { font-weight: bold; }
+TD.mdname1, TD.mdname { color: #088; font-weight: bold; }
+TABLE[cellspacing="5"] { margin-left: 2em; }
+TABLE[cellspacing="5"] dl em { color: #088; font-weight: bold; }
+DIV.groupHeader {
+       margin-left: 16px;
+       margin-top: 12px;
+       margin-bottom: 6px;
+       font-weight: bold;
+}
+DIV.groupText { margin-left: 16px; font-style: italic; font-size: 14px }
+BODY {
+	background: white;
+	color: black;
+	margin-right: 20px;
+	margin-left: 20px;
+}
+TD.indexkey, TD.indexvalue {
+    padding: 0.1em 1em 0.1em 0.1em;
+}
+TD.indexkey {
+	font-weight: bold;
+}
+TD.indexvalue {
+	font-style: italic;
+}
+TR.memlist {
+   background-color: #f0f0f0; 
+}
+P.formulaDsp { text-align: center; }
+IMG.formulaDsp { }
+IMG.formulaInl { vertical-align: middle; }
+SPAN.keyword       { color: #008000 }
+SPAN.keywordtype   { color: #604020 }
+SPAN.keywordflow   { color: #e08000 }
+SPAN.comment       { color: #800000 }
+SPAN.preprocessor  { color: #806020 }
+SPAN.stringliteral { color: #002080 }
+SPAN.charliteral   { color: #008080 }
+.mdTable {
+}
+.mdRow {
+}
+.mdescLeft, .mdescRight {
+    font-style: italic;
+    font-size: 80%;
+}
+.mdescRight {
+}
+.memItemLeft {
+    font-style: italic;
+}
+.memItemLeft, .memItemRight {
+    font-size: 80%;
+}
+.memItemRight {
+}
+.memTemplItemLeft {
+	padding: 1px 0px 0px 8px;
+	margin: 4px;
+	border-top-width: 1px;
+	border-right-width: 1px;
+	border-bottom-width: 1px;
+	border-left-width: 1px;
+	border-top-color: #E0E0E0;
+	border-right-color: #E0E0E0;
+	border-bottom-color: #E0E0E0;
+	border-left-color: #E0E0E0;
+	border-top-style: none;
+	border-right-style: none;
+	border-bottom-style: none;
+	border-left-style: none;
+	background-color: #FAFAFA;
+	font-size: 12px;
+}
+.memTemplItemRight {
+	padding: 1px 8px 0px 8px;
+	margin: 4px;
+	border-top-width: 1px;
+	border-right-width: 1px;
+	border-bottom-width: 1px;
+	border-left-width: 1px;
+	border-top-color: #E0E0E0;
+	border-right-color: #E0E0E0;
+	border-bottom-color: #E0E0E0;
+	border-left-color: #E0E0E0;
+	border-top-style: none;
+	border-right-style: none;
+	border-bottom-style: none;
+	border-left-style: none;
+	background-color: #FAFAFA;
+	font-size: 13px;
+}
+.memTemplParams {
+	padding: 1px 0px 0px 8px;
+	margin: 4px;
+	border-top-width: 1px;
+	border-right-width: 1px;
+	border-bottom-width: 1px;
+	border-left-width: 1px;
+	border-top-color: #E0E0E0;
+	border-right-color: #E0E0E0;
+	border-bottom-color: #E0E0E0;
+	border-left-color: #E0E0E0;
+	border-top-style: solid;
+	border-right-style: none;
+	border-bottom-style: none;
+	border-left-style: none;
+       color: #606060;
+	background-color: #FAFAFA;
+	font-size: 12px;
+}
+.search     { color: #003399;
+              font-weight: bold;
+}
+FORM.search {
+              margin-bottom: 0px;
+              margin-top: 0px;
+}
+INPUT.search { font-size: 75%;
+               color: #000080;
+               font-weight: normal;
+               background-color: #eeeeff;
+}
+TD.tiny      { font-size: 75%;
+}
+a {
+	color: #252E78;
+}
+a:visited {
+	color: #3D2185;
+}
Index: libmpc/branches/r2d/libmpcdec/docs/mainpage.txt
===================================================================
--- libmpc/branches/r2d/libmpcdec/docs/mainpage.txt	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/docs/mainpage.txt	(revision 130)
@@ -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: libmpc/branches/r2d/libmpcdec/include/mpcdec/mpc_types.h
===================================================================
--- libmpc/branches/r2d/libmpcdec/include/mpcdec/mpc_types.h	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/include/mpcdec/mpc_types.h	(revision 130)
@@ -0,0 +1,98 @@
+/*
+  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;
+typedef unsigned __int64 mpc_uint64_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;
+typedef uint64_t  mpc_uint64_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 {
+    MPC_FALSE = 0,
+    MPC_TRUE  = !MPC_FALSE
+};
+
+#ifdef __cplusplus
+}
+#endif
+#endif
Index: libmpc/branches/r2d/libmpcdec/include/mpcdec/mpcdec.h
===================================================================
--- libmpc/branches/r2d/libmpcdec/include/mpcdec/mpcdec.h	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/include/mpcdec/mpcdec.h	(revision 130)
@@ -0,0 +1,111 @@
+/*
+  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 mpcdec.h
+/// Top level include file for libmpcdec.
+#ifndef _MPCDEC_H_
+#define _MPCDEC_H_
+#ifdef WIN32
+#pragma once
+#endif
+
+#include "streaminfo.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+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
+};
+
+typedef struct mpc_decoder_t mpc_decoder;
+typedef struct mpc_bits_reader_t mpc_bits_reader;
+typedef struct mpc_demux_t mpc_demux;
+
+typedef struct mpc_frame_info_t {
+	mpc_uint32_t samples;	// number of samples in the frame
+	MPC_SAMPLE_FORMAT * buffer;	// frame samples buffer (size = samples * channels * sizeof(MPC_SAMPLE_FORMAT)
+} mpc_frame_info;
+
+/// Initializes mpc decoder with the supplied stream info parameters.
+/// \param si streaminfo structure indicating format of source stream
+/// \return pointer on the initialized decoder structure if successful, 0 if not
+mpc_decoder * mpc_decoder_init(mpc_streaminfo *si);
+
+/// Releases input mpc decoder
+void mpc_decoder_exit(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 *p_dec, mpc_streaminfo *si, mpc_bool_t fast_seeking);
+
+// 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 *p_dec, 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.
+void mpc_decoder_decode_frame(mpc_decoder * d, mpc_bits_reader * r, mpc_frame_info * i);
+
+/// Seeks to the specified sample in the source stream.
+// 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 *p_dec, double seconds);
+
+// init demuxer
+mpc_demux * mpc_demux_init(mpc_reader * p_reader);
+// free demuxer
+void mpc_demux_exit(mpc_demux * d);
+// decode frame
+void mpc_demux_decode(mpc_demux * d, mpc_frame_info * i);
+// get streaminfo
+void mpc_demux_get_info(mpc_demux * d, mpc_streaminfo * i);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
Index: libmpc/branches/r2d/libmpcdec/include/mpcdec/reader.h
===================================================================
--- libmpc/branches/r2d/libmpcdec/include/mpcdec/reader.h	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/include/mpcdec/reader.h	(revision 130)
@@ -0,0 +1,90 @@
+/*
+  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_
+#ifdef WIN32
+#pragma once
+#endif
+
+#include "mpc_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/// \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 mpc_reader;
+struct mpc_reader_t {
+    /// Reads size bytes of data into buffer at ptr.
+    mpc_int32_t (*read)(mpc_reader *p_reader, void *ptr, mpc_int32_t size);
+
+    /// Seeks to byte position 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)(mpc_reader *p_reader);
+
+    /// Returns the total length of the source stream, in bytes.
+    mpc_int32_t (*get_size)(mpc_reader *p_reader);
+
+    /// True if the stream is a seekable stream.
+    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;
+};
+
+/// Initializes reader with default stdio file reader implementation.  Use
+/// this if you're just reading from a plain file.
+///
+/// \param r p_reader handle to initialize
+/// \param filename input filename to attach to the reader
+mpc_status mpc_reader_init_stdio(mpc_reader *p_reader, const char *filename);
+
+/// Release reader with default stdio file reader implementation.
+///
+/// \param r reader handle to release
+void mpc_reader_exit_stdio(mpc_reader *p_reader);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
Index: libmpc/branches/r2d/libmpcdec/include/mpcdec/streaminfo.h
===================================================================
--- libmpc/branches/r2d/libmpcdec/include/mpcdec/streaminfo.h	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/include/mpcdec/streaminfo.h	(revision 130)
@@ -0,0 +1,110 @@
+/*
+  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_
+#ifdef WIN32
+#pragma once
+#endif
+
+#include "mpc_types.h"
+#include "reader.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+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;        ///< Approximate number of pcm samples in stream
+    mpc_uint32_t         max_band;           ///< Maximum band-index used in stream (0...31)
+    mpc_uint32_t         ms;                 ///< Mid/side stereo (0: off, 1: on)
+	mpc_uint32_t         fast_seek;          ///< True if stream supports fast-seeking (sv7)
+	mpc_uint32_t         frames_per_block;   ///< Number of frames in a block (sv8)
+    //@}
+
+    /// @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
+    //@}
+
+    /// @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
+    //@}
+
+	/// @name Encoder informations
+    //@{
+    mpc_uint32_t         encoder_version;    ///< Version of encoder used
+    char                 encoder[256];       ///< Encoder name
+	mpc_bool_t           pns;                ///< pns used
+	mpc_uint32_t         profile;            ///< Quality profile of stream
+	const char*          profile_name;       ///< Name of profile used by stream
+	//@}
+
+    mpc_streaminfo_off_t tag_offset;         ///< Offset to file tags
+    mpc_streaminfo_off_t total_file_length;  ///< Total length of underlying file
+} mpc_streaminfo;
+
+/// 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: libmpc/branches/r2d/libmpcdec/libwavformat/input.c
===================================================================
--- libmpc/branches/r2d/libmpcdec/libwavformat/input.c	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/libwavformat/input.c	(revision 130)
@@ -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: libmpc/branches/r2d/libmpcdec/libwavformat/libwaveformat.h
===================================================================
--- libmpc/branches/r2d/libmpcdec/libwavformat/libwaveformat.h	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/libwavformat/libwaveformat.h	(revision 130)
@@ -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: libmpc/branches/r2d/libmpcdec/libwavformat/output.c
===================================================================
--- libmpc/branches/r2d/libmpcdec/libwavformat/output.c	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/libwavformat/output.c	(revision 130)
@@ -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: libmpc/branches/r2d/libmpcdec/mpcdec/mpcdec.c
===================================================================
--- libmpc/branches/r2d/libmpcdec/mpcdec/mpcdec.c	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/mpcdec/mpcdec.c	(revision 130)
@@ -0,0 +1,138 @@
+/*
+  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>
+
+#ifdef WIN32
+#include <crtdbg.h>
+#endif
+
+t_wav_uint32 mpc_wav_output_write(void* p_user_data, void const* p_buffer, t_wav_uint32 p_bytes)
+{
+    FILE* p_handle = (FILE*) p_user_data;
+    return (t_wav_uint32) fwrite(p_buffer, 1, p_bytes, p_handle);
+}
+
+t_wav_uint32 mpc_wav_output_seek(void* p_user_data, t_wav_uint32 p_position)
+{
+    FILE* p_handle = (FILE*) p_user_data;
+    return (t_wav_uint32) !fseek(p_handle, p_position, SEEK_SET);
+}
+
+static void
+usage(const char *exename)
+{
+    printf("Usage: %s <infile.mpc> [<outfile.wav>]\n", exename);
+}
+
+int
+main(int argc, char **argv)
+{
+    mpc_reader reader; mpc_streaminfo si; mpc_decoder* decoder; mpc_status err;
+    MPC_SAMPLE_FORMAT sample_buffer[MPC_DECODER_BUFFER_LENGTH];
+    clock_t begin, end, sum; int total_samples; t_wav_output_file wav_output;
+    mpc_bool_t is_wav_output;
+
+    if(3 < argc && argc < 2)
+    {
+        usage(argv[0]);
+        return 0;
+    }
+
+    err = mpc_reader_init_stdio(&reader, argv[1]);
+    if(err < 0) return !MPC_STATUS_OK;
+
+    err = mpc_streaminfo_init(&si, &reader);
+    if(err < 0) return !MPC_STATUS_OK;
+
+    err = mpc_decoder_init(&decoder, &reader, &si);
+    if(err < 0) return !MPC_STATUS_OK;
+
+    is_wav_output = argc > 2;
+    if(is_wav_output)
+    {
+        t_wav_output_file_callback wavo_fc;
+        memset(&wav_output, 0, sizeof wav_output);
+        wavo_fc.m_seek      = mpc_wav_output_seek;
+        wavo_fc.m_write     = mpc_wav_output_write;
+        wavo_fc.m_user_data = fopen(argv[2], "wb");
+        if(!wavo_fc.m_user_data) return !MPC_STATUS_OK;
+        err = waveformat_output_open(&wav_output, wavo_fc, si.channels, 16, 0, si.sample_freq, (t_wav_uint32) si.pcm_samples * 2);
+        if(!err) return !MPC_STATUS_OK;
+    }
+
+    sum = total_samples = 0;
+    while(MPC_TRUE)
+    {
+        mpc_uint32_t samples;
+
+        begin   = clock();
+        samples = mpc_decoder_decode(decoder, sample_buffer, 0, 0);
+        end     = clock();
+
+        if(samples <= 0) break;
+        if(!samples)     break;
+        total_samples += samples;
+        sum           += end - begin;
+
+        if(is_wav_output)
+            if(waveformat_output_process_float32(&wav_output, sample_buffer, samples*2) < 0)
+                break;
+    }
+
+    printf("%u samples ", total_samples);
+    total_samples = (mpc_uint32_t) ((double) total_samples * CLOCKS_PER_SEC * 100 / (si.sample_freq * sum));
+    printf("decoded in %u ms (%u.%02ux)\n",
+           sum * 1000 / CLOCKS_PER_SEC,
+           total_samples / 100,
+           total_samples % 100
+           );
+
+    mpc_decoder_exit(decoder);
+    mpc_reader_exit_stdio(&reader);
+    if(is_wav_output)
+    {
+        waveformat_output_close(&wav_output);
+        fclose(wav_output.m_callback.m_user_data);
+    }
+
+#ifdef WIN32
+    assert(_CrtCheckMemory());
+    _CrtDumpMemoryLeaks();
+#endif
+    return 0;
+}
Index: libmpc/branches/r2d/libmpcdec/src/decoder.h
===================================================================
--- libmpc/branches/r2d/libmpcdec/src/decoder.h	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/src/decoder.h	(revision 130)
@@ -0,0 +1,105 @@
+/*
+  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 {
+    /// @name internal state variables
+    //@{
+	mpc_uint32_t stream_version;     ///< Streamversion of stream
+	mpc_uint32_t max_band;           ///< Maximum band-index used in stream (0...31)
+	mpc_uint32_t ms;                 ///< Mid/side stereo (0: off, 1: on)
+	mpc_uint32_t channels;           ///< Number of channels in stream
+
+	mpc_uint64_t samples;            ///< Number of samples in stream
+
+	mpc_uint64_t decoded_samples;    ///< Number of samples decoded from file begining
+	mpc_uint32_t samples_to_skip;    ///< Number samples to skip (used for seeking)
+
+    // randomizer state variables
+    mpc_uint32_t  __r1;
+    mpc_uint32_t  __r2;
+
+    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: libmpc/branches/r2d/libmpcdec/src/huffman.c
===================================================================
--- libmpc/branches/r2d/libmpcdec/src/huffman.c	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/src/huffman.c	(revision 130)
@@ -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: libmpc/branches/r2d/libmpcdec/src/huffman.h
===================================================================
--- libmpc/branches/r2d/libmpcdec/src/huffman.h	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/src/huffman.h	(revision 130)
@@ -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: libmpc/branches/r2d/libmpcdec/src/internal.h
===================================================================
--- libmpc/branches/r2d/libmpcdec/src/internal.h	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/src/internal.h	(revision 130)
@@ -0,0 +1,92 @@
+/*
+  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>
+
+/// 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));
+}
+
+typedef struct mpc_block_t {
+	char key[2];	// block key
+	mpc_uint64_t size;	// block size minus the block header size
+} mpc_block;
+
+// mpc_bits_reader.c
+struct mpc_bits_reader_t {
+	unsigned char * buff; /// pointer on current byte
+	unsigned int count; /// unread bits in current byte
+};
+
+#define DEMUX_BUFFER_SIZE 65536
+
+struct mpc_demux_t {
+	mpc_reader * r;
+	mpc_decoder * d;
+	mpc_streaminfo si;
+	mpc_uint8_t buffer[DEMUX_BUFFER_SIZE];
+	mpc_uint32_t bytes_total;
+	mpc_bits_reader bits_reader;
+	mpc_uint32_t block_bits;	// bits remaining in current audio block
+};
+
+/// 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_init_quant(mpc_decoder *d, double scale_factor);
+void mpc_decoder_synthese_filter_float(mpc_decoder *d, MPC_SAMPLE_FORMAT* OutData);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
Index: libmpc/branches/r2d/libmpcdec/src/math.h
===================================================================
--- libmpc/branches/r2d/libmpcdec/src/math.h	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/src/math.h	(revision 130)
@@ -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: libmpc/branches/r2d/libmpcdec/src/mpc_bits_reader.c
===================================================================
--- libmpc/branches/r2d/libmpcdec/src/mpc_bits_reader.c	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/src/mpc_bits_reader.c	(revision 130)
@@ -0,0 +1,102 @@
+/*
+  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 <mpcdec/mpcdec.h>
+#include "internal.h"
+#include "huffman.h"
+
+mpc_uint32_t mpc_bits_read(mpc_bits_reader * r, const unsigned int nb_bits)
+{
+	mpc_uint32_t ret = r->buff[0];
+
+	while(nb_bits > r->count){
+		r->buff++;
+		ret = (ret << 8) | r->buff[0];
+		r->count += 8;
+	}
+
+	r->count -= nb_bits;
+
+	return (ret >> r->count) & (-1u >> (32 - nb_bits));
+}
+
+// basic huffman decoding routine
+// works with maximum lengths up to 16
+mpc_int32_t mpc_bits_huff_dec(mpc_bits_reader * r, const mpc_huffman *Table)
+{
+	mpc_uint32_t code = ((r->buff[0] << 16) | (r->buff[1] << 8) | r->buff[2])
+			<< (16 - r->count);
+
+	while (code < Table->Code) Table++;
+
+	int tmp = r->count - Table->Length;
+	r->buff -= tmp >> 3;
+	r->count = tmp & 0x07;
+
+	return Table->Value;
+}
+
+unsigned int mpc_bits_get_size(mpc_bits_reader * r, mpc_uint64_t * p_size)
+{
+	unsigned char tmp;
+	mpc_uint64_t size = 0;
+	unsigned int ret = 0;
+
+	do {
+		tmp = mpc_bits_read(r, 8);
+		size = (size << 7) | (tmp & 0x7F);
+		ret++;
+	} while((tmp & 0x80));
+
+	*p_size = size;
+	return ret;
+}
+
+int mpc_bits_get_block(mpc_bits_reader * r, mpc_block * p_block)
+{
+	int size = 2;
+
+	p_block->size = 0;
+	p_block->key[0] = mpc_bits_read(r, 8);
+	p_block->key[1] = mpc_bits_read(r, 8);
+
+	size += mpc_bits_get_size(r, &(p_block->size));
+
+	p_block->size -= size;
+
+	return size;
+}
+
+
+
Index: libmpc/branches/r2d/libmpcdec/src/mpc_decoder.c
===================================================================
--- libmpc/branches/r2d/libmpcdec/src/mpc_decoder.c	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/src/mpc_decoder.c	(revision 130)
@@ -0,0 +1,603 @@
+/*
+  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 mpc_decoder.c
+/// Core decoding routines and logic.
+#include <string.h>
+#include <mpcdec/mpcdec.h>
+#include "decoder.h"
+#include "huffman.h"
+#include "internal.h"
+#include "math.h"
+#include "requant.h"
+
+mpc_uint32_t mpc_bits_read(mpc_bits_reader * r, const unsigned int nb_bits);
+mpc_int32_t mpc_bits_huff_dec(mpc_bits_reader * r, const mpc_huffman *Table);
+
+//SV7 tables
+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];
+
+//------------------------------------------------------------------------------
+// types
+//------------------------------------------------------------------------------
+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)
+};
+
+//------------------------------------------------------------------------------
+// forward declarations
+//------------------------------------------------------------------------------
+void mpc_decoder_read_bitstream_sv7(mpc_decoder * d, mpc_bits_reader * r);
+static void mpc_decoder_requantisierung(mpc_decoder *d);
+
+// static void mpc_decoder_reset_y(mpc_decoder *d)
+// {
+// 	memset(d->Y_L, 0, sizeof d->Y_L);
+// 	memset(d->Y_R, 0, sizeof d->Y_R);
+// }
+
+void mpc_decoder_setup(mpc_decoder *d)
+{
+	memset(d, 0, sizeof *d);
+
+	d->__r1 = 1;
+	d->__r2 = 1;
+	d->samples_to_skip = MPC_DECODER_SYNTH_DELAY;
+
+	mpc_decoder_init_quant(d, 1.0f);
+}
+
+void mpc_decoder_set_streaminfo(mpc_decoder *d, mpc_streaminfo *si)
+{
+	d->stream_version     = si->stream_version;
+	d->ms                 = si->ms;
+	d->max_band           = si->max_band;
+	d->channels           = si->channels;
+
+	if (si->stream_version == 7 && si->is_true_gapless)
+		d->samples = ((si->samples + MPC_FRAME_LENGTH - 1) / MPC_FRAME_LENGTH) * MPC_FRAME_LENGTH;
+	else
+		d->samples = si->samples;
+}
+
+mpc_decoder * mpc_decoder_init(mpc_streaminfo *si)
+{
+	mpc_decoder* p_tmp = malloc(sizeof(mpc_decoder));
+
+	if (p_tmp != 0) {
+		mpc_decoder_setup(p_tmp);
+		mpc_decoder_set_streaminfo(p_tmp, si);
+	}
+
+	return p_tmp;
+}
+
+void mpc_decoder_exit(mpc_decoder *d)
+{
+	free(d);
+}
+
+void mpc_decoder_decode_frame(mpc_decoder * d,
+							  mpc_bits_reader * r,
+							  mpc_frame_info * i)
+{
+	mpc_bits_reader r_sav = *r;
+	mpc_int64_t samples_left;
+
+	if (d->decoded_samples >= d->samples && d->samples != 0) {
+		i->samples = 0;
+		return;
+	}
+
+	mpc_decoder_read_bitstream_sv7(d, r);
+	mpc_decoder_requantisierung(d);
+	mpc_decoder_synthese_filter_float(d, i->buffer);
+
+	d->decoded_samples += MPC_FRAME_LENGTH;
+
+    // reconstruct exact filelength
+	if (d->decoded_samples == d->samples && d->stream_version == 7) {
+		int last_frame_samples = mpc_bits_read(r, 11);
+		if (last_frame_samples == 0) last_frame_samples = MPC_FRAME_LENGTH;
+		d->samples += last_frame_samples - MPC_FRAME_LENGTH;
+	}
+
+	samples_left = d->samples - d->decoded_samples + MPC_DECODER_SYNTH_DELAY;
+	i->samples = samples_left > MPC_FRAME_LENGTH ? MPC_FRAME_LENGTH : samples_left < 0 ? 0 : samples_left;
+	i->bits = ((r->buff - r_sav.buff) << 3) + r_sav.count - r->count;
+
+	if (d->samples_to_skip) {
+		if (i->samples < d->samples_to_skip) {
+			d->samples_to_skip -= i->samples;
+			i->samples = 0;
+		} else {
+			i->samples -= d->samples_to_skip;
+			memmove(i->buffer, i->buffer + d->samples_to_skip * d->channels,
+					i->samples * d->channels * sizeof (MPC_SAMPLE_FORMAT));
+			d->samples_to_skip = 0;
+		}
+	}
+}
+
+void
+mpc_decoder_requantisierung(mpc_decoder *d)
+{
+    mpc_int32_t     Band;
+    mpc_int32_t     n;
+    MPC_SAMPLE_FORMAT facL;
+    MPC_SAMPLE_FORMAT facR;
+    MPC_SAMPLE_FORMAT templ;
+    MPC_SAMPLE_FORMAT tempr;
+    MPC_SAMPLE_FORMAT* YL;
+    MPC_SAMPLE_FORMAT* YR;
+    mpc_int32_t*    L;
+    mpc_int32_t*    R;
+	const mpc_int32_t Last_Band = d->max_band;
+
+#ifdef MPC_FIXED_POINT
+#if MPC_FIXED_POINT_FRACTPART == 14
+#define MPC_MULTIPLY_SCF(CcVal, SCF_idx) \
+    MPC_MULTIPLY_EX(CcVal, d->SCF[SCF_idx], d->SCF_shift[SCF_idx])
+#else
+
+#error FIXME, Cc table is in 18.14 format
+
+#endif
+#else
+#define MPC_MULTIPLY_SCF(CcVal, SCF_idx) \
+    MPC_MULTIPLY(CcVal, d->SCF[SCF_idx])
+#endif
+    // requantization and scaling of subband-samples
+    for ( Band = 0; Band <= Last_Band; Band++ ) {   // setting pointers
+        YL = d->Y_L[0] + Band;
+        YR = d->Y_R[0] + Band;
+        L  = d->Q[Band].L;
+        R  = d->Q[Band].R;
+        /************************** MS-coded **************************/
+        if ( d->MS_Flag [Band] ) {
+            if ( d->Res_L [Band] ) {
+                if ( d->Res_R [Band] ) {    // M!=0, S!=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]] , (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]] , (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++));
+                        *YR   = templ - tempr;
+                    }
+                } else {    // M!=0, S==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]] , (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]] , (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++);
+                    }
+                }
+            } else {
+                if (d->Res_R[Band])    // M==0, S!=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]] , (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]] , (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++)));
+                    }
+                } else {    // M==0, S==0
+                    for ( n = 0; n < 36; n++, YL += 32, YR += 32 ) {
+                        *YR = *YL = 0;
+                    }
+                }
+            }
+        }
+        /************************** LR-coded **************************/
+        else {
+            if ( d->Res_L [Band] ) {
+                if ( d->Res_R [Band] ) {    // L!=0, R!=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]] , (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]] , (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++);
+                        *YR = MPC_MULTIPLY_FLOAT_INT(facR,*R++);
+                    }
+                } else {     // L!=0, R==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]] , (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]] , (mpc_uint8_t) d->SCF_Index_L[Band][2]);
+                    for ( ; n < 36; n++, YL += 32, YR += 32 ) {
+                        *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++);
+                        *YR = 0;
+                    }
+                }
+            }
+            else {
+                if ( d->Res_R [Band] ) {    // L==0, R!=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]] , (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]] , (mpc_uint8_t) d->SCF_Index_R[Band][2]);
+                    for ( ; n < 36; n++, YL += 32, YR += 32 ) {
+                        *YL = 0;
+                        *YR = MPC_MULTIPLY_FLOAT_INT(facR,*R++);
+                    }
+                } else {    // L==0, R==0
+                    for ( n = 0; n < 36; n++, YL += 32, YR += 32 ) {
+                        *YR = *YL = 0;
+                    }
+                }
+            }
+        }
+    }
+}
+
+void mpc_decoder_read_bitstream_sv7(mpc_decoder * d, mpc_bits_reader * r)
+{
+    // these arrays hold decoding results for bundled quantizers (3- and 5-step)
+    static const mpc_int32_t idx30[] = { -1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1};
+    static const mpc_int32_t idx31[] = { -1,-1,-1, 0, 0, 0, 1, 1, 1,-1,-1,-1, 0, 0, 0, 1, 1, 1,-1,-1,-1, 0, 0, 0, 1, 1, 1};
+    static const mpc_int32_t idx32[] = { -1,-1,-1,-1,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1};
+    static const mpc_int32_t idx50[] = { -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2};
+    static const mpc_int32_t idx51[] = { -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2};
+
+    mpc_int32_t n,k;
+    mpc_int32_t Max_used_Band=0;
+    const mpc_huffman *Table;
+    mpc_int32_t idx;
+    mpc_int32_t *L   ,*R;
+    mpc_int32_t *ResL,*ResR;
+    mpc_uint32_t tmp;
+
+    /***************************** Header *****************************/
+    ResL  = d->Res_L;
+    ResR  = d->Res_R;
+
+    // first subband
+    *ResL = mpc_bits_read(r, 4);
+    *ResR = mpc_bits_read(r, 4);
+	if (d->ms && !(*ResL==0 && *ResR==0)) {
+        d->MS_Flag[0] = mpc_bits_read(r, 1);
+    }
+
+    // consecutive subbands
+    ++ResL; ++ResR; // increase pointers
+	for (n=1; n <= d->max_band; ++n, ++ResL, ++ResR)
+    {
+		idx   = mpc_bits_huff_dec(r, mpc_table_HuffHdr);
+        *ResL = (idx!=4) ? *(ResL-1) + idx : (int) mpc_bits_read(r, 4);
+
+		idx   = mpc_bits_huff_dec(r, mpc_table_HuffHdr);
+        *ResR = (idx!=4) ? *(ResR-1) + idx : (int) mpc_bits_read(r, 4);
+
+		if (d->ms && !(*ResL==0 && *ResR==0)) {
+            d->MS_Flag[n] = mpc_bits_read(r, 1);
+        }
+
+        // only perform following procedures up to the maximum non-zero subband
+        if (*ResL!=0 || *ResR!=0) {
+            Max_used_Band = n;
+        }
+    }
+    /****************************** SCFI ******************************/
+    L     = d->SCFI_L;
+    R     = d->SCFI_R;
+    ResL  = d->Res_L;
+    ResR  = d->Res_R;
+    for (n=0; n <= Max_used_Band; ++n, ++L, ++R, ++ResL, ++ResR) {
+		if (*ResL) *L = mpc_bits_huff_dec(r, mpc_table_HuffSCFI);
+		if (*ResR) *R = mpc_bits_huff_dec(r, mpc_table_HuffSCFI);
+    }
+
+    /**************************** SCF/DSCF ****************************/
+    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)
+        {
+            switch (d->SCFI_L[n])
+            {
+            case 1:
+                idx  = mpc_bits_huff_dec(r, mpc_table_HuffDSCF);
+                L[0] = (idx!=8) ? L[2] + idx : (int) mpc_bits_read(r, 6);
+                idx  = mpc_bits_huff_dec(r, mpc_table_HuffDSCF);
+                L[1] = (idx!=8) ? L[0] + idx : (int) mpc_bits_read(r, 6);
+                L[2] = L[1];
+                break;
+            case 3:
+                idx  = mpc_bits_huff_dec(r, mpc_table_HuffDSCF);
+                L[0] = (idx!=8) ? L[2] + idx : (int) mpc_bits_read(r, 6);
+                L[1] = L[0];
+                L[2] = L[1];
+                break;
+            case 2:
+                idx  = mpc_bits_huff_dec(r, mpc_table_HuffDSCF);
+                L[0] = (idx!=8) ? L[2] + idx : (int) mpc_bits_read(r, 6);
+                L[1] = L[0];
+                idx  = mpc_bits_huff_dec(r, mpc_table_HuffDSCF);
+                L[2] = (idx!=8) ? L[1] + idx : (int) mpc_bits_read(r, 6);
+                break;
+            case 0:
+                idx  = mpc_bits_huff_dec(r, mpc_table_HuffDSCF);
+                L[0] = (idx!=8) ? L[2] + idx : (int) mpc_bits_read(r, 6);
+                idx  = mpc_bits_huff_dec(r, mpc_table_HuffDSCF);
+                L[1] = (idx!=8) ? L[0] + idx : (int) mpc_bits_read(r, 6);
+                idx  = mpc_bits_huff_dec(r, mpc_table_HuffDSCF);
+                L[2] = (idx!=8) ? L[1] + idx : (int) mpc_bits_read(r, 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;
+        }
+        if (*ResR)
+        {
+            switch (d->SCFI_R[n])
+            {
+            case 1:
+                idx  = mpc_bits_huff_dec(r, mpc_table_HuffDSCF);
+                R[0] = (idx!=8) ? R[2] + idx : (int) mpc_bits_read(r, 6);
+                idx  = mpc_bits_huff_dec(r, mpc_table_HuffDSCF);
+                R[1] = (idx!=8) ? R[0] + idx : (int) mpc_bits_read(r, 6);
+                R[2] = R[1];
+                break;
+            case 3:
+                idx  = mpc_bits_huff_dec(r, mpc_table_HuffDSCF);
+                R[0] = (idx!=8) ? R[2] + idx : (int) mpc_bits_read(r, 6);
+                R[1] = R[0];
+                R[2] = R[1];
+                break;
+            case 2:
+                idx  = mpc_bits_huff_dec(r, mpc_table_HuffDSCF);
+                R[0] = (idx!=8) ? R[2] + idx : (int) mpc_bits_read(r, 6);
+                R[1] = R[0];
+                idx  = mpc_bits_huff_dec(r, mpc_table_HuffDSCF);
+                R[2] = (idx!=8) ? R[1] + idx : (int) mpc_bits_read(r, 6);
+                break;
+            case 0:
+                idx  = mpc_bits_huff_dec(r, mpc_table_HuffDSCF);
+                R[0] = (idx!=8) ? R[2] + idx : (int) mpc_bits_read(r, 6);
+                idx  = mpc_bits_huff_dec(r, mpc_table_HuffDSCF);
+                R[1] = (idx!=8) ? R[0] + idx : (int) mpc_bits_read(r, 6);
+                idx  = mpc_bits_huff_dec(r, mpc_table_HuffDSCF);
+                R[2] = (idx!=8) ? R[1] + idx : (int) mpc_bits_read(r, 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;
+        }
+    }
+
+//     if (d->seeking == TRUE)
+//         return;
+
+    /***************************** Samples ****************************/
+    ResL = d->Res_L;
+    ResR = d->Res_R;
+    L    = d->Q[0].L;
+    R    = d->Q[0].R;
+    for (n=0; n <= Max_used_Band; ++n, ++ResL, ++ResR, L+=36, R+=36)
+    {
+        /************** links **************/
+        switch (*ResL)
+        {
+        case  -2: case  -3: case  -4: case  -5: case  -6: case  -7: case  -8: case  -9:
+        case -10: case -11: case -12: case -13: case -14: case -15: case -16: case -17:
+            L += 36;
+            break;
+        case -1:
+            for (k=0; k<36; k++ ) {
+                tmp  = mpc_random_int(d);
+                *L++ = ((tmp >> 24) & 0xFF) + ((tmp >> 16) & 0xFF) + ((tmp >>  8) & 0xFF) + ((tmp >>  0) & 0xFF) - 510;
+            }
+            break;
+        case 0:
+            L += 36;// increase pointer
+            break;
+        case 1:
+            Table = mpc_table_HuffQ[mpc_bits_read(r, 1)][1];
+            for (k=0; k<12; ++k)
+            {
+                idx = mpc_bits_huff_dec(r, Table);
+                *L++ = idx30[idx];
+                *L++ = idx31[idx];
+                *L++ = idx32[idx];
+            }
+            break;
+        case 2:
+            Table = mpc_table_HuffQ[mpc_bits_read(r, 1)][2];
+            for (k=0; k<18; ++k)
+            {
+                idx = mpc_bits_huff_dec(r, Table);
+                *L++ = idx50[idx];
+                *L++ = idx51[idx];
+            }
+            break;
+        case 3:
+        case 4:
+            Table = mpc_table_HuffQ[mpc_bits_read(r, 1)][*ResL];
+            for (k=0; k<36; ++k)
+                *L++ = mpc_bits_huff_dec(r, Table);
+            break;
+        case 5:
+            Table = mpc_table_HuffQ[mpc_bits_read(r, 1)][*ResL];
+            for (k=0; k<36; ++k)
+                *L++ = mpc_bits_huff_dec(r, Table);
+            break;
+        case 6:
+        case 7:
+            Table = mpc_table_HuffQ[mpc_bits_read(r, 1)][*ResL];
+            for (k=0; k<36; ++k)
+                *L++ = mpc_bits_huff_dec(r, Table);
+            break;
+        case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 17:
+            tmp = Dc[*ResL];
+            for (k=0; k<36; ++k)
+                *L++ = (mpc_int32_t)mpc_bits_read(r, Res_bit[*ResL]) - tmp;
+            break;
+        default:
+            return;
+        }
+        /************** rechts **************/
+        switch (*ResR)
+        {
+        case  -2: case  -3: case  -4: case  -5: case  -6: case  -7: case  -8: case  -9:
+        case -10: case -11: case -12: case -13: case -14: case -15: case -16: case -17:
+            R += 36;
+            break;
+        case -1:
+                for (k=0; k<36; k++ ) {
+                    tmp  = mpc_random_int(d);
+                    *R++ = ((tmp >> 24) & 0xFF) + ((tmp >> 16) & 0xFF) + ((tmp >>  8) & 0xFF) + ((tmp >>  0) & 0xFF) - 510;
+                }
+                break;
+            case 0:
+                R += 36;// increase pointer
+                break;
+            case 1:
+                Table = mpc_table_HuffQ[mpc_bits_read(r, 1)][1];
+                for (k=0; k<12; ++k)
+                {
+                    idx = mpc_bits_huff_dec(r, Table);
+                    *R++ = idx30[idx];
+                    *R++ = idx31[idx];
+                    *R++ = idx32[idx];
+                }
+                break;
+            case 2:
+                Table = mpc_table_HuffQ[mpc_bits_read(r, 1)][2];
+                for (k=0; k<18; ++k)
+                {
+                    idx = mpc_bits_huff_dec(r, Table);
+                    *R++ = idx50[idx];
+                    *R++ = idx51[idx];
+                }
+                break;
+            case 3:
+            case 4:
+                Table = mpc_table_HuffQ[mpc_bits_read(r, 1)][*ResR];
+                for (k=0; k<36; ++k)
+                    *R++ = mpc_bits_huff_dec(r, Table);
+                break;
+            case 5:
+                Table = mpc_table_HuffQ[mpc_bits_read(r, 1)][*ResR];
+                for (k=0; k<36; ++k)
+                    *R++ = mpc_bits_huff_dec(r, Table);
+                break;
+            case 6:
+            case 7:
+                Table = mpc_table_HuffQ[mpc_bits_read(r, 1)][*ResR];
+                for (k=0; k<36; ++k)
+                    *R++ = mpc_bits_huff_dec(r, Table);
+                break;
+            case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 17:
+                tmp = Dc[*ResR];
+                for (k=0; k<36; ++k)
+                    *R++ = (mpc_int32_t)mpc_bits_read(r, Res_bit[*ResR]) - tmp;
+                break;
+            default:
+                return;
+        }
+    }
+}
+
+
+
Index: libmpc/branches/r2d/libmpcdec/src/mpc_demux.c
===================================================================
--- libmpc/branches/r2d/libmpcdec/src/mpc_demux.c	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/src/mpc_demux.c	(revision 130)
@@ -0,0 +1,308 @@
+/*
+  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 <mpcdec/streaminfo.h>
+#include <mpcdec/mpcdec.h>
+#include "internal.h"
+#include "decoder.h"
+
+// mpc_bits_reader.c
+mpc_uint32_t mpc_bits_read(mpc_bits_reader * r, const unsigned int nb_bits);
+int mpc_bits_get_block(mpc_bits_reader * r, mpc_block * p_block);
+
+// streaminfo.c
+mpc_status streaminfo_read_header_sv8(mpc_streaminfo* si, const mpc_bits_reader * r_in);
+mpc_status streaminfo_read_header_sv7(mpc_streaminfo* si, mpc_bits_reader * r_in);
+void  streaminfo_encoder_info(mpc_streaminfo* si, const mpc_bits_reader * r_in);
+void  streaminfo_gain(mpc_streaminfo* si, const mpc_bits_reader * r_in);
+
+#define MAX_FRAME_SIZE 4352
+
+enum {
+	MPC_BUFFER_CLEAR = 1,
+	MPC_BUFFER_SWAP = 2,
+	MPC_BUFFER_FULL = 4,
+};
+
+static mpc_uint32_t
+mpc_demux_fill(mpc_demux * d, mpc_uint32_t min_bytes, int flags)
+{
+	mpc_uint32_t unread_bytes = d->bytes_total + d->buffer - d->bits_reader.buff
+			- ((8 - d->bits_reader.count) >> 3);
+
+	if (min_bytes == 0 || min_bytes > DEMUX_BUFFER_SIZE ||
+		    (unread_bytes < min_bytes && flags & MPC_BUFFER_FULL))
+		min_bytes = DEMUX_BUFFER_SIZE;
+
+	if (unread_bytes < min_bytes) {
+		mpc_uint32_t bytes2read = min_bytes - unread_bytes;
+		mpc_uint32_t bytes_free = DEMUX_BUFFER_SIZE - d->bytes_total;
+
+		if (flags & MPC_BUFFER_SWAP)
+			bytes2read &= -1 << 2;
+
+		if (bytes2read > bytes_free) {
+			if (d->bits_reader.count == 0) {
+				d->bits_reader.count = 8;
+				d->bits_reader.buff++;
+			}
+			memmove(d->buffer, d->bits_reader.buff, unread_bytes);
+			d->bits_reader.buff = d->buffer;
+			d->bytes_total = unread_bytes;
+		}
+		bytes2read = d->r->read(d->r, d->buffer + d->bytes_total, bytes2read);
+		if (flags & MPC_BUFFER_SWAP){
+			unsigned int i, * tmp = (unsigned int *) (d->buffer + d->bytes_total);
+			for(i = 0 ;i < (bytes2read >> 2); i++)
+				tmp[i] = mpc_swap32(tmp[i]);
+		}
+		d->bytes_total += bytes2read;
+		return bytes2read;
+	}
+
+	return 0;
+}
+
+static mpc_status mpc_demux_header(mpc_demux * d)
+{
+	char magic[4];
+	int err;
+
+	memset(&d->si, 0, sizeof d->si);
+
+    // get header position
+	err = d->si.header_position = mpc_skip_id3v2(d->r);
+	if(err < 0) return MPC_STATUS_FILE;
+
+	// seek to first byte of mpc data
+	err = d->r->seek(d->r, d->si.header_position);
+	if(!err) return MPC_STATUS_FILE;
+
+	d->si.tag_offset = d->si.total_file_length = d->r->get_size(d->r);
+
+	mpc_demux_fill(d, 4, 0);
+	magic[0] = mpc_bits_read(&d->bits_reader, 8);
+	magic[1] = mpc_bits_read(&d->bits_reader, 8);
+	magic[2] = mpc_bits_read(&d->bits_reader, 8);
+	magic[3] = mpc_bits_read(&d->bits_reader, 8);
+
+	if (memcmp(magic, "MP+", 3) == 0) {
+		d->si.stream_version = magic[3] & 15;
+		d->si.pns = magic[3] >> 4;
+		if (d->si.stream_version == 7) {
+			mpc_demux_fill(d, 6 * 4, MPC_BUFFER_SWAP); // header block size + endian convertion
+			streaminfo_read_header_sv7(&d->si, &d->bits_reader);
+		} else {
+			return MPC_STATUS_INVALIDSV;
+		}
+	} else if (memcmp(magic, "MPCK", 4) == 0) {
+		mpc_block b;
+		int size;
+		mpc_demux_fill(d, 11, 0); // max header block size
+		size = mpc_bits_get_block(&d->bits_reader, &b);
+		while( memcmp(b.key, "AD", 2) != 0 ){ // scan all blocks until audio
+			mpc_demux_fill(d, 11 + b.size, 0);
+			if (memcmp(b.key, "SI", 2) == 0)
+				streaminfo_read_header_sv8(&d->si, &d->bits_reader);
+			else if (memcmp(b.key, "EI", 2) == 0)
+				streaminfo_encoder_info(&d->si, &d->bits_reader);
+			else if (memcmp(b.key, "RG", 2) == 0)
+				streaminfo_gain(&d->si, &d->bits_reader);
+			d->bits_reader.buff += b.size;
+			size = mpc_bits_get_block(&d->bits_reader, &b);
+		}
+		d->bits_reader.buff -= size;
+	} else
+		return MPC_STATUS_INVALIDSV;
+
+	return MPC_STATUS_OK;
+}
+
+mpc_demux * mpc_demux_init(mpc_reader * p_reader)
+{
+	mpc_demux* p_tmp = malloc(sizeof(mpc_demux));
+
+	if (p_tmp != 0) {
+		p_tmp->r = p_reader;
+		p_tmp->bytes_total = 0;
+		p_tmp->bits_reader.buff = p_tmp->buffer;
+		p_tmp->bits_reader.count = 8;
+		p_tmp->block_bits = 0;
+		// lire entÃªte
+		mpc_demux_header(p_tmp);
+		// initialisation decodeur
+		p_tmp->d = mpc_decoder_init(&p_tmp->si);
+	}
+
+	return p_tmp;
+}
+
+void mpc_demux_exit(mpc_demux * d)
+{
+	mpc_decoder_exit(d->d);
+	free(d);
+}
+
+void mpc_demux_get_info(mpc_demux * d, mpc_streaminfo * i)
+{
+	memcpy(i, &d->si, sizeof d->si);
+}
+
+void mpc_demux_decode(mpc_demux * d, mpc_frame_info * i)
+{
+	if (d->si.stream_version == 8) {
+		mpc_bits_reader r;
+		if (d->block_bits < 8 && (d->d->decoded_samples < d->d->samples || d->d->samples == 0)){
+			mpc_block b;
+			d->bits_reader.count &= -8;
+			mpc_demux_fill(d, 11, 0); // max header block size
+			mpc_bits_get_block(&d->bits_reader, &b);
+			while( memcmp(b.key, "AD", 2) != 0 ){ // scan all blocks until audio
+				mpc_demux_fill(d, 11 + b.size, 0);
+				d->bits_reader.buff += b.size;
+				mpc_bits_get_block(&d->bits_reader, &b);
+			}
+			d->block_bits = b.size * 8;
+		}
+
+		mpc_demux_fill(d, (d->block_bits >> 3) + 1, 0);
+		r = d->bits_reader;
+		mpc_decoder_decode_frame(d->d, &d->bits_reader, i);
+		d->block_bits -= ((d->bits_reader.buff - r.buff) << 3) + r.count - d->bits_reader.count;
+	} else {
+		mpc_bits_reader r;
+		mpc_demux_fill(d, MAX_FRAME_SIZE, MPC_BUFFER_FULL | MPC_BUFFER_SWAP);
+		mpc_bits_read(&d->bits_reader, 20); // read frame size
+		r = d->bits_reader;
+		mpc_decoder_decode_frame(d->d, &d->bits_reader, i);
+	}
+}
+
+// static mpc_uint32_t
+// mpc_decoder_decode_internal(mpc_decoder *d, MPC_SAMPLE_FORMAT *buffer)
+// {
+// 	mpc_uint32_t output_frame_length = MPC_FRAME_LENGTH;
+// 	mpc_uint32_t FwdJumpInfo = 0;
+// 	mpc_uint32_t  FrameBitCnt = 0;
+//
+// 	if (d->decoded_frames >= d->OverallFrames) {
+// 		return (mpc_uint32_t)(-1);                           // end of file -> abort decoding
+// 	}
+//
+//     // add seeking info
+// 	if (d->seeking_table_frames < d->decoded_frames &&
+// 		   (d->decoded_frames & ((1 << d->seeking_pwr) - 1)) == 0) {
+// 		d->seeking_table[d->decoded_frames >> d->seeking_pwr] = mpc_decoder_bits_read(d);
+// 		d->seeking_table_frames = d->decoded_frames;
+// 		   }
+//
+// 		   switch (d->StreamVersion) {
+// 			   case 0x07:
+// 			   case 0x17:
+// 		// read jump-info for validity check of frame
+// 				   FwdJumpInfo  = mpc_decoder_bitstream_read(d, 20);
+//     	// decode data and check for validity of frame
+// 				   FrameBitCnt = mpc_decoder_bits_read(d);
+//
+// 				   d->FrameWasValid = mpc_decoder_bits_read(d) - FrameBitCnt == FwdJumpInfo;
+// 				   break;
+// 			   case 0x08:
+// 				   if (d->BlockBits < 8){
+// 					   mpc_block block;
+// 			// trouver le block
+// 					   mpc_decoder_bitstream_read(d, d->BlockBits);
+// 					   while (1) {
+// 						   mpc_decoder_get_block(d, &block);
+// 						   if (memcmp(block.key, "AD", 2) != 0)
+// 							   mpc_decoder_seek(d, mpc_decoder_bits_read(d) + block.size * 8);
+// 						   else
+// 							   break;
+// 					   }
+// 					   d->BlockBits = block.size * 8;
+// 				   }
+// 				   FrameBitCnt = mpc_decoder_bits_read(d);
+// 				   mpc_decoder_read_bitstream_sv7(d, FALSE);
+// 				   d->BlockBits -= mpc_decoder_bits_read(d) - FrameBitCnt;
+// 				   d->FrameWasValid = 1;
+// 				   break;
+// 			   default:
+// 				   return (mpc_uint32_t)(-1);
+// 		   }
+//
+// 		   return output_frame_length;
+// }
+//
+// 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)
+// {
+// 	for(;;)
+// 	{
+//         //const mpc_int32_t MaxBrokenFrames = 0; // PluginSettings.MaxBrokenFrames
+//
+// 		mpc_uint32_t RING = d->Zaehler;
+// 		mpc_int32_t vbr_ring = (RING << 5) + d->pos;
+//
+// 		mpc_uint32_t valid_samples = mpc_decoder_decode_internal(d, buffer);
+//
+// 		if (valid_samples == (mpc_uint32_t)(-1) ) {
+// 			return 0;
+// 		}
+//
+// 		/**************** ERROR CONCEALMENT *****************/
+// 		if (d->FrameWasValid == 0 ) {
+//             // error occurred in bitstream
+// 			return (mpc_uint32_t)(-1);
+// 		}
+// 		else {
+// 			if (vbr_update_acc && vbr_update_bits) {
+// 				(*vbr_update_acc) ++;
+// 				vbr_ring = (d->Zaehler << 5) + d->pos - vbr_ring;
+// 				if (vbr_ring < 0) {
+// 					vbr_ring += 524288;
+// 				}
+// 				(*vbr_update_bits) += vbr_ring;
+// 			}
+//
+// 		}
+// 		mpc_decoder_update_buffer(d, RING);
+//
+// 		if (valid_samples > 0) {
+// 			return valid_samples;
+// 		}
+// 	}
+// }
+
Index: libmpc/branches/r2d/libmpcdec/src/mpc_reader.c
===================================================================
--- libmpc/branches/r2d/libmpcdec/src/mpc_reader.c	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/src/mpc_reader.c	(revision 130)
@@ -0,0 +1,182 @@
+/*
+  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 mpc_reader.c
+/// Contains implementations for simple file-based mpc_reader
+#include <mpcdec/reader.h>
+#include "internal.h"
+#include <stdio.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_stdio(mpc_reader *p_reader, void *ptr, mpc_int32_t size)
+{
+    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_stdio(mpc_reader *p_reader, mpc_int32_t offset)
+{
+    mpc_reader_stdio *p_stdio = (mpc_reader_stdio*) p_reader->data;
+    if(p_stdio->magic != STDIO_MAGIC) return MPC_FALSE;
+    return p_stdio->is_seekable ? fseek(p_stdio->p_file, offset, SEEK_SET) == 0 : MPC_FALSE;
+}
+
+static mpc_int32_t
+tell_stdio(mpc_reader *p_reader)
+{
+    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_stdio(mpc_reader *p_reader)
+{
+    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_stdio(mpc_reader *p_reader)
+{
+    mpc_reader_stdio *p_stdio = (mpc_reader_stdio*) p_reader->data;
+    if(p_stdio->magic != STDIO_MAGIC) return MPC_FALSE;
+    return p_stdio->is_seekable;
+}
+
+mpc_status
+mpc_reader_init_stdio(mpc_reader *p_reader, const 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 = MPC_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_exit_stdio(mpc_reader *p_reader)
+{
+    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;
+}
+
+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: libmpc/branches/r2d/libmpcdec/src/requant.c
===================================================================
--- libmpc/branches/r2d/libmpcdec/src/requant.c	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/src/requant.c	(revision 130)
@@ -0,0 +1,124 @@
+/*
+  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.c
+/// Requantization function implementations.
+/// \todo document me
+#include <mpcdec/mpcdec.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
+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
+};
+
+// Requantization coefficients
+// 65536/step bzw. 65536/(2*D+1)
+
+#define _(X) MAKE_MPC_SAMPLE_EX(X,14)
+
+const MPC_SAMPLE_FORMAT  __Cc [1 + 18] = {
+    _(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)
+};
+
+#undef _
+
+// Requantization offset
+// 2*D+1 = steps of quantizer
+const mpc_int32_t  __Dc [1 + 18] = {
+      2,
+      0,     1,     2,     3,     4,     7,    15,    31,    63,
+    127,   255,   511,  1023,  2047,  4095,  8191, 16383, 32767
+};
+
+#ifdef MPC_FIXED_POINT
+static mpc_uint32_t find_shift(double fval)
+{
+    mpc_int64_t  val = (mpc_int64_t) fval;
+    mpc_uint32_t ptr = 0;
+    if(val<0)
+        val = -val;
+    while(val)
+    {
+        val >>= 1;
+        ptr++;
+    }
+    return ptr > 31 ? 0 : 31 - ptr;
+}
+#endif
+
+/* 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] = (mpc_uint8_t) find_shift(X));
+
+void
+mpc_decoder_scale_output(mpc_decoder *d, double factor)
+{
+    mpc_int32_t n; double f1, f2;
+
+#ifndef MPC_FIXED_POINT
+    factor *= 1.0 / (double) (1<<(MPC_FIXED_POINT_SHIFT-1));
+#else
+    factor *= 1.0 / (double) (1<<(16-MPC_FIXED_POINT_SHIFT));
+#endif
+    f1 = f2 = factor;
+
+    // handles +1.58...-98.41 dB, where's scf[n] / scf[n-1] = 1.20050805774840750476
+
+    SET_SCF(1,factor);
+
+    f1 *=   0.83298066476582673961;
+    f2 *= 1/0.83298066476582673961;
+
+    for ( n = 1; n <= 128; n++ ) {
+        SET_SCF((mpc_uint8_t)(1+n),f1);
+        SET_SCF((mpc_uint8_t)(1-n),f2);
+        f1 *=   0.83298066476582673961;
+        f2 *= 1/0.83298066476582673961;
+    }
+}
+
+void
+mpc_decoder_init_quant(mpc_decoder *d, double scale_factor)
+{
+    mpc_decoder_scale_output(d, scale_factor);
+}
Index: libmpc/branches/r2d/libmpcdec/src/requant.h
===================================================================
--- libmpc/branches/r2d/libmpcdec/src/requant.h	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/src/requant.h	(revision 130)
@@ -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: libmpc/branches/r2d/libmpcdec/src/streaminfo.c
===================================================================
--- libmpc/branches/r2d/libmpcdec/src/streaminfo.c	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/src/streaminfo.c	(revision 130)
@@ -0,0 +1,204 @@
+/*
+  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.c
+/// Implementation of streaminfo reading functions.
+
+#include <mpcdec/mpcdec.h>
+#include <mpcdec/streaminfo.h>
+#include <stdio.h>
+#include "internal.h"
+
+mpc_uint32_t mpc_bits_read(mpc_bits_reader * r, const unsigned int nb_bits);
+unsigned int mpc_bits_get_size(mpc_bits_reader * r, mpc_uint64_t * p_size);
+
+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 *
+mpc_get_version_string(mpc_uint32_t profile) // profile is 0...15, where 7...13 is used
+{
+    return profile >= sizeof versionNames / sizeof *versionNames ? na : versionNames[profile];
+}
+
+static void
+mpc_get_encoder_string(mpc_streaminfo* si)
+{
+	if (si->stream_version < 8) {
+		if (si->encoder_version == 0) {
+			sprintf(si->encoder, "Buschmann 1.7.0...9, Klemm 0.90...1.05");
+		} else {
+			switch (si->encoder_version % 10) {
+				case 0:
+					sprintf(si->encoder, "Release %u.%u", si->encoder_version / 100,
+							si->encoder_version / 10 % 10);
+					break;
+				case 2: case 4: case 6: case 8:
+					sprintf(si->encoder, "Beta %u.%02u", si->encoder_version / 100,
+							si->encoder_version % 100);
+					break;
+				default:
+					sprintf(si->encoder, "--Alpha-- %u.%02u",
+							si->encoder_version / 100, si->encoder_version % 100);
+					break;
+			}
+		}
+	} else {
+		int major = si->encoder_version >> 24;
+		int minor = (si->encoder_version >> 16) & 0xFF;
+		int impl = (si->encoder_version >> 8) & 0xFF;
+		int build = si->encoder_version & 0xFF;
+		char * tmp = "--Stable--";
+
+		if (minor & 1)
+			tmp = "--Unstable--";
+
+		sprintf(si->encoder, "%s %u.%u.%u build %u", tmp, major, minor, impl,
+				build);
+	}
+}
+
+/// Reads streaminfo from SV7 header.
+mpc_status
+streaminfo_read_header_sv7(mpc_streaminfo* si, mpc_bits_reader * r)
+{
+    mpc_uint16_t Estimatedpeak_title = 0;
+	mpc_uint32_t frames, last_frame_samples;
+
+	si->bitrate            = 0;
+	frames                 = mpc_bits_read(r, 32);
+	mpc_bits_read(r, 1); // intensity stereo : should be 0
+	si->ms                 = mpc_bits_read(r, 1);
+	si->max_band           = mpc_bits_read(r, 6);
+	si->profile            = mpc_bits_read(r, 4);
+    si->profile_name       = mpc_get_version_string(si->profile);
+	mpc_bits_read(r, 2); // Link ?
+	si->sample_freq        = samplefreqs[mpc_bits_read(r, 2)];
+	Estimatedpeak_title    = (mpc_uint16_t) mpc_bits_read(r, 16);   // read the ReplayGain data
+	si->gain_title         = (mpc_uint16_t) mpc_bits_read(r, 16);
+	si->peak_title         = (mpc_uint16_t) mpc_bits_read(r, 16);
+	si->gain_album         = (mpc_uint16_t) mpc_bits_read(r, 16);
+	si->peak_album         = (mpc_uint16_t) mpc_bits_read(r, 16);
+	si->is_true_gapless    = mpc_bits_read(r, 1); // true gapless: used?
+	last_frame_samples     = mpc_bits_read(r, 11); // true gapless: valid samples for last frame
+	si->fast_seek          = mpc_bits_read(r, 1); // fast seeking
+	mpc_bits_read(r, 19); // unused
+	si->encoder_version    = mpc_bits_read(r, 8);
+    si->channels           = 2;
+
+	mpc_get_encoder_string(si);
+
+	if (last_frame_samples == 0) last_frame_samples = MPC_FRAME_LENGTH;
+	si->samples = (mpc_int64_t) frames * MPC_FRAME_LENGTH;
+	if (si->is_true_gapless)
+		si->samples -= (MPC_FRAME_LENGTH - last_frame_samples);
+	else
+		si->samples -= MPC_DECODER_SYNTH_DELAY;
+
+	si->average_bitrate = (si->tag_offset  - si->header_position) * 8.0
+			*  si->sample_freq / si->samples;
+
+    return MPC_STATUS_OK;
+}
+
+/// Reads streaminfo from SV8 header.
+mpc_status
+streaminfo_read_header_sv8(mpc_streaminfo* si, const mpc_bits_reader * r_in)
+{
+	mpc_uint32_t CRC;
+	mpc_bits_reader r = *r_in;
+
+	// FIXME : add CRC check
+	CRC = mpc_bits_read(&r, 32);
+	si->stream_version = mpc_bits_read(&r, 8);
+	mpc_bits_get_size(&r, &si->samples);
+	si->is_true_gapless = 1;
+	si->sample_freq = samplefreqs[mpc_bits_read(&r, 4)];
+	si->channels = mpc_bits_read(&r, 4) + 1;
+	si->max_band = mpc_bits_read(&r, 5) + 1;
+	si->ms = mpc_bits_read(&r, 1);
+	si->frames_per_block = 1 << mpc_bits_read(&r, 4);
+
+	si->bitrate = 0;
+
+	si->average_bitrate = (si->tag_offset - si->header_position) * 8.0
+			*  si->sample_freq / si->samples;
+
+	return MPC_STATUS_OK;
+}
+
+/// Reads encoder informations
+void  streaminfo_encoder_info(mpc_streaminfo* si, const mpc_bits_reader * r_in)
+{
+	mpc_bits_reader r = *r_in;
+
+	si->profile            = mpc_bits_read(&r, 4);
+	si->profile_name       = mpc_get_version_string(si->profile);
+	si->pns                = mpc_bits_read(&r, 1);
+	mpc_bits_read(&r, 3); // unused
+	si->encoder_version = mpc_bits_read(&r, 4) << 24; // major
+	si->encoder_version |= mpc_bits_read(&r, 8) << 16; // minor
+	si->encoder_version |= mpc_bits_read(&r, 4) << 8; // implementation
+	si->encoder_version |= mpc_bits_read(&r, 8); // build
+
+	mpc_get_encoder_string(si);
+}
+
+/// Reads replay gain datas
+void  streaminfo_gain(mpc_streaminfo* si, const mpc_bits_reader * r_in)
+{
+	mpc_bits_reader r = *r_in;
+
+	mpc_bits_read(&r, 8); // gain version
+	// FIXME : add gain conversion
+	si->gain_title         = (mpc_uint16_t) mpc_bits_read(&r, 16);
+	si->peak_title         = (mpc_uint16_t) mpc_bits_read(&r, 16);
+	si->gain_album         = (mpc_uint16_t) mpc_bits_read(&r, 16);
+	si->peak_album         = (mpc_uint16_t) mpc_bits_read(&r, 16);
+}
+
+double
+mpc_streaminfo_get_length(mpc_streaminfo * si)
+{
+    return (double) si->samples / si->sample_freq;
+}
+
+mpc_int64_t mpc_streaminfo_get_length_samples(mpc_streaminfo *si)
+{
+	return si->samples;
+}
Index: libmpc/branches/r2d/libmpcdec/src/synth_filter.c
===================================================================
--- libmpc/branches/r2d/libmpcdec/src/synth_filter.c	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/src/synth_filter.c	(revision 130)
@@ -0,0 +1,428 @@
+/*
+  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 synth_filter.c
+/// Synthesis functions.
+/// \todo document me
+#include <string.h>
+#include <mpcdec/mpcdec.h>
+#include "decoder.h"
+#include "math.h"
+
+/* C O N S T A N T S */
+#define MPC_FIXED_POINT_SYNTH_FIX 2
+
+#undef _
+#ifdef MPC_FIXED_POINT
+#define _(value)  MPC_MAKE_FRACT_CONST((double)value/(double)(0x40000))
+#else
+#define _(value)  MAKE_MPC_SAMPLE((double)value/(double)(0x10000))
+#endif
+
+
+static const MPC_SAMPLE_FORMAT  Di_opt [32] [16] = {
+    { _(  0), _( -29), _( 213), _( -459), _( 2037), _(-5153), _(  6574), _(-37489), _(75038), _(37489), _(6574), _( 5153), _(2037), _( 459), _(213), _(29) },
+    { _( -1), _( -31), _( 218), _( -519), _( 2000), _(-5517), _(  5959), _(-39336), _(74992), _(35640), _(7134), _( 4788), _(2063), _( 401), _(208), _(26) },
+    { _( -1), _( -35), _( 222), _( -581), _( 1952), _(-5879), _(  5288), _(-41176), _(74856), _(33791), _(7640), _( 4425), _(2080), _( 347), _(202), _(24) },
+    { _( -1), _( -38), _( 225), _( -645), _( 1893), _(-6237), _(  4561), _(-43006), _(74630), _(31947), _(8092), _( 4063), _(2087), _( 294), _(196), _(21) },
+    { _( -1), _( -41), _( 227), _( -711), _( 1822), _(-6589), _(  3776), _(-44821), _(74313), _(30112), _(8492), _( 3705), _(2085), _( 244), _(190), _(19) },
+    { _( -1), _( -45), _( 228), _( -779), _( 1739), _(-6935), _(  2935), _(-46617), _(73908), _(28289), _(8840), _( 3351), _(2075), _( 197), _(183), _(17) },
+    { _( -1), _( -49), _( 228), _( -848), _( 1644), _(-7271), _(  2037), _(-48390), _(73415), _(26482), _(9139), _( 3004), _(2057), _( 153), _(176), _(16) },
+    { _( -2), _( -53), _( 227), _( -919), _( 1535), _(-7597), _(  1082), _(-50137), _(72835), _(24694), _(9389), _( 2663), _(2032), _( 111), _(169), _(14) },
+    { _( -2), _( -58), _( 224), _( -991), _( 1414), _(-7910), _(    70), _(-51853), _(72169), _(22929), _(9592), _( 2330), _(2001), _(  72), _(161), _(13) },
+    { _( -2), _( -63), _( 221), _(-1064), _( 1280), _(-8209), _(  -998), _(-53534), _(71420), _(21189), _(9750), _( 2006), _(1962), _(  36), _(154), _(11) },
+    { _( -2), _( -68), _( 215), _(-1137), _( 1131), _(-8491), _( -2122), _(-55178), _(70590), _(19478), _(9863), _( 1692), _(1919), _(   2), _(147), _(10) },
+    { _( -3), _( -73), _( 208), _(-1210), _(  970), _(-8755), _( -3300), _(-56778), _(69679), _(17799), _(9935), _( 1388), _(1870), _( -29), _(139), _( 9) },
+    { _( -3), _( -79), _( 200), _(-1283), _(  794), _(-8998), _( -4533), _(-58333), _(68692), _(16155), _(9966), _( 1095), _(1817), _( -57), _(132), _( 8) },
+    { _( -4), _( -85), _( 189), _(-1356), _(  605), _(-9219), _( -5818), _(-59838), _(67629), _(14548), _(9959), _(  814), _(1759), _( -83), _(125), _( 7) },
+    { _( -4), _( -91), _( 177), _(-1428), _(  402), _(-9416), _( -7154), _(-61289), _(66494), _(12980), _(9916), _(  545), _(1698), _(-106), _(117), _( 7) },
+    { _( -5), _( -97), _( 163), _(-1498), _(  185), _(-9585), _( -8540), _(-62684), _(65290), _(11455), _(9838), _(  288), _(1634), _(-127), _(111), _( 6) },
+    { _( -5), _(-104), _( 146), _(-1567), _(  -45), _(-9727), _( -9975), _(-64019), _(64019), _( 9975), _(9727), _(   45), _(1567), _(-146), _(104), _( 5) },
+    { _( -6), _(-111), _( 127), _(-1634), _( -288), _(-9838), _(-11455), _(-65290), _(62684), _( 8540), _(9585), _( -185), _(1498), _(-163), _( 97), _( 5) },
+    { _( -7), _(-117), _( 106), _(-1698), _( -545), _(-9916), _(-12980), _(-66494), _(61289), _( 7154), _(9416), _( -402), _(1428), _(-177), _( 91), _( 4) },
+    { _( -7), _(-125), _(  83), _(-1759), _( -814), _(-9959), _(-14548), _(-67629), _(59838), _( 5818), _(9219), _( -605), _(1356), _(-189), _( 85), _( 4) },
+    { _( -8), _(-132), _(  57), _(-1817), _(-1095), _(-9966), _(-16155), _(-68692), _(58333), _( 4533), _(8998), _( -794), _(1283), _(-200), _( 79), _( 3) },
+    { _( -9), _(-139), _(  29), _(-1870), _(-1388), _(-9935), _(-17799), _(-69679), _(56778), _( 3300), _(8755), _( -970), _(1210), _(-208), _( 73), _( 3) },
+    { _(-10), _(-147), _(  -2), _(-1919), _(-1692), _(-9863), _(-19478), _(-70590), _(55178), _( 2122), _(8491), _(-1131), _(1137), _(-215), _( 68), _( 2) },
+    { _(-11), _(-154), _( -36), _(-1962), _(-2006), _(-9750), _(-21189), _(-71420), _(53534), _(  998), _(8209), _(-1280), _(1064), _(-221), _( 63), _( 2) },
+    { _(-13), _(-161), _( -72), _(-2001), _(-2330), _(-9592), _(-22929), _(-72169), _(51853), _(  -70), _(7910), _(-1414), _( 991), _(-224), _( 58), _( 2) },
+    { _(-14), _(-169), _(-111), _(-2032), _(-2663), _(-9389), _(-24694), _(-72835), _(50137), _(-1082), _(7597), _(-1535), _( 919), _(-227), _( 53), _( 2) },
+    { _(-16), _(-176), _(-153), _(-2057), _(-3004), _(-9139), _(-26482), _(-73415), _(48390), _(-2037), _(7271), _(-1644), _( 848), _(-228), _( 49), _( 1) },
+    { _(-17), _(-183), _(-197), _(-2075), _(-3351), _(-8840), _(-28289), _(-73908), _(46617), _(-2935), _(6935), _(-1739), _( 779), _(-228), _( 45), _( 1) },
+    { _(-19), _(-190), _(-244), _(-2085), _(-3705), _(-8492), _(-30112), _(-74313), _(44821), _(-3776), _(6589), _(-1822), _( 711), _(-227), _( 41), _( 1) },
+    { _(-21), _(-196), _(-294), _(-2087), _(-4063), _(-8092), _(-31947), _(-74630), _(43006), _(-4561), _(6237), _(-1893), _( 645), _(-225), _( 38), _( 1) },
+    { _(-24), _(-202), _(-347), _(-2080), _(-4425), _(-7640), _(-33791), _(-74856), _(41176), _(-5288), _(5879), _(-1952), _( 581), _(-222), _( 35), _( 1) },
+    { _(-26), _(-208), _(-401), _(-2063), _(-4788), _(-7134), _(-35640), _(-74992), _(39336), _(-5959), _(5517), _(-2000), _( 519), _(-218), _( 31), _( 1) }
+};
+
+#undef  _
+
+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
+    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 = 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;
+    B01 = A01 + A14;
+    B02 = A02 + A13;
+    B03 = A03 + A12;
+    B04 = A04 + A11;
+    B05 = A05 + A10;
+    B06 = A06 + A09;
+    B07 = A07 + A08;;
+    B08 = MPC_SCALE_CONST((A00 - A15) , 0.5024192929f , 31);
+    B09 = MPC_SCALE_CONST((A01 - A14) , 0.5224986076f , 31);
+    B10 = MPC_SCALE_CONST((A02 - A13) , 0.5669440627f , 31);
+    B11 = MPC_SCALE_CONST((A03 - A12) , 0.6468217969f , 31);
+    B12 = MPC_SCALE_CONST((A04 - A11) , 0.7881546021f , 31);
+    B13 = MPC_SCALE_CONST((A05 - A10) , 1.0606776476f , 30);
+    B14 = MPC_SCALE_CONST((A06 - A09) , 1.7224471569f , 30);
+    B15 = MPC_SCALE_CONST((A07 - A08) , 5.1011486053f , 28);
+
+    A00 =  B00 + B07;
+    A01 =  B01 + B06;
+    A02 =  B02 + B05;
+    A03 =  B03 + B04;
+    A04 = MPC_SCALE_CONST((B00 - B07) , 0.5097956061f , 31);
+    A05 = MPC_SCALE_CONST((B01 - B06) , 0.6013448834f , 31);
+    A06 = MPC_SCALE_CONST((B02 - B05) , 0.8999761939f , 31);
+    A07 = MPC_SCALE_CONST((B03 - B04) , 2.5629155636f , 29);
+    A08 =  B08 + B15;
+    A09 =  B09 + B14;
+    A10 =  B10 + B13;
+    A11 =  B11 + B12;
+    A12 = MPC_SCALE_CONST((B08 - B15) , 0.5097956061f , 31);
+    A13 = MPC_SCALE_CONST((B09 - B14) , 0.6013448834f , 31);
+    A14 = MPC_SCALE_CONST((B10 - B13) , 0.8999761939f , 31);
+    A15 = MPC_SCALE_CONST((B11 - B12) , 2.5629155636f , 29);
+
+    B00 =  A00 + A03;
+    B01 =  A01 + A02;
+    B02 = MPC_MULTIPLY_FRACT_CONST_FIX((A00 - A03) , 0.5411961079f , 1);
+    B03 = MPC_MULTIPLY_FRACT_CONST_FIX((A01 - A02) , 1.3065630198f , 2);
+    B04 =  A04 + A07;
+    B05 =  A05 + A06;
+    B06 = MPC_MULTIPLY_FRACT_CONST_FIX((A04 - A07) , 0.5411961079f , 1);
+    B07 = MPC_MULTIPLY_FRACT_CONST_FIX((A05 - A06) , 1.3065630198f , 2);
+    B08 =  A08 + A11;
+    B09 =  A09 + A10;
+    B10 = MPC_MULTIPLY_FRACT_CONST_FIX((A08 - A11) , 0.5411961079f , 1);
+    B11 = MPC_MULTIPLY_FRACT_CONST_FIX((A09 - A10) , 1.3065630198f , 2);
+    B12 =  A12 + A15;
+    B13 =  A13 + A14;
+    B14 = MPC_MULTIPLY_FRACT_CONST_FIX((A12 - A15) , 0.5411961079f , 1);
+    B15 = MPC_MULTIPLY_FRACT_CONST_FIX((A13 - A14) , 1.3065630198f , 2);
+
+    A00 =  B00 + B01;
+    A01 = MPC_MULTIPLY_FRACT_CONST_FIX((B00 - B01) , 0.7071067691f , 1);
+    A02 =  B02 + B03;
+    A03 = MPC_MULTIPLY_FRACT_CONST_FIX((B02 - B03) , 0.7071067691f , 1);
+    A04 =  B04 + B05;
+    A05 = MPC_MULTIPLY_FRACT_CONST_FIX((B04 - B05) , 0.7071067691f , 1);
+    A06 =  B06 + B07;
+    A07 = MPC_MULTIPLY_FRACT_CONST_FIX((B06 - B07) , 0.7071067691f , 1);
+    A08 =  B08 + B09;
+    A09 = MPC_MULTIPLY_FRACT_CONST_FIX((B08 - B09) , 0.7071067691f , 1);
+    A10 =  B10 + B11;
+    A11 = MPC_MULTIPLY_FRACT_CONST_FIX((B10 - B11) , 0.7071067691f , 1);
+    A12 =  B12 + B13;
+    A13 = MPC_MULTIPLY_FRACT_CONST_FIX((B12 - B13) , 0.7071067691f , 1);
+    A14 =  B14 + B15;
+    A15 = MPC_MULTIPLY_FRACT_CONST_FIX((B14 - B15) , 0.7071067691f , 1);
+
+    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((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         ((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         ((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;
+    B01 =  A01 + A14;
+    B02 =  A02 + A13;
+    B03 =  A03 + A12;
+    B04 =  A04 + A11;
+    B05 =  A05 + A10;
+    B06 =  A06 + A09;
+    B07 =  A07 + A08;
+    B08 = MPC_SCALE_CONST((A00 - A15) , 0.5024192929f , 31);
+    B09 = MPC_SCALE_CONST((A01 - A14) , 0.5224986076f , 31);
+    B10 = MPC_SCALE_CONST((A02 - A13) , 0.5669440627f , 31);
+    B11 = MPC_SCALE_CONST((A03 - A12) , 0.6468217969f , 31);
+    B12 = MPC_SCALE_CONST((A04 - A11) , 0.7881546021f , 31);
+    B13 = MPC_SCALE_CONST((A05 - A10) , 1.0606776476f , 30);
+    B14 = MPC_SCALE_CONST((A06 - A09) , 1.7224471569f , 30);
+    B15 = MPC_SCALE_CONST((A07 - A08) , 5.1011486053f , 28);
+
+    A00 =  B00 + B07;
+    A01 =  B01 + B06;
+    A02 =  B02 + B05;
+    A03 =  B03 + B04;
+    A04 = MPC_SCALE_CONST((B00 - B07) , 0.5097956061f , 31);
+    A05 = MPC_SCALE_CONST((B01 - B06) , 0.6013448834f , 31);
+    A06 = MPC_SCALE_CONST((B02 - B05) , 0.8999761939f , 31);
+    A07 = MPC_SCALE_CONST((B03 - B04) , 2.5629155636f , 29);
+    A08 =  B08 + B15;
+    A09 =  B09 + B14;
+    A10 =  B10 + B13;
+    A11 =  B11 + B12;
+    A12 = MPC_SCALE_CONST((B08 - B15) , 0.5097956061f , 31);
+    A13 = MPC_SCALE_CONST((B09 - B14) , 0.6013448834f , 31);
+    A14 = MPC_SCALE_CONST((B10 - B13) , 0.8999761939f , 31);
+    A15 = MPC_SCALE_CONST((B11 - B12) , 2.5629155636f , 29);
+
+    B00 =  A00 + A03;
+    B01 =  A01 + A02;
+    B02 = MPC_SCALE_CONST((A00 - A03) , 0.5411961079f , 31);
+    B03 = MPC_SCALE_CONST((A01 - A02) , 1.3065630198f , 30);
+    B04 =  A04 + A07;
+    B05 =  A05 + A06;
+    B06 = MPC_SCALE_CONST((A04 - A07) , 0.5411961079f , 31);
+    B07 = MPC_SCALE_CONST((A05 - A06) , 1.3065630198f , 30);
+    B08 =  A08 + A11;
+    B09 =  A09 + A10;
+    B10 = MPC_SCALE_CONST((A08 - A11) , 0.5411961079f , 31);
+    B11 = MPC_SCALE_CONST((A09 - A10) , 1.3065630198f , 30);
+    B12 =  A12 + A15;
+    B13 =  A13 + A14;
+    B14 = MPC_SCALE_CONST((A12 - A15) , 0.5411961079f , 31);
+    B15 = MPC_SCALE_CONST((A13 - A14) , 1.3065630198f , 30);
+
+    A00 = MPC_SHL(B00 + B01, MPC_FIXED_POINT_SYNTH_FIX);
+    A01 = MPC_SCALE_CONST_SHL((B00 - B01) , 0.7071067691f , 31, MPC_FIXED_POINT_SYNTH_FIX);
+    A02 = MPC_SHL(B02 + B03, MPC_FIXED_POINT_SYNTH_FIX);
+    A03 = MPC_SCALE_CONST_SHL((B02 - B03) , 0.7071067691f , 31, MPC_FIXED_POINT_SYNTH_FIX);
+    A04 = MPC_SHL(B04 + B05, MPC_FIXED_POINT_SYNTH_FIX);
+    A05 = MPC_SCALE_CONST_SHL((B04 - B05) , 0.7071067691f , 31, MPC_FIXED_POINT_SYNTH_FIX);
+    A06 = MPC_SHL(B06 + B07, MPC_FIXED_POINT_SYNTH_FIX);
+    A07 = MPC_SCALE_CONST_SHL((B06 - B07) , 0.7071067691f , 31, MPC_FIXED_POINT_SYNTH_FIX);
+    A08 = MPC_SHL(B08 + B09, MPC_FIXED_POINT_SYNTH_FIX);
+    A09 = MPC_SCALE_CONST_SHL((B08 - B09) , 0.7071067691f , 31, MPC_FIXED_POINT_SYNTH_FIX);
+    A10 = MPC_SHL(B10 + B11, MPC_FIXED_POINT_SYNTH_FIX);
+    A11 = MPC_SCALE_CONST_SHL((B10 - B11) , 0.7071067691f , 31, MPC_FIXED_POINT_SYNTH_FIX);
+    A12 = MPC_SHL(B12 + B13, MPC_FIXED_POINT_SYNTH_FIX);
+    A13 = MPC_SCALE_CONST_SHL((B12 - B13) , 0.7071067691f , 31, MPC_FIXED_POINT_SYNTH_FIX);
+    A14 = MPC_SHL(B14 + B15, MPC_FIXED_POINT_SYNTH_FIX);
+    A15 = MPC_SCALE_CONST_SHL((B14 - B15) , 0.7071067691f , 31, MPC_FIXED_POINT_SYNTH_FIX);
+
+    // mehrfach verwendete Ausdrücke: A04+A06+A07, A09+A13+A15
+    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 
+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++, 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++ )
+        {
+            *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* p_dec, MPC_SAMPLE_FORMAT* p_out) 
+{
+    /********* left channel ********/
+    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(&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]);
+}
+
+/*******************************************/
+/*                                         */
+/*            dithered synthesis           */
+/*                                         */
+/*******************************************/
+
+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,
+    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,
+    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,
+    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,
+    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
+};
+
+/*
+ *  This is a simple random number generator with good quality for audio purposes.
+ *  It consists of two polycounters with opposite rotation direction and different
+ *  periods. The periods are coprime, so the total period is the product of both.
+ *
+ *     -------------------------------------------------------------------------------------------------
+ * +-> |31:30:29:28:27:26:25:24:23:22:21:20:19:18:17:16:15:14:13:12:11:10: 9: 8: 7: 6: 5: 4: 3: 2: 1: 0|
+ * |   -------------------------------------------------------------------------------------------------
+ * |                                                                          |  |  |  |     |        |
+ * |                                                                          +--+--+--+-XOR-+--------+
+ * |                                                                                      |
+ * +--------------------------------------------------------------------------------------+
+ *
+ *     -------------------------------------------------------------------------------------------------
+ *     |31:30:29:28:27:26:25:24:23:22:21:20:19:18:17:16:15:14:13:12:11:10: 9: 8: 7: 6: 5: 4: 3: 2: 1: 0| <-+
+ *     -------------------------------------------------------------------------------------------------   |
+ *       |  |           |  |                                                                               |
+ *       +--+----XOR----+--+                                                                               |
+ *                |                                                                                        |
+ *                +----------------------------------------------------------------------------------------+
+ *
+ *
+ *  The first has an period of 3*5*17*257*65537, the second of 7*47*73*178481,
+ *  which gives a period of 18.410.713.077.675.721.215. The result is the
+ *  XORed values of both generators.
+ */
+mpc_uint32_t
+mpc_random_int(mpc_decoder* p_dec) 
+{
+#if 1
+    mpc_uint32_t  t1, t2, t3, t4;
+
+    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 (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: libmpc/branches/r2d/libmpcdec/win32/libmpcdec.sln
===================================================================
--- libmpc/branches/r2d/libmpcdec/win32/libmpcdec.sln	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/win32/libmpcdec.sln	(revision 130)
@@ -0,0 +1,36 @@
+﻿
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmpcdec", "libmpcdec.vcproj", "{4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}"
+EndProject
+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}"
+	ProjectSection(ProjectDependencies) = postProject
+		{13D176A2-B6BB-403F-A816-AA1F388078B7} = {13D176A2-B6BB-403F-A816-AA1F388078B7}
+		{4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3} = {4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}
+	EndProjectSection
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Win32 = Debug|Win32
+		Release|Win32 = Release|Win32
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}.Debug|Win32.ActiveCfg = Debug|Win32
+		{4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}.Debug|Win32.Build.0 = Debug|Win32
+		{4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}.Release|Win32.ActiveCfg = Release|Win32
+		{4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}.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
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal
Index: libmpc/branches/r2d/libmpcdec/win32/libmpcdec.vcproj
===================================================================
--- libmpc/branches/r2d/libmpcdec/win32/libmpcdec.vcproj	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/win32/libmpcdec.vcproj	(revision 130)
@@ -0,0 +1,226 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8,00"
+	Name="libmpcdec"
+	ProjectGUID="{4C5362CD-0BF2-4B3B-971B-8293EB1A1DC3}"
+	RootNamespace="libmpcdec"
+	>
+	<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"
+				AdditionalIncludeDirectories="../include"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
+				ExceptionHandling="0"
+				BasicRuntimeChecks="3"
+				SmallerTypeCheck="true"
+				RuntimeLibrary="1"
+				BrowseInformation="1"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="1"
+				CompileAs="1"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+				OutputFile="$(OutDir)\$(ProjectName)_d.lib"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+				CommandLine="copy $(TargetPath) ..\bin\."
+			/>
+		</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"
+				AdditionalIncludeDirectories="../include"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
+				StringPooling="true"
+				ExceptionHandling="0"
+				BufferSecurityCheck="false"
+				EnableFunctionLevelLinking="true"
+				WarningLevel="3"
+				CompileAs="1"
+			/>
+			<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"
+				CommandLine="copy $(TargetPath) ..\bin\."
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			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="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>
+			<File
+				RelativePath="..\include\mpcdec\mpcdec.h"
+				>
+			</File>
+			<File
+				RelativePath="..\include\mpcdec\reader.h"
+				>
+			</File>
+			<File
+				RelativePath="..\include\mpcdec\streaminfo.h"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: libmpc/branches/r2d/libmpcdec/win32/libwavformat.vcproj
===================================================================
--- libmpc/branches/r2d/libmpcdec/win32/libwavformat.vcproj	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/win32/libwavformat.vcproj	(revision 130)
@@ -0,0 +1,175 @@
+<?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"
+				ExceptionHandling="0"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				UsePrecompiledHeader="0"
+				BrowseInformation="1"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="1"
+				CompileAs="1"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+				OutputFile="$(OutDir)\$(ProjectName)_d.lib"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+				CommandLine="copy $(TargetPath) ..\bin\."
+			/>
+		</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"
+				ExceptionHandling="0"
+				RuntimeLibrary="0"
+				BufferSecurityCheck="false"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="0"
+				CompileAs="1"
+			/>
+			<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"
+				CommandLine="copy $(TargetPath) ..\bin\."
+			/>
+		</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: libmpc/branches/r2d/libmpcdec/win32/mpcdec.vcproj
===================================================================
--- libmpc/branches/r2d/libmpcdec/win32/mpcdec.vcproj	(revision 130)
+++ libmpc/branches/r2d/libmpcdec/win32/mpcdec.vcproj	(revision 130)
@@ -0,0 +1,198 @@
+<?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;_CRT_SECURE_NO_DEPRECATE"
+				ExceptionHandling="0"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="1"
+				CompileAs="1"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="libmpcdec_d.lib libwavformat_d.lib"
+				OutputFile="$(OutDir)\$(ProjectName)_d.exe"
+				AdditionalLibraryDirectories="../bin"
+				GenerateManifest="false"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				TargetMachine="1"
+				AllowIsolation="false"
+			/>
+			<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"
+				CommandLine="copy $(TargetPath) ..\bin\."
+			/>
+		</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,../libwavformat"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
+				ExceptionHandling="0"
+				BufferSecurityCheck="false"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="0"
+				CompileAs="1"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="libmpcdec.lib libwavformat.lib"
+				AdditionalLibraryDirectories="../bin"
+				GenerateManifest="false"
+				SubSystem="1"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"
+				AllowIsolation="false"
+			/>
+			<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"
+				CommandLine="copy $(TargetPath) ..\bin\."
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Sources"
+			>
+			<File
+				RelativePath="..\mpcdec\mpcdec.c"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
