Index: libmpc/branches/r2d/mpcenc/mpcenc.h
===================================================================
--- libmpc/branches/r2d/mpcenc/mpcenc.h	(revision 173)
+++ 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 */
