Only in lame.20001203: DEFINES
diff -duHr lame.20001203/Makefile.B32 lame.org/Makefile.B32
--- lame.20001203/Makefile.B32	Thu Nov 30 11:22:05 2000
+++ lame.org/Makefile.B32	Mon Dec  4 15:32:28 2000
@@ -22,7 +22,7 @@
 ##########################################################################
 # -DHAVEMPGLIB compiles the mpglib *decoding* library into libmp3lame
 ##########################################################################
-CPP_OPTS = $(CPP_OPTS) -DHAVE_MPGLIB 
+CPP_OPTS = $(CPP_OPTS) -DHAVEMPGLIB 
 
 
 ##########################################################################
@@ -71,7 +71,7 @@
 # Define these in the OS specific sections below to compile in code for
 # the GTK mp3 frame analyzer
 #
-# Requires  -DHAVE_MPGLIB
+# Requires  -DHAVEMPGLIB
 # and SNDLIB = -DLAME or -DLIBSNDFILE
 #
 # GTK = -DHAVEGTK `gtk-config --cflags`
@@ -102,7 +102,7 @@
 # LIBSNDFILE= -L $(LIBSNDHOME) sndfile.lib -I $(LIBSNDHOME)
 
 # uncomment to compile in Vorbis support
-# VORBIS = -DHAVE_VORBIS -I ../vorbis/include
+# VORBIS = -DHAVEVORBIS -I ../vorbis/include
 # VORBIS_LIB = -L ../vorbis/lib vorbis.lib
 
 # for debugging:
@@ -112,7 +112,7 @@
 # FEATURES = -DRH_NOISE_CALC
 
 
-CC_SWITCHES = -DHAVE_CONFIG_MS_H -DNDEBUG $(CC_OPTS) $(SNDLIB) $(GTK) $(BRHIST_SWITCH) $(VORBIS) 
+CC_SWITCHES = -DNDEBUG $(CC_OPTS) $(SNDLIB) $(GTK) $(BRHIST_SWITCH) $(VORBIS) 
 frontend_sources = \
         frontend/brhist.c \
 	frontend/get_audio.c \
diff -duHr lame.20001203/Makefile.MSVC lame.org/Makefile.MSVC
--- lame.20001203/Makefile.MSVC	Wed Nov 29 16:44:49 2000
+++ lame.org/Makefile.MSVC	Mon Dec  4 16:30:28 2000
@@ -1,52 +1,20 @@
-#	Makefile.MSVC: MSVC Makefile for LAME 3.88
+# Makefile.MSVC: MSVC Makefile for LAME 3.88
 #
-#	2000-11-21 Robert Hegemann  e-mail: Robert.Hegemann@gmx.de
-#	dedicated to the LAME project http://www.mp3dev.org
+# 2000-11-21 Robert Hegemann  e-mail: Robert.Hegemann@gmx.de
+# dedicated to the LAME project http://www.mp3dev.org
 ###############################################################################
 
-
-
-#__ readme ____________________________________________________________________
-#	nmake -f Makefile.MSVC
-#		-> build lame and dll, but not mp3x
-#		-> use Robert's code modifications
-#		-> assume INTEL compiler available  
-#		-> assume NASM available
-#		-> assemble MMX code with NASM
-#		-> optimize for PIII
-#		-> single file optimizations
-#		-> no compiler warnings
-#
-#	passing arguments, one can modify the default behaviour:
-#	COMP=<anything but INTEL>  ->  use MS compiler
-#	WARN=<anything but OFF>    ->  give verbose compiler warnings
-#	OPT=<NORMAL,EXTRA,ULTRA>   ->  different Intel optimizations
-#	ASM=<anything but YES>     ->  no NASM nor MMX
-#	MMX=<anything but YES>     ->  do not assemble MMX code
-#	CFG=<anything but RH>      ->  disable Robert's modifications
-#	OGG=<anything>             ->  have Vorbis library, use it
-#	CPU=P1                     ->  optimize for Pentium instead of P II/III
-#	GTK=YES                    ->  have GTK, adds mp3x to default targets
-#
-#	Example:
-#	nmake -f Makefile.MSVC CPU=P1 GTK=YES
-#____________________________________________________________________ readme __
-
-
-
-#	targets <-> DOS filenames
+# targets <-> DOS filenames
 T_LAME = lame.exe
 T_LDLL = lame_enc.dll
 T_MP3X = mp3x.exe
 
-#	default targets
+# default targets
 PGM = $(T_LAME) $(T_LDLL)
 
-#	some default settings
+# some default settings
 
-!	IF "$(COMP)" == ""
 COMP = INTEL
-!	ENDIF
 
 !	IF "$(ASM)" == ""
 ASM = YES
@@ -68,27 +36,25 @@
 OPT = NORMAL
 !	ENDIF
 
-!	IF "$(WARN)" == ""
-WARN = OFF
-!	ENDIF
-
 
 !	MESSAGE ----------------------------------------------------------------------
 !	MESSAGE building LAME featuring $(CFG)
 !	IF "$(ASM)" == "YES"
 !	MESSAGE + ASM
+!	ENDIF 
 !	IF "$(MMX)" == "YES"
 !	MESSAGE + MMX
 !	ENDIF 
-!	ENDIF 
 !	IF "$(GTK)" == "YES"
 !	MESSAGE + GTK
 !	ENDIF 
-!	IF "$(OGG)" != ""
-!	MESSAGE + Ogg-Vorbis
-!	ENDIF 
 !	IF "$(COMP)" == "INTEL"
 !	MESSAGE using INTEL COMPILER
+!	IF "$(CPU)" == "P1"
+!	MESSAGE + optimizing for Pentium (MMX) (may slow down PIII a few percent)
+!	ELSE
+!	MESSAGE + optimizing for Pentium II/III (slows down Pentium a few percent)
+!	ENDIF
 !	IF "$(OPT)" == "NORMAL"
 !	MESSAGE + perform single-file optimizations
 !	ENDIF
@@ -98,139 +64,82 @@
 !	IF "$(OPT)" == "ULTRA"
 !	MESSAGE + perform multi-file optimizations over entire program
 !	ENDIF
-!	ELSE
-!	MESSAGE using MS COMPILER
-!	ENDIF
-!	IF "$(CPU)" == "P1"
-!	MESSAGE + optimizing for Pentium (MMX) (may slow down PIII a few percent)
-!	ELSE
-!	MESSAGE + optimizing for Pentium II/III (slows down Pentium a few percent)
 !	ENDIF
 !	MESSAGE ----------------------------------------------------------------------
 
-
-
 !	IF "$(COMP)" != "INTEL"
-
-#__ Microsoft C options _______________________________________________________
-#
-#	/O2     maximize speed
-#	/Ob<n>  inline expansion
-#	/Og     enable global optimizations
-#	/Oi     enable intrinsic functions
-#	/Ot     favor code speed
-#	/Oy     enable frame pointer omission
-#	/G5     Pentium optimization
-#	/G6     Pentium II/III optimization
-#	/GA     optimize for Windows Application
-#	/GF     enable read-only string pooling
-#	/Gf     enable string spooling
-#	/Gs     disable stack checking calls
-#	/Gy     separate functions for linker
-#	/QIfdiv generate code for Pentium FDIV fix
-#	/QI0f   generate code for Pentium 0x0f erratum fix
-#
-#	remarks: 
-#	 - aliasing options seem to break code
-#	 - try to get the Intel compiler demonstration code!
-#	   ICL produces faster code.
+# Microsoft C options
+CC = cl
+LN = link
 
 # debugging options
 # CC_OPTS = /nologo /Zi /Ge /GZ
 # LN_OPTS = /nologo /debug:full /debugtype:cv /fixed:no
 
 # profiling options
-# CC_OPTS = /nologo /Zi /O2b2gity /G6AFs /DNDEBUG 
+# CC_OPTS = /nologo /Zi /O2ab2gitwy /G6AFs /DNDEBUG 
 # LN_OPTS = /nologo /debug:full /debugtype:cv /fixed:no /profile
 
 # release options
-CC_OPTS = /nologo /DNDEBUG /O2 /Ob2 /GAfy /Gs1024 /QIfdiv /QI0f /YX
-LN_OPTS = /nologo /DNDEBUG
-
-!	IF "$(CPU)" == "P1"
-CC_OPTS = $(CC_OPTS) /G5
-!	ELSE
-CC_OPTS = $(CC_OPTS) /G6
-!	ENDIF
-
-!	IF "$(WARN)" == "OFF"
-CC_OPTS = $(CC_OPTS) /w
-!	ELSE
-CC_OPTS = $(CC_OPTS) /W2 /Wport
-!	ENDIF
-
-LN_DLL = /LD
-LN_OUT = /Fe
-CC_OUT = /Fo
+CC_OPTS = /nologo /O2ab2gitwy /G6AFs /DNDEBUG 
+LN_OPTS = /nologo
 
-CC = cl
-LN = cl
-#_______________________________________________________ Microsoft C options __
+LN_DLL = /DLL
+LN_OUT = /OUT:
 
 !	ELSE
 
 #__ Intel 4.5 options _________________________________________________________
+#CC_OPTS = /nologo /DNDEBUG /Qunroll /O2 /G5AFs /QaxM /Qipo_obj /QIfist- 
+# /YX         enable automatic precompiled header file creation/usage
+# /Ox         maximum optimization
+# /Ow         assume no aliasing within functions, but across calls
+# /Gd      1) make cdecl the default calling convention
+# /G5      2) optimized for Pentium
+# /G6      3) optimized for Pentium II/III
+# /GA         assume single threaded
+# /Gs[n]      disable stack checks for functions with < n bytes of locals
+# /GF     	  read-only string pooling optimization
+# /Qunroll    unroll loops with default heuristic
+# /QIfist     enable fast float to int conversion
+# /QIfdiv     enable patch for Pentium with FDIV erratum
+# /QI0f	 	  enable patch for Pentium with 0f erratum
+# /Qip     2) enable single-file IP optimizations (within files)
+# /Qipo       enable multi-file IP optimizations (between files)
+# /Qipo_wp 4) enable entire program multi-file IP optimizations
+# /QaxiMK     automatic use of specialized code for PII/III, MMX, SIMD
 #
-#	/YX         enable automatic precompiled header file creation/usage
-#	/Ox         maximum optimization same as /O2 without /Gfy
-#	/O2         same as /Gfsy /Ob1gyti
-#	/Gd      1) make cdecl the default calling convention
-#	/G5      2) optimized for Pentium
-#	/G6      3) optimized for Pentium II/III
-#	/GA         assume single threaded
-#	/Gs[n]      disable stack checks for functions with <n bytes of locals
-#	/GF         read-only string pooling optimization
-#	/Gy         separate functions for the linker 
-#	/Qunroll    unroll loops with default heuristic
-#	/QIfist     enable fast float to int conversion
-#	/QIfdiv     enable patch for Pentium with FDIV erratum
-#	/QI0f       enable patch for Pentium with 0f erratum
-#	/Qip     2) enable single-file IP optimizations (within files)
-#	/Qipo       enable multi-file IP optimizations (between files)
-#	/Qipo_wp 4) enable entire program multi-file IP optimizations
-#	/QaxiMK     automatic use of specialized code for PII/III, MMX, SIMD
-#
-#	remarks: 
-#	1) slows speed down, not using
-#	2) faster compared to 3) or 4) on Pentium MMX at 200 MHz
+# remarks: 
+# 1) slows speed down, not using
+# 2) faster compared to 3) or 4) on Pentium MMX at 200 MHz
 
 !	IF "$(CPU)" == "P1"
-CC_OPTS = /G5
+CCOPTS = /G5
 !	ELSE
-CC_OPTS = /G6
+CCOPTS = /G6
 !	ENDIF
-
 !	IF "$(OPT)" == "NORMAL"
-CC_OPTS = $(CC_OPTS) /Qip
+CCOPTS = $(CCOPTS) /Qip
 !	ELSE
 !	IF "$(OPT)" == "EXTRA"
-#	resulting exe seems to be not faster than with NORMAL
-CC_OPTS = $(CC_OPTS) /Qip /Qipo
+CCOPTS = $(CCOPTS) /Qip /Qipo
 !	ELSE
 !	IF "$(OPT)" == "ULTRA"
-#	resulting exe seems to be not faster than with NORMAL
-CC_OPTS = $(CC_OPTS) /Qip /Qipo_wp
-!	ENDIF
+CCOPTS = $(CCOPTS) /Qip /Qipo_wp
 !	ENDIF
 !	ENDIF
-
-!	IF "$(WARN)" == "OFF"
-CC_OPTS = $(CC_OPTS) /w
-!	ELSE
-CC_OPTS = $(CC_OPTS) /W2 /Wport
 !	ENDIF
 
-CC_OPTS = /nologo /DNDEBUG /YX /GA /O2 /Gs1024 \
-          /Qunroll /Qsox- /QIfist /QIfdiv /QI0f /QaxiMK $(CC_OPTS)
+CC_OPTS = /nologo /DNDEBUG /YX /Ox /GA /Gs1024 /GF \
+          /Qunroll /QIfist /QIfdiv /QI0f /QaxiMK $(CCOPTS) 
 
-LN_OPTS = $(CC_OPTS)
+LN_OPTS = $(CC_OPTS) 
 LN_DLL = /LD
 LN_OUT = /Fe
-CC_OUT = /Fo
 
 CC = icl
 LN = icl
-#_________________________________________________________ Intel 4.5 options __
+#--------------------------------------------------------- Intel 4.5 options --
 
 !	ENDIF
 
@@ -247,19 +156,17 @@
 
 
 
-#__ FRAME ANALYZER SUPPORT ____________________________________________________
-#
-#	Assuming you have "glib-dev" and "gtk+-dev" installed and the system
-#	DLLs "glib-1.3.dll", "gdk-1.3.dll" and "gtk-1.3.dll" copied into the
-#	"Win\System" folder
+#== FRAME ANALYZER SUPPORT ====================================================
+# assuming you have "glib-dev" and "gtk+-dev" installed
+# and the system DLLs "glib-1.3.dll", "gdk-1.3.dll" and "gtk-1.3.dll"
+# copied into the "Win\System" folder
 #
-#	To compile in the frame analyzer support, you need the above mentioned
-#	libraries. You can pass the appropriate path to them in GTK_DIRS.
+# to compile in the frame analyzer support,
+# you need the above mentioned libraries 
+# and to uncomment the following lines
 #
 !	IF "$(GTK)" == "YES"
-!	IF "$(GTK_DIRS)" == ""
 GTK_DIRS = ../src
-!	ENDIF
 GTK_OPTS = -I$(GTK_DIRS)/glib     \
            -I$(GTK_DIRS)/gtk+     \
            -I$(GTK_DIRS)/gtk+/gtk \
@@ -267,51 +174,53 @@
 GTK_LIBS = $(GTK_DIRS)/gtk+/gtk/gtk-1.3.lib \
            $(GTK_DIRS)/gtk+/gdk/gdk-1.3.lib \
            $(GTK_DIRS)/glib/glib-1.3.lib
-
+             
 PGM = $(T_MP3X) $(PGM)
 !	ELSE
 !	IF "$(GTK)" == ""
 !	MESSAGE Pass GTK=YES to build the frame analyzer. (requires installed GTK)
 !	ENDIF
 !	ENDIF
-#____________________________________________________ FRAME ANALYZER SUPPORT __
+#==================================================== FRAME ANALYZER SUPPORT ==
 
 
 
-#__ VORBIS SUPPORT ____________________________________________________________
-!	IF "$(OGG)" != ""
-VORBIS = /DHAVE_VORBIS -I../vorbis/include
-VORBISLIB = ../vorbis/lib/vorbis.lib
-!	ENDIF
-#____________________________________________________________ VORBIS SUPPORT __
+#== VORBIS SUPPORT ============================================================
+#
+# uncomment the following if you have Vorbis
+#
+#VORBIS = /DHAVE_VORBIS -I../vorbis/include
+#VORBISLIB = ../vorbis/lib/vorbis.lib
+#============================================================ VORBIS SUPPORT ==
 
 
 
-#__ MPG123 DECODING ___________________________________________________________
+#== MPG123 DECODING ===========================================================
 #
 #	uncomment the following if you want decoding support
-#	It's always a good idea to compile it in!
 #
 CPP_OPTS = $(CPP_OPTS) /DHAVE_MPGLIB /DUSE_LAYER_1 /DUSE_LAYER_2
-#___________________________________________________________ MPG123 DECODING __
+#=========================================================== MPG123 DECODING ==
 
 
 
-#__ Takehiro's IEEE hack ______________________________________________________
+#== Takehiro's IEEE hack ======================================================
 #
 #	uncomment the following to enable Takehiro's IEEE hack
-#	You'll want it on a x86 machine with i387 FPU
 #
 CPP_OPTS = $(CPP_OPTS) /DTAKEHIRO_IEEE754_HACK
-#______________________________________________________ Takehiro's IEEE hack __
+#====================================================== Takehiro's IEEE hack ==
 
 
 
-#__ Robert's alternate code ___________________________________________________
+#== Robert's alternate code ===================================================
+#
+#	uncomment the following to enable some alternate code
+#
 !	IF "$(CFG)" == "RH"
 CPP_OPTS = $(CPP_OPTS) /DRH_AMP /DRH
 !	ENDIF
-#___________________________________________________ Robert's alternate code __
+#=================================================== Robert's alternate code ==
 
 
 
@@ -321,23 +230,23 @@
 LN_SWITCHES = $(LN_OPTS)
 
 lame_sources = \
-	frontend/main.c
+	frontend/main.c  
 
 mpx_sources = \
 	frontend/gpkplotting.c \
 	frontend/gtkanal.c \
-	frontend/mp3x.c
+	frontend/mp3x.c 
 
 dll_sources = \
 	dll/BladeMP3EncDll.c
-
+	
 common_sources = \
 	frontend/portableio.c \
 	frontend/get_audio.c \
 	frontend/parse.c \
 	frontend/timestatus.c \
 	frontend/lametime.c \
-	frontend/brhist.c
+	frontend/brhist.c 
 
 lamelib_sources = \
 	libmp3lame/bitstream.c \
@@ -357,7 +266,7 @@
 	libmp3lame/vorbis_interface.c \
 	libmp3lame/mpglib_interface.c \
 	libmp3lame/VbrTag.c \
-	libmp3lame/version.c
+	libmp3lame/version.c 
 
 mpglib_sources = \
 	mpglib/common.c \
@@ -367,7 +276,7 @@
 	mpglib/layer2.c \
 	mpglib/layer3.c \
 	mpglib/tabinit.c \
-	mpglib/interface.c
+	mpglib/interface.c 
 
 
 
@@ -384,7 +293,7 @@
 	@echo --=*  $(PGM) uptodate  *=--
 	@echo.
 
-#__ NASM ______________________________________________________________________
+#== NASM ======================================================================
 #
 #	NASM: Netwide Assembler
 #
@@ -394,19 +303,15 @@
 	@nasmw -f win32 -i libmp3lame/i386/ -DWIN32 \
 		libmp3lame/i386/cpu_feat.nas \
 		-o libmp3lame/i386/cpu_feat.obj
-
+                
 CC_SWITCHES = $(CC_SWITCHES) /DHAVE_NASM
 ASM_OBJ = $(ASM_OBJ) libmp3lame/i386/cpu_feat.obj
 !	ENDIF
-#______________________________________________________________________ NASM __
-
-
+#====================================================================== NASM ==
 
-#__ MMX _______________________________________________________________________
+#== MMX =======================================================================
 #
-#	you need NASM but *not necessarily* a processor with MMX
-#	The above CPU feature detection code allows to run the same
-#	binary on a CPU without MMX too!
+#	you have NASM and a processor with MMX 
 #
 !	IF "$(ASM)" == "YES"
 !	IF "$(MMX)" == "YES"
@@ -420,42 +325,42 @@
 ASM_OBJ = $(ASM_OBJ) libmp3lame/i386/choose_table.obj
 !	ENDIF
 !	ENDIF
-#_______________________________________________________________________ MMX __
+#======================================================================= MMX ==
 
 !	MESSAGE
 
 
-
 config.h : configMS.h
 	@-copy configMS.h config.h
 
+
 .c.obj: 
 	@$(CC) $(CPP_OPTS) $(CC_SWITCHES) -Iinclude -Ilibmp3lame \
-	       /c $< $(CC_OUT)$@
+	       /c $< /Fo$@
 
 $(MPX_OBJ) : $(mpx_sources)
 	@$(CC) $(CPP_OPTS) $(CC_SWITCHES) $(GTK_OPTS) \
-	       -Iinclude -Impglib -Ilibmp3lame /c $** $(CC_OUT)frontend/
+	       -Iinclude -Impglib -Ilibmp3lame /c $** /Fofrontend/
 	@echo.
 	@echo --- FRAME ANALYZER STUFF READY ---
 	@echo.
 
 $(CMMN_OBJ): $(common_sources) 
-	@$(CC) $(CPP_OPTS) $(CC_SWITCHES) -Iinclude /c $** $(CC_OUT)frontend/
+	@$(CC) $(CPP_OPTS) $(CC_SWITCHES) -Iinclude /c $** /Fofrontend/
 	@echo.
 	@echo --- COMMON FRONTEND STUFF UPTODATE ---
 	@echo.
 
 $(LIB_OBJ) : $(lamelib_sources)
 	@$(CC) $(CPP_OPTS) $(CC_SWITCHES) \
-	       -Iinclude -Impglib /c $** $(CC_OUT)libmp3lame/
+	       -Iinclude -Impglib /c $** /Folibmp3lame/
 	@echo.
 	@echo --- LAME MP3 ENCODING LIBRARY UPTODATE ---
 	@echo.
 
 $(MPG_OBJ) : $(mpglib_sources)
 	@$(CC) $(CPP_OPTS) $(CC_SWITCHES) \
-	       -Iinclude -Ilibmp3lame /c $** $(CC_OUT)mpglib/
+	       -Iinclude -Ilibmp3lame /c $** /Fompglib/
 	@echo.
 	@echo --- MPG123 DECODING LIBRARY UPTODATE ---
 	@echo.
@@ -467,7 +372,7 @@
 	       $(ASM_OBJ) $(LIB_OBJ) $(MPG_OBJ) $(CMMN_OBJ) $(LAME_OBJ) \
 		   $(LN_OUT)$@
 	@echo.
-	@echo --=*  $@ ready  *=--
+	@echo --=*  $(T_LAME) ready  *=--
 	@echo.
 
 $(T_LDLL) : config.h lib $(CMMN_OBJ) $(DLL_OBJ)
@@ -475,7 +380,7 @@
 	       $(ASM_OBJ) $(LIB_OBJ) $(MPG_OBJ) $(DLL_OBJ) \
 		   $(LN_DLL) $(LN_OUT)$@
 	@echo.
-	@echo --=*  $@ ready  *=--
+	@echo --=*  $(T_LDLL) ready  *=--
 	@echo.
 	
 $(T_MP3X) : config.h lib $(CMMN_OBJ) $(MPX_OBJ)
@@ -483,7 +388,7 @@
 	       $(ASM_OBJ) $(LIB_OBJ) $(MPG_OBJ) $(CMMN_OBJ) $(MPX_OBJ) \
 		   $(LN_OUT)$@
 	@echo.
-	@echo --=*  $@ ready  *=--
+	@echo --=*  $(T_MP3X) ready  *=--
 	@echo.
 
 clean:
@@ -499,8 +404,6 @@
 
 rebuild: clean all
 
-
 lame	:	$(T_LAME)
 dll 	:	$(T_LDLL)
 mp3x	:	$(T_MP3X)
-
diff -duHr lame.20001203/config.h.in lame.org/config.h.in
--- lame.20001203/config.h.in	Thu Nov 30 11:20:12 2000
+++ lame.org/config.h.in	Mon Dec  4 15:32:29 2000
@@ -67,9 +67,6 @@
    byte first (like Motorola and SPARC, unlike Intel and VAX).  */
 #undef WORDS_BIGENDIAN
 
-/* The number of bytes in a int.  */
-#undef SIZEOF_INT
-
 /* The number of bytes in a unsigned long.  */
 #undef SIZEOF_UNSIGNED_LONG
 
diff -duHr lame.20001203/configMS.h lame.org/configMS.h
--- lame.20001203/configMS.h	Thu Nov 30 11:20:12 2000
+++ lame.org/configMS.h	Mon Dec  4 15:32:29 2000
@@ -1,6 +1,3 @@
-/* The number of bytes in a int.  */
-#define SIZEOF_INT 4
-
 /* The number of bytes in a unsigned long.  */
 #define SIZEOF_UNSIGNED_LONG 4
 
diff -duHr lame.20001203/configure.in lame.org/configure.in
--- lame.20001203/configure.in	Thu Nov 30 11:20:23 2000
+++ lame.org/configure.in	Mon Dec  4 15:32:30 2000
@@ -1,4 +1,4 @@
-dnl $Id: configure.in,v 1.38 2000/11/30 10:08:24 aleidinger Exp $
+dnl $Id: configure.in,v 1.40 2000/12/03 23:00:10 markt Exp $
 dnl
 dnl Process this file with autoconf to produce a configure script.
 dnl
@@ -87,7 +87,6 @@
 AC_C_CONST
 AC_C_INLINE
 AC_CHECK_SIZEOF(unsigned long)
-AC_CHECK_SIZEOF(int)
 AC_TYPE_SIZE_T
 AC_HEADER_TIME
 
@@ -540,13 +539,7 @@
     CONFIG_DEBUG="${enableval}", CONFIG_DEBUG="no")
 
 if test "x$GCC" = "xyes"; then
-	DEBUG_NORM_OPT="-O -ggdb -W -Wall -Wbad-function-cast -Wcast-align \
-		-Wcast-qual -Wchar-subscripts -Wconversion \
-		-Wmissing-prototypes -Wnested-externs -Wpointer-arith \
-		-Wredundant-decls -Wshadow -Wstrict-prototypes \
-		-Wwrite-strings -Winline \
-		-Wformat -Wswitch -Waggregate-return -Wmissing-noreturn \
-		-Wimplicit-int -fno-builtin"
+	DEBUG_NORM_OPT="-O -g"
 
 	case "${CONFIG_DEBUG}" in
 	no)
diff -duHr lame.20001203/frontend/Makefile.am lame.org/frontend/Makefile.am
--- lame.20001203/frontend/Makefile.am	Thu Nov 30 11:20:23 2000
+++ lame.org/frontend/Makefile.am	Mon Dec  4 15:32:43 2000
@@ -1,4 +1,4 @@
-## $Id: Makefile.am,v 1.10 2000/11/30 10:07:03 aleidinger Exp $
+## $Id: Makefile.am,v 1.11 2000/12/03 23:00:13 markt Exp $
 
 AUTOMAKE_OPTIONS = foreign $(top_srcdir)/ansi2knr
 
@@ -54,15 +54,7 @@
 
 CLEANFILES = lclint.txt
 
-LCLINTFLAGS= \
-	+posixlib \
-	+showsummary \
-	+showalluses \
-	+whichlib \
-	+forcehints \
-	-fixedformalarray \
-	+matchanyintegral \
-	-Dlint
+LCLINTFLAGS= +posixlib +showsummary +showalluses +whichlib +forcehints -Dlint
 
 lclint.txt: ${lame_SOURCES} ${noinst_HEADERS}
 	@lclint ${LCLINTFLAGS} ${INCLUDES} ${DEFS} ${lame_SOURCES} 2>&1 >lclint.txt || true
diff -duHr lame.20001203/frontend/get_audio.c lame.org/frontend/get_audio.c
--- lame.20001203/frontend/get_audio.c	Thu Nov 30 11:20:23 2000
+++ lame.org/frontend/get_audio.c	Mon Dec  4 15:32:43 2000
@@ -19,7 +19,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
-/* $Id: get_audio.c,v 1.40 2000/11/30 10:17:30 aleidinger Exp $ */
+/* $Id: get_audio.c,v 1.41 2000/12/03 23:00:13 markt Exp $ */
 
 
 #ifdef HAVE_CONFIG_H
@@ -50,6 +50,7 @@
 mp3data_struct mp3input_data; /* used by Ogg and MP3 */
 unsigned int num_samples_read;             
 FILE *musicin;
+enum byte_order NativeByteOrder = order_unknown;
 
 
 #ifdef AMIGA_MPEGA
@@ -151,58 +152,45 @@
 }
 
 
-void SwapBytesInWords ( short *ptr, size_t short_words )  /* Some speedy code */
+void SwapBytesInWords ( short* loc, size_t words )
 {
-    unsigned long  val;
-    unsigned long* p = (unsigned long*) ptr;
-
-#ifndef lint
-# if defined(CHAR_BIT)
-#  if CHAR_BIT != 8
-#   error CHAR_BIT != 8
-#  endif
-# else
-#  error can not determine number of bits in a char
-# endif
-#endif /* lint */
+    int i;
+    short thisval;
+    char *dst, *src;
+    src = (char *) &thisval;
+    for ( i = 0; i < words; i++ )
+    {
+        thisval = *loc;
+        dst = (char *) loc++;
+        dst[0] = src[1];
+        dst[1] = src[0];
+    }
+}
 
-    assert( sizeof(short) != 2 );
 
+/*****************************************************************************
+*
+*  Routines to determine byte order and swap bytes
+*
+*****************************************************************************/
 
-#if defined(SIZEOF_UNSIGNED_LONG) && SIZEOF_UNSIGNED_LONG == 4
-    for ( ; short_words >= 2; short_words -= 2, p++ ) {
-        val = *p;
-        *p  = ((val<<8) & 0xFF00FF00) | ((val>>8) & 0x00FF00FF);
-    }
-    ptr = (short*)p;
-    for ( ; short_words >= 1; short_words -= 1, ptr++ ) {
-        val   = *ptr;
-        *ptr  = ((val<<8) & 0xFF00) | ((val>>8) & 0x00FF);
-    }
-#elif defined(SIZEOF_UNSIGNED_LONG) && SIZEOF_UNSIGNED_LONG == 8
-    for ( ; short_words >= 4; short_words -= 4, p++ ) {
-        val = *p;
-        *p  = ((val<<8) & 0xFF00FF00FF00FF00) | ((val>>8) & 0x00FF00FF00FF00FF);
-    }
-    ptr = (short*)p;
-    for ( ; short_words >= 1; short_words -= 1, ptr++ ) {
-        val   = *ptr;
-        *ptr  = ((val<<8) & 0xFF00) | ((val>>8) & 0x00FF);
-    }
-#else
-# ifdef SIZEOF_UNSIGNED_LONG
-#  warning Using unoptimized SwapBytesInWords().
-# endif
-    for ( ; short_words >= 1; short_words -= 1, ptr++ ) {
-        val   = *ptr;
-        *ptr  = ((val<<8) & 0xFF00) | ((val>>8) & 0x00FF);
-    }
-#endif
+enum byte_order DetermineByteOrder(void)
+{
+    static unsigned char  test [8] = { 1, 2, 3, 4, 5, 6, 7, 8 };
+    unsigned long         t        = *(unsigned long*) test;
 
-    assert ( short_words == 0 );
+    if ( t == 0x04030201  ||  t == 0x0807060504030201 )
+        return order_littleEndian;
+    if ( t == 0x01020304  ||  t == 0x0102030405060708 )
+        return order_bigEndian;
+        
+    return order_unknown;
 }
 
 
+
+
+
 /************************************************************************
 *
 * get_audio()
@@ -632,14 +620,13 @@
     gs_wfInfo.samplerate=gfp->in_samplerate;
     gs_wfInfo.pcmbitwidth=16;
     gs_wfInfo.channels=gfp->num_channels;
-#ifndef WORDS_BIGENDIAN
-      /* little endian */
+    if (DetermineByteOrder()==order_littleEndian) {
       if (swapbytes) gs_wfInfo.format=SF_FORMAT_RAW_BE;
       else gs_wfInfo.format=SF_FORMAT_RAW_LE;
-#else
+    } else {
       if (swapbytes) gs_wfInfo.format=SF_FORMAT_RAW_LE;
       else gs_wfInfo.format=SF_FORMAT_RAW_BE;
-#endif
+    }
 
     gs_pSndFileIn=sf_open_read(lpszFileName,&gs_wfInfo);
     musicin = (SNDFILE *) gs_pSndFileIn;
@@ -823,17 +810,22 @@
 
 
     if (16==pcmbitwidth) {
+      if ( NativeByteOrder == order_unknown )
+	{
+	  NativeByteOrder = DetermineByteOrder();
+	  if ( NativeByteOrder == order_unknown )
+	    {
+	      fprintf(stderr,"byte order not determined\n" );
+	      exit(1);
+	    }
+	}
       /* intel=littleEndian.  wav files are always little endian */
-#ifndef WORDS_BIGENDIAN
-      /* little endian */
-      if (!iswav)
+      if (!iswav && ( NativeByteOrder == order_littleEndian ))
 	SwapBytesInWords( sample_buffer, samples_read );
-#else
-      /* big endian */
-      if (iswav)
+      
+      if (iswav && ( NativeByteOrder == order_bigEndian ))
 	SwapBytesInWords( sample_buffer, samples_read );
-#endif
-
+      
       if (swapbytes)
 	SwapBytesInWords( sample_buffer, samples_read );
     }
@@ -1224,7 +1216,7 @@
 
 
 #if defined(HAVE_MPGLIB)
-static int check_aid ( const unsigned char* header ) 
+static int check_aid ( const char* header ) 
 {
     return  0 == strncmp ( header, "AiD\1", 4 );
 }
@@ -1269,7 +1261,7 @@
 int lame_decode_initfile(FILE *fd, mp3data_struct *mp3data)
 {
   VBRTAGDATA pTagData;
-  unsigned char buf[100];
+  char buf[100];
   int ret;
   int num_frames=0;
   int len,len2,xing_header,aid_header;
@@ -1384,7 +1376,7 @@
 int lame_decode_fromfile(FILE *fd, short pcm_l[], short pcm_r[],mp3data_struct *mp3data)
 {
   int ret=0,len;
-  unsigned char buf[100];
+  char buf[100];
   /* read until we get a valid output frame */
   while(0==ret) {
     len = fread(buf,1,100,fd);
diff -duHr lame.20001203/frontend/get_audio.h lame.org/frontend/get_audio.h
--- lame.20001203/frontend/get_audio.h	Thu Nov 30 11:20:23 2000
+++ lame.org/frontend/get_audio.h	Mon Dec  4 15:32:43 2000
@@ -57,7 +57,12 @@
 
 
 
+
+enum byte_order { order_unknown, order_bigEndian, order_littleEndian };
+extern enum byte_order NativeByteOrder;
+enum byte_order DetermineByteOrder(void);
 void SwapBytesInWords( short *loc, size_t words );
+
 
 
 
diff -duHr lame.20001203/frontend/gtkanal.c lame.org/frontend/gtkanal.c
--- lame.20001203/frontend/gtkanal.c	Wed Nov 29 16:44:31 2000
+++ lame.org/frontend/gtkanal.c	Mon Dec  4 15:32:43 2000
@@ -19,7 +19,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
-/* $Id: gtkanal.c,v 1.12 2000/11/24 17:28:54 robert Exp $ */
+/* $Id: gtkanal.c,v 1.13 2000/12/03 23:00:13 markt Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
@@ -117,7 +117,7 @@
   pinfo->frameNum = frameNum;
   pinfo->sampfreq=gfp->out_samplerate;
   pinfo->framesize=576*gfc->mode_gr;
-  pinfo->stereo = gfc->channels_out;
+  pinfo->stereo = gfc->stereo;
 
   /* If the analsys code is enabled, lame will writes data into gfc->pinfo,
    * and mpg123 will write data into mpg123_pinfo.  Set these so
@@ -133,7 +133,7 @@
 
     /* add a delay of framesize-DECDELAY, which will make the total delay
      * exactly one frame, so we can sync MP3 output with WAV input */
-    for ( ch = 0; ch < gfc->channels_out; ch++ ) {
+    for ( ch = 0; ch < gfc->stereo; ch++ ) {
       for ( j = 0; j < gfp->framesize-DECDELAY; j++ )
 	gfc->pinfo->pcmdata2[ch][j] = gfc->pinfo->pcmdata2[ch][j+gfp->framesize];
       for ( j = 0; j < gfp->framesize; j++ )
diff -duHr lame.20001203/frontend/main.c lame.org/frontend/main.c
--- lame.20001203/frontend/main.c	Wed Nov 29 16:44:30 2000
+++ lame.org/frontend/main.c	Mon Dec  4 15:32:43 2000
@@ -20,7 +20,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
-/* $Id: main.c,v 1.34 2000/11/26 10:49:59 robert Exp $ */
+/* $Id: main.c,v 1.35 2000/12/03 23:00:13 markt Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
@@ -111,7 +111,7 @@
         { "stereo", "force-ms", "dual-ch", "single-ch" }
     };
     int  ret;
-    unsigned char  mp3buffer [LAME_MAXMP3BUFFER];
+  char mp3buffer[LAME_MAXMP3BUFFER];
   short int Buffer[2][1152];
   int iread,imp3;
   lame_global_flags gf;
diff -duHr lame.20001203/frontend/parse.c lame.org/frontend/parse.c
--- lame.20001203/frontend/parse.c	Wed Nov 29 16:45:36 2000
+++ lame.org/frontend/parse.c	Mon Dec  4 15:32:43 2000
@@ -19,7 +19,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
-/* $Id: parse.c,v 1.36 2000/11/22 01:09:23 robert Exp $ */
+/* $Id: parse.c,v 1.37 2000/12/03 23:00:13 markt Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
@@ -126,7 +126,7 @@
               "\n"
               "Try  \"%s --help\"     for more information\n" 
               "  or \"%s --longhelp\"\n"
-              "  or \"%s --?\"        for a complete options list\n\n",
+              "  or \"%s -?\"         for a complete options list\n\n",
               ProgramName, ProgramName, ProgramName, ProgramName ); 
     return 0;
 }
@@ -1034,7 +1034,7 @@
 		        break;
 			
 		    case '?':   
-		        short_help ( gfp, stderr, ProgramName );
+		        long_help ( gfp, stderr, ProgramName, 0 /* LESSMODE=NO */);
 		        return -1;
 		        
 		    default:    
diff -duHr lame.20001203/frontend/portableio.c lame.org/frontend/portableio.c
--- lame.20001203/frontend/portableio.c	Sun Dec  3 15:14:56 2000
+++ lame.org/frontend/portableio.c	Mon Dec  4 15:32:43 2000
@@ -43,7 +43,7 @@
  * conversions, and accommodated conversions involving +/- infinity,
  * NaN's, and denormalized numbers.
  *
- * $Id: portableio.c,v 1.6 2000/12/03 14:14:56 aleidinger Exp $
+ * $Id: portableio.c,v 1.7 2000/12/03 23:00:13 markt Exp $
  */
 
 #ifdef HAVE_CONFIG_H
@@ -64,35 +64,6 @@
  * Big/little-endian independent I/O routines.
  ****************************************************************/
 
-/*
- * It is a hoax to call this code portable-IO:
- * 
- *   - It doesn't work on machines with CHAR_BIT != 8
- *   - it also don't test this error condition
- *   - otherwise it tries to handle CHAR_BIT != 8 by things like 
- *     masking 'putc(i&0xff,fp)'
- *   - It doesn't handle EOF in any way
- *   - it only works with ints with 32 or more bits
- *   - It is a collection of initial buggy code with patching the known errors
- *     instead of CORRECTING them! 
- *     For that see comments on the old Read16BitsHighLow()
- */
-
-#ifdef KLEMM_36
-
-signed int    ReadByte ( FILE* fp )
-{
-    int  result = getc (fp);
-    return result == EOF  ?  0  :  (signed char) (result & 0xFF);
-}
-
-unsigned int  ReadByteUnsigned ( FILE* fp )
-{
-    int  result = getc (fp);
-    return result == EOF  ?  0  :  (unsigned char) (result & 0xFF);
-}
-
-#else
 
 int
 ReadByte(FILE *fp)
@@ -105,19 +76,7 @@
 	return result;
 }
 
-#endif
 
-#ifdef KLEMM_36
-
-int  Read16BitsLowHigh ( FILE* fp )
-{
-    int  low  = ReadByteUnsigned (fp);
-    int  high = ReadByte         (fp);
-    
-    return (high << 8) | low;
-}
-
-#else
 int
 Read16BitsLowHigh(FILE *fp)
 {
@@ -133,57 +92,24 @@
 #endif	/* THINK_C */
 	return(result);
 }
-#endif
-
-
-#ifdef KLEMM_36
 
-int  Read16BitsHighLow ( FILE* fp )
-{
-    int  high = ReadByte         (fp);
-    int  low  = ReadByteUnsigned (fp);
-    
-    return (high << 8) | low;
-}
 
-#else
 int
 Read16BitsHighLow(FILE *fp)
 {
 	int	first, second, result;
-     
-        /* Reads the High bits, the value is -128...127 
-	 * (which gave after upscaling the -32768...+32512
-	 * Why this value is not converted to signed char?
-	 */
-        first = 0xff & getc(fp);
-        /* Reads the Lows bits, the value is 0...255 
-	 * This is correct. This value gives an additional offset
-	 * for the High bits
-	 */
+
+	first = 0xff & getc(fp);
 	second = 0xff & getc(fp);
 
-        /* This is right */
 	result = (first << 8) + second;
-    
-        /* Now we are starting to correct the nasty bug of the first instruction
-	 * The value of the high bits is wrong. Always. So we must correct this
-	 * value. This seems to be not necessary for THINK_C42. This is either
-	 * a 16 bit compiler with 16 bit ints (where this bug is hidden and 0x10000
-	 * is not in the scope of an int) or it is not a C compiler, but only a
-	 * C like compiler. In the first case the '#ifndef THINK_C42' is wrong
-	 * because it's not a property of the THINK_C42 compiler, but of all compilers
-	 * with sizeof(int)*CHAR_BIT < 18.
-	 * Another nasty thing is that the rest of the code doesn't work for 16 bit ints,
-	 * so this patch don't solve the 16 bit problem.
-         */
 #ifndef	THINK_C42
 	if (result & 0x8000)
 		result = result - 0x10000;
 #endif	/* THINK_C */
 	return(result);
 }
-#endif
+
 
 void
 Write8Bits(FILE *fp, int i)
@@ -207,18 +133,7 @@
 	putc(i&0xff,fp);
 }
 
-#ifdef KLEMM_36
-
-int  Read24BitsHighLow ( FILE* fp )
-{
-    int  high = ReadByte         (fp);
-    int  med  = ReadByteUnsigned (fp);
-    int  low  = ReadByteUnsigned (fp);
-    
-    return (high << 16) | (med << 8) | low;
-}
 
-#else
 int
 Read24BitsHighLow(FILE *fp)
 {
@@ -234,23 +149,9 @@
 		result = result - 0x1000000;
 	return(result);
 }
-#endif
 
 #define	Read32BitsLowHigh(f)	Read32Bits(f)
 
-#ifdef KLEMM_36
-
-int  Read32Bits ( FILE* fp )
-{
-    int  low  = ReadByte         (fp);
-    int  medl = ReadByteUnsigned (fp);
-    int  medh = ReadByteUnsigned (fp);
-    int  high = ReadByteUnsigned (fp);
-    
-    return (high << 24) | (medh << 16) | (medl << 8) | low;
-}
-
-#else
 
 int
 Read32Bits(FILE *fp)
@@ -267,22 +168,7 @@
 #endif	/* CRAY */
 	return(result);
 }
-#endif
-
 
-#ifdef KLEMM_36
-
-int  Read32BitsHighLow ( FILE* fp )
-{
-    int  high = ReadByte         (fp);
-    int  medh = ReadByteUnsigned (fp);
-    int  medl = ReadByteUnsigned (fp);
-    int  low  = ReadByteUnsigned (fp);
-    
-    return (high << 24) | (medh << 16) | (medl << 8) | low;
-}
-
-#else
 
 int
 Read32BitsHighLow(FILE *fp)
@@ -300,7 +186,6 @@
 	return(result);
 }
 
-#endif
 
 void
 Write32Bits(FILE *fp, int i)
@@ -325,34 +210,19 @@
 	Write16BitsHighLow(fp,(int)(i&0xffffL));
 }
 
-#ifdef KLEMM_36
-void ReadBytes (FILE     *fp, char *p, int n) 
-{
-    memset ( p, 0, n );
-    fread  ( p, 1, n, fp );
-}
-#else
 void ReadBytes(FILE	*fp, char *p, int n)
 {
-	/* What about fread? */
-	 
 	while (!feof(fp) & (n-- > 0))
 		*p++ = getc(fp);
 }
-#endif
 
 void ReadBytesSwapped(FILE *fp, char *p, int n)
 {
 	register char	*q = p;
 
-	/* What about fread? */
-	  
 	while (!feof(fp) & (n-- > 0))
 		*q++ = getc(fp);
 
-        /* If not all bytes could be read, the resorting is different
-	 * from the normal resorting. Is this intention or another bug?
-	 */
 	for (q--; p < q; p++, q--){
 		n = *p;
 		*p = *q;
@@ -360,35 +230,18 @@
 	}
 }
 
-#ifdef KLEMM_36
 void WriteBytes(FILE *fp, char *p, int n)
 {
-    /* return n == */
-    fwrite ( p, 1, n, fp );
-}
-#else
-void WriteBytes(FILE *fp, char *p, int n)
-{
-        /* No error condition checking */
-        while (n-- > 0)
+	while (n-- > 0)
 		putc(*p++, fp);
 }
-#endif
-#ifdef KLEMM_36
-void WriteBytesSwapped(FILE *fp, char *p, int n)
-{
-    p += n;
-    while ( n-- > 0 )
-	putc ( *--p, fp );
-}
-#else
+
 void WriteBytesSwapped(FILE *fp, char *p, int n)
 {
 	p += n-1;
 	while (n-- > 0)
 		putc(*p--, fp);
 }
-#endif
 
 
 
@@ -435,15 +288,10 @@
 			|	((unsigned long)(bytes[8] & 0xFF) << 8)
 			|	((unsigned long)(bytes[9] & 0xFF));
 
-        /* This case should also be called if the number is below the smallest
-	 * positive double variable */
 	if (expon == 0 && hiMant == 0 && loMant == 0) {
 		f = 0;
 	}
 	else {
-	        /* This case should also be called if the number is too large to fit into 
-		 * a double variable */
-	    
 		if (expon == 0x7FFF) {	/* Infinity or NaN */
 			f = HUGE_VAL;
 		}
@@ -467,9 +315,9 @@
 double
 ReadIeeeExtendedHighLow(FILE *fp)
 {
-	char	bytes [10];
+	char	bits[10];
 
-	ReadBytes ( fp, bytes, 10 );
-	return ConvertFromIeeeExtended ( bytes );
+	ReadBytes(fp, bits, 10);
+	return ConvertFromIeeeExtended(bits);
 }
 
diff -duHr lame.20001203/include/lame.h lame.org/include/lame.h
--- lame.20001203/include/lame.h	Wed Nov 29 16:45:36 2000
+++ lame.org/include/lame.h	Mon Dec  4 15:32:43 2000
@@ -66,9 +66,7 @@
   int num_channels;           /* input number of channels. default=2  */
   int in_samplerate;          /* input_samp_rate in Hz. default=44.1 kHz     */
   int out_samplerate;         /* output_samp_rate. default: LAME picks best value */
-                              /* at least not used for MP3 decoding: Remember 44.1 kHz MP3s and AC97 */
   float scale;                /* scale input by this amount before encoding */
-                              /* at least not used for MP3 decoding */
 
   /* general control params */
   int analysis;               /* collect data for a MP3 frame analyzer?       */
@@ -84,7 +82,7 @@
   int free_format;            /* use free format? default=0*/
 
   /* set either brate>0  or compression_ratio>0, LAME will compute
-   * the value of the variable not set.  Default is compression_ratio = 11.025 */
+   * the value of the variable not set.  Default is compression_ratio=11 */
   int brate;                  /* bitrate */
   float compression_ratio;    /* sizeof(wav file)/sizeof(mp3 file) */
 
@@ -122,7 +120,7 @@
 
 
 
-  /* psycho acoustics and other arguments which you should not change 
+  /* psycho acoustics and other aguments which you should not change 
    * unless you know what you are doing  */
   int ATHonly;                    /* only use ATH */
   int ATHshort;                   /* only use ATH for short blocks */
@@ -131,19 +129,17 @@
   int cwlimit;                    /* predictability limit */
   int allow_diff_short;           /* allow blocktypes to differ between channels ? */
   int no_short_blocks;            /* disable short blocks       */
-  int emphasis;                   /* Input PCM is emphased PCM (for instance 
-                                   * from one of the rarely emphased CDs), it is 
-				   * STRONGLY not recommended to use this, because
-				   * psycho not take into account of preemphasis
-				   * and last but not least many decoders doesn't care
-				   * about these bits */
+  int emphasis;                   /* obsolete */
+
+
+
 
   /************************************************************************/
   /* internal variables, do not set...                                    */
   /* provided because they may be of use to calling application           */
   /************************************************************************/
 
-  int version;                    /* 0=MPEG-2  1=MPEG-1  (2=MPEG-2.5) */
+  int version;                    /* 0=MPEG2  1=MPEG1 */
   int encoder_delay;
   int framesize;                  
   int frameNum;                   /* number of frames encoded */
@@ -261,14 +257,14 @@
  * This will overwrite the data in leftpcm[] and rightpcm[].
  * 
 */
-//int lame_encode_buffer(lame_global_flags *,short int leftpcm[], short int rightpcm[],int num_samples, unsigned char *mp3buffer,int  mp3buffer_size);
+//int lame_encode_buffer(lame_global_flags *,short int leftpcm[], short int rightpcm[],int num_samples, char *mp3buffer,int  mp3buffer_size);
 
 int    CDECL lame_encode_buffer (
         lame_global_flags*  gfp,
         const short int     buffer_l [],
         const short int     buffer_r [],
         const int           nsamples,
-        unsigned char*      mp3buf,
+        char* const         mp3buf,
         const int           mp3buf_size );
 
 /* as above, but input has L & R channel data interleaved.  Note: 
@@ -276,7 +272,7 @@
  * channel, not the total number of samples in pcm[]  
  */
 int CDECL lame_encode_buffer_interleaved(lame_global_flags *,short int pcm[], 
-int num_samples, unsigned char *mp3buffer,int  mp3buffer_size);
+int num_samples, char *mp3buffer,int  mp3buffer_size);
 
 
 
@@ -287,7 +283,7 @@
  *
  * return code = number of bytes output to mp3buffer.  can be 0
  */
-int CDECL lame_encode_flush(lame_global_flags *,unsigned char *mp3buffer, int size);
+int CDECL lame_encode_flush(lame_global_flags *,char *mp3buffer, int size);
 
 
 
@@ -342,7 +338,7 @@
  * and lame_close in one call.  However, once this call is made,
  * the statistics routines will no longer function since there 
  * data will have been cleared */
-int CDECL lame_encode_finish(lame_global_flags *,unsigned char *mp3buffer, int size);
+int CDECL lame_encode_finish(lame_global_flags *,char *mp3buffer, int size);
 
 
 
@@ -384,17 +380,17 @@
  * input 1 mp3 frame, output (maybe) pcm data.  
  * lame_decode return code:  -1: error.  0: need more data.  n>0: size of pcm output
  *********************************************************************/
-int CDECL lame_decode(unsigned char *mp3buf,int len,short pcm_l[],short pcm_r[]);
+int CDECL lame_decode(char *mp3buf,int len,short pcm_l[],short pcm_r[]);
 
 /* same as lame_decode, and also returns mp3 header data */
-int CDECL lame_decode_headers(unsigned char *mp3buf,int len,short pcm_l[],short pcm_r[],
+int CDECL lame_decode_headers(char *mp3buf,int len,short pcm_l[],short pcm_r[],
 mp3data_struct *mp3data);
 
 /* same as lame_decode, but returns at most one frame */
-int CDECL lame_decode1(unsigned char *mp3buf,int len,short pcm_l[],short pcm_r[]);
+int CDECL lame_decode1(char *mp3buf,int len,short pcm_l[],short pcm_r[]);
 
 /* same as lame_decode1, but returns at most one frame and mp3 header data */
-int CDECL lame_decode1_headers(unsigned char *mp3buf,int len,short pcm_l[],short pcm_r[],
+int CDECL lame_decode1_headers(char *mp3buf,int len,short pcm_l[],short pcm_r[],
 mp3data_struct *mp3data);
 
 /* Also useful for decoding is the ability to parse Xing VBR headers: */
@@ -488,14 +484,17 @@
 /* maximum size of mp3buffer needed if you encode at most 1152 samples for
    each call to lame_encode_buffer.  see lame_encode_buffer() below  
    (LAME_MAXMP3BUFFER is now obsolete)  */
-#define LAME_MAXMP3BUFFER   16384
+#define LAME_MAXMP3BUFFER 16384
+
+
+/* MPEG modes */
+#define         MPG_MD_STEREO           0
+#define         MPG_MD_JOINT_STEREO     1
+#define         MPG_MD_DUAL_CHANNEL     2   /* not supported by LAME */
+#define         MPG_MD_MONO             3
+
 
 
-/* MPEG modes (may be an enum in the future) */
-#define MPG_MD_STEREO           0
-#define MPG_MD_JOINT_STEREO     1
-#define MPG_MD_DUAL_CHANNEL     2   /* not supported by LAME */
-#define MPG_MD_MONO             3
 
 
 #if defined(__cplusplus)
diff -duHr lame.20001203/libmp3lame/Makefile.am lame.org/libmp3lame/Makefile.am
--- lame.20001203/libmp3lame/Makefile.am	Thu Nov 30 11:20:23 2000
+++ lame.org/libmp3lame/Makefile.am	Mon Dec  4 15:32:43 2000
@@ -1,4 +1,4 @@
-## $Id: Makefile.am,v 1.8 2000/11/30 10:07:02 aleidinger Exp $
+## $Id: Makefile.am,v 1.9 2000/12/03 23:00:14 markt Exp $
 
 AUTOMAKE_OPTIONS = foreign $(top_srcdir)/ansi2knr
 
@@ -37,7 +37,6 @@
         id3tag.c \
         lame.c \
         newmdct.c \
-	pcm.c \
 	psymodel.c \
 	quantize.c \
 	quantize_pvt.c \
@@ -70,15 +69,7 @@
 
 CLEANFILES = lclint.txt
 
-LCLINTFLAGS= \
-	+posixlib \
-	+showsummary \
-	+showalluses \
-	+whichlib \
-	+forcehints \
-	-fixedformalarray \
-	+matchanyintegral \
-	-Dlint
+LCLINTFLAGS= +posixlib +showsummary +showalluses +whichlib +forcehints -Dlint
 
 lclint.txt: ${libmp3lame_la_SOURCES} ${noinst_HEADERS}
 	@lclint ${LCLINTFLAGS} ${INCLUDES} ${DEFS} ${libmp3lame_la_SOURCES} 2>&1 >lclint.txt || true
diff -duHr lame.20001203/libmp3lame/bitstream.c lame.org/libmp3lame/bitstream.c
--- lame.20001203/libmp3lame/bitstream.c	Wed Nov 29 16:45:36 2000
+++ lame.org/libmp3lame/bitstream.c	Mon Dec  4 15:32:43 2000
@@ -19,7 +19,6 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#define KLEMM_14
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -141,285 +140,6 @@
     }
 }
 
-#ifdef KLEMM_14 /*======================================================*/
-
-/*
- * Some combinations of bitrate, Fs, and stereo make it impossible to stuff
- * out a frame using just main_data, due to the limited number of bits to
- * indicate main_data_length. In these situations, we put stuffing bits into
- * the ancillary data...
- */
-
-inline static void drain_into_ancillary ( lame_global_flags* const gfp, int remainingBits )
-{
-    lame_internal_flags*  gfc = gfp->internal_flags;
-    char                  buffer [80];
-    char*                 p = buffer;
-    
-    assert (remainingBits >= 0);
-    
-    sprintf ( p, "LAME%s", get_lame_short_version () );
-
-    for (; *p != '\0'  &&  remainingBits >= 8; p++, remainingBits -= 8 )
-        putbits2 ( gfp, *p, 8 );
-
-    for (; remainingBits >= 1; remainingBits -= 1 ) {
-        putbits2 ( gfp, gfc->ancillary_flag, 1 );
-        gfc->ancillary_flag ^= 1;
-    }
-
-    assert (remainingBits == 0);
-}
-
-
-static void  writeheader (
-        lame_internal_flags* const  gfc, 
-        const unsigned              value, 
-        size_t                      bitcount )
-{
-    static unsigned  tab [2] = { 0, CRC16_POLYNOMIAL };
-    int              i;
-    int              k;
-
-    assert (bitcount < MAX_LENGTH-2  &&  value < (1lu << bitcount) );
-
-    // Update CRC value
-    for ( i = bitcount; i-- > 0; )
-        gfc->crcvalue = (gfc->crcvalue << 1) ^ tab [ ((gfc->crcvalue >> 15) ^ (value >> i)) & 1 ];
-      
-    // Poke value into bitbuffer
-    i = gfc->header[gfc->h_ptr].ptr;
-    while ( 1 ) {
-        if (bitcount < 8 - (i & 7)) {            // 'bitcount <= ...' also possible ?
-	    gfc->header [gfc->h_ptr].buf [i >> 3] |= value << (8 - (i & 7) - bitcount);
-	    i += bitcount;
-	    break;
-	} else {
-	    bitcount -= (k = 8 - (i & 7));
-	    gfc->header [gfc->h_ptr].buf [i >> 3] |= (value >> bitcount) << (8 - (i & 7) - k);
-	    i += k;
-	}
-    }
-    gfc->header[gfc->h_ptr].ptr = i;
-}
-
-static void  writedummy (
-        lame_internal_flags* const  gfc, 
-        size_t                      bitcount )
-{
-    gfc->header[gfc->h_ptr].ptr += bitcount;   // dummy bits without updating CRC and Buffer
-}
-
-
-inline static void encodeSideInfo2 ( lame_global_flags* const gfp, int bitsPerFrame )
-{
-    lame_internal_flags *gfc=gfp->internal_flags;
-    III_side_info_t *l3_side;
-    int gr, ch, band, old;
-    
-    l3_side = &gfc->l3_side;
-    gfc->header[gfc->h_ptr].ptr = 0;
-    memset(gfc->header[gfc->h_ptr].buf, 0, gfc->sideinfo_len);
-    
-    writeheader ( gfc, gfp->out_samplerate >= 16000 ? 0xfff : 0xffe, 12 );
-    writeheader ( gfc, gfp->version          , 1 );
-    writeheader ( gfc, 4 - 3                 , 2 );
-    writeheader ( gfc, !gfp->error_protection, 1 );
-
-    /* Reset CRC generator */
-    gfc->crcvalue = 0xFFFF;
-    writeheader ( gfc, gfc->bitrate_index    , 4 );
-    writeheader ( gfc, gfc->samplerate_index , 2 );
-    writeheader ( gfc, gfc->padding          , 1 );
-    writeheader ( gfc, gfp->extension        , 1 );
-    writeheader ( gfc, gfp->mode             , 2 );
-    writeheader ( gfc, gfc->mode_ext         , 2 );
-    writeheader ( gfc, gfp->copyright        , 1 );
-    writeheader ( gfc, gfp->original         , 1 );
-    writeheader ( gfc, gfp->emphasis         , 2 );
-    if (gfp->error_protection)
-        writedummy ( gfc, 16 );
-
-    if ( gfp->version == 1 ) { /* MPEG1 */
-    
-	assert(l3_side->main_data_begin >= 0);
-	writeheader ( gfc, l3_side->main_data_begin         , 9 );
-	writeheader ( gfc, l3_side->private_bits            , gfc->channels_out == 2  ?  3  :  5 );
-
-	for (ch = 0; ch < gfc->channels_out; ch++) {
-	    for (band = 0; band < 4; band++) {
-		writeheader ( gfc, l3_side->scfsi[ch][band] , 1 );
-	    }
-	}
-
-	for (gr = 0; gr < 2; gr++) {
-	    for (ch = 0; ch < gfc->channels_out; ch++) {
-		gr_info *gi = &l3_side->gr[gr].ch[ch].tt;
-		writeheader ( gfc, gi->part2_3_length       ,12 );
-		writeheader ( gfc, gi->big_values / 2       , 9 );
-		writeheader ( gfc, gi->global_gain          , 8 );
-		writeheader ( gfc, gi->scalefac_compress    , 4 );
-		writeheader ( gfc, gi->window_switching_flag, 1 );
-
-		if (gi->window_switching_flag) {
-		    writeheader ( gfc, gi->block_type       , 2 );
-		    writeheader ( gfc, gi->mixed_block_flag , 1 );
-
-		    if (gi->table_select[0] == 14)
-			gi->table_select[0] = 16;
-		    writeheader ( gfc, gi->table_select[0]  , 5 );
-		    if (gi->table_select[1] == 14)
-			gi->table_select[1] = 16;
-		    writeheader ( gfc, gi->table_select[1]  , 5 );
-
-		    writeheader ( gfc, gi->subblock_gain[0] , 3 );
-		    writeheader ( gfc, gi->subblock_gain[1] , 3 );
-		    writeheader ( gfc, gi->subblock_gain[2] , 3 );
-		} else {
-		    assert(gi->block_type == NORM_TYPE);
-		    if (gi->table_select[0] == 14)
-			gi->table_select[0] = 16;
-		    writeheader ( gfc, gi->table_select[0]  , 5 );
-		    if (gi->table_select[1] == 14)
-			gi->table_select[1] = 16;
-		    writeheader ( gfc, gi->table_select[1]  , 5 );
-		    if (gi->table_select[2] == 14)
-			gi->table_select[2] = 16;
-		    writeheader ( gfc, gi->table_select[2]  , 5 );
-
-		    assert(gi->region0_count < 16U);
-		    assert(gi->region1_count < 8U);
-		    writeheader ( gfc, gi->region0_count    , 4 );
-		    writeheader ( gfc, gi->region1_count    , 3 );
-		}
-		writeheader ( gfc, gi->preflag              , 1 );
-		writeheader ( gfc, gi->scalefac_scale       , 1 );
-		writeheader ( gfc, gi->count1table_select   , 1 );
-	    }
-	}
-    }
-    else { /* MPEG2 */
-	
-	assert(l3_side->main_data_begin >= 0);
-	writeheader ( gfc, l3_side->main_data_begin         , 8 );
-	writeheader ( gfc, l3_side->private_bits            , gfc->channels_out );
-
-	gr = 0;
-	for (ch = 0; ch < gfc->channels_out; ch++) {
-	    gr_info *gi = &l3_side->gr[gr].ch[ch].tt;
-	    writeheader ( gfc, gi->part2_3_length           ,12 );
-	    writeheader ( gfc, gi->big_values / 2           , 9 );
-	    writeheader ( gfc, gi->global_gain              , 8 );
-	    writeheader ( gfc, gi->scalefac_compress        , 9 );
-	    writeheader ( gfc, gi->window_switching_flag    , 1 );
-
-	    if (gi->window_switching_flag) {
-		writeheader ( gfc, gi->block_type           , 2 );
-		writeheader ( gfc, gi->mixed_block_flag     , 1 );
-
-		if (gi->table_select[0] == 14)
-		    gi->table_select[0] = 16;
-		writeheader ( gfc, gi->table_select[0]      , 5 );
-		if (gi->table_select[1] == 14)
-		    gi->table_select[1] = 16;
-		writeheader ( gfc, gi->table_select [1]     , 5 );
-
-		writeheader ( gfc, gi->subblock_gain [0]    , 3 );
-		writeheader ( gfc, gi->subblock_gain [1]    , 3 );
-		writeheader ( gfc, gi->subblock_gain [2]    , 3 );
-	    } else {
-		if (gi->table_select[0] == 14)
-		    gi->table_select[0] = 16;
-		writeheader ( gfc, gi->table_select [0]     , 5 );
-		if (gi->table_select[1] == 14)
-		    gi->table_select[1] = 16;
-		writeheader ( gfc, gi->table_select [1]     , 5 );
-		if (gi->table_select[2] == 14)
-		    gi->table_select[2] = 16;
-		writeheader ( gfc, gi->table_select [2]     , 5 );
-
-		assert(gi->region0_count < 16U);
-		assert(gi->region1_count < 8U);
-		writeheader ( gfc, gi->region0_count        , 4 );
-		writeheader ( gfc, gi->region1_count        , 3 );
-	    }
-
-	    writeheader ( gfc, gi->scalefac_scale           , 1 );
-	    writeheader ( gfc, gi->count1table_select       , 1 );
-	}
-    }
-
-    if ( gfp->error_protection ) {
-	/* (jo) error_protection: add crc16 information to header */
-	gfc->header[gfc->h_ptr].buf [4] = (gfc->crcvalue >> 8) & 0xFF;
-	gfc->header[gfc->h_ptr].buf [5] = (gfc->crcvalue >> 0) & 0xFF;
-    }
-
-
-    old = gfc->h_ptr;
-    assert (gfc->header[old].ptr == gfc->sideinfo_len * 8);
-
-    gfc->h_ptr                           = (old + 1) & (MAX_HEADER_BUF - 1);
-    gfc->header[gfc->h_ptr].write_timing = gfc->header[old].write_timing + bitsPerFrame;
-
-    if ( gfc->h_ptr == gfc->w_ptr ) { /* yikes! we are out of header buffer space */
-        ERRORF("Error: MAX_HEADER_BUF too small in bitstream.c \n");
-    }
-}
-
-/* 
- * For region 1 (only values of -1, 0 and +1) one step codes 4 values.
- * This table contains the coded 'huffmancode' in bits 7...4 and the
- * value 'p' in bit 3...0. So you don't need a lot of unpredictable jumps
- * to code this area. Merge the 4 values and make a table lookup.
- */
-
-static unsigned char klemm_table [3*3*3*3] = {
-    0xFF, 0x7E, 0xEF, 0x7D, 0x3C, 0x6D, 0xDF, 0x6E, 0xCF,
-    0x7B, 0x3A, 0x6B, 0x39, 0x18, 0x29, 0x5B, 0x2A, 0x4B,
-    0xBF, 0x5E, 0xAF, 0x5D, 0x2C, 0x4D, 0x9F, 0x4E, 0x8F,
-    0x77, 0x36, 0x67, 0x35, 0x14, 0x25, 0x57, 0x26, 0x47,
-    0x33, 0x12, 0x23, 0x11, 0x00, 0x01, 0x13, 0x02, 0x03,
-    0x37, 0x16, 0x27, 0x15, 0x04, 0x05, 0x17, 0x06, 0x07,
-    0x7F, 0x3E, 0x6F, 0x3D, 0x1C, 0x2D, 0x5F, 0x2E, 0x4F,
-    0x3B, 0x1A, 0x2B, 0x19, 0x08, 0x09, 0x1B, 0x0A, 0x0B,
-    0x3F, 0x1E, 0x2F, 0x1D, 0x0C, 0x0D, 0x1F, 0x0E, 0x0F,
-};
-
-/*
- *  This function codes the part 2 of the quantized values.
- *  This is the part consisting only of (-1,0,+1). The part 3 is the part
- *  which is always [0], the part 1 can contain all values from [-8191,+8191]
- */
-
-inline static int  huffman_coder_count1 ( lame_global_flags* const gfp, const int* ix, gr_info* gi )
-{
-#ifdef DEBUG
-    lame_internal_flags*  gfc    = gfp->internal_flags;
-    int                   gegebo = gfc->bs.totbit;
-#endif
-    /* Write count1 area */
-    const struct huffcodetab* h = ht + gi->count1table_select + 32;
-    int  bits = 0;
-    int  i;
-    int  tmp;
-
-    assert (gi->count1table_select < 2u);
-
-    for ( i = (gi->count1 - gi->big_values) / 4, ix += gi->big_values; i > 0; i--, ix += 4 ) {
-        assert ( ix[0]+1 <= 2u  &&  ix[1]+1 <= 2u  &&  ix[2]+1 <= 2u  &&  ix[3]+1 <= 2u );
-	tmp   = klemm_table [ 40 + 27*ix[0] + 9*ix[1] + 3*ix[2] + ix[3] ];
-	bits += h->hlen [tmp & 15];
-	putbits2 ( gfp, (tmp >> 4) + h->table [tmp & 15], h->hlen [tmp & 15] );
-    }
-    
-#ifdef DEBUG
-    DEBUGF("%ld %d %d %d\n",gfc->bs.totbit -gegebo, gi->count1bits, gi->big_values, gi->count1);
-#endif
-    return bits;
-}
-
-#else /*================================================================*/
 
 /*
   Some combinations of bitrate, Fs, and stereo make it impossible to stuff
@@ -461,20 +181,13 @@
 	}
     }
 
-    /* drain the rest 16 bits at a time */
-    bits = remainingBits & (16 - 1);
-    for (i=0; i<bits; ++i) {
-      putbits2(gfp,gfc->ancillary_flag,1);
-      gfc->ancillary_flag = 1-gfc->ancillary_flag;
+    for (; remainingBits >= 1; remainingBits -= 1 ) {
+        putbits2 ( gfp, gfc->ancillary_flag, 1 );
+        gfc->ancillary_flag ^= 1;
     }
 
-    remainingBits /= 16;
-    for (; remainingBits > 0; remainingBits--) {
-      if (gfc->ancillary_flag)
-	putbits2(gfp,0xAAAA, 16);
-      else
-	putbits2(gfp,0x5555, 16);
-    }
+    assert (remainingBits == 0);
+
 }
 
 /*write N bits into the header */
@@ -494,7 +207,6 @@
     gfc->header[gfc->h_ptr].ptr = ptr;
 }
 
-#if 1  /* Set to 0 for new CRC function, but speed improvement is around 0.2% */
 
 /* (jo) this wrapper function for BF_addEntry() updates also the crc */
 static void
@@ -515,61 +227,7 @@
 
 void main_CRC_init (void) {}
 
-#else
-
-static unsigned short CRC_table [256];
-
-static void CRC_init ( unsigned short polynom )
-{
-    int            i;
-    int            j;
-    unsigned long  val;
-    
-    i = 0;
-    do {
-        val = 0;
-        j = 0x80;
-        do {
-            val <<= 1;
-            if ( !(val & 0x10000) ^ !(i & j) )
-		val ^= polynom;
-   	} while ( j >>= 1 );
-   	CRC_table [i] = val;
-    } while ( ++i < 0x100 );
-}
-
-static void CRC_writeheader ( lame_internal_flags*  gfc,
-                              unsigned int          val, 
-                              unsigned              len,
-                              unsigned int*         crc )
-{
-    unsigned long c = *crc;
-    
-    assert ( len <= 16 );
-    assert ( val < (1 << len) );
-    assert ( c < 0x10000 );
-    
-    if ( len > 8 ) {
-        c <<= len-8;
-        c  ^= CRC_table [ (c>>16) ^ (val >> 8) ];
-        c  &= 0xFFFF;
-        c <<= 8;
-        c  ^= CRC_table [ (c>>16) ^ (val & 0xFF) ];
-    } else {
-        c <<= len;
-        c  ^= CRC_table [ (c>>16) ^ val ];
-    }
-    
-    *crc = c & 0xFFFF;
-    writeheader ( gfc, val, len );
-}
-
-void main_CRC_init ( void )
-{
-    CRC_init ( CRC16_POLYNOMIAL );
-}
 
-#endif
 
 inline static void
 encodeSideInfo2(lame_global_flags *gfp,int bitsPerFrame)
@@ -609,12 +267,12 @@
 	assert(l3_side->main_data_begin >= 0);
 	CRC_writeheader(gfc,(l3_side->main_data_begin), 9,&crc);
 
-	if (gfc->channels_out == 2)
+	if (gfc->stereo == 2)
 	    CRC_writeheader(gfc,l3_side->private_bits, 3,&crc);
 	else
 	    CRC_writeheader(gfc,l3_side->private_bits, 5,&crc);
 
-	for (ch = 0; ch < gfc->channels_out; ch++) {
+	for (ch = 0; ch < gfc->stereo; ch++) {
 	    int band;
 	    for (band = 0; band < 4; band++) {
 		CRC_writeheader(gfc,l3_side->scfsi[ch][band], 1,&crc);
@@ -622,7 +280,7 @@
 	}
 
 	for (gr = 0; gr < 2; gr++) {
-	    for (ch = 0; ch < gfc->channels_out; ch++) {
+	    for (ch = 0; ch < gfc->stereo; ch++) {
 		gr_info *gi = &l3_side->gr[gr].ch[ch].tt;
 		CRC_writeheader(gfc,gi->part2_3_length,       12,&crc);
 		CRC_writeheader(gfc,gi->big_values / 2,        9,&crc);
@@ -670,10 +328,10 @@
 	/* MPEG2 */
 	assert(l3_side->main_data_begin >= 0);
 	CRC_writeheader(gfc,(l3_side->main_data_begin), 8,&crc);
-	CRC_writeheader(gfc,l3_side->private_bits, gfc->channels_out,&crc);
+	CRC_writeheader(gfc,l3_side->private_bits, gfc->stereo,&crc);
 
 	gr = 0;
-	for (ch = 0; ch < gfc->channels_out; ch++) {
+	for (ch = 0; ch < gfc->stereo; ch++) {
 	    gr_info *gi = &l3_side->gr[gr].ch[ch].tt;
 	    CRC_writeheader(gfc,gi->part2_3_length,       12,&crc);
 	    CRC_writeheader(gfc,gi->big_values / 2,        9,&crc);
@@ -807,7 +465,6 @@
 }
 
 
-#endif /*====================================================================*/
 
 /*
   Implements the pseudocode of page 98 of the IS
@@ -970,7 +627,7 @@
     if (gfp->version == 1) {
 	/* MPEG 1 */
 	for (gr = 0; gr < 2; gr++) {
-	    for (ch = 0; ch < gfc->channels_out; ch++) {
+	    for (ch = 0; ch < gfc->stereo; ch++) {
 		gr_info *gi = &l3_side->gr[gr].ch[ch].tt;
 		int slen1 = slen1_tab[gi->scalefac_compress];
 		int slen2 = slen2_tab[gi->scalefac_compress];
@@ -1026,7 +683,7 @@
     } else {
 	/* MPEG 2 */
 	gr = 0;
-	for (ch = 0; ch < gfc->channels_out; ch++) {
+	for (ch = 0; ch < gfc->stereo; ch++) {
 	    gr_info *gi = &l3_side->gr[gr].ch[ch].tt;
 	    int i, sfb_partition;
 	    assert(gi->sfb_partition_table);
@@ -1203,7 +860,7 @@
 }
 
 
-int copy_buffer(unsigned char* buffer,int size,Bit_stream_struc *bs)
+int copy_buffer(char *buffer,int size,Bit_stream_struc *bs)
 {
   int minimum = bs->buf_byte_idx + 1;
   if (minimum <= 0) return 0;
diff -duHr lame.20001203/libmp3lame/bitstream.h lame.org/libmp3lame/bitstream.h
--- lame.20001203/libmp3lame/bitstream.h	Wed Nov 29 16:45:36 2000
+++ lame.org/libmp3lame/bitstream.h	Mon Dec  4 15:32:43 2000
@@ -30,7 +30,7 @@
 void flush_bitstream(lame_global_flags *gfp);
 void add_dummy_byte ( lame_global_flags* gfp, unsigned char val );
 
-int  copy_buffer(unsigned char *buffer,int buffer_size,Bit_stream_struc *bs);
+int  copy_buffer(char *buffer,int buffer_size,Bit_stream_struc *bs);
 void init_bit_stream_w(lame_internal_flags *gfc);
 void main_CRC_init (void);   // remove sometimes
 
diff -duHr lame.20001203/libmp3lame/encoder.c lame.org/libmp3lame/encoder.c
--- lame.20001203/libmp3lame/encoder.c	Wed Nov 29 16:45:36 2000
+++ lame.org/libmp3lame/encoder.c	Mon Dec  4 15:32:43 2000
@@ -19,7 +19,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
-/* $Id: encoder.c,v 1.18 2000/11/26 10:50:00 robert Exp $ */
+/* $Id: encoder.c,v 1.19 2000/12/03 23:00:14 markt Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -76,12 +76,10 @@
 
 typedef FLOAT8 pedata[2][2];
 
-int  lame_encode_mp3_frame (				// Output
-	lame_global_flags* const  gfp,			// Context
-	sample_t*                 inbuf_l,              // Input
-	sample_t*                 inbuf_r,              // Input
-	unsigned char*            mp3buf, 		// Output
-	size_t                    mp3buf_size )		// Output
+int lame_encode_mp3_frame(lame_global_flags *gfp,
+sample_t inbuf_l[],
+sample_t inbuf_r[],
+char *mp3buf, int mp3buf_size)
 {
 #ifdef macintosh /* PLL 14/04/2000 */
   static FLOAT8 xr[2][2][576];
@@ -95,7 +93,7 @@
   III_psy_ratio masking_MS_ratio[2][2]; /*MS ratios */
   III_psy_ratio (*masking)[2][2];  /*LR ratios and MS ratios*/
   III_scalefac_t scalefac[2][2];
-  const sample_t *inbuf[2];
+  sample_t *inbuf[2];
   lame_internal_flags *gfc=gfp->internal_flags;
 
   pedata pe,pe_MS;
@@ -117,16 +115,11 @@
   inbuf[0]=inbuf_l;
   inbuf[1]=inbuf_r;
 
-  /* Now another nasty example about programming:
-   * A lot of lame functions destroy data, so you can't trust
-   * in that data is not modified. A lot of prophylactic copying is done.
-   */
-   
   if (gfp->scale != 0) {
     int i;
     for (i=0 ; i<gfp->framesize; ++i) {
       inbuf_l[i] *= gfp->scale;
-      if (gfc->channels_out==2) inbuf_r[i] *= gfp->scale;
+      if (gfc->stereo==2) inbuf_r[i] *= gfp->scale;
     }
   }
   
@@ -167,18 +160,18 @@
       for (i=0, j=0; i<286+576*(1+gfc->mode_gr); ++i) {
 	if (i<576*gfc->mode_gr) {
 	  primebuff0[i]=0;
-	  if (gfc->channels_out==2) 
+	  if (gfc->stereo==2) 
 	    primebuff1[i]=0;
 	}else{
 	  primebuff0[i]=inbuf[0][j];
-	  if (gfc->channels_out==2) 
+	  if (gfc->stereo==2) 
 	    primebuff1[i]=inbuf[1][j];
 	  ++j;
 	}
       }
       /* polyphase filtering / mdct */
       for ( gr = 0; gr < gfc->mode_gr; gr++ ) {
-	for ( ch = 0; ch < gfc->channels_out; ch++ ) {
+	for ( ch = 0; ch < gfc->stereo; ch++ ) {
 	  gfc->l3_side.gr[gr].ch[ch].tt.block_type=SHORT_TYPE;
 	}
       }
@@ -237,13 +230,13 @@
      * (mt 6/99).
      */
     int ret;
-    const sample_t *bufp[2];  /* address of beginning of left & right granule */
+    sample_t *bufp[2];  /* address of beginning of left & right granule */
     int blocktype[2];
 
     ms_ratio_prev=gfc->ms_ratio[gfc->mode_gr-1];
     for (gr=0; gr < gfc->mode_gr ; gr++) {
 
-      for ( ch = 0; ch < gfc->channels_out; ch++ )
+      for ( ch = 0; ch < gfc->stereo; ch++ )
 	bufp[ch] = &inbuf[ch][576 + gr*576-FFTOFFSET];
 
       ret=L3psycho_anal( gfp, bufp, gr, 
@@ -252,7 +245,7 @@
 		     pe[gr],pe_MS[gr],blocktype);
       if (ret!=0) return -4;
 
-      for ( ch = 0; ch < gfc->channels_out; ch++ )
+      for ( ch = 0; ch < gfc->stereo; ch++ )
 	gfc->l3_side.gr[gr].ch[ch].tt.block_type=blocktype[ch];
 
     }
@@ -260,7 +253,7 @@
     gfc->ms_ratio[1]=gfc->ms_ratio[gfc->mode_gr-1];
   }else{
     for (gr=0; gr < gfc->mode_gr ; gr++)
-      for ( ch = 0; ch < gfc->channels_out; ch++ ) {
+      for ( ch = 0; ch < gfc->stereo; ch++ ) {
 	gfc->l3_side.gr[gr].ch[ch].tt.block_type=NORM_TYPE;
 	pe_MS[gr][ch]=pe[gr][ch]=700;
       }
@@ -269,7 +262,7 @@
 
   /* block type flags */
   for( gr = 0; gr < gfc->mode_gr; gr++ ) {
-    for ( ch = 0; ch < gfc->channels_out; ch++ ) {
+    for ( ch = 0; ch < gfc->stereo; ch++ ) {
       gr_info *cod_info = &gfc->l3_side.gr[gr].ch[ch].tt;
       cod_info->mixed_block_flag = 0;     /* never used by this model */
       if (cod_info->block_type == NORM_TYPE )
@@ -284,7 +277,7 @@
   mdct_sub48(gfc, inbuf[0], inbuf[1], xr);
   /* re-order the short blocks, for more efficient encoding below */
   for (gr = 0; gr < gfc->mode_gr; gr++) {
-    for (ch = 0; ch < gfc->channels_out; ch++) {
+    for (ch = 0; ch < gfc->stereo; ch++) {
       gr_info *cod_info = &gfc->l3_side.gr[gr].ch[ch].tt;
       if (cod_info->block_type==SHORT_TYPE) {
 	freorder(gfc->scalefac_band.s,xr[gr][ch]);
@@ -351,7 +344,7 @@
 
   if (gfp->analysis && gfc->pinfo != NULL) {
     for ( gr = 0; gr < gfc->mode_gr; gr++ ) {
-      for ( ch = 0; ch < gfc->channels_out; ch++ ) {
+      for ( ch = 0; ch < gfc->stereo; ch++ ) {
 	gfc->pinfo->ms_ratio[gr]=gfc->ms_ratio[gr];
 	gfc->pinfo->ms_ener_ratio[gr]=gfc->ms_ener_ratio[gr];
 	gfc->pinfo->blocktype[gr][ch]=
@@ -411,7 +404,7 @@
 
   if (gfp->analysis && gfc->pinfo != NULL) {
     int j;
-    for ( ch = 0; ch < gfc->channels_out; ch++ ) {
+    for ( ch = 0; ch < gfc->stereo; ch++ ) {
       for ( j = 0; j < FFTOFFSET; j++ )
 	gfc->pinfo->pcmdata[ch][j] = gfc->pinfo->pcmdata[ch][j+gfp->framesize];
       for ( j = FFTOFFSET; j < 1600; j++ ) {
diff -duHr lame.20001203/libmp3lame/encoder.h lame.org/libmp3lame/encoder.h
--- lame.20001203/libmp3lame/encoder.h	Wed Nov 29 16:44:27 2000
+++ lame.org/libmp3lame/encoder.h	Mon Dec  4 15:32:43 2000
@@ -122,10 +122,10 @@
 #include "lame.h"
 
 int  lame_encode_mp3_frame (
-        lame_global_flags*  gfp,
-        sample_t*           inbuf_l,
-        sample_t*           inbuf_r,
-        unsigned char*      mp3buf, 
-	size_t              mp3buf_size );
+        lame_global_flags* gfp,
+        sample_t  inbuf_l [],
+        sample_t  inbuf_r [],
+        char*     mp3buf, 
+	int       mp3buf_size );
 
 #endif
diff -duHr lame.20001203/libmp3lame/fft.c lame.org/libmp3lame/fft.c
--- lame.20001203/libmp3lame/fft.c	Wed Nov 29 16:44:27 2000
+++ lame.org/libmp3lame/fft.c	Mon Dec  4 15:32:43 2000
@@ -31,7 +31,7 @@
 **           Takehiro  - some dirty hack for speed up
 */
 
-/* $Id: fft.c,v 1.11 2000/11/26 10:50:00 robert Exp $ */
+/* $Id: fft.c,v 1.12 2000/12/03 23:00:14 markt Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
@@ -179,7 +179,7 @@
 
 
 void fft_short(lame_internal_flags *gfc, 
-                FLOAT x_real[3][BLKSIZE_s], int chn, const sample_t *buffer[2])
+                FLOAT x_real[3][BLKSIZE_s], int chn, sample_t *buffer[2])
 {
     const FLOAT*  window_s = (const FLOAT *)&gfc->window_s[0];
     int           i;
@@ -218,7 +218,7 @@
 }
 
 void fft_long(lame_internal_flags * const gfc,
-               FLOAT x[BLKSIZE], int chn, const sample_t *buffer[2] )
+               FLOAT x[BLKSIZE], int chn, sample_t *buffer[2] )
 {
     const FLOAT*  window = (const FLOAT *)&gfc->window[0];
     int           i;
diff -duHr lame.20001203/libmp3lame/fft.h lame.org/libmp3lame/fft.h
--- lame.20001203/libmp3lame/fft.h	Wed Nov 29 16:44:27 2000
+++ lame.org/libmp3lame/fft.h	Mon Dec  4 15:32:43 2000
@@ -25,10 +25,10 @@
 #include "encoder.h"
 
 void fft_long(lame_internal_flags* gfc, FLOAT x_real[BLKSIZE], 
-               int chn, const sample_t *data[2] );
+               int chn, sample_t *data[2] );
 
 void fft_short(lame_internal_flags* gfc, FLOAT x_real[3][BLKSIZE_s], 
-               int chn, const sample_t *data[2] );
+               int chn, sample_t *data[2] );
 
 void init_fft(lame_internal_flags* gfc );
 
diff -duHr lame.20001203/libmp3lame/i386/cpu_feat.nas lame.org/libmp3lame/i386/cpu_feat.nas
--- lame.20001203/libmp3lame/i386/cpu_feat.nas	Wed Nov 29 16:44:26 2000
+++ lame.org/libmp3lame/i386/cpu_feat.nas	Mon Dec  4 15:32:48 2000
@@ -2,7 +2,7 @@
 ;
 ; 	assembler routines to detect CPU-features
 ;
-;	MMX / 3DNow! / SIMD / SIMD2
+;	MMX / 3DNow! / SIMD
 ;
 ;	for the LAME project
 ;	Frank Klemm, Robert Hegemann 2000-10-12
@@ -13,11 +13,23 @@
 	globaldef	has_MMX_nasm
 	globaldef	has_3DNow_nasm
 	globaldef	has_SIMD_nasm
-	globaldef	has_SIMD2_nasm
 
         segment_code
 
-testCPUID:
+
+
+;---------------------------------------
+;	int has_MMX_nasm(void)
+;---------------------------------------
+
+	align	16
+        
+has_MMX_nasm:
+
+	push	ebp
+	mov	ebp,esp
+        
+        pushad
 	pushfd	                        
 	pop	eax
 	mov	ecx,eax
@@ -27,81 +39,122 @@
 	pushfd
 	pop	eax
 	cmp	eax,ecx
-	ret
-
-;---------------------------------------
-;	int  has_MMX_nasm (void)
-;---------------------------------------
-
-has_MMX_nasm:
-        pushad
-	call	testCPUID
-	jz	return0		; no CPUID command, so no MMX
+	jz	NO_MMX_FEATURE	; no CPUID command
 
 	mov	eax,0x1
 	CPUID
 	test	edx,0x800000
-	jz	return0		; no MMX support
-	jmp	return1		; MMX support
+	jz	NO_MMX_FEATURE	; no MMX support
+	popad
+	mov	eax,0x1
+	jmp	return_MMX
         
-;---------------------------------------
-;	int  has_SIMD_nasm (void)
-;---------------------------------------
+NO_MMX_FEATURE:
+
+	popad
+	xor	eax,eax
+
+return_MMX:    
+
+	mov	esp,ebp
+	pop	ebp
+        ret
 
-has_SIMD_nasm:
-        pushad
-	call	testCPUID
-	jz	return0		; no CPUID command, so no SIMD
         
-	mov	eax,0x1
-	CPUID
-	test	edx,0x02000000
-	jz	return0		; no SIMD support
-	jmp	return1		; SIMD support
         
 ;---------------------------------------
-;	int  has_SIMD2_nasm (void)
+;	int has_SIMD_nasm(void)
 ;---------------------------------------
 
-has_SIMD2_nasm:
+	align	16
+        
+has_SIMD_nasm:
+
+	push	ebp
+	mov	ebp,esp
+        
         pushad
-	call	testCPUID
-	jz	return0		; no CPUID command, so no SIMD2
+	pushfd	                        
+	pop	eax
+	mov	ecx,eax
+	xor	eax,0x200000
+	push	eax
+	popfd
+	pushfd
+	pop	eax
+	cmp	eax,ecx
+	jz	NO_SIMD_FEATURE	; no CPUID command
         
 	mov	eax,0x1
 	CPUID
-	test	edx,0x04000000
-	jz	return0		; no SIMD2 support
-	jmp	return1		; SIMD2 support
+	test	edx,0x2000000
+	jz	NO_SIMD_FEATURE	; no SIMD support
+	popad
+	mov	eax,0x1
+
+	jmp	return_SIMD
+
+NO_SIMD_FEATURE:
+
+	popad
+	xor	eax,eax
+
+return_SIMD:    
+
+	mov	esp,ebp
+	pop	ebp
+        ret
+
+
         
 ;---------------------------------------
-;	int  has_3DNow_nasm (void)
+;	int has_3DNow_nasm(void)
 ;---------------------------------------
 
+	align	16
+        
 has_3DNow_nasm:
+
+	push	ebp
+	mov	ebp,esp
+        
         pushad
-	call	testCPUID
-	jz	return0		; no CPUID command, so no 3DNow!
+	pushfd	                        
+	pop	eax
+	mov	ecx,eax
+	xor	eax,0x200000
+	push	eax
+	popfd
+	pushfd
+	pop	eax
+	cmp	eax,ecx
+	jz	NO_3DNow_FEATURE	; no CPUID command
 
 	mov	eax,0x80000000
 	CPUID
 	cmp	eax,0x80000000
-	jbe	return0		; no extended MSR(1), so no 3DNow!
+	jbe	NO_3DNow_FEATURE	; no extended MSR1
 
 	mov	eax,0x80000001
 	CPUID
 	test	edx,0x80000000
-	jz	return0		; no 3DNow! support
-				; 3DNow! support
-return1:
+	jz	NO_3DNow_FEATURE	; no 3DNow!
 	popad
-	xor	eax,eax
-	inc	eax
-	ret
+	mov	eax,0x1
+
+	jmp	return_3DNow
+
+NO_3DNow_FEATURE:
 
-return0:
 	popad
 	xor	eax,eax
-	ret
+
+return_3DNow:    
+
+	mov	esp,ebp
+	pop	ebp
+        ret
+        
+        
         
         end
diff -duHr lame.20001203/libmp3lame/lame.c lame.org/libmp3lame/lame.c
--- lame.20001203/libmp3lame/lame.c	Wed Nov 29 16:45:36 2000
+++ lame.org/libmp3lame/lame.c	Mon Dec  4 15:32:44 2000
@@ -20,9 +20,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
-/* $Id: lame.c,v 1.54 2000/11/26 20:58:48 robert Exp $ */
-
-//#define KLEMM_42
+/* $Id: lame.c,v 1.55 2000/12/03 23:00:14 markt Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
@@ -237,7 +235,7 @@
     if (channels >= 2. )
         br /= 1.75 + 0.25 * (channels-2.);    // MS needs 1.75x mono, LR needs 2.00x mono (experimental data of a lot of albums)
         
-    br *= 0.5;                                // the sine and cosine term must share the bitrate
+    br *= 0.5;                                // the sinus and cosine term must share the bitrate
 
 /* 
  *  So, now we have the bitrate for every spectral line.
@@ -270,7 +268,7 @@
  *   What I propose?
  *       A slightly with the bitrate increasing bits/line function. It is
  *       better to decrease NMR for low bitrates to get a little bit more
- *       bandwidth. So we have a better trade off between twickling and
+ *       bandwidth. So we have a better trade of between twickling and
  *       muffled sound.
  */    
 
@@ -311,7 +309,7 @@
 	// fflush (stdout);
 	
 	while ( f_low > f_low_sw ) {
-	    double  dATH = ATHformula (f_low) - ATHformula (f_low_sw);	// [dB]
+	    double  dATH = ATHformula (f_low*1.e-3) - ATHformula (f_low_sw*1.e-3);	// [dB]
 	    double  dNMR = br / f_low - br_sw / f_low_sw;		// bit
 
   	    // printf ("br   =%f  f_low   =%f\n", br   , f_low    );
@@ -321,7 +319,7 @@
 	    
 	    if ( dATH / 4.0  <  dNMR * 6.0206 / 1.25 )			// 1 bit = 6.0206... dB
 		break;
-	    f_low *= 0.99609375;
+	    f_low -= 25.;
 	}
     } 
 
@@ -371,7 +369,8 @@
 /*
  * Rules:
  *
- *  - output sample frequency should NOT be decreased by more than 3% if lowpass allows this
+ *  - input sample frequency should be decreased 
+ *    by more than 3% if lowpass allows this
  *  - if possible, sfb21 should NOT be used
  *
  *  Problem: Switches to 32 kHz at 112 kbps
@@ -408,91 +407,95 @@
     int                  j;
     lame_internal_flags* gfc = gfp -> internal_flags;
 
-    gfc -> gfp                = gfp;
-
     gfc -> Class_ID           = 0;
   
     gfc -> CPU_features_i387  = has_i387  ();
     gfc -> CPU_features_3DNow = has_3DNow ();
     gfc -> CPU_features_MMX   = has_MMX   ();
     gfc -> CPU_features_SIMD  = has_SIMD  ();
-    gfc -> CPU_features_SIMD2 = has_SIMD2 ();
+    gfc -> CPU_features_SIMD2 = 0;
     
     //init_scalar_functions ( gfc );      /* Select the fastest functions for this CPU */
 
-    gfc->channels_in  = gfp->num_channels;
-    if ( gfc->channels_in == 1 ) 
-	gfp->mode     = MPG_MD_MONO;
-    gfc->channels_out = (gfp->mode == MPG_MD_MONO)  ?  1  :  2;
-    gfc->mode_ext     = MPG_MD_LR_LR;
-    if ( gfp->mode == MPG_MD_MONO ) gfp->force_ms = 0;	// don't allow forced mid/side stereo for mono output
+  if (gfp->num_channels == 1)
+      gfp->mode = MPG_MD_MONO;
+  
+  if (gfp->mode == MPG_MD_MONO) 
+      gfc->stereo = 1;  /* malicious variable name, really */
+  else
+      gfc->stereo = 2;
 
-    /* Here are some hidden flaws, the first step to show them is to reformat this
-     * code. The next steps are little code morphings to ease the readability of
-     * this code and to show some strange (may be wanted???) misbehaves.
-     * The reason of this flaws are extending of the automation without understanding
-     * the rest of the automation code.
-     * 
-     * Another point are changes in the documentation. Some adds, some removes
-     * of old (for the current code wrong) remarks, etc.
-     */
-    
-    if ( gfp->VBR != vbr_off )  /* VBR can't be combined with Free format */
-	gfp->free_format = 0;
+  if (gfp->VBR!=vbr_off) {
+    gfp->free_format=0;  /* VBR can't be mixed with free format */
+  }
 
-    if ( gfp->VBR == vbr_off  &&  gfp->brate == 0 )  /* no bitrate or compression ratio specified, so use a compression ratio of 11.025 (CD => 128 kbps) */
-	if ( gfp->compression_ratio == 0 ) gfp->compression_ratio = 11.025;
+  if (gfp->VBR==vbr_off && gfp->brate==0) {
+    /* no bitrate or compression ratio specified, use 11.025 */
+    if (gfp->compression_ratio==0) gfp->compression_ratio=11.025;   /* rate to compress a CD down to exactly 128000 bps */
+  }
 
-    /* find bitrate if now a compression ratio is specified */
-    if ( gfp->VBR == vbr_off  &&  gfp->compression_ratio > 0 ) {
+
+  /* find bitrate if user specify a compression ratio */
+  if (gfp->VBR==vbr_off && gfp->compression_ratio > 0) {
     
-	if ( gfp->out_samplerate == 0 ) 
-	    gfp->out_samplerate = map2MP3Frequency (0.97 * gfp->in_samplerate); /* round up with a margin of 3% */
+    if (gfp->out_samplerate==0) 
+      gfp->out_samplerate = map2MP3Frequency (0.97 * gfp->in_samplerate); /* round up with a margin of 3% */
+    
+    /* choose a bitrate for the output samplerate which achieves
+     * specified compression ratio 
+     */
+    gfp->brate = 
+      gfp->out_samplerate*16*gfc->stereo/(1000.0*gfp->compression_ratio);
 
-	/* choose a bitrate for the output samplerate which achieves specified compression ratio */
-	gfp->brate = gfp->out_samplerate * 16 * gfc->channels_out / (1.e3 * gfp->compression_ratio);
+    /* we need the version for the bitrate table look up */
+    gfc->samplerate_index = SmpFrqIndex(gfp->out_samplerate, &gfp->version);
+    /* find the nearest allowed bitrate */
+    if (!gfp->free_format)
+      gfp->brate = FindNearestBitrate(gfp->brate,gfp->version,gfp->out_samplerate);
+  }
+  if (gfp->brate >= 320) gfp->VBR=vbr_off;  /* don't bother with VBR at 320kbs */
 
-	/* we need the version for the bitrate table look up */
-	gfc->samplerate_index = SmpFrqIndex ( gfp->out_samplerate, &gfp->version );
 
-	if ( !gfp->free_format )   /* for non Free Format find the nearest allowed bitrate */
-	    gfp->brate = FindNearestBitrate ( gfp->brate, gfp->version, gfp->out_samplerate );
-    }
+
+  /* set the output sampling rate, and resample options if necessary
+     samplerate = input sample rate
+     resamplerate = ouput sample rate
+  */
     
-    if ( gfp->VBR != vbr_off  &&  gfp->brate >= 320 ) 
-	gfp->VBR = vbr_off;  /* at 160 kbps (MPEG-2/2.5)/ 320 kbps (MPEG-1) only Free format or CBR are possible, no VBR */
+  if (gfp->out_samplerate==0) {
+    /* if resamplerate is not valid, find a valid value */
+    gfp->out_samplerate = map2MP3Frequency (0.97 * gfp->in_samplerate);
 
-    if ( gfp->out_samplerate == 0 ) { /* if output sample frequency is not given, find an useful value */
-	gfp->out_samplerate = map2MP3Frequency (0.97 * gfp->in_samplerate);
 
-	/* check if user specified bitrate requires downsampling, if compression    */
-	/* ratio is > 13, choose a new samplerate to get the ratio down to about 10 */
-	 
-	if ( gfp->VBR == vbr_off  &&  gfp->brate > 0 ) {
-	    gfp->compression_ratio = gfp->out_samplerate * 16*gfc->channels_out / (1.e3 * gfp->brate);
-	    if ( gfp->compression_ratio > 13. )
-		gfp->out_samplerate = map2MP3Frequency ( (10. * 1.e3*gfp->brate)/(16 * gfc->channels_out) );
-	}
-	if ( gfp->VBR == vbr_abr ) {
-	    gfp->compression_ratio = gfp->out_samplerate * 16*gfc->channels_out / (1.e3 * gfp->VBR_mean_bitrate_kbps );
-	    if (gfp->compression_ratio > 13. )
-		gfp->out_samplerate = map2MP3Frequency ( (10. * 1.e3*gfp->VBR_mean_bitrate_kbps)/(16 * gfc->channels_out));
-	}
+    /* check if user specified bitrate requires downsampling */
+    /* if compression ratio is > 13, choose a new samplerate to get
+     * the compression ratio down to about 10 */
+    if (gfp->VBR==vbr_off && gfp->brate>0) {
+      gfp->compression_ratio = gfp->out_samplerate*16*gfc->stereo/(1000.0*gfp->brate);
+      if (gfp->compression_ratio > 13 ) {
+	gfp->out_samplerate = map2MP3Frequency((10*1000*gfp->brate)/(16*gfc->stereo));
+      }
     }
-
-    if ( gfp->ogg ) {
-        gfp->framesize     = 1024;
-        gfp->encoder_delay = ENCDELAY;
-	gfc->coding        = coding_Ogg_Vorbis;
-    } else {
-        gfc->mode_gr       = gfp->out_samplerate <= 24000  ?  1  :  2;  // Number of granules per frame
-        gfp->framesize     = 576 * gfc->mode_gr;
-        gfp->encoder_delay = ENCDELAY;
-	gfc->coding        = coding_MPEG_Layer_3;
+    if (gfp->VBR==vbr_abr) {
+      gfp->compression_ratio = 
+	gfp->out_samplerate*16*gfc->stereo/(1000.0*gfp->VBR_mean_bitrate_kbps);
+      if (gfp->compression_ratio > 13 ) {
+	gfp->out_samplerate = 
+	  map2MP3Frequency((10*1000*gfp->VBR_mean_bitrate_kbps)/(16*gfc->stereo));
+      }
     }
-    
-    gfc->frame_size     = gfp->framesize;
-    gfc->resample_ratio = (double)gfp->in_samplerate / gfp->out_samplerate;
+  }
+
+  gfc->mode_gr = (gfp->out_samplerate <= 24000) ? 1 : 2;  /* mode_gr = 2 */
+  gfp->framesize = gfc->mode_gr*576;
+  if (gfp->ogg) gfp->framesize = 1024;
+
+  gfp->encoder_delay = ENCDELAY;
+
+    if ( gfp->out_samplerate != gfp->in_samplerate ) 
+        gfc->resample_ratio = (double)gfp->in_samplerate / gfp->out_samplerate;
+    else
+        gfc->resample_ratio = 1.;
 
     /* 
      *  sample freq       bitrate     compression ratio
@@ -534,10 +537,10 @@
         gfp->compression_ratio = cmp [ gfp->VBR_q ];
 	break;
     case vbr_abr:
-        gfp->compression_ratio = gfp->out_samplerate * 16 * gfc->channels_out / (1.e3 * gfp->VBR_mean_bitrate_kbps);
+        gfp->compression_ratio = gfp->out_samplerate * 16 * gfc->stereo / (1.e3 * gfp->VBR_mean_bitrate_kbps);
 	break;
     default:  
-        gfp->compression_ratio = gfp->out_samplerate * 16 * gfc->channels_out / (1.e3 * gfp->brate);
+        gfp->compression_ratio = gfp->out_samplerate * 16 * gfc->stereo / (1.e3 * gfp->brate);
 	break;
     }
 
@@ -575,8 +578,11 @@
    *   fs < 32 kHz I have not tested.
    */
    
-    if ( !gfp->mode_fixed  &&  gfp->mode != MPG_MD_MONO  &&  gfp->compression_ratio < 9 )
-        gfp->mode = MPG_MD_STEREO;
+  if ( (!gfp->mode_fixed) && (gfp->mode !=MPG_MD_MONO)) {
+    if (gfp->compression_ratio /* <= 8.82 */ < 9 ) {
+      gfp->mode = MPG_MD_STEREO;
+    }
+  }
 
 #endif    
 
@@ -609,7 +615,7 @@
 	
         optimum_bandwidth ( &lowpass, 
 	                    &highpass, 
-			    gfp->out_samplerate * 16 * gfc->channels_out / gfp->compression_ratio,
+			    gfp->out_samplerate * 16 * gfc->stereo / gfp->compression_ratio,
 			    gfp->out_samplerate,
 			    channels );
 			
@@ -712,99 +718,116 @@
 #endif    
   
 
-    /************************************************************************/
-    /* compute info needed for polyphase filter (filter type==0, default)   */
-    /************************************************************************/
-    lame_init_params_ppflt (gfc);
 
-    /***************************************************************/
-    /* compute info needed for FIR filter (filter_type==1)         */
-    /***************************************************************/
-    /* not yet coded */
 
+  /***************************************************************/
+  /* compute info needed for polyphase filter (filter type==0, default)   */
+  /***************************************************************/
+  lame_init_params_ppflt(gfc);
 
-    gfc->samplerate_index = SmpFrqIndex ( gfp->out_samplerate, &gfp->version );
-    if ( gfc->samplerate_index < 0 )
+
+  /***************************************************************/
+  /* compute info needed for FIR filter (filter_type==1) */
+  /***************************************************************/
+  /* not yet coded */
+
+  gfc->mode_ext=MPG_MD_LR_LR;
+  gfc->stereo = (gfp->mode == MPG_MD_MONO) ? 1 : 2;
+
+  gfc->samplerate_index = SmpFrqIndex(gfp->out_samplerate, &gfp->version);
+  if( gfc->samplerate_index < 0) {
+    return -1;
+  }
+  if (gfp->free_format) {
+    gfc->bitrate_index=0;
+  }else{
+    if( (gfc->bitrate_index = BitrateIndex(gfp->brate, gfp->version,gfp->out_samplerate)) < 0) {
+      return -1;
+    }
+  }
+
+
+  /* choose a min/max bitrate for VBR */
+  if (gfp->VBR!=vbr_off) {
+    /* if the user didn't specify VBR_max_bitrate: */
+    if (0==gfp->VBR_max_bitrate_kbps) {
+      gfc->VBR_max_bitrate = 14;      /* default: allow 160 kbps (MPEG-2) or 320 kbps (MPEG-1) */
+    }else{
+      if( (gfc->VBR_max_bitrate  = BitrateIndex(gfp->VBR_max_bitrate_kbps, gfp->version,gfp->out_samplerate)) < 0) {
 	return -1;
-  
-    if ( gfp->VBR == vbr_off ) {
-        if ( gfp->free_format ) {
-	    gfc->bitrate_index = 0;
-        } else {
-	    gfc->bitrate_index = BitrateIndex ( gfp->brate, gfp->version,
-                                                gfp->out_samplerate );
-            if ( gfc->bitrate_index < 0 )
-	        return -1;  
-        }
+      }
+    }
+    if (0==gfp->VBR_min_bitrate_kbps) {
+      gfc->VBR_min_bitrate =  1;      /* default: allow 8 kbps (MPEG-2) or 32 kbps (MPEG-1) */
+    }else{
+      if( (gfc->VBR_min_bitrate  = BitrateIndex(gfp->VBR_min_bitrate_kbps, gfp->version,gfp->out_samplerate)) < 0) {
+	return -1;
+      }
     }
-    else { /* choose a min/max bitrate for VBR */
-        /* if the user didn't specify VBR_max_bitrate: */
-	gfc->VBR_min_bitrate =  1;      /* default: allow   8 kbps (MPEG-2) or  32 kbps (MPEG-1) */
-	gfc->VBR_max_bitrate = 14;      /* default: allow 160 kbps (MPEG-2) or 320 kbps (MPEG-1) */
-	
-	if ( gfp->VBR_min_bitrate_kbps )
-	    if ( (gfc->VBR_min_bitrate = BitrateIndex ( gfp->VBR_min_bitrate_kbps, gfp->version,gfp->out_samplerate)) < 0 )
-		return -1;	    
-	if ( gfp->VBR_max_bitrate_kbps )
-	    if ( (gfc->VBR_max_bitrate = BitrateIndex ( gfp->VBR_max_bitrate_kbps, gfp->version,gfp->out_samplerate)) < 0 )
-		return -1;
 
-	gfp->VBR_min_bitrate_kbps  = bitrate_table [gfp->version] [gfc->VBR_min_bitrate];
-	gfp->VBR_max_bitrate_kbps  = bitrate_table [gfp->version] [gfc->VBR_max_bitrate];
-	
-	gfp->VBR_mean_bitrate_kbps = Min ( bitrate_table [gfp->version] [gfc->VBR_max_bitrate], gfp->VBR_mean_bitrate_kbps );
-	gfp->VBR_mean_bitrate_kbps = Max ( bitrate_table [gfp->version] [gfc->VBR_min_bitrate], gfp->VBR_mean_bitrate_kbps );
-      
-	/* Note: ABR mode should normally be used without a -V n setting,
-	 * (or with the default value of 4)
-	 * but the code below allows us to test how adjusting the maskings
-	 * effects CBR encodings.  Lowering the maskings will make LAME
-	 * work harder to get over=0 and may give better noise shaping?
-	 */
+    gfp->VBR_min_bitrate_kbps = bitrate_table[gfp->version][gfc->VBR_min_bitrate];
+    gfp->VBR_max_bitrate_kbps = bitrate_table[gfp->version][gfc->VBR_max_bitrate];
+
+    gfp->VBR_mean_bitrate_kbps = Min(bitrate_table[gfp->version][gfc->VBR_max_bitrate],gfp->VBR_mean_bitrate_kbps);
+    gfp->VBR_mean_bitrate_kbps = Max(bitrate_table[gfp->version][gfc->VBR_min_bitrate],gfp->VBR_mean_bitrate_kbps);
+    
+    /* Note: ABR mode should normally be used without a -V n setting,
+     * (or with the default value of 4)
+     * but the code below allows us to test how adjusting the maskings
+     * effects CBR encodings.  Lowering the maskings will make LAME
+     * work harder to get over=0 and may give better noise shaping?
+     */
+
+      /* A third dbQ table */
+      /* Can all dbQ setup can be done here using a switch statement? */
+
      
         switch ( gfp->VBR ) {
 	case vbr_abr:
-	    assert ( (unsigned)gfp->VBR_q < sizeof(dbQ)/sizeof(*dbQ) );
-	    assert ( (unsigned)gfp->VBR_q < sizeof(atQ)/sizeof(*atQ) );
+	    assert( (unsigned)gfp->VBR_q < sizeof(dbQ)/sizeof(*dbQ) );
+	    assert( (unsigned)gfp->VBR_q < sizeof(atQ)/sizeof(*atQ) );
             gfc->masking_lower = pow (10., 0.1 * dbQ [gfp->VBR_q] );
             gfc->ATH_vbrlower  = atQ [ gfp->VBR_q ];
             break;
         case vbr_rh:
         case vbr_mtrh:
-	    assert ( (unsigned)gfp->VBR_q < sizeof(atQ)/sizeof(*atQ) );
+	    assert( (unsigned)gfp->VBR_q < sizeof(atQ)/sizeof(*atQ) );
 	    gfc->ATH_vbrlower  = atQ [ gfp->VBR_q ];
             break;
 	default:
 	    break;
 	}
-    }
+  }
 
-    /* 
-     * VBR needs at least the output of GPSYCHO,
-     * so we have to garantee that by setting a minimum 
-     * quality level, actually level 5 does it.
-     * the -v and -V x settings switch the quality to level 2
-     * you would have to add a -q 5 to reduce the quality
-     * down to level 5
-     */
-    
-    if ( gfp->VBR != vbr_off )      gfp->quality = Min ( gfp->quality, 5 );
-    
-    /* Do not write VBR tag if VBR flag is not specified */
-    if ( gfp->VBR==vbr_off ) gfp->bWriteVbrTag = 0;
-    if ( gfp->ogg )          gfp->bWriteVbrTag = 0;
-    if ( gfp->analysis )     gfp->bWriteVbrTag = 0;
-    
-    /* some file options not allowed if output is: not specified or stdout */
-    if ( gfc->pinfo != NULL )
-	gfp->bWriteVbrTag = 0;  /* disable Xing VBR tag */  
+  /* VBR needs at least the output of GPSYCHO,
+   * so we have to garantee that by setting a minimum 
+   * quality level, actually level 5 does it.
+   * the -v and -V x settings switch the quality to level 2
+   * you would have to add a -q 5 to reduce the quality
+   * down to level 5
+   */
+  if (gfp->VBR!=vbr_off) gfp->quality=Min(gfp->quality,5);
+  /* dont allow forced mid/side stereo for mono output */
+  if (gfp->mode == MPG_MD_MONO) gfp->force_ms=0;
 
-    init_bit_stream_w ( gfc );
 
-    /* 
-     * Sets internal feature flags.  
-     * User should not access these since some combinations will produce strange results
-     */
+  /* Do not write VBR tag if VBR flag is not specified */
+  if (gfp->VBR==vbr_off) gfp->bWriteVbrTag=0;
+  if (gfp->ogg) gfp->bWriteVbrTag=0;
+  if (gfp->analysis) gfp->bWriteVbrTag=0;
+
+  /* some file options not allowed if output is: not specified or stdout */
+
+  if (gfc->pinfo != NULL) {
+    gfp->bWriteVbrTag=0;  /* disable Xing VBR tag */
+  }
+
+  init_bit_stream_w(gfc);
+
+
+  /* set internal feature flags.  USER should not access these since
+   * some combinations will produce strange results */
+
 
     switch ( gfp->quality ) {
     case 9: /* no psymodel, no noise shaping */
@@ -885,13 +908,14 @@
 
     /* determine the mean bitrate for main data */
     if ( gfp->version == 1 ) /* MPEG 1 */
-	gfc->sideinfo_len = (gfc->channels_out == 1)  ?  4+17  :  4+32;
+	gfc->sideinfo_len = (gfc->stereo == 1)  ?  4+17  :  4+32;
     else                     /* MPEG 2 */
-	gfc->sideinfo_len = (gfc->channels_out == 1)  ?  4+ 9  :  4+17;
+	gfc->sideinfo_len = (gfc->stereo == 1)  ?  4+ 9  :  4+17;
   
     if ( gfp->error_protection ) 
         gfc->sideinfo_len += 2;
   
+
     /* 
      *  Write id3v2 tag into the bitstream.
      *  This tag must be before the Xing VBR header.
@@ -910,37 +934,10 @@
   
     gfc->nsPsy.use = gfp->exp_nspsytune;
 
-    switch (gfp->VBR) {
-    case vbr_mt:
-    case vbr_rh:
-    case vbr_mtrh:
-        if (gfc->nsPsy.use == 1 || gfp->experimentalY == 1) 
-            gfc->amp_mode = amp_mode_mid;
-        else
-            gfc->amp_mode = gfp->quality > 2 ? amp_mode_all : amp_mode_low; 
-        break;
-    default:
-    case vbr_off:
-    case vbr_abr:
-        if (gfc->nsPsy.use == 1 || gfp->experimentalY == 1)
-            gfc->amp_mode = amp_mode_max;
-        else
-#ifdef RH_AMP
-            gfc->amp_mode = gfp->quality > 2 ? amp_mode_all : amp_mode_low; 
-#else
-            gfc->amp_mode = amp_mode_all; 
-#endif
-        break;
-    }
-    if (gfp->version == 1) /* 0 indicates use lower sample freqs algorithm */
-        gfc->is_mpeg1 = 1; /* yes */
-    else
-        gfc->is_mpeg1 = 0; /* no */
-
     /* estimate total frames.  */
     gfp->totalframes           = 2 + gfp->num_samples/(gfc->resample_ratio * gfp->framesize);
     gfc->Class_ID              = LAME_ID;
-
+    
     return 0;
 }
 
@@ -984,7 +981,7 @@
         MSGF ("\n");  
     }
   
-    if ( gfp->num_channels==2  &&  gfc->channels_out==1 /* mono */ ) {
+    if ( gfp->num_channels==2  &&  gfc->stereo==1 /* mono */ ) {
 	MSGF ("Autoconverting from stereo to mono. Setting encoding to mono mode.\n");
     }
     
@@ -1029,7 +1026,7 @@
 */
 int lame_encode_frame(lame_global_flags *gfp,
 sample_t inbuf_l[],sample_t inbuf_r[],
-unsigned char *mp3buf, int mp3buf_size)
+char *mp3buf, int mp3buf_size)
 {
   int ret;
   if (gfp->ogg) {
@@ -1080,7 +1077,7 @@
         const short int     buffer_l [],
         const short int     buffer_r [],
         int                 nsamples,
-        unsigned char*      mp3buf,
+        char*               mp3buf,
         const int           mp3buf_size )
 {
   lame_internal_flags *gfc = gfp->internal_flags;
@@ -1123,7 +1120,7 @@
   mfbuf[0]=gfc->mfbuf[0];
   mfbuf[1]=gfc->mfbuf[1];
 
-  if (gfp->num_channels==2  && gfc->channels_out==1) {
+  if (gfp->num_channels==2  && gfc->stereo==1) {
     /* downsample to mono */
     for (i=0; i<nsamples; ++i) {
       in_buffer[0][i] = 0.5 * ( (FLOAT8)in_buffer[0][i] + in_buffer[1][i] );
@@ -1138,7 +1135,7 @@
 
     /* copy in new samples into mfbuf, with resampling if necessary */
     if (gfc->resample_ratio != 1.0)  {
-      for (ch=0; ch<gfc->channels_out; ch++) {
+      for (ch=0; ch<gfc->stereo; ch++) {
 	n_out = fill_buffer_resample(gfp,&mfbuf[ch][gfc->mf_size],gfp->framesize, in_buffer[ch],nsamples,&n_in,ch);
 	in_buffer[ch] += n_in;
       }
@@ -1147,7 +1144,7 @@
       n_in=n_out;
       for (i = 0 ; i< n_out; ++i) {
 	mfbuf[0][gfc->mf_size+i]=in_buffer[0][i];
-	if (gfc->channels_out==2)
+	if (gfc->stereo==2)
 	  mfbuf[1][gfc->mf_size+i]=in_buffer[1][i];
       }
       in_buffer[0] += n_in;
@@ -1174,7 +1171,7 @@
       /* shift out old samples */
       gfc->mf_size -= gfp->framesize;
       gfc->mf_samples_to_encode -= gfp->framesize;
-      for (ch=0; ch<gfc->channels_out; ch++)
+      for (ch=0; ch<gfc->stereo; ch++)
 	for (i=0; i<gfc->mf_size; i++)
 	  mfbuf[ch][i]=mfbuf[ch][i+gfp->framesize];
     }
@@ -1196,7 +1193,7 @@
                 lame_global_flags* gfp,
                 short int          buffer [],
                 int                nsamples,
-                unsigned char*     mp3buf,
+                char*              mp3buf,
                 int                mp3buf_size )
 {
   int mp3size = 0, ret, i, ch, mf_needed;
@@ -1251,7 +1248,7 @@
      * averaging L & R channels if we are encoding mono with
      * stereo input */
     for (i=0; i<n_out; ++i) {
-      if (gfp->num_channels==2  && gfc->channels_out==1) {
+      if (gfp->num_channels==2  && gfc->stereo==1) {
 	mfbuf[0][gfc->mf_size+i]=((int)buffer[2*i]+(int)buffer[2*i+1])/2.0;
 	mfbuf[1][gfc->mf_size+i]=0;
       }else{
@@ -1272,7 +1269,7 @@
       /* encode the frame */
       ret = lame_encode_frame(gfp,mfbuf[0],mfbuf[1],mp3buf,mp3buf_size);
       if (ret < 0) {
-	/* fatal error: mp3buffer was too small */
+	/* fatel error: mp3buffer was too small */
 	return ret;
       }
       mp3buf += ret;
@@ -1281,7 +1278,7 @@
       /* shift out old samples */
       gfc->mf_size -= gfp->framesize;
       gfc->mf_samples_to_encode -= gfp->framesize;
-      for (ch=0; ch<gfc->channels_out; ch++)
+      for (ch=0; ch<gfc->stereo; ch++)
 	for (i=0; i<gfc->mf_size; i++)
 	  mfbuf[ch][i]=mfbuf[ch][i+gfp->framesize];
     }
@@ -1300,7 +1297,7 @@
 int lame_encode (
         lame_global_flags* const  gfp,
         const short int           in_buffer [2] [1152],
-        unsigned char* const      mp3buf,
+        char* const               mp3buf,
         const int                 size )
 {
     lame_internal_flags*  gfc = gfp->internal_flags;
@@ -1319,7 +1316,7 @@
 
 int    lame_encode_flush (
                 lame_global_flags* gfp,
-                unsigned char*     mp3buffer,
+                char*              mp3buffer,
                 int                mp3buffer_size )
 {
     short int buffer[2][1152];
@@ -1416,7 +1413,7 @@
 
 int    lame_encode_finish (
                 lame_global_flags* gfp,
-                unsigned char*     mp3buffer,
+                char*              mp3buffer,
                 int                mp3buffer_size )
 {
     int ret = lame_encode_flush( gfp, mp3buffer, mp3buffer_size );
diff -duHr lame.20001203/libmp3lame/mpglib_interface.c lame.org/libmp3lame/mpglib_interface.c
--- lame.20001203/libmp3lame/mpglib_interface.c	Wed Nov 29 16:44:27 2000
+++ lame.org/libmp3lame/mpglib_interface.c	Mon Dec  4 15:32:44 2000
@@ -1,4 +1,4 @@
-/* $Id: mpglib_interface.c,v 1.12 2000/11/26 10:50:00 robert Exp $ */
+/* $Id: mpglib_interface.c,v 1.13 2000/12/03 23:00:14 markt Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
@@ -18,11 +18,13 @@
 
 MPSTR           mp;
 plotting_data*  mpg123_pinfo = NULL;
+// static char     buf [16384];
 
 
 int  lame_decode_init ( void )
 {
     InitMP3 ( &mp );
+//  memset ( buf, 0, sizeof(buf) );
     return 0;
 }
 
@@ -34,7 +36,7 @@
  */
  
 int  lame_decode1_headers (
-        unsigned char*   buffer,
+        char*            buffer,
         int              len,
         short            pcm_l [],
         short            pcm_r [],
@@ -55,6 +57,11 @@
     mp3data->header_parsed = 0;
   
     ret = decodeMP3 ( &mp, buffer, len, (char*)p, sizeof(out), &processed_bytes );
+    //                                  ^^^^^^^^^^^^^^^^^^^^^
+    //  this argument is the size of the output buffer in bytes.
+    //  Even though decodeMP3 returns short ints!
+    //
+    // Then sizeof(out) is really right, as expected. Changed.
   
     if ( mp.header_parsed ) {
         mp3data->header_parsed = 1;
@@ -87,7 +94,6 @@
 	    }
 	    break;
 	default:
-            processed_samples = -1;
 	    assert (0);
 	    break;
         }    
@@ -120,7 +126,7 @@
  */
  
 int  lame_decode1 ( 
-        unsigned char*  buffer,
+        char*  buffer,
 	int    len,
 	short  pcm_l [],
 	short  pcm_r [] )
@@ -139,7 +145,7 @@
  */
  
 int  lame_decode_headers ( 
-        unsigned char*   buffer,
+        char*            buffer,
 	int              len,
 	short            pcm_l [],
 	short            pcm_r [],
@@ -161,7 +167,7 @@
 
 
 int  lame_decode (
-        unsigned char*  buffer,
+        char*  buffer,
 	int    len,
 	short  pcm_l [],
 	short  pcm_r [] )
diff -duHr lame.20001203/libmp3lame/newmdct.c lame.org/libmp3lame/newmdct.c
--- lame.20001203/libmp3lame/newmdct.c	Wed Nov 29 16:44:27 2000
+++ lame.org/libmp3lame/newmdct.c	Mon Dec  4 15:32:44 2000
@@ -24,7 +24,7 @@
  *         Special Thanks to Patrick De Smet for your advices.
  */
 
-/* $Id: newmdct.c,v 1.18 2000/11/26 10:50:00 robert Exp $ */
+/* $Id: newmdct.c,v 1.19 2000/12/03 23:00:14 markt Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
@@ -370,12 +370,12 @@
 
 
 /* returns sum_j=0^31 a[j]*cos(PI*j*(k+1/2)/32), 0<=k<32 */
-inline static void window_subband ( const sample_t *x1, FLOAT8 a[SBLIMIT] )
+inline static void window_subband(sample_t *x1, FLOAT8 a[SBLIMIT])
 {
     int i;
     FLOAT8 const *wp = enwindow+10;
 
-    const sample_t *x2 = &x1[238-14-286];
+    sample_t *x2 = &x1[238-14-286];
 
     for (i = -15; i < 0; i++) {
 	FLOAT8 w, s, t;
@@ -712,15 +712,15 @@
 }
 
 
-void mdct_sub48( lame_internal_flags *gfc, const sample_t *w0, const sample_t *w1, 
+void mdct_sub48( lame_internal_flags *gfc, sample_t *w0, sample_t *w1, 
                  FLOAT8 mdct_freq[2][2][576] )
 {
     int gr, k, ch;
-    const sample_t *wk;
+    sample_t *wk;
 
     wk = w0 + 286;
     /* thinking cache performance, ch->gr loop is better than gr->ch loop */
-    for (ch = 0; ch < gfc->channels_out; ch++) {
+    for (ch = 0; ch < gfc->stereo; ch++) {
 	for (gr = 0; gr < gfc->mode_gr; gr++) {
 	    int	band;
 	    FLOAT8 *mdct_enc = &mdct_freq[gr][ch][0];
diff -duHr lame.20001203/libmp3lame/newmdct.h lame.org/libmp3lame/newmdct.h
--- lame.20001203/libmp3lame/newmdct.h	Wed Nov 29 16:44:27 2000
+++ lame.org/libmp3lame/newmdct.h	Mon Dec  4 15:32:44 2000
@@ -22,7 +22,7 @@
 #ifndef LAME_NEWMDCT_H
 #define LAME_NEWMDCT_H
 
-void mdct_sub48(lame_internal_flags *gfc,const sample_t *w0, const sample_t *w1,
+void mdct_sub48(lame_internal_flags *gfc,sample_t *w0, sample_t *w1,
 		FLOAT8 mdct_freq[2][2][576]);
 
 #endif /* LAME_NEWMDCT_H */
diff -duHr lame.20001203/libmp3lame/psymodel.c lame.org/libmp3lame/psymodel.c
--- lame.20001203/libmp3lame/psymodel.c	Fri Dec  1 18:42:08 2000
+++ lame.org/libmp3lame/psymodel.c	Mon Dec  4 15:32:47 2000
@@ -19,7 +19,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
-/* $Id: psymodel.c,v 1.25 2000/12/01 17:42:08 aleidinger Exp $ */
+/* $Id: psymodel.c,v 1.26 2000/12/03 23:00:14 markt Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
@@ -110,7 +110,7 @@
 }
 
 int L3psycho_anal( lame_global_flags * gfp,
-                    const sample_t *buffer[2], int gr_out, 
+                    sample_t *buffer[2],int gr_out , 
                     FLOAT8 *ms_ratio,
                     FLOAT8 *ms_ratio_next,
 		    FLOAT8 *ms_ener_ratio,
@@ -187,7 +187,7 @@
     case  8000: samplerate *= 2; break;  /* kludge so mpeg2.5 uses mpeg2 tables  for now */
     case 11025: samplerate *= 2; break;
     case 12000: samplerate *= 2; break;
-    default:    ERRORF("error, invalid sampling frequency: %d Hz\a\n",
+    default:    ERRORF("error, invalid sampling frequency: %d Hz\n",
 			gfp->out_samplerate);
     return -1;
     }
@@ -337,20 +337,11 @@
 
   
   
-  numchn = gfc->channels_out;
+  numchn = gfc->stereo;
   /* chn=2 and 3 = Mid and Side channels */
   if (gfp->mode == MPG_MD_JOINT_STEREO) numchn=4;
 
   if (gfc->nsPsy.use) {
-#ifdef KLEMM_04
-    static const sample_t fircoef[] = {
-      0,-0.00851586, 0  , 0.0209036,
-      0,-0.0438162 , 0  , 0.0931738,
-      0,-0.313819  , 0.5,-0.313819,
-      0, 0.0931738 , 0  ,-0.0438162,
-      0, 0.0209036 , 0  ,-0.00851586,
-    };
-#else    
     static const FLOAT fircoef[] = {
       -8.65163e-18,-0.00851586,-6.74764e-18, 0.0209036,
       -3.36639e-17,-0.0438162 ,-1.54175e-17, 0.0931738,
@@ -359,15 +350,11 @@
       -3.36639e-17, 0.0209036 ,-6.74764e-18,-0.00851586,
       -8.65163e-18,
     };
-#endif
 
-    for(chn=0;chn<gfc->channels_out;chn++)
+
+    for(chn=0;chn<gfc->stereo;chn++)
       {
-#ifdef KLEMM_04
-	sample_t firbuf [576 + 576/3 + NSFIRLEN];
-#else      
 	FLOAT firbuf[576+576/3+NSFIRLEN];
-#endif	
 
 	/* apply high pass filter of fs/4 */
 	
@@ -375,16 +362,12 @@
 	  firbuf[i+NSFIRLEN] = buffer[chn][576-350+(i)];
 
 	for(i=0;i<576+576/3-NSFIRLEN;i++)
-#ifdef KLEMM_04
-	    ns_hpfsmpl [chn] [i] = scalar20 ( fircoef, firbuf+i );
-#else
           {
 	    FLOAT sum = 0;
 	    for(j=0;j<NSFIRLEN;j++)
 	      sum += fircoef[j] * firbuf[i+j];
 	    ns_hpfsmpl[chn][i] = sum;
 	  }
-#endif	    
 
 	for(;i<576+576/3;i++)
 	  ns_hpfsmpl[chn][i] = 0;
@@ -1203,12 +1186,12 @@
    * determine final block type
    ***************************************************************/
 
-  for (chn=0; chn<gfc->channels_out; chn++) {
+  for (chn=0; chn<gfc->stereo; chn++) {
     blocktype[chn] = NORM_TYPE;
   }
 
 
-  if (gfc->channels_out==2) {
+  if (gfc->stereo==2) {
     if (!gfp->allow_diff_short || gfp->mode==MPG_MD_JOINT_STEREO) {
       /* force both channels to use the same block type */
       /* this is necessary if the frame is to be encoded in ms_stereo.  */
@@ -1225,7 +1208,7 @@
   
   /* update the blocktype of the previous granule, since it depends on what
    * happend in this granule */
-  for ( chn = 0; chn < gfc->channels_out; chn++ ) {
+  for (chn=0; chn<gfc->stereo; chn++) {
     if ( uselongblock[chn])
       {				/* no attack : use long blocks */
 	assert( gfc->blocktype_old[chn] != START_TYPE );
@@ -1288,123 +1271,175 @@
 
 
 
-int  L3para_read (
-	lame_global_flags* const gfp, 
-	FLOAT8   sfreq, 
-	int*     numlines_l,
-	int*     numlines_s, 
-	FLOAT8*  minval,
-	FLOAT8   s3_l [CBANDS] [CBANDS], 
-	FLOAT8   s3_s [CBANDS] [CBANDS],
-	FLOAT8*  SNR, 
-	int*     bu_l, 
-	int*     bo_l, 
-	FLOAT8*  w1_l, 
-	FLOAT8*  w2_l, 
-	int*     bu_s, 
-	int*     bo_s, 
-	FLOAT8*  w1_s, 
-	FLOAT8*  w2_s,
-	int*     npart_l_orig,
-	int*     npart_l,
-	int*     npart_s_orig,
-	int*     npart_s )
+int L3para_read(lame_global_flags * gfp, FLOAT8 sfreq, int *numlines_l,int *numlines_s, 
+FLOAT8 *minval,
+FLOAT8 s3_l[CBANDS][CBANDS], FLOAT8 s3_s[CBANDS][CBANDS],
+FLOAT8 *SNR, 
+int *bu_l, int *bo_l, FLOAT8 *w1_l, FLOAT8 *w2_l, 
+int *bu_s, int *bo_s, FLOAT8 *w1_s, FLOAT8 *w2_s,
+int *npart_l_orig,int *npart_l,int *npart_s_orig,int *npart_s)
 {
-    lame_internal_flags* const gfc = gfp->internal_flags;
-    FLOAT8          bval_l [CBANDS];
-    FLOAT8          bval_s [CBANDS];
-    int             cbmax;
-    int             i;
-    int             j;
-    int             index = sfreq==16000 ? 0 : sfreq==22050 ? 1 : sfreq==24000 ? 2 : sfreq==32000 ? 3 : sfreq==44100 ? 4 : sfreq==48000 ? 5 : -1;
-    const type5_t*  ti    = table5 + index;
-
-    /******************************************************************/
-    /* Read long block data (part 1)                                  */
-    /******************************************************************/
+  lame_internal_flags *gfc=gfp->internal_flags;
+  FLOAT8 freq_tp;
+  FLOAT8 bval_l[CBANDS], bval_s[CBANDS];
+  int   cbmax=0, cbmax_tp;
+  const FLOAT* p = psy_data;
+  int  sbmax ;
+  int  i,j,k2,loop;
+  int freq_scale=1;
+/*  int partition[HBLKSIZE]; */
 
-    *npart_l_orig = cbmax = ti->len1;
+  /******************************************************************/
+  /* Read long block data */
+  /******************************************************************/
+  for(loop=0;loop<6;loop++)
+    {
+      freq_tp = *p++;
+      cbmax_tp = (int) *p++;
+      cbmax_tp++;
 
-    for ( i = 0; i < cbmax; i++ ) {
-	if ( i != ti->tab1[i].no ) {
-	    ERRORF ("psy_data(%u): idx=%d  table idx=%f\a\n", 1, i, ti->tab1[i].no );
-	    return -1;
+      if (sfreq == freq_tp/freq_scale )
+	{
+	  cbmax = cbmax_tp;
+	  for(i=0,k2=0;i<cbmax_tp;i++)
+	    {
+	      j = (int) *p++;
+	      numlines_l[i] = (int) *p++;
+	      minval[i] = exp(-((*p++) ) * LN_TO_LOG10);
+	      /* qthr_l[i] = *p++ */ p++;
+	      /* norm_l[i] = *p++*/ p++;
+	      /* bval_l[i] = *p++; */ p++;
+	      if (j!=i)
+		{
+		  ERRORF("1. please check \"psy_data\"");
+		  return -1;
+		}
+	    }
 	}
-	numlines_l  [i] = ti->tab1[i].width;
-	minval      [i] = exp ( -LN_TO_LOG10 * ti->tab1[i].minval_2 / 2. );
-	// qthr_l [i] = ti->tab1[i].quiet_thr;
-	// norm_l [i] = ti->tab1[i].norm;
-	// bval_l [i] = ti->tab1[i].bark;
+      else
+	p += cbmax_tp * 6;
     }
 
-    /******************************************************************/
-    /* Read short block data (part 2)                                 */
-    /******************************************************************/
-
-    *npart_s_orig = cbmax = ti->len2;
+  *npart_l_orig = cbmax;
 
-    for ( i = 0; i < cbmax; i++ ) {
-	if ( i != ti->tab2[i].no ) {
-	    ERRORF ("psy_data(%u): idx=%d  table idx=%f\a\n", 2, i, ti->tab2[i].no );
-	    return -1;
-	}
-	numlines_s [i]  = ti->tab2[i].width;
-	// qthr_s [i] = ti->tab2[i].quiet_thr;
-	// norm_s [i] = ti->tab2[i].norm;
-	SNR [i]         = ti->tab2[i].SNR;
-	// bval_s [i] = ti->tab2[i].bark;
-	if ( SNR[i] <= 0 ) {
-	    ERRORF ("psy_data(%u): idx=%d  bad SNR: %f\a\n", 2, i, SNR[i] );
-	    return -1;
+  /* Read short block data */
+  for(loop=0;loop<6;loop++)
+    {
+      freq_tp = *p++;
+      cbmax_tp = (int) *p++;
+      cbmax_tp++;
+      if (sfreq == freq_tp/freq_scale )
+	{
+	  cbmax = cbmax_tp;
+	  for(i=0,k2=0;i<cbmax_tp;i++)
+	    {
+	      j = (int) *p++;
+	      numlines_s[i] = (int) *p++;
+	      /* qthr_s[i] = *p++*/  p++;         
+	      /* norm_s[i] =*p++ */ p++;         
+	      SNR[i] = *p++;            
+	      /* bval_s[i] = *p++ */ p++;
+	      if (j!=i)
+		{
+		  ERRORF("3. please check \"psy_data\"");
+		  return -1;
+		}
+	    }
 	}
+      else
+	p += cbmax_tp * 6;
     }
+  *npart_s_orig = cbmax;
 
-    /******************************************************************/
-    /* Read long block data for converting threshold                  */
-    /* calculation partitions to scale factor bands (part 3)          */
-    /******************************************************************/
+  /* MPEG1 SNR_s data is given in db, convert to energy */
+  if (gfp->version == 1) {
+    for ( i = 0;i < *npart_s_orig; i++ ) {
+      SNR[i]=exp( (FLOAT8) SNR[i] * LN_TO_LOG10 );
+    }
+  }
 
-    cbmax = ti->len3;
-    assert (cbmax == 21);
-    for ( i = 0; i < cbmax; i++ ) {
-	if ( i != ti->tab3[i].no ) {
-	    ERRORF ("psy_data(%u): idx=%d  table idx=%f\a\n", 3, i, ti->tab3[i].no );
-	    return -1;
-	}
-	bu_l [i] = ti->tab3[i].bu;
-	bo_l [i] = ti->tab3[i].bo;
-	w1_l [i] = ti->tab3[i].w1_576 / 576.;
-	w2_l [i] = ti->tab3[i].w2_576 / 576.;
-	
-	if ( i != 0  &&  fabs (1.-w1_l[i]-w2_l[i-1] > 1.e-6 ) ) {
-	    ERRORF ("psy_data(%u): idx=%d  sum error: w1=%f w2=%f\a\n", 3, i, w1_l [i], w2_l [i-1] );
-	    return -1;
+
+
+
+  /* Read long block data for converting threshold calculation 
+     partitions to scale factor bands */
+
+  for(loop=0;loop<6;loop++)
+    {
+      freq_tp = *p++;
+      sbmax =  (int) *p++;
+      sbmax++;
+
+      if (sfreq == freq_tp/freq_scale)
+	{
+	  for(i=0;i<sbmax;i++)
+	    {
+	      j = (int) *p++;
+	      p++;             
+	      bu_l[i] = (int) *p++;
+	      bo_l[i] = (int) *p++;
+	      w1_l[i] = (FLOAT8) *p++;
+	      w2_l[i] = (FLOAT8) *p++;
+	      if (j!=i)
+		{ ERRORF("30:please check \"psy_data\"\n");
+		return -1;
+		}
+
+	      if (i!=0)
+		if ( (fabs(1.0-w1_l[i]-w2_l[i-1]) > 0.01 ) )
+		  {
+		    ERRORF("31l: please check \"psy_data.\"\n"
+                           "w1,w2: %f %f \n",w1_l[i],w2_l[i-1]);
+		    return -1;
+		  }
+	    }
 	}
+      else
+	p += sbmax * 6;
     }
-    
-    /******************************************************************/
-    /* Read short block data for converting threshold                 */
-    /* calculation partitions to scale factor bands (part 4)          */
-    /******************************************************************/
 
-    cbmax = ti->len4;
-    assert (cbmax == 12);
-    for ( i = 0; i < cbmax; i++ ) {
-	if ( i != ti->tab4[i].no ) {
-	    ERRORF ("psy_data(%u): idx=%d  table idx=%f\a\n", 4, i, ti->tab4[i].no );
-	    return -1;
-	}
-	bu_s [i] = ti->tab4[i].bu;
-	bo_s [i] = ti->tab4[i].bo;
-	w1_s [i] = ti->tab4[i].w1_576 / 576.;
-	w2_s [i] = ti->tab4[i].w2_576 / 576.;
-	
-	if ( i != 0  &&  fabs (1.-w1_s[i]-w2_s[i-1] > 1.e-6 ) ) {
-	    ERRORF ("psy_data(%u): idx=%d  sum error: w1=%f w2=%f\a\n", 3, i, w1_s [i], w2_s [i-1] );
-	    return -1;
+  /* Read short block data for converting threshold calculation 
+     partitions to scale factor bands */
+
+  for(loop=0;loop<6;loop++)
+    {
+      freq_tp = *p++;
+      sbmax = (int) *p++;
+      sbmax++;
+
+      if (sfreq == freq_tp/freq_scale)
+	{
+	  for(i=0;i<sbmax;i++)
+	    {
+	      j = (int) *p++;
+	      p++;
+	      bu_s[i] = (int) *p++;
+	      bo_s[i] = (int) *p++;
+	      w1_s[i] = *p++;
+	      w2_s[i] = *p++;
+	      if (j!=i)
+		{ ERRORF("30:please check \"psy_data\"\n");
+		return -1;
+		}
+
+	      if (i!=0)
+		if ( (fabs(1.0-w1_s[i]-w2_s[i-1]) > 0.01 ) )
+		  { 
+                  ERRORF("31s: please check \"psy_data.\"\n"
+                         "w1,w2: %f %f \n",w1_s[i],w2_s[i-1]);
+		  return -1;
+		  }
+	    }
 	}
+      else
+	p += sbmax * 6;
     }
 
+  /******************************************************************/
+  /* done reading table data */
+  /******************************************************************/
+
+
 
 
 #undef NOTABLES
@@ -1429,8 +1464,10 @@
 	bark2  = freq2bark(sfreq*ji/BLKSIZE);
       } while ((bark2 - bark1) < delbark  && j2<=BLKSIZE/2);
 
-      // DEBUGF("%i old n=%i  %f old numlines:  %i   new=%i (%i,%i) (%f,%f) \n", i,*npart_l_orig,freq,numlines_l[i],j2-j,j,j2-1,bark1,bark2);
-      
+      /*
+      DEBUGF("%i old n=%i  %f old numlines:  %i   new=%i (%i,%i) (%f,%f) \n",
+i,*npart_l_orig,freq,numlines_l[i],j2-j,j,j2-1,bark1,bark2);
+      */
       for (k=j; k<j2; ++k)
 	partition[k]=i;
       numlines_l[i]=(j2-j);
@@ -1484,10 +1521,10 @@
 
       gfc->ATH_partitionbands [i] = 1.e37; // preinit for minimum search
       for (k=0; k < numlines_l[i]; k++, j++) {
-	FLOAT8  freq = sfreq*j/BLKSIZE;
+	FLOAT8  freq = sfreq*j/(1000.0*BLKSIZE);
 	FLOAT8  level;
-	assert( freq <= 24000 );              // or only '<'
-	//	freq = Min(100,freq);       // ATH below 100 Hz constant, not further climbing
+	assert( freq <= 24 );              // or only '<'
+	//	freq = Min(.1,freq);       // ATH below 100 Hz constant, not further climbing
 	level  = ATHformula (freq) - 20;   // scale to FFT units; returned value is in dB
 	level  = pow ( 10., 0.1*level );   // convert from dB -> energy
 	level *= numlines_l [i];
@@ -1739,5 +1776,3 @@
   
   return 0;
 }
-
-/* end of psymodel.c */
diff -duHr lame.20001203/libmp3lame/psymodel.h lame.org/libmp3lame/psymodel.h
--- lame.20001203/libmp3lame/psymodel.h	Wed Nov 29 16:44:27 2000
+++ lame.org/libmp3lame/psymodel.h	Mon Dec  4 15:32:47 2000
@@ -25,7 +25,7 @@
 #include "l3side.h"
 
 int L3psycho_anal( lame_global_flags *gfc,
-                    const sample_t *buffer[2], int gr, 
+                    sample_t *buffer[2], int gr , 
 		    FLOAT8 *ms_ratio, 
 		    FLOAT8 *ms_ratio_next, 
 		    FLOAT8 *ms_ener_ratio, 
diff -duHr lame.20001203/libmp3lame/quantize.c lame.org/libmp3lame/quantize.c
--- lame.20001203/libmp3lame/quantize.c	Wed Nov 29 16:45:36 2000
+++ lame.org/libmp3lame/quantize.c	Mon Dec  4 15:32:47 2000
@@ -19,7 +19,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
-/* $Id: quantize.c,v 1.35 2000/11/25 22:59:35 robert Exp $ */
+/* $Id: quantize.c,v 1.36 2000/12/03 23:00:14 markt Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
@@ -52,14 +52,14 @@
 
 static int 
 init_outer_loop(
+    lame_global_flags *gfp,
     gr_info *const cod_info, 
     III_scalefac_t *const scalefac, 
-    const int is_mpeg1,
     const FLOAT8 xr[576], 
     FLOAT8 xrpow[576] )
 {
-    FLOAT8 tmp, sum = 0;
-    int i;
+  //    lame_internal_flags *gfc=gfp->internal_flags;
+    int i, o=0;
 
     /*  initialize fresh cod_info
      */
@@ -91,7 +91,7 @@
              *  MPEG-1:      sfbs 0-7 long block, 3-12 short blocks 
              *  MPEG-2(.5):  sfbs 0-5 long block, 3-12 short blocks
              */ 
-            cod_info->sfb_lmax    = is_mpeg1 ? 8 : 6;
+            cod_info->sfb_lmax    = (gfp->version == 1) ? 8 : 6;
 	    cod_info->sfb_smin    = 3;
 	}
     } else {
@@ -112,14 +112,14 @@
     /*  check if there is some energy we have to quantize
      *  and calculate xrpow matching our fresh scalefactors
      */
-    for (i = 0; i < 576; ++i) {
-        tmp  = fabs (xr[i]);
-        sum += tmp;
-        xrpow[i] = sqrt (tmp * sqrt(tmp));
+    for (i = 0; i < 576; i++) {
+        FLOAT8 temp = fabs (xr[i]);
+        xrpow[i] = sqrt (temp * sqrt(temp));
+        o += (temp > 1E-20);
     }
    /*  return 1 if we have something to quantize, else 0
     */
-   return sum > (FLOAT8)1E-20;
+   return o > 0;
 }
 
 
@@ -349,7 +349,7 @@
                  ||  ( calc->over_noise == best->over_noise  &&
                      ( calc->max_noise   < best->max_noise  
 		     ||  ( calc->max_noise  == best->max_noise  &&
-                           calc->tot_noise   < best->tot_noise )
+                           calc->tot_noise  <= best->tot_noise )
 		      )); 
 	    break;
         case 7: 
@@ -379,16 +379,127 @@
 
 static void 
 amp_scalefac_bands(
-    lame_internal_flags *gfc,
+    lame_global_flags *gfp,
     const gr_info  *const cod_info, 
     III_scalefac_t *const scalefac,
-    calc_noise_result * noise_info, 
+    FLOAT8 distort[4][SBMAX_l], 
     FLOAT8 xrpow[576] )
+#ifndef RH_AMP
 {
-    unsigned int start, end, sfb;
-    unsigned int l,i,j;
+  lame_internal_flags *gfc=gfp->internal_flags;
+  int start, end, l,i,j,sfb;
+  FLOAT8 ifqstep34,distort_thresh;
+
+  if (cod_info->scalefac_scale == 0) {
+    ifqstep34 = 1.29683955465100964055; /* 2**(.75*.5)*/
+  } else {
+    ifqstep34 = 1.68179283050742922612;  /* 2**(.75*1) */
+  }
+  /* distort[] = noise/masking.  Comput distort_thresh so that:
+   * distort_thresh = 1, unless all bands have distort < 1
+   * In that case, just amplify bands with distortion
+   * within 95% of largest distortion/masking ratio */
+  distort_thresh = -900;
+  for (sfb = 0; sfb < cod_info->sfb_lmax; sfb++) {
+    distort_thresh = Max(distort[0][sfb],distort_thresh);
+  }
+
+  for (sfb = cod_info->sfb_smin; sfb < 12; sfb++) {
+    for (i = 0; i < 3; i++ ) {
+      distort_thresh = Max(distort[i+1][sfb],distort_thresh);
+    }
+  }
+  if (distort_thresh>1.0)
+    distort_thresh=1.0;
+  else
+    distort_thresh *= .95;
+
+  if (gfc->nsPsy.use && (gfp->VBR == vbr_off || gfp->VBR == vbr_abr)) {
+    int asfb = -1,ablk=0,astart=0,aend=0;
+    FLOAT8 max_dist = 0;
+
+    for (sfb = 0; sfb < cod_info->sfb_lmax; sfb++ ) {
+      start = gfc->scalefac_band.l[sfb];
+      end   = gfc->scalefac_band.l[sfb+1];
+    
+      if (distort[0][sfb]>distort_thresh  ) {
+        if (distort[0][sfb]-distort_thresh > max_dist) {
+          max_dist = distort[0][sfb]-distort_thresh;
+          asfb = sfb;
+        }
+      }
+    }
+
+    if (asfb != -1) {
+      scalefac->l[asfb]++;
+      start = gfc->scalefac_band.l[asfb];
+      end   = gfc->scalefac_band.l[asfb+1];
+      for ( l = start; l < end; l++ )
+        xrpow[l] *= ifqstep34;
+    }
+
+    max_dist = 0;
+    asfb = -1;
+    for (j=0,sfb = cod_info->sfb_smin; sfb < 12; sfb++ ) {
+      start = gfc->scalefac_band.s[sfb];
+      end   = gfc->scalefac_band.s[sfb+1];
+      for (i = 0; i < 3; i++ ) {
+	if ( distort[i+1][sfb]>distort_thresh) {
+	  if (distort[i+1][sfb]>max_dist) {
+	    max_dist = distort[i+1][sfb];
+	    asfb = sfb;
+	    ablk = i;
+	    astart = j;
+	    aend = j + end - start;
+	  }
+	}
+	j += end-start;
+      }
+    }
+
+    if (asfb != -1) {
+      scalefac->s[asfb][ablk]++;
+      for (l = astart; l < aend; l++) {
+	xrpow[l] *= ifqstep34;
+      }
+    }
+  } else {
+    for ( sfb = 0; sfb < cod_info->sfb_lmax; sfb++ ) {
+      if ( distort[0][sfb]>distort_thresh  ) {
+        scalefac->l[sfb]++;
+        start = gfc->scalefac_band.l[sfb];
+        end   = gfc->scalefac_band.l[sfb+1];
+        for ( l = start; l < end; l++ ) {
+          xrpow[l] *= ifqstep34;
+        }
+      }
+    }
+
+    for ( j=0,sfb = cod_info->sfb_smin; sfb < 12; sfb++ ) {
+      start = gfc->scalefac_band.s[sfb];
+      end   = gfc->scalefac_band.s[sfb+1];
+      for ( i = 0; i < 3; i++ ) {
+	int j2 = j;
+	if ( distort[i+1][sfb]>distort_thresh) {
+	  scalefac->s[sfb][i]++;
+	  for (l = start; l < end; l++) {
+	    xrpow[j2++] *= ifqstep34;
+	  }
+	}
+	j += end-start;
+      }
+    }
+  }
+}
+#else
+{
+    int start, end;
+    int l,i,j;
+    int max_ind[4]={0,0,0,0};
+    int sfb;
     FLOAT8 ifqstep34;
-    FLOAT8 distort_thresh = -1.f;
+    FLOAT8 distort_thresh[4] = {-1.f, -1.f, -1.f, -1.f};
+    lame_internal_flags *gfc = gfp->internal_flags;
 
     if (cod_info->scalefac_scale == 0) 
         ifqstep34 = 1.29683955465100964055; /* 2**(.75*0.5)*/
@@ -399,54 +510,55 @@
     /*  find maximum distortion and appropriate scalefactor bands
      */    
     for (sfb = 0; sfb < cod_info->sfb_lmax; sfb++) 
-        if (distort_thresh < noise_info->dist_l[sfb]) {
-            distort_thresh = noise_info->dist_l[sfb];
+        if (distort_thresh[0] < distort[0][sfb]) {
+            distort_thresh[0] = distort[0][sfb];
+            max_ind[0] = sfb;
         }
     for (sfb = cod_info->sfb_smin; sfb < 12; sfb++) 
-        for (i = 0; i < 3; i++) 
-            if (distort_thresh < noise_info->dist_s[i][sfb]) {
-                distort_thresh = noise_info->dist_s[i][sfb];
+        for (i = 1; i < 4; i++) 
+            if (distort_thresh[i] < distort[i][sfb]) {
+                distort_thresh[i] = distort[i][sfb];
+                max_ind[i] = sfb;
             }
     
-    /*  adjust threshold
+    /*  adjust thresholds
      */
-     
-    switch (gfc->amp_mode) {
-    default:
-    case amp_mode_all:
-            if (distort_thresh > 1.0f) 
-               /* all bands with distortion */
-                distort_thresh = 1.0f;
-            else 
-                /* amplify some bands */
-                distort_thresh *= 0.95;
-            break;
-    case amp_mode_low:
-            if (distort_thresh > 1.0f) 
-                /* only bands with distortion at least 20% of maximum */
-                distort_thresh = pow (distort_thresh, 0.20f);
-            else 
-                /* amplify only bands near 95% of maximum noise */
-                distort_thresh = pow (distort_thresh, 1.05f);
-            break;
-    case amp_mode_mid:
-            if (distort_thresh > 1.0f) 
-               /* only bands with distortion at least 50% of maximum */
-                distort_thresh = pow (distort_thresh, 0.50f);
-            else 
-                /* amplify only bands near 98% of maximum noise */
-                distort_thresh = pow (distort_thresh, 1.02f);
-            break;
-    case amp_mode_max:
-            /* nothing to adjust */
-            break;
+    if (gfp->VBR == vbr_rh || gfp->VBR == vbr_mtrh) { 
+        /* VBR modes */
+        if (gfp->experimentalY) 
+            for (i = 0; i < 4; i++) 
+                if (distort_thresh[i] > 1.0f) 
+                   /* only bands with distortion at least 50% of maximum */
+                    distort_thresh[i] = pow (distort_thresh[i], 0.50f);
+                else 
+                    /* amplify only bands near 98% of maximum noise */
+                    distort_thresh[i] = pow (distort_thresh[i], 1.02f);
+        else 
+            for (i = 0; i < 4; i++) 
+                if (distort_thresh[i] > 1.0f) 
+                    /* all distorted bands */
+                    distort_thresh[i] = 1.0f;
+                else 
+                    /* amplify only bands near 95% of maximum noise */
+                    distort_thresh[i] = pow (distort_thresh[i], 1.05f);
+    } else {
+        /* CBR/ABR modes */
+        if (!gfp->experimentalY) {
+            for (i = 0; i < 4; i++) 
+                if (distort_thresh[i] > 1.0f) 
+                    /* only bands with distortion at least 25% of maximum */
+                    distort_thresh[i] = pow (distort_thresh[i], 0.25f);
+                else 
+                    /* amplify only bands near 95% of maximum noise */
+                    distort_thresh[i] = pow (distort_thresh[i], 1.05f);
+        }   /* else only maximum distorted bands */
     }
    
     
     /*  amplify bands exceeding thresholds
      */
     for (sfb = 0; sfb < cod_info->sfb_lmax; sfb++) {
-        if (noise_info->dist_l[sfb] >= distort_thresh) {
+        if (distort[0][sfb] >= distort_thresh[0]) {
             scalefac->l[sfb]++;
             start = gfc->scalefac_band.l[sfb];
             end   = gfc->scalefac_band.l[sfb+1];
@@ -458,8 +570,8 @@
         start = gfc->scalefac_band.s[sfb];
         end   = gfc->scalefac_band.s[sfb+1];
         for (i = 0; i < 3; i++) {
-            int j2 = j;
-            if (noise_info->dist_s[i][sfb] >= distort_thresh) {
+            int j2 = j, b = i+1;
+            if (distort[b][sfb] >= distort_thresh[b]) {
                 scalefac->s[sfb][i]++;
                 for (l = start; l < end; l++) 
                     xrpow[j2++] *= ifqstep34;
@@ -468,6 +580,7 @@
         }
     }
 }
+#endif
 
 
 
@@ -582,6 +695,7 @@
             }
 
             scalefac->s[sfb][window] = 0;
+            //gf.distort[band] = -1.0;
             width = gfc->scalefac_band.s[sfb] - gfc->scalefac_band.s[sfb+1];
             i = gfc->scalefac_band.s[sfb] * 3 + width * window;
             amp = IPOW20(210 + (s << (cod_info->scalefac_scale + 1)));
@@ -613,15 +727,16 @@
 inline
 static int 
 balance_noise (
-    lame_internal_flags * const gfc,
+    lame_global_flags  *gfp,
     gr_info        * const cod_info,
     III_scalefac_t * const scalefac, 
-    calc_noise_result * noise_info,
+    FLOAT8                 distort[4][SBMAX_l],
     FLOAT8                 xrpow[576] )
 {
+    lame_internal_flags *gfc=gfp->internal_flags;
     int status;
     
-    amp_scalefac_bands ( gfc, cod_info, scalefac, noise_info, xrpow);
+    amp_scalefac_bands ( gfp, cod_info, scalefac, distort, xrpow);
 
     /* check to make sure we have not amplified too much 
      * loop_break returns 0 if there is an unamplified scalefac
@@ -636,7 +751,7 @@
     /* not all scalefactors have been amplified.  so these 
      * scalefacs are possibly valid.  encode them: 
      */
-    if (gfc->is_mpeg1)
+    if (gfp->version == 1)
         status = scale_bitcount (scalefac, cod_info);
     else 
         status = scale_bitcount_lsf (scalefac, cod_info);
@@ -655,7 +770,7 @@
 #ifdef RH_AMP
          && gfc->noise_shaping > 0)
 #else
-         && gfc->noise_shaping > 1)
+         && gfp->experimentalZ && gfc->noise_shaping > 1)
 #endif
         {
             status = inc_subblock_gain (gfc, cod_info, scalefac, xrpow)
@@ -663,7 +778,7 @@
         }
     }
     if (!status) {
-        if (gfc->is_mpeg1) 
+        if (gfp->version == 1) 
             status = scale_bitcount (scalefac, cod_info);
         else 
             status = scale_bitcount_lsf (scalefac, cod_info);
@@ -707,6 +822,7 @@
     III_scalefac_t save_scalefac;
     gr_info save_cod_info;
     FLOAT8 save_xrpow[576];
+    FLOAT8 distort[4][SBMAX_l];
     calc_noise_result noise_info;
     calc_noise_result best_noise_info;
     int l3_enc_w[576]; 
@@ -772,7 +888,7 @@
         if (gfc->noise_shaping) 
             /* coefficients and thresholds both l/r (or both mid/side) */
             over = calc_noise (gfc, xr, l3_enc_w, cod_info, l3_xmin, 
-                               scalefac, &noise_info);
+                               scalefac, distort, &noise_info);
         else {
             /* fast mode, no noise shaping, we are ready */
             best_noise_info = noise_info;
@@ -844,11 +960,11 @@
          */
         if (gfc->sfb21_extra) {
             if (cod_info->block_type == SHORT_TYPE) {
-                if (noise_info.dist_s[0][SBMAX_s-1] > 1 ||
-                    noise_info.dist_s[1][SBMAX_s-1] > 1 ||
-                    noise_info.dist_s[2][SBMAX_s-1] > 1) break;
+                if (distort[1][SBMAX_s-1] > 1 ||
+                    distort[2][SBMAX_s-1] > 1 ||
+                    distort[3][SBMAX_s-1] > 1) break;
             } else {
-                if (noise_info.dist_l[SBMAX_l-1] > 1) break;
+                if (distort[0][SBMAX_l-1] > 1) break;
             }
         }
 
@@ -863,7 +979,7 @@
             }
         }
             
-        notdone = balance_noise (gfc, cod_info, scalefac, &noise_info, xrpow);
+        notdone = balance_noise (gfp, cod_info, scalefac, distort, xrpow);
         
         if (notdone == 0) 
             break;
@@ -915,7 +1031,7 @@
     int gr, ch, i;
     
     for (gr = 0; gr < gfc->mode_gr; gr++) {
-        for (ch = 0; ch < gfc->channels_out; ch++) {
+        for (ch = 0; ch < gfc->stereo; ch++) {
             gr_info *cod_info = &l3_side->gr[gr].ch[ch].tt;
 
             /*  try some better scalefac storage
@@ -989,7 +1105,7 @@
         if (gfc->mode_ext == MPG_MD_MS_LR) 
             ms_convert (xr[gr], xr[gr]); 
     
-        for (ch = 0; ch < gfc->channels_out; ch++) {
+        for (ch = 0; ch < gfc->stereo; ch++) {
             gr_info *cod_info = &gfc->l3_side.gr[gr].ch[ch].tt;
       
             if (cod_info->block_type == SHORT_TYPE) 
@@ -1139,13 +1255,13 @@
      */
     gfc->bitrate_index = gfc->VBR_min_bitrate;
     getframebits (gfp, &bitsPerFrame, &mean_bits);
-    *min_mean_bits = mean_bits / gfc->channels_out;
+    *min_mean_bits = mean_bits / gfc->stereo;
 
     /*  bits for analog silence 
      */
     gfc->bitrate_index = 1;
     getframebits (gfp, &bitsPerFrame, &mean_bits);
-    *analog_mean_bits = mean_bits / gfc->channels_out;
+    *analog_mean_bits = mean_bits / gfc->stereo;
 
     for (i = 1; i <= gfc->VBR_max_bitrate; i++) {
         gfc->bitrate_index = i;
@@ -1239,8 +1355,8 @@
     int max_bits;
     
     max_bits  = frameBits[gfc->VBR_max_bitrate];
-    max_bits /= gfc -> channels_out * gfc -> mode_gr;
-    max_bits  = Min (1200 + max_bits, 4095 - 195*(gfc -> channels_out-1));
+    max_bits /= gfc -> stereo * gfc -> mode_gr;
+    max_bits  = Min (1200 + max_bits, 4095 - 195*(gfc -> stereo-1));
     max_bits  = Max (max_bits, min_bits);
     
     return max_bits;
@@ -1300,7 +1416,7 @@
         num_chan    = 1;
     } else {
         reduce_s_ch = 0;
-        num_chan    = gfc->channels_out;
+        num_chan    = gfc->stereo;
     }
   
     analog_silence
@@ -1321,8 +1437,7 @@
       
             /*  init_outer_loop sets up cod_info, scalefac and xrpow 
              */
-            ret = init_outer_loop(cod_info, &scalefac[gr][ch], gfc->is_mpeg1,
-                                  xr[gr][ch], xrpow);
+            ret = init_outer_loop(gfp, cod_info, &scalefac[gr][ch], xr[gr][ch], xrpow);
             if (ret == 0) {
                 /*  xr contains no energy 
                  *  l3_enc, our encoding data, will be quantized to zero
@@ -1340,12 +1455,12 @@
             max_bits = calc_max_bits (gfc, frameBits, min_bits);
             
             if (gfp->VBR == vbr_mtrh) {
-                ret = VBR_noise_shaping2 (gfc, xr[gr][ch], xrpow, 
+                ret = VBR_noise_shaping2 (gfp, xr[gr][ch], xrpow, 
                                         &ratio[gr][ch], l3_enc[gr][ch], 0, 
                                         min_bits, max_bits, &scalefac[gr][ch],
                                         &l3_xmin[gr][ch], gr, ch );
                 if (ret < 0) {
-                    init_outer_loop (cod_info, &scalefac[gr][ch], gfc->is_mpeg1,
+                    init_outer_loop (gfp, cod_info, &scalefac[gr][ch], 
                                      xr[gr][ch], xrpow);
                     VBR_encode_granule (gfp, cod_info, xr[gr][ch], 
                                         &l3_xmin[gr][ch], &scalefac[gr][ch],
@@ -1397,7 +1512,7 @@
      *  and side channel when in quality=5 reduce_side is used
      */  
     for (gr = 0; gr < gfc->mode_gr; gr++) {
-        for (ch = 0; ch < gfc->channels_out; ch++) {
+        for (ch = 0; ch < gfc->stereo; ch++) {
             int ret;
             cod_info = &l3_side->gr[gr].ch[ch].tt;
       
@@ -1415,8 +1530,7 @@
             }
             /*  init_outer_loop sets up cod_info, scalefac and xrpow 
              */
-            ret = init_outer_loop(cod_info, &scalefac[gr][ch], gfc->is_mpeg1,
-                                  xr[gr][ch], xrpow);
+            ret = init_outer_loop(gfp, cod_info, &scalefac[gr][ch], xr[gr][ch], xrpow);
             if (ret == 0) 
             {
                 /*  xr contains no energy 
@@ -1474,7 +1588,7 @@
 
     gfc->bitrate_index = 1;
     getframebits (gfp, &bitsPerFrame, &mean_bits);
-    *analog_silence_bits = mean_bits / gfc->channels_out;
+    *analog_silence_bits = mean_bits / gfc->stereo;
 
     mean_bits  = gfp->VBR_mean_bitrate_kbps * gfp->framesize * 1000;
     mean_bits /= gfp->out_samplerate;
@@ -1488,14 +1602,14 @@
         res_factor = 1.00;
 
     for (gr = 0; gr < gfc->mode_gr; gr++) {
-        for (ch = 0; ch < gfc->channels_out; ch++) {
-            targ_bits[gr][ch] = res_factor * (mean_bits / gfc->channels_out);
+        for (ch = 0; ch < gfc->stereo; ch++) {
+            targ_bits[gr][ch] = res_factor * (mean_bits / gfc->stereo);
             
             if (pe[gr][ch] > 700) {
                 int add_bits = (pe[gr][ch] - 700) / 1.4;
   
                 gr_info *cod_info = &l3_side->gr[gr].ch[ch].tt;
-                targ_bits[gr][ch] = res_factor * (mean_bits / gfc->channels_out);
+                targ_bits[gr][ch] = res_factor * (mean_bits / gfc->stereo);
  
                 /* short blocks use a little extra, no matter what the pe */
                 if (cod_info->block_type == SHORT_TYPE) {
@@ -1523,7 +1637,7 @@
      */
     totbits=0;
     for (gr = 0; gr < gfc->mode_gr; gr++) {
-        for (ch = 0; ch < gfc->channels_out; ch++) {
+        for (ch = 0; ch < gfc->stereo; ch++) {
             if (targ_bits[gr][ch] > 4095) 
                 targ_bits[gr][ch] = 4095;
             totbits += targ_bits[gr][ch];
@@ -1534,7 +1648,7 @@
      */
     if (totbits > *max_frame_bits) {
         for(gr = 0; gr < gfc->mode_gr; gr++) {
-            for(ch = 0; ch < gfc->channels_out; ch++) {
+            for(ch = 0; ch < gfc->stereo; ch++) {
                 targ_bits[gr][ch] *= *max_frame_bits; 
                 targ_bits[gr][ch] /= totbits; 
             }
@@ -1588,13 +1702,12 @@
         if (gfc->mode_ext == MPG_MD_MS_LR) 
             ms_convert (xr[gr], xr[gr]);
 
-        for (ch = 0; ch < gfc->channels_out; ch++) {
+        for (ch = 0; ch < gfc->stereo; ch++) {
             cod_info = &l3_side->gr[gr].ch[ch].tt;
 
             /*  cod_info, scalefac and xrpow get initialized in init_outer_loop
              */
-            ret = init_outer_loop(cod_info, &scalefac[gr][ch], gfc->is_mpeg1,
-                                  xr[gr][ch], xrpow);
+            ret = init_outer_loop(gfp, cod_info, &scalefac[gr][ch], xr[gr][ch], xrpow);
             if (ret == 0) {
                 /*  xr contains no energy 
                  *  l3_enc, our encoding data, will be quantized to zero
@@ -1685,13 +1798,13 @@
             reduce_side (targ_bits, ms_ener_ratio[gr], mean_bits, max_bits);
         }
         
-        for (ch=0 ; ch < gfc->channels_out ; ch ++) {
+        for (ch=0 ; ch < gfc->stereo ; ch ++) {
             cod_info = &l3_side->gr[gr].ch[ch].tt; 
 
             /*  init_outer_loop sets up cod_info, scalefac and xrpow 
              */
-            i = init_outer_loop(cod_info, &scalefac[gr][ch], gfc->is_mpeg1, 
-                                xr[gr][ch], xrpow);
+            i = init_outer_loop(gfp, cod_info, &scalefac[gr][ch], xr[gr][ch],
+                                xrpow);
             if (i == 0) {
                 /*  xr contains no energy, l3_enc will be quantized to zero
                  */
@@ -1738,7 +1851,7 @@
        the second granule to use bits saved by the first granule.
        Requires using the --nores.  This is useful for testing only */
     for (gr = 0; gr < gfc->mode_gr; gr++) {
-        for (ch =  0; ch < gfc->channels_out; ch++) {
+        for (ch =  0; ch < gfc->stereo; ch++) {
             cod_info = &l3_side->gr[gr].ch[ch].tt;
             ResvAdjust (gfc, cod_info, l3_side, mean_bits);
         }
diff -duHr lame.20001203/libmp3lame/quantize.h lame.org/libmp3lame/quantize.h
--- lame.20001203/libmp3lame/quantize.h	Wed Nov 29 16:44:27 2000
+++ lame.org/libmp3lame/quantize.h	Mon Dec  4 15:32:47 2000
@@ -62,7 +62,7 @@
     /*  used by VBR_iteration_loop() */ 
 
 int VBR_noise_shaping2(
-                    lame_internal_flags *gfc,
+                    lame_global_flags        *gfp,
                     FLOAT8           xr       [576], 
                     FLOAT8           xr34orig [576], 
                     III_psy_ratio  * ratio,
diff -duHr lame.20001203/libmp3lame/quantize_pvt.c lame.org/libmp3lame/quantize_pvt.c
--- lame.20001203/libmp3lame/quantize_pvt.c	Wed Nov 29 16:44:27 2000
+++ lame.org/libmp3lame/quantize_pvt.c	Mon Dec  4 15:32:48 2000
@@ -19,7 +19,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
-/* $Id: quantize_pvt.c,v 1.26 2000/11/25 18:18:22 robert Exp $ */
+/* $Id: quantize_pvt.c,v 1.27 2000/12/03 23:00:14 markt Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
@@ -221,7 +221,7 @@
     lame_internal_flags *gfc = gfp->internal_flags;
     FLOAT8 ath;
   
-    ath = ATHformula( 1.e3 * f );
+    ath = ATHformula( f );
 	  
     /* convert to energy */
     if (gfc->nsPsy.use) {
@@ -319,18 +319,16 @@
 
 
 
-/* convert from L/R <-> Mid/Side, src == dst allowed */
-void ms_convert(FLOAT8 dst[2][576], FLOAT8 src[2][576])
+/* convert from L/R <-> Mid/Side */
+void ms_convert(FLOAT8 xr[2][576],FLOAT8 xr_org[2][576])
 {
-    FLOAT8 l;
-    FLOAT8 r;
-    int i;
-    for (i = 0; i < 576; ++i) {
-        l = src[0][i];
-        r = src[1][i];
-        dst[0][i] = (l+r) * (FLOAT8)(SQRT2*0.5);
-        dst[1][i] = (l-r) * (FLOAT8)(SQRT2*0.5);
-    }
+  int i;
+  for ( i = 0; i < 576; i++ ) {
+    FLOAT8 l = xr_org[0][i];
+    FLOAT8 r = xr_org[1][i];
+    xr[0][i] = (l+r)*(SQRT2*0.5);
+    xr[1][i] = (l-r)*(SQRT2*0.5);
+  }
 }
 
 
@@ -355,13 +353,13 @@
 
   bits=0;
 
-  for (ch=0 ; ch < gfc->channels_out ; ch ++) {
+  for (ch=0 ; ch < gfc->stereo ; ch ++) {
     /******************************************************************
      * allocate bits for each channel 
      ******************************************************************/
     cod_info = &l3_side->gr[gr].ch[ch].tt;
     
-    targ_bits[ch]=Min(4095,tbits/gfc->channels_out);
+    targ_bits[ch]=Min(4095,tbits/gfc->stereo);
     
     add_bits[ch]=(pe[gr][ch]-750)/1.4;
     /* short blocks us a little extra, no matter what the pe */
@@ -379,11 +377,11 @@
     bits += add_bits[ch];
   }
   if (bits > extra_bits)
-    for (ch=0 ; ch < gfc->channels_out ; ch ++) {
+    for (ch=0 ; ch < gfc->stereo ; ch ++) {
       add_bits[ch] = (extra_bits*add_bits[ch])/bits;
     }
 
-  for (ch=0 ; ch < gfc->channels_out ; ch ++) {
+  for (ch=0 ; ch < gfc->stereo ; ch ++) {
     targ_bits[ch] = targ_bits[ch] + add_bits[ch];
     extra_bits -= add_bits[ch];
   }
@@ -576,7 +574,8 @@
         const gr_info           * const cod_info,
         const III_psy_xmin      * const l3_xmin, 
         const III_scalefac_t    * const scalefac,
-              calc_noise_result * const res )
+              FLOAT8                    xfsf [4][SBMAX_l], 
+              calc_noise_result *       res )
 {
   int sfb,start, end, j,l, i, over=0;
   FLOAT8 sum, bw;
@@ -618,10 +617,10 @@
 	      l++;
 	    } while (l < end);
 
-	    noise  = sum / bw;
-            noise /= l3_xmin->s[sfb][i];
+	    xfsf[i+1][sfb]  = sum / bw;
+            xfsf[i+1][sfb] /= l3_xmin->s[sfb][i];
             
-            res->dist_s[i][sfb] = noise;
+            noise = xfsf[i+1][sfb];
 	    
             /* multiplying here is adding in dB */
 	    tot_noise *= Max(noise, 1E-20);         // IISC this is nonsense, a nearly nondistorted band doesn't comp a heavly distorted one
@@ -663,14 +662,14 @@
 	}
 
 	if (gfc->nsPsy.use) {
-	  noise = sum;
+	  xfsf[0][sfb] = sum;
 	  sum /= bw;
 	} else {
-	  noise = sum / bw;
+	  xfsf[0][sfb] = sum / bw;
 	}
 
-        noise /= l3_xmin->l[sfb];
-	res->dist_l[sfb] = noise;
+        xfsf[0][sfb] /= l3_xmin->l[sfb];
+	noise = xfsf[0][sfb];
 	/* multiplying here is adding in dB */
 	tot_noise *= Max(noise, 1E-20);
 	if (noise > 1) {
@@ -752,10 +751,11 @@
 
     III_psy_xmin l3_xmin;
     calc_noise_result noise;
+    FLOAT8 xfsf[4][SBMAX_l];
 
     calc_xmin (gfp,xr, ratio, cod_info, &l3_xmin);
 
-    calc_noise (gfc, xr, l3_enc, cod_info, &l3_xmin, scalefac, &noise);
+    calc_noise (gfc, xr, l3_enc, cod_info, &l3_xmin, scalefac, xfsf, &noise);
 
     if (cod_info->block_type == SHORT_TYPE) {
         for (j=0, sfb = 0; sfb < SBMAX_s; sfb++ )  {
@@ -806,7 +806,7 @@
                 /* convert to MDCT units */
                 en1=1e15;  /* scaling so it shows up on FFT plot */
                 gfc->pinfo->xfsf_s[gr][ch][3*sfb+i] 
-                    = en1*noise.dist_s[i][sfb]*l3_xmin.s[sfb][i];
+                    = en1*xfsf[i+1][sfb]*l3_xmin.s[sfb][i];
                 gfc->pinfo->en_s[gr][ch][3*sfb+i] = en1*en0;
 
                 if (ratio->en.s[sfb][i]>0)
@@ -878,7 +878,7 @@
 
             /* convert to MDCT units */
             en1=1e15;  /* scaling so it shows up on FFT plot */
-            gfc->pinfo->xfsf[gr][ch][sfb] = en1*noise.dist_l[sfb]*l3_xmin.l[sfb];
+            gfc->pinfo->xfsf[gr][ch][sfb] =  en1*xfsf[0][sfb]*l3_xmin.l[sfb];
             gfc->pinfo->en[gr][ch][sfb] = en1*en0;
             if (ratio->en.l[sfb]>0)
                 en0 = en0/ratio->en.l[sfb];
@@ -943,7 +943,7 @@
     
     /* reconstruct the scalefactors in case SCSFI was used 
      */
-    for (ch = 0; ch < gfc->channels_out; ch ++) {
+    for (ch = 0; ch < gfc->stereo; ch ++) {
         for (sfb = 0; sfb < SBMAX_l; sfb ++) {
             if (scalefac[1][ch].l[sfb] == -1) {/* scfsi */
                 act_scalefac[ch].l[sfb] = scalefac[0][ch].l[sfb];
@@ -957,7 +957,7 @@
     /* for every granule and channel patch l3_enc and set info
      */
     for (gr = 0; gr < gfc->mode_gr; gr ++) {
-        for (ch = 0; ch < gfc->channels_out; ch ++) {
+        for (ch = 0; ch < gfc->stereo; ch ++) {
             int i;
             gr_info *cod_info = &gfc->l3_side.gr[gr].ch[ch].tt;
             
diff -duHr lame.20001203/libmp3lame/quantize_pvt.h lame.org/libmp3lame/quantize_pvt.h
--- lame.20001203/libmp3lame/quantize_pvt.h	Wed Nov 29 16:44:27 2000
+++ lame.org/libmp3lame/quantize_pvt.h	Mon Dec  4 15:32:48 2000
@@ -54,8 +54,6 @@
     FLOAT8  tot_noise;       /* sum of all quantization noise */
     FLOAT8  max_noise;       /* max quantization noise */
     float   klemm_noise;
-    FLOAT8  dist_l[SBMAX_l];
-    FLOAT8  dist_s[3][SBMAX_s];
 } calc_noise_result;
 
 void    compute_ath (lame_global_flags * gfp, FLOAT8 ATH_l[SBPSY_l],
@@ -88,7 +86,7 @@
                     const int ix[576], const gr_info * cod_info,
                     const III_psy_xmin * l3_xmin,
                     const III_scalefac_t * scalefac,
-                    calc_noise_result * res);
+                    FLOAT8 distort[4][SBMAX_l], calc_noise_result * res);
 
 void    set_frame_pinfo (lame_global_flags *gfp, FLOAT8 xr[2][2][576],
                          III_psy_ratio ratio[2][2], int l3_enc[2][2][576],
diff -duHr lame.20001203/libmp3lame/reservoir.c lame.org/libmp3lame/reservoir.c
--- lame.20001203/libmp3lame/reservoir.c	Wed Nov 29 16:44:27 2000
+++ lame.org/libmp3lame/reservoir.c	Mon Dec  4 15:32:48 2000
@@ -19,7 +19,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
-/* $Id: reservoir.c,v 1.9 2000/11/24 17:06:54 robert Exp $ */
+/* $Id: reservoir.c,v 1.10 2000/12/03 23:00:14 markt Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
@@ -37,42 +37,6 @@
   size of the reservoir, and checks to make sure main_data_begin
   was set properly by the formatter
 */
-
-/*
- *  Background information:
- *
- *  This is the original text from the ISO standard. Because of 
- *  sooo many bugs and irritations correcting comments are added 
- *  in brackets []. A '^W' means you should remove the last word.
- *
- *  1) The following rule can be used to calculate the maximum 
- *     number of bits used for one granule [^W frame]: 
- *     At the highest possible bitrate of Layer III (320 kbps 
- *     per stereo signal [^W^W^W], 48 kHz) the frames must be of
- *     [^W^W^W are designed to have] constant length, i.e. 
- *     one buffer [^W^W the frame] length is:
- *
- *         320 kbps * 1152/48 kHz = 7680 bit = 960 byte
- *
- *     This value is used as the maximum buffer per channel [^W^W] at 
- *     lower bitrates [than 320 kbps]. At 64 kbps mono or 128 kbps 
- *     stereo the main granule length is 64 kbps * 576/48 kHz = 768 bit
- *     [per granule and channel] at 48 kHz sampling frequency. 
- *     This means that there is a maximum deviation (short time buffer 
- *     [= reservoir]) of 7680 - 2*2*768 = 4608 bits is allowed at 64 kbps. 
- *     The actual deviation is equal to the number of bytes [with the 
- *     meaning of octets] denoted by the main_data_end offset pointer. 
- *     The actual maximum deviation is (2^9-1)*8 bit = 4088 bits 
- *     [for MPEG-1 and (2^8-1)*8 bit for MPEG-2, both are hard limits].
- *     ... The xchange of buffer bits between the left and right channel
- *     is allowed without restrictions [exception: dual channel].
- *     Because of the [constructed] constraint on the buffer size
- *     main_data_end is always set to 0 in the case of bit_rate_index==14, 
- *     i.e. data rate 320 kbps per stereo signal [^W^W^W]. In this case 
- *     all data are allocated between adjacent header [^W sync] words 
- *     [, i.e. there is no buffering at all].
- */
- 
 int
 ResvFrameBegin(lame_global_flags *gfp,III_side_info_t *l3_side, int mean_bits, int frameLength )
 {
@@ -81,61 +45,41 @@
     int resvLimit;
     int maxmp3buf;
 
-/*
- *  Meaning of the variables:
- *      resvLimit: (0, 8, ..., 8*255 (MPEG-2), 8*511 (MPEG-1))
- *          Number of bits can be stored in previous frame(s) due to 
- *          counter size constaints
- *      maxmp3buf: ( ??? ... 8*1951 (MPEG-1 and 2), 8*2047 (MPEG-2.5))
- *          Number of bits allowed to encode one frame (you can take 8*511 bit 
- *          from the bit reservoir and at most 8*1440 bit from the current 
- *          frame (320 kbps, 32 kHz), so 8*1951 bit is the largest possible 
- *          value for MPEG-1 and -2)
- *      fullFrameBits:
- *
- *      mean_bits:
- *
- *      frameLength:
- *
- *      gfc->ResvMax:
- *
- *      gfc->ResvSize:
- *
- *      l3_side->resvDrain_pre:
- *
- */
 
-    /* main_data_begin has 9 bits in MPEG-1, 8 bits MPEG-2 */
-    resvLimit = (gfp->version==1) ? 8*511 : 8* 255;
+    /* main_data_begin has 9 bits in MPEG 1, 8 bits MPEG2 */
+    resvLimit = (gfp->version==1) ? 8*511 : 8*255 ;
+
+
     /* maximum allowed frame size */
-    maxmp3buf = (gfp->strict_ISO) ? 8*960 : 8*2047;
+    if (gfp->strict_ISO)
+      maxmp3buf = 8*960;
+    else
+      maxmp3buf = 8*2047;
 
-    if ( frameLength > maxmp3buf  ||  gfp->disable_reservoir ) {
+    if ( frameLength > maxmp3buf )
 	gfc->ResvMax = 0;
-    } else {
+    else
 	gfc->ResvMax = maxmp3buf - frameLength;
-        if ( gfc->ResvMax > resvLimit ) 
-            gfc->ResvMax = resvLimit;
-    }
-    
-    fullFrameBits = mean_bits * gfc->mode_gr + Min ( gfc->ResvSize, gfc->ResvMax );
-    
-    if ( gfp->strict_ISO  &&  fullFrameBits > maxmp3buf )
-        fullFrameBits = maxmp3buf;
-        
+    if (gfp->disable_reservoir) gfc->ResvMax=0;
+    if ( gfc->ResvMax > resvLimit ) gfc->ResvMax = resvLimit;
     assert ( 0 == gfc->ResvMax % 8 );
     assert ( gfc->ResvMax >= 0 );
 
     l3_side->resvDrain_pre = 0;
 
-    if ( gfc->pinfo != NULL ) {
-        gfc->pinfo->mean_bits = mean_bits / 2;  /* expected bits per channel per granule [is this also right for mono/stereo, MPEG-1/2 ?] */
-        gfc->pinfo->resvsize  = gfc->ResvSize;
+    if (gfc->pinfo != NULL){
+      gfc->pinfo->mean_bits=mean_bits/2;  /* expected bits per channel per granule */
+      gfc->pinfo->resvsize=gfc->ResvSize;
+    }
+
+    fullFrameBits = mean_bits * gfc->mode_gr + Min(gfc->ResvSize,gfc->ResvMax);
+    if (gfp->strict_ISO) {
+      if (fullFrameBits>maxmp3buf) fullFrameBits=maxmp3buf;
     }
-        
     return fullFrameBits;
 }
 
+
 /*
   ResvMaxBits
   returns targ_bits:  target number of bits to use for 1 granule
@@ -184,11 +128,11 @@
 void
 ResvAdjust(lame_internal_flags *gfc,gr_info *gi, III_side_info_t *l3_side, int mean_bits )
 {
-  gfc->ResvSize += (mean_bits / gfc->channels_out) - gi->part2_3_length;
+  gfc->ResvSize += (mean_bits / gfc->stereo) - gi->part2_3_length;
 #if 0
   printf("part2_3_length:  %i  avg=%i  incres: %i  resvsize=%i\n",gi->part2_3_length,
-	 mean_bits/gfc->channels_out,
-mean_bits/gfc->channels_out-gi->part2_3_length,gfc->ResvSize);
+	 mean_bits/gfc->stereo,
+mean_bits/gfc->stereo-gi->part2_3_length,gfc->ResvSize);
 #endif
 }
 
@@ -207,7 +151,7 @@
 
 
     /* just in case mean_bits is odd, this is necessary... */
-    if ( gfc->channels_out == 2  &&  (mean_bits & 1) )
+    if ( gfc->stereo == 2  &&  (mean_bits & 1) )
 	gfc->ResvSize += 1;
 
     stuffingBits=0;
@@ -258,4 +202,4 @@
     return;
 }
 
-/* end of reservoir.c */
+
diff -duHr lame.20001203/libmp3lame/tables.c lame.org/libmp3lame/tables.c
--- lame.20001203/libmp3lame/tables.c	Fri Dec  1 18:42:08 2000
+++ lame.org/libmp3lame/tables.c	Mon Dec  4 15:32:48 2000
@@ -19,7 +19,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
-/* $Id: tables.c,v 1.10 2000/12/01 17:42:08 aleidinger Exp $ */
+/* $Id: tables.c,v 1.12 2000/12/03 23:03:37 markt Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
@@ -186,7 +186,7 @@
   1 << 0,  5 << 1,  4 << 1,  5 << 2,  6 << 1,  5 << 2,  4 << 2,  4 << 3,
   7 << 1,  3 << 2,  6 << 2,  0 << 3,  7 << 2,  2 << 3,  3 << 3,  1 << 4};
 
-static const short    t33HB[]   = {
+static const short      t33HB[]   = {
  15 << 0, 14 << 1, 13 << 1, 12 << 2, 11 << 1, 10 << 2,  9 << 2,  8 << 3,
   7 << 1,  6 << 2,  5 << 2,  4 << 3,  3 << 2,  2 << 3,  1 << 3,  0 << 4};
 
@@ -410,1015 +410,878 @@
 
   { 0,   0,t32HB, t32l},
   { 0,   0,t33HB, t33l},
-};
+};	
 
-//
-// Threshold calculation partitions with following parameters:
-// width, minval, threshold in quiet, norm, bval (Bark)
-//
 
-// See Table 3-C.7a, long blocks, MPEG-1
-// See Table D.3.a, long blocks, MPEG-2
 
-static const type1_t   table1_48000 [] = {
-// Table entry no, FFT lines=width, minval, quiet thr, norm, bval (Bark)   
-    {  0,  1, 24.5*2, 4.532, 0.970,  0.000 },
-    {  1,  1, 24.5*2, 4.532, 0.755,  0.469 },
-    {  2,  1, 24.5*2, 4.532, 0.738,  0.938 },
-    {  3,  1, 24.5*2, 0.904, 0.730,  1.406 },
-    {  4,  1, 24.5*2, 0.904, 0.724,  1.875 },
-    {  5,  1, 20.0*2, 0.090, 0.723,  2.344 },
-    {  6,  1, 20.0*2, 0.090, 0.723,  2.813 },
-    {  7,  1, 20.0*2, 0.029, 0.723,  3.281 },
-    {  8,  1, 20.0*2, 0.029, 0.718,  3.750 },
-    {  9,  1, 20.0*2, 0.009, 0.690,  4.199 },
-    { 10,  1, 20.0*2, 0.009, 0.660,  4.625 },
-    { 11,  1, 18.0*2, 0.009, 0.641,  5.047 },
-    { 12,  1, 18.0*2, 0.009, 0.600,  5.438 },
-    { 13,  1, 18.0*2, 0.009, 0.584,  5.828 },
-    { 14,  1, 12.0*2, 0.009, 0.532,  6.188 },
-    { 15,  1, 12.0*2, 0.009, 0.537,  6.522 },
-    { 16,  2,  6.0*2, 0.018, 0.857,  7.174 },
-    { 17,  2,  6.0*2, 0.018, 0.858,  7.801 },
-    { 18,  2,  3.0*2, 0.018, 0.853,  8.402 },
-    { 19,  2,  3.0*2, 0.018, 0.824,  8.966 },
-    { 20,  2,  3.0*2, 0.018, 0.778,  9.484 },
-    { 21,  2,  3.0*2, 0.018, 0.740,  9.966 },
-    { 22,  2,  0.0*2, 0.018, 0.709, 10.426 },
-    { 23,  2,  0.0*2, 0.018, 0.676, 10.866 },
-    { 24,  2,  0.0*2, 0.018, 0.632, 11.279 },
-    { 25,  2,  0.0*2, 0.018, 0.592, 11.669 },
-    { 26,  2,  0.0*2, 0.018, 0.553, 12.042 },
-    { 27,  2,  0.0*2, 0.018, 0.510, 12.386 },
-    { 28,  2,  0.0*2, 0.018, 0.513, 12.721 },
-    { 29,  3,  0.0*2, 0.027, 0.608, 13.115 },
-    { 30,  3,  0.0*2, 0.027, 0.673, 13.562 },
-    { 31,  3,  0.0*2, 0.027, 0.637, 13.984 },
-    { 32,  3,  0.0*2, 0.027, 0.586, 14.371 },
-    { 33,  3,  0.0*2, 0.027, 0.571, 14.741 },
-    { 34,  4,  0.0*2, 0.036, 0.616, 15.140 },
-    { 35,  4,  0.0*2, 0.036, 0.640, 15.563 },
-    { 36,  4,  0.0*2, 0.036, 0.598, 15.962 },
-    { 37,  4,  0.0*2, 0.036, 0.538, 16.324 },
-    { 38,  4,  0.0*2, 0.036, 0.512, 16.665 },
-    { 39,  5,  0.0*2, 0.045, 0.528, 17.020 },
-    { 40,  5,  0.0*2, 0.045, 0.517, 17.373 },
-    { 41,  5,  0.0*2, 0.045, 0.493, 17.708 },
-    { 42,  6,  0.0*2, 0.054, 0.499, 18.045 },
-    { 43,  7,  0.0*2, 0.063, 0.525, 18.398 },
-    { 44,  7,  0.0*2, 0.063, 0.541, 18.762 },
-    { 45,  8,  0.0*2, 0.072, 0.528, 19.120 },
-    { 46,  8,  0.0*2, 0.072, 0.510, 19.466 },
-    { 47,  8,  0.0*2, 0.072, 0.506, 19.807 },
-    { 48, 10,  0.0*2, 0.180, 0.525, 20.159 },
-    { 49, 10,  0.0*2, 0.180, 0.536, 20.522 },
-    { 50, 10,  0.0*2, 0.180, 0.518, 20.874 },
-    { 51, 13,  0.0*2, 0.372, 0.501, 21.214 },
-    { 52, 13,  0.0*2, 0.372, 0.497, 21.553 },
-    { 53, 14,  0.0*2, 0.400, 0.497, 21.892 },
-    { 54, 18,  0.0*2, 1.627, 0.495, 22.231 },
-    { 55, 18,  0.0*2, 1.627, 0.494, 22.569 },
-    { 56, 20,  0.0*2, 1.808, 0.497, 22.909 },
-    { 57, 25,  0.0*2, 22.607, 0.494, 23.248 },
-    { 58, 25,  0.0*2, 22.607, 0.487, 23.583 },
-    { 59, 35,  0.0*2, 31.650, 0.483, 23.915 },
-    { 60, 67,  0.0*2, 605.867, 0.482, 24.246 },
-    { 61, 67,  0.0*2, 605.867, 0.524, 24.576 },
-};
 
-// See Table 3-C.7b, long blocks, MPEG-1
-// See Table D.3.b, long blocks, MPEG-2
 
-static const type1_t   table1_44100 [] = {
-    {  0,  1, 24.5*2, 4.532, 0.951,  0.000 }, // Table entry no, FFT lines=width, minval, quiet thr, norm, bval (Bark)
-    {  1,  1, 24.5*2, 4.532, 0.700,  0.431 },
-    {  2,  1, 24.5*2, 4.532, 0.681,  0.861 },
-    {  3,  1, 24.5*2, 0.904, 0.675,  1.292 },
-    {  4,  1, 24.5*2, 0.904, 0.667,  1.723 },
-    {  5,  1, 20.0*2, 0.090, 0.665,  2.153 },
-    {  6,  1, 20.0*2, 0.090, 0.664,  2.584 },
-    {  7,  1, 20.0*2, 0.029, 0.664,  3.015 },
-    {  8,  1, 20.0*2, 0.029, 0.664,  3.445 },
-    {  9,  1, 20.0*2, 0.029, 0.655,  3.876 },
-    { 10,  1, 20.0*2, 0.009, 0.616,  4.279 },
-    { 11,  1, 20.0*2, 0.009, 0.597,  4.670 },
-    { 12,  1, 18.0*2, 0.009, 0.578,  5.057 },
-    { 13,  1, 18.0*2, 0.009, 0.541,  5.416 },
-    { 14,  1, 18.0*2, 0.009, 0.575,  5.774 },
-    { 15,  2, 12.0*2, 0.018, 0.856,  6.422 },
-    { 16,  2,  6.0*2, 0.018, 0.846,  7.026 },
-    { 17,  2,  6.0*2, 0.018, 0.840,  7.609 },
-    { 18,  2,  3.0*2, 0.018, 0.822,  8.168 },
-    { 19,  2,  3.0*2, 0.018, 0.800,  8.710 },
-    { 20,  2,  3.0*2, 0.018, 0.753,  9.207 },
-    { 21,  2,  3.0*2, 0.018, 0.704,  9.662 },
-    { 22,  2,  0.0*2, 0.018, 0.674, 10.099 },
-    { 23,  2,  0.0*2, 0.018, 0.640, 10.515 },
-    { 24,  2,  0.0*2, 0.018, 0.609, 10.917 },
-    { 25,  2,  0.0*2, 0.018, 0.566, 11.293 },
-    { 26,  2,  0.0*2, 0.018, 0.535, 11.652 },
-    { 27,  2,  0.0*2, 0.018, 0.531, 11.997 },
-    { 28,  3,  0.0*2, 0.027, 0.615, 12.394 },
-    { 29,  3,  0.0*2, 0.027, 0.686, 12.850 },
-    { 30,  3,  0.0*2, 0.027, 0.650, 13.277 },
-    { 31,  3,  0.0*2, 0.027, 0.612, 13.681 },
-    { 32,  3,  0.0*2, 0.027, 0.567, 14.062 },
-    { 33,  3,  0.0*2, 0.027, 0.520, 14.411 },
-    { 34,  3,  0.0*2, 0.027, 0.513, 14.751 },
-    { 35,  4,  0.0*2, 0.036, 0.557, 15.119 },
-    { 36,  4,  0.0*2, 0.036, 0.584, 15.508 },
-    { 37,  4,  0.0*2, 0.036, 0.570, 15.883 },
-    { 38,  5,  0.0*2, 0.045, 0.579, 16.263 },
-    { 39,  5,  0.0*2, 0.045, 0.585, 16.654 },
-    { 40,  5,  0.0*2, 0.045, 0.548, 17.020 },
-    { 41,  6,  0.0*2, 0.054, 0.536, 17.374 },
-    { 42,  6,  0.0*2, 0.054, 0.550, 17.744 },
-    { 43,  7,  0.0*2, 0.063, 0.532, 18.104 },
-    { 44,  7,  0.0*2, 0.063, 0.504, 18.447 },
-    { 45,  7,  0.0*2, 0.063, 0.496, 18.782 },
-    { 46,  9,  0.0*2, 0.081, 0.517, 19.130 },
-    { 47,  9,  0.0*2, 0.081, 0.527, 19.487 },
-    { 48,  9,  0.0*2, 0.081, 0.516, 19.838 },
-    { 49, 10,  0.0*2, 0.180, 0.497, 20.179 },
-    { 50, 10,  0.0*2, 0.180, 0.489, 20.510 },
-    { 51, 11,  0.0*2, 0.198, 0.502, 20.852 },
-    { 52, 14,  0.0*2, 0.400, 0.501, 21.196 },
-    { 53, 14,  0.0*2, 0.400, 0.491, 21.531 },
-    { 54, 15,  0.0*2, 0.429, 0.497, 21.870 },
-    { 55, 20,  0.0*2, 1.808, 0.504, 22.214 },
-    { 56, 20,  0.0*2, 1.808, 0.504, 22.558 },
-    { 57, 21,  0.0*2, 1.898, 0.495, 22.898 },
-    { 58, 27,  0.0*2, 24.416, 0.486, 23.232 },
-    { 59, 27,  0.0*2, 24.416, 0.484, 23.564 },
-    { 60, 36,  0.0*2, 32.554, 0.483, 23.897 },
-    { 61, 73,  0.0*2, 660.124, 0.475, 24.229 },
-    { 62, 18,  0.0*2, 162.770, 0.515, 24.442 },
-};
+const FLOAT  psy_data [] = {
+
+ 48000.0, 61,				// Sample Frequency, Table entries
+ 0, 1, 24.5, 4.532, 0.970, 0.000,	// Table entry 0, data?, TMN?, data?, data?, data?
+ 1, 1, 24.5, 4.532, 0.755, 0.469,
+ 2, 1, 24.5, 4.532, 0.738, 0.938,
+ 3, 1, 24.5, 0.904, 0.730, 1.406,
+ 4, 1, 24.5, 0.904, 0.724, 1.875,
+ 5, 1, 20.0, 0.090, 0.723, 2.344,
+ 6, 1, 20.0, 0.090, 0.723, 2.813,
+ 7, 1, 20.0, 0.029, 0.723, 3.281,
+ 8, 1, 20.0, 0.029, 0.718, 3.750,
+ 9, 1, 20.0, 0.009, 0.690, 4.199,
+ 10, 1, 20.0, 0.009, 0.660, 4.625,
+ 11, 1, 18.0, 0.009, 0.641, 5.047,
+ 12, 1, 18.0, 0.009, 0.600, 5.438,
+ 13, 1, 18.0, 0.009, 0.584, 5.828,
+ 14, 1, 12.0, 0.009, 0.532, 6.188,
+ 15, 1, 12.0, 0.009, 0.537, 6.522,
+ 16, 2, 6.0, 0.018, 0.857, 7.174,
+ 17, 2, 6.0, 0.018, 0.858, 7.801,
+ 18, 2, 3.0, 0.018, 0.853, 8.402,
+ 19, 2, 3.0, 0.018, 0.824, 8.966,
+ 20, 2, 3.0, 0.018, 0.778, 9.484,
+ 21, 2, 3.0, 0.018, 0.740, 9.966,
+ 22, 2, 0.0, 0.018, 0.709, 10.426,
+ 23, 2, 0.0, 0.018, 0.676, 10.866,
+ 24, 2, 0.0, 0.018, 0.632, 11.279,
+ 25, 2, 0.0, 0.018, 0.592, 11.669,
+ 26, 2, 0.0, 0.018, 0.553, 12.042,
+ 27, 2, 0.0, 0.018, 0.510, 12.386,
+ 28, 2, 0.0, 0.018, 0.513, 12.721,
+ 29, 3, 0.0, 0.027, 0.608, 13.115,
+ 30, 3, 0.0, 0.027, 0.673, 13.562,
+ 31, 3, 0.0, 0.027, 0.637, 13.984,
+ 32, 3, 0.0, 0.027, 0.586, 14.371,
+ 33, 3, 0.0, 0.027, 0.571, 14.741,
+ 34, 4, 0.0, 0.036, 0.616, 15.140,
+ 35, 4, 0.0, 0.036, 0.640, 15.563,
+ 36, 4, 0.0, 0.036, 0.598, 15.962,
+ 37, 4, 0.0, 0.036, 0.538, 16.324,
+ 38, 4, 0.0, 0.036, 0.512, 16.665,
+ 39, 5, 0.0, 0.045, 0.528, 17.020,
+ 40, 5, 0.0, 0.045, 0.517, 17.373,
+ 41, 5, 0.0, 0.045, 0.493, 17.708,
+ 42, 6, 0.0, 0.054, 0.499, 18.045,
+ 43, 7, 0.0, 0.063, 0.525, 18.398,
+ 44, 7, 0.0, 0.063, 0.541, 18.762,
+ 45, 8, 0.0, 0.072, 0.528, 19.120,
+ 46, 8, 0.0, 0.072, 0.510, 19.466,
+ 47, 8, 0.0, 0.072, 0.506, 19.807,
+ 48, 10, 0.0, 0.180, 0.525, 20.159,
+ 49, 10, 0.0, 0.180, 0.536, 20.522,
+ 50, 10, 0.0, 0.180, 0.518, 20.874,
+ 51, 13, 0.0, 0.372, 0.501, 21.214,
+ 52, 13, 0.0, 0.372, 0.497, 21.553,
+ 53, 14, 0.0, 0.400, 0.497, 21.892,
+ 54, 18, 0.0, 1.627, 0.495, 22.231,
+ 55, 18, 0.0, 1.627, 0.494, 22.569,
+ 56, 20, 0.0, 1.808, 0.497, 22.909,
+ 57, 25, 0.0, 22.607, 0.494, 23.248,
+ 58, 25, 0.0, 22.607, 0.487, 23.583,
+ 59, 35, 0.0, 31.650, 0.483, 23.915,
+ 60, 67, 0.0, 605.867, 0.482, 24.246,
+ 61, 67, 0.0, 605.867, 0.524, 24.576,
  
-// See Table 3-C.7c, long blocks, MPEG-1
-// See Table D.3.c, long blocks, MPEG-2
+ 44100.0, 62,
+ 0, 1, 24.5, 4.532, 0.951, 0.000,
+ 1, 1, 24.5, 4.532, 0.700, 0.431,
+ 2, 1, 24.5, 4.532, 0.681, 0.861,
+ 3, 1, 24.5, 0.904, 0.675, 1.292,
+ 4, 1, 24.5, 0.904, 0.667, 1.723,
+ 5, 1, 20.0, 0.090, 0.665, 2.153,
+ 6, 1, 20.0, 0.090, 0.664, 2.584,
+ 7, 1, 20.0, 0.029, 0.664, 3.015,
+ 8, 1, 20.0, 0.029, 0.664, 3.445,
+ 9, 1, 20.0, 0.029, 0.655, 3.876,
+ 10, 1, 20.0, 0.009, 0.616, 4.279,
+ 11, 1, 20.0, 0.009, 0.597, 4.670,
+ 12, 1, 18.0, 0.009, 0.578, 5.057,
+ 13, 1, 18.0, 0.009, 0.541, 5.416,
+ 14, 1, 18.0, 0.009, 0.575, 5.774,
+ 15, 2, 12.0, 0.018, 0.856, 6.422,
+ 16, 2, 6.0, 0.018, 0.846, 7.026,
+ 17, 2, 6.0, 0.018, 0.840, 7.609,
+ 18, 2, 3.0, 0.018, 0.822, 8.168,
+ 19, 2, 3.0, 0.018, 0.800, 8.710,
+ 20, 2, 3.0, 0.018, 0.753, 9.207,
+ 21, 2, 3.0, 0.018, 0.704, 9.662,
+ 22, 2, 0.0, 0.018, 0.674, 10.099,
+ 23, 2, 0.0, 0.018, 0.640, 10.515,
+ 24, 2, 0.0, 0.018, 0.609, 10.917,
+ 25, 2, 0.0, 0.018, 0.566, 11.293,
+ 26, 2, 0.0, 0.018, 0.535, 11.652,
+ 27, 2, 0.0, 0.018, 0.531, 11.997,
+ 28, 3, 0.0, 0.027, 0.615, 12.394,
+ 29, 3, 0.0, 0.027, 0.686, 12.850,
+ 30, 3, 0.0, 0.027, 0.650, 13.277,
+ 31, 3, 0.0, 0.027, 0.612, 13.681,
+ 32, 3, 0.0, 0.027, 0.567, 14.062,
+ 33, 3, 0.0, 0.027, 0.520, 14.411,
+ 34, 3, 0.0, 0.027, 0.513, 14.751,
+ 35, 4, 0.0, 0.036, 0.557, 15.119,
+ 36, 4, 0.0, 0.036, 0.584, 15.508,
+ 37, 4, 0.0, 0.036, 0.570, 15.883,
+ 38, 5, 0.0, 0.045, 0.579, 16.263,
+ 39, 5, 0.0, 0.045, 0.585, 16.654,
+ 40, 5, 0.0, 0.045, 0.548, 17.020,
+ 41, 6, 0.0, 0.054, 0.536, 17.374,
+ 42, 6, 0.0, 0.054, 0.550, 17.744,
+ 43, 7, 0.0, 0.063, 0.532, 18.104,
+ 44, 7, 0.0, 0.063, 0.504, 18.447,
+ 45, 7, 0.0, 0.063, 0.496, 18.782,
+ 46, 9, 0.0, 0.081, 0.517, 19.130,
+ 47, 9, 0.0, 0.081, 0.527, 19.487,
+ 48, 9, 0.0, 0.081, 0.516, 19.838,
+ 49, 10, 0.0, 0.180, 0.497, 20.179,
+ 50, 10, 0.0, 0.180, 0.489, 20.510,
+ 51, 11, 0.0, 0.198, 0.502, 20.852,
+ 52, 14, 0.0, 0.400, 0.501, 21.196,
+ 53, 14, 0.0, 0.400, 0.491, 21.531,
+ 54, 15, 0.0, 0.429, 0.497, 21.870,
+ 55, 20, 0.0, 1.808, 0.504, 22.214,
+ 56, 20, 0.0, 1.808, 0.504, 22.558,
+ 57, 21, 0.0, 1.898, 0.495, 22.898,
+ 58, 27, 0.0, 24.416, 0.486, 23.232,
+ 59, 27, 0.0, 24.416, 0.484, 23.564,
+ 60, 36, 0.0, 32.554, 0.483, 23.897,
+ 61, 73, 0.0, 660.124, 0.475, 24.229,
+ 62, 18, 0.0, 162.770, 0.515, 24.442,
  
-static const type1_t   table1_32000 [] = {
-    {  0,  2, 24.5*2, 4.532, 0.997,  0.313 }, // Table entry no, FFT lines=width, minval, quiet thr, norm, bval (Bark)
-    {  1,  2, 24.5*2, 4.532, 0.893,  0.938 },
-    {  2,  2, 24.5*2, 1.809, 0.881,  1.563 },
-    {  3,  2, 20.0*2, 0.181, 0.873,  2.188 },
-    {  4,  2, 20.0*2, 0.181, 0.872,  2.813 },
-    {  5,  2, 20.0*2, 0.057, 0.871,  3.438 },
-    {  6,  2, 20.0*2, 0.018, 0.860,  4.045 },
-    {  7,  2, 20.0*2, 0.018, 0.839,  4.625 },
-    {  8,  2, 18.0*2, 0.018, 0.812,  5.173 },
-    {  9,  2, 18.0*2, 0.018, 0.784,  5.698 },
-    { 10,  2, 12.0*2, 0.018, 0.741,  6.185 },
-    { 11,  2, 12.0*2, 0.018, 0.697,  6.634 },
-    { 12,  2,  6.0*2, 0.018, 0.674,  7.070 },
-    { 13,  2,  6.0*2, 0.018, 0.651,  7.492 },
-    { 14,  2,  6.0*2, 0.018, 0.633,  7.905 },
-    { 15,  2,  3.0*2, 0.018, 0.611,  8.305 },
-    { 16,  2,  3.0*2, 0.018, 0.589,  8.695 },
-    { 17,  2,  3.0*2, 0.018, 0.575,  9.064 },
-    { 18,  3,  3.0*2, 0.027, 0.654,  9.484 },
-    { 19,  3,  3.0*2, 0.027, 0.724,  9.966 },
-    { 20,  3,  0.0*2, 0.027, 0.701, 10.426 },
-    { 21,  3,  0.0*2, 0.027, 0.673, 10.866 },
-    { 22,  3,  0.0*2, 0.027, 0.631, 11.279 },
-    { 23,  3,  0.0*2, 0.027, 0.592, 11.669 },
-    { 24,  3,  0.0*2, 0.027, 0.553, 12.042 },
-    { 25,  3,  0.0*2, 0.027, 0.510, 12.386 },
-    { 26,  3,  0.0*2, 0.027, 0.506, 12.721 },
-    { 27,  4,  0.0*2, 0.036, 0.562, 13.091 },
-    { 28,  4,  0.0*2, 0.036, 0.598, 13.488 },
-    { 29,  4,  0.0*2, 0.036, 0.589, 13.873 },
-    { 30,  5,  0.0*2, 0.045, 0.607, 14.268 },
-    { 31,  5,  0.0*2, 0.045, 0.620, 14.679 },
-    { 32,  5,  0.0*2, 0.045, 0.580, 15.067 },
-    { 33,  5,  0.0*2, 0.045, 0.532, 15.424 },
-    { 34,  5,  0.0*2, 0.045, 0.517, 15.771 },
-    { 35,  6,  0.0*2, 0.054, 0.517, 16.120 },
-    { 36,  6,  0.0*2, 0.054, 0.509, 16.466 },
-    { 37,  6,  0.0*2, 0.054, 0.506, 16.807 },
-    { 38,  8,  0.0*2, 0.072, 0.522, 17.158 },
-    { 39,  8,  0.0*2, 0.072, 0.531, 17.518 },
-    { 40,  8,  0.0*2, 0.072, 0.519, 17.869 },
-    { 41, 10,  0.0*2, 0.090, 0.512, 18.215 },
-    { 42, 10,  0.0*2, 0.090, 0.509, 18.563 },
-    { 43, 10,  0.0*2, 0.090, 0.498, 18.902 },
-    { 44, 12,  0.0*2, 0.109, 0.494, 19.239 },
-    { 45, 12,  0.0*2, 0.109, 0.501, 19.580 },
-    { 46, 13,  0.0*2, 0.118, 0.508, 19.925 },
-    { 47, 14,  0.0*2, 0.252, 0.502, 20.269 },
-    { 48, 14,  0.0*2, 0.252, 0.493, 20.606 },
-    { 49, 16,  0.0*2, 0.288, 0.497, 20.944 },
-    { 50, 20,  0.0*2, 0.572, 0.506, 21.288 },
-    { 51, 20,  0.0*2, 0.572, 0.510, 21.635 },
-    { 52, 23,  0.0*2, 0.658, 0.504, 21.980 },
-    { 53, 27,  0.0*2, 2.441, 0.496, 22.319 },
-    { 54, 27,  0.0*2, 2.441, 0.493, 22.656 },
-    { 55, 32,  0.0*2, 2.893, 0.490, 22.993 },
-    { 56, 37,  0.0*2, 33.458, 0.482, 23.326 },
-    { 57, 37,  0.0*2, 33.458, 0.458, 23.656 },
-    { 58, 12,  0.0*2, 10.851, 0.500, 23.937 },
-};                
-                  
-// Taken from 'dist10/lsf/encoder/tables/psy_data'
-  
-static const type1_t   table1_24000 [] = {
-    {  0,  2, 15*2, 17.8250179, 0.697374165, 0.236874461 }, // Table entry no, FFT lines=width, minval, quiet thr, norm, bval (Bark)
-    {  1,  2, 15*2, 17.8250179, 0.455024809, 0.71016103 },
-    {  2,  2, 15*2, 1.78250182, 0.431440443, 1.18193281 },
-    {  3,  2, 15*2, 1.78250182, 0.42391625, 1.65102732 },
-    {  4,  2, 13*2, 0.178250194, 0.418206781, 2.11632562 },
-    {  5,  2, 13*2, 0.178250194, 0.41158545, 2.57676744 },
-    {  6,  2, 13*2, 0.0563676581, 0.405409157, 3.03136396 },
-    {  7,  2, 13*2, 0.0563676581, 0.399695486, 3.47920918 },
-    {  8,  2, 13*2, 0.0563676581, 0.393753231, 3.91948748 },
-    {  9,  2, 12*2, 0.0178250186, 0.387357473, 4.35147953 },
-    { 10,  2, 12*2, 0.0178250186, 0.38045457, 4.77456427 },
-    { 11,  2, 10*2, 0.0178250186, 0.373053908, 5.18822002 },
-    { 12,  2, 10*2, 0.0178250186, 0.365188122, 5.59202194 },
-    { 13,  2, 10*2, 0.0178250186, 0.356897771, 5.98564005 },
-    { 14,  2,  9*2, 0.0178250186, 0.348700613, 6.36883163 },
-    { 15,  2,  9*2, 0.0178250186, 0.340260029, 6.74143791 },
-    { 16,  2,  6*2, 0.0178250186, 0.332341045, 7.10337448 },
-    { 17,  2,  6*2, 0.0178250186, 0.330462843, 7.45462418 },
-    { 18,  2,  6*2, 0.0178250186, 0.345568359, 7.79523182 },
-    { 19,  3,  3*2, 0.0267375279, 0.377859652, 8.20455742 },
-    { 20,  3,  3*2, 0.0267375279, 0.396689415, 8.67640114 },
-    { 21,  3,  3*2, 0.0267375279, 0.391237885, 9.12561035 },
-    { 22,  3,  3*2, 0.0267375279, 0.37761277, 9.55298138 },
-    { 23,  3,  3*2, 0.0267375279, 0.362836808, 9.95940971 },
-    { 24,  3,  0*2, 0.0267375279, 0.349010617, 10.3458519 },
-    { 25,  3,  0*2, 0.0267375279, 0.339673489, 10.7132998 },
-    { 26,  3,  0*2, 0.0267375279, 0.343845725, 11.0627575 },
-    { 27,  4,  0*2, 0.0356500372, 0.355822682, 11.447506 },
-    { 28,  4,  0*2, 0.0356500372, 0.358104348, 11.8627586 },
-    { 29,  4,  0*2, 0.0356500372, 0.34745428, 12.2520256 },
-    { 30,  4,  0*2, 0.0356500372, 0.334927917, 12.6173973 },
-    { 31,  4,  0*2, 0.0356500372, 0.331643254, 12.9608269 },
-    { 32,  5,  0*2, 0.0445625484, 0.333368897, 13.3219252 },
-    { 33,  5,  0*2, 0.0445625484, 0.332313001, 13.6976833 },
-    { 34,  5,  0*2, 0.0445625484, 0.3314417, 14.047802 },
-    { 35,  6,  0*2, 0.0534750558, 0.330947191, 14.405302 },
-    { 36,  6,  0*2, 0.0534750558, 0.332477689, 14.7684803 },
-    { 37,  7,  0*2, 0.062387567, 0.332647532, 15.1315956 },
-    { 38,  7,  0*2, 0.062387567, 0.330841452, 15.4940481 },
-    { 39,  8,  0*2, 0.0713000745, 0.327769846, 15.8516159 },
-    { 40,  8,  0*2, 0.0713000745, 0.324572712, 16.204628 },
-    { 41,  9,  0*2, 0.0802125856, 0.323825002, 16.5502281 },
-    { 42, 10,  0*2, 0.0891250968, 0.321414798, 16.9067478 },
-    { 43, 10,  0*2, 0.0891250968, 0.318189293, 17.2537231 },
-    { 44, 11,  0*2, 0.0980376005, 0.315934151, 17.5901108 },
-    { 45, 12,  0*2, 0.106950112, 0.315639287, 17.931406 },
-    { 46, 13,  0*2, 0.115862623, 0.316569835, 18.2750721 },
-    { 47, 14,  0*2, 0.124775134, 0.31656, 18.6191597 },
-    { 48, 15,  0*2, 0.133687645, 0.315465957, 18.9621754 },
-    { 49, 16,  0*2, 0.142600149, 0.313576341, 19.3029613 },
-    { 50, 17,  0*2, 0.151512653, 0.311635971, 19.6405869 },
-    { 51, 18,  0*2, 0.160425171, 0.311066717, 19.9742699 },
-    { 52, 20,  0*2, 0.355655879, 0.311465651, 20.3115921 },
-    { 53, 21,  0*2, 0.373438686, 0.311872005, 20.6507797 },
-    { 54, 23,  0*2, 0.409004271, 0.311015964, 20.9890823 },
-    { 55, 24,  0*2, 0.676411927, 0.309207708, 21.3251152 },
-    { 56, 26,  0*2, 0.732779562, 0.3081128, 21.6565971 },
-    { 57, 28,  0*2, 0.789147198, 0.310006589, 21.9881554 },
-    { 58, 31,  0*2, 2.76287794, 0.327113092, 22.3222847 },
-    { 59, 34,  0*2, 3.03025317, 0.416082352, 22.6605186 },
-};
+ 32000.0, 58,
+ 0, 2, 24.5, 4.532, 0.997, 0.313,
+ 1, 2, 24.5, 4.532, 0.893, 0.938,
+ 2, 2, 24.5, 1.809, 0.881, 1.563,
+ 3, 2, 20.0, 0.181, 0.873, 2.188,
+ 4, 2, 20.0, 0.181, 0.872, 2.813,
+ 5, 2, 20.0, 0.057, 0.871, 3.438,
+ 6, 2, 20.0, 0.018, 0.860, 4.045,
+ 7, 2, 20.0, 0.018, 0.839, 4.625,
+ 8, 2, 18.0, 0.018, 0.812, 5.173,
+ 9, 2, 18.0, 0.018, 0.784, 5.698,
+ 10, 2, 12.0, 0.018, 0.741, 6.185,
+ 11, 2, 12.0, 0.018, 0.697, 6.634,
+ 12, 2, 6.0, 0.018, 0.674, 7.070,
+ 13, 2, 6.0, 0.018, 0.651, 7.492,
+ 14, 2, 6.0, 0.018, 0.633, 7.905,
+ 15, 2, 3.0, 0.018, 0.611, 8.305,
+ 16, 2, 3.0, 0.018, 0.589, 8.695,
+ 17, 2, 3.0, 0.018, 0.575, 9.064,
+ 18, 3, 3.0, 0.027, 0.654, 9.484,
+ 19, 3, 3.0, 0.027, 0.724, 9.966,
+ 20, 3, 0.0, 0.027, 0.701, 10.426,
+ 21, 3, 0.0, 0.027, 0.673, 10.866,
+ 22, 3, 0.0, 0.027, 0.631, 11.279,
+ 23, 3, 0.0, 0.027, 0.592, 11.669,
+ 24, 3, 0.0, 0.027, 0.553, 12.042,
+ 25, 3, 0.0, 0.027, 0.510, 12.386,
+ 26, 3, 0.0, 0.027, 0.506, 12.721,
+ 27, 4, 0.0, 0.036, 0.562, 13.091,
+ 28, 4, 0.0, 0.036, 0.598, 13.488,
+ 29, 4, 0.0, 0.036, 0.589, 13.873,
+ 30, 5, 0.0, 0.045, 0.607, 14.268,
+ 31, 5, 0.0, 0.045, 0.620, 14.679,
+ 32, 5, 0.0, 0.045, 0.580, 15.067,
+ 33, 5, 0.0, 0.045, 0.532, 15.424,
+ 34, 5, 0.0, 0.045, 0.517, 15.771,
+ 35, 6, 0.0, 0.054, 0.517, 16.120,
+ 36, 6, 0.0, 0.054, 0.509, 16.466,
+ 37, 6, 0.0, 0.054, 0.506, 16.807,
+ 38, 8, 0.0, 0.072, 0.522, 17.158,
+ 39, 8, 0.0, 0.072, 0.531, 17.518,
+ 40, 8, 0.0, 0.072, 0.519, 17.869,
+ 41, 10, 0.0, 0.090, 0.512, 18.215,
+ 42, 10, 0.0, 0.090, 0.509, 18.563,
+ 43, 10, 0.0, 0.090, 0.498, 18.902,
+ 44, 12, 0.0, 0.109, 0.494, 19.239,
+ 45, 12, 0.0, 0.109, 0.501, 19.580,
+ 46, 13, 0.0, 0.118, 0.508, 19.925,
+ 47, 14, 0.0, 0.252, 0.502, 20.269,
+ 48, 14, 0.0, 0.252, 0.493, 20.606,
+ 49, 16, 0.0, 0.288, 0.497, 20.944,
+ 50, 20, 0.0, 0.572, 0.506, 21.288,
+ 51, 20, 0.0, 0.572, 0.510, 21.635,
+ 52, 23, 0.0, 0.658, 0.504, 21.980,
+ 53, 27, 0.0, 2.441, 0.496, 22.319,
+ 54, 27, 0.0, 2.441, 0.493, 22.656,
+ 55, 32, 0.0, 2.893, 0.490, 22.993,
+ 56, 37, 0.0, 33.458, 0.482, 23.326,
+ 57, 37, 0.0, 33.458, 0.458, 23.656,
+ 58, 12, 0.0, 10.851, 0.500, 23.937,
  
-// Taken from 'dist10/lsf/encoder/tables/psy_data'
-  
-static const type1_t   table1_22050 [] = {
-    {  0,  2, 15*2, 17.8250179, 0.658683598, 0.217637643 }, // Table entry no, FFT lines=width, minval, quiet thr, norm, bval (Bark)
-    {  1,  2, 15*2, 17.8250179, 0.432554901, 0.652563453 },
-    {  2,  2, 15*2, 1.78250182, 0.405113578, 1.08633137 },
-    {  3,  2, 15*2, 1.78250182, 0.397231787, 1.51803517 },
-    {  4,  2, 15*2, 1.78250182, 0.392088681, 1.94679713 },
-    {  5,  2, 13*2, 0.178250194, 0.386788279, 2.37177849 },
-    {  6,  2, 13*2, 0.178250194, 0.380574644, 2.79218864 },
-    {  7,  2, 13*2, 0.0563676581, 0.375309765, 3.20729256 },
-    {  8,  2, 13*2, 0.0563676581, 0.370087624, 3.61641645 },
-    {  9,  2, 12*2, 0.0178250186, 0.364568561, 4.01895428 },
-    { 10,  2, 12*2, 0.0178250186, 0.358959526, 4.4143672 },
-    { 11,  2, 12*2, 0.0178250186, 0.352938265, 4.80218887 },
-    { 12,  2, 10*2, 0.0178250186, 0.3465029, 5.18202305 },
-    { 13,  2, 10*2, 0.0178250186, 0.33968094, 5.55354261 },
-    { 14,  2, 10*2, 0.0178250186, 0.332571507, 5.91648674 },
-    { 15,  2,  9*2, 0.0178250186, 0.326015651, 6.27065945 },
-    { 16,  2,  9*2, 0.0178250186, 0.325442046, 6.61592293 },
-    { 17,  2,  9*2, 0.0178250186, 0.341315031, 6.95219517 },
-    { 18,  3,  6*2, 0.0267375279, 0.374984443, 7.3584404 },
-    { 19,  3,  6*2, 0.0267375279, 0.396138102, 7.8290925 },
-    { 20,  3,  3*2, 0.0267375279, 0.39271906, 8.27975655 },
-    { 21,  3,  3*2, 0.0267375279, 0.380755007, 8.71083069 },
-    { 22,  3,  3*2, 0.0267375279, 0.367386311, 9.12284088 },
-    { 23,  3,  3*2, 0.0267375279, 0.354351997, 9.51640987 },
-    { 24,  3,  3*2, 0.0267375279, 0.341508389, 9.89222908 },
-    { 25,  3,  0*2, 0.0267375279, 0.333577901, 10.2510386 },
-    { 26,  3,  0*2, 0.0267375279, 0.338108748, 10.5936022 },
-    { 27,  4,  0*2, 0.0356500372, 0.350744486, 10.9723492 },
-    { 28,  4,  0*2, 0.0356500372, 0.354519457, 11.38272 },
-    { 29,  4,  0*2, 0.0356500372, 0.345274031, 11.7689981 },
-    { 30,  4,  0*2, 0.0356500372, 0.333828837, 12.1329184 },
-    { 31,  4,  0*2, 0.0356500372, 0.331436664, 12.4761295 },
-    { 32,  5,  0*2, 0.0445625484, 0.334172577, 12.8381901 },
-    { 33,  5,  0*2, 0.0445625484, 0.334024847, 13.2160273 },
-    { 34,  5,  0*2, 0.0445625484, 0.33392629, 13.5690479 },
-    { 35,  6,  0*2, 0.0534750558, 0.334218502, 13.9303951 },
-    { 36,  6,  0*2, 0.0534750558, 0.336405039, 14.298193 },
-    { 37,  7,  0*2, 0.062387567, 0.337080389, 14.666563 },
-    { 38,  7,  0*2, 0.062387567, 0.335603535, 15.0346909 },
-    { 39,  8,  0*2, 0.0713000745, 0.332515866, 15.398139 },
-    { 40,  8,  0*2, 0.0713000745, 0.327727586, 15.7570457 },
-    { 41,  9,  0*2, 0.0802125856, 0.322346836, 16.1083431 },
-    { 42,  9,  0*2, 0.0802125856, 0.317575186, 16.4528522 },
-    { 43, 10,  0*2, 0.0891250968, 0.31632933, 16.7886105 },
-    { 44, 11,  0*2, 0.0980376005, 0.317602783, 17.132 },
-    { 45, 12,  0*2, 0.106950112, 0.319945186, 17.4796028 },
-    { 46, 13,  0*2, 0.115862623, 0.320881754, 17.8287659 },
-    { 47, 14,  0*2, 0.124775134, 0.320346534, 18.1774921 },
-    { 48, 15,  0*2, 0.133687645, 0.318628669, 18.5243168 },
-    { 49, 16,  0*2, 0.142600149, 0.316125751, 18.8681736 },
-    { 50, 17,  0*2, 0.151512653, 0.313746184, 19.2082729 },
-    { 51, 18,  0*2, 0.160425171, 0.312971771, 19.5440025 },
-    { 52, 20,  0*2, 0.178250194, 0.313278913, 19.8831882 },
-    { 53, 21,  0*2, 0.373438686, 0.313735574, 20.224247 },
-    { 54, 23,  0*2, 0.409004271, 0.31308493, 20.5646286 },
-    { 55, 24,  0*2, 0.426787049, 0.31156227, 20.903141 },
-    { 56, 26,  0*2, 0.732779562, 0.310435742, 21.2376747 },
-    { 57, 28,  0*2, 0.789147198, 0.31132248, 21.5730591 },
-    { 58, 30,  0*2, 0.845514894, 0.32730341, 21.9066811 },
-    { 59, 33,  0*2, 2.94112802, 0.414659739, 22.2411156 },
-};
-
-// Taken from 'dist10/lsf/encoder/tables/psy_data'
-  
-static const type1_t   table1_16000 [] = {
-    {  0,  3, 15*2, 26.7375278, 0.697374165, 0.236874461 }, // Table entry no, FFT lines=width, minval, quiet thr, norm, bval (Bark)
-    {  1,  3, 15*2, 26.7375278, 0.455024809, 0.71016103 },
-    {  2,  3, 15*2, 2.67375278, 0.431440443, 1.18193281 },
-    {  3,  3, 15*2, 2.67375278, 0.42391625, 1.65102732 },
-    {  4,  3, 13*2, 0.26737529, 0.418206781, 2.11632562 },
-    {  5,  3, 13*2, 0.26737529, 0.41158545, 2.57676744 },
-    {  6,  3, 13*2, 0.0845514908, 0.405409157, 3.03136396 },
-    {  7,  3, 13*2, 0.0845514908, 0.399695486, 3.47920918 },
-    {  8,  3, 13*2, 0.0845514908, 0.393753231, 3.91948748 },
-    {  9,  3, 12*2, 0.0267375279, 0.387357473, 4.35147953 },
-    { 10,  3, 12*2, 0.0267375279, 0.38045457, 4.77456427 },
-    { 11,  3, 10*2, 0.0267375279, 0.373053908, 5.18822002 },
-    { 12,  3, 10*2, 0.0267375279, 0.365188122, 5.59202194 },
-    { 13,  3, 10*2, 0.0267375279, 0.356897742, 5.98564005 },
-    { 14,  3,  9*2, 0.0267375279, 0.34869957, 6.36883163 },
-    { 15,  3,  9*2, 0.0267375279, 0.340241522, 6.74143791 },
-    { 16,  3,  6*2, 0.0267375279, 0.332089454, 7.10337448 },
-    { 17,  3,  6*2, 0.0267375279, 0.328292668, 7.45462418 },
-    { 18,  3,  6*2, 0.0267375279, 0.336574793, 7.79523182 },
-    { 19,  4,  3*2, 0.0356500372, 0.354600489, 8.17827797 },
-    { 20,  4,  3*2, 0.0356500372, 0.364343345, 8.59994984 },
-    { 21,  4,  3*2, 0.0356500372, 0.359369367, 9.00363636 },
-    { 22,  4,  3*2, 0.0356500372, 0.347775847, 9.38988018 },
-    { 23,  4,  3*2, 0.0356500372, 0.335562587, 9.7592926 },
-    { 24,  4,  0*2, 0.0356500372, 0.326988578, 10.1125278 },
-    { 25,  4,  0*2, 0.0356500372, 0.327966213, 10.4502735 },
-    { 26,  5,  0*2, 0.0445625484, 0.334450752, 10.811614 },
-    { 27,  5,  0*2, 0.0445625484, 0.335228145, 11.1935263 },
-    { 28,  5,  0*2, 0.0445625484, 0.329595625, 11.5549288 },
-    { 29,  5,  0*2, 0.0445625484, 0.326683223, 11.8971443 },
-    { 30,  6,  0*2, 0.0534750558, 0.326986551, 12.2520256 },
-    { 31,  6,  0*2, 0.0534750558, 0.325072199, 12.6173973 },
-    { 32,  6,  0*2, 0.0534750558, 0.323560268, 12.9608269 },
-    { 33,  7,  0*2, 0.062387567, 0.322494298, 13.3093863 },
-    { 34,  7,  0*2, 0.062387567, 0.323403448, 13.6617231 },
-    { 35,  8,  0*2, 0.0713000745, 0.323232353, 14.0134668 },
-    { 36,  8,  0*2, 0.0713000745, 0.322662383, 14.3639784 },
-    { 37,  9,  0*2, 0.0802125856, 0.324054241, 14.7098465 },
-    { 38, 10,  0*2, 0.0891250968, 0.323228806, 15.0686541 },
-    { 39, 10,  0*2, 0.0891250968, 0.320751846, 15.4191036 },
-    { 40, 11,  0*2, 0.0980376005, 0.318823338, 15.7594051 },
-    { 41, 12,  0*2, 0.106950112, 0.318418682, 16.104557 },
-    { 42, 13,  0*2, 0.115862623, 0.318762124, 16.451416 },
-    { 43, 14,  0*2, 0.124775134, 0.317806393, 16.7975388 },
-    { 44, 15,  0*2, 0.133687645, 0.315653771, 17.1411018 },
-    { 45, 16,  0*2, 0.142600149, 0.313369036, 17.4808159 },
-    { 46, 17,  0*2, 0.151512653, 0.312513858, 17.8158207 },
-    { 47, 19,  0*2, 0.169337675, 0.312785119, 18.1543369 },
-    { 48, 20,  0*2, 0.178250194, 0.31343773, 18.4948578 },
-    { 49, 22,  0*2, 0.196075201, 0.313258767, 18.8350143 },
-    { 50, 23,  0*2, 0.20498772, 0.312570423, 19.1740704 },
-    { 51, 25,  0*2, 0.222812727, 0.312572777, 19.5104179 },
-    { 52, 27,  0*2, 0.240637749, 0.313047856, 19.8497677 },
-    { 53, 29,  0*2, 0.515701056, 0.315029174, 20.1900635 },
-    { 54, 31,  0*2, 0.551266611, 0.330613613, 20.5294952 },
-    { 55, 33,  0*2, 0.586832225, 0.41819948, 20.8664398 },
-};              
-                
-// See Table 3-C.7d, short blocks, MPEG-1
-// See Table D.3.d, short blocks, MPEG-2
-
-static const type2_t   table2_48000 [] = {
-    {  0,  1, 4.532, 1.000, 0.15,  0.000 },  // no, FFT-lines=width, quiet thr, norm, SNR(dB), bval (Bark)
-    {  1,  1, 0.904, 0.989, 0.15,  1.875 },
-    {  2,  1, 0.029, 0.989, 0.15,  3.750 },
-    {  3,  1, 0.009, 0.981, 0.15,  5.438 },
-    {  4,  1, 0.009, 0.985, 0.15,  6.857 },
-    {  5,  1, 0.009, 0.984, 0.15,  8.109 },
-    {  6,  1, 0.009, 0.980, 0.15,  9.237 },
-    {  7,  1, 0.009, 0.968, 0.15, 10.202 },
-    {  8,  1, 0.009, 0.954, 0.15, 11.083 },
-    {  9,  1, 0.009, 0.929, 0.15, 11.865 },
-    { 10,  1, 0.009, 0.906, 0.18, 12.554 },
-    { 11,  1, 0.009, 0.883, 0.18, 13.195 },
-    { 12,  1, 0.009, 0.844, 0.18, 13.781 },
-    { 13,  1, 0.009, 0.792, 0.18, 14.309 },
-    { 14,  1, 0.009, 0.747, 0.18, 14.803 },
-    { 15,  1, 0.009, 0.689, 0.18, 15.250 },
-    { 16,  1, 0.009, 0.644, 0.18, 15.667 },
-    { 17,  1, 0.009, 0.592, 0.18, 16.068 },
-    { 18,  1, 0.009, 0.553, 0.18, 16.409 },
-    { 19,  2, 0.018, 0.850, 0.18, 17.045 },
-    { 20,  2, 0.018, 0.811, 0.20, 17.607 },
-    { 21,  2, 0.018, 0.736, 0.20, 18.097 },
-    { 22,  2, 0.018, 0.665, 0.20, 18.528 },
-    { 23,  2, 0.018, 0.610, 0.20, 18.931 },
-    { 24,  2, 0.018, 0.544, 0.20, 19.295 },
-    { 25,  2, 0.018, 0.528, 0.20, 19.636 },
-    { 26,  3, 0.054, 0.621, 0.20, 20.038 },
-    { 27,  3, 0.054, 0.673, 0.20, 20.486 },
-    { 28,  3, 0.054, 0.635, 0.20, 20.900 },
-    { 29,  4, 0.114, 0.626, 0.20, 21.306 },
-    { 30,  4, 0.114, 0.636, 0.25, 21.722 },
-    { 31,  5, 0.452, 0.615, 0.25, 22.128 },
-    { 32,  5, 0.452, 0.579, 0.25, 22.513 },
-    { 33,  5, 0.452, 0.551, 0.25, 22.877 },
-    { 34,  7, 6.330, 0.552, 0.30, 23.241 },
-    { 35,  7, 6.330, 0.559, 0.30, 23.616 },
-    { 36, 11, 9.947, 0.528, 0.30, 23.974 },
-    { 37, 17, 153.727, 0.479, 0.30, 24.313 },
-};
+ 24000, 59,
+ 0, 2, 15, 17.8250179, 0.697374165, 0.236874461,
+ 1, 2, 15, 17.8250179, 0.455024809, 0.71016103,
+ 2, 2, 15, 1.78250182, 0.431440443, 1.18193281,
+ 3, 2, 15, 1.78250182, 0.42391625, 1.65102732,
+ 4, 2, 13, 0.178250194, 0.418206781, 2.11632562,
+ 5, 2, 13, 0.178250194, 0.41158545, 2.57676744,
+ 6, 2, 13, 0.0563676581, 0.405409157, 3.03136396,
+ 7, 2, 13, 0.0563676581, 0.399695486, 3.47920918,
+ 8, 2, 13, 0.0563676581, 0.393753231, 3.91948748,
+ 9, 2, 12, 0.0178250186, 0.387357473, 4.35147953,
+ 10, 2, 12, 0.0178250186, 0.38045457, 4.77456427,
+ 11, 2, 10, 0.0178250186, 0.373053908, 5.18822002,
+ 12, 2, 10, 0.0178250186, 0.365188122, 5.59202194,
+ 13, 2, 10, 0.0178250186, 0.356897771, 5.98564005,
+ 14, 2, 9, 0.0178250186, 0.348700613, 6.36883163,
+ 15, 2, 9, 0.0178250186, 0.340260029, 6.74143791,
+ 16, 2, 6, 0.0178250186, 0.332341045, 7.10337448,
+ 17, 2, 6, 0.0178250186, 0.330462843, 7.45462418,
+ 18, 2, 6, 0.0178250186, 0.345568359, 7.79523182,
+ 19, 3, 3, 0.0267375279, 0.377859652, 8.20455742,
+ 20, 3, 3, 0.0267375279, 0.396689415, 8.67640114,
+ 21, 3, 3, 0.0267375279, 0.391237885, 9.12561035,
+ 22, 3, 3, 0.0267375279, 0.37761277, 9.55298138,
+ 23, 3, 3, 0.0267375279, 0.362836808, 9.95940971,
+ 24, 3, 0, 0.0267375279, 0.349010617, 10.3458519,
+ 25, 3, 0, 0.0267375279, 0.339673489, 10.7132998,
+ 26, 3, 0, 0.0267375279, 0.343845725, 11.0627575,
+ 27, 4, 0, 0.0356500372, 0.355822682, 11.447506,
+ 28, 4, 0, 0.0356500372, 0.358104348, 11.8627586,
+ 29, 4, 0, 0.0356500372, 0.34745428, 12.2520256,
+ 30, 4, 0, 0.0356500372, 0.334927917, 12.6173973,
+ 31, 4, 0, 0.0356500372, 0.331643254, 12.9608269,
+ 32, 5, 0, 0.0445625484, 0.333368897, 13.3219252,
+ 33, 5, 0, 0.0445625484, 0.332313001, 13.6976833,
+ 34, 5, 0, 0.0445625484, 0.3314417, 14.047802,
+ 35, 6, 0, 0.0534750558, 0.330947191, 14.405302,
+ 36, 6, 0, 0.0534750558, 0.332477689, 14.7684803,
+ 37, 7, 0, 0.062387567, 0.332647532, 15.1315956,
+ 38, 7, 0, 0.062387567, 0.330841452, 15.4940481,
+ 39, 8, 0, 0.0713000745, 0.327769846, 15.8516159,
+ 40, 8, 0, 0.0713000745, 0.324572712, 16.204628,
+ 41, 9, 0, 0.0802125856, 0.323825002, 16.5502281,
+ 42, 10, 0, 0.0891250968, 0.321414798, 16.9067478,
+ 43, 10, 0, 0.0891250968, 0.318189293, 17.2537231,
+ 44, 11, 0, 0.0980376005, 0.315934151, 17.5901108,
+ 45, 12, 0, 0.106950112, 0.315639287, 17.931406,
+ 46, 13, 0, 0.115862623, 0.316569835, 18.2750721,
+ 47, 14, 0, 0.124775134, 0.31656, 18.6191597,
+ 48, 15, 0, 0.133687645, 0.315465957, 18.9621754,
+ 49, 16, 0, 0.142600149, 0.313576341, 19.3029613,
+ 50, 17, 0, 0.151512653, 0.311635971, 19.6405869,
+ 51, 18, 0, 0.160425171, 0.311066717, 19.9742699,
+ 52, 20, 0, 0.355655879, 0.311465651, 20.3115921,
+ 53, 21, 0, 0.373438686, 0.311872005, 20.6507797,
+ 54, 23, 0, 0.409004271, 0.311015964, 20.9890823,
+ 55, 24, 0, 0.676411927, 0.309207708, 21.3251152,
+ 56, 26, 0, 0.732779562, 0.3081128, 21.6565971,
+ 57, 28, 0, 0.789147198, 0.310006589, 21.9881554,
+ 58, 31, 0, 2.76287794, 0.327113092, 22.3222847,
+ 59, 34, 0, 3.03025317, 0.416082352, 22.6605186,
  
-// See Table 3-C.7e, short blocks, MPEG-1
-// See Table D.3.e, short blocks, MPEG-2
-
-static const type2_t   table2_44100 [] = {
-    {  0,  1, 4.532, 1.000, 0.15,  0.000 }, // no, FFT-lines=width, quiet thr, norm, SNR(dB), bval (Bark)
-    {  1,  1, 0.904, 0.983, 0.15,  1.723 },
-    {  2,  1, 0.029, 0.983, 0.15,  3.445 },
-    {  3,  1, 0.009, 0.982, 0.15,  5.057 },
-    {  4,  1, 0.009, 0.985, 0.15,  6.422 },
-    {  5,  1, 0.009, 0.983, 0.15,  7.609 },
-    {  6,  1, 0.009, 0.978, 0.15,  8.710 },
-    {  7,  1, 0.009, 0.967, 0.15,  9.662 },
-    {  8,  1, 0.009, 0.948, 0.15, 10.515 },
-    {  9,  1, 0.009, 0.930, 0.15, 11.293 },
-    { 10,  1, 0.009, 0.914, 0.18, 12.009 },
-    { 11,  1, 0.009, 0.870, 0.18, 12.625 },
-    { 12,  1, 0.009, 0.845, 0.18, 13.210 },
-    { 13,  1, 0.009, 0.800, 0.18, 13.748 },
-    { 14,  1, 0.009, 0.749, 0.18, 14.241 },
-    { 15,  1, 0.009, 0.701, 0.18, 14.695 },
-    { 16,  1, 0.009, 0.653, 0.18, 15.125 },
-    { 17,  1, 0.009, 0.590, 0.18, 15.508 },
-    { 18,  1, 0.009, 0.616, 0.18, 15.891 },
-    { 19,  2, 0.018, 0.860, 0.18, 16.537 },
-    { 20,  2, 0.018, 0.823, 0.20, 17.112 },
-    { 21,  2, 0.018, 0.762, 0.20, 17.621 },
-    { 22,  2, 0.018, 0.688, 0.20, 18.073 },
-    { 23,  2, 0.018, 0.612, 0.20, 18.470 },
-    { 24,  2, 0.018, 0.594, 0.20, 18.849 },
-    { 25,  3, 0.027, 0.658, 0.20, 19.271 },
-    { 26,  3, 0.027, 0.706, 0.20, 19.741 },
-    { 27,  3, 0.054, 0.660, 0.20, 20.177 },
-    { 28,  3, 0.054, 0.606, 0.20, 20.576 },
-    { 29,  3, 0.054, 0.565, 0.20, 20.950 },
-    { 30,  4, 0.114, 0.560, 0.25, 21.316 },
-    { 31,  4, 0.114, 0.579, 0.25, 21.699 },
-    { 32,  5, 0.452, 0.567, 0.25, 22.078 },
-    { 33,  5, 0.452, 0.534, 0.25, 22.438 },
-    { 34,  5, 0.452, 0.514, 0.30, 22.782 },
-    { 35,  7, 6.330, 0.520, 0.30, 23.133 },
-    { 36,  7, 6.330, 0.518, 0.30, 23.484 },
-    { 37,  7, 6.330, 0.507, 0.30, 23.828 },
-    { 38, 19, 171.813, 0.447, 0.35, 24.173 },
-};
-
-// See Table 3-C.7f, short blocks, MPEG-1
-// See Table D.3.f, short blocks, MPEG-2
-
-static const type2_t   table2_32000 [] = {
-    {  0,  1, 4.532, 1.000, 0.15,  0.000 }, // no, FFT-lines=width, quiet thr, norm, SNR(dB), bval (Bark)
-    {  1,  1, 0.904, 0.985, 0.15,  1.250 },
-    {  2,  1, 0.090, 0.983, 0.15,  2.500 },
-    {  3,  1, 0.029, 0.983, 0.15,  3.750 },
-    {  4,  1, 0.009, 0.981, 0.15,  4.909 },
-    {  5,  1, 0.009, 0.975, 0.15,  5.958 },
-    {  6,  1, 0.009, 0.959, 0.15,  6.857 },
-    {  7,  1, 0.009, 0.944, 0.15,  7.700 },
-    {  8,  1, 0.009, 0.933, 0.15,  8.500 },
-    {  9,  1, 0.009, 0.920, 0.15,  9.237 },
-    { 10,  1, 0.009, 0.892, 0.18,  9.895 },
-    { 11,  1, 0.009, 0.863, 0.18, 10.500 },
-    { 12,  1, 0.009, 0.839, 0.18, 11.083 },
-    { 13,  1, 0.009, 0.786, 0.18, 11.604 },
-    { 14,  1, 0.009, 0.755, 0.18, 12.107 },
-    { 15,  1, 0.009, 0.698, 0.18, 12.554 },
-    { 16,  1, 0.009, 0.673, 0.18, 13.000 },
-    { 17,  1, 0.009, 0.605, 0.18, 13.391 },
-    { 18,  1, 0.009, 0.629, 0.18, 13.781 },
-    { 19,  2, 0.018, 0.883, 0.18, 14.474 },
-    { 20,  2, 0.018, 0.858, 0.20, 15.096 },
-    { 21,  2, 0.018, 0.829, 0.20, 15.667 },
-    { 22,  2, 0.018, 0.767, 0.20, 16.177 },
-    { 23,  2, 0.018, 0.705, 0.20, 16.636 },
-    { 24,  2, 0.018, 0.637, 0.20, 17.057 },
-    { 25,  2, 0.018, 0.564, 0.20, 17.429 },
-    { 26,  2, 0.018, 0.550, 0.20, 17.786 },
-    { 27,  3, 0.027, 0.603, 0.20, 18.177 },
-    { 28,  3, 0.027, 0.635, 0.20, 18.597 },
-    { 29,  3, 0.027, 0.592, 0.20, 18.994 },
-    { 30,  3, 0.027, 0.533, 0.25, 19.352 },
-    { 31,  3, 0.027, 0.518, 0.25, 19.693 },
-    { 32,  4, 0.072, 0.568, 0.25, 20.066 },
-    { 33,  4, 0.072, 0.594, 0.25, 20.462 },
-    { 34,  4, 0.072, 0.568, 0.30, 20.841 },
-    { 35,  5, 0.143, 0.536, 0.30, 21.201 },
-    { 36,  5, 0.143, 0.522, 0.30, 21.549 },
-    { 37,  6, 0.172, 0.542, 0.30, 21.911 },
-    { 38,  7, 0.633, 0.539, 0.35, 22.275 },
-    { 39,  7, 0.633, 0.519, 0.35, 22.625 },
-    { 40,  8, 0.723, 0.514, 0.40, 22.971 },
-    { 41, 10, 9.043, 0.518, 0.40, 23.321 },
-};
+ 22050, 59,
+ 0, 2, 15, 17.8250179, 0.658683598, 0.217637643,
+ 1, 2, 15, 17.8250179, 0.432554901, 0.652563453,
+ 2, 2, 15, 1.78250182, 0.405113578, 1.08633137,
+ 3, 2, 15, 1.78250182, 0.397231787, 1.51803517,
+ 4, 2, 15, 1.78250182, 0.392088681, 1.94679713,
+ 5, 2, 13, 0.178250194, 0.386788279, 2.37177849,
+ 6, 2, 13, 0.178250194, 0.380574644, 2.79218864,
+ 7, 2, 13, 0.0563676581, 0.375309765, 3.20729256,
+ 8, 2, 13, 0.0563676581, 0.370087624, 3.61641645,
+ 9, 2, 12, 0.0178250186, 0.364568561, 4.01895428,
+ 10, 2, 12, 0.0178250186, 0.358959526, 4.4143672,
+ 11, 2, 12, 0.0178250186, 0.352938265, 4.80218887,
+ 12, 2, 10, 0.0178250186, 0.3465029, 5.18202305,
+ 13, 2, 10, 0.0178250186, 0.33968094, 5.55354261,
+ 14, 2, 10, 0.0178250186, 0.332571507, 5.91648674,
+ 15, 2, 9, 0.0178250186, 0.326015651, 6.27065945,
+ 16, 2, 9, 0.0178250186, 0.325442046, 6.61592293,
+ 17, 2, 9, 0.0178250186, 0.341315031, 6.95219517,
+ 18, 3, 6, 0.0267375279, 0.374984443, 7.3584404,
+ 19, 3, 6, 0.0267375279, 0.396138102, 7.8290925,
+ 20, 3, 3, 0.0267375279, 0.39271906, 8.27975655,
+ 21, 3, 3, 0.0267375279, 0.380755007, 8.71083069,
+ 22, 3, 3, 0.0267375279, 0.367386311, 9.12284088,
+ 23, 3, 3, 0.0267375279, 0.354351997, 9.51640987,
+ 24, 3, 3, 0.0267375279, 0.341508389, 9.89222908,
+ 25, 3, 0, 0.0267375279, 0.333577901, 10.2510386,
+ 26, 3, 0, 0.0267375279, 0.338108748, 10.5936022,
+ 27, 4, 0, 0.0356500372, 0.350744486, 10.9723492,
+ 28, 4, 0, 0.0356500372, 0.354519457, 11.38272,
+ 29, 4, 0, 0.0356500372, 0.345274031, 11.7689981,
+ 30, 4, 0, 0.0356500372, 0.333828837, 12.1329184,
+ 31, 4, 0, 0.0356500372, 0.331436664, 12.4761295,
+ 32, 5, 0, 0.0445625484, 0.334172577, 12.8381901,
+ 33, 5, 0, 0.0445625484, 0.334024847, 13.2160273,
+ 34, 5, 0, 0.0445625484, 0.33392629, 13.5690479,
+ 35, 6, 0, 0.0534750558, 0.334218502, 13.9303951,
+ 36, 6, 0, 0.0534750558, 0.336405039, 14.298193,
+ 37, 7, 0, 0.062387567, 0.337080389, 14.666563,
+ 38, 7, 0, 0.062387567, 0.335603535, 15.0346909,
+ 39, 8, 0, 0.0713000745, 0.332515866, 15.398139,
+ 40, 8, 0, 0.0713000745, 0.327727586, 15.7570457,
+ 41, 9, 0, 0.0802125856, 0.322346836, 16.1083431,
+ 42, 9, 0, 0.0802125856, 0.317575186, 16.4528522,
+ 43, 10, 0, 0.0891250968, 0.31632933, 16.7886105,
+ 44, 11, 0, 0.0980376005, 0.317602783, 17.132,
+ 45, 12, 0, 0.106950112, 0.319945186, 17.4796028,
+ 46, 13, 0, 0.115862623, 0.320881754, 17.8287659,
+ 47, 14, 0, 0.124775134, 0.320346534, 18.1774921,
+ 48, 15, 0, 0.133687645, 0.318628669, 18.5243168,
+ 49, 16, 0, 0.142600149, 0.316125751, 18.8681736,
+ 50, 17, 0, 0.151512653, 0.313746184, 19.2082729,
+ 51, 18, 0, 0.160425171, 0.312971771, 19.5440025,
+ 52, 20, 0, 0.178250194, 0.313278913, 19.8831882,
+ 53, 21, 0, 0.373438686, 0.313735574, 20.224247,
+ 54, 23, 0, 0.409004271, 0.31308493, 20.5646286,
+ 55, 24, 0, 0.426787049, 0.31156227, 20.903141,
+ 56, 26, 0, 0.732779562, 0.310435742, 21.2376747,
+ 57, 28, 0, 0.789147198, 0.31132248, 21.5730591,
+ 58, 30, 0, 0.845514894, 0.32730341, 21.9066811,
+ 59, 33, 0, 2.94112802, 0.414659739, 22.2411156,
  
-// Taken from 'dist10/lsf/encoder/tables/psy_data'
+ 16000, 55,
+ 0, 3, 15, 26.7375278, 0.697374165, 0.236874461,
+ 1, 3, 15, 26.7375278, 0.455024809, 0.71016103,
+ 2, 3, 15, 2.67375278, 0.431440443, 1.18193281,
+ 3, 3, 15, 2.67375278, 0.42391625, 1.65102732,
+ 4, 3, 13, 0.26737529, 0.418206781, 2.11632562,
+ 5, 3, 13, 0.26737529, 0.41158545, 2.57676744,
+ 6, 3, 13, 0.0845514908, 0.405409157, 3.03136396,
+ 7, 3, 13, 0.0845514908, 0.399695486, 3.47920918,
+ 8, 3, 13, 0.0845514908, 0.393753231, 3.91948748,
+ 9, 3, 12, 0.0267375279, 0.387357473, 4.35147953,
+ 10, 3, 12, 0.0267375279, 0.38045457, 4.77456427,
+ 11, 3, 10, 0.0267375279, 0.373053908, 5.18822002,
+ 12, 3, 10, 0.0267375279, 0.365188122, 5.59202194,
+ 13, 3, 10, 0.0267375279, 0.356897742, 5.98564005,
+ 14, 3, 9, 0.0267375279, 0.34869957, 6.36883163,
+ 15, 3, 9, 0.0267375279, 0.340241522, 6.74143791,
+ 16, 3, 6, 0.0267375279, 0.332089454, 7.10337448,
+ 17, 3, 6, 0.0267375279, 0.328292668, 7.45462418,
+ 18, 3, 6, 0.0267375279, 0.336574793, 7.79523182,
+ 19, 4, 3, 0.0356500372, 0.354600489, 8.17827797,
+ 20, 4, 3, 0.0356500372, 0.364343345, 8.59994984,
+ 21, 4, 3, 0.0356500372, 0.359369367, 9.00363636,
+ 22, 4, 3, 0.0356500372, 0.347775847, 9.38988018,
+ 23, 4, 3, 0.0356500372, 0.335562587, 9.7592926,
+ 24, 4, 0, 0.0356500372, 0.326988578, 10.1125278,
+ 25, 4, 0, 0.0356500372, 0.327966213, 10.4502735,
+ 26, 5, 0, 0.0445625484, 0.334450752, 10.811614,
+ 27, 5, 0, 0.0445625484, 0.335228145, 11.1935263,
+ 28, 5, 0, 0.0445625484, 0.329595625, 11.5549288,
+ 29, 5, 0, 0.0445625484, 0.326683223, 11.8971443,
+ 30, 6, 0, 0.0534750558, 0.326986551, 12.2520256,
+ 31, 6, 0, 0.0534750558, 0.325072199, 12.6173973,
+ 32, 6, 0, 0.0534750558, 0.323560268, 12.9608269,
+ 33, 7, 0, 0.062387567, 0.322494298, 13.3093863,
+ 34, 7, 0, 0.062387567, 0.323403448, 13.6617231,
+ 35, 8, 0, 0.0713000745, 0.323232353, 14.0134668,
+ 36, 8, 0, 0.0713000745, 0.322662383, 14.3639784,
+ 37, 9, 0, 0.0802125856, 0.324054241, 14.7098465,
+ 38, 10, 0, 0.0891250968, 0.323228806, 15.0686541,
+ 39, 10, 0, 0.0891250968, 0.320751846, 15.4191036,
+ 40, 11, 0, 0.0980376005, 0.318823338, 15.7594051,
+ 41, 12, 0, 0.106950112, 0.318418682, 16.104557,
+ 42, 13, 0, 0.115862623, 0.318762124, 16.451416,
+ 43, 14, 0, 0.124775134, 0.317806393, 16.7975388,
+ 44, 15, 0, 0.133687645, 0.315653771, 17.1411018,
+ 45, 16, 0, 0.142600149, 0.313369036, 17.4808159,
+ 46, 17, 0, 0.151512653, 0.312513858, 17.8158207,
+ 47, 19, 0, 0.169337675, 0.312785119, 18.1543369,
+ 48, 20, 0, 0.178250194, 0.31343773, 18.4948578,
+ 49, 22, 0, 0.196075201, 0.313258767, 18.8350143,
+ 50, 23, 0, 0.20498772, 0.312570423, 19.1740704,
+ 51, 25, 0, 0.222812727, 0.312572777, 19.5104179,
+ 52, 27, 0, 0.240637749, 0.313047856, 19.8497677,
+ 53, 29, 0, 0.515701056, 0.315029174, 20.1900635,
+ 54, 31, 0, 0.551266611, 0.330613613, 20.5294952,
+ 55, 33, 0, 0.586832225, 0.41819948, 20.8664398,
  
-static const type2_t   table2_24000 [] = {
-    {  0,  1, 8.91250896, 0.971850038, 0.15, 0 }, // no, FFT-lines=width, quiet thr, norm, SNR(dB), bval (Bark)
-    {  1,  1, 8.91250896, 0.874727964, 0.15, 0.946573138 },
-    {  2,  1, 0.891250908, 0.85779953, 0.15, 1.88476217 },
-    {  3,  1, 0.0891250968, 0.839743853, 0.15, 2.8056457 },
-    {  4,  1, 0.028183829, 0.82260257, 0.15, 3.70133615 },
-    {  5,  1, 0.00891250931, 0.80018574, 0.15, 4.56532001 },
-    {  6,  1, 0.00891250931, 0.771475196, 0.15, 5.39263105 },
-    {  7,  1, 0.00891250931, 0.737389982, 0.15, 6.17986727 },
-    {  8,  1, 0.00891250931, 0.701111019, 0.15, 6.92507982 },
-    {  9,  1, 0.00891250931, 0.65977633, 0.15, 7.62757969 },
-    { 10,  1, 0.00891250931, 0.615037441, 0.15, 8.28770351 },
-    { 11,  1, 0.00891250931, 0.568658054, 0.15, 8.90657234 },
-    { 12,  1, 0.00891250931, 0.522260666, 0.18, 9.48587132 },
-    { 13,  1, 0.00891250931, 0.478903115, 0.18, 10.0276566 },
-    { 14,  1, 0.00891250931, 0.43808648, 0.18, 10.5341988 },
-    { 15,  1, 0.00891250931, 0.412505627, 0.18, 11.0078659 },
-    { 16,  1, 0.00891250931, 0.39070797, 0.18, 11.4510288 },
-    { 17,  1, 0.00891250931, 0.371887118, 0.18, 11.866004 },
-    { 18,  1, 0.00891250931, 0.367617637, 0.18, 12.2550087 },
-    { 19,  1, 0.00891250931, 0.422220588, 0.18, 12.6201363 },
-    { 20,  2, 0.0178250186, 0.564990044, 0.18, 13.2772083 },
-    { 21,  2, 0.0178250186, 0.519700944, 0.18, 13.871047 },
-    { 22,  2, 0.0178250186, 0.455360681, 0.20, 14.4024391 },
-    { 23,  2, 0.0178250186, 0.408867925, 0.20, 14.8811684 },
-    { 24,  2, 0.0178250186, 0.381538749, 0.20, 15.3153324 },
-    { 25,  2, 0.0178250186, 0.362357527, 0.20, 15.7116165 },
-    { 26,  2, 0.0178250186, 0.365735918, 0.20, 16.0755405 },
-    { 27,  3, 0.0267375279, 0.38064, 0.20, 16.4882088 },
-    { 28,  3, 0.0267375279, 0.379183382, 0.20, 16.9410992 },
-    { 29,  3, 0.0267375279, 0.360672712, 0.20, 17.3513336 },
-    { 30,  3, 0.0267375279, 0.343065977, 0.20, 17.7264423 },
-    { 31,  3, 0.0267375279, 0.339290261, 0.20, 18.0722466 },
-    { 32,  4, 0.0356500372, 0.342963994, 0.20, 18.4426575 },
-    { 33,  4, 0.0356500372, 0.343128443, 0.20, 18.8344078 },
-    { 34,  4, 0.0356500372, 0.343988508, 0.25, 19.1955795 },
-    { 35,  5, 0.0445625484, 0.343928397, 0.25, 19.5697021 },
-    { 36,  5, 0.0445625484, 0.339527696, 0.25, 19.9551182 },
-    { 37,  5, 0.0889139697, 0.336541563, 0.28, 20.3115921 },
-    { 38,  6, 0.106696762, 0.334955156, 0.28, 20.6737747 },
-    { 39,  6, 0.169102982, 0.335601568, 0.30, 21.0404968 },
-    { 40,  7, 0.1972868, 0.334716886, 0.30, 21.4060211 },
-    { 41,  7, 0.1972868, 0.331676662, 0.30, 21.7696877 },
-    { 42,  8, 0.713000774, 0.328550965, 0.40, 22.1267223 },
-    { 43,  8, 0.713000774, 0.339241952, 0.40, 22.4769249 },
-    { 44,  9, 0.802125871, 0.425207615, 0.40, 22.8164864 },
-};
+ 48000.0, 37,
+ 0, 1, 4.532, 1.000, -8.240, 0.000,
+ 1, 1, 0.904, 0.989, -8.240, 1.875,
+ 2, 1, 0.029, 0.989, -8.240, 3.750,
+ 3, 1, 0.009, 0.981, -8.240, 5.438,
+ 4, 1, 0.009, 0.985, -8.240, 6.857,
+ 5, 1, 0.009, 0.984, -8.240, 8.109,
+ 6, 1, 0.009, 0.980, -8.240, 9.237,
+ 7, 1, 0.009, 0.968, -8.240, 10.202,
+ 8, 1, 0.009, 0.954, -8.240, 11.083,
+ 9, 1, 0.009, 0.929, -8.240, 11.865,
+ 10, 1, 0.009, 0.906, -7.447, 12.554,
+ 11, 1, 0.009, 0.883, -7.447, 13.195,
+ 12, 1, 0.009, 0.844, -7.447, 13.781,
+ 13, 1, 0.009, 0.792, -7.447, 14.309,
+ 14, 1, 0.009, 0.747, -7.447, 14.803,
+ 15, 1, 0.009, 0.689, -7.447, 15.250,
+ 16, 1, 0.009, 0.644, -7.447, 15.667,
+ 17, 1, 0.009, 0.592, -7.447, 16.068,
+ 18, 1, 0.009, 0.553, -7.447, 16.409,
+ 19, 2, 0.018, 0.850, -7.447, 17.045,
+ 20, 2, 0.018, 0.811, -6.990, 17.607,
+ 21, 2, 0.018, 0.736, -6.990, 18.097,
+ 22, 2, 0.018, 0.665, -6.990, 18.528,
+ 23, 2, 0.018, 0.610, -6.990, 18.931,
+ 24, 2, 0.018, 0.544, -6.990, 19.295,
+ 25, 2, 0.018, 0.528, -6.990, 19.636,
+ 26, 3, 0.054, 0.621, -6.990, 20.038,
+ 27, 3, 0.054, 0.673, -6.990, 20.486,
+ 28, 3, 0.054, 0.635, -6.990, 20.900,
+ 29, 4, 0.114, 0.626, -6.990, 21.306,
+ 30, 4, 0.114, 0.636, -6.020, 21.722,
+ 31, 5, 0.452, 0.615, -6.020, 22.128,
+ 32, 5, 0.452, 0.579, -6.020, 22.513,
+ 33, 5, 0.452, 0.551, -6.020, 22.877,
+ 34, 7, 6.330, 0.552, -5.229, 23.241,
+ 35, 7, 6.330, 0.559, -5.229, 23.616,
+ 36, 11, 9.947, 0.528, -5.229, 23.974,
+ 37, 17, 153.727, 0.479, -5.229, 24.313,
  
-// Taken from 'dist10/lsf/encoder/tables/psy_data'
-  
-static const type2_t   table2_22050 [] = {
-    {  0,  1, 8.91250896, 0.954045713, 0.15, 0 }, // no, FFT-lines=width, quiet thr, norm, SNR(dB), bval (Bark)
-    {  1,  1, 8.91250896, 0.833381653, 0.15, 0.869851649 },
-    {  2,  1, 0.891250908, 0.815945923, 0.15, 1.73325908 },
-    {  3,  1, 0.0891250968, 0.794244766, 0.15, 2.58322191 },
-    {  4,  1, 0.028183829, 0.776486695, 0.15, 3.4134295 },
-    {  5,  1, 0.00891250931, 0.755260408, 0.15, 4.21850443 },
-    {  6,  1, 0.00891250931, 0.731070817, 0.15, 4.99414825 },
-    {  7,  1, 0.00891250931, 0.701775849, 0.15, 5.73718691 },
-    {  8,  1, 0.00891250931, 0.667876124, 0.15, 6.44553185 },
-    {  9,  1, 0.00891250931, 0.630284071, 0.15, 7.11807632 },
-    { 10,  1, 0.00891250931, 0.590170324, 0.15, 7.75455618 },
-    { 11,  1, 0.00891250931, 0.548788548, 0.15, 8.3553915 },
-    { 12,  1, 0.00891250931, 0.507795513, 0.15, 8.92152882 },
-    { 13,  1, 0.00891250931, 0.469515711, 0.18, 9.45430183 },
-    { 14,  1, 0.00891250931, 0.432291716, 0.18, 9.95530319 },
-    { 15,  1, 0.00891250931, 0.411131173, 0.18, 10.4262848 },
-    { 16,  1, 0.00891250931, 0.390771538, 0.18, 10.8690758 },
-    { 17,  1, 0.00891250931, 0.373318017, 0.18, 11.2855215 },
-    { 18,  1, 0.00891250931, 0.36956048, 0.18, 11.6774378 },
-    { 19,  1, 0.00891250931, 0.42595759, 0.18, 12.0465794 },
-    { 20,  2, 0.0178250186, 0.576900065, 0.18, 12.7141209 },
-    { 21,  2, 0.0178250186, 0.533114731, 0.18, 13.3197365 },
-    { 22,  2, 0.0178250186, 0.469967514, 0.18, 13.8634901 },
-    { 23,  2, 0.0178250186, 0.417268544, 0.20, 14.3544445 },
-    { 24,  2, 0.0178250186, 0.389299124, 0.20, 14.8002586 },
-    { 25,  2, 0.0178250186, 0.362824857, 0.20, 15.2073727 },
-    { 26,  2, 0.0178250186, 0.346801281, 0.20, 15.5811834 },
-    { 27,  2, 0.0178250186, 0.349400043, 0.20, 15.926218 },
-    { 28,  3, 0.0267375279, 0.364026934, 0.20, 16.3194923 },
-    { 29,  3, 0.0267375279, 0.36560446, 0.20, 16.752903 },
-    { 30,  3, 0.0267375279, 0.354275256, 0.20, 17.1470814 },
-    { 31,  3, 0.0267375279, 0.351219416, 0.20, 17.5086212 },
-    { 32,  4, 0.0356500372, 0.354364097, 0.20, 17.8938141 },
-    { 33,  4, 0.0356500372, 0.348915905, 0.20, 18.2992878 },
-    { 34,  4, 0.0356500372, 0.337649345, 0.20, 18.6713982 },
-    { 35,  4, 0.0356500372, 0.332076877, 0.25, 19.015646 },
-    { 36,  5, 0.0445625484, 0.330793113, 0.25, 19.3734016 },
-    { 37,  5, 0.0445625484, 0.327528268, 0.25, 19.7430382 },
-    { 38,  5, 0.0889139697, 0.32551071, 0.28, 20.0859604 },
-    { 39,  6, 0.106696762, 0.324436843, 0.28, 20.4354992 },
-    { 40,  6, 0.106696762, 0.325835049, 0.28, 20.7905579 },
-    { 41,  7, 0.1972868, 0.326221824, 0.30, 21.1458054 },
-    { 42,  7, 0.1972868, 0.325960994, 0.30, 21.5005951 },
-    { 43,  8, 0.225470632, 0.339019388, 0.30, 21.8504524 },
-    { 44,  8, 0.713000774, 0.426850349, 0.40, 22.1951065 },
-};
-
-// Taken from 'dist10/lsf/encoder/tables/psy_data'
-
-static const type2_t   table2_16000 [] = {
-    {  0,  1, 8.91250896, 0.834739447, 0.15, 0 }, // no, FFT-lines=width, quiet thr, norm, SNR(dB), bval (Bark)
-    {  1,  1, 8.91250896, 0.623757005, 0.15, 0.631518543 },
-    {  2,  1, 0.891250908, 0.60420388, 0.15, 1.2606914 },
-    {  3,  1, 0.891250908, 0.591974258, 0.15, 1.88476217 },
-    {  4,  1, 0.0891250968, 0.575301588, 0.15, 2.50111985 },
-    {  5,  1, 0.028183829, 0.561547697, 0.15, 3.1073606 },
-    {  6,  1, 0.028183829, 0.546665847, 0.15, 3.70133615 },
-    {  7,  1, 0.00891250931, 0.52986443, 0.15, 4.28118753 },
-    {  8,  1, 0.00891250931, 0.511183441, 0.15, 4.84536505 },
-    {  9,  1, 0.00891250931, 0.490902334, 0.15, 5.39263105 },
-    { 10,  1, 0.00891250931, 0.46938166, 0.15, 5.92205667 },
-    { 11,  1, 0.00891250931, 0.447003782, 0.15, 6.43299866 },
-    { 12,  1, 0.00891250931, 0.428170592, 0.15, 6.92507982 },
-    { 13,  1, 0.00891250931, 0.414536625, 0.15, 7.39815664 },
-    { 14,  1, 0.00891250931, 0.401033074, 0.15, 7.85228777 },
-    { 15,  1, 0.00891250931, 0.38779071, 0.15, 8.28770351 },
-    { 16,  1, 0.00891250931, 0.374230444, 0.15, 8.704772 },
-    { 17,  1, 0.00891250931, 0.360547513, 0.18, 9.10397339 },
-    { 18,  1, 0.00891250931, 0.348256677, 0.18, 9.48587132 },
-    { 19,  1, 0.00891250931, 0.350327015, 0.18, 9.85109234 },
-    { 20,  1, 0.00891250931, 0.406330824, 0.18, 10.200304 },
-    { 21,  2, 0.0178250186, 0.554098248, 0.18, 10.846529 },
-    { 22,  2, 0.0178250186, 0.528312504, 0.18, 11.4447651 },
-    { 23,  2, 0.0178250186, 0.476527005, 0.18, 11.9928398 },
-    { 24,  2, 0.0178250186, 0.428205669, 0.18, 12.495945 },
-    { 25,  2, 0.0178250186, 0.402271926, 0.18, 12.9588718 },
-    { 26,  2, 0.0178250186, 0.378024429, 0.18, 13.3859692 },
-    { 27,  2, 0.0178250186, 0.36254698, 0.18, 13.7811394 },
-    { 28,  2, 0.0178250186, 0.368058592, 0.20, 14.1478529 },
-    { 29,  3, 0.0267375279, 0.385963261, 0.20, 14.5674343 },
-    { 30,  3, 0.0267375279, 0.38640517, 0.20, 15.0304852 },
-    { 31,  3, 0.0267375279, 0.367834061, 0.20, 15.4513416 },
-    { 32,  3, 0.0267375279, 0.349686563, 0.20, 15.836277 },
-    { 33,  3, 0.0267375279, 0.345709383, 0.20, 16.1904697 },
-    { 34,  4, 0.0356500372, 0.34871915, 0.20, 16.5683517 },
-    { 35,  4, 0.0356500372, 0.347054332, 0.20, 16.9660263 },
-    { 36,  4, 0.0356500372, 0.346329987, 0.20, 17.3304482 },
-    { 37,  5, 0.0445625484, 0.344658494, 0.20, 17.7055588 },
-    { 38,  5, 0.0445625484, 0.338779271, 0.20, 18.0899811 },
-    { 39,  5, 0.0445625484, 0.334878683, 0.20, 18.4440536 },
-    { 40,  6, 0.0534750558, 0.332811534, 0.20, 18.8030052 },
-    { 41,  6, 0.0534750558, 0.333717585, 0.25, 19.1665268 },
-    { 42,  7, 0.062387567, 0.333986402, 0.25, 19.5299358 },
-    { 43,  7, 0.062387567, 0.334142625, 0.25, 19.8934898 },
-    { 44,  8, 0.142262354, 0.34677428, 0.28, 20.2535706 },
-    { 45,  8, 0.142262354, 0.436254472, 0.28, 20.610569 },
-};
-
-//
-// Tables for converting threshold calculation partitions 
-// to scalefactor bands 
-//
-
-// See Table 3-C.8a, long blocks, MPEG-1
-// See Table D.4.a, long blocks, MPEG-2
-
-static const type34_t  table3_48000 [] = {
-/* sb cbw bu  bo   w1   w2  (w1+w2 multiplied by 576) */
-    {    0, 3,  0,  4, 576,  32 },
-    {    1, 3,  4,  7, 544, 352 },
-    {    2, 4,  7, 11, 224,  96 },
-    {    3, 3, 11, 14, 480, 416 },
-    {    4, 3, 14, 17, 160, 368 },
-    {    5, 2, 17, 19, 208, 240 },
-    {    6, 3, 19, 22, 336,  48 },
-    {    7, 2, 22, 24, 528, 432 },
-    {    8, 3, 24, 27, 144, 240 },
-    {    9, 3, 27, 30, 336, 373 },
-    {   10, 3, 30, 33, 203, 352 },
-    {   11, 3, 33, 36, 224, 360 },
-    {   12, 4, 36, 40, 216,  83 },
-    {   13, 3, 40, 43, 493, 224 },
-    {   14, 3, 43, 46, 352,  92 },
-    {   15, 3, 46, 49, 484, 125 },
-    {   16, 3, 49, 52, 451, 106 },
-    {   17, 2, 52, 54, 470, 510 },
-    {   18, 3, 54, 57,  66, 180 },
-    {   19, 2, 57, 59, 396, 260 },
-    {   20, 1, 59, 60, 316, 523 },
-};
-
-// See Table 3-C.8b, long blocks, MPEG-1
-// See Table D.4.b, long blocks, MPEG-2
-
-static const type34_t  table3_44100 [] = {
-/* sb cbw bu  bo   w1   w2  (w1+w2 multiplied by 576) */
-    {    0, 3,  0,  4, 576,  32 },
-    {    1, 3,  4,  7, 544, 352 },
-    {    2, 4,  7, 11, 224,  96 },
-    {    3, 3, 11, 14, 480, 416 },
-    {    4, 3, 14, 17, 160,  80 },
-    {    5, 1, 17, 18, 496, 528 },
-    {    6, 3, 18, 21,  48, 336 },
-    {    7, 3, 21, 24, 240, 144 },
-    {    8, 3, 24, 27, 432, 464 },
-    {    9, 3, 27, 30, 112, 331 },
-    {   10, 3, 30, 33, 245, 309 },
-    {   11, 3, 33, 36, 267, 472 },
-    {   12, 4, 36, 40, 104,  58 },
-    {   13, 3, 40, 43, 518, 270 },
-    {   14, 3, 43, 46, 306, 359 },
-    {   15, 3, 46, 49, 217, 259 },
-    {   16, 3, 49, 52, 317, 318 },
-    {   17, 3, 52, 55, 258, 232 },
-    {   18, 2, 55, 57, 344, 370 },
-    {   19, 2, 57, 59, 206, 416 },
-    {   20, 2, 59, 61, 160, 553 },
-};
-
-// See Table 3-C.8c, long blocks, MPEG-1
-// See Table D.4.c, long blocks, MPEG-2
-
-static const type34_t  table3_32000 [] = {
-/* sb cbw bu  bo   w1   w2  (w1+w2 multiplied by 576) */
-    {    0, 1,  0,  2, 576, 304 },
-    {    1, 2,  2,  4, 272, 176 },
-    {    2, 2,  4,  6, 400,  48 },
-    {    3, 1,  6,  7, 528, 496 },
-    {    4, 2,  7,  9,  80, 368 },
-    {    5, 2,  9, 11, 208, 240 },
-    {    6, 3, 11, 14, 336,  48 },
-    {    7, 2, 14, 16, 528, 432 },
-    {    8, 3, 16, 19, 144, 501 },
-    {    9, 3, 19, 22,  75, 480 },
-    {   10, 4, 22, 26,  96, 224 },
-    {   11, 4, 26, 30, 352, 275 },
-    {   12, 4, 30, 34, 301,  19 },
-    {   13, 3, 34, 37, 557, 528 },
-    {   14, 4, 37, 41,  48, 355 },
-    {   15, 3, 41, 44, 221, 573 },
-    {   16, 4, 44, 48,   3, 158 },
-    {   17, 3, 48, 51, 418, 277 },
-    {   18, 3, 51, 54, 299, 150 },
-    {   19, 2, 54, 56, 426, 509 },
-    {   20, 2, 56, 58,  67, 576 },
-};
-
-// Tables in FhG docu are copy&paste from MPEG-1 and 
-// are fully wrong, don't trust in this snafu
-
-static const type34_t  table3_24000 [] = {
-/* sb cbw bu  bo   w1   w2  (w1+w2 multiplied by 576) */
-    {    0, 2,  0,  3, 576, 528 },
-    {    1, 3,  3,  6,  48, 336 },
-    {    2, 3,  6,  9, 240, 144 },
-    {    3, 2,  9, 11, 432, 528 },
-    {    4, 3, 11, 14,  48, 336 },
-    {    5, 3, 14, 17, 240, 144 },
-    {    6, 3, 17, 20, 432, 309 },
-    {    7, 3, 20, 23, 267, 288 },
-    {    8, 4, 23, 27, 288,  32 },
-    {    9, 3, 27, 30, 544, 232 },
-    {   10, 3, 30, 33, 344, 442 },
-    {   11, 3, 33, 36, 134, 464 },
-    {   12, 3, 36, 39, 112, 443 },
-    {   13, 3, 39, 42, 133, 352 },
-    {   14, 3, 42, 45, 224, 259 },
-    {   15, 3, 45, 48, 317, 112 },
-    {   16, 2, 48, 50, 464, 526 },
-    {   17, 3, 50, 53,  50, 334 },
-    {   18, 3, 53, 56, 242,  65 },
-    {   19, 2, 56, 58, 511, 307 },
-    {   20, 2, 58, 60, 269, 398 },
-};
-
-// Tables in FhG docu are copy&paste from MPEG-1 and 
-// are fully wrong, don't trust in this snafu
-
-static const type34_t  table3_22050 [] = {
-/* sb cbw bu  bo   w1   w2  (w1+w2 multiplied by 576) */
-    {    0, 2,  0,  3, 576, 528 },
-    {    1, 3,  3,  6,  48, 336 },
-    {    2, 3,  6,  9, 240, 144 },
-    {    3, 2,  9, 11, 432, 528 },
-    {    4, 3, 11, 14,  48, 336 },
-    {    5, 3, 14, 17, 240, 144 },
-    {    6, 3, 17, 20, 432, 117 },
-    {    7, 3, 20, 23, 459,  96 },
-    {    8, 3, 23, 26, 480, 416 },
-    {    9, 4, 26, 30, 160,  88 },
-    {   10, 3, 30, 33, 488, 326 },
-    {   11, 3, 33, 36, 250, 539 },
-    {   12, 4, 36, 40,  37,  68 },
-    {   13, 3, 40, 43, 508,  53 },
-    {   14, 2, 43, 45, 523, 538 },
-    {   15, 3, 45, 48,  38, 331 },
-    {   16, 3, 48, 51, 245, 134 },
-    {   17, 2, 51, 53, 442, 437 },
-    {   18, 3, 53, 56, 139, 108 },
-    {   19, 2, 56, 58, 468, 307 },
-    {   20, 2, 58, 60, 269, 148 },
-};
-
-// Tables in FhG docu are copy&paste from MPEG-1 and 
-// are fully wrong, don't trust in this snafu
-
-static const type34_t  table3_16000 [] = {
-/* sb cbw bu  bo   w1   w2  (w1+w2 multiplied by 576) */
-    {    0, 1,  0,  2, 576, 544 },
-    {    1, 2,  2,  4,  32, 416 },
-    {    2, 2,  4,  6, 160, 288 },
-    {    3, 2,  6,  8, 288, 160 },
-    {    4, 2,  8, 10, 416,  32 },
-    {    5, 1, 10, 11, 544, 480 },
-    {    6, 3, 11, 14,  96, 117 },
-    {    7, 3, 14, 17, 459,  96 },
-    {    8, 3, 17, 20, 480, 312 },
-    {    9, 3, 20, 23, 264, 376 },
-    {   10, 4, 23, 27, 200,  96 },
-    {   11, 3, 27, 30, 480, 416 },
-    {   12, 4, 30, 34, 160, 160 },
-    {   13, 3, 34, 37, 416, 348 },
-    {   14, 3, 37, 40, 228, 362 },
-    {   15, 3, 40, 43, 214, 313 },
-    {   16, 3, 43, 46, 263, 214 },
-    {   17, 3, 46, 49, 362,   5 },
-    {   18, 2, 49, 51, 571, 288 },
-    {   19, 2, 51, 53, 288, 511 },
-    {   20, 2, 53, 55,  65, 362 },
-};
-
-// See Table 3-C.8d, short blocks, MPEG-1
-// See Table D.4.d, short blocks, MPEG-2
-
-static const type34_t  table4_48000 [] = {
-/* sb cbw bu  bo   w1   w2  (w1+w2 multiplied by 576) */
-    {    0, 2,  0,  3, 576,  96 },
-    {    1, 2,  3,  5, 480, 480 },
-    {    2, 3,  5,  8,  96, 288 },
-    {    3, 3,  8, 11, 288,  96 },
-    {    4, 4, 11, 15, 480,  96 },
-    {    5, 4, 15, 19, 480, 336 },
-    {    6, 3, 19, 22, 240, 528 },
-    {    7, 4, 22, 26,  48, 544 },
-    {    8, 4, 26, 30,  32,  24 },
-    {    9, 2, 30, 32, 552, 327 },
-    {   10, 3, 32, 35, 249,  96 },
-    {   11, 2, 35, 37, 480, 356 },
-};
-// See Table 3-C.8e, short blocks, MPEG-1
-// See Table D.4.e, short blocks, MPEG-2
-
-static const type34_t  table4_44100 [] = {
-/* sb cbw bu  bo   w1   w2  (w1+w2 multiplied by 576) */
-    {    0, 2,  0,  3, 576,  96 },
-    {    1, 2,  3,  5, 480, 480 },
-    {    2, 3,  5,  8,  96, 288 },
-    {    3, 3,  8, 11, 288,  96 },
-    {    4, 4, 11, 15, 480,  96 },
-    {    5, 5, 15, 20, 480, 144 },
-    {    6, 3, 20, 23, 432, 336 },
-    {    7, 4, 23, 27, 240,  32 },
-    {    8, 3, 27, 30, 544, 216 },
-    {    9, 3, 30, 33, 360, 173 },
-    {   10, 3, 33, 36, 403,  96 },
-    {   11, 2, 36, 38, 480, 576 },
-};
-// See Table 3-C.8f, short blocks, MPEG-1
-// See Table D.4.f, short blocks, MPEG-2
-
-static const type34_t  table4_32000 [] = {
-/* sb cbw bu  bo   w1   w2  (w1+w2 multiplied by 576) */
-    {    0, 2,  0,  3, 576,  96 },
-    {    1, 2,  3,  5, 480, 480 },
-    {    2, 3,  5,  8,  96, 288 },
-    {    3, 3,  8, 11, 288,  96 },
-    {    4, 4, 11, 15, 480,  96 },
-    {    5, 5, 15, 20, 480, 144 },
-    {    6, 4, 20, 24, 432, 144 },
-    {    7, 5, 24, 29, 432,  32 },
-    {    8, 4, 29, 33, 544, 216 },
-    {    9, 4, 33, 37, 360, 272 },
-    {   10, 3, 37, 40, 304, 540 },
-    {   11, 1, 40, 41,  36, 576 },
-};
-// Tables in FhG docu are copy&paste from MPEG-1 and 
-// are fully wrong, don't trust in this snafu
-
-static const type34_t  table4_24000 [] = {
-/* sb cbw bu  bo   w1   w2  (w1+w2 multiplied by 576) */
-    {    0, 3,  0,  4, 576,  96 },
-    {    1, 2,  4,  6, 480, 480 },
-    {    2, 3,  6,  9,  96, 288 },
-    {    3, 4,  9, 13, 288, 288 },
-    {    4, 5, 13, 18, 288, 480 },
-    {    5, 5, 18, 23,  96, 144 },
-    {    6, 4, 23, 27, 432, 144 },
-    {    7, 3, 27, 30, 432, 352 },
-    {    8, 4, 30, 34, 224, 120 },
-    {    9, 3, 34, 37, 456, 442 },
-    {   10, 4, 37, 41, 134, 261 },
-    {   11, 4, 41, 45, 315, 160 },
-};
-// Tables in FhG docu are copy&paste from MPEG-1 and 
-// are fully wrong, don't trust in this snafu
+ 44100.0, 38,
+ 0, 1, 4.532, 1.000, -8.240, 0.000,
+ 1, 1, 0.904, 0.983, -8.240, 1.723,
+ 2, 1, 0.029, 0.983, -8.240, 3.445,
+ 3, 1, 0.009, 0.982, -8.240, 5.057,
+ 4, 1, 0.009, 0.985, -8.240, 6.422,
+ 5, 1, 0.009, 0.983, -8.240, 7.609,
+ 6, 1, 0.009, 0.978, -8.240, 8.710,
+ 7, 1, 0.009, 0.967, -8.240, 9.662,
+ 8, 1, 0.009, 0.948, -8.240, 10.515,
+ 9, 1, 0.009, 0.930, -8.240, 11.293,
+ 10, 1, 0.009, 0.914, -7.447, 12.009,
+ 11, 1, 0.009, 0.870, -7.447, 12.625,
+ 12, 1, 0.009, 0.845, -7.447, 13.210,
+ 13, 1, 0.009, 0.800, -7.447, 13.748,
+ 14, 1, 0.009, 0.749, -7.447, 14.241,
+ 15, 1, 0.009, 0.701, -7.447, 14.695,
+ 16, 1, 0.009, 0.653, -7.447, 15.125,
+ 17, 1, 0.009, 0.590, -7.447, 15.508,
+ 18, 1, 0.009, 0.616, -7.447, 15.891,
+ 19, 2, 0.018, 0.860, -7.447, 16.537,
+ 20, 2, 0.018, 0.823, -6.990, 17.112,
+ 21, 2, 0.018, 0.762, -6.990, 17.621,
+ 22, 2, 0.018, 0.688, -6.990, 18.073,
+ 23, 2, 0.018, 0.612, -6.990, 18.470,
+ 24, 2, 0.018, 0.594, -6.990, 18.849,
+ 25, 3, 0.027, 0.658, -6.990, 19.271,
+ 26, 3, 0.027, 0.706, -6.990, 19.741,
+ 27, 3, 0.054, 0.660, -6.990, 20.177,
+ 28, 3, 0.054, 0.606, -6.990, 20.576,
+ 29, 3, 0.054, 0.565, -6.990, 20.950,
+ 30, 4, 0.114, 0.560, -6.020, 21.316,
+ 31, 4, 0.114, 0.579, -6.020, 21.699,
+ 32, 5, 0.452, 0.567, -6.020, 22.078,
+ 33, 5, 0.452, 0.534, -6.020, 22.438,
+ 34, 5, 0.452, 0.514, -5.229, 22.782,
+ 35, 7, 6.330, 0.520, -5.229, 23.133,
+ 36, 7, 6.330, 0.518, -5.229, 23.484,
+ 37, 7, 6.330, 0.507, -5.229, 23.828,
+ 38, 19, 171.813, 0.447, -4.559, 24.173,
+ 
+ 32000.0, 41,
+ 0, 1, 4.532, 1.000, -8.240, 0.000,
+ 1, 1, 0.904, 0.985, -8.240, 1.250,
+ 2, 1, 0.090, 0.983, -8.240, 2.500,
+ 3, 1, 0.029, 0.983, -8.240, 3.750,
+ 4, 1, 0.009, 0.981, -8.240, 4.909,
+ 5, 1, 0.009, 0.975, -8.240, 5.958,
+ 6, 1, 0.009, 0.959, -8.240, 6.857,
+ 7, 1, 0.009, 0.944, -8.240, 7.700,
+ 8, 1, 0.009, 0.933, -8.240, 8.500,
+ 9, 1, 0.009, 0.920, -8.240, 9.237,
+ 10, 1, 0.009, 0.892, -7.447, 9.895,
+ 11, 1, 0.009, 0.863, -7.447, 10.500,
+ 12, 1, 0.009, 0.839, -7.447, 11.083,
+ 13, 1, 0.009, 0.786, -7.447, 11.604,
+ 14, 1, 0.009, 0.755, -7.447, 12.107,
+ 15, 1, 0.009, 0.698, -7.447, 12.554,
+ 16, 1, 0.009, 0.673, -7.447, 13.000,
+ 17, 1, 0.009, 0.605, -7.447, 13.391,
+ 18, 1, 0.009, 0.629, -7.447, 13.781,
+ 19, 2, 0.018, 0.883, -7.447, 14.474,
+ 20, 2, 0.018, 0.858, -6.990, 15.096,
+ 21, 2, 0.018, 0.829, -6.990, 15.667,
+ 22, 2, 0.018, 0.767, -6.990, 16.177,
+ 23, 2, 0.018, 0.705, -6.990, 16.636,
+ 24, 2, 0.018, 0.637, -6.990, 17.057,
+ 25, 2, 0.018, 0.564, -6.990, 17.429,
+ 26, 2, 0.018, 0.550, -6.990, 17.786,
+ 27, 3, 0.027, 0.603, -6.990, 18.177,
+ 28, 3, 0.027, 0.635, -6.990, 18.597,
+ 29, 3, 0.027, 0.592, -6.990, 18.994,
+ 30, 3, 0.027, 0.533, -6.020, 19.352,
+ 31, 3, 0.027, 0.518, -6.020, 19.693,
+ 32, 4, 0.072, 0.568, -6.020, 20.066,
+ 33, 4, 0.072, 0.594, -6.020, 20.462,
+ 34, 4, 0.072, 0.568, -5.229, 20.841,
+ 35, 5, 0.143, 0.536, -5.229, 21.201,
+ 36, 5, 0.143, 0.522, -5.229, 21.549,
+ 37, 6, 0.172, 0.542, -5.229, 21.911,
+ 38, 7, 0.633, 0.539, -4.559, 22.275,
+ 39, 7, 0.633, 0.519, -4.559, 22.625,
+ 40, 8, 0.723, 0.514, -3.980, 22.971,
+ 41, 10, 9.043, 0.518, -3.980, 23.321,
+ 
+ 24000, 44,
+ 0, 1, 8.91250896, 0.971850038, 0.15, 0,
+ 1, 1, 8.91250896, 0.874727964, 0.15, 0.946573138,
+ 2, 1, 0.891250908, 0.85779953, 0.15, 1.88476217,
+ 3, 1, 0.0891250968, 0.839743853, 0.15, 2.8056457,
+ 4, 1, 0.028183829, 0.82260257, 0.15, 3.70133615,
+ 5, 1, 0.00891250931, 0.80018574, 0.15, 4.56532001,
+ 6, 1, 0.00891250931, 0.771475196, 0.15, 5.39263105,
+ 7, 1, 0.00891250931, 0.737389982, 0.15, 6.17986727,
+ 8, 1, 0.00891250931, 0.701111019, 0.15, 6.92507982,
+ 9, 1, 0.00891250931, 0.65977633, 0.15, 7.62757969,
+ 10, 1, 0.00891250931, 0.615037441, 0.15, 8.28770351,
+ 11, 1, 0.00891250931, 0.568658054, 0.15, 8.90657234,
+ 12, 1, 0.00891250931, 0.522260666, 0.18, 9.48587132,
+ 13, 1, 0.00891250931, 0.478903115, 0.18, 10.0276566,
+ 14, 1, 0.00891250931, 0.43808648, 0.18, 10.5341988,
+ 15, 1, 0.00891250931, 0.412505627, 0.18, 11.0078659,
+ 16, 1, 0.00891250931, 0.39070797, 0.18, 11.4510288,
+ 17, 1, 0.00891250931, 0.371887118, 0.18, 11.866004,
+ 18, 1, 0.00891250931, 0.367617637, 0.18, 12.2550087,
+ 19, 1, 0.00891250931, 0.422220588, 0.18, 12.6201363,
+ 20, 2, 0.0178250186, 0.564990044, 0.18, 13.2772083,
+ 21, 2, 0.0178250186, 0.519700944, 0.18, 13.871047,
+ 22, 2, 0.0178250186, 0.455360681, 0.20, 14.4024391,
+ 23, 2, 0.0178250186, 0.408867925, 0.20, 14.8811684,
+ 24, 2, 0.0178250186, 0.381538749, 0.20, 15.3153324,
+ 25, 2, 0.0178250186, 0.362357527, 0.20, 15.7116165,
+ 26, 2, 0.0178250186, 0.365735918, 0.20, 16.0755405,
+ 27, 3, 0.0267375279, 0.38064, 0.20, 16.4882088,
+ 28, 3, 0.0267375279, 0.379183382, 0.20, 16.9410992,
+ 29, 3, 0.0267375279, 0.360672712, 0.20, 17.3513336,
+ 30, 3, 0.0267375279, 0.343065977, 0.20, 17.7264423,
+ 31, 3, 0.0267375279, 0.339290261, 0.20, 18.0722466,
+ 32, 4, 0.0356500372, 0.342963994, 0.20, 18.4426575,
+ 33, 4, 0.0356500372, 0.343128443, 0.20, 18.8344078,
+ 34, 4, 0.0356500372, 0.343988508, 0.25, 19.1955795,
+ 35, 5, 0.0445625484, 0.343928397, 0.25, 19.5697021,
+ 36, 5, 0.0445625484, 0.339527696, 0.25, 19.9551182,
+ 37, 5, 0.0889139697, 0.336541563, 0.28, 20.3115921,
+ 38, 6, 0.106696762, 0.334955156, 0.28, 20.6737747,
+ 39, 6, 0.169102982, 0.335601568, 0.30, 21.0404968,
+ 40, 7, 0.1972868, 0.334716886, 0.30, 21.4060211,
+ 41, 7, 0.1972868, 0.331676662, 0.30, 21.7696877,
+ 42, 8, 0.713000774, 0.328550965, 0.40, 22.1267223,
+ 43, 8, 0.713000774, 0.339241952, 0.40, 22.4769249,
+ 44, 9, 0.802125871, 0.425207615, 0.40, 22.8164864,
+ 
+ 22050, 44,
+ 0, 1, 8.91250896, 0.954045713, 0.15, 0,
+ 1, 1, 8.91250896, 0.833381653, 0.15, 0.869851649,
+ 2, 1, 0.891250908, 0.815945923, 0.15, 1.73325908,
+ 3, 1, 0.0891250968, 0.794244766, 0.15, 2.58322191,
+ 4, 1, 0.028183829, 0.776486695, 0.15, 3.4134295,
+ 5, 1, 0.00891250931, 0.755260408, 0.15, 4.21850443,
+ 6, 1, 0.00891250931, 0.731070817, 0.15, 4.99414825,
+ 7, 1, 0.00891250931, 0.701775849, 0.15, 5.73718691,
+ 8, 1, 0.00891250931, 0.667876124, 0.15, 6.44553185,
+ 9, 1, 0.00891250931, 0.630284071, 0.15, 7.11807632,
+ 10, 1, 0.00891250931, 0.590170324, 0.15, 7.75455618,
+ 11, 1, 0.00891250931, 0.548788548, 0.15, 8.3553915,
+ 12, 1, 0.00891250931, 0.507795513, 0.15, 8.92152882,
+ 13, 1, 0.00891250931, 0.469515711, 0.18, 9.45430183,
+ 14, 1, 0.00891250931, 0.432291716, 0.18, 9.95530319,
+ 15, 1, 0.00891250931, 0.411131173, 0.18, 10.4262848,
+ 16, 1, 0.00891250931, 0.390771538, 0.18, 10.8690758,
+ 17, 1, 0.00891250931, 0.373318017, 0.18, 11.2855215,
+ 18, 1, 0.00891250931, 0.36956048, 0.18, 11.6774378,
+ 19, 1, 0.00891250931, 0.42595759, 0.18, 12.0465794,
+ 20, 2, 0.0178250186, 0.576900065, 0.18, 12.7141209,
+ 21, 2, 0.0178250186, 0.533114731, 0.18, 13.3197365,
+ 22, 2, 0.0178250186, 0.469967514, 0.18, 13.8634901,
+ 23, 2, 0.0178250186, 0.417268544, 0.20, 14.3544445,
+ 24, 2, 0.0178250186, 0.389299124, 0.20, 14.8002586,
+ 25, 2, 0.0178250186, 0.362824857, 0.20, 15.2073727,
+ 26, 2, 0.0178250186, 0.346801281, 0.20, 15.5811834,
+ 27, 2, 0.0178250186, 0.349400043, 0.20, 15.926218,
+ 28, 3, 0.0267375279, 0.364026934, 0.20, 16.3194923,
+ 29, 3, 0.0267375279, 0.36560446, 0.20, 16.752903,
+ 30, 3, 0.0267375279, 0.354275256, 0.20, 17.1470814,
+ 31, 3, 0.0267375279, 0.351219416, 0.20, 17.5086212,
+ 32, 4, 0.0356500372, 0.354364097, 0.20, 17.8938141,
+ 33, 4, 0.0356500372, 0.348915905, 0.20, 18.2992878,
+ 34, 4, 0.0356500372, 0.337649345, 0.20, 18.6713982,
+ 35, 4, 0.0356500372, 0.332076877, 0.25, 19.015646,
+ 36, 5, 0.0445625484, 0.330793113, 0.25, 19.3734016,
+ 37, 5, 0.0445625484, 0.327528268, 0.25, 19.7430382,
+ 38, 5, 0.0889139697, 0.32551071, 0.28, 20.0859604,
+ 39, 6, 0.106696762, 0.324436843, 0.28, 20.4354992,
+ 40, 6, 0.106696762, 0.325835049, 0.28, 20.7905579,
+ 41, 7, 0.1972868, 0.326221824, 0.30, 21.1458054,
+ 42, 7, 0.1972868, 0.325960994, 0.30, 21.5005951,
+ 43, 8, 0.225470632, 0.339019388, 0.30, 21.8504524,
+ 44, 8, 0.713000774, 0.426850349, 0.40, 22.1951065,
+ 
+ 16000, 45,
+ 0, 1, 8.91250896, 0.834739447, 0.15, 0,
+ 1, 1, 8.91250896, 0.623757005, 0.15, 0.631518543,
+ 2, 1, 0.891250908, 0.60420388, 0.15, 1.2606914,
+ 3, 1, 0.891250908, 0.591974258, 0.15, 1.88476217,
+ 4, 1, 0.0891250968, 0.575301588, 0.15, 2.50111985,
+ 5, 1, 0.028183829, 0.561547697, 0.15, 3.1073606,
+ 6, 1, 0.028183829, 0.546665847, 0.15, 3.70133615,
+ 7, 1, 0.00891250931, 0.52986443, 0.15, 4.28118753,
+ 8, 1, 0.00891250931, 0.511183441, 0.15, 4.84536505,
+ 9, 1, 0.00891250931, 0.490902334, 0.15, 5.39263105,
+ 10, 1, 0.00891250931, 0.46938166, 0.15, 5.92205667,
+ 11, 1, 0.00891250931, 0.447003782, 0.15, 6.43299866,
+ 12, 1, 0.00891250931, 0.428170592, 0.15, 6.92507982,
+ 13, 1, 0.00891250931, 0.414536625, 0.15, 7.39815664,
+ 14, 1, 0.00891250931, 0.401033074, 0.15, 7.85228777,
+ 15, 1, 0.00891250931, 0.38779071, 0.15, 8.28770351,
+ 16, 1, 0.00891250931, 0.374230444, 0.15, 8.704772,
+ 17, 1, 0.00891250931, 0.360547513, 0.18, 9.10397339,
+ 18, 1, 0.00891250931, 0.348256677, 0.18, 9.48587132,
+ 19, 1, 0.00891250931, 0.350327015, 0.18, 9.85109234,
+ 20, 1, 0.00891250931, 0.406330824, 0.18, 10.200304,
+ 21, 2, 0.0178250186, 0.554098248, 0.18, 10.846529,
+ 22, 2, 0.0178250186, 0.528312504, 0.18, 11.4447651,
+ 23, 2, 0.0178250186, 0.476527005, 0.18, 11.9928398,
+ 24, 2, 0.0178250186, 0.428205669, 0.18, 12.495945,
+ 25, 2, 0.0178250186, 0.402271926, 0.18, 12.9588718,
+ 26, 2, 0.0178250186, 0.378024429, 0.18, 13.3859692,
+ 27, 2, 0.0178250186, 0.36254698, 0.18, 13.7811394,
+ 28, 2, 0.0178250186, 0.368058592, 0.20, 14.1478529,
+ 29, 3, 0.0267375279, 0.385963261, 0.20, 14.5674343,
+ 30, 3, 0.0267375279, 0.38640517, 0.20, 15.0304852,
+ 31, 3, 0.0267375279, 0.367834061, 0.20, 15.4513416,
+ 32, 3, 0.0267375279, 0.349686563, 0.20, 15.836277,
+ 33, 3, 0.0267375279, 0.345709383, 0.20, 16.1904697,
+ 34, 4, 0.0356500372, 0.34871915, 0.20, 16.5683517,
+ 35, 4, 0.0356500372, 0.347054332, 0.20, 16.9660263,
+ 36, 4, 0.0356500372, 0.346329987, 0.20, 17.3304482,
+ 37, 5, 0.0445625484, 0.344658494, 0.20, 17.7055588,
+ 38, 5, 0.0445625484, 0.338779271, 0.20, 18.0899811,
+ 39, 5, 0.0445625484, 0.334878683, 0.20, 18.4440536,
+ 40, 6, 0.0534750558, 0.332811534, 0.20, 18.8030052,
+ 41, 6, 0.0534750558, 0.333717585, 0.25, 19.1665268,
+ 42, 7, 0.062387567, 0.333986402, 0.25, 19.5299358,
+ 43, 7, 0.062387567, 0.334142625, 0.25, 19.8934898,
+ 44, 8, 0.142262354, 0.34677428, 0.28, 20.2535706,
+ 45, 8, 0.142262354, 0.436254472, 0.28, 20.610569,
+ 
+ 48000.0, 20,
+ 0, 3, 0, 4, 1.000, 0.056,
+ 1, 3, 4, 7, 0.944, 0.611,
+ 2, 4, 7, 11, 0.389, 0.167,
+ 3, 3, 11, 14, 0.833, 0.722,
+ 4, 3, 14, 17, 0.278, 0.639,
+ 5, 2, 17, 19, 0.361, 0.417,
+ 6, 3, 19, 22, 0.583, 0.083,
+ 7, 2, 22, 24, 0.917, 0.750,
+ 8, 3, 24, 27, 0.250, 0.417,
+ 9, 3, 27, 30, 0.583, 0.648,
+ 10, 3, 30, 33, 0.352, 0.611,
+ 11, 3, 33, 36, 0.389, 0.625,
+ 12, 4, 36, 40, 0.375, 0.144,
+ 13, 3, 40, 43, 0.856, 0.389,
+ 14, 3, 43, 46, 0.611, 0.160,
+ 15, 3, 46, 49, 0.840, 0.217,
+ 16, 3, 49, 52, 0.783, 0.184,
+ 17, 2, 52, 54, 0.816, 0.886,
+ 18, 3, 54, 57, 0.114, 0.313,
+ 19, 2, 57, 59, 0.687, 0.452,
+ 20, 1, 59, 60, 0.548, 0.908,
+ 
+ 44100.0, 20,
+ 0, 3, 0, 4, 1.000, 0.056,
+ 1, 3, 4, 7, 0.944, 0.611,
+ 2, 4, 7, 11, 0.389, 0.167,
+ 3, 3, 11, 14, 0.833, 0.722,
+ 4, 3, 14, 17, 0.278, 0.139,
+ 5, 1, 17, 18, 0.861, 0.917,
+ 6, 3, 18, 21, 0.083, 0.583,
+ 7, 3, 21, 24, 0.417, 0.250,
+ 8, 3, 24, 27, 0.750, 0.805,
+ 9, 3, 27, 30, 0.194, 0.574,
+ 10, 3, 30, 33, 0.426, 0.537,
+ 11, 3, 33, 36, 0.463, 0.819,
+ 12, 4, 36, 40, 0.180, 0.100,
+ 13, 3, 40, 43, 0.900, 0.468,
+ 14, 3, 43, 46, 0.532, 0.623,
+ 15, 3, 46, 49, 0.376, 0.450,
+ 16, 3, 49, 52, 0.550, 0.552,
+ 17, 3, 52, 55, 0.448, 0.403,
+ 18, 2, 55, 57, 0.597, 0.643,
+ 19, 2, 57, 59, 0.357, 0.722,
+ 20, 2, 59, 61, 0.278, 0.960,
+ 
+ 32000, 20,
+ 0, 1, 0, 2, 1.000, 0.528,
+ 1, 2, 2, 4, 0.472, 0.305,
+ 2, 2, 4, 6, 0.694, 0.083,
+ 3, 1, 6, 7, 0.917, 0.861,
+ 4, 2, 7, 9, 0.139, 0.639,
+ 5, 2, 9, 11, 0.361, 0.417,
+ 6, 3, 11, 14, 0.583, 0.083,
+ 7, 2, 14, 16, 0.917, 0.750,
+ 8, 3, 16, 19, 0.250, 0.870,
+ 9, 3, 19, 22, 0.130, 0.833,
+ 10, 4, 22, 26, 0.167, 0.389,
+ 11, 4, 26, 30, 0.611, 0.478,
+ 12, 4, 30, 34, 0.522, 0.033,
+ 13, 3, 34, 37, 0.967, 0.917,
+ 14, 4, 37, 41, 0.083, 0.617,
+ 15, 3, 41, 44, 0.383, 0.995,
+ 16, 4, 44, 48, 0.005, 0.274,
+ 17, 3, 48, 51, 0.726, 0.480,
+ 18, 3, 51, 54, 0.519, 0.261,
+ 19, 2, 54, 56, 0.739, 0.884,
+ 20, 2, 56, 58, 0.116, 1.000,
+ 
+ 24000, 20,
+ 0, 2, 0, 3, 1, 0.916666746,
+ 1, 3, 3, 6, 0.0833332539, 0.583333492,
+ 2, 3, 6, 9, 0.416666508, 0.25,
+ 3, 2, 9, 11, 0.75, 0.916666985,
+ 4, 3, 11, 14, 0.0833330154, 0.583333969,
+ 5, 3, 14, 17, 0.416666031, 0.25,
+ 6, 3, 17, 20, 0.75, 0.537036896,
+ 7, 3, 20, 23, 0.462963104, 0.5,
+ 8, 4, 23, 27, 0.5, 0.0555559993,
+ 9, 3, 27, 30, 0.944444001, 0.402778625,
+ 10, 3, 30, 33, 0.597221375, 0.766667187,
+ 11, 3, 33, 36, 0.233332828, 0.805555999,
+ 12, 3, 36, 39, 0.194444016, 0.769841909,
+ 13, 3, 39, 42, 0.23015812, 0.611111104,
+ 14, 3, 42, 45, 0.388888896, 0.449494779,
+ 15, 3, 45, 48, 0.550505221, 0.194444954,
+ 16, 2, 48, 50, 0.805555046, 0.913194656,
+ 17, 3, 50, 53, 0.0868053436, 0.580555737,
+ 18, 3, 53, 56, 0.419444263, 0.113426208,
+ 19, 2, 56, 58, 0.886573792, 0.533730626,
+ 20, 2, 58, 60, 0.466269344, 0.691176474,
+ 
+ 22050, 20,
+ 0, 2, 0, 3, 1, 0.916666746,
+ 1, 3, 3, 6, 0.0833332539, 0.583333492,
+ 2, 3, 6, 9, 0.416666508, 0.25,
+ 3, 2, 9, 11, 0.75, 0.916666985,
+ 4, 3, 11, 14, 0.0833330154, 0.583333969,
+ 5, 3, 14, 17, 0.416666031, 0.25,
+ 6, 3, 17, 20, 0.75, 0.203703582,
+ 7, 3, 20, 23, 0.796296418, 0.166666687,
+ 8, 3, 23, 26, 0.833333313, 0.722222686,
+ 9, 4, 26, 30, 0.277777344, 0.152778625,
+ 10, 3, 30, 33, 0.847221375, 0.566667199,
+ 11, 3, 33, 36, 0.433332831, 0.93518573,
+ 12, 4, 36, 40, 0.0648142472, 0.118056297,
+ 13, 3, 40, 43, 0.881943703, 0.0925937295,
+ 14, 2, 43, 45, 0.907406271, 0.934344172,
+ 15, 3, 45, 48, 0.0656557977, 0.575398028,
+ 16, 3, 48, 51, 0.424601972, 0.232026935,
+ 17, 2, 51, 53, 0.767973065, 0.758334339,
+ 18, 3, 53, 56, 0.241665646, 0.187501252,
+ 19, 2, 56, 58, 0.812498748, 0.533731699,
+ 20, 2, 58, 60, 0.466268271, 0.257577598,
+ 
+ 16000, 20,
+ 0, 1, 0, 2, 1, 0.944444478,
+ 1, 2, 2, 4, 0.0555555038, 0.722222328,
+ 2, 2, 4, 6, 0.277777672, 0.5,
+ 3, 2, 6, 8, 0.5, 0.27777797,
+ 4, 2, 8, 10, 0.72222203, 0.0555559993,
+ 5, 1, 10, 11, 0.944444001, 0.833333313,
+ 6, 3, 11, 14, 0.166666672, 0.203703582,
+ 7, 3, 14, 17, 0.796296418, 0.166666687,
+ 8, 3, 17, 20, 0.833333313, 0.54166698,
+ 9, 3, 20, 23, 0.458333015, 0.652778625,
+ 10, 4, 23, 27, 0.347221375, 0.166667163,
+ 11, 3, 27, 30, 0.833332837, 0.722222924,
+ 12, 4, 30, 34, 0.277777106, 0.277778625,
+ 13, 3, 34, 37, 0.722221375, 0.604167938,
+ 14, 3, 37, 40, 0.395832062, 0.627778649,
+ 15, 3, 40, 43, 0.37222138, 0.542736351,
+ 16, 3, 43, 46, 0.457263649, 0.371528625,
+ 17, 3, 46, 49, 0.628471375, 0.00833433867,
+ 18, 2, 49, 51, 0.991665661, 0.500001311,
+ 19, 2, 51, 53, 0.499998659, 0.886832893,
+ 20, 2, 53, 55, 0.113167092, 0.629034221,
+ 
+ 48000.0, 11,
+ 0, 2, 0, 3, 1.000, 0.167,
+ 1, 2, 3, 5, 0.833, 0.833,
+ 2, 3, 5, 8, 0.167, 0.500,
+ 3, 3, 8, 11, 0.500, 0.167,
+ 4, 4, 11, 15, 0.833, 0.167,
+ 5, 4, 15, 19, 0.833, 0.583,
+ 6, 3, 19, 22, 0.417, 0.917,
+ 7, 4, 22, 26, 0.083, 0.944,
+ 8, 4, 26, 30, 0.055, 0.042,
+ 9, 2, 30, 32, 0.958, 0.567,
+ 10, 3, 32, 35, 0.433, 0.167,
+ 11, 2, 35, 37, 0.833, 0.618,
+ 
+ 44100.0, 11,
+ 0, 2, 0, 3, 1.000, 0.167,
+ 1, 2, 3, 5, 0.833, 0.833,
+ 2, 3, 5, 8, 0.167, 0.500,
+ 3, 3, 8, 11, 0.500, 0.167,
+ 4, 4, 11, 15, 0.833, 0.167,
+ 5, 5, 15, 20, 0.833, 0.250,
+ 6, 3, 20, 23, 0.750, 0.583,
+ 7, 4, 23, 27, 0.417, 0.055,
+ 8, 3, 27, 30, 0.944, 0.375,
+ 9, 3, 30, 33, 0.625, 0.300,
+ 10, 3, 33, 36, 0.700, 0.167,
+ 11, 2, 36, 38, 0.833, 1.000,
+ 
+ 32000, 11,
+ 0, 2, 0, 3, 1.000, 0.167,
+ 1, 2, 3, 5, 0.833, 0.833,
+ 2, 3, 5, 8, 0.167, 0.500,
+ 3, 3, 8, 11, 0.500, 0.167,
+ 4, 4, 11, 15, 0.833, 0.167,
+ 5, 5, 15, 20, 0.833, 0.250,
+ 6, 4, 20, 24, 0.750, 0.250,
+ 7, 5, 24, 29, 0.750, 0.055,
+ 8, 4, 29, 33, 0.944, 0.375,
+ 9, 4, 33, 37, 0.625, 0.472,
+ 10, 3, 37, 40, 0.528, 0.937,
+ 11, 1, 40, 41, 0.062, 1.000,
+ 
+ 24000, 11,
+ 0, 3, 0, 4, 1, 0.166666746,
+ 1, 2, 4, 6, 0.833333254, 0.833333492,
+ 2, 3, 6, 9, 0.166666508, 0.5,
+ 3, 4, 9, 13, 0.5, 0.5,
+ 4, 5, 13, 18, 0.5, 0.833333969,
+ 5, 5, 18, 23, 0.166666031, 0.25,
+ 6, 4, 23, 27, 0.75, 0.25,
+ 7, 3, 27, 30, 0.75, 0.611111999,
+ 8, 4, 30, 34, 0.388888031, 0.208333969,
+ 9, 3, 34, 37, 0.791666031, 0.766667187,
+ 10, 4, 37, 41, 0.233332828, 0.45238167,
+ 11, 4, 41, 45, 0.54761833, 0.277778625,
+ 
+ 22050, 11,
+ 0, 3, 0, 4, 1, 0.166666746,
+ 1, 2, 4, 6, 0.833333254, 0.833333492,
+ 2, 3, 6, 9, 0.166666508, 0.5,
+ 3, 4, 9, 13, 0.5, 0.5,
+ 4, 4, 13, 17, 0.5, 0.5,
+ 5, 4, 17, 21, 0.5, 0.916666985,
+ 6, 4, 21, 25, 0.0833330154, 0.25,
+ 7, 4, 25, 29, 0.75, 0.611111999,
+ 8, 4, 29, 33, 0.388888031, 0.458333969,
+ 9, 4, 33, 37, 0.541666031, 0.633334339,
+ 10, 4, 37, 41, 0.366665661, 0.583334565,
+ 11, 4, 41, 45, 0.416665405, 0.437500954,
+ 
+ 16000, 11,
+ 0, 0, 0, 4, 1, 0.166666746,
+ 1, 0, 4, 6, 0.833333254, 0.833333492,
+ 2, 0, 6, 9, 0.166666508, 0.5,
+ 3, 0, 9, 13, 0.5, 0.5,
+ 4, 0, 13, 18, 0.5, 0.833333969,
+ 5, 0, 18, 23, 0.166666031, 0.75,
+ 6, 0, 23, 27, 0.25, 0.75,
+ 7, 0, 27, 31, 0.25, 0.611111999,
+ 8, 0, 31, 35, 0.388888031, 0.458333969,
+ 9, 0, 35, 39, 0.541666031, 0.166667163,
+ 10, 0, 39, 42, 0.833332837, 0.805555999,
+ 11, 0, 42, 46, 0.194444016, 0.4375
 
-static const type34_t  table4_22050 [] = {
-/* sb cbw bu  bo   w1   w2  (w1+w2 multiplied by 576) */
-    {    0, 3,  0,  4, 576,  96 },
-    {    1, 2,  4,  6, 480, 480 },
-    {    2, 3,  6,  9,  96, 288 },
-    {    3, 4,  9, 13, 288, 288 },
-    {    4, 4, 13, 17, 288, 288 },
-    {    5, 4, 17, 21, 288, 528 },
-    {    6, 4, 21, 25,  48, 144 },
-    {    7, 4, 25, 29, 432, 352 },
-    {    8, 4, 29, 33, 224, 264 },
-    {    9, 4, 33, 37, 312, 365 },
-    {   10, 4, 37, 41, 211, 336 },
-    {   11, 4, 41, 45, 240, 252 },
 };
-// Tables in FhG docu are copy&paste from MPEG-1 and 
-// are fully wrong, don't trust in this snafu
 
-static const type34_t  table4_16000 [] = {
-/* sb cbw bu  bo   w1   w2  (w1+w2 multiplied by 576) */
-    {    0, 0,  0,  4, 576,  96 },
-    {    1, 0,  4,  6, 480, 480 },
-    {    2, 0,  6,  9,  96, 288 },
-    {    3, 0,  9, 13, 288, 288 },
-    {    4, 0, 13, 18, 288, 480 },
-    {    5, 0, 18, 23,  96, 432 },
-    {    6, 0, 23, 27, 144, 432 },
-    {    7, 0, 27, 31, 144, 352 },
-    {    8, 0, 31, 35, 224, 264 },
-    {    9, 0, 35, 39, 312,  96 },
-    {   10, 0, 39, 42, 480, 464 },
-    {   11, 0, 42, 46, 112, 252 },
-};
 
-const type5_t  table5 [6] = {
-    {
-    sizeof(table1_16000)/sizeof(*table1_16000), table1_16000,
-    sizeof(table2_16000)/sizeof(*table2_16000), table2_16000,
-    sizeof(table3_16000)/sizeof(*table3_16000), table3_16000,
-    sizeof(table4_16000)/sizeof(*table4_16000), table4_16000,
-    },
-    {
-    sizeof(table1_22050)/sizeof(*table1_22050), table1_22050,
-    sizeof(table2_22050)/sizeof(*table2_22050), table2_22050,
-    sizeof(table3_22050)/sizeof(*table3_22050), table3_22050,
-    sizeof(table4_22050)/sizeof(*table4_22050), table4_22050,
-    },
-    {
-    sizeof(table1_24000)/sizeof(*table1_24000), table1_24000,
-    sizeof(table2_24000)/sizeof(*table2_24000), table2_24000,
-    sizeof(table3_24000)/sizeof(*table3_24000), table3_24000,
-    sizeof(table4_24000)/sizeof(*table4_24000), table4_24000,
-    },
-    {
-    sizeof(table1_32000)/sizeof(*table1_32000), table1_32000,
-    sizeof(table2_32000)/sizeof(*table2_32000), table2_32000,
-    sizeof(table3_32000)/sizeof(*table3_32000), table3_32000,
-    sizeof(table4_32000)/sizeof(*table4_32000), table4_32000,
-    },
-    {
-    sizeof(table1_44100)/sizeof(*table1_44100), table1_44100,
-    sizeof(table2_44100)/sizeof(*table2_44100), table2_44100,
-    sizeof(table3_44100)/sizeof(*table3_44100), table3_44100,
-    sizeof(table4_44100)/sizeof(*table4_44100), table4_44100,
-    },
-    {
-    sizeof(table1_48000)/sizeof(*table1_48000), table1_48000,
-    sizeof(table2_48000)/sizeof(*table2_48000), table2_48000,
-    sizeof(table3_48000)/sizeof(*table3_48000), table3_48000,
-    sizeof(table4_48000)/sizeof(*table4_48000), table4_48000,
-    }
-};
 
 /*  for (i = 0; i < 16*16; i++) {
  *      largetbl[i] = ((ht[16].hlen[i]) << 16) + ht[24].hlen[i];
diff -duHr lame.20001203/libmp3lame/tables.h lame.org/libmp3lame/tables.h
--- lame.20001203/libmp3lame/tables.h	Fri Dec  1 14:01:10 2000
+++ lame.org/libmp3lame/tables.h	Mon Dec  4 15:32:48 2000
@@ -23,13 +23,14 @@
 #define LAME_TABLES_H
 
 #include "machine.h"
+extern const FLOAT psy_data [];
 
 #define HTN	34
  
 struct huffcodetab {
     const int    xlen; 	        /* max. x-index+			*/ 
     const int    linmax;	/* max number to be stored in linbits	*/
-    const short* table;	        /* pointer to array[xlen][ylen]		*/
+    const short*   table;	        /* pointer to array[xlen][ylen]		*/
     const char*  hlen;	        /* pointer to array[xlen][ylen]		*/
 };
 
@@ -45,45 +46,4 @@
 extern const unsigned int   largetbl    [16*16];
 extern const unsigned int   table23       [3*3];
 extern const unsigned int   table56       [4*4];
-
-typedef struct {
-    unsigned char  no;
-    unsigned char  width;
-    unsigned char  minval_2;
-    float          quiet_thr;
-    float          norm;
-    float          bark;
-} type1_t;
-
-typedef struct {
-    unsigned char  no;
-    unsigned char  width;
-    float          quiet_thr;
-    float          norm;
-    float          SNR;
-    float          bark;
-} type2_t;
-
-typedef struct {
-    unsigned int  no     :  5;
-    unsigned int  cbw    :  3;
-    unsigned int  bu     :  6;
-    unsigned int  bo     :  6;
-    unsigned int  w1_576 : 10;
-    unsigned int  w2_576 : 10;
-} type34_t;
-
-typedef struct {
-    size_t                 len1;
-    const type1_t*  const  tab1;
-    size_t                 len2;
-    const type2_t*  const  tab2;
-    size_t                 len3;
-    const type34_t* const  tab3;
-    size_t                 len4;
-    const type34_t* const  tab4;
-} type5_t;
-
-extern const type5_t  table5 [6];
-
 #endif /* LAME_TABLES_H */
diff -duHr lame.20001203/libmp3lame/util.c lame.org/libmp3lame/util.c
--- lame.20001203/libmp3lame/util.c	Wed Nov 29 16:45:36 2000
+++ lame.org/libmp3lame/util.c	Mon Dec  4 15:32:48 2000
@@ -19,7 +19,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
-/* $Id: util.c,v 1.35 2000/11/26 20:58:48 robert Exp $ */
+/* $Id: util.c,v 1.37 2000/12/03 23:27:43 markt Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
@@ -68,7 +68,24 @@
     free ( gfc );
 }
 
-#ifdef KLEMM_01
+
+#if 0
+FLOAT8 ATHformula(FLOAT8 f)
+{
+  FLOAT8 ath;
+  f  = Max(0.01, f);
+  f  = Min(18.0,f);
+
+  /* from Painter & Spanias, 1997 */
+  /* minimum: (i=77) 3.3kHz = -5db */
+  ath =    3.640 * pow(f,-0.8)
+         - 6.500 * exp(-0.6*pow(f-3.3,2.0))
+         + 0.001 * pow(f,4.0);
+  return ath;
+}
+#endif
+
+
 
 /* 
  *  Klemm 1994 and 1997. Experimental data. Sorry, data looks a little bit
@@ -77,10 +94,10 @@
  *  ATH is not good even if it's theoretically inaudible).
  */
 
-double  ATHformula ( double freq )
+FLOAT8  ATHformula( FLOAT8 freq )
 {
     /* short [MilliBel] is also sufficient */
-    static float tab [] = {
+    static FLOAT tab [] = {
         /*    10.0 */  96.69, 96.69, 96.26, 95.12,
         /*    12.6 */  93.53, 91.13, 88.82, 86.76,
         /*    15.8 */  84.69, 82.43, 79.97, 77.48,
@@ -117,9 +134,10 @@
         /* 19952.6 */  63.85, 66.04, 68.33, 70.09,
         /* 25118.9 */  70.66, 71.27, 71.91, 72.60,
     };
-    double    freq_log;
+    FLOAT8    freq_log;
     unsigned  index;
     
+    freq *= 1000.;
     if ( freq <    10. ) freq =    10.;
     if ( freq > 25000. ) freq = 25000.;
     
@@ -129,24 +147,7 @@
     return tab [index] * (1 + index - freq_log) + tab [index+1] * (freq_log - index);
 }
 
-#else
 
-FLOAT8 ATHformula(FLOAT8 freq)
-{
-  FLOAT8 ath;
-  freq  = Max (   20, freq);   // reaches +84 dB which is known as the subsonic/sonic border
-  freq  = Min (18000, freq);
-
-  /* from Painter & Spanias, 1997 */
-  /* minimum: (i=77) 3.3 kHz = -5 dB */
-  freq *= 1.e-3;
-  ath   =  3.640 * pow (freq, -0.8)
-         - 6.500 * exp (-0.6*pow (freq-3.3, 2.) )
-         + 0.001 * pow (freq, 4.);
-  return ath;
-}
-
-#endif
 
 /* see for example "Zwicker: Psychoakustik, 1982; ISBN 3-540-11401-7 */
 FLOAT8 freq2bark(FLOAT8 freq)
@@ -211,14 +212,16 @@
 int version,      /* MPEG-1 or MPEG-2 LSF */
 int samplerate)   /* convert bitrate in kbps to index */
 {
-    int  bitrate = 0;
-    int  i;
+  int     index = 0;
+  int     bitrate = 10000;
   
-    for ( i = 1; i <= 14; i++ )
-        if ( ABS (bitrate_table[version][i] - bRate) < ABS (bitrate - bRate) )
-            bitrate = bitrate_table [version] [i];
-	    
-    return bitrate;
+  while( index<15)   {
+    if( ABS( bitrate_table[version][index] - bRate) < ABS(bitrate-bRate) ) {
+      bitrate = bitrate_table[version][index];
+    }
+    ++index;
+  }
+  return bitrate;
 }
 
 
@@ -241,19 +244,26 @@
 }
 
 int BitrateIndex(
-int bRate,        /* legal rates from 32 to 448 kbps */
-int version,      /* MPEG-1 or MPEG-2/2.5 LSF */
+int bRate,        /* legal rates from 32 to 448 */
+int version,      /* MPEG-1 or MPEG-2 LSF */
 int samplerate)   /* convert bitrate in kbps to index */
 {
-    int  i;
+int     index = 0;
+int     found = 0;
 
-    for ( i = 1; i <= 14; i++)
-        if ( bitrate_table [version] [i] == bRate )
-            return i;
-	    
-    ERRORF ( "Bitrate %d kbps not legal for %i Hz output sampling frequency.\n", 
-             bRate, samplerate );
-    return -1;
+    while(!found && index<15)   {
+        if(bitrate_table[version][index] == bRate)
+            found = 1;
+        else
+            ++index;
+    }
+    if(found)
+        return(index);
+    else {
+        ERRORF("Bitrate %d kbps not legal for %i Hz output sampling frequency.\n",
+                bRate, samplerate);
+        return(-1);     /* Error! */
+    }
 }
 
 /* convert samp freq in Hz to index */
@@ -314,17 +324,17 @@
 
 
 /* resampling via FIR filter, blackman window */
-inline static double blackman(int i,double offset,double fcn,int l)
+inline static FLOAT8 blackman(int i,FLOAT8 offset,FLOAT8 fcn,int l)
 {
   /* This algorithm from:
 SIGNAL PROCESSING ALGORITHMS IN FORTRAN AND C
 S.D. Stearns and R.A. David, Prentice-Hall, 1992
   */
 
-  double bkwn;
-  double wcn = (PI * fcn);
-  double dly = l / 2.0;
-  double x = i-offset;
+  FLOAT8 bkwn;
+  FLOAT8 wcn = (PI * fcn);
+  FLOAT8 dly = l / 2.0;
+  FLOAT8 x = i-offset;
   if (x<0) x=0;
   if (x>l) x=l;
   bkwn = 0.42 - 0.5 * cos((x * 2) * PI /l)
@@ -359,10 +369,10 @@
   
   lame_internal_flags *gfc=gfp->internal_flags;
   int BLACKSIZE;
-  double offset,xvalue;
+  FLOAT8 offset,xvalue;
   int i,j=0,k;
   int filter_l;
-  double fcn,intratio;
+  FLOAT8 fcn,intratio;
   FLOAT *inbuf_old;
   int bpc;   /* number of convolution functions to pre-compute */
   bpc = gfp->out_samplerate/gcd(gfp->out_samplerate,gfp->in_samplerate);
@@ -392,7 +402,7 @@
 
     /* precompute blackman filter coefficients */
     for ( j = 0; j <= 2*bpc; j++ ) {
-        double sum = 0.; 
+        FLOAT8 sum = 0.; 
         offset = (j-bpc) / (2.*bpc);
         for ( i = 0; i <= filter_l; i++ ) 
             sum += 
@@ -527,15 +537,6 @@
 #endif
 }    
 
-int  has_SIMD2 ( void )
-{
-#ifdef HAVE_NASM 
-    extern int has_SIMD2_nasm ( void );
-    return has_SIMD2_nasm ();
-#else
-    return 0;   /* don't know, assume not */
-#endif
-}    
 
 /***********************************************************************
  *
@@ -561,8 +562,8 @@
     /* count bitrate indices */
     gfc->bitrate_stereoMode_Hist [gfc->bitrate_index] [4] ++;
     
-    /* count 'em for every mode extension in case of 2 channel encoding */
-    if (gfc->channels_out == 2)
+    /* count 'em for every mode extension in case of stereo encoding */
+    if (gfc->stereo == 2)
         gfc->bitrate_stereoMode_Hist [gfc->bitrate_index] [gfc->mode_ext]++;
 }
 
diff -duHr lame.20001203/libmp3lame/util.h lame.org/libmp3lame/util.h
--- lame.20001203/libmp3lame/util.h	Wed Nov 29 16:45:36 2000
+++ lame.org/libmp3lame/util.h	Mon Dec  4 15:32:48 2000
@@ -128,39 +128,6 @@
 } nsPsy_t;
 
 
-/* different amplification modes */
-typedef enum {
-    amp_mode_all = 0, /* the old one, all distorted bands at once */ 
-    amp_mode_low, 
-    amp_mode_mid, 
-    amp_mode_max      /* only maximum distorted band at once */
-} amp_mode_t;
-
-
-/* Guest structure, only temporarly here */
-
-typedef enum {
-    coding_MPEG_Layer_1 = 1,
-    coding_MPEG_Layer_2 = 2,
-    coding_MPEG_Layer_3 = 3,
-    coding_MPEG_AAC     = 4,
-    coding_Ogg_Vorbis   = 5
-} coding_t;
-
-
-typedef struct {
-    unsigned long  Class_ID;
-    long double    sample_freq_in;
-    long double    sample_freq_out;
-    float          lowpass_freq;
-    int            scale_in;
-    int            scale_out;
-    sample_t**     fir;
-    sample_t*      lastsamples [2];
-    // ...
-} resample_t;
-
-
 typedef struct  {
 
   /********************************************************************
@@ -192,16 +159,7 @@
 
   int padding;                    /* padding for the current frame? */
   int mode_gr;                    /* granules per frame */
-    int          channels_in;	/* number of channels in the input data stream (PCM or decoded PCM) */
-    int          channels_out;  /* number of channels in the output data stream (not used for decoding) */
-    resample_t*  resample_in;   /* context for coding (PCM=>MP3) resampling */
-    resample_t*  resample_out;	/* context for decoding (MP3=>PCM) resampling */
-    size_t       frame_size;    /* size of one frame in samples per channel */
-    lame_global_flags* gfp;     /* needed as long as the frame encoding functions must access gfp (all needed information can be added to gfc) */
-    coding_t     coding;        /* MPEG Layer 1/2/3, Ogg Vorbis, MPEG AAC, ... */
-    unsigned long frame_count;  /* Number of frames coded, 2^32 > 3 years */
-    float          ampl;	  /* amplification at the end of the current chunk (1. = 0 dB) */
-    float          last_ampl;	  /* amplification at the end of the last chunk    (1. = 0 dB) */
+  int stereo;                     /* number of channels */
   int VBR_min_bitrate;            /* min bitrate index */
   int VBR_max_bitrate;            /* max bitrate index */
   float resample_ratio;           /* input_samp_rate/output_samp_rate */
@@ -273,10 +231,6 @@
   char bv_scf[576];
   
   int sfb21_extra; /* will be set in lame_init_params */
-  
-  amp_mode_t amp_mode; 
-
-  int is_mpeg1; /* 1 for MPEG-1, 0 for MPEG-2(.5) */
 
   /* variables used by util.c */
   /* BPC = maximum number of filter convolution windows to precompute */
@@ -453,7 +407,7 @@
 extern int  has_MMX   ( void );
 extern int  has_3DNow ( void );
 extern int  has_SIMD  ( void );
-extern int  has_SIMD2 ( void );
+
 
 extern void updateStats (lame_internal_flags *gfc);
 
diff -duHr lame.20001203/libmp3lame/vbrquantize.c lame.org/libmp3lame/vbrquantize.c
--- lame.20001203/libmp3lame/vbrquantize.c	Wed Nov 29 16:45:36 2000
+++ lame.org/libmp3lame/vbrquantize.c	Mon Dec  4 15:32:48 2000
@@ -19,7 +19,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
-/* $Id: vbrquantize.c,v 1.21 2000/11/25 18:56:35 robert Exp $ */
+/* $Id: vbrquantize.c,v 1.22 2000/12/03 23:00:14 markt Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
@@ -44,72 +44,17 @@
 #define MAGIC_FLOAT (65536*(128))
 #define MAGIC_INT    0x4b000000
 
-#ifdef TAKEHIRO_IEEE754_HACK
 
-#ifdef MAXQUANTERROR 
-#define DUFFBLOCK() do { \
-        xp = xr34[0] * sfpow34_p1; \
-        xe = xr34[0] * sfpow34_eq; \
-        xm = xr34[0] * sfpow34_m1; \
-        if (xm > IXMAX_VAL)  \
-            return -1; \
-        xp += MAGIC_FLOAT; \
-        xe += MAGIC_FLOAT; \
-        xm += MAGIC_FLOAT; \
-        fi[0].f = xp; \
-        fi[1].f = xe; \
-        fi[2].f = xm; \
-        fi[0].f = xp + (adj43asm - MAGIC_INT)[fi[0].i]; \
-        fi[1].f = xe + (adj43asm - MAGIC_INT)[fi[1].i]; \
-        fi[2].f = xm + (adj43asm - MAGIC_INT)[fi[2].i]; \
-        fi[0].i -= MAGIC_INT; \
-        fi[1].i -= MAGIC_INT; \
-        fi[2].i -= MAGIC_INT; \
-        x0 = fabs(xr[0]); \
-        xp = x0 - pow43[fi[0].i] * sfpow_p1; \
-        xe = x0 - pow43[fi[1].i] * sfpow_eq; \
-        xm = x0 - pow43[fi[2].i] * sfpow_m1; \
-        xp *= xp; \
-        xe *= xe; \
-        xm *= xm; \
-        xfsf_eq = Max(xfsf_eq, xe); \
-        xfsf_p1 = Max(xfsf_p1, xp); \
-        xfsf_m1 = Max(xfsf_m1, xm); \
-        ++xr; \
-        ++xr34; \
-    } while(0)  
-#else
-#define DUFFBLOCK() do { \
-        xp = xr34[0] * sfpow34_p1; \
-        xe = xr34[0] * sfpow34_eq; \
-        xm = xr34[0] * sfpow34_m1; \
-        if (xm > IXMAX_VAL)  \
-            return -1; \
-        xp += MAGIC_FLOAT; \
-        xe += MAGIC_FLOAT; \
-        xm += MAGIC_FLOAT; \
-        fi[0].f = xp; \
-        fi[1].f = xe; \
-        fi[2].f = xm; \
-        fi[0].f = xp + (adj43asm - MAGIC_INT)[fi[0].i]; \
-        fi[1].f = xe + (adj43asm - MAGIC_INT)[fi[1].i]; \
-        fi[2].f = xm + (adj43asm - MAGIC_INT)[fi[2].i]; \
-        fi[0].i -= MAGIC_INT; \
-        fi[1].i -= MAGIC_INT; \
-        fi[2].i -= MAGIC_INT; \
-        x0 = fabs(xr[0]); \
-        xp = x0 - pow43[fi[0].i] * sfpow_p1; \
-        xe = x0 - pow43[fi[1].i] * sfpow_eq; \
-        xm = x0 - pow43[fi[2].i] * sfpow_m1; \
-        xfsf_p1 += xp * xp; \
-        xfsf_eq += xe * xe; \
-        xfsf_m1 += xm * xm; \
-        ++xr; \
-        ++xr34; \
-    } while(0)  
+#ifndef TAKEHIRO_IEEE754_HACK
+
+
+#if (defined(__GNUC__) && defined(__i386__))
+#define USE_GNUC_ASM
+#endif
+#ifdef _MSC_VER
+#define USE_MSC_ASM
 #endif
 
-#else
 
 /*********************************************************************
  * XRPOW_FTOI is a macro to convert floats to ints.  
@@ -119,9 +64,29 @@
  * if XRPOW_FTOI(x) = floor(x), then QUANTFAC(x)=asj43[x]   
  *                                   ROUNDFAC=0.4054
  *********************************************************************/
+#ifdef USE_GNUC_ASM
+#  define QUANTFAC(rx)  adj43asm[rx]
+#  define ROUNDFAC -0.0946
+#  define XRPOW_FTOI(src, dest) \
+     __asm__ ("fistpl %0 " : "=m"(dest) : "t"(src) : "st")
+#elif defined (USE_MSC_ASM)
+#  define QUANTFAC(rx)  adj43asm[rx]
+#  define ROUNDFAC -0.0946
+#  define XRPOW_FTOI(src, dest) do { \
+     FLOAT8 src_ = (src); \
+     int dest_; \
+     { \
+       __asm fld src_ \
+       __asm fistp dest_ \
+     } \
+     (dest) = dest_; \
+   } while (0)
+#else
 #  define QUANTFAC(rx)  adj43[rx]
 #  define ROUNDFAC 0.4054
 #  define XRPOW_FTOI(src,dest) ((dest) = (int)(src))
+#endif
+
 
 
 #endif
@@ -133,6 +98,7 @@
 calc_sfb_noise(const FLOAT8 *xr, const FLOAT8 *xr34, const int bw, const int sf)
 {
   int j;
+//  int ix;
   fi_union fi; 
   FLOAT8 temp;
   FLOAT8 xfsf=0;
@@ -143,7 +109,6 @@
 
   for ( j=0; j < bw ; ++j) {
 #if 0
-    int ix;
     if (xr34[j]*sfpow34 > IXMAX_VAL) return -1;
     ix=floor( xr34[j]*sfpow34);
     temp = fabs(xr[j])- pow43[ix]*sfpow;
@@ -196,81 +161,84 @@
 static FLOAT8
 calc_sfb_noise_ave(const FLOAT8 *xr, const FLOAT8 *xr34, const int bw, const int sf)
 {
-    double xp;
-    double xe;
-    double xm;
-#ifdef TAKEHIRO_IEEE754_HACK
-    double x0;
-#endif
-    int xx[3], j;
-    fi_union *fi = (fi_union *)xx; 
-    FLOAT8 sfpow34_eq, sfpow34_p1, sfpow34_m1;
-    FLOAT8 sfpow_eq, sfpow_p1, sfpow_m1;
-    FLOAT8 xfsf_eq = 0, xfsf_p1 = 0, xfsf_m1 = 0;
+  int j;
+  fi_union fi; 
+  double temp,temp_p1,temp_m1;
+  FLOAT8 xfsf=0, xfsf_p1=0, xfsf_m1=0;
+  FLOAT8 sfpow34,sfpow34_p1,sfpow34_m1;
+  FLOAT8 sfpow,sfpow_p1,sfpow_m1;
 
-    sfpow_eq = POW20(sf + 210); /*pow(2.0,sf/4.0); */
-    sfpow_m1 = sfpow_eq * .8408964153;  /* pow(2,(sf-1)/4.0) */
-    sfpow_p1 = sfpow_eq * 1.189207115;  
-    
-    sfpow34_eq = IPOW20(sf + 210); /*pow(sfpow,-3.0/4.0);*/
-    sfpow34_m1 = sfpow34_eq * 1.13878863476;       /* .84089 ^ -3/4 */
-    sfpow34_p1 = sfpow34_eq * 0.878126080187;
+  sfpow = POW20(sf+210); /*pow(2.0,sf/4.0); */
+  sfpow34  = IPOW20(sf+210); /*pow(sfpow,-3.0/4.0);*/
 
-#ifdef TAKEHIRO_IEEE754_HACK
-    /*
-     *  loop unrolled into "Duff's Device".   Robert Hegemann
-     */    
-    j = (bw+3) / 4;
-    switch (bw % 4) {
-        default:
-        case 0: do{ DUFFBLOCK();
-        case 3:     DUFFBLOCK();
-        case 2:     DUFFBLOCK();
-        case 1:     DUFFBLOCK(); } while (--j);
-    }
-#else
-    for (j = 0; j < bw; ++j) {
+  sfpow_m1 = sfpow*.8408964153;  /* pow(2,(sf-1)/4.0) */
+  sfpow34_m1 = sfpow34*1.13878863476;       /* .84089 ^ -3/4 */
 
-        if (xr34[j]*sfpow34_m1 > IXMAX_VAL) return -1;
+  sfpow_p1 = sfpow*1.189207115;  
+  sfpow34_p1 = sfpow34*0.878126080187;
 
-        xe = xr34[j]*sfpow34_eq;
-        XRPOW_FTOI(xe, fi[0].i);
-        XRPOW_FTOI(xe + QUANTFAC(fi[0].i), fi[0].i);
-        xe = fabs(xr[j])- pow43[fi[0].i]*sfpow_eq;
-        xe *= xe;
+  for ( j=0; j < bw ; ++j) {
 
-        xp = xr34[j]*sfpow34_p1;
-        XRPOW_FTOI(xp, fi[0].i);
-        XRPOW_FTOI(xp + QUANTFAC(fi[0].i), fi[0].i);
-        xp = fabs(xr[j])- pow43[fi[0].i]*sfpow_p1;
-        xp *= xp;
+    if (xr34[j]*sfpow34_m1 > IXMAX_VAL) return -1;
 
-        xm = xr34[j]*sfpow34_m1;
-        XRPOW_FTOI(xm, fi[0].i);
-        XRPOW_FTOI(xm + QUANTFAC(fi[0].i), fi[0].i);
-        xm = fabs(xr[j])- pow43[fi[0].i]*sfpow_m1;
-        xm *= xm;
+#ifdef TAKEHIRO_IEEE754_HACK
+    temp   = xr34[j]*sfpow34;
+    temp  += MAGIC_FLOAT; 
+    fi.f  = temp;
+    fi.f  = temp + (adj43asm - MAGIC_INT)[fi.i];
+    fi.i -= MAGIC_INT;
+#else
+    temp = xr34[j]*sfpow34;
+    XRPOW_FTOI(temp, fi.i);
+    XRPOW_FTOI(temp + QUANTFAC(fi.i), fi.i);
+#endif
+    temp = fabs(xr[j])- pow43[fi.i]*sfpow;
+    temp *= temp;
 
-#ifdef MAXQUANTERROR
-        xfsf_eq = Max(xfsf,xm);
-        xfsf_p1 = Max(xfsf_p1,xp);
-        xfsf_m1 = Max(xfsf_m1,xm);
+#ifdef TAKEHIRO_IEEE754_HACK
+    temp_p1 = xr34[j]*sfpow34_p1;
+    temp_p1 += MAGIC_FLOAT; 
+    fi.f  = temp_p1;
+    fi.f  = temp_p1 + (adj43asm - MAGIC_INT)[fi.i];
+    fi.i -= MAGIC_INT;
 #else
-        xfsf_eq += xe;
-        xfsf_p1 += xp;
-        xfsf_m1 += xm;
+    temp_p1 = xr34[j]*sfpow34_p1;
+    XRPOW_FTOI(temp_p1, fi.i);
+    XRPOW_FTOI(temp_p1 + QUANTFAC(fi.i), fi.i);
 #endif
-    }
+    temp_p1 = fabs(xr[j])- pow43[fi.i]*sfpow_p1;
+    temp_p1 *= temp_p1;
+    
+#ifdef TAKEHIRO_IEEE754_HACK
+    temp_m1   = xr34[j]*sfpow34_m1;
+    temp_m1  += MAGIC_FLOAT; 
+    fi.f  = temp_m1;
+    fi.f  = temp_m1 + (adj43asm - MAGIC_INT)[fi.i];
+    fi.i -= MAGIC_INT;
+#else
+    temp_m1 = xr34[j]*sfpow34_m1;
+    XRPOW_FTOI(temp_m1, fi.i);
+    XRPOW_FTOI(temp_m1 + QUANTFAC(fi.i), fi.i);
 #endif
+    temp_m1 = fabs(xr[j])- pow43[fi.i]*sfpow_m1;
+    temp_m1 *= temp_m1;
 
-    if (xfsf_eq < xfsf_p1) 
-        xfsf_eq = xfsf_p1;
-    if (xfsf_eq < xfsf_m1) 
-        xfsf_eq = xfsf_m1;
 #ifdef MAXQUANTERROR
-    return xfsf_eq;
+    xfsf = Max(xfsf,temp);
+    xfsf_p1 = Max(xfsf_p1,temp_p1);
+    xfsf_m1 = Max(xfsf_m1,temp_m1);
 #else
-    return xfsf_eq/bw;
+    xfsf += temp;
+    xfsf_p1 += temp_p1;
+    xfsf_m1 += temp_m1;
+#endif
+  }
+  if (xfsf_p1>xfsf) xfsf = xfsf_p1;
+  if (xfsf_m1>xfsf) xfsf = xfsf_m1;
+#ifdef MAXQUANTERROR
+  return xfsf;
+#else
+  return xfsf/bw;
 #endif
 }
 
@@ -566,7 +534,7 @@
 
 static int
 VBR_quantize_granule( 
-          lame_internal_flags *gfc,
+          lame_global_flags *gfp,
           FLOAT8                 xr34[576], 
           int                    l3_enc[576],
     const III_psy_ratio  * const ratio,  
@@ -574,6 +542,7 @@
     const int gr, 
     const int ch)
 {
+  lame_internal_flags *gfc=gfp->internal_flags;
   int status;
   gr_info *cod_info;  
   III_side_info_t * l3_side;
@@ -582,7 +551,7 @@
 
 
   /* encode scalefacs */
-  if (gfc->is_mpeg1) 
+  if ( gfp->version == 1 ) 
     status=scale_bitcount(scalefac, cod_info);
   else
     status=scale_bitcount_lsf(scalefac, cod_info);
@@ -697,12 +666,13 @@
 
 static void 
 short_block_scalefacs (
-    const lame_internal_flags * const gfc,
+       lame_global_flags *gfp,
           gr_info        * const cod_info,
           III_scalefac_t * const scalefac,
           III_scalefac_t * const vbrsf,
           int            * const VBRmax )
 {
+    lame_internal_flags *gfc=gfp->internal_flags;
     const int * max_range;
     unsigned int sfb, b;
     int maxover, maxover0, maxover1, mover;
@@ -710,7 +680,7 @@
     int minsfb;
     int vbrmax = *VBRmax;
     
-    max_range = gfc->is_mpeg1 ? max_range_short : max_range_short_lsf;
+    max_range = gfp->version ? max_range_short : max_range_short_lsf;
     
     maxover0 = 0;
     maxover1 = 0;
@@ -751,7 +721,7 @@
             vbrsf->s[sfb][b] -= vbrmax;
         }
     }
-    if (gfc->is_mpeg1) 
+    if ( gfp->version == 1 ) 
         maxover = compute_scalefacs_short (vbrsf->s, cod_info, scalefac->s,
                                            cod_info->subblock_gain);
     else
@@ -788,12 +758,13 @@
 
 static void 
 long_block_scalefacs (
-    const lame_internal_flags * const gfc,
+    lame_global_flags *gfp,
           gr_info        * const cod_info,
           III_scalefac_t * const scalefac,
           III_scalefac_t * const vbrsf,
           int            * const VBRmax )
 {
+    lame_internal_flags *gfc=gfp->internal_flags;
     const int * max_range;
     const int * max_rangep;
     unsigned int sfb;
@@ -801,8 +772,8 @@
     int v0, v1, v0p, v1p;
     int vbrmax = *VBRmax;
 
-    max_range  = gfc->is_mpeg1 ? max_range_long : max_range_long_lsf;
-    max_rangep = gfc->is_mpeg1 ? max_range_long : max_range_long_lsf_pretab;
+    max_range  = gfp->version ? max_range_long : max_range_long_lsf;
+    max_rangep = gfp->version ? max_range_long : max_range_long_lsf_pretab;
     
     maxover0  = 0;
     maxover1  = 0;
@@ -864,7 +835,7 @@
     for (sfb = 0; sfb < SBPSY_l; sfb++)   
         vbrsf->l[sfb] -= vbrmax;
     
-    if (gfc->is_mpeg1) 
+    if ( gfp->version == 1 ) 
         maxover = compute_scalefacs_long (vbrsf->l, cod_info, scalefac->l);
     else
         maxover = compute_scalefacs_long_lsf (vbrsf->l, cod_info, scalefac->l);
@@ -930,20 +901,8 @@
         for (b = 0; b < 3; b++) {
             ifac = 8*cod_info->subblock_gain[b]+ifqstep*scalefac->s[sfb][b];
             fac = calc_fac( ifac );
-            /*
-             *  loop unrolled into "Duff's Device".  Robert Hegemann
-             */
-            l = (end-start+7) / 8;
-            switch ((end-start) % 8) {
-                default:
-                case 0: do{ xr34[j] = xr34_orig[j]*fac; j++;
-                case 7:     xr34[j] = xr34_orig[j]*fac; j++;
-                case 6:     xr34[j] = xr34_orig[j]*fac; j++;
-                case 5:     xr34[j] = xr34_orig[j]*fac; j++;
-                case 4:     xr34[j] = xr34_orig[j]*fac; j++;
-                case 3:     xr34[j] = xr34_orig[j]*fac; j++;
-                case 2:     xr34[j] = xr34_orig[j]*fac; j++;
-                case 1:     xr34[j] = xr34_orig[j]*fac; j++; } while (--l);
+            for ( l = start; l < end; l++ ) {
+                xr34[j] = xr34_orig[j]*fac; j++;
             }
         }
     }
@@ -959,7 +918,7 @@
     const FLOAT8                 xr34_orig[576],
           FLOAT8                 xr34     [576] )
 { 
-    unsigned int sfb, l, j;
+    unsigned int sfb, l;
     int    ifac, ifqstep, start, end;
     FLOAT8 fac;
         
@@ -974,21 +933,8 @@
 
         start = gfc->scalefac_band.l[ sfb ];
         end   = gfc->scalefac_band.l[ sfb+1 ];
-        /*
-         *  loop unrolled into "Duff's Device".  Robert Hegemann
-         */
-        j = start;
-        l = (end-start+7) / 8;
-        switch ((end-start) % 8) {
-            default:
-            case 0: do{ xr34[j] = xr34_orig[j]*fac; j++;
-            case 7:     xr34[j] = xr34_orig[j]*fac; j++;
-            case 6:     xr34[j] = xr34_orig[j]*fac; j++;
-            case 5:     xr34[j] = xr34_orig[j]*fac; j++;
-            case 4:     xr34[j] = xr34_orig[j]*fac; j++;
-            case 3:     xr34[j] = xr34_orig[j]*fac; j++;
-            case 2:     xr34[j] = xr34_orig[j]*fac; j++;
-            case 1:     xr34[j] = xr34_orig[j]*fac; j++; } while (--l);
+        for ( l = start; l < end; l++ ) {
+            xr34[l] = xr34_orig[l]*fac;
         }
     }
 }
@@ -1059,13 +1005,13 @@
         memset (scalefac, 0, sizeof(III_scalefac_t));
         
         if (shortblock) {
-            short_block_scalefacs (gfc, cod_info, scalefac, &vbrsf, &vbrmax);
+            short_block_scalefacs (gfp, cod_info, scalefac, &vbrsf, &vbrmax);
             short_block_xr34      (gfc, cod_info, scalefac, xr34orig, xr34);
         } else {
-            long_block_scalefacs (gfc, cod_info, scalefac, &vbrsf, &vbrmax);
+            long_block_scalefacs (gfp, cod_info, scalefac, &vbrsf, &vbrmax);
             long_block_xr34      (gfc, cod_info, scalefac, xr34orig, xr34);
         } 
-        VBR_quantize_granule (gfc, xr34, l3_enc, ratio, scalefac, gr, ch);
+        VBR_quantize_granule (gfp, xr34, l3_enc, ratio, scalefac, gr, ch);
 
         
         /* decrease noise until we use at least minbits
@@ -1092,7 +1038,7 @@
             ERRORF ("%ld impossible to encode ??? frame! bits=%d\n",
                     //  gfp->frameNum, cod_info->part2_3_length);
                              -1,       cod_info->part2_3_length);
-        VBR_quantize_granule (gfc, xr34, l3_enc, ratio, scalefac, gr, ch);
+        VBR_quantize_granule (gfp, xr34, l3_enc, ratio, scalefac, gr, ch);
 
         ++global_gain_adjust;
     }
@@ -1114,7 +1060,7 @@
  
 int
 VBR_noise_shaping2 (
-    lame_internal_flags *const gfc,
+    lame_global_flags        *gfp,
     FLOAT8                 xr       [576], 
     FLOAT8                 xr34orig [576],
     III_psy_ratio  * const ratio,
@@ -1127,6 +1073,7 @@
     int                    gr,
     int                    ch )
 {
+    lame_internal_flags *gfc=gfp->internal_flags;
     III_scalefac_t vbrsf;
     gr_info *cod_info;  
     FLOAT8 xr34[576];
@@ -1136,19 +1083,24 @@
     cod_info   = &gfc->l3_side.gr[gr].ch[ch].tt;
     shortblock = (cod_info->block_type == SHORT_TYPE);
       
-    if (shortblock) {
+    if (shortblock)
         vbrmax = short_block_vbr_sf (gfc, l3_xmin, xr34orig, xr, &vbrsf);  
-        short_block_scalefacs (gfc, cod_info, scalefac, &vbrsf, &vbrmax);
+    else
+        vbrmax = long_block_vbr_sf (gfc, l3_xmin, xr34orig, xr, &vbrsf);  
+
+    memset (scalefac, 0, sizeof(III_scalefac_t));
+
+    if (shortblock) {
+        short_block_scalefacs (gfp, cod_info, scalefac, &vbrsf, &vbrmax);
         short_block_xr34      (gfc, cod_info, scalefac, xr34orig, xr34);
     } else {
-        vbrmax = long_block_vbr_sf (gfc, l3_xmin, xr34orig, xr, &vbrsf);  
-        long_block_scalefacs (gfc, cod_info, scalefac, &vbrsf, &vbrmax);
+        long_block_scalefacs (gfp, cod_info, scalefac, &vbrsf, &vbrmax);
         long_block_xr34      (gfc, cod_info, scalefac, xr34orig, xr34);
     } 
     
     gfc->use_best_huffman = 0; /* we will do it later */
  
-    ret = VBR_quantize_granule (gfc, xr34, l3_enc, ratio, scalefac, gr, ch);
+    ret = VBR_quantize_granule (gfp, xr34, l3_enc, ratio, scalefac, gr, ch);
     
     gfc->use_best_huffman = best_huffman;
 
@@ -1234,7 +1186,7 @@
     if (gfc->mode_ext==MPG_MD_MS_LR) {
       ms_convert(xr[gr],xr[gr]);
     }
-    for (ch = 0; ch < gfc->channels_out; ch++) {
+    for (ch = 0; ch < gfc->stereo; ch++) {
       /* if in the following sections the quality would not be adjusted
        * then we would only have to call calc_xmin once here and
        * could drop subsequently calls (rh 2000/07/17)
@@ -1292,27 +1244,27 @@
     gfc->bitrate_index=gfc->VBR_min_bitrate;
   }
   getframebits(gfp, &bitsPerFrame, &mean_bits);
-  minbits = (mean_bits/gfc->channels_out);
+  minbits = (mean_bits/gfc->stereo);
 
   /* compute maximum allowed bits from max allowed bitrate */
   gfc->bitrate_index=gfc->VBR_max_bitrate;
   getframebits(gfp, &bitsPerFrame, &mean_bits);
   max_frame_bits = ResvFrameBegin(gfp, l3_side, mean_bits, bitsPerFrame);
-  maxbits=2.5*(mean_bits/gfc->channels_out);
+  maxbits=2.5*(mean_bits/gfc->stereo);
 
   {
   /* compute a target  mean_bits based on compression ratio 
    * which was set based on VBR_q  
    */
-  int bit_rate = gfp->out_samplerate*16*gfc->channels_out/(1000.0*gfp->compression_ratio);
+  int bit_rate = gfp->out_samplerate*16*gfc->stereo/(1000.0*gfp->compression_ratio);
   bitsPerFrame = (bit_rate*gfp->framesize*1000)/gfp->out_samplerate;
   mean_bits = (bitsPerFrame - 8*gfc->sideinfo_len) / gfc->mode_gr;
   }
 
 
   minbits = Max(minbits,125);
-  minbits=Max(minbits,.40*(mean_bits/gfc->channels_out));
-  maxbits=Min(maxbits,2.5*(mean_bits/gfc->channels_out));
+  minbits=Max(minbits,.40*(mean_bits/gfc->stereo));
+  maxbits=Min(maxbits,2.5*(mean_bits/gfc->stereo));
 
 
 
@@ -1355,13 +1307,13 @@
 #endif
 
 
-      for (ch = 0; ch < gfc->channels_out; ch++) { 
+      for (ch = 0; ch < gfc->stereo; ch++) { 
         int adjusted,shortblock;
         cod_info = &l3_side->gr[gr].ch[ch].tt;
         
         /* ENCODE this data first pass, and on future passes unless it uses
          * a very small percentage of the max_frame_bits  */
-        if (cod_info->part2_3_length > (max_frame_bits/(2*gfc->channels_out*gfc->mode_gr))) {
+        if (cod_info->part2_3_length > (max_frame_bits/(2*gfc->stereo*gfc->mode_gr))) {
   
           shortblock = (cod_info->block_type == SHORT_TYPE);
   
@@ -1423,7 +1375,7 @@
    * might enable scfsi which breaks the interation loops */
   totbits=0;
   for (gr = 0; gr < gfc->mode_gr; gr++) {
-    for (ch = 0; ch < gfc->channels_out; ch++) {
+    for (ch = 0; ch < gfc->stereo; ch++) {
       best_scalefac_store(gfc, gr, ch, l3_enc, l3_side, scalefac);
       totbits += l3_side->gr[gr].ch[ch].tt.part2_3_length;
     }
@@ -1451,7 +1403,7 @@
   //  DEBUGF("%i total_bits=%i max_frame_bits=%i index=%i  \n",gfp->frameNum,totbits,max_frame_bits,gfc->bitrate_index);
 
   for (gr = 0; gr < gfc->mode_gr; gr++) {
-    for (ch = 0; ch < gfc->channels_out; ch++) {
+    for (ch = 0; ch < gfc->stereo; ch++) {
       cod_info = &l3_side->gr[gr].ch[ch].tt;
 
 
diff -duHr lame.20001203/libmp3lame/version.h lame.org/libmp3lame/version.h
--- lame.20001203/libmp3lame/version.h	Wed Nov 29 16:45:36 2000
+++ lame.org/libmp3lame/version.h	Mon Dec  4 15:32:48 2000
@@ -35,7 +35,7 @@
 
 # define LAME_MAJOR_VERSION      3      /* Major version number */
 # define LAME_MINOR_VERSION     88      /* Minor version number */
-# define LAME_ALPHA_VERSION      9      /* Patch level of alpha version, otherwise zero */
+# define LAME_ALPHA_VERSION      8      /* Patch level of alpha version, otherwise zero */
 # define LAME_BETA_VERSION       0      /* Patch level of beta  version, otherwise zero */
 
 # define PSY_MAJOR_VERSION       0      /* Major version number */
diff -duHr lame.20001203/libmp3lame/vorbis_interface.c lame.org/libmp3lame/vorbis_interface.c
--- lame.20001203/libmp3lame/vorbis_interface.c	Wed Nov 29 16:44:27 2000
+++ lame.org/libmp3lame/vorbis_interface.c	Mon Dec  4 15:32:48 2000
@@ -1,4 +1,4 @@
-/* $Id: vorbis_interface.c,v 1.5 2000/11/26 10:50:00 robert Exp $ */
+/* $Id: vorbis_interface.c,v 1.6 2000/12/03 23:00:14 markt Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
@@ -363,7 +363,7 @@
     MSGF("Encoding with Vorbis mode info_A \n");
   }
 
-  vi2.channels = gfc->channels_out;
+  vi2.channels = gfc->stereo;
   vi2.rate = gfp->out_samplerate;
 
   
@@ -488,28 +488,25 @@
 
 
 
-int  lame_encode_ogg_frame (
-	lame_global_flags*  gfp,
-	const sample_t*     inbuf_l, 
-	const sample_t*     inbuf_r,
-	unsigned char*      mp3buf, 
-	size_t              mp3buf_size )
+int lame_encode_ogg_frame(lame_global_flags *gfp,
+			  short int inbuf_l[],short int inbuf_r[],
+			  char *mp3buf, int mp3buf_size)
 {
 
-    lame_internal_flags *gfc = gfp->internal_flags;
-    int  i;
-    int  eos   = 0;
-    int  bytes = 0;
+  lame_internal_flags *gfc=gfp->internal_flags;
+  long i;
+  int eos=0;
+  int bytes=0;
   
-    /* expose the buffer to submit data */
-    double **buffer = vorbis_analysis_buffer(&vd2,gfp->framesize);
+  /* expose the buffer to submit data */
+  double **buffer=vorbis_analysis_buffer(&vd2,gfp->framesize);
   
-    /* change level of input by -90 dB (no de-interleaving!) */
-    for ( i = 0; i < gfp->framesize; i++ )
-        buffer [0] [i] = (1/32768.) * inbuf_l [i];
-    if ( gfc->channels_out == 2 )
-        for ( i = 0; i < gfp->framesize; i++ )
-            buffer [1] [i] = (1/32768.) * inbuf_r [i];
+  /* uninterleave samples */
+  for(i=0;i<gfp->framesize;i++){
+    buffer[0][i]=(double)inbuf_l[i]/32768.0;
+    if (gfc->stereo==2)
+      buffer[1][i]=(double)inbuf_r[i]/32768.0;
+  }
   
   /* tell the library how much we actually submitted */
   vorbis_analysis_wrote(&vd2,i);
diff -duHr lame.20001203/mpglib/Makefile.am lame.org/mpglib/Makefile.am
--- lame.20001203/mpglib/Makefile.am	Thu Nov 30 11:20:28 2000
+++ lame.org/mpglib/Makefile.am	Mon Dec  4 15:32:49 2000
@@ -1,4 +1,4 @@
-## $Id: Makefile.am,v 1.5 2000/11/30 10:07:03 aleidinger Exp $
+## $Id: Makefile.am,v 1.6 2000/12/03 23:00:15 markt Exp $
 
 AUTOMAKE_OPTIONS = foreign $(top_srcdir)/ansi2knr
 
@@ -32,15 +32,7 @@
 	mpglib.h \
 	tabinit.h
 
-LCLINTFLAGS= \
-	+posixlib \
-	+showsummary \
-	+showalluses \
-	+whichlib \
-	+forcehints \
-	-fixedformalarray \
-	+matchanyintegral \
-	-Dlint
+LCLINTFLAGS= +posixlib +showsummary +showalluses +whichlib +forcehints -Dlint
 
 lclint.txt: ${libmpgdecoder_la_SOURCES} ${noinst_HEADERS}
 	@lclint ${LCLINTFLAGS} ${INCLUDES} ${DEFS} ${libmpgdecoder_la_SOURCES} 2>&1 >lclint.txt || true
diff -duHr lame.20001203/mpglib/interface.c lame.org/mpglib/interface.c
--- lame.20001203/mpglib/interface.c	Wed Nov 29 16:44:45 2000
+++ lame.org/mpglib/interface.c	Mon Dec  4 15:32:49 2000
@@ -1,4 +1,4 @@
-/* $Id: interface.c,v 1.28 2000/11/26 10:50:00 robert Exp $ */
+/* $Id: interface.c,v 1.29 2000/12/03 23:00:15 markt Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
@@ -67,7 +67,7 @@
 	}
 }
 
-static struct buf *addbuf( PMPSTR mp, unsigned char *buf,int size)
+static struct buf *addbuf( PMPSTR mp,char *buf,int size)
 {
 	struct buf *nbuf;
 
@@ -290,7 +290,7 @@
 
 
 
-int decodeMP3( PMPSTR mp,unsigned char *in,int isize,char *out,
+int decodeMP3( PMPSTR mp,char *in,int isize,char *out,
 		int osize,int *done)
 {
 	int i,iret,bits,bytes;
diff -duHr lame.20001203/mpglib/interface.h lame.org/mpglib/interface.h
--- lame.20001203/mpglib/interface.h	Wed Nov 29 16:44:45 2000
+++ lame.org/mpglib/interface.h	Mon Dec  4 15:32:49 2000
@@ -22,7 +22,7 @@
 #include "common.h"
 
 BOOL InitMP3(PMPSTR mp);
-int	 decodeMP3(PMPSTR mp,unsigned char *inmemory,int inmemsize,char *outmemory,int outmemsize,int *done);
+int	 decodeMP3(PMPSTR mp,char *inmemory,int inmemsize,char *outmemory,int outmemsize,int *done);
 void ExitMP3(PMPSTR mp);
 
 /* added remove_buf to support mpglib seeking */
Binary files lame.20001203/testcase.mp3 and lame.org/testcase.mp3 differ
