Index: /libmpc/branches/r2d/include/mpc/mpc_types.h
===================================================================
--- /libmpc/branches/r2d/include/mpc/mpc_types.h	(revision 194)
+++ /libmpc/branches/r2d/include/mpc/mpc_types.h	(revision 195)
@@ -70,6 +70,9 @@
 typedef int mpc_int_t;
 typedef unsigned int mpc_uint_t;
-// FIXME : must be the same size as a pointer
 typedef size_t mpc_size_t;
+typedef mpc_uint8_t mpc_bool_t;
+
+# define mpc_int64_min -9223372036854775808ll
+# define mpc_int64_max 9223372036854775807ll
 
 /// Libmpcdec error codes
@@ -90,6 +93,4 @@
 #endif
 
-typedef mpc_uint8_t mpc_bool_t;
-
 enum {
     MPC_FALSE = 0,
@@ -97,4 +98,15 @@
 };
 
+//// 'Cdecl' forces the use of standard C/C++ calling convention ///////
+#if   defined _WIN32
+# define mpc_cdecl           __cdecl
+#elif defined __ZTC__
+# define mpc_cdecl           _cdecl
+#elif defined __TURBOC__
+# define mpc_cdecl           cdecl
+#else
+# define mpc_cdecl
+#endif
+
 #ifdef __cplusplus
 }
Index: /libmpc/branches/r2d/include/mpc/mpcdec.h
===================================================================
--- /libmpc/branches/r2d/include/mpc/mpcdec.h	(revision 195)
+++ /libmpc/branches/r2d/include/mpc/mpcdec.h	(revision 195)
@@ -0,0 +1,116 @@
+/*
+  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 (counting once for multiple channels)
+	mpc_int32_t bits;	/// number of bits consumed by this frame (-1) if end of stream
+	MPC_SAMPLE_FORMAT * buffer;	/// frame samples buffer (size = samples * channels * sizeof(MPC_SAMPLE_FORMAT))
+	mpc_bool_t is_key_frame; /// 1 if this frame is a key frame (first in block) 0 else. Set by the demuxer.
+} 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);
+
+/**
+ * set the scf indexes for seeking use
+ * needed only for sv7 seeking
+ * @param d
+ */
+void mpc_decoder_reset_scf(mpc_decoder * d);
+
+/// 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);
+
+// 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);
+// seek
+mpc_status mpc_demux_seek_sample(mpc_demux * d, mpc_uint64_t destsample);
+mpc_status mpc_demux_seek_second(mpc_demux * d, double seconds);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
Index: /libmpc/branches/r2d/include/mpc/reader.h
===================================================================
--- /libmpc/branches/r2d/include/mpc/reader.h	(revision 195)
+++ /libmpc/branches/r2d/include/mpc/reader.h	(revision 195)
@@ -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/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/include/mpc/streaminfo.h
===================================================================
--- /libmpc/branches/r2d/include/mpc/streaminfo.h	(revision 195)
+++ /libmpc/branches/r2d/include/mpc/streaminfo.h	(revision 195)
@@ -0,0 +1,109 @@
+/*
+  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/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_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         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         block_pwr;          ///< Number of frames in a block = 2^block_pwr (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_uint64_t         samples;            ///< Number of samples in the stream
+    //@}
+
+	/// @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 header_position;    ///< Byte offset of position of header in 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/decoder.h
===================================================================
--- /libmpc/branches/r2d/libmpcdec/decoder.h	(revision 194)
+++ /libmpc/branches/r2d/libmpcdec/decoder.h	(revision 195)
@@ -39,5 +39,5 @@
 #endif
 
-#include <mpcdec/reader.h>
+#include <mpc/reader.h>
 
 #ifdef __cplusplus
Index: /libmpc/branches/r2d/libmpcdec/internal.h
===================================================================
--- /libmpc/branches/r2d/libmpcdec/internal.h	(revision 194)
+++ /libmpc/branches/r2d/libmpcdec/internal.h	(revision 195)
@@ -43,5 +43,5 @@
 #endif
 
-#include <mpcdec/mpcdec.h>
+#include <mpc/mpcdec.h>
 
 /// Big/little endian 32 bit byte swapping routine.
Index: /libmpc/branches/r2d/libmpcdec/math.h
===================================================================
--- /libmpc/branches/r2d/libmpcdec/math.h	(revision 194)
+++ /libmpc/branches/r2d/libmpcdec/math.h	(revision 195)
@@ -75,5 +75,5 @@
 
 #ifdef _DEBUG
-static inline MPC_SAMPLE_FORMAT MPC_MULTIPLY(MPC_SAMPLE_FORMAT item1,MPC_SAMPLE_FORMAT item2)
+static mpc_inline MPC_SAMPLE_FORMAT MPC_MULTIPLY(MPC_SAMPLE_FORMAT item1,MPC_SAMPLE_FORMAT item2)
 {
     MPC_SAMPLE_FORMAT_MULTIPLY temp = MPC_MULTIPLY_NOTRUNCATE(item1,item2);
@@ -82,5 +82,5 @@
 }
 
-static inline MPC_SAMPLE_FORMAT MPC_MULTIPLY_EX(MPC_SAMPLE_FORMAT item1,MPC_SAMPLE_FORMAT item2,unsigned shift)
+static mpc_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);
Index: /libmpc/branches/r2d/libmpcdec/mpc_bits_reader.c
===================================================================
--- /libmpc/branches/r2d/libmpcdec/mpc_bits_reader.c	(revision 194)
+++ /libmpc/branches/r2d/libmpcdec/mpc_bits_reader.c	(revision 195)
@@ -33,5 +33,5 @@
 */
 
-#include <mpcdec/mpcdec.h>
+#include <mpc/mpcdec.h>
 #include "internal.h"
 #include "huffman.h"
Index: /libmpc/branches/r2d/libmpcdec/mpc_decoder.c
===================================================================
--- /libmpc/branches/r2d/libmpcdec/mpc_decoder.c	(revision 194)
+++ /libmpc/branches/r2d/libmpcdec/mpc_decoder.c	(revision 195)
@@ -35,5 +35,5 @@
 /// Core decoding routines and logic.
 #include <string.h>
-#include <mpcdec/mpcdec.h>
+#include <mpc/mpcdec.h>
 #include <mpc/minimax.h>
 #include "decoder.h"
Index: /libmpc/branches/r2d/libmpcdec/mpc_demux.c
===================================================================
--- /libmpc/branches/r2d/libmpcdec/mpc_demux.c	(revision 194)
+++ /libmpc/branches/r2d/libmpcdec/mpc_demux.c	(revision 195)
@@ -34,6 +34,6 @@
 
 #include <string.h>
-#include <mpcdec/streaminfo.h>
-#include <mpcdec/mpcdec.h>
+#include <mpc/streaminfo.h>
+#include <mpc/mpcdec.h>
 #include "internal.h"
 #include "decoder.h"
Index: /libmpc/branches/r2d/libmpcdec/mpc_reader.c
===================================================================
--- /libmpc/branches/r2d/libmpcdec/mpc_reader.c	(revision 194)
+++ /libmpc/branches/r2d/libmpcdec/mpc_reader.c	(revision 195)
@@ -34,5 +34,5 @@
 /// \file mpc_reader.c
 /// Contains implementations for simple file-based mpc_reader
-#include <mpcdec/reader.h>
+#include <mpc/reader.h>
 #include "internal.h"
 #include <stdio.h>
Index: /libmpc/branches/r2d/libmpcdec/requant.c
===================================================================
--- /libmpc/branches/r2d/libmpcdec/requant.c	(revision 194)
+++ /libmpc/branches/r2d/libmpcdec/requant.c	(revision 195)
@@ -35,5 +35,5 @@
 /// Requantization function implementations.
 /// \todo document me
-#include <mpcdec/mpcdec.h>
+#include <mpc/mpcdec.h>
 
 #include "requant.h"
Index: /libmpc/branches/r2d/libmpcdec/streaminfo.c
===================================================================
--- /libmpc/branches/r2d/libmpcdec/streaminfo.c	(revision 194)
+++ /libmpc/branches/r2d/libmpcdec/streaminfo.c	(revision 195)
@@ -35,6 +35,6 @@
 /// Implementation of streaminfo reading functions.
 
-#include <mpcdec/mpcdec.h>
-#include <mpcdec/streaminfo.h>
+#include <mpc/mpcdec.h>
+#include <mpc/streaminfo.h>
 #include <stdio.h>
 #include "internal.h"
Index: /libmpc/branches/r2d/libmpcdec/synth_filter.c
===================================================================
--- /libmpc/branches/r2d/libmpcdec/synth_filter.c	(revision 194)
+++ /libmpc/branches/r2d/libmpcdec/synth_filter.c	(revision 195)
@@ -36,5 +36,5 @@
 /// \todo document me
 #include <string.h>
-#include <mpcdec/mpcdec.h>
+#include <mpc/mpcdec.h>
 #include "decoder.h"
 #include "math.h"
@@ -283,5 +283,5 @@
     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
+    // mehrfach verwendete Ausdrcke: 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;
@@ -289,9 +289,9 @@
     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[39] = tmp - A02 - A03;                      // abhï¿œgig vom Befehl drber
+    pV[41] = (tmp += A13 - A12) - A02 - A03;       // abhï¿œgig vom Befehl 2 drber
+    pV[43] = tmp - A04 - A06 - A07;                // abhï¿œgig von Befehlen 1 und 3 drber
     pV[47] = (tmp = -(A08 + A12 + A14 + A15)) - A00;
-    pV[45] = tmp - A04 - A06 - A07;                // abhängig vom Befehl drüber
+    pV[45] = tmp - A04 - A06 - A07;                // abhï¿œgig vom Befehl drber
 
     pV[32] = -pV[ 0];
@@ -329,5 +329,5 @@
 }
 
-static void 
+static void
 mpc_synthese_filter_float_internal(MPC_SAMPLE_FORMAT* p_out, MPC_SAMPLE_FORMAT* pV, const MPC_SAMPLE_FORMAT* pY)
 {
@@ -356,5 +356,5 @@
 
 void
-mpc_decoder_synthese_filter_float(mpc_decoder* p_dec, MPC_SAMPLE_FORMAT* p_out) 
+mpc_decoder_synthese_filter_float(mpc_decoder* p_dec, MPC_SAMPLE_FORMAT* p_out)
 {
     /********* left channel ********/
@@ -411,5 +411,5 @@
  */
 mpc_uint32_t
-mpc_random_int(mpc_decoder* p_dec) 
+mpc_random_int(mpc_decoder* p_dec)
 {
 #if 1
Index: /libmpc/branches/r2d/libmpcpsy/ans.c
===================================================================
--- /libmpc/branches/r2d/libmpcpsy/ans.c	(revision 194)
+++ /libmpc/branches/r2d/libmpcpsy/ans.c	(revision 195)
@@ -62,5 +62,5 @@
 
 // calculates optimal reflection coefficients and time response of a prediction filter in LPC analysis
-static __inline void
+static mpc_inline void
 durbin_akf_to_kh1( float*        k,     // out: reflection coefficients
                    float*        h,     // out: time response
@@ -70,5 +70,5 @@
 }
 
-static __inline void
+static mpc_inline void
 durbin_akf_to_kh2( float*        k,     // out: reflection coefficients
                    float*        h,     // out: time response
@@ -83,5 +83,5 @@
 }
 
-static __inline void
+static mpc_inline void
 durbin_akf_to_kh3( float*        k,     // out: reflection coefficients
                    float*        h,     // out: time response
@@ -104,5 +104,5 @@
 
 
-static __inline void
+static mpc_inline void
 durbin_akf_to_kh ( float*        k,     // out: reflection coefficients
                    float*        h,     // out: time response
Index: /libmpc/branches/r2d/libmpcpsy/cvd.c
===================================================================
--- /libmpc/branches/r2d/libmpcpsy/cvd.c	(revision 194)
+++ /libmpc/branches/r2d/libmpcpsy/cvd.c	(revision 195)
@@ -222,5 +222,5 @@
 #else
 
-static __inline float   /* This is a rough estimation with an accuracy of |x|<0.0037 */
+static mpc_inline float   /* This is a rough estimation with an accuracy of |x|<0.0037 */
 logfast ( float x )
 {
Index: /libmpc/branches/r2d/libmpcpsy/fft4g.c
===================================================================
--- /libmpc/branches/r2d/libmpcpsy/fft4g.c	(revision 194)
+++ /libmpc/branches/r2d/libmpcpsy/fft4g.c	(revision 195)
@@ -26,10 +26,10 @@
 static          void  makewt       ( const int nw, int* ip, float* w );
 static          void  makect       ( const int nc, int* ip, float* c );
-static __inline void  bitrv2       ( const int n, int* ip, float* a );                   //
-static __inline void  cftfsub      ( const int n, float* a, float* w );                  //
-static __inline void  rftfsub      ( const int n, float* a, int nc, float* c );          //
-static __inline void  cft1st       ( const int n, float* a, float* w );                  //
-static __inline void  cftmdl_i386  ( const int n, const int l, float* a, float* w );     // 5648
-// static __inline void  cftmdl_3DNow ( const int n, const int l, float* a, float* w );     // 4954
+static mpc_inline void  bitrv2       ( const int n, int* ip, float* a );                   //
+static mpc_inline void  cftfsub      ( const int n, float* a, float* w );                  //
+static mpc_inline void  rftfsub      ( const int n, float* a, int nc, float* c );          //
+static mpc_inline void  cft1st       ( const int n, float* a, float* w );                  //
+static mpc_inline void  cftmdl_i386  ( const int n, const int l, float* a, float* w );     // 5648
+// static mpc_inline void  cftmdl_3DNow ( const int n, const int l, float* a, float* w );     // 4954
 
 #if 0
@@ -396,6 +396,6 @@
 }
 
-// extern void Cdecl cftmdl_3DNow_1 ( const int n, const int l, float* a, float* w );
-// extern void Cdecl cftmdl_3DNow_2 ( const int n, const int l, float* a, float* w );
+// extern void mpc_cdecl cftmdl_3DNow_1 ( const int n, const int l, float* a, float* w );
+// extern void mpc_cdecl cftmdl_3DNow_2 ( const int n, const int l, float* a, float* w );
 
 
Index: /libmpc/branches/r2d/mpcdec/mpcdec.c
===================================================================
--- /libmpc/branches/r2d/mpcdec/mpcdec.c	(revision 194)
+++ /libmpc/branches/r2d/mpcdec/mpcdec.c	(revision 195)
@@ -35,5 +35,5 @@
 #include <assert.h>
 #include <time.h>
-#include <mpcdec/mpcdec.h>
+#include <mpc/mpcdec.h>
 #include <libwaveformat.h>
 
Index: /libmpc/branches/r2d/mpcenc/mpcenc.c
===================================================================
--- /libmpc/branches/r2d/mpcenc/mpcenc.c	(revision 194)
+++ /libmpc/branches/r2d/mpcenc/mpcenc.c	(revision 195)
@@ -36,6 +36,6 @@
 int           APE_Version     = 2000;
 int           LowDelay        = 0;
-Bool_t        EnableTags      = MPC_FALSE;
-Bool_t        IsEndBeep       = MPC_FALSE;
+mpc_bool_t    EnableTags      = MPC_FALSE;
+mpc_bool_t    IsEndBeep       = MPC_FALSE;
 
 #define MODE_OVERWRITE          0
@@ -48,5 +48,5 @@
 unsigned int  verbose         = 0;      // more information during output
 unsigned int  NoUnicode       = 1;      // console is unicode or not (tag translation)
-UintMax_t     SamplesInWAVE   = 0;      // number of samples per channel in the WAV file
+mpc_uint64_t    SamplesInWAVE   = 0;      // number of samples per channel in the WAV file
 float         MaxOverFlow     = 0.f;    // maximum overflow
 float         ScalingFactorl  = 1.f;    // Scaling the input signal
@@ -57,6 +57,6 @@
 float         SkipTime        = 0.f;    // Skip the beginning of the file (sec)
 double        Duration        = 1.e+99; // Maximum encoded audio length
-Bool_t        FrontendPresent = 0;      // Flag for frontend-detection
-Bool_t        XLevel          = 1;      // Encode extreme levels with relative SCFs
+mpc_bool_t    FrontendPresent = 0;      // Flag for frontend-detection
+mpc_bool_t    XLevel          = 1;      // Encode extreme levels with relative SCFs
 
 #if MPPENC_MINOR % 2 == 0
@@ -115,5 +115,5 @@
 
     echo_off ();
-    ret = READ1 ( STDIN, buff );
+    ret = READ1 ( stdin, buff );
     echo_on ();
     return ret == 1  ?  buff[0]  :  -1;
@@ -430,5 +430,5 @@
     for ( n = 0; n < BLOCK; n++, N++ ) {
         idx           = n + CENTER;
-        fadeout_pos   = UintMAX_FP(SamplesInWAVE - N) * inv_fs;
+        fadeout_pos   = (long double)(SamplesInWAVE - N) * inv_fs;
         scale         = fadeout_pos / FadeOutTime;
         scale         = bump (scale);
@@ -1312,15 +1312,15 @@
 
 static const char*
-PrintTime ( PsyModel* m, UintMax_t samples, int sign )
+PrintTime ( PsyModel* m, mpc_uint64_t samples, int sign )
 {
     static char  ret [32];
-	Ulong        tmp  = (Ulong) ( UintMAX_FP(samples) * 100. / m->SampleFreq );
-    Uint         hour = (Uint)  ( tmp / 360000     );
-    Uint         min  = (Uint)  ( tmp / 6000 %  60 );
-    Uint         sec  = (Uint)  ( tmp / 100  %  60 );
-    Uint         csec = (Uint)  ( tmp        % 100 );
-
-
-	if ( UintMAX_FP(samples) >= m->SampleFreq * 360000. )
+	mpc_uint32_t tmp  = (mpc_uint32_t) ( (long double)(samples) * 100. / m->SampleFreq );
+    mpc_uint_t   hour = (mpc_uint_t)  ( tmp / 360000     );
+    mpc_uint_t   min  = (mpc_uint_t)  ( tmp / 6000 %  60 );
+    mpc_uint_t   sec  = (mpc_uint_t)  ( tmp / 100  %  60 );
+    mpc_uint_t   csec = (mpc_uint_t)  ( tmp        % 100 );
+
+
+	if ( (long double)(samples) >= m->SampleFreq * 360000. )
         return "            ";
     else if ( hour > 9 )
@@ -1340,7 +1340,7 @@
 static void
 ShowProgress ( PsyModel* m,
-			   UintMax_t  samples,
-               UintMax_t  total_samples,
-               UintMax_t  databits )
+			   mpc_uint64_t  samples,
+               mpc_uint64_t  total_samples,
+               mpc_uint64_t  databits )
 {
     static clock_t  start;
@@ -1363,11 +1363,11 @@
         return;
 
-    percent     = 100.f    * UintMAX_FP(samples) / UintMAX_FP(total_samples);
-	kbps        =   1.e-3f * UintMAX_FP(databits) * m->SampleFreq / UintMAX_FP(samples);
-	speed       =   1.f    * UintMAX_FP(samples) * (CLOCKS_PER_SEC / m->SampleFreq) / (unsigned long)(curr - start) ;
-    total_estim =   1.f    * UintMAX_FP(total_samples) / UintMAX_FP(samples) * (unsigned long)(curr - start);
+    percent     = 100.f    * (long double)(samples) / (long double)(total_samples);
+	kbps        =   1.e-3f * (long double)(databits) * m->SampleFreq / (long double)(samples);
+	speed       =   1.f    * (long double)(samples) * (CLOCKS_PER_SEC / m->SampleFreq) / (unsigned long)(curr - start) ;
+    total_estim =   1.f    * (long double)(total_samples) / (long double)(samples) * (unsigned long)(curr - start);
 
     // progress percent
-    if ( total_samples < IntMax_MAX )
+	if ( total_samples < mpc_int64_max )
         stderr_printf ("\r%5.1f ", percent );
     else
@@ -1521,5 +1521,5 @@
     SubbandQuantTyp  Q [32];                    // Subband samples after quantization
     wave_t           Wave;                      // contains WAV-files arguments
-    UintMax_t        AllSamplesRead   =    0;   // overall read Samples per channel
+    mpc_uint64_t        AllSamplesRead   =    0;   // overall read Samples per channel
     unsigned int     CurrentRead      =    0;   // current read Samples per channel
     unsigned int     N;                         // counter for processed frames
@@ -1595,5 +1595,5 @@
         return 1;
 
-    if ( UintMAX_FP(SamplesInWAVE) >= Wave.SampleFreq * (SkipTime + Duration) ) {
+    if ( (long double)(SamplesInWAVE) >= Wave.SampleFreq * (SkipTime + Duration) ) {
         SamplesInWAVE = Wave.SampleFreq * (SkipTime + Duration);
     }
@@ -1602,7 +1602,7 @@
 
     // check fade-length
-    if ( FadeInTime + FadeOutTime > UintMAX_FP(SamplesInWAVE) / Wave.SampleFreq ) {
+    if ( FadeInTime + FadeOutTime > (long double)(SamplesInWAVE) / Wave.SampleFreq ) {
         stderr_printf ( "WARNING: Duration of fade in + out exceeds file length!\n");
-        FadeInTime = FadeOutTime = 0.5 * UintMAX_FP(SamplesInWAVE) / Wave.SampleFreq;
+        FadeInTime = FadeOutTime = 0.5 * (long double)(SamplesInWAVE) / Wave.SampleFreq;
     }
 
@@ -1662,9 +1662,9 @@
     if ( myfeof (Wave.fp) ) {
         stderr_printf ( "WAVE file has incorrect header: header: %.3f s, contents: %.3f s    \n",
-						UintMAX_FP(AllSamplesRead) / m.SampleFreq, UintMAX_FP(SamplesInWAVE) / m.SampleFreq );
+						(long double)(AllSamplesRead) / m.SampleFreq, (long double)(SamplesInWAVE) / m.SampleFreq );
         SamplesInWAVE = AllSamplesRead;
     }
 
-    for ( N = 0; (UintMax_t)N * BLOCK < SamplesInWAVE + DECODER_DELAY; N++ ) {
+    for ( N = 0; (mpc_uint64_t)N * BLOCK < SamplesInWAVE + DECODER_DELAY; N++ ) {
 
         // setting residual data-fields to zero
@@ -1680,8 +1680,8 @@
         /*********************************************************************************/
         if ( FadeInTime  > 0. )
-            if ( FadeInTime  > UintMAX_FP(BLOCK         + (UintMax_t)N*BLOCK) / Wave.SampleFreq )
+            if ( FadeInTime  > (long double)(BLOCK         + (mpc_uint64_t)N*BLOCK) / Wave.SampleFreq )
                 Fading_In  ( &Main, N*BLOCK, Wave.SampleFreq );
         if ( FadeOutTime > 0. )
-            if ( FadeOutTime > UintMAX_FP(SamplesInWAVE - (UintMax_t)N*BLOCK) / Wave.SampleFreq )
+            if ( FadeOutTime > (long double)(SamplesInWAVE - (mpc_uint64_t)N*BLOCK) / Wave.SampleFreq )
                 Fading_Out ( &Main, N*BLOCK, Wave.SampleFreq );
 
@@ -1716,7 +1716,7 @@
         writeBitstream_SV8 ( &e, m.Max_Band, Q );                                                // write SV7-Bitstream
 
-        if ( (Int)(time (NULL) - T) >= 0 ) {                            // output
+        if ( (int)(time (NULL) - T) >= 0 ) {                            // output
             T += labs (DisplayUpdateTime);
-			ShowProgress (&m, (UintMax_t)(N+1) * BLOCK, SamplesInWAVE, e.outputBits );
+			ShowProgress (&m, (mpc_uint64_t)(N+1) * BLOCK, SamplesInWAVE, e.outputBits );
         }
 
@@ -1733,5 +1733,5 @@
         if ( myfeof (Wave.fp) ) {
             stderr_printf ( "WAVE file has incorrect header: header: %.3f s, contents: %.3f s    \n",
-							UintMAX_FP(AllSamplesRead) / m.SampleFreq, UintMAX_FP(SamplesInWAVE) / m.SampleFreq );
+							(long double)(AllSamplesRead) / m.SampleFreq, (long double)(SamplesInWAVE) / m.SampleFreq );
             SamplesInWAVE = AllSamplesRead;
         }
@@ -1769,12 +1769,8 @@
 
 /************ The main() function *****************************/
-int Cdecl
+int mpc_cdecl
 main ( int argc, char** argv )
 {
     int  ret;
-
-#if (defined USE_OSS_AUDIO  ||  defined USE_ESD_AUDIO  ||  defined USE_SUN_AUDIO)  &&  (defined USE_REALTIME  ||  defined USE_NICE)
-    // DisableSUID ();
-#endif
 
 #ifdef _OS2
Index: /libmpc/branches/r2d/mpcenc/mpcenc.h
===================================================================
--- /libmpc/branches/r2d/mpcenc/mpcenc.h	(revision 194)
+++ /libmpc/branches/r2d/mpcenc/mpcenc.h	(revision 195)
@@ -18,6 +18,6 @@
  */
 
-#ifndef MPPENC_MPPENC_H
-#define MPPENC_MPPENC_H
+#ifndef MPCENC_MPCENC_H
+#define MPCENC_MPCENC_H
 
 #include "libmpcenc.h"
@@ -26,10 +26,173 @@
 #include <mpc/minimax.h>
 
-#include "mppdec.h"
-
-#define WIN32_MESSAGES      1                   // support Windows-Messaging to Frontend
-
-// analyse_filter.c
-#define X_MEM            1152
+//// optimization/feature defines //////////////////////////////////
+#ifndef NOT_INCLUDE_CONFIG_H
+# include "config.h"
+#endif
+
+//// portable system includes //////////////////////////////////////
+#include <stddef.h>
+#include <math.h>
+
+//// system dependent system includes //////////////////////////////
+// low level I/O, where are prototypes and constants?
+#if   defined _WIN32  ||  defined __TURBOC__  ||  defined __ZTC__  ||  defined _MSC_VER
+# include <io.h>
+#elif defined __unix__  ||  defined __linux__  ||  defined __APPLE__
+# include <unistd.h>
+#else
+// .... add Includes for new Operating System here (with prefix: #elif defined)
+# include <unistd.h>
+#endif
+
+#if   defined __linux__
+#  include <fpu_control.h>
+#elif defined __FreeBSD__
+# include <machine/floatingpoint.h>
+#elif defined _MSC_VER
+# include <float.h>
+#endif
+
+
+#if !defined(__APPLE__)
+// use optimized assembler routines for Pentium III/K6-2/Athlon (only 32 bit OS, Intel x86 and no MAKE_xxBITS)
+// you need the NASM assembler on your system, the program becomes a little bit larger and decoding
+// on AMD K6-2 (x3), AMD K6-III (x3), AMD Duron (x1.7), AMD Athlon (x1.7), Pentium III (x2) and Pentium 4 (x1.8) becomes faster
+#define USE_ASM
+
+#endif
+
+// Use termios for reading values from keyboard without echo and ENTER
+#define USE_TERMIOS
+
+// make debug output in tags.c stfu
+#define STFU
+
+#if INT_MAX < 2147483647L
+# undef USE_ASM
+#endif
+
+#ifndef O_BINARY
+# ifdef _O_BINARY
+#  define O_BINARY              _O_BINARY
+# else
+#  define O_BINARY              0
+# endif
+#endif
+
+#if defined _WIN32  ||  defined __TURBOC__
+# define strncasecmp(__s1,__s2,__n) strnicmp ((__s1), (__s2), (__n))
+# define strcasecmp(__s1,__s2)      stricmp  ((__s1), (__s2))
+#endif
+
+#if defined _WIN32
+# include <direct.h>
+# define snprintf                   _snprintf
+# define getcwd(__buff,__len)       _getcwd ((__buff), (__len))
+#endif
+
+//// Binary/Low-Level-IO ///////////////////////////////////////////
+//
+
+#if   defined __BORLANDC__  ||  defined _WIN32
+# define FILENO(__fp)          _fileno ((__fp))
+#elif defined __CYGWIN__  ||  defined __TURBOC__  ||  defined __unix__  ||  defined __EMX__  ||  defined _MSC_VER
+# define FILENO(__fp)          fileno  ((__fp))
+#else
+# define FILENO(__fp)          fileno  ((__fp))
+#endif
+
+
+//
+// If we have access to a file via file name, we can open the file with an
+// additional "b" or a O_BINARY within the (f)open function to get a
+// transparent untranslated data stream which is necessary for audio bitstream
+// data and also for PCM data. If we are working with
+// stdin/stdout/FILENO_STDIN/FILENO_STDOUT we can't open the file with these
+// attributes, because the files are already open. So we need a non
+// standardized sequence to switch to this mode (not necessary for Unix).
+// Mostly the sequence is the same for incoming and outgoing streams, but only
+// mostly so we need one for IN and one for OUT.
+// Macros are called with the file pointer and you get back the untransalted file
+// pointer which can be equal or different from the original.
+//
+
+#if   defined __EMX__
+# define SETBINARY_IN(__fp)     (_fsetmode ( (__fp), "b" ), (__fp))
+# define SETBINARY_OUT(__fp)    (_fsetmode ( (__fp), "b" ), (__fp))
+#elif defined __TURBOC__ || defined __BORLANDC__
+# define SETBINARY_IN(__fp)     (setmode   ( FILENO ((__fp)),  O_BINARY ), (__fp))
+# define SETBINARY_OUT(__fp)    (setmode   ( FILENO ((__fp)),  O_BINARY ), (__fp))
+#elif defined __CYGWIN__
+# define SETBINARY_IN(__fp)     (setmode   ( FILENO ((__fp)), _O_BINARY ), (__fp))
+# define SETBINARY_OUT(__fp)    (setmode   ( FILENO ((__fp)), _O_BINARY ), (__fp))
+#elif defined _WIN32
+# define SETBINARY_IN(__fp)     (_setmode  ( FILENO ((__fp)), _O_BINARY ), (__fp))
+# define SETBINARY_OUT(__fp)    (_setmode  ( FILENO ((__fp)), _O_BINARY ), (__fp))
+#elif defined _MSC_VER
+# define SETBINARY_IN(__fp)     (setmode   ( FILENO ((__fp)),  O_BINARY ), (__fp))
+# define SETBINARY_OUT(__fp)    (setmode   ( FILENO ((__fp)),  O_BINARY ), (__fp))
+#elif defined __unix__
+# define SETBINARY_IN(__fp)     (__fp)
+# define SETBINARY_OUT(__fp)    (__fp)
+#elif 0
+# define SETBINARY_IN(__fp)     (freopen   ( NULL, "rb", (__fp) ), (__fp))
+# define SETBINARY_OUT(__fp)    (freopen   ( NULL, "wb", (__fp) ), (__fp))
+#else
+# define SETBINARY_IN(__fp)     (__fp)
+# define SETBINARY_OUT(__fp)    (__fp)
+#endif
+
+// file I/O using ANSI buffered file I/O via file pointer FILE* (fopen, fread, fwrite, fclose)
+#define READ(fp,ptr,len)       fread  (ptr, 1, len, fp)     // READ    returns -1 or 0 on error/EOF, otherwise > 0
+#define READ1(fp,ptr)          fread  (ptr, 1, 1, fp)       // READ    returns -1 or 0 on error/EOF, otherwise > 0
+
+#ifdef _WIN32
+# define POPEN_READ_BINARY_OPEN(cmd)    _popen ((cmd), "rb")
+#else
+# define POPEN_READ_BINARY_OPEN(cmd)    popen ((cmd), "r")
+#endif
+
+// Path separator
+#if defined __unix__  ||  defined __bsdi__  ||  defined __FreeBSD__  ||  defined __OpenBSD__  ||  defined __NetBSD__  ||  defined __APPLE__
+# define PATH_SEP               '/'
+# define DRIVE_SEP              '\0'
+# define EXE_EXT                ""
+# define DEV_NULL               "/dev/null"
+# define ENVPATH_SEP            ':'
+#elif defined _WIN32  ||  defined __TURBOC__  ||  defined __ZTC__  ||  defined _MSC_VER
+# define PATH_SEP               '\\'
+# define DRIVE_SEP              ':'
+# define EXE_EXT                ".exe"
+# define DEV_NULL               "\\nul"
+# define ENVPATH_SEP            ';'
+#else
+# define PATH_SEP               '/'         // Amiga: C:/
+# define DRIVE_SEP              ':'
+# define EXE_EXT                ""
+# define DEV_NULL               "nul"
+# define ENVPATH_SEP            ';'
+#endif
+
+#ifdef _WIN32
+# define TitleBar(text)   SetConsoleTitle (text)
+#else
+# define TitleBar(text)   (void) (text)
+#endif
+
+
+//// constants /////////////////////////////////////////////////////
+#define DECODER_DELAY    (512 - 32 + 1)
+#define BLK_SIZE         (36 * 32)
+
+
+//// procedures/functions //////////////////////////////////////////
+// pipeopen.c
+FILE*      pipeopen                   ( const char* command, const char* filename );
+
+// stderr.c
+void       SetStderrSilent            ( mpc_bool_t state );
+mpc_bool_t GetStderrSilent            ( void );
+int mpc_cdecl  stderr_printf              ( const char* format, ... );
 
 // quant.h
@@ -37,16 +200,17 @@
 
 // wave_in.h
-
 typedef struct {
     FILE*         fp;                   // File pointer to read data
-    Ulong         PCMOffset;            // File offset of PCM data
+    mpc_size_t    PCMOffset;            // File offset of PCM data
     long double   SampleFreq;           // Sample frequency in Hz
-    Uint          BitsPerSample;        // used bits per sample, 8*BytesPerSample-7 <= BitsPerSample <= BytesPerSample
-    Uint          BytesPerSample;       // allocated bytes per sample
-    Uint          Channels;             // Number of channels, 1...8
-    UintMax_t     PCMBytes;             // PCM Samples (in 8 bit units)
-    UintMax_t     PCMSamples;           // PCM Samples per Channel
-    Bool_t        raw;                  // raw: headerless format
+    mpc_uint_t    BitsPerSample;        // used bits per sample, 8*BytesPerSample-7 <= BitsPerSample <= BytesPerSample
+    mpc_uint_t    BytesPerSample;       // allocated bytes per sample
+    mpc_uint_t    Channels;             // Number of channels, 1...8
+	mpc_size_t    PCMBytes;             // PCM Samples (in 8 bit units)
+	mpc_size_t    PCMSamples;           // PCM Samples per Channel
+    mpc_bool_t    raw;                  // raw: headerless format
 } wave_t;
+
+typedef float SCFTriple [3];
 
 // FIXME : put in lib header
@@ -121,10 +285,4 @@
 void writeBitstream_SV8 ( mpc_encoder_t*, int, const SubbandQuantTyp*);
 
-
-
-
-void    Huffman_SV7_Encoder ( void );
-
-
 // keyboard.c
 int    WaitKey      ( void );
@@ -153,4 +311,5 @@
 // winmsg.c
 #ifdef _WIN32
+#define WIN32_MESSAGES      1                   // support Windows-Messaging to Frontend
 int    SearchForFrontend   ( void );
 void   SendQuitMessage     ( void );
@@ -159,5 +318,4 @@
 void   SendProgressMessage ( const int, const float, const float );
 #else
-# undef  WIN32_MESSAGES
 # define WIN32_MESSAGES                 0
 # define SearchForFrontend()            (0)
@@ -173,19 +331,9 @@
 #define MPPENC_DENORMAL_FIX_RIGHT ( MPPENC_DENORMAL_FIX_BASE * 0.5f )
 
-
-#endif /* MPPENC_MPPENC_H */
-
-#if 0
-# define LAST_HUFFMAN   15
-# define DUMP_HIGHRES
-#endif
-
-#if 0
-# define DUMP_RES15
-#endif
-
 #ifndef LAST_HUFFMAN
 # define LAST_HUFFMAN    7
 #endif
 
+#endif /* MPCENC_MPCENC_H */
+
 /* end of mpcenc.h */
Index: bmpc/branches/r2d/mpcenc/mpp.h
===================================================================
--- /libmpc/branches/r2d/mpcenc/mpp.h	(revision 194)
+++ 	(revision )
@@ -1,194 +1,0 @@
-/*
- * Musepack audio compression
- * Copyright (C) 1999-2004 Buschmann/Klemm/Piecha/Wolf
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/******************************************************
- *                                                    *
- *            Source Compile configuration            *
- *                                                    *
- ******************************************************/
-
-
-#if !defined(__APPLE__)
-// use optimized assembler routines for Pentium III/K6-2/Athlon (only 32 bit OS, Intel x86 and no MAKE_xxBITS)
-// you need the NASM assembler on your system, the program becomes a little bit larger and decoding
-// on AMD K6-2 (x3), AMD K6-III (x3), AMD Duron (x1.7), AMD Athlon (x1.7), Pentium III (x2) and Pentium 4 (x1.8) becomes faster
-#define USE_ASM
-
-// Open Sound System support (only Unix with OSS support)
-// If your Operating System supports the Open Sound System, you can output to /dev/dsp* and
-// instead of writing a file the program plays the file via this sound device.
-// on some systems you also must link the libossaudio library, so maybe you also must edit the Makefile
-#define USE_OSS_AUDIO
-
-// Enlightenment Sound Daemon support (only Unix with ESD support)
-// If your Operating System supports the Enlightenment Sound Daemon you can output to /dev/esd and
-// instead of writing a file the program plays the file via this sound device.
-// you also must link the libesd library, so maybe you also must edit the Makefile
-//#define USE_ESD_AUDIO
-
-#endif
-
-// native Sun Onboard-Audio support (only SunOS)
-// If you have a Sun Workstation with Onboard-Audio, you can output to /dev/audio and
-// instead of writing a file the program plays the file via this sound device.
-// Some machines lacking librt.a so you are unable to link a static executable with realtime-support.
-// Although you can still perfectly use the dynamic executable.
-//#define USE_SUN_AUDIO
-
-// Sound support for SGI Irix
-// If you have a SGI Workstation running IRIX, you can output to /dev/audio and
-// instead of writing a file the program plays the file via this sound device.
-//#define USE_IRIX_AUDIO
-
-// Audio support for Windows (WAVE OUT) (only Windows)
-// If you have a Windows based system and if you also want to play files directly instead of only writing audio files,
-// then define the next item
-#define USE_WIN_AUDIO
-
-// Buffersize for Windows Audio in 4.5 KByte units
-// Only needed for Windows+USE_WIN_AUDIO
-// Good values are 8...32 for fast machines and 128...512 for slow machines
-// large values decrease average performance a little bit, increase memory
-// consumption (1 Block = 4.5 KByte), but increase buffering, so it takes a
-// longer time to get a dropout. Note that I don't have a 486/80...133, so
-// I don't know anything about their performance.
-// (Attention: 512 = additional 2.3 MByte of memory)
-#define MAX_WAVEBLOCKS    40
-
-// increase priority if destination is an audio device
-// this increases the priority of the decoder when playing the file directly to a sound card to reduce/prevent
-// dropouts during the playback due to CPU time shortage
-#define USE_NICE
-
-// use realtime scheduling if destination is an audio device
-// This sets the program to real time priority when playing the file directly to a sound card.
-// Now it should be really difficult to get dropouts (file IO and other realtime programs are the remaining weak points)
-#define USE_REALTIME
-
-// use ANSI-Escape sequences to structure output
-#define USE_ANSI_ESCAPE
-
-// Use termios for reading values from keyboard without echo and ENTER
-#define USE_TERMIOS
-
-// if none of the next three macros MAKE_xxBIT is defined,
-// normal non-dithered and non-shaped 16 bit PCM output is generated
-
-// create 16 bit Output
-// output is 16 bit wide, you can also dither and noise shape
-//#define MAKE_16BIT
-
-// create 24 bit Output
-// output is 24 bit wide instead of 16 bit wide, you can also dither and noise shape
-//#define MAKE_24BIT
-
-// create 32 bit Output
-// output is 32 bit wide instead of 16 bit wide, you can also dither and noise shape
-//#define MAKE_32BIT
-
-// Select subset of function used for file I/O:
-//   1: ANSI via file pointer (FILE*)
-//   2: POSIX via file handle (int or HANDLE)
-//   3: POSIX like lowest level function of Turbo/Borland C
-//   4: WinAMP 3: running inside WinAMP
-// Try to use '2', if this doesn't work, try '1'. '3' is for Borland compilers.
-#ifndef FILEIO
-# if   defined MPP_ENCODER
-#  define FILEIO      1             // mpcenc still uses buffered ANSI-I/O
-# elif defined MPP_DECODER
-#  define FILEIO      2
-# else
-#   error Neigher MPP_DECODER nor MPP_ENCODER is defined. Abort.
-# endif
-#endif
-
-// the POSIX function read() can return less bytes than requested not only at the end of the file.
-// if this happens, the following macro must be defined:
-#define HAVE_INCOMPLETE_READ
-
-// use a shorter Huffman_t  representation, may be faster
-// use for performance tuning
-#define USE_HUFF_PACK
-
-// use shorter representation for SCF_Index[][] and Res[], may be faster
-// use for performance tuning
-#define USE_ARRAY_PACK
-
-// use the System 5 timer for profiling
-// otherwise a special piece of code for Turbo-C is used or the Timestamp Counter on Intel IA32/gcc systems.
-// Both is highly non-portable. This solution is more portable (you only need a SYS 5 compatible system,
-// but also much much more inaccurate.
-//#define USE_SYSV_TIMER
-
-// do a memory shift every n subband samples, otherwise only increment pointer (6, 12, 18 and 36 are good values)
-// use for performance tuning
-#define VIRT_SHIFT    18
-
-// selects InputBuff size, size is 4 * 2^IBUFLOG2 bytes (11...14 are good values)
-// use for performance tuning
-// can also be used to eliminate disk performance issue while tuning the program
-// (set to a value, so the test cases are fully read before decoding
-#define IBUFLOG2      14
-
-// Dump contents of MPEGplus files (only for development), 0x00 no dump
-// Bit 0: maxband, Bit 1: msbits, Bit 2: allocation/resolution, Bit 3: SCF
-// Bit 4: Subsamples, Bit 5: Datenrate, Bit 6: Bitusage der Sektionen
-//#define DUMPSELECT    0xFF
-
-// 16 bit and 32 bit accesses must be aligned, otherwise a bus error occures.
-// try this if you get bus errors
-//#define MUST_ALIGNED
-
-// Experimental: use http/ftp streaming
-#define USE_HTTP
-
-// _use setargv module
-#define USE_ARGV
-
-
-// Use IPv4 and IPv6
-//#define USE_IPv4_6
-// Use only IPv6
-//#define USE_IPv6
-
-// compile StreamVersion 8 decoding (always disable, no usabiltity)
-// do not edit
-//#define USE_SV8
-
-// disables assert()
-// assert() is for development only and decreases speed and increases the size of the program
-#ifndef NDEBUG
-# define NDEBUG
-#endif
-
-// Some other tracing (only for development)
-// do not edit
-//#define DEBUG
-
-// Some tracings of popen()
-// do not edit
-//#define DEBUG2
-
-// activate simple profiler
-//#define PROFILE
-
-// make debug output in tags.c stfu
-#define STFU
-
-/* end of mpp.h */
Index: bmpc/branches/r2d/mpcenc/mppdec.h
===================================================================
--- /libmpc/branches/r2d/mpcenc/mppdec.h	(revision 194)
+++ 	(revision )
@@ -1,1105 +1,0 @@
-/*
- * Musepack audio compression
- * Copyright (C) 1999-2004 Buschmann/Klemm/Piecha/Wolf
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-//// Macros typical for Compilers:
-//
-//  __TURBOC__          Turbo-C, Borland-C
-//  __BORLANDC__        Borland-C
-//  __ZTC__             Zortech-C
-//  _MSC_VER            Microsoft-C
-//  __EMX__             Eberhard Mattes EMX (GNU based)
-//  __GNUC__            GNU C based compiler (also Cygwin)
-//  __CYGWIN__          Cygnus Windows C-Compiler (GNU based)
-//  __APPLE_CC__        Apple GCC (GNU based)
-
-
-//// Macros typical for Operating Systems
-//
-//  __linux__           Linux
-//  __bsdi__            BSDi
-//  __FreeBSD__         FreeBSD
-//  __NetBSD__          NetBSD
-//  __OpenBSD__         OpenBSD
-//  __unix__            Unix ????????
-//  _WIN16              16 bit-Windows
-//  _WIN32              32 bit-Windows (WIN32 is wrong, not defined by not MSC) (also __GNUC__ + _WIN32 is possible)
-//  _HPUX_SOURCE        HP-UX
-//  __BEOS__            BeOS
-//  __APPLE__           Apple Mac OS X (only when using Apple GCC)
-//  ???????             MS-DOS and relatives
-
-
-//// Macros typical for special conformances
-//                      System 5 Release 4 (SVr4)
-//                      System 5 ID     (SVID)
-//                      POSIX 1.0
-//                      POSIX 1.0b
-//                      X/OPEN
-//                      BSD 4.3
-//                      BSD 4.4
-//                      ANSI
-
-
-// Macros to manipulate Sockets + Files in one, in (+0x4000)
-// output times TIME/TIME_T/DTIME
-
-#ifndef MPPDEC_MPPDEC_H
-#define MPPDEC_MPPDEC_H
-
-//// optimization/feature defines //////////////////////////////////
-#ifndef NOT_INCLUDE_CONFIG_H
-# include "config.h"
-#endif
-#include "./mpp.h"
-
-
-//// portable system includes //////////////////////////////////////
-#include <stdio.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include <stdarg.h>
-#include <string.h>
-#include <limits.h>
-#include <assert.h>
-#include <math.h>
-
-
-//// system dependent system includes //////////////////////////////
-// low level I/O, where are prototypes and constants?
-#if   defined _WIN32  ||  defined __TURBOC__  ||  defined __ZTC__  ||  defined _MSC_VER
-# include <io.h>
-# include <fcntl.h>
-# include <time.h>
-# include <sys/types.h>
-# include <sys/stat.h>
-#elif defined __unix__  ||  defined __linux__  ||  defined __APPLE__
-# include <fcntl.h>
-# include <unistd.h>
-# include <sys/time.h>
-# include <sys/ioctl.h>
-# include <sys/types.h>
-# include <sys/stat.h>
-#else
-// .... add Includes for new Operating System here (with prefix: #elif defined)
-# include <fcntl.h>
-# include <unistd.h>
-# include <sys/ioctl.h>
-# include <sys/stat.h>
-#endif
-
-
-#if   defined __linux__
-#  include <fpu_control.h>
-#elif defined __FreeBSD__
-# include <machine/floatingpoint.h>
-#elif defined _MSC_VER
-# include <float.h>
-#endif
-
-
-#if defined _WIN32
-# undef USE_OSS_AUDIO
-# undef USE_ESD_AUDIO
-# undef USE_SUN_AUDIO
-#else
-# undef USE_WIN_AUDIO
-#endif
-
-#if defined __APPLE__
-# undef USE_OSS_AUDIO
-# undef USE_SUN_AUDIO
-# undef USE_WIN_AUDIO
-# undef USE_NICE
-# undef USE_REALTIME
-# undef USE_ASM
-# undef USE_ESD_AUDIO
-# define NO_DEV_AUDIO
-#endif
-
-#if defined __TURBOC__
-# undef USE_OSS_AUDIO
-# undef USE_ESD_AUDIO
-# undef USE_SUN_AUDIO
-# undef USE_NICE
-# undef USE_REALTIME
-#endif
-
-#if defined USE_DIET  ||  defined MAKE_24BIT  ||  defined MAKE_32BIT
-# undef USE_ESD_AUDIO
-#endif
-
-#if defined MAKE_16BIT  ||  defined MAKE_24BIT  ||  defined MAKE_32BIT
-# undef USE_ASM
-#endif
-
-#if INT_MAX < 2147483647L
-# undef USE_ASM
-#endif
-
-// sound card
-#if defined USE_OSS_AUDIO
-# include <sys/ioctl.h>
-# include <sys/time.h>
-# if   defined __linux__        // the standard is that this file is stored somewhere on the hard disk
-#  include <linux/soundcard.h>
-# elif defined __bsdi__
-#  include <sys/soundcard.h>
-# elif defined __FreeBSD__
-#  include <machine/soundcard.h>
-# elif defined __NetBSD__  ||  defined __OpenBSD__
-#  include <soundcard.h>
-# elif defined __APPLE__  &&  defined __MACH__
-#  include <pleasepatchheretherightpathofsoundcard.hforMacOSX/soundcard.h>
-# else
-#  include <pleasepatchheretherightpathof/soundcard.h>
-# endif
-#endif /* USE_OSS_AUDIO */
-
-#if defined USE_ESD_AUDIO
-# include <esd.h>
-#endif
-
-#if defined USE_SUN_AUDIO
-# include <sys/audioio.h>
-#endif
-
-#ifdef MPP_ENCODER
-# undef USE_HTTP
-#endif
-
-#ifdef USE_HTTP
-# ifdef _WIN32
-#  include <winsock2.h>
-# else
-#  include <sys/socket.h>
-# endif
-#endif
-
-#if   defined USE_WIN_AUDIO
-# include <windows.h>
-# define WINAUDIO_FD            ((FILE_T)-128)
-#elif defined USE_IRIX_AUDIO
-# define IRIXAUDIO_FD           ((FILE_T)-127)
-#endif
-#define  NULL_FD                ((FILE_T)-126)
-
-#if defined USE_NICE  &&  !defined _WIN32
-# include <sys/resource.h>
-#endif
-
-// scheduler stuff
-#if defined USE_REALTIME  &&  !defined _WIN32
-# include <sched.h>
-#endif
-
-#ifndef O_BINARY
-# ifdef _O_BINARY
-#  define O_BINARY              _O_BINARY
-# else
-#  define O_BINARY              0
-# endif
-#endif
-
-#if defined _WIN32  ||  defined __TURBOC__
-# define strncasecmp(__s1,__s2,__n) strnicmp ((__s1), (__s2), (__n))
-# define strcasecmp(__s1,__s2)      stricmp  ((__s1), (__s2))
-# define MKDIR(__dir,__attr)        mkdir ((__dir))
-#else
-# define MKDIR(__dir,__attr)        mkdir ((__dir), (__attr))
-#endif
-
-#if defined _WIN32
-# include <direct.h>
-# define snprintf                   _snprintf
-# define getcwd(__buff,__len)       _getcwd ((__buff), (__len))
-# define sleep(__sec)               Sleep ((__sec) * 1000)
-#endif
-
-#if defined _WIN32
-# define TIME_T                     long
-# define TIME(__x)                  time ( &(__x) )
-# define DTIME(__x,__y)             ( (double)(__y) - (__x) )
-#else
-# define TIME_T                     struct timeval
-# define TIME(__x)                  gettimeofday ( &(__x), NULL )
-# define DTIME(__x,__y)             ( ((double)(__y).tv_sec - (__x).tv_sec) + 1.e-6 * ((double)(__y).tv_usec - (__x).tv_usec) )
-#endif
-
-#if   defined __GNUC__
-# define inline                 __inline__
-# define restrict
-#elif defined _WIN32
-# define inline                 __inline
-# define restrict
-#else
-# define inline
-# define restrict
-#endif
-
-
-//// Binary/Low-Level-IO ///////////////////////////////////////////
-//
-// All file I/O is basicly handled via an ANSI file pointer (type: FILE*) in
-// FILEIO-Mode 1 and via a POSIX file descriptor (type: int) in
-// FILEIO-Mode 2 and 3.
-//
-// Some operations are only available via the POSIX interface (fcntl, setmode,
-// ...) so we need a function to get the file descriptor from a file pointer.
-// In FILEIO-Mode 2 and 3 this is a dummy function because we are always working
-// with these file descriptors.
-//
-
-#if  FILEIO == 1
-# if   defined __BORLANDC__  ||  defined _WIN32
-#  define FILENO(__fp)          _fileno ((__fp))
-# elif defined __CYGWIN__  ||  defined __TURBOC__  ||  defined __unix__  ||  defined __EMX__  ||  defined _MSC_VER
-#  define FILENO(__fp)          fileno  ((__fp))
-# else
-#  define FILENO(__fp)          fileno  ((__fp))
-# endif
-#else
-#  define FILENO(__fd)          (__fd)
-#endif
-
-
-//
-// If we have access to a file via file name, we can open the file with an
-// additional "b" or a O_BINARY within the (f)open function to get a
-// transparent untranslated data stream which is necessary for audio bitstream
-// data and also for PCM data. If we are working with
-// stdin/stdout/FILENO_STDIN/FILENO_STDOUT we can't open the file with these
-// attributes, because the files are already open. So we need a non
-// standardized sequence to switch to this mode (not necessary for Unix).
-// Mostly the sequence is the same for incoming and outgoing streams, but only
-// mostly so we need one for IN and one for OUT.
-// Macros are called with the file pointer and you get back the untransalted file
-// pointer which can be equal or different from the original.
-//
-
-#if   defined __EMX__
-# define SETBINARY_IN(__fp)     (_fsetmode ( (__fp), "b" ), (__fp))
-# define SETBINARY_OUT(__fp)    (_fsetmode ( (__fp), "b" ), (__fp))
-#elif defined __TURBOC__ || defined __BORLANDC__
-# define SETBINARY_IN(__fp)     (setmode   ( FILENO ((__fp)),  O_BINARY ), (__fp))
-# define SETBINARY_OUT(__fp)    (setmode   ( FILENO ((__fp)),  O_BINARY ), (__fp))
-#elif defined __CYGWIN__
-# define SETBINARY_IN(__fp)     (setmode   ( FILENO ((__fp)), _O_BINARY ), (__fp))
-# define SETBINARY_OUT(__fp)    (setmode   ( FILENO ((__fp)), _O_BINARY ), (__fp))
-#elif defined _WIN32
-# define SETBINARY_IN(__fp)     (_setmode  ( FILENO ((__fp)), _O_BINARY ), (__fp))
-# define SETBINARY_OUT(__fp)    (_setmode  ( FILENO ((__fp)), _O_BINARY ), (__fp))
-#elif defined _MSC_VER
-# define SETBINARY_IN(__fp)     (setmode   ( FILENO ((__fp)),  O_BINARY ), (__fp))
-# define SETBINARY_OUT(__fp)    (setmode   ( FILENO ((__fp)),  O_BINARY ), (__fp))
-#elif defined __unix__
-# define SETBINARY_IN(__fp)     (__fp)
-# define SETBINARY_OUT(__fp)    (__fp)
-#elif 0
-# define SETBINARY_IN(__fp)     (freopen   ( NULL, "rb", (__fp) ), (__fp))
-# define SETBINARY_OUT(__fp)    (freopen   ( NULL, "wb", (__fp) ), (__fp))
-#else
-# define SETBINARY_IN(__fp)     (__fp)
-# define SETBINARY_OUT(__fp)    (__fp)
-#endif
-
-// file I/O using ANSI buffered file I/O via file pointer FILE* (fopen, fread, fwrite, fclose)
-#if  FILEIO == 1
-# define OFF_T                  signed long
-# define FILE_T                 FILE*
-# define OPEN(name)             fopen  (name, "rb" )
-# define OPENRW(name)           fopen  (name, "r+b")
-# define CREATE(name)           fopen  (name, "wb" )
-# define INVALID_FILEDESC       NULL
-# define CLOSE(fp)              fclose (fp)                  // CLOSE   returns -1 on error, otherwise 0
-# define READ(fp,ptr,len)       fread  (ptr, 1, len, fp)     // READ    returns -1 or 0 on error/EOF, otherwise > 0
-# define READ1(fp,ptr)          fread  (ptr, 1, 1, fp)       // READ    returns -1 or 0 on error/EOF, otherwise > 0
-# define WRITE(fp,ptr,len)      fwrite (ptr, 1, len, fp)     // WRITE   returns -1 or 0 on error/EOF, otherwise > 0
-# define SEEK(fp,offs,lbl)      fseek  (fp, offs, lbl)       // SEEK    returns -1 on error, otherwise >= 0
-# define FILEPOS(fp)            ftell  (fp)                  // FILEPOS returns -1 on error, otherwise >= 0
-# define STDIN                  stdin
-# define STDOUT                 stdout
-# define STDERR                 stderr
-# define FDOPEN(fd,mode)        fdopen (fd, mode)
-# define UNBUFFER(fp)           setvbuf(fp, NULL, _IONBF, 0 )
-# define FLUSH(fp)              fflush (fp)
-#endif /* FILEIO==1 */
-
-// file I/O using POSIX unbuffered file I/O via file descriptors (open, read, write, close)
-#if  FILEIO == 2
-# ifdef WIN32
-#  define OFF_T                 _off_t
-# else
-#  define OFF_T                 off_t
-# endif
-# define FILE_T                 int
-# define OPEN(name)             open  (name, O_RDONLY|O_BINARY)
-# define OPENRW(name)           open  (name, O_RDWR  |O_BINARY)
-# define CREATE(name)           open  (name, O_WRONLY|O_BINARY|O_TRUNC|O_CREAT, 0644)
-# define INVALID_FILEDESC       (-1)
-# define CLOSE(fd)              close (fd)                   // CLOSE   returns -1 on error, otherwise 0
-// # if defined HAVE_INCOMPLETE_READ
-// #  define READ(fd,ptr,len)      complete_read (fd, ptr, len) // READ    returns -1 or 0 on error/EOF, otherwise > 0
-// # else
-// #  define READ(fd,ptr,len)      (size_t)read   (fd, ptr, len)// READ    returns -1 or 0 on error/EOF, otherwise > 0
-// # endif
-# define READ1(fd,ptr)          (size_t)read   (fd, ptr, 1)  // READ    returns -1 or 0 on error/EOF, otherwise > 0
-# define WRITE(fd,ptr,len)      (size_t)write  (fd, ptr, len)// WRITE   returns -1 or 0 on error/EOF, otherwise > 0
-# define SEEK(fd,offs,lbl)      lseek  (fd, offs, lbl)       // SEEK    returns -1 on error, otherwise >= 0
-# define FILEPOS(fd)            lseek  (fd, 0L, SEEK_CUR)    // FILEPOS returns -1 on error, otherwise >= 0
-# define STDIN                  0
-# define STDOUT                 1
-# define STDERR                 2
-# define FDOPEN(fd,mode)        (fd)
-# define UNBUFFER(fd)           (void)(fd)
-# define FLUSH(fd)              (void)(fd)
-#endif /* FILEIO==2 */
-
-// file I/O using Turbo-C lowest level unbuffered file I/O via file descriptors (_open, _read, _write, _close)
-#if  FILEIO == 3
-# define OFF_T                  signed long
-# define FILE_T                 int
-# define OPEN(name)             _open (name, O_RDONLY)
-# define OPENRW(name)           _open (name, O_RDWR  )
-# define CREATE(name)           _creat(name, 0)
-# define INVALID_FILEDESC       (-1)
-# define CLOSE(fd)              _close (fd)                  // CLOSE   returns -1 on error, otherwise 0
-# define READ(fd,ptr,len)       (size_t)_read  (fd, ptr, len)// READ    returns -1 or 0 on error/EOF, otherwise > 0
-# define READ1(fd,ptr)          (size_t)_read  (fd, ptr, 1)  // READ    returns -1 or 0 on error/EOF, otherwise > 0
-# define WRITE(fd,ptr,len)      (size_t)_write (fd, ptr, len)// WRITE   returns -1 or 0 on error/EOF, otherwise > 0
-# define SEEK(fd,offs,lbl)      lseek  (fd, offs, lbl)       // SEEK    returns -1 on error, otherwise >= 0
-# define FILEPOS(fd)            lseek  (fd, 0L, SEEK_CUR)    // FILEPOS returns -1 on error, otherwise >= 0
-# define STDIN                  0
-# define STDOUT                 1
-# define STDERR                 2
-# undef  SETBINARY_IN
-# undef  SETBINARY_OUT
-# define SETBINARY_IN(fd)       (fd)
-# define SETBINARY_OUT(fd)      (fd)
-# define FDOPEN(fd,mode)        (fd)
-# define UNBUFFER(fd)           (void)(fd)
-# define FLUSH(fd)              (void)(fd)
-#endif /* FILEIO==3 */
-
-#if FILEIO != 2  &&  defined USE_HTTP
-# error HTTP can only be used by FILEIO==2
-#endif
-
-#if defined _WIN32  ||  defined __BEOS__
-# define WRITE_SOCKET(sock,ptr,len)     send (sock, ptr, len, 0)
-# define READ_SOCKET(sock,ptr,len)      recv (sock, ptr, len, 0)
-#else
-# define WRITE_SOCKET(sock,ptr,len)     write (sock, ptr, len)
-# define READ_SOCKET(sock,ptr,len)      read  (sock, ptr, len)
-#endif
-
-#ifdef _WIN32
-# define POPEN_READ_BINARY_OPEN(cmd)    _popen ((cmd), "rb")
-# define POPEN_WRITE_BINARY_OPEN(cmd)   _popen ((cmd), "wb")
-# define PCLOSE(fp)                     _pclose(fp)
-#else
-# define POPEN_READ_BINARY_OPEN(cmd)    popen ((cmd), "r")
-# define POPEN_WRITE_BINARY_OPEN(cmd)   popen ((cmd), "w")
-# define PCLOSE(fp)                     pclose(fp)
-#endif
-
-#ifndef S_ISDIR
-# if   defined S_IFDIR
-#  define S_ISDIR(x)            ((x) &   S_IFDIR)
-# elif defined _S_IFDIR
-#  define S_ISDIR(x)            ((x) &  _S_IFDIR)
-# elif defined __S_IFDIR
-#  define S_ISDIR(x)            ((x) & __S_IFDIR)
-# else
-#  error Cannot find a way to test for a directory
-# endif
-#endif /* !S_ISDIR */
-
-#if defined __unix__  ||  defined __bsdi__  ||  defined __FreeBSD__  ||  defined __OpenBSD__  ||  defined __NetBSD__  ||  defined __TURBOC__  ||  defined _WIN32  ||  defined __APPLE__
-# define ISATTY(fd)             isatty (fd)
-#else
-# define ISATTY(fd)             0
-#endif
-
-// Path separator
-#if defined __unix__  ||  defined __bsdi__  ||  defined __FreeBSD__  ||  defined __OpenBSD__  ||  defined __NetBSD__  ||  defined __APPLE__
-# define PATH_SEP               '/'
-# define DRIVE_SEP              '\0'
-# define EXE_EXT                ""
-# define DEV_NULL               "/dev/null"
-# define ENVPATH_SEP            ':'
-#elif defined _WIN32  ||  defined __TURBOC__  ||  defined __ZTC__  ||  defined _MSC_VER
-# define PATH_SEP               '\\'
-# define DRIVE_SEP              ':'
-# define EXE_EXT                ".exe"
-# define DEV_NULL               "\\nul"
-# define ENVPATH_SEP            ';'
-#else
-# define PATH_SEP               '/'         // Amiga: C:/
-# define DRIVE_SEP              ':'
-# define EXE_EXT                ""
-# define DEV_NULL               "nul"
-# define ENVPATH_SEP            ';'
-#endif
-
-// maximum length of file names
-#ifndef PATHLEN_MAX
-# if   defined FILENAME_MAX
-#  define PATHLEN_MAX           FILENAME_MAX
-# elif INT_MAX < 2147483647L
-#  define PATHLEN_MAX            128
-# else
-#  define PATHLEN_MAX           1024
-# endif
-#endif /* !PATHLEN_MAX */
-
-#ifdef _WIN32
-# define TitleBar(text)   SetConsoleTitle (text)
-#else
-# define TitleBar(text)   (void) (text)
-#endif
-
-
-//// constants /////////////////////////////////////////////////////
-#ifdef USE_SV8
-# define MAX_SV          "SV8"
-#else
-# define MAX_SV          "SV7"
-#endif
-
-#ifdef USE_ASM
-# define BUILD           "3DNOW!/SSE"
-#else
-# define BUILD           ""
-#endif
-
-
-#define COPYRIGHT        "(C) 1999-2003 Buschmann/Klemm/Piecha/Wolf"
-
-#define DECODER_DELAY    (512 - 32 + 1)
-#define BLK_SIZE         (36 * 32)
-
-
-//// logging defines, for development only /////////////////////////
-#if defined _WIN32  ||  defined __TURBOC__
-# define LOGPATH         ".\\"
-# define MUSICPATH       "D:\\AUDIO\\"
-#else
-# define LOGPATH         "./"
-# define MUSICPATH       "/Archive/Audio/"
-#endif
-#define _(x)             (void)(fprintf(stderr,"<%d>\n",(x)),fflush(stderr))
-
-#ifdef DEBUG
-# define REP(x)          (void)(x)
-#else
-# define REP(x)
-#endif
-
-
-//// numerical constants ///////////////////////////////////////////
-#define C00              (Float) 0.500000000000000000000000L    // Cxx = 0.5 / cos (xx*M_PI/64)
-#define C01              (Float) 0.500602998235196301334178L
-#define C02              (Float) 0.502419286188155705518560L
-#define C03              (Float) 0.505470959897543659956626L
-#define C04              (Float) 0.509795579104159168925062L
-#define C05              (Float) 0.515447309922624546962323L
-#define C06              (Float) 0.522498614939688880640101L
-#define C07              (Float) 0.531042591089784174473998L
-#define C08              (Float) 0.541196100146196984405269L
-#define C09              (Float) 0.553103896034444527838540L
-#define C10              (Float) 0.566944034816357703685831L
-#define C11              (Float) 0.582934968206133873665654L
-#define C12              (Float) 0.601344886935045280535340L
-#define C13              (Float) 0.622504123035664816182728L
-#define C14              (Float) 0.646821783359990129535794L
-#define C15              (Float) 0.674808341455005746033820L
-#define C16              (Float) 0.707106781186547524436104L
-#define C17              (Float) 0.744536271002298449773679L
-#define C18              (Float) 0.788154623451250224773056L
-#define C19              (Float) 0.839349645415527038721463L
-#define C20              (Float) 0.899976223136415704611808L
-#define C21              (Float) 0.972568237861960693780520L
-#define C22              (Float) 1.060677685990347471323668L
-#define C23              (Float) 1.169439933432884955134476L
-#define C24              (Float) 1.306562964876376527851784L
-#define C25              (Float) 1.484164616314166277319733L
-#define C26              (Float) 1.722447098238333927796261L
-#define C27              (Float) 2.057781009953411550808880L
-#define C28              (Float) 2.562915447741506178719328L
-#define C29              (Float) 3.407608418468718785698107L
-#define C30              (Float) 5.101148618689163857960189L
-#define C31              (Float)10.190008123548056810994678L
-
-#define SS05             (Float) 0.840896415253714543018917L      // 0.5^0.25
-
-
-#ifndef M_PI
-# define M_PI            3.1415926535897932384626433832795029     // 4*atan(1)
-# define M_PIl           3.1415926535897932384626433832795029L
-# define M_LN2           0.6931471805599453094172321214581766     // ln(2)
-# define M_LN2l          0.6931471805599453094172321214581766L
-# define M_LN10          2.3025850929940456840179914546843642     // ln 10 */
-# define M_LN10l         2.3025850929940456840179914546843642L
-#endif
-
-
-//// 'Cdecl' forces the use of standard C/C++ calling convention ///////
-#if   defined _WIN32
-# define Cdecl           __cdecl
-#elif defined __ZTC__
-# define Cdecl           _cdecl
-#elif defined __TURBOC__
-# define Cdecl           cdecl
-#else
-# define Cdecl
-#endif
-
-//// expect handling of GCC ////////////////////////////////////////
-#ifdef __GNUC__
-# if __GNUC__ < 3
-#  define __builtin_expect(cond,exp)  (cond)
-#  ifndef expect
-#    define expect(cond,exp)          __builtin_expect(cond,exp)
-#  endif
-# else
-#  ifndef expect
-#   define expect(cond,exp)           __builtin_expect(cond,exp)
-#  endif
-# endif
-#else
-# define __builtin_expect(cond,exp)   (cond)
-# ifndef expect
-#  define expect(cond,exp)            __builtin_expect(cond,exp)
-# endif
-#endif
-
-#define if0(x)                        if (expect(x,0))
-#define if1(x)                        if (expect(x,1))
-#define while0(x)                     while (expect(x,0))
-#define while1(x)                     while (expect(x,1))
-
-#ifndef __GNUC__
-# define __attribute__(x)
-#else
-# define __attribute__(x)
-#endif
-
-//// Remaining macros //////////////////////////////////////////////
-// selects input buffer size and some constants needed for input buffer handling
-#ifndef IBUFLOG2                 // must be at least 10 (bitrate always <626 kbps) or better 11 ( <1253 kbps)
-# if INT_MAX < 2147483647L
-#  define IBUFLOG2       11      // 8 KByte buffer, possible 11...13 (32 KByte limit)
-# else
-#  define IBUFLOG2       21      // 8 MByte buffer, possible 11...29 ( 2 GByte limit)
-# endif
-#endif
-#define IBUFSIZE         ((size_t)(1LU<<(IBUFLOG2)))
-#define IBUFSIZE2        ((size_t)((IBUFSIZE)/2))
-#define IBUFMASK         ((size_t)((IBUFSIZE)-1))
-
-// save memory space for 16 bit compiler (data + stack < 64 KByte)
-#if INT_MAX < 2147483647L
-# if VIRT_SHIFT     >  6
-#  undef  VIRT_SHIFT
-#  define VIRT_SHIFT   6
-# endif
-# if      IBUFLOG2  > 11
-#  undef  IBUFLOG2
-#  define IBUFLOG2    11
-# endif
-# define USE_HUFF_PACK
-# define USE_ARRAY_PACK
-#endif
-
-// generate a macro which contains information about compile time settings
-#define STR(x)   _STR(x)
-#define _STR(x)  #x
-#ifdef NDEBUG
-# define T1  ""
-#else
-# define T1  "DEBUG "
-#endif
-#if  defined USE_OSS_AUDIO  ||  defined USE_ESD_AUDIO  ||  defined USE_SUN_AUDIO  ||  defined USE_WIN_AUDIO
-# define T2  "SND "
-#else
-# define T2  ""
-#endif
-#ifdef USE_NICE
-# define T3  "NICE "
-#else
-# define T3  ""
-#endif
-#if defined USE_REALTIME
-# define T4  "RT "
-#else
-# define T4  ""
-#endif
-#ifdef HAVE_IEEE754_FLOAT
-# define T5  "IEEE "
-#else
-# define T5  ""
-#endif
-#define T6  "IO=" STR(FILEIO) " "
-#ifdef USE_HUFF_PACK
-# define T7  "H-PCK "
-#else
-# define T7  ""
-#endif
-#ifdef USE_ARRAY_PACK
-# define T8  "A-PCK "
-#else
-# define T8  ""
-#endif
-#define T9  "SHFT=" STR(VIRT_SHIFT) " "
-#define T10 "IBUF=" STR(IBUFLOG2) " "
-
-#define COMPILER_FLAGS  T1 T2 T3 T4 T5 T6 T7 T8 T9 T10
-
-// align a pointer by maybe incrementing it
-#define ALIGN(ptr,alignment) \
-                    (void*)((((ptrdiff_t)(ptr)) & (-(ptrdiff_t)(alignment))) + (alignment))   // aligns a pointer with alignment, the source array should be at least alignment-1 Bytes longer than the needed length
-
-
-//// Simple types //////////////////////////////////////////////////
-
-#if   CHAR_BIT == 8  &&  SCHAR_MAX == 127L
-typedef unsigned char       Uint8_t;    // guaranteed  8 bit unsigned integer type with range 0...255
-typedef signed   char       Int8_t;     // guaranteed  8 bit signed   integer type with range -128...127
-#else
-# error No  8 bit int type found. Tested: char
-#endif
-
-#if   SHRT_MAX == 32767L
-typedef unsigned short int  Uint16_t;   // guaranteed 16 bit unsigned integer type with range 0...65535
-typedef signed   short int  Int16_t;    // guaranteed 16 bit signed   integer type with range -32768...32767
-#else
-# error No 16 bit int type found. Tested: short
-#endif
-
-#if   INT_MAX == 2147483647L
-typedef unsigned int        Uint32_t;   // guaranteed 32 bit unsigned integer type with range 0...4294967295
-typedef signed   int        Int32_t;    // guaranteed 32 bit signed   integer type with range -2147483648...2147483647
-#elif LONG_MAX == 2147483647L
-typedef unsigned long int   Uint32_t;   // guaranteed 32 bit unsigned integer type with range 0...4294967295
-typedef signed   long int   Int32_t;    // guaranteed 32 bit signed   integer type with range -2147483648...2147483647
-#else
-# error No 32 bit int type found. Tested: int, long
-#endif
-
-#if    defined __C99__                 // C9x has a type which is exact 64 bit
-typedef int64_t             Int64_t;
-typedef uint64_t            Uint64_t;
-typedef intmax_t            IntMax_t;
-typedef uintmax_t           UintMax_t;
-# define IntMax_MIN        -9223372036854775808
-# define IntMax_MAX         9223372036854775807
-# define UintMax_MAX       18446744073709551615
-# define UintMAX_FP(x)      (long double)(x)
-#elif  defined __GNUC__                // GCC uses long long as 64 bit
-typedef signed   long long  Int64_t;
-typedef unsigned long long  Uint64_t;
-typedef signed   long long  IntMax_t;
-typedef unsigned long long  UintMax_t;
-# define IntMax_MIN        -9223372036854775808LL
-# define IntMax_MAX         9223372036854775807LL
-# define UintMax_MAX       18446744073709551615LLU
-# define UintMAX_FP(x)      (long double)(x)
-#elif defined _MSC_VER
-typedef signed   __int64    Int64_t;
-typedef unsigned __int64    Uint64_t;
-typedef signed   __int64    IntMax_t;
-typedef unsigned __int64    UintMax_t;
-# define IntMax_MIN        -9223372036854775808I64
-# define IntMax_MAX         9223372036854775807I64
-# define UintMax_MAX       18446744073709551615UI64
-# define UintMAX_FP(x)      (long double)(IntMax_t)(x)
-#elif defined LLONG_MAX               // long long (when existing) is normally 64 bit
-typedef signed   long long  Int64_t;
-typedef unsigned long long  Uint64_t;
-typedef signed   long long  IntMax_t;
-typedef unsigned long long  UintMax_t;
-# define IntMax_MIN        -9223372036854775808LL
-# define IntMax_MAX         9223372036854775807LL
-# define UintMax_MAX       18446744073709551615LLU
-# define UintMAX_FP(x)      (long double)(x)
-#elif  LONG_MAX > 0xFFFFFFFFLU         // long is longer than 33 bit, assume 64 bit
-typedef signed   long       Int64_t;
-typedef unsigned long       Uint64_t;
-typedef signed   long       IntMax_t;
-typedef unsigned long       UintMax_t;
-# define IntMax_MIN        -9223372036854775808L
-# define IntMax_MAX         9223372036854775807L
-# define UintMax_MAX       18446744073709551615LU
-# define UintMAX_FP(x)      (long double)(x)
-#elif  defined _WIN32                  // Microsoft and Intel call it __int64
-typedef signed   __int64    Int64_t;
-typedef unsigned __int64    Uint64_t;
-typedef signed   __int64    IntMax_t;
-typedef unsigned __int64    UintMax_t;
-# define IntMax_MIN        -9223372036854775808I64
-# define IntMax_MAX         9223372036854775807I64
-# define UintMax_MAX       18446744073709551615UI64
-# define UintMAX_FP(x)      (long double)(IntMax_t)(x)
-#else
-# define NO_INT64_T                    // no type mapped to 64 bit integer
-typedef signed   long       IntMax_t;
-typedef unsigned long       UintMax_t;
-# define IntMax_MIN        -2147483648L
-# define IntMax_MAX         2147483647L
-# define UintMax_MAX        4294967295LU
-# define UintMAX_FP(x)      (long double)(x)
-#endif
-
-
-#if defined _WIN32  &&  !defined __GNUC__  &&  !defined __C99__
-typedef signed long         ssize_t;
-#endif
-
-#ifdef USE_ARRAY_PACK
-typedef signed char         Bool_t;     // ==0: false, !=0: true
-#else
-typedef signed int          Bool_t;     // ==0: false, !=0: true
-#endif
-typedef Uint32_t            Ibuf_t;     // type for input buffer, currently this type must be 32 bit
-typedef signed   char       Schar;      // at least -127...+127
-typedef unsigned char       Uchar;      // at least 0...255
-typedef signed   short int  Short;      // at least -32767...+32767, memory economic type
-typedef unsigned short int  Ushort;     // at least 0...65535, memory economic type
-typedef signed   int        Int;        // at least -32767...+32767, fast type
-typedef unsigned int        Uint;       // at least 0...65535, fast type
-typedef signed   long int   Long;       // at least -2147483647...+2147483647, but more is better
-typedef unsigned long int   Ulong;      // at least 0...4294967295, but more is better
-//                          size_t;     // size of memory objects
-//                          ptrdiff_t;  // pointer differences, may be larger than size_t
-typedef float               Float32_t;  // guaranteed 32 bit floating point type
-typedef double              Float64_t;  // guaranteed 64 bit floating point type
-typedef float               Float;      // fastest floating point type, memory economic (used for all PCM calculations)
-#define SIZEOF_Float  4                 // size of the type 'Float' in sizeof units
-typedef double              Double;     // floating point with extended precision (more than 32 bit mantissa)
-typedef long double         Ldouble;    // most exact floating point format
-typedef Int16_t             Int2x16_t [2];
-typedef Int32_t             Int2x32_t [2];
-
-#if   defined MAKE_16BIT  ||  defined MAKE_24BIT  ||  defined MAKE_32BIT
-# ifdef NO_INT64_T
-#   error No 64 bit int type found, needed for HQ 16...32 bit output
-# endif
-typedef Int2x32_t           Int2xSample_t;
-# if defined MAKE_32BIT
-#  define SAMPLE_SIZE        32
-#  define PROG_NAME          "mppdec32"
-#  define SAMPLE_SIZE_STRING " (32 bit HQ)"
-#  define Write_PCM(fd,p,b)  Write_PCM_HQ_2x32bit ( fd, p, b )
-#  define Synthese_Filter(Stream,offset,Vi,Yi,ch) \
-                            Synthese_Filter_32_C ( Stream, offset, Vi, Yi, ch )
-#  undef  USE_ESD_AUDIO
-# elif defined MAKE_24BIT
-#  define SAMPLE_SIZE        24
-#  define PROG_NAME          "mppdec24"
-#  define SAMPLE_SIZE_STRING " (24 bit HQ)"
-#  define Write_PCM(fd,p,b)  Write_PCM_HQ_2x24bit ( fd, p, b )
-#  define Synthese_Filter(Stream,offset,Vi,Yi,ch) \
-                            Synthese_Filter_32_C ( Stream, offset, Vi, Yi, ch )
-#  undef  USE_ESD_AUDIO
-# elif defined MAKE_16BIT
-#  define SAMPLE_SIZE        16
-#  define PROG_NAME          "mppdec16"
-#  define SAMPLE_SIZE_STRING " (16 bit HQ)"
-#  define Write_PCM(fd,p,b)  Write_PCM_HQ_2x16bit ( fd, p, b )
-#  define Synthese_Filter(Stream,offset,Vi,Yi,ch) \
-                            Synthese_Filter_32_C ( Stream, offset, Vi, Yi, ch )
-# endif
-#else
-typedef Int2x16_t           Int2xSample_t;
-# define SAMPLE_SIZE        16
-# define PROG_NAME          "mppdec"
-# define SAMPLE_SIZE_STRING ""
-# define Write_PCM(fd,p,b)  Write_PCM_2x16bit ( fd, p, b )
-# ifdef USE_ASM
-#  define Synthese_Filter(Stream,offset,Vi,Yi,ch) \
-                            Synthese_Filter_16 ( Stream, offset, Vi, Yi )
-# else
-#  define Synthese_Filter(Stream,offset,Vi,Yi,ch) \
-                            Synthese_Filter_16_C ( Stream, offset, Vi, Yi )
-# endif /* USE_ASM */
-#endif
-
-
-//// More complex types ////////////////////////////////////////////
-typedef struct {
-    Int    L [36];
-    Int    R [36];
-} Quant_t ;
-
-typedef struct {
-    Uint   L;
-    Uint   R;
-} UPair_t ;
-
-typedef struct {
-    Int    L;
-    Int    R;
-} Pair_t ;
-
-typedef struct {
-#ifdef USE_ARRAY_PACK
-    Schar  L;
-    Schar  R;
-#else
-    Int    L;
-    Int    R;
-#endif
-} CPair_t ;
-
-typedef Float     FloatArray [32];
-typedef UPair_t   UPairArray [32];
-typedef Pair_t    PairArray  [32];
-typedef CPair_t   CPairArray [32];
-typedef Float     SCFTriple   [3];
-
-typedef struct {
-    OFF_T         FileSize;
-    Int           GenreNo;
-    Int           TrackNo;
-    char          Genre   [128];
-    char          Year    [ 20];
-    char          Track   [  8];
-    char          Title   [256];
-    char          Artist  [256];
-    char          Album   [256];
-    char          Comment [512];
-} TagInfo_t ;
-
-typedef void  (*SyntheseFilter16_t) ( Int2x16_t* Stream, Int* const offset, Float* Vi, const FloatArray* Yi );
-typedef void  (*SyntheseFilter32_t) ( Int2x32_t* Stream, Int* const offset, Float* Vi, const FloatArray* Yi, int ch );
-typedef Int   (*HeaderWriter_t)     ( FILE_T outputFile, Ldouble  SampleFreq, Uint BitsPerSample, Uint Channels, Ulong SamplesPerChannel );
-
-#if defined MAKE_16BIT  ||  defined MAKE_24BIT  ||  defined MAKE_32BIT
-typedef struct {
-    const Float*  FilterCoeff;
-    Uint64_t      Mask;
-    Float64_t     Add;
-    Float         Dither;
-    Uint32_t      Overdrives;
-    Int64_t       MaxLevel;
-    Bool_t        NoShaping;
-    Float         ErrorHistory     [2] [16];       // max. 2 channels, 16th order Noise shaping
-    Float         DitherHistory    [2] [16];
-    Int32_t       LastRandomNumber [2];
-} dither_t;
-#else
-typedef struct {
-    Uint32_t      Overdrives;
-    Int32_t       MaxLevel;
-} dither_t;
-#endif
-
-
-//// Variables /////////////////////////////////////////////////////
-
-// decode.c
-extern Ibuf_t             InputBuff [IBUFSIZE]; // read buffer for the MP+ data stream
-extern size_t             InputCnt;             // current offset in this buffer
-
-// // huffsv7.c
-// extern Huffman_t          HuffHdr    [10];
-// extern Huffman_t          HuffSCFI   [ 4];
-// extern Huffman_t          HuffDSCF   [16];
-// extern Huffman_t          HuffQ1 [2] [ 3*3*3];
-// extern Huffman_t          HuffQ2 [2] [ 5*5];
-// extern Huffman_t          HuffQ3 [2] [ 7];
-// extern Huffman_t          HuffN3 [2] [ 7*7];
-// extern Huffman_t          HuffQ4 [2] [ 9];
-// extern Huffman_t          HuffQ5 [2] [15];
-// extern Huffman_t          HuffQ6 [2] [31];
-// extern Huffman_t          HuffQ7 [2] [63];
-// extern Huffman_t          HuffN8 [2][127];
-// extern const Huffman_t*   HuffQ  [2] [ 8];
-// extern const Huffman_t*   HuffN  [2] [ 9];
-// extern Uint8_t            LUT1_0  [1<< 6];
-// extern Uint8_t            LUT1_1  [1<< 9];
-// extern Uint8_t            LUT2_0  [1<< 7];
-// extern Uint8_t            LUT2_1  [1<<10];
-// extern Uint8_t            LUT3_0  [1<< 4];
-// extern Uint8_t            LUT3_1  [1<< 5];
-// extern Uint8_t            LUT4_0  [1<< 4];
-// extern Uint8_t            LUT4_1  [1<< 5];
-// extern Uint8_t            LUT5_0  [1<< 6];
-// extern Uint8_t            LUT5_1  [1<< 8];
-// extern Uint8_t            LUT6_0  [1<< 7];
-// extern Uint8_t            LUT6_1  [1<< 7];
-// extern Uint8_t            LUT7_0  [1<< 8];
-// extern Uint8_t            LUT7_1  [1<< 8];
-// extern Uint8_t            LUTDSCF [1<< 6];
-
-// mppdec.c
-extern Float              Y_L      [36] [32];
-extern Float              Y_R      [36] [32];
-extern CPair_t            SCF_Index [3] [32];      // Scalefactor
-extern CPair_t            Res           [32];      // resolution steps of the subbands
-extern Quant_t            Q             [32];      // quantized samples
-extern CPair_t            SCFI          [32];      // transfer order of the SCF
-extern Bool_t             MS_Band       [32];      // subband-wise flag for M/S-signal guidance
-extern Bool_t             MS_used;                 // global flag for M/S-signal guidance
-extern Bool_t             IS_used;
-
-// requant.c
-extern Float              __SCF    [6 + 128];       // tabulated Scalefactors from -6 to +127
-#define SCF             ( __SCF + 6 )
-extern Int8_t             Q_bit         [32];       // number of bits to save the resolution (SV6)
-extern Int8_t             Q_res         [32] [16];  // Index -> resolution (SV6)
-extern Uint               Bitrate;
-extern Int                Min_Band;
-extern Float              __Cc          [1 + 18];
-extern const Uint         __Dc          [1 + 18];
-#define Cc              ( __Cc + 1 )
-#define Dc              ( __Dc + 1 )
-
-// synthtab.c
-extern const Float        Cos64         [32];
-extern const Float        Di_opt        [32] [16];
-
-// stderr.c
-
-
-//// procedures/functions //////////////////////////////////////////
-// cpu_feat.c
-Bool_t Cdecl  Has_MMX                 ( void );
-Bool_t Cdecl  Has_SIMD                ( void );
-Bool_t Cdecl  Has_SIMD2               ( void );
-Bool_t Cdecl  Has_3DNow               ( void );
-
-// decode.c
-void       Bitstream_init             ( void );
-Ulong      BitsRead                   ( void );
-Uint32_t   Bitstream_read             ( Int  bits );
-Uint32_t   Bitstream_peek             ( Uint pos, Int bits );
-void       Bitstream_skip             ( Uint bits );
-Uint32_t   Bitstream_preview          ( Int  bits );  // same as above, but data doesn't get receipted yet
-void       Read_Bitstream_SV6         ( void );
-void       Read_Bitstream_SV7         ( void );
-void       Read_Bitstream_SV8         ( void );
-
-// http.c
-int        http_open                  ( const char* URL );
-
-// huffsv7.c
-void       Init_Huffman_Decoder_SV7   ( void );
-
-// huffsv46.c
-void       Init_Huffman_Decoder_SV4_6 ( void );
-
-// id3tag.c
-Int        Read_ID3V1_Tags            ( FILE_T fp, TagInfo_t* tip );
-Int        Read_APE_Tags              ( FILE_T fp, TagInfo_t* tip );
-
-// requant.c
-void       Init_QuantTab              ( Int maximum_Band, Bool_t used_IS, Double amplification, Uint StreamVersion );
-
-// synth.c
-Uint32_t   random_int                 ( void );
-
-void Cdecl Calculate_New_V_i387       ( const Float* Sample, Float* V );
-void Cdecl Calculate_New_V_3DNow      ( const Float* Sample, Float* V );
-void Cdecl New_V_Helper2              ( Float* A, const Float* Sample );
-void Cdecl New_V_Helper3              ( Float* A, const Float* Sample );
-void Cdecl New_V_Helper4              ( Float* V );
-
-void Cdecl VectorMult_i387            ( void* buff, const Float* V );
-void Cdecl VectorMult_3DNow           ( void* buff, const Float* V );
-void Cdecl VectorMult_SIMD            ( void* buff, const Float* V );
-
-void       Synthese_Filter_16_C       ( Int2x16_t* Stream, Int* const offset, Float* Vi, const FloatArray* Yi );
-void       Synthese_Filter_32_C       ( Int2x32_t* Stream, Int* const offset, Float* Vi, const FloatArray* Yi, Uint channel );
-
-void Cdecl Reset_FPU                  ( void );
-void Cdecl Reset_FPU_3DNow            ( void );
-void Cdecl memcpy_dn_MMX              ( void* dst, const void* src, size_t words64byte  );
-void Cdecl memcpy_dn_SIMD             ( void* dst, const void* src, size_t words128byte );
-
-void       Init_Dither                ( Int bits, int shapingtype, Double dither );
-// void       OverdriveReport            ( void );
-SyntheseFilter16_t
-           Get_Synthese_Filter        ( void );
-
-// wave_out.c
-Int        Write_WAVE_Header          ( FILE_T outputFile, Ldouble SampleFreq, Uint BitsPerSample, Uint Channels, Ulong SamplesPerChannel );
-Int        Write_AIFF_Header          ( FILE_T outputFile, Ldouble SampleFreq, Uint BitsPerSample, Uint Channels, Ulong SamplesPerChannel );
-Int        Write_Raw_Header           ( FILE_T outputFile, Ldouble SampleFreq, Uint BitsPerSample, Uint Channels, Ulong SamplesPerChannel );
-Int        Set_DSP_OSS_Params         ( FILE_T outputFile, Ldouble SampleFreq, Uint BitsPerSample, Uint Channels );
-Int        Set_DSP_Sun_Params         ( FILE_T outputFile, Ldouble SampleFreq, Uint BitsPerSample, Uint Channels );
-Int        Set_ESD_Params             ( FILE_T dummyFile , Ldouble SampleFreq, Uint BitsPerSample, Uint Channels );
-Int        Set_WIN_Params             ( FILE_T dummyFile , Ldouble SampleFreq, Uint BitsPerSample, Uint Channels );
-Int        Set_IRIX_Params            ( FILE_T dummyFile , Ldouble SampleFreq, Uint BitsPerSample, Uint Channels );
-size_t     Write_PCM_2x16bit          ( FILE_T outputFile, Int2x16_t* data, size_t len );
-size_t     Write_PCM_HQ_2x16bit       ( FILE_T outputFile, Int2x32_t* data, size_t len );
-size_t     Write_PCM_HQ_2x24bit       ( FILE_T outputFile, Int2x32_t* data, size_t len );
-size_t     Write_PCM_HQ_2x32bit       ( FILE_T outputFile, Int2x32_t* data, size_t len );
-int        WIN_Play_Samples           ( const void* buff, size_t len );
-int        IRIX_Play_Samples          ( const void* buff, size_t len );
-int        WIN_Audio_close            ( void );
-int        IRIX_Audio_close           ( void );
-void       DisableSUID                ( void );
-void       EnableSUID                 ( void );
-
-// pipeopen.c
-FILE*      pipeopen                   ( const char* command, const char* filename );
-
-// stderr.c
-void       SetStderrSilent            ( Bool_t state );
-Bool_t     GetStderrSilent            ( void );
-int Cdecl  stderr_printf              ( const char* format, ... );
-
-// _setargv.c
-long       treewalk                   ( const char* start, const char** mask, int (*fn)(const char* filename, void* aux), void* aux );
-void       mysetargv                  ( int* argc, char*** argv, const char** extentions );
-
-#ifdef MPC_BIG_ENDIAN
-
-# define ReadLE32(dst,psrc)       dst = *(Uint32_t*)(psrc)
-# define ReadBE32(dst,psrc)                           \
-       ((Uint8_t*)&(dst))[0] = ((Uint8_t*)(psrc))[3], \
-       ((Uint8_t*)&(dst))[1] = ((Uint8_t*)(psrc))[2], \
-       ((Uint8_t*)&(dst))[2] = ((Uint8_t*)(psrc))[1], \
-       ((Uint8_t*)&(dst))[3] = ((Uint8_t*)(psrc))[0]
-
-
-#elif defined __i386__           /* 486+ */
-
-#  define ReadBE32(dst,psrc)      __asm__ ( "bswap %0" : "=r" (dst) : "0" (*(Uint32_t*)(psrc)) )
-#  define ReadLE32(dst,psrc)       dst = *(Uint32_t*)(psrc)
-
-# else
-
-#  define ReadBE32(dst,psrc)                          \
-       ((Uint8_t*)&(dst))[0] = ((Uint8_t*)(psrc))[3], \
-       ((Uint8_t*)&(dst))[1] = ((Uint8_t*)(psrc))[2], \
-       ((Uint8_t*)&(dst))[2] = ((Uint8_t*)(psrc))[1], \
-       ((Uint8_t*)&(dst))[3] = ((Uint8_t*)(psrc))[0]
-#  define ReadLE32(dst,psrc)       dst = *(Uint32_t*)(psrc)
-
-# endif
-
-#ifdef _MSC_VER
-#pragma warning ( disable : 4244 )
-#endif
-
-#endif /* MPPDEC_MPPDEC_H */
-
-/* end of mppdec.h */
Index: /libmpc/branches/r2d/mpcenc/pipeopen.c
===================================================================
--- /libmpc/branches/r2d/mpcenc/pipeopen.c	(revision 194)
+++ /libmpc/branches/r2d/mpcenc/pipeopen.c	(revision 195)
@@ -17,8 +17,8 @@
  */
 
-//#define DEBUG2
+#include <mpc/mpc_types.h>
+#include <ctype.h>
 
-#include "mppdec.h"
-#include <ctype.h>
+#include "mpcenc.h"
 
 
@@ -69,5 +69,5 @@
     strcpy ( p, executable_filename );
 #ifdef DEBUG2
-    stderr_printf ("Test for file »%s«        \n", filename );
+    stderr_printf ("Test for file %s        \n", filename );
 #endif
     fp = fopen ( filename, "rb" );
@@ -78,5 +78,5 @@
         fp = POPEN_READ_BINARY_OPEN ( cmdline );
 #ifdef DEBUG2
-        stderr_printf ("Executed »%s«\n", cmdline );
+        stderr_printf ("Executed %s\n", cmdline );
 #endif
    }
@@ -114,8 +114,8 @@
 
 /*
- *  Executes command line given by »command«.
+ *  Executes command line given by command.
  *  The command must be found in some predefined paths or in the ${PATH} aka %PATH%
- *  The char »#« in command is replaced by the contents
- *  of »filename«. Special characters are escaped.
+ *  The char # in command is replaced by the contents
+ *  of filename. Special characters are escaped.
  */
 
@@ -129,6 +129,6 @@
         "/usr/bin:/usr/local/bin:/opt/mpp:.";
 #endif
-    char          command_line        [4096];           // » -o - bar.pac«
-    char          executable_filename [4096];           // »foo.exe«
+    char          command_line        [4096];           //  -o - bar.pac
+    char          executable_filename [4096];           // foo.exe
     char*         p;
     const char*   q;
Index: /libmpc/branches/r2d/mpcenc/stderr.c
===================================================================
--- /libmpc/branches/r2d/mpcenc/stderr.c	(revision 194)
+++ /libmpc/branches/r2d/mpcenc/stderr.c	(revision 195)
@@ -2,5 +2,5 @@
  *  stderr - Message output system
  *
- *  (C) Frank Klemm, Janne Hyvärinen 2002. All rights reserved.
+ *  (C) Frank Klemm, Janne Hyvï¿œinen 2002. All rights reserved.
  *
  *  Principles:
@@ -20,15 +20,21 @@
  */
 
-#include "mppdec.h"
+#include <mpc/mpc_types.h>
+
 #ifdef _WIN32
 # include <windows.h>
 #endif
 
+#include <stdio.h>
+#include <stdarg.h>
+// #include "mpcenc.h"
 
-static Bool_t  stderr_silent = 0;
+#define WRITE(fp,ptr,len)      fwrite (ptr, 1, len, fp)     // WRITE   returns -1 or 0 on error/EOF, otherwise > 0
+
+static mpc_bool_t  stderr_silent = 0;
 
 
 void
-SetStderrSilent ( Bool_t state )
+SetStderrSilent ( mpc_bool_t state )
 {
     stderr_silent = state;
@@ -36,5 +42,5 @@
 
 
-Bool_t
+mpc_bool_t
 GetStderrSilent ( void )
 {
@@ -43,8 +49,8 @@
 
 
-int Cdecl
+int mpc_cdecl
 stderr_printf ( const char* format, ... )
 {
-    char     buff [2 * PATHLEN_MAX + 3072];
+    char     buff [2 * 1024 + 3072];
     char*    p = buff;
     char*    q;
@@ -61,5 +67,5 @@
 #if   defined __unix__  ||  defined __UNIX__
 
-        WRITE ( STDERR, buff, ret );
+        WRITE ( stderr, buff, ret );
 
 #elif defined _WIN32
@@ -89,9 +95,9 @@
         if ( hSTDERR == INVALID_HANDLE_VALUE ) {
             while ( ( q = strchr (p, '\n')) != NULL ) {
-                WRITE ( STDERR, p, q-p );
-                WRITE ( STDERR, "\r\n", 2 );
+                WRITE ( stderr, p, q-p );
+                WRITE ( stderr, "\r\n", 2 );
                 p = q+1;
             }
-            WRITE ( STDERR, p, strlen (p) );
+            WRITE ( stderr, p, strlen (p) );
         }
         else {
@@ -165,9 +171,9 @@
         // for non-Unix systems we must merge carriage returns into the stream to avoid staircases
         while ( ( q = strchr (p, '\n')) != NULL ) {
-            WRITE ( STDERR, p, q-p );
-            WRITE ( STDERR, "\r\n", 2 );
+            WRITE ( stderr, p, q-p );
+            WRITE ( stderr, "\r\n", 2 );
             p = q+1;
         }
-        WRITE ( STDERR, p, strlen (p) );
+        WRITE ( stderr, p, strlen (p) );
 
 #endif
Index: /libmpc/branches/r2d/mpcenc/tags.c
===================================================================
--- /libmpc/branches/r2d/mpcenc/tags.c	(revision 194)
+++ /libmpc/branches/r2d/mpcenc/tags.c	(revision 195)
@@ -60,10 +60,10 @@
 
 struct APETagFooterStruct {
-    Uint8_t   ID       [8];    // should equal 'APETAGEX'
-    Uint8_t   Version  [4];    // currently 1000 (version 1.000)
-    Uint8_t   Length   [4];    // the complete size of the tag, including this footer
-    Uint8_t   TagCount [4];    // the number of fields in the tag
-    Uint8_t   Flags    [4];    // the tag flags (none currently defined)
-    Uint8_t   Reserved [8];    // reserved for later use
+    mpc_uint8_t   ID       [8];    // should equal 'APETAGEX'
+    mpc_uint8_t   Version  [4];    // currently 1000 (version 1.000)
+    mpc_uint8_t   Length   [4];    // the complete size of the tag, including this footer
+    mpc_uint8_t   TagCount [4];    // the number of fields in the tag
+    mpc_uint8_t   Flags    [4];    // the tag flags (none currently defined)
+    mpc_uint8_t   Reserved [8];    // reserved for later use
 };
 
@@ -608,5 +608,5 @@
         return 0;
 
-	if ( src [0] != 0xFF  ||  src [1] != 0xFE )                 // Microsoft Unicode preample (also useful to detect endianess, but currently only little endian is supported)
+	if ( src [0] != (char)0xFF  ||  src [1] != (char)0xFE )     // Microsoft Unicode preample (also useful to detect endianess, but currently only little endian is supported)
         return 0;
 
@@ -614,5 +614,5 @@
         if ( ( src [1] & 0xFC ) == 0xDC )
             return 0;
-        if ( src [1] == 0xFF  &&  ( src [0] & 0xFE ) == 0xFE )
+		if ( src [1] == (char)0xFF  &&  ( src [0] & 0xFE ) == 0xFE )
             return 0;
         if ( ( src [1] & 0xFC ) == 0xD8 ) {
@@ -796,5 +796,5 @@
 
 
-static int Cdecl
+static int mpc_cdecl
 cmpfn2 ( const void* p1, const void* p2 )
 {
@@ -910,7 +910,7 @@
 CopyTags_ID3 ( FILE* fp )
 {
-    Uint8_t  tmp [128];
-
-    if ( -1 == SEEK ( fp, -128L, SEEK_END ) )
+    mpc_uint8_t  tmp [128];
+
+    if ( -1 == fseek ( fp, -128L, SEEK_END ) )
         return -1;
 
@@ -948,8 +948,8 @@
 Read_LE_Uint32 ( const unsigned char* p )
 {
-    return ((Uint32_t)p[0] <<  0) |
-           ((Uint32_t)p[1] <<  8) |
-           ((Uint32_t)p[2] << 16) |
-           ((Uint32_t)p[3] << 24);
+    return ((mpc_uint32_t)p[0] <<  0) |
+           ((mpc_uint32_t)p[1] <<  8) |
+           ((mpc_uint32_t)p[2] << 16) |
+           ((mpc_uint32_t)p[3] << 24);
 }
 
@@ -958,16 +958,15 @@
 CopyTags_APE ( FILE* fp )
 {
-    Uint32_t                   len;
-    Uint32_t                   flags;
-    Uint32_t                   version;
+    mpc_uint32_t               len;
+    mpc_uint32_t               flags;
+    mpc_uint32_t               version;
     unsigned char              buff [32768];
     unsigned char              key [257];
     unsigned char*             p;
     struct APETagFooterStruct  T;
-    Uint32_t                   TagLen;
-    Uint32_t                   TagCount;
-    // Uint32_t                   tmp;
-
-    if ( -1 == SEEK ( fp, -(long)sizeof T, SEEK_END ) )
+    mpc_uint32_t               TagLen;
+    mpc_uint32_t               TagCount;
+
+    if ( -1 == fseek ( fp, -(long)sizeof T, SEEK_END ) )
         return -1;
     if ( sizeof(T) != READ ( fp, &T, sizeof T ) )
@@ -981,5 +980,5 @@
     if ( TagLen <= sizeof T )
         return -1;
-    if ( -1 == SEEK ( fp, -(long)TagLen, SEEK_END ) )
+    if ( -1 == fseek ( fp, -(long)TagLen, SEEK_END ) )
         return -1;
     memset ( buff, 0, sizeof(buff) );
Index: /libmpc/branches/r2d/mpcenc/wave_in.c
===================================================================
--- /libmpc/branches/r2d/mpcenc/wave_in.c	(revision 194)
+++ /libmpc/branches/r2d/mpcenc/wave_in.c	(revision 195)
@@ -32,18 +32,4 @@
 #endif
 
-
-#if defined USE_OSS_AUDIO  ||  defined USE_ESD_AUDIO  ||  defined USE_SUN_AUDIO
-static void
-Set_Realtime ( void )
-{
-# if defined USE_NICE
-    seteuid     ( 0 );
-    setpriority ( PRIO_PROCESS, getpid(), -20 );
-    seteuid     ( getuid() );
-# endif
-}
-#endif /* USE_OSS_AUDIO || USE_ESD_AUDIO || USE_SUN_AUDIO */
-
-
 #define EXT(x)  (0 == strcasecmp (ext, #x))
 
@@ -59,76 +45,4 @@
         fp = SETBINARY_IN ( stdin );
     }
-#ifndef _WIN32
-#ifndef NO_DEV_AUDIO
-    else if ( 0 == strncmp ( filename, "/dev/", 5) ) {
-        int          fd;
-        int          arg;
-        int          org;
-
-        fd = open (filename, O_RDONLY);
-        if ( fd < 0 )
-            return -1;
-
-        type->Channels = org = arg = 2;
-        if ( -1 == ioctl ( fd, SOUND_PCM_WRITE_CHANNELS, &arg ) )
-            return -1;
-        if (arg != org)
-            return -1;
-
-        type->BitsPerSample = org = arg = 16;
-        type->BytesPerSample = 2;
-        if ( -1 == ioctl ( fd, SOUND_PCM_WRITE_BITS, &arg ) )
-            return -1;
-        if (arg != org)
-            return -1;
-
-        org = arg = AFMT_S16_LE;
-        if ( -1 == ioctl ( fd, SNDCTL_DSP_SETFMT, &arg ) )
-            return -1;
-        if ((arg & org) == 0)
-            return -1;
-
-        type->SampleFreq = org = arg = 44100.;
-        if ( -1 == ioctl ( fd, SOUND_PCM_WRITE_RATE, &arg ) )
-            return -1;
-        if ( 23.609375 * abs(arg-org) > abs(arg+org) )    // Sample frequency: Accept 40.5...48.0 kHz for 44.1 kHz
-            return -1;
-
-        type->raw        = 1;
-        type->PCMOffset  = 0;
-        type->PCMBytes   = 0xFFFFFFFF;
-        type->PCMSamples = 86400 * type->SampleFreq;
-
-        fp = fdopen (fd, "rb");
-        Set_Realtime ();
-    }
-#endif
-#else
-    else if ( 0 == strncmp ( filename, "/dev/audio", 10 ) ) {
-        int     tmp;
-        int     fs  = 44100;
-        double  dur = 86400.;
-
-        sscanf ( filename, "%*[^:]:%u:%lf", &fs, &dur );
-
-        fp                     = (FILE*)-1;
-        type -> Channels       =  2;
-        type -> BitsPerSample  = 16;
-        type -> BytesPerSample =  2;
-        type -> SampleFreq     = fs;
-        type -> PCMOffset      =  0;
-        type -> PCMBytes       = 0xFFFFFFFF;
-        type -> PCMSamples     = dur * type -> SampleFreq;
-        type -> raw            = 1;
-        tmp  = init_in ( 1152, (int) floor (type -> SampleFreq + 0.5), type -> Channels, type -> BitsPerSample );
-        if ( tmp )
-            return -1;
-# if   defined USE_REALTIME
-        SetPriorityClass ( GetCurrentProcess (), REALTIME_PRIORITY_CLASS );
-# elif defined USE_NICE
-        SetPriorityClass ( GetCurrentProcess (), HIGH_PRIORITY_CLASS );
-# endif
-    }
-#endif
     else if ( ext == NULL ) {
         fp = NULL;
@@ -454,5 +368,5 @@
     if (type->PCMBytes >= 0xFFFFFF00  ||
 			type->PCMBytes == 0  ||
-			(Uint32_t)type->PCMBytes % (type -> Channels * type->BytesPerSample) != 0) {
+			(mpc_uint32_t)type->PCMBytes % (type -> Channels * type->BytesPerSample) != 0) {
 		type->PCMSamples = 36000000 * type->SampleFreq;
 	}
Index: /libmpc/branches/r2d/mpcgain/mpcgain.c
===================================================================
--- /libmpc/branches/r2d/mpcgain/mpcgain.c	(revision 194)
+++ /libmpc/branches/r2d/mpcgain/mpcgain.c	(revision 195)
@@ -34,5 +34,5 @@
 #include <stdio.h>
 #include <math.h>
-#include <mpcdec/mpcdec.h>
+#include <mpc/mpcdec.h>
 #include <mpc/minimax.h>
 #include <replaygain/gain_analysis.h>
