[xiph-commits] r10202 - in trunk/oggdsf/src/lib/codecs/speex/libs/libspeex: . doc include include/speex libspeex src symbian win32 win32/libspeex win32/speexdec win32/speexenc

illiminable at svn.xiph.org illiminable at svn.xiph.org
Thu Oct 20 05:44:55 PDT 2005


Author: illiminable
Date: 2005-10-20 05:42:06 -0700 (Thu, 20 Oct 2005)
New Revision: 10202

Added:
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/Speex.kdevelop
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/config.h.in
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/configure.ac
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_config_types.h.in
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_echo.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_jitter.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_preprocess.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_types.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/arch.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/cb_search_arm4.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/cb_search_bfin.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/cb_search_sse.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/filters_arm4.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/filters_bfin.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/fixed_arm4.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/fixed_arm5e.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/fixed_bfin.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/fixed_debug.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/fixed_generic.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/jitter.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/lbr_48k_tables.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/lpc_bfin.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/ltp_arm4.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/ltp_bfin.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/mdf.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/misc_bfin.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/preprocess.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/smallft.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/smallft.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/speex.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/testdenoise.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/testecho.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/vq_arm4.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/vq_bfin.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/vq_sse.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/symbian/
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/symbian/Makefile.am
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/symbian/Makefile.in
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/symbian/bld.inf
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/symbian/config.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/symbian/speex.mmp
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/config.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/libspeex/libspeex_dynamic.dsp
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/libspeex/speex.def
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/speex.iss
Modified:
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/AUTHORS
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/COPYING
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/ChangeLog
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/INSTALL
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/Makefile.am
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/Makefile.in
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/Speex.spec
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/Speex.spec.in
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/TODO
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/acinclude.m4
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/aclocal.m4
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/config.guess
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/config.sub
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/configure
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/depcomp
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/doc/Makefile.in
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/doc/manual.pdf
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/Makefile.am
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/Makefile.in
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/Makefile.am
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/Makefile.in
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_bits.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_header.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_stereo.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/install-sh
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/Makefile.am
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/Makefile.in
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/bits.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/cb_search.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/cb_search.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/exc_10_16_table.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/exc_10_32_table.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/exc_20_32_table.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/exc_5_256_table.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/exc_5_64_table.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/exc_8_128_table.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/filters.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/filters.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/filters_sse.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/gain_table.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/gain_table_lbr.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/hexc_10_32_table.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/hexc_table.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/high_lsp_tables.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/lpc.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/lpc.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/lsp.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/lsp.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/lsp_tables_nb.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/ltp.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/ltp.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/ltp_sse.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/math_approx.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/math_approx.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/misc.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/misc.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/modes.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/modes.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/nb_celp.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/nb_celp.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/quant_lsp.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/quant_lsp.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/sb_celp.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/sb_celp.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/speex_callbacks.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/speex_header.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/stack_alloc.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/stereo.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/testenc.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/testenc_uwb.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/testenc_wb.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/vbr.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/vbr.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/vq.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/vq.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/ltmain.sh
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/missing
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/speex.m4
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/speex.pc.in
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/Makefile.am
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/Makefile.in
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/speexdec.1
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/speexdec.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/speexenc.1
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/speexenc.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/wav_io.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/wav_io.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/wave_out.c
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/wave_out.h
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/Makefile.am
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/Makefile.in
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/libspeex/Makefile.am
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/libspeex/Makefile.in
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/libspeex/libspeex.dsp
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/libspeex/libspeex.dsw
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/libspeex/libspeex.vcproj
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/speexdec/Makefile.in
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/speexdec/speexdec.dsp
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/speexenc/Makefile.in
   trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/speexenc/speexenc.dsp
Log:
* Update lib speex. meep !

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/AUTHORS
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/AUTHORS	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/AUTHORS	2005-10-20 12:42:06 UTC (rev 10202)
@@ -8,6 +8,9 @@
 John Francis Edwards:
    wave_out.[ch], some #ifdefs for windows port and MSVC project files
 
+Segher Boessenkool
+   Misc. optimizations (for QMF in particular)
+
 Atsuhiko Yamanaka <ymnk at jcraft.com>:
    Patch to speexenc.c to add Vorbis comment format
 

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/COPYING
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/COPYING	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/COPYING	2005-10-20 12:42:06 UTC (rev 10202)
@@ -1,3 +1,10 @@
+Copyright 2002-2005 
+        Xiph.org Foundation
+        Jean-Marc Valin
+        David Rowe
+        EpicGames
+        Analog Devices
+
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions
 are met:

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/ChangeLog
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/ChangeLog	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/ChangeLog	2005-10-20 12:42:06 UTC (rev 10202)
@@ -1,3 +1,12 @@
+2004-02-18 Jean-Marc Valin <jean-marc.valin at usherbrooke.ca>
+	Patch for compiling with mingw32 sent by j at thing.net 
+
+2004-02-18 Jean-Marc Valin <jean-marc.valin at usherbrooke.ca>
+	Integrated IRIX patch (getopt stuff) from Michael Pruett <michael at 68k.org> 
+
+2004-02-18 Jean-Marc Valin <jean-marc.valin at usherbrooke.ca>
+	Changed the Makefile.am so that KDevelop can parse SUBDIRS correctly 
+
 2002/03/27 Jean-Marc Valin:
 Working encoder and decoder for both narrowband and wideband.
 

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/INSTALL
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/INSTALL	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/INSTALL	2005-10-20 12:42:06 UTC (rev 10202)
@@ -4,5 +4,5 @@
 % make
 % make install
 
-Note that if you are using the code from CVS, you will need to run "autogen.sh"
+Note that if you are using the code from SVN, you will need to run "autogen.sh"
 instead of "configure".

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/Makefile.am
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/Makefile.am	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/Makefile.am	2005-10-20 12:42:06 UTC (rev 10202)
@@ -1,7 +1,8 @@
 ## Process this file with automake to produce Makefile.in. -*-Makefile-*-
 
-# Disable automatic dependency tracking if using other tools than gcc and gmake
-#AUTOMAKE_OPTIONS = no-dependencies
+# To disable automatic dependency tracking if using other tools than
+# gcc and gmake, add the option 'no-dependencies'
+AUTOMAKE_OPTIONS = 1.8
 
 m4datadir = $(datadir)/aclocal
 m4data_DATA = speex.m4
@@ -9,11 +10,12 @@
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = speex.pc
 
-EXTRA_DIST = Speex.spec Speex.spec.in speex.m4 speex.pc.in
+EXTRA_DIST = Speex.spec Speex.spec.in Speex.kdevelop speex.m4 speex.pc.in
 
-SUBDIRS = libspeex include @src@ doc win32
+#Fools KDevelop into including all files
+SUBDIRS = libspeex include @src@ doc win32 symbian
 
-DIST_SUBDIRS = libspeex include src doc win32
+DIST_SUBDIRS = libspeex include src doc win32 symbian
 
 rpm: dist
 	rpmbuild -ta ${PACKAGE}-${VERSION}.tar.gz

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/Makefile.in
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/Makefile.in	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/Makefile.in	2005-10-20 12:42:06 UTC (rev 10202)
@@ -14,9 +14,6 @@
 
 @SET_MAKE@
 
-# Disable automatic dependency tracking if using other tools than gcc and gmake
-#AUTOMAKE_OPTIONS = no-dependencies
-
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
@@ -40,18 +37,20 @@
 host_triplet = @host@
 DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
 	$(srcdir)/Makefile.in $(srcdir)/Speex.spec.in \
-	$(srcdir)/speex.pc.in $(top_srcdir)/configure AUTHORS COPYING \
-	ChangeLog INSTALL NEWS TODO config.guess config.sub depcomp \
-	install-sh ltmain.sh missing mkinstalldirs
+	$(srcdir)/config.h.in $(srcdir)/speex.pc.in \
+	$(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \
+	TODO config.guess config.sub depcomp install-sh ltmain.sh \
+	missing mkinstalldirs
 subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
  configure.lineno configure.status.lineno
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = config.h
 CONFIG_CLEAN_FILES = Speex.spec speex.pc
 SOURCES =
 DIST_SOURCES =
@@ -122,8 +121,7 @@
 MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 OBJEXT = @OBJEXT@
-OGG_INCLUDES = @OGG_INCLUDES@
-OGG_LDFLAGS = @OGG_LDFLAGS@
+OGG_CFLAGS = @OGG_CFLAGS@
 OGG_LIBS = @OGG_LIBS@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -135,9 +133,12 @@
 RANLIB = @RANLIB@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
+SIZE16 = @SIZE16@
+SIZE32 = @SIZE32@
 SPEEX_LT_AGE = @SPEEX_LT_AGE@
 SPEEX_LT_CURRENT = @SPEEX_LT_CURRENT@
 SPEEX_LT_REVISION = @SPEEX_LT_REVISION@
+SPEEX_VERSION = @SPEEX_VERSION@
 STRIP = @STRIP@
 VERSION = @VERSION@
 ac_ct_AR = @ac_ct_AR@
@@ -182,15 +183,22 @@
 src = @src@
 sysconfdir = @sysconfdir@
 target_alias = @target_alias@
+
+# To disable automatic dependency tracking if using other tools than
+# gcc and gmake, add the option 'no-dependencies'
+AUTOMAKE_OPTIONS = 1.8
 m4datadir = $(datadir)/aclocal
 m4data_DATA = speex.m4
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = speex.pc
-EXTRA_DIST = Speex.spec Speex.spec.in speex.m4 speex.pc.in
-SUBDIRS = libspeex include @src@ doc win32
-DIST_SUBDIRS = libspeex include src doc win32
-all: all-recursive
+EXTRA_DIST = Speex.spec Speex.spec.in Speex.kdevelop speex.m4 speex.pc.in
 
+#Fools KDevelop into including all files
+SUBDIRS = libspeex include @src@ doc win32 symbian
+DIST_SUBDIRS = libspeex include src doc win32 symbian
+all: config.h
+	$(MAKE) $(AM_MAKEFLAGS) all-recursive
+
 .SUFFIXES:
 am--refresh:
 	@:
@@ -225,6 +233,23 @@
 	cd $(srcdir) && $(AUTOCONF)
 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
 	cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+
+config.h: stamp-h1
+	@if test ! -f $@; then \
+	  rm -f stamp-h1; \
+	  $(MAKE) stamp-h1; \
+	else :; fi
+
+stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
+	@rm -f stamp-h1
+	cd $(top_builddir) && $(SHELL) ./config.status config.h
+$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) 
+	cd $(top_srcdir) && $(AUTOHEADER)
+	rm -f stamp-h1
+	touch $@
+
+distclean-hdr:
+	-rm -f config.h stamp-h1
 Speex.spec: $(top_builddir)/config.status $(srcdir)/Speex.spec.in
 	cd $(top_builddir) && $(SHELL) ./config.status $@
 speex.pc: $(top_builddir)/config.status $(srcdir)/speex.pc.in
@@ -343,7 +368,7 @@
 	mkid -fID $$unique
 tags: TAGS
 
-TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
 	here=`pwd`; \
@@ -360,7 +385,7 @@
 	      tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
 	  fi; \
 	done; \
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
@@ -372,11 +397,11 @@
 	    $$tags $$unique; \
 	fi
 ctags: CTAGS
-CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
 	here=`pwd`; \
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 	  done | \
@@ -397,7 +422,7 @@
 distdir: $(DISTFILES)
 	$(am__remove_distdir)
 	mkdir $(distdir)
-	$(mkdir_p) $(distdir)/.
+	$(mkdir_p) $(distdir)/. $(distdir)/include/speex
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
 	list='$(DISTFILES)'; for file in $$list; do \
@@ -536,7 +561,7 @@
 	       exit 1; } >&2
 check-am: all-am
 check: check-recursive
-all-am: Makefile $(DATA)
+all-am: Makefile $(DATA) config.h
 installdirs: installdirs-recursive
 installdirs-am:
 	for dir in "$(DESTDIR)$(m4datadir)" "$(DESTDIR)$(pkgconfigdir)"; do \
@@ -573,8 +598,8 @@
 distclean: distclean-recursive
 	-rm -f $(am__CONFIG_DISTCLEAN_FILES)
 	-rm -f Makefile
-distclean-am: clean-am distclean-generic distclean-libtool \
-	distclean-tags
+distclean-am: clean-am distclean-generic distclean-hdr \
+	distclean-libtool distclean-tags
 
 dvi: dvi-recursive
 
@@ -623,18 +648,18 @@
 	check-am clean clean-generic clean-libtool clean-recursive \
 	ctags ctags-recursive dist dist-all dist-bzip2 dist-gzip \
 	dist-shar dist-tarZ dist-zip distcheck distclean \
-	distclean-generic distclean-libtool distclean-recursive \
-	distclean-tags distcleancheck distdir distuninstallcheck dvi \
-	dvi-am html html-am info info-am install install-am \
-	install-data install-data-am install-exec install-exec-am \
-	install-info install-info-am install-m4dataDATA install-man \
-	install-pkgconfigDATA install-strip installcheck \
-	installcheck-am installdirs installdirs-am maintainer-clean \
-	maintainer-clean-generic maintainer-clean-recursive \
-	mostlyclean mostlyclean-generic mostlyclean-libtool \
-	mostlyclean-recursive pdf pdf-am ps ps-am tags tags-recursive \
-	uninstall uninstall-am uninstall-info-am uninstall-m4dataDATA \
-	uninstall-pkgconfigDATA
+	distclean-generic distclean-hdr distclean-libtool \
+	distclean-recursive distclean-tags distcleancheck distdir \
+	distuninstallcheck dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-exec \
+	install-exec-am install-info install-info-am \
+	install-m4dataDATA install-man install-pkgconfigDATA \
+	install-strip installcheck installcheck-am installdirs \
+	installdirs-am maintainer-clean maintainer-clean-generic \
+	maintainer-clean-recursive mostlyclean mostlyclean-generic \
+	mostlyclean-libtool mostlyclean-recursive pdf pdf-am ps ps-am \
+	tags tags-recursive uninstall uninstall-am uninstall-info-am \
+	uninstall-m4dataDATA uninstall-pkgconfigDATA
 
 
 rpm: dist

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/Speex.kdevelop
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/Speex.kdevelop	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/Speex.kdevelop	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,123 @@
+<?xml version = '1.0'?>
+<kdevelop>
+  <general>
+    <author>Jean-Marc Valin</author>
+    <email>jean-marc.valin at usherbrooke.ca</email>
+    <version>$VERSION$</version>
+    <projectmanagement>KDevAutoProject</projectmanagement>
+    <primarylanguage>C</primarylanguage>
+    <ignoreparts/>
+    <projectdirectory>.</projectdirectory>
+    <absoluteprojectpath>false</absoluteprojectpath>
+    <description/>
+    <secondaryLanguages/>
+  </general>
+  <kdevautoproject>
+    <general>
+      <activetarget>src/Speex</activetarget>
+      <useconfiguration>default</useconfiguration>
+    </general>
+    <run>
+      <mainprogram>src/Speex</mainprogram>
+      <directoryradio>executable</directoryradio>
+      <customdirectory>/</customdirectory>
+      <programargs/>
+      <terminal>false</terminal>
+      <autocompile>true</autocompile>
+      <envvars/>
+    </run>
+    <configurations>
+      <optimized>
+        <builddir>optimized</builddir>
+        <ccompiler>GccOptions</ccompiler>
+        <cxxcompiler>GppOptions</cxxcompiler>
+        <f77compiler>G77Options</f77compiler>
+        <cflags>-O2 -g0</cflags>
+      </optimized>
+      <debug>
+        <configargs>--enable-debug=full</configargs>
+        <builddir>debug</builddir>
+        <ccompiler>GccOptions</ccompiler>
+        <cxxcompiler>GppOptions</cxxcompiler>
+        <f77compiler>G77Options</f77compiler>
+        <cflags>-O0 -g3</cflags>
+      </debug>
+    </configurations>
+    <make>
+      <envvars>
+        <envvar value="1" name="WANT_AUTOCONF_2_5" />
+        <envvar value="1" name="WANT_AUTOMAKE_1_6" />
+      </envvars>
+      <abortonerror>false</abortonerror>
+      <numberofjobs>1</numberofjobs>
+      <dontact>false</dontact>
+      <makebin/>
+    </make>
+  </kdevautoproject>
+  <kdevdebugger>
+    <general>
+      <dbgshell>libtool</dbgshell>
+      <programargs/>
+      <gdbpath/>
+      <configGdbScript/>
+      <runShellScript/>
+      <runGdbScript/>
+      <breakonloadinglibs>true</breakonloadinglibs>
+      <separatetty>false</separatetty>
+      <floatingtoolbar>false</floatingtoolbar>
+    </general>
+    <display>
+      <staticmembers>false</staticmembers>
+      <demanglenames>true</demanglenames>
+    </display>
+  </kdevdebugger>
+  <kdevfilecreate>
+    <filetypes/>
+    <useglobaltypes>
+      <type ext="c" />
+      <type ext="h" />
+    </useglobaltypes>
+  </kdevfilecreate>
+  <kdevcppsupport>
+    <references/>
+    <codecompletion>
+      <includeGlobalFunctions>true</includeGlobalFunctions>
+      <includeTypes>true</includeTypes>
+      <includeEnums>true</includeEnums>
+      <includeTypedefs>false</includeTypedefs>
+      <automaticCodeCompletion>true</automaticCodeCompletion>
+      <automaticArgumentsHint>true</automaticArgumentsHint>
+      <automaticHeaderCompletion>true</automaticHeaderCompletion>
+      <codeCompletionDelay>250</codeCompletionDelay>
+      <argumentsHintDelay>400</argumentsHintDelay>
+      <headerCompletionDelay>250</headerCompletionDelay>
+    </codecompletion>
+  </kdevcppsupport>
+  <kdevfileview>
+    <groups>
+      <hidenonprojectfiles>false</hidenonprojectfiles>
+      <hidenonlocation>false</hidenonlocation>
+    </groups>
+    <tree>
+      <hidepatterns>*.o,*.lo,CVS</hidepatterns>
+      <hidenonprojectfiles>true</hidenonprojectfiles>
+    </tree>
+  </kdevfileview>
+  <kdevdoctreeview>
+    <projectdoc>
+      <userdocDir>html/</userdocDir>
+      <apidocDir>html/</apidocDir>
+    </projectdoc>
+    <ignoreqt_xml/>
+    <ignoredoxygen/>
+    <ignorekdocs/>
+    <ignoretocs/>
+    <ignoredevhelp/>
+  </kdevdoctreeview>
+  <cppsupportpart>
+    <filetemplates>
+      <interfacesuffix>.h</interfacesuffix>
+      <implementationsuffix>.cpp</implementationsuffix>
+    </filetemplates>
+  </cppsupportpart>
+</kdevelop>

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/Speex.spec
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/Speex.spec	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/Speex.spec	2005-10-20 12:42:06 UTC (rev 10202)
@@ -1,5 +1,5 @@
 %define name     speex
-%define ver      1.0.4
+%define ver      1.1.10
 %define rel      1
 
 Summary: An open-source, patent-free speech codec
@@ -41,7 +41,7 @@
 %setup
 
 %build
-export CFLAGS='-O3 -DRELEASE'
+export CFLAGS='-O3'
 ./configure --prefix=/usr --enable-shared --enable-static
 make
 
@@ -64,7 +64,6 @@
 %files devel
 %defattr(644,root,root,755)
 %attr(755,root,root) %{_libdir}/libspeex*.la
-%{_includedir}/speex*.h
 %{_includedir}/speex/speex*.h
 /usr/share/aclocal/speex.m4
 %{_libdir}/pkgconfig/speex.pc

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/Speex.spec.in
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/Speex.spec.in	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/Speex.spec.in	2005-10-20 12:42:06 UTC (rev 10202)
@@ -41,7 +41,7 @@
 %setup
 
 %build
-export CFLAGS='-O3 -DRELEASE'
+export CFLAGS='-O3'
 ./configure --prefix=/usr --enable-shared --enable-static
 make
 
@@ -64,7 +64,6 @@
 %files devel
 %defattr(644,root,root,755)
 %attr(755,root,root) %{_libdir}/libspeex*.la
-%{_includedir}/speex*.h
 %{_includedir}/speex/speex*.h
 /usr/share/aclocal/speex.m4
 %{_libdir}/pkgconfig/speex.pc

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/TODO
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/TODO	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/TODO	2005-10-20 12:42:06 UTC (rev 10202)
@@ -1,18 +1,35 @@
+Allocator override (speex_lib_ctl)
+Support alloca/variable size arrays
+Better error handling
+Fixed-point:
+  - Packet-loss concealment
+  - Wideband
+  - Initialization
+  - Jitter buffer
+Echo cancellation:
+  - Re-enable denoiser hooks
+  - Improve doubletalk detector
+Denoiser:
+  - Fix hyper-geometric approximation
+  - Do some tuning
+VAD-NG:
+  - Use median filtering instead of "non-linear mean"
+
+
+
 Features
 -Add maximum/minimum bit-rate control for VBR
 -Get the encoder to use the rate of packet loss (more conservative pitch gains)
+-Improve error handling (with perror-like call?)
 
 Long-term quality improvements
 -Improve perceptual enhancement (including wideband)
 
 Standards
-*Complete Speex RTP profile
+-Complete Speex RTP profile
 -MIME type registration
--MS ACM wrapper
 
-*required for 1.0
-
 ideas:
 Peelable stream (double codebook, higher bands, stereo)
 LPC from spectral domain
-Better psycho-acoustics? Masking curve from Vorbis
+Better psycho-acoustic model. Masking curve from Vorbis?

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/acinclude.m4
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/acinclude.m4	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/acinclude.m4	2005-10-20 12:42:06 UTC (rev 10202)
@@ -1,84 +1,102 @@
-AC_DEFUN(AC_FIND_FILE,
-[
-$3=NONE
-for i in $2;
-do
-  for j in $1;
-  do
-    if test -r "$i/$j"; then
-      $3=$i
-      break 2
-    fi
-  done
-done
-])
+# Configure paths for libogg
+# Jack Moffitt <jack at icecast.org> 10-21-2000
+# Shamelessly stolen from Owen Taylor and Manish Singh
 
-AC_DEFUN(AC_PATH_LIBOGG,
-[
-OGG_LIBS="-logg"
+dnl XIPH_PATH_OGG([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
+dnl Test for libogg, and define OGG_CFLAGS and OGG_LIBS
+dnl
+AC_DEFUN([XIPH_PATH_OGG],
+[dnl 
+dnl Get the cflags and libraries
+dnl
+AC_ARG_WITH(ogg,[  --with-ogg=PFX   Prefix where libogg is installed (optional)], ogg_prefix="$withval", ogg_prefix="")
+AC_ARG_WITH(ogg-libraries,[  --with-ogg-libraries=DIR   Directory where libogg library is installed (optional)], ogg_libraries="$withval", ogg_libraries="")
+AC_ARG_WITH(ogg-includes,[  --with-ogg-includes=DIR   Directory where libogg header files are installed (optional)], ogg_includes="$withval", ogg_includes="")
+AC_ARG_ENABLE(oggtest, [  --disable-oggtest       Do not try to compile and run a test Ogg program],, enable_oggtest=yes)
 
-AC_MSG_CHECKING([for libogg])
+  if test "x$ogg_libraries" != "x" ; then
+    OGG_LIBS="-L$ogg_libraries"
+  elif test "x$ogg_prefix" != "x" ; then
+    OGG_LIBS="-L$ogg_prefix/lib"
+  elif test "x$prefix" != "xNONE" ; then
+    OGG_LIBS="-L$prefix/lib"
+  fi
 
-ac_ogg_includes=NONE ac_ogg_libraries=NONE ac_ogg_bindir=NONE
-ogg_libraries=""
-ogg_includes=""
-AC_ARG_WITH(ogg-dir,
-    [  --with-ogg-dir=DIR       where the root of OGG is installed ],
-    [  ac_ogg_includes="$withval"/include
-       ac_ogg_libraries="$withval"/lib
-    ])
+  OGG_LIBS="$OGG_LIBS -logg"
 
-AC_ARG_WITH(ogg-includes,
-    [  --with-ogg-includes=DIR  where the OGG includes are. ],
-    [  
-       ac_ogg_includes="$withval"
-    ])
-    
-ogg_libs_given=no
+  if test "x$ogg_includes" != "x" ; then
+    OGG_CFLAGS="-I$ogg_includes"
+  elif test "x$ogg_prefix" != "x" ; then
+    OGG_CFLAGS="-I$ogg_prefix/include"
+  elif test "x$prefix" != "xNONE"; then
+    OGG_CFLAGS="-I$prefix/include"
+  fi
 
-AC_ARG_WITH(ogg-libraries,
-    [  --with-ogg-libraries=DIR where the OGG library is installed.],
-    [  ac_ogg_libraries="$withval"
-       ogg_libs_given=yes
-    ])
+  AC_MSG_CHECKING(for Ogg)
+  no_ogg=""
 
-ogg_incdirs="/usr/include /usr/lib/ogg/include /opt/include /usr/local/ogg/include /usr/include/ogg /usr/include /usr/local/include"
-if test ! "$ac_ogg_includes" = "NONE"; then
-  ogg_incdirs="$ac_ogg_includes $ac_ogg_includes/.. $ogg_incdirs"
-fi
-AC_FIND_FILE(ogg/ogg.h, $ogg_incdirs, ogg_incdir)
-echo "Ogg includes in $ogg_incdir"
 
+  if test "x$enable_oggtest" = "xyes" ; then
+    ac_save_CFLAGS="$CFLAGS"
+    ac_save_LIBS="$LIBS"
+    CFLAGS="$CFLAGS $OGG_CFLAGS"
+    LIBS="$LIBS $OGG_LIBS"
+dnl
+dnl Now check if the installed Ogg is sufficiently new.
+dnl
+      rm -f conf.oggtest
+      AC_TRY_RUN([
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ogg/ogg.h>
 
-ogg_libdirs="$ac_ogg_libraries /usr/lib/ogg/lib /usr/lib /opt/lib /usr/local/ogg/lib /usr/local/lib /usr/lib/ogg /usr/local/lib"
-test -n "$OGGDIR" && ogg_libdirs="$OGGDIR/lib $OGGDIR $ogg_libdirs"
-if test ! "$ac_ogg_libraries" = "NONE"; then
-  ogg_libdirs="$ac_ogg_libraries $ogg_libdirs"
-fi
+int main ()
+{
+  system("touch conf.oggtest");
+  return 0;
+}
 
-test=NONE
-ogg_libdir=NONE
-for dir in $ogg_libdirs; do
-  try="ls -1 $dir/libogg*"
-  if test=`eval $try 2> /dev/null`; then ogg_libdir=$dir; break; else echo "tried $dir" >&AC_FD_CC ; fi
-done
+],, no_ogg=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
+       CFLAGS="$ac_save_CFLAGS"
+       LIBS="$ac_save_LIBS"
+  fi
 
-echo "Ogg libraries in $ogg_libdir"
-
-if test "$ogg_libdir" = "NONE" || test "$ogg_incdir" = "NONE"; then
-   have_libogg=no
-else
-   have_libogg=yes
-   AC_DEFINE(HAVE_LIBOGG)
-fi
-
-OGG_INCLUDES="-I$ogg_incdir"
-OGG_LDFLAGS="-L$ogg_libdir"
-
-
-AC_SUBST(OGG_LIBS)
-AC_SUBST(OGG_INCLUDES)
-AC_SUBST(OGG_LDFLAGS)
-
+  if test "x$no_ogg" = "x" ; then
+     AC_MSG_RESULT(yes)
+     ifelse([$1], , :, [$1])     
+  else
+     AC_MSG_RESULT(no)
+     if test -f conf.oggtest ; then
+       :
+     else
+       echo "*** Could not run Ogg test program, checking why..."
+       CFLAGS="$CFLAGS $OGG_CFLAGS"
+       LIBS="$LIBS $OGG_LIBS"
+       AC_TRY_LINK([
+#include <stdio.h>
+#include <ogg/ogg.h>
+],     [ return 0; ],
+       [ echo "*** The test program compiled, but did not run. This usually means"
+       echo "*** that the run-time linker is not finding Ogg or finding the wrong"
+       echo "*** version of Ogg. If it is not finding Ogg, you'll need to set your"
+       echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
+       echo "*** to the installed location  Also, make sure you have run ldconfig if that"
+       echo "*** is required on your system"
+       echo "***"
+       echo "*** If you have an old version installed, it is best to remove it, although"
+       echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
+       [ echo "*** The test program failed to compile or link. See the file config.log for the"
+       echo "*** exact error that occured. This usually means Ogg was incorrectly installed"
+       echo "*** or that you have moved Ogg since it was installed." ])
+       CFLAGS="$ac_save_CFLAGS"
+       LIBS="$ac_save_LIBS"
+     fi
+     OGG_CFLAGS=""
+     OGG_LIBS=""
+     ifelse([$2], , :, [$2])
+  fi
+  AC_SUBST(OGG_CFLAGS)
+  AC_SUBST(OGG_LIBS)
+  rm -f conf.oggtest
 ])
-

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/aclocal.m4
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/aclocal.m4	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/aclocal.m4	2005-10-20 12:42:06 UTC (rev 10202)
@@ -6317,6 +6317,30 @@
      [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
 ])
 
+# Like AC_CONFIG_HEADER, but automatically create stamp file. -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 2000, 2001, 2003 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 7
+
+# AM_CONFIG_HEADER is obsolete.  It has been replaced by AC_CONFIG_HEADERS.
+AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)])
+
 # Do all the work for Automake.                            -*- Autoconf -*-
 
 # This macro actually does too much some checks are only needed if

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/config.guess
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/config.guess	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/config.guess	2005-10-20 12:42:06 UTC (rev 10202)
@@ -1,9 +1,9 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+#   2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 
-timestamp='2004-03-12'
+timestamp='2005-04-22'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -53,7 +53,7 @@
 GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
@@ -203,15 +203,15 @@
     amiga:OpenBSD:*:*)
 	echo m68k-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
-    arc:OpenBSD:*:*)
-	echo mipsel-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
     cats:OpenBSD:*:*)
 	echo arm-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
     hp300:OpenBSD:*:*)
 	echo m68k-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
+    luna88k:OpenBSD:*:*)
+    	echo m88k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
     mac68k:OpenBSD:*:*)
 	echo m68k-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
@@ -227,21 +227,12 @@
     mvmeppc:OpenBSD:*:*)
 	echo powerpc-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
-    pegasos:OpenBSD:*:*)
-	echo powerpc-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
-    pmax:OpenBSD:*:*)
-	echo mipsel-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
     sgi:OpenBSD:*:*)
-	echo mipseb-unknown-openbsd${UNAME_RELEASE}
+	echo mips64-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
     sun3:OpenBSD:*:*)
 	echo m68k-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
-    wgrisc:OpenBSD:*:*)
-	echo mipsel-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
     *:OpenBSD:*:*)
 	echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
@@ -307,9 +298,6 @@
 	# 1.2 uses "1.2" for uname -r.
 	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
 	exit 0 ;;
-    Alpha*:OpenVMS:*:*)
-	echo alpha-hp-vms
-	exit 0 ;;
     Alpha\ *:Windows_NT*:*)
 	# How do we know it's Interix rather than the generic POSIX subsystem?
 	# Should we change UNAME_MACHINE based on the output of uname instead
@@ -331,6 +319,9 @@
     *:OS/390:*:*)
 	echo i370-ibm-openedition
 	exit 0 ;;
+    *:z/VM:*:*)
+	echo s390-ibm-zvmoe
+	exit 0 ;;
     *:OS400:*:*)
         echo powerpc-ibm-os400
 	exit 0 ;;
@@ -354,7 +345,7 @@
     DRS?6000:unix:4.0:6*)
 	echo sparc-icl-nx6
 	exit 0 ;;
-    DRS?6000:UNIX_SV:4.2*:7*)
+    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
 	case `/usr/bin/uname -p` in
 	    sparc) echo sparc-icl-nx7 && exit 0 ;;
 	esac ;;
@@ -764,7 +755,7 @@
 	echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
 	exit 0 ;;
     *:UNICOS/mp:*:*)
-	echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
 	exit 0 ;;
     F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
 	FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
@@ -787,21 +778,7 @@
 	echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
 	exit 0 ;;
     *:FreeBSD:*:*)
-	# Determine whether the default compiler uses glibc.
-	eval $set_cc_for_build
-	sed 's/^	//' << EOF >$dummy.c
-	#include <features.h>
-	#if __GLIBC__ >= 2
-	LIBC=gnu
-	#else
-	LIBC=
-	#endif
-EOF
-	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
-	# GNU/KFreeBSD systems have a "k" prefix to indicate we are using
-	# FreeBSD's kernel, but not the complete OS.
-	case ${LIBC} in gnu) kernel_only='k' ;; esac
-	echo ${UNAME_MACHINE}-unknown-${kernel_only}freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC}
+	echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
 	exit 0 ;;
     i*:CYGWIN*:*)
 	echo ${UNAME_MACHINE}-pc-cygwin
@@ -827,6 +804,9 @@
     i*:UWIN*:*)
 	echo ${UNAME_MACHINE}-pc-uwin
 	exit 0 ;;
+    amd64:CYGWIN*:*:*)
+	echo x86_64-unknown-cygwin
+	exit 0 ;;
     p*:CYGWIN*:*)
 	echo powerpcle-unknown-cygwin
 	exit 0 ;;
@@ -850,6 +830,12 @@
     cris:Linux:*:*)
 	echo cris-axis-linux-gnu
 	exit 0 ;;
+    crisv32:Linux:*:*)
+	echo crisv32-axis-linux-gnu
+	exit 0 ;;
+    frv:Linux:*:*)
+    	echo frv-unknown-linux-gnu
+	exit 0 ;;
     ia64:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit 0 ;;
@@ -1096,9 +1082,9 @@
     M680?0:D-NIX:5.3:*)
 	echo m68k-diab-dnix
 	exit 0 ;;
-    M68*:*:R3V[567]*:*)
+    M68*:*:R3V[5678]*:*)
 	test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
-    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0)
+    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
 	OS_REL=''
 	test -r /etc/.relid \
 	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
@@ -1154,6 +1140,10 @@
 	# From seanf at swdc.stratus.com.
 	echo i860-stratus-sysv4
 	exit 0 ;;
+    i*86:VOS:*:*)
+	# From Paul.Green at stratus.com.
+	echo ${UNAME_MACHINE}-stratus-vos
+	exit 0 ;;
     *:VOS:*:*)
 	# From Paul.Green at stratus.com.
 	echo hppa1.1-stratus-vos
@@ -1196,9 +1186,10 @@
 	echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
 	exit 0 ;;
     *:Darwin:*:*)
-	case `uname -p` in
+	UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+	case $UNAME_PROCESSOR in
 	    *86) UNAME_PROCESSOR=i686 ;;
-	    powerpc) UNAME_PROCESSOR=powerpc ;;
+	    unknown) UNAME_PROCESSOR=powerpc ;;
 	esac
 	echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
 	exit 0 ;;
@@ -1213,6 +1204,9 @@
     *:QNX:*:4*)
 	echo i386-pc-qnx
 	exit 0 ;;
+    NSE-?:NONSTOP_KERNEL:*:*)
+	echo nse-tandem-nsk${UNAME_RELEASE}
+	exit 0 ;;
     NSR-?:NONSTOP_KERNEL:*:*)
 	echo nsr-tandem-nsk${UNAME_RELEASE}
 	exit 0 ;;
@@ -1260,6 +1254,16 @@
     *:DragonFly:*:*)
 	echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
 	exit 0 ;;
+    *:*VMS:*:*)
+    	UNAME_MACHINE=`(uname -p) 2>/dev/null`
+	case "${UNAME_MACHINE}" in
+	    A*) echo alpha-dec-vms && exit 0 ;;
+	    I*) echo ia64-dec-vms && exit 0 ;;
+	    V*) echo vax-dec-vms && exit 0 ;;
+	esac ;;
+    *:XENIX:*:SysV)
+	echo i386-pc-xenix
+	exit 0 ;;
 esac
 
 #echo '(No uname command or uname output not recognized.)' 1>&2
@@ -1419,7 +1423,9 @@
 the operating system you are using. It is advised that you
 download the most up to date version of the config scripts from
 
-    ftp://ftp.gnu.org/pub/gnu/config/
+  http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
+and
+  http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
 
 If the version you run ($0) is already up to date, please
 send the following data and any information you think might be

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/config.h.in
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/config.h.in	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/config.h.in	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,147 @@
+/* config.h.in.  Generated from configure.ac by autoheader.  */
+
+/* Make use of ARM4 assembly optimizations */
+#undef ARM4_ASM
+
+/* Make use of ARM5E assembly optimizations */
+#undef ARM5_ASM
+
+/* Make use of Blackfin assembly optimizations */
+#undef BFIN_ASM
+
+/* Disable wideband codec */
+#undef DISABLE_WIDEBAND
+
+/* Enable valgrind extra checks */
+#undef ENABLE_VALGRIND
+
+/* Enable support for Epic 4.8 kbps mode */
+#undef EPIC_48K
+
+/* Debug fixed-point implementation */
+#undef FIXED_DEBUG
+
+/* Compile as fixed-point */
+#undef FIXED_POINT
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you have the `getopt_long' function. */
+#undef HAVE_GETOPT_LONG
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the `m' library (-lm). */
+#undef HAVE_LIBM
+
+/* Define to 1 if you have the `winmm' library (-lwinmm). */
+#undef HAVE_LIBWINMM
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the <sys/audioio.h> header file. */
+#undef HAVE_SYS_AUDIOIO_H
+
+/* Define to 1 if you have the <sys/soundcard.h> header file. */
+#undef HAVE_SYS_SOUNDCARD_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Reduce precision to 16 bits (EXPERIMENTAL) */
+#undef PRECISION16
+
+/* The size of a `int', as computed by sizeof. */
+#undef SIZEOF_INT
+
+/* The size of a `long', as computed by sizeof. */
+#undef SIZEOF_LONG
+
+/* The size of a `long long', as computed by sizeof. */
+#undef SIZEOF_LONG_LONG
+
+/* The size of a `short', as computed by sizeof. */
+#undef SIZEOF_SHORT
+
+/* Version extra */
+#undef SPEEX_EXTRA_VERSION
+
+/* Version major */
+#undef SPEEX_MAJOR_VERSION
+
+/* Version micro */
+#undef SPEEX_MICRO_VERSION
+
+/* Version minor */
+#undef SPEEX_MINOR_VERSION
+
+/* Complete version string */
+#undef SPEEX_VERSION
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Enable support for TI C55X DSP */
+#undef TI_C55X
+
+/* Make use of alloca */
+#undef USE_ALLOCA
+
+/* Use C99 variable-size arrays */
+#undef VAR_ARRAYS
+
+/* Define to 1 if your processor stores words with the most significant byte
+   first (like Motorola and SPARC, unlike Intel and VAX). */
+#undef WORDS_BIGENDIAN
+
+/* Enable SSE support */
+#undef _USE_SSE
+
+/* Define to empty if `const' does not conform to ANSI C. */
+#undef const
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+   calls it, or to nothing if 'inline' is not supported under any name.  */
+#ifndef __cplusplus
+#undef inline
+#endif
+
+/* Define to equivalent of C99 restrict keyword, or to nothing if this is not
+   supported. Do not define if restrict is supported directly. */
+#undef restrict

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/config.sub
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/config.sub	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/config.sub	2005-10-20 12:42:06 UTC (rev 10202)
@@ -1,9 +1,9 @@
 #! /bin/sh
 # Configuration validation subroutine script.
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+#   2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 
-timestamp='2004-03-12'
+timestamp='2005-04-22'
 
 # This file is (in principle) common to ALL GNU software.
 # The presence of a machine in this file suggests that SOME GNU software
@@ -70,7 +70,7 @@
 version="\
 GNU config.sub ($timestamp)
 
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
@@ -145,7 +145,7 @@
 	-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
 	-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
 	-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-	-apple | -axis)
+	-apple | -axis | -knuth | -cray)
 		os=
 		basic_machine=$1
 		;;
@@ -231,13 +231,14 @@
 	| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
 	| am33_2.0 \
 	| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
+	| bfin \
 	| c4x | clipper \
 	| d10v | d30v | dlx | dsp16xx \
 	| fr30 | frv \
 	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
 	| i370 | i860 | i960 | ia64 \
 	| ip2k | iq2000 \
-	| m32r | m32rle | m68000 | m68k | m88k | mcore \
+	| m32r | m32rle | m68000 | m68k | m88k | maxq | mcore \
 	| mips | mipsbe | mipseb | mipsel | mipsle \
 	| mips16 \
 	| mips64 | mips64el \
@@ -262,12 +263,13 @@
 	| pyramid \
 	| sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
 	| sh64 | sh64le \
-	| sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv8 | sparcv9 | sparcv9b \
+	| sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \
+	| sparcv8 | sparcv9 | sparcv9b \
 	| strongarm \
 	| tahoe | thumb | tic4x | tic80 | tron \
 	| v850 | v850e \
 	| we32k \
-	| x86 | xscale | xstormy16 | xtensa \
+	| x86 | xscale | xscalee[bl] | xstormy16 | xtensa \
 	| z8k)
 		basic_machine=$basic_machine-unknown
 		;;
@@ -298,9 +300,9 @@
 	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
 	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
 	| avr-* \
-	| bs2000-* \
+	| bfin-* | bs2000-* \
 	| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
-	| clipper-* | cydra-* \
+	| clipper-* | craynv-* | cydra-* \
 	| d10v-* | d30v-* | dlx-* \
 	| elxsi-* \
 	| f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
@@ -310,7 +312,7 @@
 	| ip2k-* | iq2000-* \
 	| m32r-* | m32rle-* \
 	| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
-	| m88110-* | m88k-* | mcore-* \
+	| m88110-* | m88k-* | maxq-* | mcore-* \
 	| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
 	| mips16-* \
 	| mips64-* | mips64el-* \
@@ -326,8 +328,9 @@
 	| mipsisa64sb1-* | mipsisa64sb1el-* \
 	| mipsisa64sr71k-* | mipsisa64sr71kel-* \
 	| mipstx39-* | mipstx39el-* \
+	| mmix-* \
 	| msp430-* \
-	| none-* | np1-* | nv1-* | ns16k-* | ns32k-* \
+	| none-* | np1-* | ns16k-* | ns32k-* \
 	| orion-* \
 	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
 	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
@@ -335,15 +338,16 @@
 	| romp-* | rs6000-* \
 	| sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \
 	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
-	| sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \
+	| sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \
+	| sparclite-* \
 	| sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
 	| tahoe-* | thumb-* \
 	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
 	| tron-* \
 	| v850-* | v850e-* | vax-* \
 	| we32k-* \
-	| x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \
-	| xtensa-* \
+	| x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \
+	| xstormy16-* | xtensa-* \
 	| ymp-* \
 	| z8k-*)
 		;;
@@ -445,6 +449,10 @@
 		basic_machine=j90-cray
 		os=-unicos
 		;;
+	craynv)
+		basic_machine=craynv-cray
+		os=-unicosmp
+		;;
 	cr16c)
 		basic_machine=cr16c-unknown
 		os=-elf
@@ -452,6 +460,9 @@
 	crds | unos)
 		basic_machine=m68k-crds
 		;;
+	crisv32 | crisv32-* | etraxfs*)
+		basic_machine=crisv32-axis
+		;;
 	cris | cris-* | etrax*)
 		basic_machine=cris-axis
 		;;
@@ -481,6 +492,10 @@
 		basic_machine=m88k-motorola
 		os=-sysv3
 		;;
+	djgpp)
+		basic_machine=i586-pc
+		os=-msdosdjgpp
+		;;
 	dpx20 | dpx20-*)
 		basic_machine=rs6000-bull
 		os=-bosx
@@ -659,10 +674,6 @@
 	mips3*)
 		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
 		;;
-	mmix*)
-		basic_machine=mmix-knuth
-		os=-mmixware
-		;;
 	monitor)
 		basic_machine=m68k-rom68k
 		os=-coff
@@ -743,10 +754,6 @@
 	np1)
 		basic_machine=np1-gould
 		;;
-	nv1)
-		basic_machine=nv1-cray
-		os=-unicosmp
-		;;
 	nsr-tandem)
 		basic_machine=nsr-tandem
 		;;
@@ -1029,6 +1036,10 @@
 		basic_machine=hppa1.1-winbond
 		os=-proelf
 		;;
+	xbox)
+		basic_machine=i686-pc
+		os=-mingw32
+		;;
 	xps | xps100)
 		basic_machine=xps100-honeywell
 		;;
@@ -1059,6 +1070,9 @@
 	romp)
 		basic_machine=romp-ibm
 		;;
+	mmix)
+		basic_machine=mmix-knuth
+		;;
 	rs6000)
 		basic_machine=rs6000-ibm
 		;;
@@ -1294,6 +1308,9 @@
 	-kaos*)
 		os=-kaos
 		;;
+	-zvmoe)
+		os=-zvmoe
+		;;
 	-none)
 		;;
 	*)
@@ -1374,6 +1391,9 @@
 	*-ibm)
 		os=-aix
 		;;
+    	*-knuth)
+		os=-mmixware
+		;;
 	*-wec)
 		os=-proelf
 		;;

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/configure
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/configure	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/configure	2005-10-20 12:42:06 UTC (rev 10202)
@@ -425,7 +425,7 @@
 PACKAGE_STRING=
 PACKAGE_BUGREPORT=
 
-ac_unique_file="libspeex/nb_celp.c"
+ac_unique_file="libspeex/speex.c"
 # Factoring default headers for most tests.
 ac_includes_default="\
 #include <stdio.h>
@@ -463,7 +463,7 @@
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS SPEEX_LT_CURRENT SPEEX_LT_REVISION SPEEX_LT_AGE INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CPP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL OGG_LIBS OGG_INCLUDES OGG_LDFLAGS src LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS SPEEX_LT_CURRENT SPEEX_LT_REVISION SPEEX_LT_AGE SPEEX_VERSION INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CPP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL OGG_CFLAGS OGG_LIBS src LIBOBJS SIZE16 SIZE32 LTLIBOBJS'
 ac_subst_files=''
 
 # Initialize some variables set by options.
@@ -1034,9 +1034,18 @@
   --disable-dependency-tracking  speeds up one-time build
   --enable-dependency-tracking   do not reject slow dependency extractors
   --disable-libtool-lock  avoid locking (might break parallel builds)
-  --enable-ogg=yes/no    Turn on or off the use of ogg
-libraries default=yes
-  --enable-sse             enable SSE support
+  --disable-oggtest       Do not try to compile and run a test Ogg program
+  --disable-wideband      Disable wideband codec
+  --enable-valgrind       Enable valgrind extra checks
+  --enable-sse            Enable SSE support
+  --enable-fixed-point    Compile as fixed-point
+  --enable-arm4-asm       Make use of ARM4 assembly optimizations
+  --enable-arm5e-asm      Make use of ARM5E assembly optimizations
+  --enable-blackfin-asm      Make use of Blackfin assembly optimizations
+  --enable-fixed-point-debug  Debug fixed-point implementation
+  --enable-epic-48k       Enable support for Epic 4.8 kbps mode
+  --enable-ti-c55x        Enable support for TI C55X DSP
+  --enable-16bit-precision Reduce precision to 16 bits (EXPERIMENTAL)
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
@@ -1046,9 +1055,9 @@
                           both]
   --with-tags[=TAGS]
                           include additional configurations [automatic]
-  --with-ogg-dir=DIR       where the root of OGG is installed
-  --with-ogg-includes=DIR  where the OGG includes are.
-  --with-ogg-libraries=DIR where the OGG library is installed.
+  --with-ogg=PFX   Prefix where libogg is installed (optional)
+  --with-ogg-libraries=DIR   Directory where libogg library is installed (optional)
+  --with-ogg-includes=DIR   Directory where libogg header files are installed (optional)
 
 Some influential environment variables:
   CC          C compiler command
@@ -1503,10 +1512,14 @@
 
 
 
+          ac_config_headers="$ac_config_headers config.h"
+
+
 SPEEX_MAJOR_VERSION=1
-SPEEX_MINOR_VERSION=0
-SPEEX_MICRO_VERSION=4
+SPEEX_MINOR_VERSION=1
+SPEEX_MICRO_VERSION=10
 SPEEX_EXTRA_VERSION=
+#SPEEX_VERSION=
 SPEEX_VERSION=$SPEEX_MAJOR_VERSION.$SPEEX_MINOR_VERSION.$SPEEX_MICRO_VERSION$SPEEX_EXTRA_VERSION
 
 SPEEX_LT_CURRENT=3
@@ -1521,6 +1534,8 @@
 VERSION=$SPEEX_VERSION
 PACKAGE=speex
 
+
+
 am__api_version="1.8"
 ac_aux_dir=
 for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
@@ -3659,7 +3674,7 @@
   ;;
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 3662 "configure"' > conftest.$ac_ext
+  echo '#line 3677 "configure"' > conftest.$ac_ext
   if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -5223,7 +5238,7 @@
 
 
 # Provide some information about the compiler.
-echo "$as_me:5226:" \
+echo "$as_me:5241:" \
      "checking for Fortran 77 compiler version" >&5
 ac_compiler=`set X $ac_compile; echo $2`
 { (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
@@ -6255,11 +6270,11 @@
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:6258: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:6273: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:6262: \$? = $ac_status" >&5
+   echo "$as_me:6277: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
@@ -6488,11 +6503,11 @@
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:6491: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:6506: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:6495: \$? = $ac_status" >&5
+   echo "$as_me:6510: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
@@ -6548,11 +6563,11 @@
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:6551: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:6566: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:6555: \$? = $ac_status" >&5
+   echo "$as_me:6570: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -8736,7 +8751,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 8739 "configure"
+#line 8754 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -8834,7 +8849,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 8837 "configure"
+#line 8852 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11011,11 +11026,11 @@
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:11014: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:11029: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:11018: \$? = $ac_status" >&5
+   echo "$as_me:11033: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
@@ -11071,11 +11086,11 @@
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:11074: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:11089: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:11078: \$? = $ac_status" >&5
+   echo "$as_me:11093: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -12440,7 +12455,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 12443 "configure"
+#line 12458 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12538,7 +12553,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 12541 "configure"
+#line 12556 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -13365,11 +13380,11 @@
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:13368: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:13383: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:13372: \$? = $ac_status" >&5
+   echo "$as_me:13387: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
@@ -13425,11 +13440,11 @@
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:13428: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:13443: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:13432: \$? = $ac_status" >&5
+   echo "$as_me:13447: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -15470,11 +15485,11 @@
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:15473: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:15488: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:15477: \$? = $ac_status" >&5
+   echo "$as_me:15492: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
@@ -15703,11 +15718,11 @@
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:15706: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:15721: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:15710: \$? = $ac_status" >&5
+   echo "$as_me:15725: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
@@ -15763,11 +15778,11 @@
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:15766: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:15781: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:15770: \$? = $ac_status" >&5
+   echo "$as_me:15785: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -17951,7 +17966,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 17954 "configure"
+#line 17969 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -18049,7 +18064,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 18052 "configure"
+#line 18067 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -19291,8 +19306,370 @@
    { (exit 1); exit 1; }; } ;;
 esac
 
+echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5
+echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6
+if test "${ac_cv_c_const+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 
+int
+main ()
+{
+/* FIXME: Include the comments suggested by Paul. */
+#ifndef __cplusplus
+  /* Ultrix mips cc rejects this.  */
+  typedef int charset[2];
+  const charset x;
+  /* SunOS 4.1.1 cc rejects this.  */
+  char const *const *ccp;
+  char **p;
+  /* NEC SVR4.0.2 mips cc rejects this.  */
+  struct point {int x, y;};
+  static struct point const zero = {0,0};
+  /* AIX XL C 1.02.0.0 rejects this.
+     It does not let you subtract one const X* pointer from another in
+     an arm of an if-expression whose if-part is not a constant
+     expression */
+  const char *g = "string";
+  ccp = &g + (g ? g-g : 0);
+  /* HPUX 7.0 cc rejects these. */
+  ++ccp;
+  p = (char**) ccp;
+  ccp = (char const *const *) p;
+  { /* SCO 3.2v4 cc rejects this.  */
+    char *t;
+    char const *s = 0 ? (char *) 0 : (char const *) 0;
 
+    *t++ = 0;
+  }
+  { /* Someone thinks the Sun supposedly-ANSI compiler will reject this.  */
+    int x[] = {25, 17};
+    const int *foo = &x[0];
+    ++foo;
+  }
+  { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
+    typedef const int *iptr;
+    iptr p = 0;
+    ++p;
+  }
+  { /* AIX XL C 1.02.0.0 rejects this saying
+       "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
+    struct s { int j; const int *ap[3]; };
+    struct s *b; b->j = 5;
+  }
+  { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
+    const int foo = 10;
+  }
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_c_const=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_c_const=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5
+echo "${ECHO_T}$ac_cv_c_const" >&6
+if test $ac_cv_c_const = no; then
+
+cat >>confdefs.h <<\_ACEOF
+#define const
+_ACEOF
+
+fi
+
+echo "$as_me:$LINENO: checking for inline" >&5
+echo $ECHO_N "checking for inline... $ECHO_C" >&6
+if test "${ac_cv_c_inline+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_c_inline=no
+for ac_kw in inline __inline__ __inline; do
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#ifndef __cplusplus
+typedef int foo_t;
+static $ac_kw foo_t static_foo () {return 0; }
+$ac_kw foo_t foo () {return 0; }
+#endif
+
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_c_inline=$ac_kw; break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5
+echo "${ECHO_T}$ac_cv_c_inline" >&6
+
+
+case $ac_cv_c_inline in
+  inline | yes) ;;
+  *)
+    case $ac_cv_c_inline in
+      no) ac_val=;;
+      *) ac_val=$ac_cv_c_inline;;
+    esac
+    cat >>confdefs.h <<_ACEOF
+#ifndef __cplusplus
+#define inline $ac_val
+#endif
+_ACEOF
+    ;;
+esac
+
+echo "$as_me:$LINENO: checking for C/C++ restrict keyword" >&5
+echo $ECHO_N "checking for C/C++ restrict keyword... $ECHO_C" >&6
+if test "${ac_cv_c_restrict+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_c_restrict=no
+   # Try the official restrict keyword, then gcc's __restrict, and
+   # the less common variants.
+   for ac_kw in restrict __restrict __restrict__ _Restrict; do
+     cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+float * $ac_kw x;
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_c_restrict=$ac_kw; break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+   done
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_c_restrict" >&5
+echo "${ECHO_T}$ac_cv_c_restrict" >&6
+ case $ac_cv_c_restrict in
+   restrict) ;;
+   no)
+cat >>confdefs.h <<\_ACEOF
+#define restrict
+_ACEOF
+ ;;
+   *)  cat >>confdefs.h <<_ACEOF
+#define restrict $ac_cv_c_restrict
+_ACEOF
+ ;;
+ esac
+
+
+
+echo "$as_me:$LINENO: checking for C99 variable-size arrays" >&5
+echo $ECHO_N "checking for C99 variable-size arrays... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+int foo=10;
+int array[foo];
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  has_var_arrays=yes;
+cat >>confdefs.h <<\_ACEOF
+#define VAR_ARRAYS
+_ACEOF
+
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+has_var_arrays=no
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $has_var_arrays" >&5
+echo "${ECHO_T}$has_var_arrays" >&6
+
+echo "$as_me:$LINENO: checking for alloca" >&5
+echo $ECHO_N "checking for alloca... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <alloca.h>
+int
+main ()
+{
+
+int foo=10;
+int *array = alloca(foo);
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+has_alloca=yes;
+if test x$has_var_arrays = "xno" ; then
+
+cat >>confdefs.h <<\_ACEOF
+#define USE_ALLOCA
+_ACEOF
+
+fi
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+has_alloca=no
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $has_alloca" >&5
+echo "${ECHO_T}$has_alloca" >&6
+
+
+
+
 for ac_header in sys/soundcard.h sys/audioio.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
@@ -19442,123 +19819,201 @@
 done
 
 
-# Check whether --enable-ogg or --disable-ogg was given.
-if test "${enable_ogg+set}" = set; then
-  enableval="$enable_ogg"
-  case "${enableval}" in
-        yes) useogg=true ;;
-        no)  useogg=false ;;
-        *) { { echo "$as_me:$LINENO: error: bad value ${enableval} for --enable-ogg" >&5
-echo "$as_me: error: bad value ${enableval} for --enable-ogg" >&2;}
-   { (exit 1); exit 1; }; } ;;
-      esac
+
+# Check whether --with-ogg or --without-ogg was given.
+if test "${with_ogg+set}" = set; then
+  withval="$with_ogg"
+  ogg_prefix="$withval"
 else
-  useogg=true
+  ogg_prefix=""
 fi;
 
-if test x$useogg = xtrue; then
-
-OGG_LIBS="-logg"
-
-echo "$as_me:$LINENO: checking for libogg" >&5
-echo $ECHO_N "checking for libogg... $ECHO_C" >&6
-
-ac_ogg_includes=NONE ac_ogg_libraries=NONE ac_ogg_bindir=NONE
-ogg_libraries=""
-ogg_includes=""
-
-# Check whether --with-ogg-dir or --without-ogg-dir was given.
-if test "${with_ogg_dir+set}" = set; then
-  withval="$with_ogg_dir"
-    ac_ogg_includes="$withval"/include
-       ac_ogg_libraries="$withval"/lib
-
+# Check whether --with-ogg-libraries or --without-ogg-libraries was given.
+if test "${with_ogg_libraries+set}" = set; then
+  withval="$with_ogg_libraries"
+  ogg_libraries="$withval"
+else
+  ogg_libraries=""
 fi;
 
-
 # Check whether --with-ogg-includes or --without-ogg-includes was given.
 if test "${with_ogg_includes+set}" = set; then
   withval="$with_ogg_includes"
+  ogg_includes="$withval"
+else
+  ogg_includes=""
+fi;
+# Check whether --enable-oggtest or --disable-oggtest was given.
+if test "${enable_oggtest+set}" = set; then
+  enableval="$enable_oggtest"
 
-       ac_ogg_includes="$withval"
-
+else
+  enable_oggtest=yes
 fi;
 
-ogg_libs_given=no
+  if test "x$ogg_libraries" != "x" ; then
+    OGG_LIBS="-L$ogg_libraries"
+  elif test "x$ogg_prefix" != "x" ; then
+    OGG_LIBS="-L$ogg_prefix/lib"
+  elif test "x$prefix" != "xNONE" ; then
+    OGG_LIBS="-L$prefix/lib"
+  fi
 
+  OGG_LIBS="$OGG_LIBS -logg"
 
-# Check whether --with-ogg-libraries or --without-ogg-libraries was given.
-if test "${with_ogg_libraries+set}" = set; then
-  withval="$with_ogg_libraries"
-    ac_ogg_libraries="$withval"
-       ogg_libs_given=yes
+  if test "x$ogg_includes" != "x" ; then
+    OGG_CFLAGS="-I$ogg_includes"
+  elif test "x$ogg_prefix" != "x" ; then
+    OGG_CFLAGS="-I$ogg_prefix/include"
+  elif test "x$prefix" != "xNONE"; then
+    OGG_CFLAGS="-I$prefix/include"
+  fi
 
-fi;
+  echo "$as_me:$LINENO: checking for Ogg" >&5
+echo $ECHO_N "checking for Ogg... $ECHO_C" >&6
+  no_ogg=""
 
-ogg_incdirs="/usr/include /usr/lib/ogg/include /opt/include /usr/local/ogg/include /usr/include/ogg /usr/include /usr/local/include"
-if test ! "$ac_ogg_includes" = "NONE"; then
-  ogg_incdirs="$ac_ogg_includes $ac_ogg_includes/.. $ogg_incdirs"
-fi
 
-ogg_incdir=NONE
-for i in $ogg_incdirs;
-do
-  for j in ogg/ogg.h;
-  do
-    if test -r "$i/$j"; then
-      ogg_incdir=$i
-      break 2
-    fi
-  done
-done
+  if test "x$enable_oggtest" = "xyes" ; then
+    ac_save_CFLAGS="$CFLAGS"
+    ac_save_LIBS="$LIBS"
+    CFLAGS="$CFLAGS $OGG_CFLAGS"
+    LIBS="$LIBS $OGG_LIBS"
+      rm -f conf.oggtest
+      if test "$cross_compiling" = yes; then
+  echo $ac_n "cross compiling; assumed OK... $ac_c"
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 
-echo "Ogg includes in $ogg_incdir"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ogg/ogg.h>
 
+int main ()
+{
+  system("touch conf.oggtest");
+  return 0;
+}
 
-ogg_libdirs="$ac_ogg_libraries /usr/lib/ogg/lib /usr/lib /opt/lib /usr/local/ogg/lib /usr/local/lib /usr/lib/ogg /usr/local/lib"
-test -n "$OGGDIR" && ogg_libdirs="$OGGDIR/lib $OGGDIR $ogg_libdirs"
-if test ! "$ac_ogg_libraries" = "NONE"; then
-  ogg_libdirs="$ac_ogg_libraries $ogg_libdirs"
-fi
 
-test=NONE
-ogg_libdir=NONE
-for dir in $ogg_libdirs; do
-  try="ls -1 $dir/libogg*"
-  if test=`eval $try 2> /dev/null`; then ogg_libdir=$dir; break; else echo "tried $dir" >&5 ; fi
-done
-
-echo "Ogg libraries in $ogg_libdir"
-
-if test "$ogg_libdir" = "NONE" || test "$ogg_incdir" = "NONE"; then
-   have_libogg=no
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
 else
-   have_libogg=yes
-   cat >>confdefs.h <<\_ACEOF
-#define HAVE_LIBOGG 1
-_ACEOF
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
+( exit $ac_status )
+no_ogg=yes
 fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+       CFLAGS="$ac_save_CFLAGS"
+       LIBS="$ac_save_LIBS"
+  fi
 
-OGG_INCLUDES="-I$ogg_incdir"
-OGG_LDFLAGS="-L$ogg_libdir"
+  if test "x$no_ogg" = "x" ; then
+     echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+     src="src"
+  else
+     echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+     if test -f conf.oggtest ; then
+       :
+     else
+       echo "*** Could not run Ogg test program, checking why..."
+       CFLAGS="$CFLAGS $OGG_CFLAGS"
+       LIBS="$LIBS $OGG_LIBS"
+       cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 
+#include <stdio.h>
+#include <ogg/ogg.h>
 
+int
+main ()
+{
+ return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+   echo "*** The test program compiled, but did not run. This usually means"
+       echo "*** that the run-time linker is not finding Ogg or finding the wrong"
+       echo "*** version of Ogg. If it is not finding Ogg, you'll need to set your"
+       echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
+       echo "*** to the installed location  Also, make sure you have run ldconfig if that"
+       echo "*** is required on your system"
+       echo "***"
+       echo "*** If you have an old version installed, it is best to remove it, although"
+       echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
+ echo "*** The test program failed to compile or link. See the file config.log for the"
+       echo "*** exact error that occured. This usually means Ogg was incorrectly installed"
+       echo "*** or that you have moved Ogg since it was installed."
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+       CFLAGS="$ac_save_CFLAGS"
+       LIBS="$ac_save_LIBS"
+     fi
+     OGG_CFLAGS=""
+     OGG_LIBS=""
+     src=""
+  fi
 
 
+  rm -f conf.oggtest
 
 
-fi
 
-if test "$have_libogg" = yes; then
-   src=src
-else
-   src=
-fi
 
-
-
 echo "$as_me:$LINENO: checking for sin in -lm" >&5
 echo $ECHO_N "checking for sin in -lm... $ECHO_C" >&6
 if test "${ac_cv_lib_m_sin+set}" = set; then
@@ -19632,7 +20087,108 @@
 fi
 
 
-echo "$as_me:$LINENO: checking for getopt_long in -lgnugetopt" >&5
+# Check for getopt_long; if not found, use included source.
+
+for ac_func in getopt_long
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != $ac_func;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_var=no"
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+else
+  # FreeBSD has a gnugetopt library.
+  echo "$as_me:$LINENO: checking for getopt_long in -lgnugetopt" >&5
 echo $ECHO_N "checking for getopt_long in -lgnugetopt... $ECHO_C" >&6
 if test "${ac_cv_lib_gnugetopt_getopt_long+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -19696,48 +20252,1918 @@
 echo "$as_me:$LINENO: result: $ac_cv_lib_gnugetopt_getopt_long" >&5
 echo "${ECHO_T}$ac_cv_lib_gnugetopt_getopt_long" >&6
 if test $ac_cv_lib_gnugetopt_getopt_long = yes; then
+  cat >>confdefs.h <<\_ACEOF
+#define HAVE_GETOPT_LONG 1
+_ACEOF
+
+else
+  # Use the GNU replacement.
+case $LIBOBJS in
+    "getopt.$ac_objext"   | \
+  *" getopt.$ac_objext"   | \
+    "getopt.$ac_objext "* | \
+  *" getopt.$ac_objext "* ) ;;
+  *) LIBOBJS="$LIBOBJS getopt.$ac_objext" ;;
+esac
+
+case $LIBOBJS in
+    "getopt1.$ac_objext"   | \
+  *" getopt1.$ac_objext"   | \
+    "getopt1.$ac_objext "* | \
+  *" getopt1.$ac_objext "* ) ;;
+  *) LIBOBJS="$LIBOBJS getopt1.$ac_objext" ;;
+esac
+
+fi
+
+fi
+done
+
+
+
+echo "$as_me:$LINENO: checking for main in -lwinmm" >&5
+echo $ECHO_N "checking for main in -lwinmm... $ECHO_C" >&6
+if test "${ac_cv_lib_winmm_main+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lwinmm  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+
+int
+main ()
+{
+main ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_winmm_main=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_winmm_main=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_winmm_main" >&5
+echo "${ECHO_T}$ac_cv_lib_winmm_main" >&6
+if test $ac_cv_lib_winmm_main = yes; then
   cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBGNUGETOPT 1
+#define HAVE_LIBWINMM 1
 _ACEOF
 
-  LIBS="-lgnugetopt $LIBS"
+  LIBS="-lwinmm $LIBS"
 
 fi
 
 
+
 cat >>confdefs.h <<_ACEOF
 #define SPEEX_VERSION "${SPEEX_VERSION}"
 _ACEOF
 
+
 cat >>confdefs.h <<_ACEOF
 #define SPEEX_MAJOR_VERSION ${SPEEX_MAJOR_VERSION}
 _ACEOF
 
+
 cat >>confdefs.h <<_ACEOF
 #define SPEEX_MINOR_VERSION ${SPEEX_MINOR_VERSION}
 _ACEOF
 
+
 cat >>confdefs.h <<_ACEOF
 #define SPEEX_MICRO_VERSION ${SPEEX_MICRO_VERSION}
 _ACEOF
 
+
 cat >>confdefs.h <<_ACEOF
 #define SPEEX_EXTRA_VERSION "${SPEEX_EXTRA_VERSION}"
 _ACEOF
 
 
+# Check whether --enable-wideband or --disable-wideband was given.
+if test "${enable_wideband+set}" = set; then
+  enableval="$enable_wideband"
+  if test "$enableval" = no; then
 
+cat >>confdefs.h <<\_ACEOF
+#define DISABLE_WIDEBAND
+_ACEOF
+
+fi
+fi;
+
+# Check whether --enable-valgrind or --disable-valgrind was given.
+if test "${enable_valgrind+set}" = set; then
+  enableval="$enable_valgrind"
+  if test "$enableval" = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define ENABLE_VALGRIND
+_ACEOF
+
+fi
+fi;
+
 # Check whether --enable-sse or --disable-sse was given.
 if test "${enable_sse+set}" = set; then
   enableval="$enable_sse"
-  if test "$enableval" = yes; then cat >>confdefs.h <<\_ACEOF
-#define _USE_SSE 1
+  if test "$enableval" = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define _USE_SSE
 _ACEOF
- fi
+
+CFLAGS="$CFLAGS -O3 -msse"
+fi
+
 fi;
 
+# Check whether --enable-fixed-point or --disable-fixed-point was given.
+if test "${enable_fixed_point+set}" = set; then
+  enableval="$enable_fixed_point"
+  if test "$enableval" = yes; then
 
-                                                                                                                        ac_config_files="$ac_config_files Makefile libspeex/Makefile src/Makefile doc/Makefile Speex.spec include/Makefile include/speex/Makefile speex.pc win32/Makefile win32/libspeex/Makefile win32/speexenc/Makefile win32/speexdec/Makefile"
+cat >>confdefs.h <<\_ACEOF
+#define FIXED_POINT
+_ACEOF
+
+fi
+fi;
+
+# Check whether --enable-arm4-asm or --disable-arm4-asm was given.
+if test "${enable_arm4_asm+set}" = set; then
+  enableval="$enable_arm4_asm"
+  if test "$enableval" = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define ARM4_ASM
+_ACEOF
+
+fi
+fi;
+
+# Check whether --enable-arm5e-asm or --disable-arm5e-asm was given.
+if test "${enable_arm5e_asm+set}" = set; then
+  enableval="$enable_arm5e_asm"
+  if test "$enableval" = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define ARM5_ASM
+_ACEOF
+
+fi
+fi;
+
+# Check whether --enable-blackfin-asm or --disable-blackfin-asm was given.
+if test "${enable_blackfin_asm+set}" = set; then
+  enableval="$enable_blackfin_asm"
+  if test "$enableval" = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define BFIN_ASM
+_ACEOF
+
+fi
+fi;
+
+# Check whether --enable-fixed-point-debug or --disable-fixed-point-debug was given.
+if test "${enable_fixed_point_debug+set}" = set; then
+  enableval="$enable_fixed_point_debug"
+  if test "$enableval" = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define FIXED_DEBUG
+_ACEOF
+
+fi
+fi;
+
+# Check whether --enable-epic-48k or --disable-epic-48k was given.
+if test "${enable_epic_48k+set}" = set; then
+  enableval="$enable_epic_48k"
+  if test "$enableval" = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define EPIC_48K
+_ACEOF
+
+fi
+fi;
+
+# Check whether --enable-ti-c55x or --disable-ti-c55x was given.
+if test "${enable_ti_c55x+set}" = set; then
+  enableval="$enable_ti_c55x"
+  if test "$enableval" = yes; then
+  has_char16=yes;
+
+cat >>confdefs.h <<\_ACEOF
+#define TI_C55X
+_ACEOF
+
+fi
+fi;
+
+# Check whether --enable-16bit-precision or --disable-16bit-precision was given.
+if test "${enable_16bit_precision+set}" = set; then
+  enableval="$enable_16bit_precision"
+  if test "$enableval" = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define PRECISION16
+_ACEOF
+
+fi
+fi;
+
+echo "$as_me:$LINENO: checking for short" >&5
+echo $ECHO_N "checking for short... $ECHO_C" >&6
+if test "${ac_cv_type_short+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+if ((short *) 0)
+  return 0;
+if (sizeof (short))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_type_short=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_type_short=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_short" >&5
+echo "${ECHO_T}$ac_cv_type_short" >&6
+
+echo "$as_me:$LINENO: checking size of short" >&5
+echo $ECHO_N "checking size of short... $ECHO_C" >&6
+if test "${ac_cv_sizeof_short+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test "$ac_cv_type_short" = yes; then
+  # The cast to unsigned long works around a bug in the HP C Compiler
+  # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+  # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+  # This bug is HP SR number 8606223364.
+  if test "$cross_compiling" = yes; then
+  # Depending upon the size, compute the lo and hi bounds.
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (short))) >= 0)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_lo=0 ac_mid=0
+  while :; do
+    cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (short))) <= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_hi=$ac_mid; break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo=`expr $ac_mid + 1`
+		    if test $ac_lo -le $ac_mid; then
+		      ac_lo= ac_hi=
+		      break
+		    fi
+		    ac_mid=`expr 2 '*' $ac_mid + 1`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (short))) < 0)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_hi=-1 ac_mid=-1
+  while :; do
+    cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (short))) >= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_lo=$ac_mid; break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_hi=`expr '(' $ac_mid ')' - 1`
+		       if test $ac_mid -le $ac_hi; then
+			 ac_lo= ac_hi=
+			 break
+		       fi
+		       ac_mid=`expr 2 '*' $ac_mid`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo= ac_hi=
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+# Binary search between lo and hi bounds.
+while test "x$ac_lo" != "x$ac_hi"; do
+  ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (short))) <= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_hi=$ac_mid
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo=`expr '(' $ac_mid ')' + 1`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+case $ac_lo in
+?*) ac_cv_sizeof_short=$ac_lo;;
+'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (short), 77
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (short), 77
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; } ;;
+esac
+else
+  if test "$cross_compiling" = yes; then
+  { { echo "$as_me:$LINENO: error: internal error: not reached in cross-compile" >&5
+echo "$as_me: error: internal error: not reached in cross-compile" >&2;}
+   { (exit 1); exit 1; }; }
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+long longval () { return (long) (sizeof (short)); }
+unsigned long ulongval () { return (long) (sizeof (short)); }
+#include <stdio.h>
+#include <stdlib.h>
+int
+main ()
+{
+
+  FILE *f = fopen ("conftest.val", "w");
+  if (! f)
+    exit (1);
+  if (((long) (sizeof (short))) < 0)
+    {
+      long i = longval ();
+      if (i != ((long) (sizeof (short))))
+	exit (1);
+      fprintf (f, "%ld\n", i);
+    }
+  else
+    {
+      unsigned long i = ulongval ();
+      if (i != ((long) (sizeof (short))))
+	exit (1);
+      fprintf (f, "%lu\n", i);
+    }
+  exit (ferror (f) || fclose (f) != 0);
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_sizeof_short=`cat conftest.val`
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+{ { echo "$as_me:$LINENO: error: cannot compute sizeof (short), 77
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (short), 77
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+rm -f conftest.val
+else
+  ac_cv_sizeof_short=0
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_sizeof_short" >&5
+echo "${ECHO_T}$ac_cv_sizeof_short" >&6
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_SHORT $ac_cv_sizeof_short
+_ACEOF
+
+
+echo "$as_me:$LINENO: checking for int" >&5
+echo $ECHO_N "checking for int... $ECHO_C" >&6
+if test "${ac_cv_type_int+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+if ((int *) 0)
+  return 0;
+if (sizeof (int))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_type_int=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_type_int=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_int" >&5
+echo "${ECHO_T}$ac_cv_type_int" >&6
+
+echo "$as_me:$LINENO: checking size of int" >&5
+echo $ECHO_N "checking size of int... $ECHO_C" >&6
+if test "${ac_cv_sizeof_int+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test "$ac_cv_type_int" = yes; then
+  # The cast to unsigned long works around a bug in the HP C Compiler
+  # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+  # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+  # This bug is HP SR number 8606223364.
+  if test "$cross_compiling" = yes; then
+  # Depending upon the size, compute the lo and hi bounds.
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (int))) >= 0)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_lo=0 ac_mid=0
+  while :; do
+    cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (int))) <= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_hi=$ac_mid; break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo=`expr $ac_mid + 1`
+		    if test $ac_lo -le $ac_mid; then
+		      ac_lo= ac_hi=
+		      break
+		    fi
+		    ac_mid=`expr 2 '*' $ac_mid + 1`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (int))) < 0)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_hi=-1 ac_mid=-1
+  while :; do
+    cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (int))) >= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_lo=$ac_mid; break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_hi=`expr '(' $ac_mid ')' - 1`
+		       if test $ac_mid -le $ac_hi; then
+			 ac_lo= ac_hi=
+			 break
+		       fi
+		       ac_mid=`expr 2 '*' $ac_mid`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo= ac_hi=
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+# Binary search between lo and hi bounds.
+while test "x$ac_lo" != "x$ac_hi"; do
+  ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (int))) <= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_hi=$ac_mid
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo=`expr '(' $ac_mid ')' + 1`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+case $ac_lo in
+?*) ac_cv_sizeof_int=$ac_lo;;
+'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (int), 77
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (int), 77
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; } ;;
+esac
+else
+  if test "$cross_compiling" = yes; then
+  { { echo "$as_me:$LINENO: error: internal error: not reached in cross-compile" >&5
+echo "$as_me: error: internal error: not reached in cross-compile" >&2;}
+   { (exit 1); exit 1; }; }
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+long longval () { return (long) (sizeof (int)); }
+unsigned long ulongval () { return (long) (sizeof (int)); }
+#include <stdio.h>
+#include <stdlib.h>
+int
+main ()
+{
+
+  FILE *f = fopen ("conftest.val", "w");
+  if (! f)
+    exit (1);
+  if (((long) (sizeof (int))) < 0)
+    {
+      long i = longval ();
+      if (i != ((long) (sizeof (int))))
+	exit (1);
+      fprintf (f, "%ld\n", i);
+    }
+  else
+    {
+      unsigned long i = ulongval ();
+      if (i != ((long) (sizeof (int))))
+	exit (1);
+      fprintf (f, "%lu\n", i);
+    }
+  exit (ferror (f) || fclose (f) != 0);
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_sizeof_int=`cat conftest.val`
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+{ { echo "$as_me:$LINENO: error: cannot compute sizeof (int), 77
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (int), 77
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+rm -f conftest.val
+else
+  ac_cv_sizeof_int=0
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_sizeof_int" >&5
+echo "${ECHO_T}$ac_cv_sizeof_int" >&6
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_INT $ac_cv_sizeof_int
+_ACEOF
+
+
+echo "$as_me:$LINENO: checking for long" >&5
+echo $ECHO_N "checking for long... $ECHO_C" >&6
+if test "${ac_cv_type_long+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+if ((long *) 0)
+  return 0;
+if (sizeof (long))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_type_long=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_type_long=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_long" >&5
+echo "${ECHO_T}$ac_cv_type_long" >&6
+
+echo "$as_me:$LINENO: checking size of long" >&5
+echo $ECHO_N "checking size of long... $ECHO_C" >&6
+if test "${ac_cv_sizeof_long+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test "$ac_cv_type_long" = yes; then
+  # The cast to unsigned long works around a bug in the HP C Compiler
+  # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+  # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+  # This bug is HP SR number 8606223364.
+  if test "$cross_compiling" = yes; then
+  # Depending upon the size, compute the lo and hi bounds.
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (long))) >= 0)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_lo=0 ac_mid=0
+  while :; do
+    cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (long))) <= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_hi=$ac_mid; break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo=`expr $ac_mid + 1`
+		    if test $ac_lo -le $ac_mid; then
+		      ac_lo= ac_hi=
+		      break
+		    fi
+		    ac_mid=`expr 2 '*' $ac_mid + 1`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (long))) < 0)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_hi=-1 ac_mid=-1
+  while :; do
+    cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (long))) >= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_lo=$ac_mid; break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_hi=`expr '(' $ac_mid ')' - 1`
+		       if test $ac_mid -le $ac_hi; then
+			 ac_lo= ac_hi=
+			 break
+		       fi
+		       ac_mid=`expr 2 '*' $ac_mid`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo= ac_hi=
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+# Binary search between lo and hi bounds.
+while test "x$ac_lo" != "x$ac_hi"; do
+  ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (long))) <= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_hi=$ac_mid
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo=`expr '(' $ac_mid ')' + 1`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+case $ac_lo in
+?*) ac_cv_sizeof_long=$ac_lo;;
+'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long), 77
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (long), 77
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; } ;;
+esac
+else
+  if test "$cross_compiling" = yes; then
+  { { echo "$as_me:$LINENO: error: internal error: not reached in cross-compile" >&5
+echo "$as_me: error: internal error: not reached in cross-compile" >&2;}
+   { (exit 1); exit 1; }; }
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+long longval () { return (long) (sizeof (long)); }
+unsigned long ulongval () { return (long) (sizeof (long)); }
+#include <stdio.h>
+#include <stdlib.h>
+int
+main ()
+{
+
+  FILE *f = fopen ("conftest.val", "w");
+  if (! f)
+    exit (1);
+  if (((long) (sizeof (long))) < 0)
+    {
+      long i = longval ();
+      if (i != ((long) (sizeof (long))))
+	exit (1);
+      fprintf (f, "%ld\n", i);
+    }
+  else
+    {
+      unsigned long i = ulongval ();
+      if (i != ((long) (sizeof (long))))
+	exit (1);
+      fprintf (f, "%lu\n", i);
+    }
+  exit (ferror (f) || fclose (f) != 0);
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_sizeof_long=`cat conftest.val`
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+{ { echo "$as_me:$LINENO: error: cannot compute sizeof (long), 77
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (long), 77
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+rm -f conftest.val
+else
+  ac_cv_sizeof_long=0
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_sizeof_long" >&5
+echo "${ECHO_T}$ac_cv_sizeof_long" >&6
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_LONG $ac_cv_sizeof_long
+_ACEOF
+
+
+echo "$as_me:$LINENO: checking for long long" >&5
+echo $ECHO_N "checking for long long... $ECHO_C" >&6
+if test "${ac_cv_type_long_long+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+if ((long long *) 0)
+  return 0;
+if (sizeof (long long))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_type_long_long=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_type_long_long=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_long_long" >&5
+echo "${ECHO_T}$ac_cv_type_long_long" >&6
+
+echo "$as_me:$LINENO: checking size of long long" >&5
+echo $ECHO_N "checking size of long long... $ECHO_C" >&6
+if test "${ac_cv_sizeof_long_long+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test "$ac_cv_type_long_long" = yes; then
+  # The cast to unsigned long works around a bug in the HP C Compiler
+  # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+  # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+  # This bug is HP SR number 8606223364.
+  if test "$cross_compiling" = yes; then
+  # Depending upon the size, compute the lo and hi bounds.
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (long long))) >= 0)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_lo=0 ac_mid=0
+  while :; do
+    cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (long long))) <= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_hi=$ac_mid; break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo=`expr $ac_mid + 1`
+		    if test $ac_lo -le $ac_mid; then
+		      ac_lo= ac_hi=
+		      break
+		    fi
+		    ac_mid=`expr 2 '*' $ac_mid + 1`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (long long))) < 0)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_hi=-1 ac_mid=-1
+  while :; do
+    cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (long long))) >= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_lo=$ac_mid; break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_hi=`expr '(' $ac_mid ')' - 1`
+		       if test $ac_mid -le $ac_hi; then
+			 ac_lo= ac_hi=
+			 break
+		       fi
+		       ac_mid=`expr 2 '*' $ac_mid`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo= ac_hi=
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+# Binary search between lo and hi bounds.
+while test "x$ac_lo" != "x$ac_hi"; do
+  ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long) (sizeof (long long))) <= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_hi=$ac_mid
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_lo=`expr '(' $ac_mid ')' + 1`
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+case $ac_lo in
+?*) ac_cv_sizeof_long_long=$ac_lo;;
+'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long long), 77
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (long long), 77
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; } ;;
+esac
+else
+  if test "$cross_compiling" = yes; then
+  { { echo "$as_me:$LINENO: error: internal error: not reached in cross-compile" >&5
+echo "$as_me: error: internal error: not reached in cross-compile" >&2;}
+   { (exit 1); exit 1; }; }
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+long longval () { return (long) (sizeof (long long)); }
+unsigned long ulongval () { return (long) (sizeof (long long)); }
+#include <stdio.h>
+#include <stdlib.h>
+int
+main ()
+{
+
+  FILE *f = fopen ("conftest.val", "w");
+  if (! f)
+    exit (1);
+  if (((long) (sizeof (long long))) < 0)
+    {
+      long i = longval ();
+      if (i != ((long) (sizeof (long long))))
+	exit (1);
+      fprintf (f, "%ld\n", i);
+    }
+  else
+    {
+      unsigned long i = ulongval ();
+      if (i != ((long) (sizeof (long long))))
+	exit (1);
+      fprintf (f, "%lu\n", i);
+    }
+  exit (ferror (f) || fclose (f) != 0);
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_sizeof_long_long=`cat conftest.val`
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+{ { echo "$as_me:$LINENO: error: cannot compute sizeof (long long), 77
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (long long), 77
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+rm -f conftest.val
+else
+  ac_cv_sizeof_long_long=0
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_sizeof_long_long" >&5
+echo "${ECHO_T}$ac_cv_sizeof_long_long" >&6
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long
+_ACEOF
+
+
+
+if test x$has_char16 = "xyes" ; then
+        case 1 in
+                $ac_cv_sizeof_short) SIZE16="short";;
+                $ac_cv_sizeof_int) SIZE16="int";;
+        esac
+else
+        case 2 in
+                $ac_cv_sizeof_short) SIZE16="short";;
+                $ac_cv_sizeof_int) SIZE16="int";;
+        esac
+fi
+
+if test x$has_char16 = "xyes" ; then
+        case 2 in
+                $ac_cv_sizeof_int) SIZE32="int";;
+                $ac_cv_sizeof_long) SIZE32="long";;
+                $ac_cv_sizeof_short) SIZE32="short";;
+        esac
+else
+        case 4 in
+                $ac_cv_sizeof_int) SIZE32="int";;
+                $ac_cv_sizeof_long) SIZE32="long";;
+                $ac_cv_sizeof_short) SIZE32="short";;
+        esac
+fi
+
+
+
+
+                                                                                                                                            ac_config_files="$ac_config_files Makefile libspeex/Makefile src/Makefile doc/Makefile Speex.spec include/Makefile include/speex/Makefile speex.pc win32/Makefile win32/libspeex/Makefile win32/speexenc/Makefile win32/speexdec/Makefile symbian/Makefile include/speex/speex_config_types.h"
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
 # tests run on this system so they can be shared between configure
@@ -19812,39 +22238,8 @@
 }'
 fi
 
-# Transform confdefs.h into DEFS.
-# Protect against shell expansion while executing Makefile rules.
-# Protect against Makefile macro expansion.
-#
-# If the first sed substitution is executed (which looks for macros that
-# take arguments), then we branch to the quote section.  Otherwise,
-# look for a macro that doesn't take arguments.
-cat >confdef2opt.sed <<\_ACEOF
-t clear
-: clear
-s,^[	 ]*#[	 ]*define[	 ][	 ]*\([^	 (][^	 (]*([^)]*)\)[	 ]*\(.*\),-D\1=\2,g
-t quote
-s,^[	 ]*#[	 ]*define[	 ][	 ]*\([^	 ][^	 ]*\)[	 ]*\(.*\),-D\1=\2,g
-t quote
-d
-: quote
-s,[	 `~#$^&*(){}\\|;'"<>?],\\&,g
-s,\[,\\&,g
-s,\],\\&,g
-s,\$,$$,g
-p
-_ACEOF
-# We use echo to avoid assuming a particular line-breaking character.
-# The extra dot is to prevent the shell from consuming trailing
-# line-breaks from the sub-command output.  A line-break within
-# single-quotes doesn't work because, if this script is created in a
-# platform that uses two characters for line-breaks (e.g., DOS), tr
-# would break.
-ac_LF_and_DOT=`echo; echo .`
-DEFS=`sed -n -f confdef2opt.sed confdefs.h | tr "$ac_LF_and_DOT" ' .'`
-rm -f confdef2opt.sed
+DEFS=-DHAVE_CONFIG_H
 
-
 ac_libobjs=
 ac_ltlibobjs=
 for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
@@ -20205,10 +22600,15 @@
       --recheck    update $as_me by reconfiguring in the same conditions
   --file=FILE[:TEMPLATE]
 		   instantiate the configuration file FILE
+  --header=FILE[:TEMPLATE]
+		   instantiate the configuration header FILE
 
 Configuration files:
 $config_files
 
+Configuration headers:
+$config_headers
+
 Configuration commands:
 $config_commands
 
@@ -20339,7 +22739,10 @@
   "win32/libspeex/Makefile" ) CONFIG_FILES="$CONFIG_FILES win32/libspeex/Makefile" ;;
   "win32/speexenc/Makefile" ) CONFIG_FILES="$CONFIG_FILES win32/speexenc/Makefile" ;;
   "win32/speexdec/Makefile" ) CONFIG_FILES="$CONFIG_FILES win32/speexdec/Makefile" ;;
+  "symbian/Makefile" ) CONFIG_FILES="$CONFIG_FILES symbian/Makefile" ;;
+  "include/speex/speex_config_types.h" ) CONFIG_FILES="$CONFIG_FILES include/speex/speex_config_types.h" ;;
   "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
+  "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
   *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
 echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
    { (exit 1); exit 1; }; };;
@@ -20352,6 +22755,7 @@
 # bizarre bug on SunOS 4.1.3.
 if $ac_need_defaults; then
   test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+  test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
   test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
 fi
 
@@ -20427,6 +22831,7 @@
 s, at SPEEX_LT_CURRENT@,$SPEEX_LT_CURRENT,;t t
 s, at SPEEX_LT_REVISION@,$SPEEX_LT_REVISION,;t t
 s, at SPEEX_LT_AGE@,$SPEEX_LT_AGE,;t t
+s, at SPEEX_VERSION@,$SPEEX_VERSION,;t t
 s, at INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t
 s, at INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t
 s, at INSTALL_DATA@,$INSTALL_DATA,;t t
@@ -20493,11 +22898,12 @@
 s, at FFLAGS@,$FFLAGS,;t t
 s, at ac_ct_F77@,$ac_ct_F77,;t t
 s, at LIBTOOL@,$LIBTOOL,;t t
+s, at OGG_CFLAGS@,$OGG_CFLAGS,;t t
 s, at OGG_LIBS@,$OGG_LIBS,;t t
-s, at OGG_INCLUDES@,$OGG_INCLUDES,;t t
-s, at OGG_LDFLAGS@,$OGG_LDFLAGS,;t t
 s, at src@,$src,;t t
 s, at LIBOBJS@,$LIBOBJS,;t t
+s, at SIZE16@,$SIZE16,;t t
+s, at SIZE32@,$SIZE32,;t t
 s, at LTLIBOBJS@,$LTLIBOBJS,;t t
 CEOF
 
@@ -20741,6 +23147,251 @@
 cat >>$CONFIG_STATUS <<\_ACEOF
 
 #
+# CONFIG_HEADER section.
+#
+
+# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
+# NAME is the cpp macro being defined and VALUE is the value it is being given.
+#
+# ac_d sets the value in "#define NAME VALUE" lines.
+ac_dA='s,^\([	 ]*\)#\([	 ]*define[	 ][	 ]*\)'
+ac_dB='[	 ].*$,\1#\2'
+ac_dC=' '
+ac_dD=',;t'
+# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
+ac_uA='s,^\([	 ]*\)#\([	 ]*\)undef\([	 ][	 ]*\)'
+ac_uB='$,\1#\2define\3'
+ac_uC=' '
+ac_uD=',;t'
+
+for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
+  # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+  case $ac_file in
+  - | *:- | *:-:* ) # input from stdin
+	cat >$tmp/stdin
+	ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+	ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+  *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+	ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+  * )   ac_file_in=$ac_file.in ;;
+  esac
+
+  test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5
+echo "$as_me: creating $ac_file" >&6;}
+
+  # First look for the input files in the build tree, otherwise in the
+  # src tree.
+  ac_file_inputs=`IFS=:
+    for f in $ac_file_in; do
+      case $f in
+      -) echo $tmp/stdin ;;
+      [\\/$]*)
+	 # Absolute (can't be DOS-style, as IFS=:)
+	 test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+   { (exit 1); exit 1; }; }
+	 # Do quote $f, to prevent DOS paths from being IFS'd.
+	 echo "$f";;
+      *) # Relative
+	 if test -f "$f"; then
+	   # Build tree
+	   echo "$f"
+	 elif test -f "$srcdir/$f"; then
+	   # Source tree
+	   echo "$srcdir/$f"
+	 else
+	   # /dev/null tree
+	   { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+   { (exit 1); exit 1; }; }
+	 fi;;
+      esac
+    done` || { (exit 1); exit 1; }
+  # Remove the trailing spaces.
+  sed 's/[	 ]*$//' $ac_file_inputs >$tmp/in
+
+_ACEOF
+
+# Transform confdefs.h into two sed scripts, `conftest.defines' and
+# `conftest.undefs', that substitutes the proper values into
+# config.h.in to produce config.h.  The first handles `#define'
+# templates, and the second `#undef' templates.
+# And first: Protect against being on the right side of a sed subst in
+# config.status.  Protect against being in an unquoted here document
+# in config.status.
+rm -f conftest.defines conftest.undefs
+# Using a here document instead of a string reduces the quoting nightmare.
+# Putting comments in sed scripts is not portable.
+#
+# `end' is used to avoid that the second main sed command (meant for
+# 0-ary CPP macros) applies to n-ary macro definitions.
+# See the Autoconf documentation for `clear'.
+cat >confdef2sed.sed <<\_ACEOF
+s/[\\&,]/\\&/g
+s,[\\$`],\\&,g
+t clear
+: clear
+s,^[	 ]*#[	 ]*define[	 ][	 ]*\([^	 (][^	 (]*\)\(([^)]*)\)[	 ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp
+t end
+s,^[	 ]*#[	 ]*define[	 ][	 ]*\([^	 ][^	 ]*\)[	 ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp
+: end
+_ACEOF
+# If some macros were called several times there might be several times
+# the same #defines, which is useless.  Nevertheless, we may not want to
+# sort them, since we want the *last* AC-DEFINE to be honored.
+uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines
+sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs
+rm -f confdef2sed.sed
+
+# This sed command replaces #undef with comments.  This is necessary, for
+# example, in the case of _POSIX_SOURCE, which is predefined and required
+# on some systems where configure will not decide to define it.
+cat >>conftest.undefs <<\_ACEOF
+s,^[	 ]*#[	 ]*undef[	 ][	 ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */,
+_ACEOF
+
+# Break up conftest.defines because some shells have a limit on the size
+# of here documents, and old seds have small limits too (100 cmds).
+echo '  # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS
+echo '  if grep "^[	 ]*#[	 ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS
+echo '  # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS
+echo '  :' >>$CONFIG_STATUS
+rm -f conftest.tail
+while grep . conftest.defines >/dev/null
+do
+  # Write a limited-size here document to $tmp/defines.sed.
+  echo '  cat >$tmp/defines.sed <<CEOF' >>$CONFIG_STATUS
+  # Speed up: don't consider the non `#define' lines.
+  echo '/^[	 ]*#[	 ]*define/!b' >>$CONFIG_STATUS
+  # Work around the forget-to-reset-the-flag bug.
+  echo 't clr' >>$CONFIG_STATUS
+  echo ': clr' >>$CONFIG_STATUS
+  sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS
+  echo 'CEOF
+  sed -f $tmp/defines.sed $tmp/in >$tmp/out
+  rm -f $tmp/in
+  mv $tmp/out $tmp/in
+' >>$CONFIG_STATUS
+  sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail
+  rm -f conftest.defines
+  mv conftest.tail conftest.defines
+done
+rm -f conftest.defines
+echo '  fi # grep' >>$CONFIG_STATUS
+echo >>$CONFIG_STATUS
+
+# Break up conftest.undefs because some shells have a limit on the size
+# of here documents, and old seds have small limits too (100 cmds).
+echo '  # Handle all the #undef templates' >>$CONFIG_STATUS
+rm -f conftest.tail
+while grep . conftest.undefs >/dev/null
+do
+  # Write a limited-size here document to $tmp/undefs.sed.
+  echo '  cat >$tmp/undefs.sed <<CEOF' >>$CONFIG_STATUS
+  # Speed up: don't consider the non `#undef'
+  echo '/^[	 ]*#[	 ]*undef/!b' >>$CONFIG_STATUS
+  # Work around the forget-to-reset-the-flag bug.
+  echo 't clr' >>$CONFIG_STATUS
+  echo ': clr' >>$CONFIG_STATUS
+  sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS
+  echo 'CEOF
+  sed -f $tmp/undefs.sed $tmp/in >$tmp/out
+  rm -f $tmp/in
+  mv $tmp/out $tmp/in
+' >>$CONFIG_STATUS
+  sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail
+  rm -f conftest.undefs
+  mv conftest.tail conftest.undefs
+done
+rm -f conftest.undefs
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+  # Let's still pretend it is `configure' which instantiates (i.e., don't
+  # use $as_me), people would be surprised to read:
+  #    /* config.h.  Generated by config.status.  */
+  if test x"$ac_file" = x-; then
+    echo "/* Generated by configure.  */" >$tmp/config.h
+  else
+    echo "/* $ac_file.  Generated by configure.  */" >$tmp/config.h
+  fi
+  cat $tmp/in >>$tmp/config.h
+  rm -f $tmp/in
+  if test x"$ac_file" != x-; then
+    if diff $ac_file $tmp/config.h >/dev/null 2>&1; then
+      { echo "$as_me:$LINENO: $ac_file is unchanged" >&5
+echo "$as_me: $ac_file is unchanged" >&6;}
+    else
+      ac_dir=`(dirname "$ac_file") 2>/dev/null ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$ac_file" : 'X\(//\)[^/]' \| \
+	 X"$ac_file" : 'X\(//\)$' \| \
+	 X"$ac_file" : 'X\(/\)' \| \
+	 .     : '\(.\)' 2>/dev/null ||
+echo X"$ac_file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+  	  /^X\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`
+      { if $as_mkdir_p; then
+    mkdir -p "$ac_dir"
+  else
+    as_dir="$ac_dir"
+    as_dirs=
+    while test ! -d "$as_dir"; do
+      as_dirs="$as_dir $as_dirs"
+      as_dir=`(dirname "$as_dir") 2>/dev/null ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$as_dir" : 'X\(//\)[^/]' \| \
+	 X"$as_dir" : 'X\(//\)$' \| \
+	 X"$as_dir" : 'X\(/\)' \| \
+	 .     : '\(.\)' 2>/dev/null ||
+echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+  	  /^X\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`
+    done
+    test ! -n "$as_dirs" || mkdir $as_dirs
+  fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
+echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
+   { (exit 1); exit 1; }; }; }
+
+      rm -f $ac_file
+      mv $tmp/config.h $ac_file
+    fi
+  else
+    cat $tmp/config.h
+    rm -f $tmp/config.h
+  fi
+# Compute $ac_file's index in $config_headers.
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+  case $_am_header in
+    $ac_file | $ac_file:* )
+      break ;;
+    * )
+      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+  esac
+done
+echo "timestamp for $ac_file" >`(dirname $ac_file) 2>/dev/null ||
+$as_expr X$ac_file : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X$ac_file : 'X\(//\)[^/]' \| \
+	 X$ac_file : 'X\(//\)$' \| \
+	 X$ac_file : 'X\(/\)' \| \
+	 .     : '\(.\)' 2>/dev/null ||
+echo X$ac_file |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+  	  /^X\(\/\/\)$/{ s//\1/; q; }
+  	  /^X\(\/\).*/{ s//\1/; q; }
+  	  s/.*/./; q'`/stamp-h$_am_stamp_count
+done
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+#
 # CONFIG_COMMANDS section.
 #
 for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue
@@ -20978,6 +23629,7 @@
 
 
 if test "x$src" = "x"; then
+echo "**IMPORTANT**"
 echo "You don't seem to have the development package for libogg (libogg-devel) installed. Only the Speex library (libspeex) will be built (no encoder/decoder executable)"
 echo "You can download libogg from http://www.vorbis.com/download.psp"
 fi

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/configure.ac
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/configure.ac	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/configure.ac	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,194 @@
+dnl Process this file with autoconf to produce a configure script. -*-m4-*-
+
+AC_INIT(libspeex/speex.c)
+
+AM_CONFIG_HEADER([config.h])
+
+SPEEX_MAJOR_VERSION=1
+SPEEX_MINOR_VERSION=1
+SPEEX_MICRO_VERSION=10
+SPEEX_EXTRA_VERSION=
+#SPEEX_VERSION=
+SPEEX_VERSION=$SPEEX_MAJOR_VERSION.$SPEEX_MINOR_VERSION.$SPEEX_MICRO_VERSION$SPEEX_EXTRA_VERSION
+
+SPEEX_LT_CURRENT=3
+SPEEX_LT_REVISION=0
+SPEEX_LT_AGE=2
+
+AC_SUBST(SPEEX_LT_CURRENT)
+AC_SUBST(SPEEX_LT_REVISION)
+AC_SUBST(SPEEX_LT_AGE)
+
+# For automake.
+VERSION=$SPEEX_VERSION
+PACKAGE=speex
+
+AC_SUBST(SPEEX_VERSION)
+
+AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
+AM_MAINTAINER_MODE
+
+AC_CANONICAL_HOST
+AM_PROG_LIBTOOL
+
+AC_C_BIGENDIAN
+AC_C_CONST
+AC_C_INLINE
+AC_C_RESTRICT
+
+
+AC_MSG_CHECKING(for C99 variable-size arrays)
+AC_TRY_COMPILE( , [
+int foo=10;
+int array[foo];
+],
+[has_var_arrays=yes;AC_DEFINE([VAR_ARRAYS], [], [Use C99 variable-size arrays])
+],
+has_var_arrays=no
+)
+AC_MSG_RESULT($has_var_arrays)
+
+AC_MSG_CHECKING(for alloca)
+AC_TRY_COMPILE( [#include <alloca.h>], [
+int foo=10;
+int *array = alloca(foo);
+],
+[
+has_alloca=yes;
+if test x$has_var_arrays = "xno" ; then
+AC_DEFINE([USE_ALLOCA], [], [Make use of alloca])
+fi
+],
+has_alloca=no
+)
+AC_MSG_RESULT($has_alloca)
+
+
+AC_CHECK_HEADERS(sys/soundcard.h sys/audioio.h)
+
+XIPH_PATH_OGG([src="src"], [src=""])
+AC_SUBST(src)
+
+AC_CHECK_LIB(m, sin)
+
+# Check for getopt_long; if not found, use included source.
+AC_CHECK_FUNCS([getopt_long],,
+[# FreeBSD has a gnugetopt library.
+  AC_CHECK_LIB([gnugetopt],[getopt_long],
+[AC_DEFINE([HAVE_GETOPT_LONG])],
+[# Use the GNU replacement.
+AC_LIBOBJ(getopt)
+AC_LIBOBJ(getopt1)])])
+
+AC_CHECK_LIB(winmm, main)
+
+AC_DEFINE_UNQUOTED(SPEEX_VERSION, "${SPEEX_VERSION}", [Complete version string])
+AC_DEFINE_UNQUOTED(SPEEX_MAJOR_VERSION, ${SPEEX_MAJOR_VERSION}, [Version major])
+AC_DEFINE_UNQUOTED(SPEEX_MINOR_VERSION, ${SPEEX_MINOR_VERSION}, [Version minor])
+AC_DEFINE_UNQUOTED(SPEEX_MICRO_VERSION, ${SPEEX_MICRO_VERSION}, [Version micro])
+AC_DEFINE_UNQUOTED(SPEEX_EXTRA_VERSION, "${SPEEX_EXTRA_VERSION}", [Version extra])
+
+AC_ARG_ENABLE(wideband, [  --disable-wideband      Disable wideband codec],
+[if test "$enableval" = no; then
+  AC_DEFINE([DISABLE_WIDEBAND], , [Disable wideband codec])
+fi])
+
+AC_ARG_ENABLE(valgrind, [  --enable-valgrind       Enable valgrind extra checks],
+[if test "$enableval" = yes; then
+  AC_DEFINE([ENABLE_VALGRIND], , [Enable valgrind extra checks])
+fi])
+
+AC_ARG_ENABLE(sse, [  --enable-sse            Enable SSE support], [if test "$enableval" = yes; then
+AC_DEFINE([_USE_SSE], , [Enable SSE support])
+CFLAGS="$CFLAGS -O3 -msse"
+fi
+])
+
+AC_ARG_ENABLE(fixed-point, [  --enable-fixed-point    Compile as fixed-point],
+[if test "$enableval" = yes; then
+  AC_DEFINE([FIXED_POINT], , [Compile as fixed-point])
+fi])
+
+AC_ARG_ENABLE(arm4-asm, [  --enable-arm4-asm       Make use of ARM4 assembly optimizations],
+[if test "$enableval" = yes; then
+  AC_DEFINE([ARM4_ASM], , [Make use of ARM4 assembly optimizations])
+fi])
+
+AC_ARG_ENABLE(arm5e-asm, [  --enable-arm5e-asm      Make use of ARM5E assembly optimizations],
+[if test "$enableval" = yes; then
+  AC_DEFINE([ARM5_ASM], , [Make use of ARM5E assembly optimizations])
+fi])
+
+AC_ARG_ENABLE(blackfin-asm, [  --enable-blackfin-asm      Make use of Blackfin assembly optimizations],
+[if test "$enableval" = yes; then
+  AC_DEFINE([BFIN_ASM], , [Make use of Blackfin assembly optimizations])
+fi])
+
+AC_ARG_ENABLE(fixed-point-debug, [  --enable-fixed-point-debug  Debug fixed-point implementation],
+[if test "$enableval" = yes; then
+  AC_DEFINE([FIXED_DEBUG], , [Debug fixed-point implementation])
+fi])
+
+AC_ARG_ENABLE(epic-48k, [  --enable-epic-48k       Enable support for Epic 4.8 kbps mode],
+[if test "$enableval" = yes; then
+  AC_DEFINE([EPIC_48K], , [Enable support for Epic 4.8 kbps mode])
+fi])
+
+AC_ARG_ENABLE(ti-c55x, [  --enable-ti-c55x        Enable support for TI C55X DSP],
+[if test "$enableval" = yes; then
+  has_char16=yes;
+  AC_DEFINE([TI_C55X], , [Enable support for TI C55X DSP])
+fi])
+
+AC_ARG_ENABLE(16bit-precision, [  --enable-16bit-precision Reduce precision to 16 bits (EXPERIMENTAL)],
+[if test "$enableval" = yes; then
+  AC_DEFINE([PRECISION16], , [Reduce precision to 16 bits (EXPERIMENTAL)])
+fi])
+
+AC_CHECK_SIZEOF(short)
+AC_CHECK_SIZEOF(int)
+AC_CHECK_SIZEOF(long)
+AC_CHECK_SIZEOF(long long)
+
+if test x$has_char16 = "xyes" ; then
+        case 1 in
+                $ac_cv_sizeof_short) SIZE16="short";;
+                $ac_cv_sizeof_int) SIZE16="int";;
+        esac
+else
+        case 2 in
+                $ac_cv_sizeof_short) SIZE16="short";;
+                $ac_cv_sizeof_int) SIZE16="int";;
+        esac
+fi
+
+if test x$has_char16 = "xyes" ; then
+        case 2 in
+                $ac_cv_sizeof_int) SIZE32="int";;
+                $ac_cv_sizeof_long) SIZE32="long";;
+                $ac_cv_sizeof_short) SIZE32="short";;
+        esac
+else
+        case 4 in
+                $ac_cv_sizeof_int) SIZE32="int";;
+                $ac_cv_sizeof_long) SIZE32="long";;
+                $ac_cv_sizeof_short) SIZE32="short";;
+        esac
+fi
+
+AC_SUBST(SIZE16)
+AC_SUBST(SIZE32)
+
+AC_OUTPUT([Makefile libspeex/Makefile src/Makefile doc/Makefile Speex.spec
+           include/Makefile include/speex/Makefile speex.pc
+           win32/Makefile win32/libspeex/Makefile win32/speexenc/Makefile
+           win32/speexdec/Makefile symbian/Makefile 
+           include/speex/speex_config_types.h ])
+
+if test "x$src" = "x"; then 
+echo "**IMPORTANT**"
+echo "You don't seem to have the development package for libogg (libogg-devel) installed. Only the Speex library (libspeex) will be built (no encoder/decoder executable)"
+echo "You can download libogg from http://www.vorbis.com/download.psp"
+fi
+
+echo "Type \"make; make install\" to compile and install Speex";

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/depcomp
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/depcomp	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/depcomp	2005-10-20 12:42:06 UTC (rev 10202)
@@ -1,10 +1,8 @@
 #! /bin/sh
+
 # depcomp - compile a program generating dependencies as side-effects
+# Copyright 1999, 2000 Free Software Foundation, Inc.
 
-scriptversion=2004-04-25.13
-
-# Copyright (C) 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
-
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 2, or (at your option)
@@ -27,36 +25,6 @@
 
 # Originally written by Alexandre Oliva <oliva at dcc.unicamp.br>.
 
-case $1 in
-  '')
-     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
-     exit 1;
-     ;;
-  -h | --h*)
-    cat <<\EOF
-Usage: depcomp [--help] [--version] PROGRAM [ARGS]
-
-Run PROGRAMS ARGS to compile a file, generating dependencies
-as side-effects.
-
-Environment variables:
-  depmode     Dependency tracking mode.
-  source      Source file read by `PROGRAMS ARGS'.
-  object      Object file output by `PROGRAMS ARGS'.
-  depfile     Dependency file to output.
-  tmpdepfile  Temporary file to use when outputing dependencies.
-  libtool     Whether libtool is used (yes/no).
-
-Report bugs to <bug-automake at gnu.org>.
-EOF
-    exit 0
-    ;;
-  -v | --v*)
-    echo "depcomp $scriptversion"
-    exit 0
-    ;;
-esac
-
 if test -z "$depmode" || test -z "$source" || test -z "$object"; then
   echo "depcomp: Variables source, object and depmode must be set" 1>&2
   exit 1
@@ -204,25 +172,19 @@
 
 aix)
   # The C for AIX Compiler uses -M and outputs the dependencies
-  # in a .u file.  In older versions, this file always lives in the
-  # current directory.  Also, the AIX compiler puts `$object:' at the
-  # start of each line; $object doesn't have directory information.
-  # Version 6 uses the directory in both cases.
-  stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
+  # in a .u file.  This file always lives in the current directory.
+  # Also, the AIX compiler puts `$object:' at the start of each line;
+  # $object doesn't have directory information.
+  stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'`
   tmpdepfile="$stripped.u"
+  outname="$stripped.o"
   if test "$libtool" = yes; then
     "$@" -Wc,-M
   else
     "$@" -M
   fi
-  stat=$?
 
-  if test -f "$tmpdepfile"; then :
-  else
-    stripped=`echo "$stripped" | sed 's,^.*/,,'`
-    tmpdepfile="$stripped.u"
-  fi
-
+  stat=$?
   if test $stat -eq 0; then :
   else
     rm -f "$tmpdepfile"
@@ -230,7 +192,6 @@
   fi
 
   if test -f "$tmpdepfile"; then
-    outname="$stripped.o"
     # Each line is of the form `foo.o: dependent.h'.
     # Do two passes, one to just change these to
     # `$object: dependent.h' and one to simply `dependent.h:'.
@@ -245,44 +206,6 @@
   rm -f "$tmpdepfile"
   ;;
 
-icc)
-  # Intel's C compiler understands `-MD -MF file'.  However on
-  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
-  # ICC 7.0 will fill foo.d with something like
-  #    foo.o: sub/foo.c
-  #    foo.o: sub/foo.h
-  # which is wrong.  We want:
-  #    sub/foo.o: sub/foo.c
-  #    sub/foo.o: sub/foo.h
-  #    sub/foo.c:
-  #    sub/foo.h:
-  # ICC 7.1 will output
-  #    foo.o: sub/foo.c sub/foo.h
-  # and will wrap long lines using \ :
-  #    foo.o: sub/foo.c ... \
-  #     sub/foo.h ... \
-  #     ...
-
-  "$@" -MD -MF "$tmpdepfile"
-  stat=$?
-  if test $stat -eq 0; then :
-  else
-    rm -f "$tmpdepfile"
-    exit $stat
-  fi
-  rm -f "$depfile"
-  # Each line is of the form `foo.o: dependent.h',
-  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
-  # Do two passes, one to just change these to
-  # `$object: dependent.h' and one to simply `dependent.h:'.
-  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
-  # Some versions of the HPUX 10.20 sed can't process this invocation
-  # correctly.  Breaking it into two sed invocations is a workaround.
-  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
-    sed -e 's/$/ :/' >> "$depfile"
-  rm -f "$tmpdepfile"
-  ;;
-
 tru64)
    # The Tru64 compiler uses -MD to generate dependencies as a side
    # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
@@ -294,37 +217,31 @@
    base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
 
    if test "$libtool" = yes; then
-      # Dependencies are output in .lo.d with libtool 1.4.
-      # They are output in .o.d with libtool 1.5.
       tmpdepfile1="$dir.libs/$base.lo.d"
-      tmpdepfile2="$dir.libs/$base.o.d"
-      tmpdepfile3="$dir.libs/$base.d"
+      tmpdepfile2="$dir.libs/$base.d"
       "$@" -Wc,-MD
    else
       tmpdepfile1="$dir$base.o.d"
       tmpdepfile2="$dir$base.d"
-      tmpdepfile3="$dir$base.d"
       "$@" -MD
    fi
 
    stat=$?
    if test $stat -eq 0; then :
    else
-      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+      rm -f "$tmpdepfile1" "$tmpdepfile2"
       exit $stat
    fi
 
    if test -f "$tmpdepfile1"; then
       tmpdepfile="$tmpdepfile1"
-   elif test -f "$tmpdepfile2"; then
-      tmpdepfile="$tmpdepfile2"
    else
-      tmpdepfile="$tmpdepfile3"
+      tmpdepfile="$tmpdepfile2"
    fi
    if test -f "$tmpdepfile"; then
       sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
-      # That's a tab and a space in the [].
-      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+      # That's a space and a tab in the [].
+      sed -e 's,^.*\.[a-z]*:[ 	]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
    else
       echo "#dummy" > "$depfile"
    fi
@@ -337,7 +254,7 @@
 
 dashmstdout)
   # Important note: in order to support this mode, a compiler *must*
-  # always write the preprocessed file to stdout, regardless of -o.
+  # always write the proprocessed file to stdout, regardless of -o.
   "$@" || exit $?
 
   # Remove the call to Libtool.
@@ -348,7 +265,9 @@
     shift
   fi
 
-  # Remove `-o $object'.
+  # Remove `-o $object'.  We will use -o /dev/null later,
+  # however we can't do the remplacement now because
+  # `-o $object' might simply not be used
   IFS=" "
   for arg
   do
@@ -368,11 +287,7 @@
   done
 
   test -z "$dashmflag" && dashmflag=-M
-  # Require at least two characters before searching for `:'
-  # in the target name.  This is to cope with DOS-style filenames:
-  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
-  "$@" $dashmflag |
-    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
+  "$@" -o /dev/null $dashmflag | sed 's:^[^:]*\:[ 	]*:'"$object"'\: :' > "$tmpdepfile"
   rm -f "$depfile"
   cat < "$tmpdepfile" > "$depfile"
   tr ' ' '
@@ -391,13 +306,6 @@
 
 makedepend)
   "$@" || exit $?
-  # Remove any Libtool call
-  if test "$libtool" = yes; then
-    while test $1 != '--mode=compile'; do
-      shift
-    done
-    shift
-  fi
   # X makedepend
   shift
   cleared=no
@@ -410,9 +318,7 @@
     case "$arg" in
     -D*|-I*)
       set fnord "$@" "$arg"; shift ;;
-    # Strip any option that makedepend may not understand.  Remove
-    # the object too, otherwise makedepend will parse it as a source file.
-    -*|$object)
+    -*)
       ;;
     *)
       set fnord "$@" "$arg"; shift ;;
@@ -433,7 +339,7 @@
 
 cpp)
   # Important note: in order to support this mode, a compiler *must*
-  # always write the preprocessed file to stdout.
+  # always write the proprocessed file to stdout.
   "$@" || exit $?
 
   # Remove the call to Libtool.
@@ -475,7 +381,7 @@
 
 msvisualcpp)
   # Important note: in order to support this mode, a compiler *must*
-  # always write the preprocessed file to stdout, regardless of -o,
+  # always write the proprocessed file to stdout, regardless of -o,
   # because we must use -o when running libtool.
   "$@" || exit $?
   IFS=" "
@@ -515,12 +421,3 @@
 esac
 
 exit 0
-
-# Local Variables:
-# mode: shell-script
-# sh-indentation: 2
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
-# End:

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/doc/Makefile.in
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/doc/Makefile.in	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/doc/Makefile.in	2005-10-20 12:42:06 UTC (rev 10202)
@@ -39,10 +39,11 @@
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 SOURCES =
 DIST_SOURCES =
@@ -94,8 +95,7 @@
 MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 OBJEXT = @OBJEXT@
-OGG_INCLUDES = @OGG_INCLUDES@
-OGG_LDFLAGS = @OGG_LDFLAGS@
+OGG_CFLAGS = @OGG_CFLAGS@
 OGG_LIBS = @OGG_LIBS@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -107,9 +107,12 @@
 RANLIB = @RANLIB@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
+SIZE16 = @SIZE16@
+SIZE32 = @SIZE32@
 SPEEX_LT_AGE = @SPEEX_LT_AGE@
 SPEEX_LT_CURRENT = @SPEEX_LT_CURRENT@
 SPEEX_LT_REVISION = @SPEEX_LT_REVISION@
+SPEEX_VERSION = @SPEEX_VERSION@
 STRIP = @STRIP@
 VERSION = @VERSION@
 ac_ct_AR = @ac_ct_AR@

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/doc/manual.pdf
===================================================================
(Binary files differ)

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/Makefile.am
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/Makefile.am	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/Makefile.am	2005-10-20 12:42:06 UTC (rev 10202)
@@ -1,9 +1,2 @@
 
 SUBDIRS = speex
-
-include_HEADERS =  speex.h \
-	speex_bits.h \
-	speex_header.h \
-	speex_callbacks.h \
-	speex_stereo.h
-

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/Makefile.in
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/Makefile.in	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/Makefile.in	2005-10-20 12:42:06 UTC (rev 10202)
@@ -13,7 +13,6 @@
 # PARTICULAR PURPOSE.
 
 @SET_MAKE@
-
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
@@ -36,14 +35,14 @@
 POST_UNINSTALL = :
 host_triplet = @host@
 subdir = include
-DIST_COMMON = $(include_HEADERS) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 SOURCES =
 DIST_SOURCES =
@@ -53,9 +52,6 @@
 	install-recursive installcheck-recursive installdirs-recursive \
 	pdf-recursive ps-recursive uninstall-info-recursive \
 	uninstall-recursive
-am__installdirs = "$(DESTDIR)$(includedir)"
-includeHEADERS_INSTALL = $(INSTALL_HEADER)
-HEADERS = $(include_HEADERS)
 ETAGS = etags
 CTAGS = ctags
 DIST_SUBDIRS = $(SUBDIRS)
@@ -104,8 +100,7 @@
 MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 OBJEXT = @OBJEXT@
-OGG_INCLUDES = @OGG_INCLUDES@
-OGG_LDFLAGS = @OGG_LDFLAGS@
+OGG_CFLAGS = @OGG_CFLAGS@
 OGG_LIBS = @OGG_LIBS@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -117,9 +112,12 @@
 RANLIB = @RANLIB@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
+SIZE16 = @SIZE16@
+SIZE32 = @SIZE32@
 SPEEX_LT_AGE = @SPEEX_LT_AGE@
 SPEEX_LT_CURRENT = @SPEEX_LT_CURRENT@
 SPEEX_LT_REVISION = @SPEEX_LT_REVISION@
+SPEEX_VERSION = @SPEEX_VERSION@
 STRIP = @STRIP@
 VERSION = @VERSION@
 ac_ct_AR = @ac_ct_AR@
@@ -165,12 +163,6 @@
 sysconfdir = @sysconfdir@
 target_alias = @target_alias@
 SUBDIRS = speex
-include_HEADERS = speex.h \
-	speex_bits.h \
-	speex_header.h \
-	speex_callbacks.h \
-	speex_stereo.h
-
 all: all-recursive
 
 .SUFFIXES:
@@ -213,24 +205,7 @@
 distclean-libtool:
 	-rm -f libtool
 uninstall-info-am:
-install-includeHEADERS: $(include_HEADERS)
-	@$(NORMAL_INSTALL)
-	test -z "$(includedir)" || $(mkdir_p) "$(DESTDIR)$(includedir)"
-	@list='$(include_HEADERS)'; for p in $$list; do \
-	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
-	  f="`echo $$p | sed -e 's|^.*/||'`"; \
-	  echo " $(includeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(includedir)/$$f'"; \
-	  $(includeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(includedir)/$$f"; \
-	done
 
-uninstall-includeHEADERS:
-	@$(NORMAL_UNINSTALL)
-	@list='$(include_HEADERS)'; for p in $$list; do \
-	  f="`echo $$p | sed -e 's|^.*/||'`"; \
-	  echo " rm -f '$(DESTDIR)$(includedir)/$$f'"; \
-	  rm -f "$(DESTDIR)$(includedir)/$$f"; \
-	done
-
 # This directory's subdirectories are mostly independent; you can cd
 # into them and run `make' without going through this Makefile.
 # To change the values of `make' variables: instead of editing Makefiles,
@@ -393,12 +368,9 @@
 	done
 check-am: all-am
 check: check-recursive
-all-am: Makefile $(HEADERS)
+all-am: Makefile
 installdirs: installdirs-recursive
 installdirs-am:
-	for dir in "$(DESTDIR)$(includedir)"; do \
-	  test -z "$$dir" || $(mkdir_p) "$$dir"; \
-	done
 install: install-recursive
 install-exec: install-exec-recursive
 install-data: install-data-recursive
@@ -442,7 +414,7 @@
 
 info-am:
 
-install-data-am: install-includeHEADERS
+install-data-am:
 
 install-exec-am:
 
@@ -468,7 +440,7 @@
 
 ps-am:
 
-uninstall-am: uninstall-includeHEADERS uninstall-info-am
+uninstall-am: uninstall-info-am
 
 uninstall-info: uninstall-info-recursive
 
@@ -477,15 +449,13 @@
 	ctags-recursive distclean distclean-generic distclean-libtool \
 	distclean-recursive distclean-tags distdir dvi dvi-am html \
 	html-am info info-am install install-am install-data \
-	install-data-am install-exec install-exec-am \
-	install-includeHEADERS install-info install-info-am \
-	install-man install-strip installcheck installcheck-am \
-	installdirs installdirs-am maintainer-clean \
+	install-data-am install-exec install-exec-am install-info \
+	install-info-am install-man install-strip installcheck \
+	installcheck-am installdirs installdirs-am maintainer-clean \
 	maintainer-clean-generic maintainer-clean-recursive \
 	mostlyclean mostlyclean-generic mostlyclean-libtool \
 	mostlyclean-recursive pdf pdf-am ps ps-am tags tags-recursive \
-	uninstall uninstall-am uninstall-includeHEADERS \
-	uninstall-info-am
+	uninstall uninstall-am uninstall-info-am
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/Makefile.am
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/Makefile.am	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/Makefile.am	2005-10-20 12:42:06 UTC (rev 10202)
@@ -1,9 +1,15 @@
 # Disable automatic dependency tracking if using other tools than gcc and gmake
 #AUTOMAKE_OPTIONS = no-dependencies
 
+nodist_pkginclude_HEADERS = speex_config_types.h
+
 pkginclude_HEADERS =  speex.h \
+	speex_types.h \
 	speex_bits.h \
 	speex_header.h \
 	speex_callbacks.h \
-	speex_stereo.h
+	speex_stereo.h \
+	speex_preprocess.h \
+	speex_jitter.h \
+	speex_echo.h
 

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/Makefile.in
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/Makefile.in	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/Makefile.in	2005-10-20 12:42:06 UTC (rev 10202)
@@ -40,19 +40,21 @@
 host_triplet = @host@
 subdir = include/speex
 DIST_COMMON = $(pkginclude_HEADERS) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in
+	$(srcdir)/Makefile.in $(srcdir)/speex_config_types.h.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-CONFIG_CLEAN_FILES =
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES = speex_config_types.h
 SOURCES =
 DIST_SOURCES =
-am__installdirs = "$(DESTDIR)$(pkgincludedir)"
+am__installdirs = "$(DESTDIR)$(pkgincludedir)" "$(DESTDIR)$(pkgincludedir)"
+nodist_pkgincludeHEADERS_INSTALL = $(INSTALL_HEADER)
 pkgincludeHEADERS_INSTALL = $(INSTALL_HEADER)
-HEADERS = $(pkginclude_HEADERS)
+HEADERS = $(nodist_pkginclude_HEADERS) $(pkginclude_HEADERS)
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -100,8 +102,7 @@
 MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 OBJEXT = @OBJEXT@
-OGG_INCLUDES = @OGG_INCLUDES@
-OGG_LDFLAGS = @OGG_LDFLAGS@
+OGG_CFLAGS = @OGG_CFLAGS@
 OGG_LIBS = @OGG_LIBS@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -113,9 +114,12 @@
 RANLIB = @RANLIB@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
+SIZE16 = @SIZE16@
+SIZE32 = @SIZE32@
 SPEEX_LT_AGE = @SPEEX_LT_AGE@
 SPEEX_LT_CURRENT = @SPEEX_LT_CURRENT@
 SPEEX_LT_REVISION = @SPEEX_LT_REVISION@
+SPEEX_VERSION = @SPEEX_VERSION@
 STRIP = @STRIP@
 VERSION = @VERSION@
 ac_ct_AR = @ac_ct_AR@
@@ -160,11 +164,16 @@
 src = @src@
 sysconfdir = @sysconfdir@
 target_alias = @target_alias@
+nodist_pkginclude_HEADERS = speex_config_types.h
 pkginclude_HEADERS = speex.h \
+	speex_types.h \
 	speex_bits.h \
 	speex_header.h \
 	speex_callbacks.h \
-	speex_stereo.h
+	speex_stereo.h \
+	speex_preprocess.h \
+	speex_jitter.h \
+	speex_echo.h
 
 all: all-am
 
@@ -198,6 +207,8 @@
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+speex_config_types.h: $(top_builddir)/config.status $(srcdir)/speex_config_types.h.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
 
 mostlyclean-libtool:
 	-rm -f *.lo
@@ -208,6 +219,23 @@
 distclean-libtool:
 	-rm -f libtool
 uninstall-info-am:
+install-nodist_pkgincludeHEADERS: $(nodist_pkginclude_HEADERS)
+	@$(NORMAL_INSTALL)
+	test -z "$(pkgincludedir)" || $(mkdir_p) "$(DESTDIR)$(pkgincludedir)"
+	@list='$(nodist_pkginclude_HEADERS)'; for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  f="`echo $$p | sed -e 's|^.*/||'`"; \
+	  echo " $(nodist_pkgincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(pkgincludedir)/$$f'"; \
+	  $(nodist_pkgincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(pkgincludedir)/$$f"; \
+	done
+
+uninstall-nodist_pkgincludeHEADERS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(nodist_pkginclude_HEADERS)'; for p in $$list; do \
+	  f="`echo $$p | sed -e 's|^.*/||'`"; \
+	  echo " rm -f '$(DESTDIR)$(pkgincludedir)/$$f'"; \
+	  rm -f "$(DESTDIR)$(pkgincludedir)/$$f"; \
+	done
 install-pkgincludeHEADERS: $(pkginclude_HEADERS)
 	@$(NORMAL_INSTALL)
 	test -z "$(pkgincludedir)" || $(mkdir_p) "$(DESTDIR)$(pkgincludedir)"
@@ -305,7 +333,7 @@
 check: check-am
 all-am: Makefile $(HEADERS)
 installdirs:
-	for dir in "$(DESTDIR)$(pkgincludedir)"; do \
+	for dir in "$(DESTDIR)$(pkgincludedir)" "$(DESTDIR)$(pkgincludedir)"; do \
 	  test -z "$$dir" || $(mkdir_p) "$$dir"; \
 	done
 install: install-am
@@ -351,7 +379,8 @@
 
 info-am:
 
-install-data-am: install-pkgincludeHEADERS
+install-data-am: install-nodist_pkgincludeHEADERS \
+	install-pkgincludeHEADERS
 
 install-exec-am:
 
@@ -377,19 +406,21 @@
 
 ps-am:
 
-uninstall-am: uninstall-info-am uninstall-pkgincludeHEADERS
+uninstall-am: uninstall-info-am uninstall-nodist_pkgincludeHEADERS \
+	uninstall-pkgincludeHEADERS
 
 .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
 	clean-libtool ctags distclean distclean-generic \
 	distclean-libtool distclean-tags distdir dvi dvi-am html \
 	html-am info info-am install install-am install-data \
 	install-data-am install-exec install-exec-am install-info \
-	install-info-am install-man install-pkgincludeHEADERS \
-	install-strip installcheck installcheck-am installdirs \
-	maintainer-clean maintainer-clean-generic mostlyclean \
-	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
-	tags uninstall uninstall-am uninstall-info-am \
-	uninstall-pkgincludeHEADERS
+	install-info-am install-man install-nodist_pkgincludeHEADERS \
+	install-pkgincludeHEADERS install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-generic \
+	mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
+	uninstall-am uninstall-info-am \
+	uninstall-nodist_pkgincludeHEADERS uninstall-pkgincludeHEADERS
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -36,7 +36,8 @@
 #ifndef SPEEX_H
 #define SPEEX_H
 
-#include "speex_bits.h"
+#include "speex/speex_bits.h"
+#include "speex/speex_types.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -56,7 +57,7 @@
 /** Set quality value */
 #define SPEEX_SET_QUALITY 4
 /** Get current quality setting */
-#define SPEEX_GET_QUALITY 5
+/* #define SPEEX_GET_QUALITY 5 -- Doesn't make much sense, does it? */
 
 /** Set sub-mode to use */
 #define SPEEX_SET_MODE 6
@@ -126,9 +127,19 @@
 /** Get DTX status (1 for on, 0 for off) */
 #define SPEEX_GET_DTX 35
 
-/* 36 and 37 aren't supported in this version */
+/** Set submode encoding in each frame (1 for yes, 0 for no, setting to no breaks the standard) */
+#define SPEEX_SET_SUBMODE_ENCODING 36
+/** */
+#define SPEEX_GET_SUBMODE_ENCODING 37
+
+/*#define SPEEX_SET_LOOKAHEAD 38*/
+/** Returns the lookahead used by Speex */
 #define SPEEX_GET_LOOKAHEAD 39
 
+/** Sets tuning for packet-loss concealment (expected loss rate) */
+#define SPEEX_SET_PLC_TUNING 40
+/** Gets tuning for PLC */
+#define SPEEX_GET_PLC_TUNING 41
 
 /* Used internally, not to be used in applications */
 /** Used internally*/
@@ -148,6 +159,8 @@
 #define SPEEX_GET_PF 1
 
 
+
+
 /* Values allowed for mode queries */
 /** Query the frame size of a mode */
 #define SPEEX_MODE_FRAME_SIZE 0
@@ -155,58 +168,85 @@
 /** Query the size of an encoded frame for a particular sub-mode */
 #define SPEEX_SUBMODE_BITS_PER_FRAME 1
 
+
+
 #define SPEEX_LIB_GET_MAJOR_VERSION 1
 #define SPEEX_LIB_GET_MINOR_VERSION 3
 #define SPEEX_LIB_GET_MICRO_VERSION 5
 #define SPEEX_LIB_GET_EXTRA_VERSION 7
 #define SPEEX_LIB_GET_VERSION_STRING 9
 
+/*#define SPEEX_LIB_SET_ALLOC_FUNC 10
+#define SPEEX_LIB_GET_ALLOC_FUNC 11
+#define SPEEX_LIB_SET_FREE_FUNC 12
+#define SPEEX_LIB_GET_FREE_FUNC 13
+
+#define SPEEX_LIB_SET_WARNING_FUNC 14
+#define SPEEX_LIB_GET_WARNING_FUNC 15
+#define SPEEX_LIB_SET_ERROR_FUNC 16
+#define SPEEX_LIB_GET_ERROR_FUNC 17
+*/
+
 /** Number of defined modes in Speex */
 #define SPEEX_NB_MODES 3
 
+/** modeID for the defined narrowband mode */
+#define SPEEX_MODEID_NB 0
+
+/** modeID for the defined wideband mode */
+#define SPEEX_MODEID_WB 1
+
+/** modeID for the defined ultra-wideband mode */
+#define SPEEX_MODEID_UWB 2
+
+#ifdef EPIC_48K
+/** modeID for the Epic 48K mode */
+#define SPEEX_MODEID_NB_48K 1000
+#endif
+
 struct SpeexMode;
 
 
 /* Prototypes for mode function pointers */
 
 /** Encoder state initialization function */
-typedef void *(*encoder_init_func)(struct SpeexMode *mode);
+typedef void *(*encoder_init_func)(const struct SpeexMode *mode);
 
 /** Encoder state destruction function */
 typedef void (*encoder_destroy_func)(void *st);
 
 /** Main encoding function */
-typedef int (*encode_func)(void *state, float *in, SpeexBits *bits);
+typedef int (*encode_func)(void *state, void *in, SpeexBits *bits);
 
 /** Function for controlling the encoder options */
 typedef int (*encoder_ctl_func)(void *state, int request, void *ptr);
 
 /** Decoder state initialization function */
-typedef void *(*decoder_init_func)(struct SpeexMode *mode);
+typedef void *(*decoder_init_func)(const struct SpeexMode *mode);
 
 /** Decoder state destruction function */
 typedef void (*decoder_destroy_func)(void *st);
 
 /** Main decoding function */
-typedef int  (*decode_func)(void *state, SpeexBits *bits, float *out);
+typedef int  (*decode_func)(void *state, SpeexBits *bits, void *out);
 
 /** Function for controlling the decoder options */
 typedef int (*decoder_ctl_func)(void *state, int request, void *ptr);
 
 
 /** Query function for a mode */
-typedef int (*mode_query_func)(void *mode, int request, void *ptr);
+typedef int (*mode_query_func)(const void *mode, int request, void *ptr);
 
 /** Struct defining a Speex mode */ 
 typedef struct SpeexMode {
    /** Pointer to the low-level mode data */
-   void *mode;
+   const void *mode;
 
    /** Pointer to the mode query function */
    mode_query_func query;
    
    /** The name of the mode (you should not rely on this to identify the mode)*/
-   char *modeName;
+   const char *modeName;
 
    /**ID of the mode*/
    int modeID;
@@ -250,7 +290,7 @@
  * @param mode The mode to use (either speex_nb_mode or speex_wb.mode) 
  * @return A newly created encoder
  */
-void *speex_encoder_init(SpeexMode *mode);
+void *speex_encoder_init(const SpeexMode *mode);
 
 /** Frees all resources associated to an existing Speex encoder state. 
  * @param state Encoder state to be destroyed */
@@ -259,11 +299,19 @@
 /** Uses an existing encoder state to encode one frame of speech pointed to by
     "in". The encoded bit-stream is saved in "bits".
  @param state Encoder state
- @param in Frame that will be encoded with a +-2^16 range
+ @param in Frame that will be encoded with a +-2^15 range
  @param bits Bit-stream where the data will be written
  */
 int speex_encode(void *state, float *in, SpeexBits *bits);
 
+/** Uses an existing encoder state to encode one frame of speech pointed to by
+    "in". The encoded bit-stream is saved in "bits".
+ @param state Encoder state
+ @param in Frame that will be encoded with a +-2^15 range
+ @param bits Bit-stream where the data will be written
+ */
+int speex_encode_int(void *state, spx_int16_t *in, SpeexBits *bits);
+
 /** Used like the ioctl function to control the encoder parameters
  *
  * @param state Encoder state
@@ -282,7 +330,7 @@
  * @param mode Speex mode (one of speex_nb_mode or speex_wb_mode)
  * @return A newly created decoder state
  */ 
-void *speex_decoder_init(SpeexMode *mode);
+void *speex_decoder_init(const SpeexMode *mode);
 
 /** Frees all resources associated to an existing decoder state.
  *
@@ -300,6 +348,16 @@
  */
 int speex_decode(void *state, SpeexBits *bits, float *out);
 
+/** Uses an existing decoder state to decode one frame of speech from
+ * bit-stream bits. The output speech is saved written to out.
+ *
+ * @param state Decoder state
+ * @param bits Bit-stream from which to decode the frame (NULL if the packet was lost)
+ * @param out Where to write the decoded frame
+ * @return return status (0 for no error, -1 for end of stream, -2 other)
+ */
+int speex_decode_int(void *state, SpeexBits *bits, spx_int16_t *out);
+
 /** Used like the ioctl function to control the encoder parameters
  *
  * @param state Decoder state
@@ -316,26 +374,34 @@
  * @param request ioctl-type request (one of the SPEEX_* macros)
  * @param ptr Data exchanged to-from function
  */
-int speex_mode_query(SpeexMode *mode, int request, void *ptr);
+int speex_mode_query(const SpeexMode *mode, int request, void *ptr);
 
 /** Functions for controlling the behavior of libspeex
- *  * @param request ioctl-type request (one of the SPEEX_LIB_* macros)
- *   * @param ptr Data exchanged to-from function
- *    */
+ * @param request ioctl-type request (one of the SPEEX_LIB_* macros)
+ * @param ptr Data exchanged to-from function
+ */
 int speex_lib_ctl(int request, void *ptr);
 
 /** Default narrowband mode */
-extern SpeexMode speex_nb_mode;
+extern const SpeexMode speex_nb_mode;
 
 /** Default wideband mode */
-extern SpeexMode speex_wb_mode;
+extern const SpeexMode speex_wb_mode;
 
 /** Default "ultra-wideband" mode */
-extern SpeexMode speex_uwb_mode;
+extern const SpeexMode speex_uwb_mode;
 
+#ifdef EPIC_48K
+/** 4.8 kbps narrowband mode */
+extern const SpeexMode speex_nb_48k_mode;
+#endif
+
 /** List of all modes available */
-extern SpeexMode *speex_mode_list[SPEEX_NB_MODES];
+extern const SpeexMode * const speex_mode_list[SPEEX_NB_MODES];
 
+/** Obtain one of the modes available */
+const SpeexMode * speex_lib_get_mode (int mode);
+
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_bits.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_bits.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_bits.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -40,16 +40,13 @@
 extern "C" {
 #endif
 
-/** Maximum size of the bit-stream (for fixed-size allocation) */
-#define MAX_BYTES_PER_FRAME 2000
-
 /** Bit-packing data structure representing (part of) a bit-stream. */
 typedef struct SpeexBits {
-   char *bytes;   /**< "raw" data */
+   char *chars;   /**< "raw" data */
    int   nbBits;  /**< Total number of bits stored in the stream*/
-   int   bytePtr; /**< Position of the byte "cursor" */
-   int   bitPtr;  /**< Position of the bit "cursor" within the current byte */
-   int   owner;   /**< Does the struct "own" the "raw" buffer (member "bytes") */
+   int   charPtr; /**< Position of the byte "cursor" */
+   int   bitPtr;  /**< Position of the bit "cursor" within the current char */
+   int   owner;   /**< Does the struct "own" the "raw" buffer (member "chars") */
    int   overflow;/**< Set to one if we try to read past the valid data */
    int   buf_size;/**< Allocated size for buffer */
    int   reserved1; /**< Reserved for future use */

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_config_types.h.in
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_config_types.h.in	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_config_types.h.in	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,11 @@
+#ifndef __SPEEX_TYPES_H__
+#define __SPEEX_TYPES_H__
+
+/* these are filled in by configure */
+typedef @SIZE16@ spx_int16_t;
+typedef unsigned @SIZE16@ spx_uint16_t;
+typedef @SIZE32@ spx_int32_t;
+typedef unsigned @SIZE32@ spx_uint32_t;
+
+#endif
+

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_echo.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_echo.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_echo.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,98 @@
+/* Copyright (C) Jean-Marc Valin
+
+   File: speex_echo.h
+
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions are
+   met:
+
+   1. Redistributions of source code must retain the above copyright notice,
+   this list of conditions and the following disclaimer.
+
+   2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+   3. The name of the author may not be used to endorse or promote products
+   derived from this software without specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+   IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+   OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+   DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+   ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+   POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef SPEEX_ECHO_H
+#define SPEEX_ECHO_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct drft_lookup;
+
+typedef struct SpeexEchoState {
+   int frame_size;           /**< Number of samples processed each time */
+   int window_size;
+   int M;
+   int cancel_count;
+   int adapted;
+   float adapt_rate;
+   float sum_adapt;
+   float Sey;
+   float Syy;
+   float See;
+   
+   float *x;
+   float *X;
+   float *d;
+   float *D;
+   float *y;
+   float *y2;
+   float *last_y;
+   float *Yps;
+   float *Y;
+   float *Y2;
+   float *E;
+   float *PHI;
+   float * restrict W;
+   float *power;
+   float *power_1;
+   float *grad;
+   float *Rf;
+   float *Yf;
+   float *Xf;
+   float *fratio;
+   float *regul;
+
+   struct drft_lookup *fft_lookup;
+
+
+} SpeexEchoState;
+
+
+/** Creates a new echo canceller state */
+SpeexEchoState *speex_echo_state_init(int frame_size, int filter_length);
+
+/** Destroys an echo canceller state */
+void speex_echo_state_destroy(SpeexEchoState *st);
+
+/** Performs echo cancellation a frame */
+void speex_echo_cancel(SpeexEchoState *st, short *ref, short *echo, short *out, float *Y);
+
+/** Reset the echo canceller state */
+void speex_echo_state_reset(SpeexEchoState *st);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_header.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_header.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_header.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -37,36 +37,40 @@
 #ifndef SPEEX_HEADER_H
 #define SPEEX_HEADER_H
 
+#include "speex/speex_types.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 struct SpeexMode;
 
+#define SPEEX_HEADER_STRING_LENGTH 8
+
 /** Maximum number of characters for encoding the Speex version number in the header */
 #define SPEEX_HEADER_VERSION_LENGTH 20
 
 /** Speex header info for file-based formats */
 typedef struct SpeexHeader {
-   char speex_string[8];       /**< Identifies a Speex bit-stream, always set to "Speex   " */
-   char speex_version[SPEEX_HEADER_VERSION_LENGTH]; /**< Speex version */
-   int speex_version_id;       /**< Version for Speex (for checking compatibility) */
-   int header_size;            /**< Total size of the header ( sizeof(SpeexHeader) ) */
-   int rate;                   /**< Sampling rate used */
-   int mode;                   /**< Mode used (0 for narrowband, 1 for wideband) */
-   int mode_bitstream_version; /**< Version ID of the bit-stream */
-   int nb_channels;            /**< Number of channels encoded */
-   int bitrate;                /**< Bit-rate used */
-   int frame_size;             /**< Size of frames */
-   int vbr;                    /**< 1 for a VBR encoding, 0 otherwise */
-   int frames_per_packet;      /**< Number of frames stored per Ogg packet */
-   int extra_headers;          /**< Number of additional headers after the comments */
-   int reserved1;              /**< Reserved for future use, must be zero */
-   int reserved2;              /**< Reserved for future use, must be zero */
+   char speex_string[SPEEX_HEADER_STRING_LENGTH];   /**< Identifies a Speex bit-stream, always set to "Speex   " */
+   char speex_version[SPEEX_HEADER_VERSION_LENGTH]; /**< Speex version */ 
+   spx_int32_t speex_version_id;       /**< Version for Speex (for checking compatibility) */
+   spx_int32_t header_size;            /**< Total size of the header ( sizeof(SpeexHeader) ) */
+   spx_int32_t rate;                   /**< Sampling rate used */
+   spx_int32_t mode;                   /**< Mode used (0 for narrowband, 1 for wideband) */
+   spx_int32_t mode_bitstream_version; /**< Version ID of the bit-stream */
+   spx_int32_t nb_channels;            /**< Number of channels encoded */
+   spx_int32_t bitrate;                /**< Bit-rate used */
+   spx_int32_t frame_size;             /**< Size of frames */
+   spx_int32_t vbr;                    /**< 1 for a VBR encoding, 0 otherwise */
+   spx_int32_t frames_per_packet;      /**< Number of frames stored per Ogg packet */
+   spx_int32_t extra_headers;          /**< Number of additional headers after the comments */
+   spx_int32_t reserved1;              /**< Reserved for future use, must be zero */
+   spx_int32_t reserved2;              /**< Reserved for future use, must be zero */
 } SpeexHeader;
 
 /** Initializes a SpeexHeader using basic information */
-void speex_init_header(SpeexHeader *header, int rate, int nb_channels, struct SpeexMode *m);
+void speex_init_header(SpeexHeader *header, int rate, int nb_channels, const struct SpeexMode *m);
 
 /** Creates the header packet from the header itself (mostly involves endianness conversion) */
 char *speex_header_to_packet(SpeexHeader *header, int *size);

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_jitter.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_jitter.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_jitter.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,87 @@
+/* Copyright (C) 2002 Jean-Marc Valin 
+   File: speex_jitter.h
+
+   Adaptive jitter buffer for Speex
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+   
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+   
+   - Neither the name of the Xiph.org Foundation nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+   
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*/
+
+#ifndef SPEEX_JITTER_H
+#define SPEEX_JITTER_H
+
+#include "speex.h"
+#include "speex_bits.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SPEEX_JITTER_MAX_PACKET_SIZE 1500
+#define SPEEX_JITTER_MAX_BUFFER_SIZE 20
+
+#define MAX_MARGIN 12
+
+typedef struct SpeexJitter {
+   int buffer_size;
+   int pointer_timestamp;
+
+   SpeexBits current_packet;
+   int valid_bits;
+
+   char buf[SPEEX_JITTER_MAX_BUFFER_SIZE][SPEEX_JITTER_MAX_PACKET_SIZE];
+   int timestamp[SPEEX_JITTER_MAX_BUFFER_SIZE];
+   int len[SPEEX_JITTER_MAX_BUFFER_SIZE];
+
+   void *dec;
+   int frame_size;
+   int frame_time;
+   int reset_state;
+   
+   int lost_count;
+   float shortterm_margin[MAX_MARGIN];
+   float longterm_margin[MAX_MARGIN];
+   float loss_rate;
+} SpeexJitter;
+
+void speex_jitter_init(SpeexJitter *jitter, void *decoder, int sampling_rate);
+
+void speex_jitter_destroy(SpeexJitter *jitter);
+
+void speex_jitter_put(SpeexJitter *jitter, char *packet, int len, int time);
+
+void speex_jitter_get(SpeexJitter *jitter, short *out, int *current_timestamp);
+
+int speex_jitter_get_pointer_timestamp(SpeexJitter *jitter);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_preprocess.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_preprocess.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_preprocess.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,147 @@
+/* Copyright (C) 2003 Epic Games 
+   Written by Jean-Marc Valin
+
+   File: speex_preprocess.h
+
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions are
+   met:
+
+   1. Redistributions of source code must retain the above copyright notice,
+   this list of conditions and the following disclaimer.
+
+   2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+   3. The name of the author may not be used to endorse or promote products
+   derived from this software without specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+   IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+   OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+   DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+   ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+   POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef SPEEX_PREPROCESS_H
+#define SPEEX_PREPROCESS_H
+
+#include "speex/speex_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct drft_lookup;
+
+typedef struct SpeexPreprocessState {
+   int    frame_size;        /**< Number of samples processed each time */
+   int    ps_size;           /**< Number of points in the power spectrum */
+   int    sampling_rate;     /**< Sampling rate of the input/output */
+   
+   /* parameters */
+   int    denoise_enabled;
+   int    agc_enabled;
+   float  agc_level;
+   int    vad_enabled;
+   int    dereverb_enabled;
+   float  reverb_decay;
+   float  reverb_level;
+   
+   float *frame;             /**< Processing frame (2*ps_size) */
+   float *ps;                /**< Current power spectrum */
+   float *gain2;             /**< Adjusted gains */
+   float *window;            /**< Analysis/Synthesis window */
+   float *noise;             /**< Noise estimate */
+   float *reverb_estimate;   /**< Estimate of reverb energy */
+   float *old_ps;            /**< Power spectrum for last frame */
+   float *gain;              /**< Ephraim Malah gain */
+   float *prior;             /**< A-priori SNR */
+   float *post;              /**< A-posteriori SNR */
+
+   float *S;                 /**< Smoothed power spectrum */
+   float *Smin;              /**< See Cohen paper */
+   float *Stmp;              /**< See Cohen paper */
+   float *update_prob;       /**< Propability of speech presence for noise update */
+
+   float *zeta;              /**< Smoothed a priori SNR */
+   float  Zpeak;
+   float  Zlast;
+
+   float *loudness_weight;   /**< Perceptual loudness curve */
+
+   float *echo_noise;
+
+   float *noise_bands;
+   float *noise_bands2;
+   int    noise_bandsN;
+   float *speech_bands;
+   float *speech_bands2;
+   int    speech_bandsN;
+
+   float *inbuf;             /**< Input buffer (overlapped analysis) */
+   float *outbuf;            /**< Output buffer (for overlap and add) */
+
+   float  speech_prob;
+   int    last_speech;
+   float  loudness;          /**< loudness estimate */
+   float  loudness2;         /**< loudness estimate */
+   int    nb_adapt;          /**< Number of frames used for adaptation so far */
+   int    nb_loudness_adapt; /**< Number of frames used for loudness adaptation so far */
+   int    consec_noise;      /**< Number of consecutive noise frames */
+   int    nb_preprocess;     /**< Number of frames processed so far */
+   struct drft_lookup *fft_lookup;   /**< Lookup table for the FFT */
+
+} SpeexPreprocessState;
+
+/** Creates a new preprocessing state */
+SpeexPreprocessState *speex_preprocess_state_init(int frame_size, int sampling_rate);
+
+/** Destroys a denoising state */
+void speex_preprocess_state_destroy(SpeexPreprocessState *st);
+
+/** Preprocess a frame */
+int speex_preprocess(SpeexPreprocessState *st, spx_int16_t *x, float *echo);
+
+/** Preprocess a frame */
+void speex_preprocess_estimate_update(SpeexPreprocessState *st, spx_int16_t *x, float *echo);
+
+/** Used like the ioctl function to control the preprocessor parameters */
+int speex_preprocess_ctl(SpeexPreprocessState *st, int request, void *ptr);
+
+
+
+#define SPEEX_PREPROCESS_SET_DENOISE 0
+#define SPEEX_PREPROCESS_GET_DENOISE 1
+
+#define SPEEX_PREPROCESS_SET_AGC 2
+#define SPEEX_PREPROCESS_GET_AGC 3
+
+#define SPEEX_PREPROCESS_SET_VAD 4
+#define SPEEX_PREPROCESS_GET_VAD 5
+
+#define SPEEX_PREPROCESS_SET_AGC_LEVEL 6
+#define SPEEX_PREPROCESS_GET_AGC_LEVEL 7
+
+#define SPEEX_PREPROCESS_SET_DEREVERB 8
+#define SPEEX_PREPROCESS_GET_DEREVERB 9
+
+#define SPEEX_PREPROCESS_SET_DEREVERB_LEVEL 10
+#define SPEEX_PREPROCESS_GET_DEREVERB_LEVEL 11
+
+#define SPEEX_PREPROCESS_SET_DEREVERB_DECAY 12
+#define SPEEX_PREPROCESS_GET_DEREVERB_DECAY 13
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_stereo.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_stereo.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_stereo.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -35,7 +35,8 @@
 #ifndef STEREO_H
 #define STEREO_H
 
-#include "speex_bits.h"
+#include "speex/speex_types.h"
+#include "speex/speex_bits.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -57,9 +58,15 @@
 /** Transforms a stereo frame into a mono frame and stores intensity stereo info in 'bits' */
 void speex_encode_stereo(float *data, int frame_size, SpeexBits *bits);
 
+/** Transforms a stereo frame into a mono frame and stores intensity stereo info in 'bits' */
+void speex_encode_stereo_int(spx_int16_t *data, int frame_size, SpeexBits *bits);
+
 /** Transforms a mono frame into a stereo frame using intensity stereo info */
 void speex_decode_stereo(float *data, int frame_size, SpeexStereoState *stereo);
 
+/** Transforms a mono frame into a stereo frame using intensity stereo info */
+void speex_decode_stereo_int(spx_int16_t *data, int frame_size, SpeexStereoState *stereo);
+
 /** Callback handler for intensity stereo info */
 int speex_std_stereo_request_handler(SpeexBits *bits, void *state, void *data);
 

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_types.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_types.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/include/speex/speex_types.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,120 @@
+/* speex_types.h taken from libogg */
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002             *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+ function: #ifdef jail to whip a few platforms into the UNIX ideal.
+ last mod: $Id: os_types.h 7524 2004-08-11 04:20:36Z conrad $
+
+ ********************************************************************/
+#ifndef _SPEEX_TYPES_H
+#define _SPEEX_TYPES_H
+
+#if defined(_WIN32) 
+
+#  if defined(__CYGWIN__)
+#    include <_G_config.h>
+     typedef _G_int64_t spx_int64_t;
+     typedef _G_int32_t spx_int32_t;
+     typedef _G_uint32_t spx_uint32_t;
+     typedef _G_int16_t spx_int16_t;
+     typedef _G_uint16_t spx_uint16_t;
+#  elif defined(__MINGW32__)
+     typedef short spx_int16_t;                                                                             
+     typedef unsigned short spx_uint16_t;                                                                   
+     typedef int spx_int32_t;                                                                               
+     typedef unsigned int spx_uint32_t;                                                                     
+     typedef long long spx_int64_t;                                                                         
+     typedef unsigned long long spx_uint64_t;  
+#  elif defined(__MWERKS__)
+     typedef long long spx_int64_t;
+     typedef int spx_int32_t;
+     typedef unsigned int spx_uint32_t;
+     typedef short spx_int16_t;
+     typedef unsigned short spx_uint16_t;
+#  else
+     /* MSVC/Borland */
+     typedef __int64 spx_int64_t;
+     typedef __int32 spx_int32_t;
+     typedef unsigned __int32 spx_uint32_t;
+     typedef __int16 spx_int16_t;
+     typedef unsigned __int16 spx_uint16_t;
+#  endif
+
+#elif defined(__MACOS__)
+
+#  include <sys/types.h>
+   typedef SInt16 spx_int16_t;
+   typedef UInt16 spx_uint16_t;
+   typedef SInt32 spx_int32_t;
+   typedef UInt32 spx_uint32_t;
+   typedef SInt64 spx_int64_t;
+
+#elif defined(__MACOSX__) /* MacOS X Framework build */
+
+#  include <sys/types.h>
+   typedef int16_t spx_int16_t;
+   typedef u_int16_t spx_uint16_t;
+   typedef int32_t spx_int32_t;
+   typedef u_int32_t spx_uint32_t;
+   typedef int64_t spx_int64_t;
+
+#elif defined(__BEOS__)
+
+   /* Be */
+#  include <inttypes.h>
+   typedef int16_t spx_int16_t;
+   typedef u_int16_t spx_uint16_t;
+   typedef int32_t spx_int32_t;
+   typedef u_int32_t spx_uint32_t;
+   typedef int64_t spx_int64_t;
+
+#elif defined (__EMX__)
+
+   /* OS/2 GCC */
+   typedef short spx_int16_t;
+   typedef unsigned short spx_uint16_t;
+   typedef int spx_int32_t;
+   typedef unsigned int spx_uint32_t;
+   typedef long long spx_int64_t;
+
+#elif defined (DJGPP)
+
+   /* DJGPP */
+   typedef short spx_int16_t;
+   typedef int spx_int32_t;
+   typedef unsigned int spx_uint32_t;
+   typedef long long spx_int64_t;
+
+#elif defined(R5900)
+
+   /* PS2 EE */
+   typedef long spx_int64_t;
+   typedef int spx_int32_t;
+   typedef unsigned spx_uint32_t;
+   typedef short spx_int16_t;
+
+#elif defined(__SYMBIAN32__)
+
+   /* Symbian GCC */
+   typedef signed short spx_int16_t;
+   typedef unsigned short spx_uint16_t;
+   typedef signed int spx_int32_t;
+   typedef unsigned int spx_uint32_t;
+   typedef long long int spx_int64_t;
+
+#else
+
+#  include <speex/speex_config_types.h>
+
+#endif
+
+#endif  /* _SPEEX_TYPES_H */

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/install-sh
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/install-sh	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/install-sh	2005-10-20 12:42:06 UTC (rev 10202)
@@ -1,8 +1,7 @@
 #!/bin/sh
+#
 # install - install a program, script, or datafile
-
-scriptversion=2004-04-01.17
-
+#
 # This originates from X11R5 (mit/util/scripts/install.sh), which was
 # later released in X11R6 (xc/config/util/install.sh) with the
 # following copyright and license.
@@ -42,11 +41,13 @@
 # from scratch.  It can only install one file at a time, a restriction
 # shared with many OS's install programs.
 
+
 # set DOITPROG to echo to test this script
 
 # Don't use :- since 4.3BSD and earlier shells don't like it.
 doit="${DOITPROG-}"
 
+
 # put in absolute paths if you don't have them in your path; or use env. vars.
 
 mvprog="${MVPROG-mv}"
@@ -58,268 +59,211 @@
 rmprog="${RMPROG-rm}"
 mkdirprog="${MKDIRPROG-mkdir}"
 
-transformbasename=
-transform_arg=
+transformbasename=""
+transform_arg=""
 instcmd="$mvprog"
 chmodcmd="$chmodprog 0755"
-chowncmd=
-chgrpcmd=
-stripcmd=
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
 rmcmd="$rmprog -f"
 mvcmd="$mvprog"
-src=
-dst=
-dir_arg=
+src=""
+dst=""
+dir_arg=""
 
-usage="Usage: $0 [OPTION]... SRCFILE DSTFILE
-   or: $0 [OPTION]... SRCFILES... DIRECTORY
-   or: $0 -d DIRECTORIES...
+while [ x"$1" != x ]; do
+    case $1 in
+	-c) instcmd="$cpprog"
+	    shift
+	    continue;;
 
-In the first form, install SRCFILE to DSTFILE, removing SRCFILE by default.
-In the second, create the directory path DIR.
+	-d) dir_arg=true
+	    shift
+	    continue;;
 
-Options:
--b=TRANSFORMBASENAME
--c         copy source (using $cpprog) instead of moving (using $mvprog).
--d         create directories instead of installing files.
--g GROUP   $chgrp installed files to GROUP.
--m MODE    $chmod installed files to MODE.
--o USER    $chown installed files to USER.
--s         strip installed files (using $stripprog).
--t=TRANSFORM
---help     display this help and exit.
---version  display version info and exit.
+	-m) chmodcmd="$chmodprog $2"
+	    shift
+	    shift
+	    continue;;
 
-Environment variables override the default commands:
-  CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
-"
+	-o) chowncmd="$chownprog $2"
+	    shift
+	    shift
+	    continue;;
 
-while test -n "$1"; do
-  case $1 in
-    -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
-        shift
-        continue;;
+	-g) chgrpcmd="$chgrpprog $2"
+	    shift
+	    shift
+	    continue;;
 
-    -c) instcmd=$cpprog
-        shift
-        continue;;
+	-s) stripcmd="$stripprog"
+	    shift
+	    continue;;
 
-    -d) dir_arg=true
-        shift
-        continue;;
+	-t=*) transformarg=`echo $1 | sed 's/-t=//'`
+	    shift
+	    continue;;
 
-    -g) chgrpcmd="$chgrpprog $2"
-        shift
-        shift
-        continue;;
+	-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+	    shift
+	    continue;;
 
-    --help) echo "$usage"; exit 0;;
+	*)  if [ x"$src" = x ]
+	    then
+		src=$1
+	    else
+		# this colon is to work around a 386BSD /bin/sh bug
+		:
+		dst=$1
+	    fi
+	    shift
+	    continue;;
+    esac
+done
 
-    -m) chmodcmd="$chmodprog $2"
-        shift
-        shift
-        continue;;
+if [ x"$src" = x ]
+then
+	echo "install:	no input file specified"
+	exit 1
+else
+	:
+fi
 
-    -o) chowncmd="$chownprog $2"
-        shift
-        shift
-        continue;;
+if [ x"$dir_arg" != x ]; then
+	dst=$src
+	src=""
+	
+	if [ -d $dst ]; then
+		instcmd=:
+		chmodcmd=""
+	else
+		instcmd=$mkdirprog
+	fi
+else
 
-    -s) stripcmd=$stripprog
-        shift
-        continue;;
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+# might cause directories to be created, which would be especially bad 
+# if $src (and thus $dsttmp) contains '*'.
 
-    -t=*) transformarg=`echo $1 | sed 's/-t=//'`
-        shift
-        continue;;
+	if [ -f "$src" ] || [ -d "$src" ]
+	then
+		:
+	else
+		echo "install:  $src does not exist"
+		exit 1
+	fi
+	
+	if [ x"$dst" = x ]
+	then
+		echo "install:	no destination specified"
+		exit 1
+	else
+		:
+	fi
 
-    --version) echo "$0 $scriptversion"; exit 0;;
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
 
-    *)  # When -d is used, all remaining arguments are directories to create.
-	test -n "$dir_arg" && break
-        # Otherwise, the last argument is the destination.  Remove it from $@.
-	for arg
-	do
-          if test -n "$dstarg"; then
-	    # $@ is not empty: it contains at least $arg.
-	    set fnord "$@" "$dstarg"
-	    shift # fnord
-	  fi
-	  shift # arg
-	  dstarg=$arg
-	done
-	break;;
-  esac
-done
-
-if test -z "$1"; then
-  if test -z "$dir_arg"; then
-    echo "$0: no input file specified." >&2
-    exit 1
-  fi
-  # It's OK to call `install-sh -d' without argument.
-  # This can happen when creating conditional directories.
-  exit 0
+	if [ -d $dst ]
+	then
+		dst="$dst"/`basename $src`
+	else
+		:
+	fi
 fi
 
-for src
-do
-  # Protect names starting with `-'.
-  case $src in
-    -*) src=./$src ;;
-  esac
+## this sed command emulates the dirname command
+dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
 
-  if test -n "$dir_arg"; then
-    dst=$src
-    src=
+# Make sure that the destination directory exists.
+#  this part is taken from Noah Friedman's mkinstalldirs script
 
-    if test -d "$dst"; then
-      instcmd=:
-      chmodcmd=
-    else
-      instcmd=$mkdirprog
-    fi
-  else
-    # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
-    # might cause directories to be created, which would be especially bad
-    # if $src (and thus $dsttmp) contains '*'.
-    if test ! -f "$src" && test ! -d "$src"; then
-      echo "$0: $src does not exist." >&2
-      exit 1
-    fi
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='
+	'
+IFS="${IFS-${defaultIFS}}"
 
-    if test -z "$dstarg"; then
-      echo "$0: no destination specified." >&2
-      exit 1
-    fi
+oIFS="${IFS}"
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS="${oIFS}"
 
-    dst=$dstarg
-    # Protect names starting with `-'.
-    case $dst in
-      -*) dst=./$dst ;;
-    esac
+pathcomp=''
 
-    # If destination is a directory, append the input filename; won't work
-    # if double slashes aren't ignored.
-    if test -d "$dst"; then
-      dst=$dst/`basename "$src"`
-    fi
-  fi
+while [ $# -ne 0 ] ; do
+	pathcomp="${pathcomp}${1}"
+	shift
 
-  # This sed command emulates the dirname command.
-  dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+	if [ ! -d "${pathcomp}" ] ;
+        then
+		$mkdirprog "${pathcomp}"
+	else
+		:
+	fi
 
-  # Make sure that the destination directory exists.
+	pathcomp="${pathcomp}/"
+done
+fi
 
-  # Skip lots of stat calls in the usual case.
-  if test ! -d "$dstdir"; then
-    defaultIFS='
-	 '
-    IFS="${IFS-$defaultIFS}"
+if [ x"$dir_arg" != x ]
+then
+	$doit $instcmd $dst &&
 
-    oIFS=$IFS
-    # Some sh's can't handle IFS=/ for some reason.
-    IFS='%'
-    set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
-    IFS=$oIFS
+	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else : ; fi &&
+	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else : ; fi &&
+	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else : ; fi &&
+	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else : ; fi
+else
 
-    pathcomp=
+# If we're going to rename the final executable, determine the name now.
 
-    while test $# -ne 0 ; do
-      pathcomp=$pathcomp$1
-      shift
-      if test ! -d "$pathcomp"; then
-        $mkdirprog "$pathcomp" || lasterr=$?
-	# mkdir can fail with a `File exist' error in case several
-	# install-sh are creating the directory concurrently.  This
-	# is OK.
-	test ! -d "$pathcomp" && { (exit ${lasterr-1}); exit; }
-      fi
-      pathcomp=$pathcomp/
-    done
-  fi
+	if [ x"$transformarg" = x ] 
+	then
+		dstfile=`basename $dst`
+	else
+		dstfile=`basename $dst $transformbasename | 
+			sed $transformarg`$transformbasename
+	fi
 
-  if test -n "$dir_arg"; then
-    $doit $instcmd "$dst" \
-      && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
-      && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
-      && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
-      && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
+# don't allow the sed command to completely eliminate the filename
 
-  else
-    # If we're going to rename the final executable, determine the name now.
-    if test -z "$transformarg"; then
-      dstfile=`basename "$dst"`
-    else
-      dstfile=`basename "$dst" $transformbasename \
-               | sed $transformarg`$transformbasename
-    fi
+	if [ x"$dstfile" = x ] 
+	then
+		dstfile=`basename $dst`
+	else
+		:
+	fi
 
-    # don't allow the sed command to completely eliminate the filename.
-    test -z "$dstfile" && dstfile=`basename "$dst"`
+# Make a temp file name in the proper directory.
 
-    # Make a couple of temp file names in the proper directory.
-    dsttmp=$dstdir/_inst.$$_
-    rmtmp=$dstdir/_rm.$$_
+	dsttmp=$dstdir/#inst.$$#
 
-    # Trap to clean up those temp files at exit.
-    trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
-    trap '(exit $?); exit' 1 2 13 15
+# Move or copy the file name to the temp name
 
-    # Move or copy the file name to the temp name
-    $doit $instcmd "$src" "$dsttmp" &&
+	$doit $instcmd $src $dsttmp &&
 
-    # and set any options; do chmod last to preserve setuid bits.
-    #
-    # If any of these fail, we abort the whole thing.  If we want to
-    # ignore errors from any of these, just make sure not to ignore
-    # errors from the above "$doit $instcmd $src $dsttmp" command.
-    #
-    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
-      && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
-      && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
-      && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
+	trap "rm -f ${dsttmp}" 0 &&
 
-    # Now rename the file to the real destination.
-    { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
-      || {
-	   # The rename failed, perhaps because mv can't rename something else
-	   # to itself, or perhaps because mv is so ancient that it does not
-	   # support -f.
+# and set any options; do chmod last to preserve setuid bits
 
-	   # Now remove or move aside any old file at destination location.
-	   # We try this two ways since rm can't unlink itself on some
-	   # systems and the destination file might be busy for other
-	   # reasons.  In this case, the final cleanup might fail but the new
-	   # file should still install successfully.
-	   {
-	     if test -f "$dstdir/$dstfile"; then
-	       $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
-	       || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
-	       || {
-		 echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
-		 (exit 1); exit
-	       }
-	     else
-	       :
-	     fi
-	   } &&
+# If any of these fail, we abort the whole thing.  If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
 
-	   # Now rename the file to the real destination.
-	   $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
-	 }
-    }
-  fi || { (exit 1); exit; }
-done
+	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else :;fi &&
+	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else :;fi &&
+	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else :;fi &&
+	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else :;fi &&
 
-# The final little trick to "correctly" pass the exit status to the exit trap.
-{
-  (exit 0); exit
-}
+# Now rename the file to the real destination.
 
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
-# End:
+	$doit $rmcmd -f $dstdir/$dstfile &&
+	$doit $mvcmd $dsttmp $dstdir/$dstfile 
+
+fi &&
+
+
+exit 0

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/Makefile.am
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/Makefile.am	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/Makefile.am	2005-10-20 12:42:06 UTC (rev 10202)
@@ -1,12 +1,11 @@
-## Process this file with automake to produce Makefile.in. -*-Makefile-*-
-
-# $Id: Makefile.am,v 1.49 2003/03/17 22:40:57 jm Exp $
-
 # Disable automatic dependency tracking if using other tools than gcc and gmake
 #AUTOMAKE_OPTIONS = no-dependencies
 
-INCLUDES = -I$(top_srcdir)/include
 
+EXTRA_DIST=testenc.c testenc_wb.c testenc_uwb.c testdenoise.c testecho.c
+
+INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_builddir) @OGG_CFLAGS@
+
 lib_LTLIBRARIES = libspeex.la
 
 # Sources for compilation in the library
@@ -23,6 +22,7 @@
 	filters.c \
 	bits.c \
 	modes.c \
+	speex.c \
 	vq.c \
 	high_lsp_tables.c \
 	vbr.c \
@@ -38,36 +38,49 @@
 	speex_header.c \
 	speex_callbacks.c \
 	math_approx.c \
-	stereo.c
+	stereo.c \
+	preprocess.c \
+	smallft.c \
+	lbr_48k_tables.c \
+	jitter.c \
+	mdf.c
 
-
 noinst_HEADERS = lsp.h \
 	nb_celp.h \
 	lpc.h \
+	lpc_bfin.h \
 	ltp.h \
 	quant_lsp.h \
 	cb_search.h \
 	filters.h \
 	stack_alloc.h \
 	vq.h \
+	vq_sse.h \
+	vq_arm4.h \
+	vq_bfin.h \
 	modes.h \
 	sb_celp.h \
 	vbr.h \
 	misc.h \
+	misc_bfin.h \
 	ltp_sse.h \
+	ltp_arm4.h \
+	ltp_bfin.h \
 	filters_sse.h \
-	math_approx.h
-	
-	
-libspeex_la_LDFLAGS = -version-info @SPEEX_LT_CURRENT@:@SPEEX_LT_REVISION@:@SPEEX_LT_AGE@
+	filters_arm4.h \
+	filters_bfin.h \
+	math_approx.h \
+	smallft.h \
+	arch.h \
+	fixed_arm4.h \
+	fixed_arm5e.h \
+	fixed_bfin.h \
+	fixed_debug.h \
+	fixed_generic.h \
+	cb_search_sse.h \
+	cb_search_arm4.h \
+	cb_search_bfin.h
 
-noinst_PROGRAMS = testenc testenc_wb testenc_uwb
 
-testenc_SOURCES = testenc.c
-testenc_LDADD = libspeex.la
+libspeex_la_LDFLAGS = -version-info @SPEEX_LT_CURRENT@:@SPEEX_LT_REVISION@:@SPEEX_LT_AGE@
 
-testenc_wb_SOURCES = testenc_wb.c
-testenc_wb_LDADD = libspeex.la
-
-testenc_uwb_SOURCES = testenc_uwb.c
-testenc_uwb_LDADD = libspeex.la

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/Makefile.in
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/Makefile.in	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/Makefile.in	2005-10-20 12:42:06 UTC (rev 10202)
@@ -14,15 +14,12 @@
 
 @SET_MAKE@
 
-# $Id: Makefile.am,v 1.49 2003/03/17 22:40:57 jm Exp $
-
 # Disable automatic dependency tracking if using other tools than gcc and gmake
 #AUTOMAKE_OPTIONS = no-dependencies
 
 
+SOURCES = $(libspeex_la_SOURCES)
 
-SOURCES = $(libspeex_la_SOURCES) $(testenc_SOURCES) $(testenc_uwb_SOURCES) $(testenc_wb_SOURCES)
-
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
@@ -44,17 +41,16 @@
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
 host_triplet = @host@
-noinst_PROGRAMS = testenc$(EXEEXT) testenc_wb$(EXEEXT) \
-	testenc_uwb$(EXEEXT)
 subdir = libspeex
 DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
 	$(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 am__installdirs = "$(DESTDIR)$(libdir)"
 libLTLIBRARIES_INSTALL = $(INSTALL)
@@ -62,24 +58,15 @@
 libspeex_la_LIBADD =
 am_libspeex_la_OBJECTS = nb_celp.lo sb_celp.lo lpc.lo ltp.lo lsp.lo \
 	quant_lsp.lo lsp_tables_nb.lo gain_table.lo gain_table_lbr.lo \
-	cb_search.lo filters.lo bits.lo modes.lo vq.lo \
+	cb_search.lo filters.lo bits.lo modes.lo speex.lo vq.lo \
 	high_lsp_tables.lo vbr.lo hexc_table.lo exc_5_256_table.lo \
 	exc_5_64_table.lo exc_8_128_table.lo exc_10_32_table.lo \
 	exc_10_16_table.lo exc_20_32_table.lo hexc_10_32_table.lo \
 	misc.lo speex_header.lo speex_callbacks.lo math_approx.lo \
-	stereo.lo
+	stereo.lo preprocess.lo smallft.lo lbr_48k_tables.lo jitter.lo \
+	mdf.lo
 libspeex_la_OBJECTS = $(am_libspeex_la_OBJECTS)
-PROGRAMS = $(noinst_PROGRAMS)
-am_testenc_OBJECTS = testenc.$(OBJEXT)
-testenc_OBJECTS = $(am_testenc_OBJECTS)
-testenc_DEPENDENCIES = libspeex.la
-am_testenc_uwb_OBJECTS = testenc_uwb.$(OBJEXT)
-testenc_uwb_OBJECTS = $(am_testenc_uwb_OBJECTS)
-testenc_uwb_DEPENDENCIES = libspeex.la
-am_testenc_wb_OBJECTS = testenc_wb.$(OBJEXT)
-testenc_wb_OBJECTS = $(am_testenc_wb_OBJECTS)
-testenc_wb_DEPENDENCIES = libspeex.la
-DEFAULT_INCLUDES = -I. -I$(srcdir)
+DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
 @AMDEP_TRUE at DEP_FILES = ./$(DEPDIR)/bits.Plo ./$(DEPDIR)/cb_search.Plo \
@@ -94,16 +81,18 @@
 @AMDEP_TRUE@	./$(DEPDIR)/hexc_10_32_table.Plo \
 @AMDEP_TRUE@	./$(DEPDIR)/hexc_table.Plo \
 @AMDEP_TRUE@	./$(DEPDIR)/high_lsp_tables.Plo \
- at AMDEP_TRUE@	./$(DEPDIR)/lpc.Plo ./$(DEPDIR)/lsp.Plo \
- at AMDEP_TRUE@	./$(DEPDIR)/lsp_tables_nb.Plo ./$(DEPDIR)/ltp.Plo \
- at AMDEP_TRUE@	./$(DEPDIR)/math_approx.Plo ./$(DEPDIR)/misc.Plo \
+ at AMDEP_TRUE@	./$(DEPDIR)/jitter.Plo \
+ at AMDEP_TRUE@	./$(DEPDIR)/lbr_48k_tables.Plo ./$(DEPDIR)/lpc.Plo \
+ at AMDEP_TRUE@	./$(DEPDIR)/lsp.Plo ./$(DEPDIR)/lsp_tables_nb.Plo \
+ at AMDEP_TRUE@	./$(DEPDIR)/ltp.Plo ./$(DEPDIR)/math_approx.Plo \
+ at AMDEP_TRUE@	./$(DEPDIR)/mdf.Plo ./$(DEPDIR)/misc.Plo \
 @AMDEP_TRUE@	./$(DEPDIR)/modes.Plo ./$(DEPDIR)/nb_celp.Plo \
+ at AMDEP_TRUE@	./$(DEPDIR)/preprocess.Plo \
 @AMDEP_TRUE@	./$(DEPDIR)/quant_lsp.Plo ./$(DEPDIR)/sb_celp.Plo \
+ at AMDEP_TRUE@	./$(DEPDIR)/smallft.Plo ./$(DEPDIR)/speex.Plo \
 @AMDEP_TRUE@	./$(DEPDIR)/speex_callbacks.Plo \
 @AMDEP_TRUE@	./$(DEPDIR)/speex_header.Plo \
- at AMDEP_TRUE@	./$(DEPDIR)/stereo.Plo ./$(DEPDIR)/testenc.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/testenc_uwb.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/testenc_wb.Po ./$(DEPDIR)/vbr.Plo \
+ at AMDEP_TRUE@	./$(DEPDIR)/stereo.Plo ./$(DEPDIR)/vbr.Plo \
 @AMDEP_TRUE@	./$(DEPDIR)/vq.Plo
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -113,10 +102,8 @@
 CCLD = $(CC)
 LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(AM_LDFLAGS) $(LDFLAGS) -o $@
-SOURCES = $(libspeex_la_SOURCES) $(testenc_SOURCES) \
-	$(testenc_uwb_SOURCES) $(testenc_wb_SOURCES)
-DIST_SOURCES = $(libspeex_la_SOURCES) $(testenc_SOURCES) \
-	$(testenc_uwb_SOURCES) $(testenc_wb_SOURCES)
+SOURCES = $(libspeex_la_SOURCES)
+DIST_SOURCES = $(libspeex_la_SOURCES)
 HEADERS = $(noinst_HEADERS)
 ETAGS = etags
 CTAGS = ctags
@@ -165,8 +152,7 @@
 MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 OBJEXT = @OBJEXT@
-OGG_INCLUDES = @OGG_INCLUDES@
-OGG_LDFLAGS = @OGG_LDFLAGS@
+OGG_CFLAGS = @OGG_CFLAGS@
 OGG_LIBS = @OGG_LIBS@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -178,9 +164,12 @@
 RANLIB = @RANLIB@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
+SIZE16 = @SIZE16@
+SIZE32 = @SIZE32@
 SPEEX_LT_AGE = @SPEEX_LT_AGE@
 SPEEX_LT_CURRENT = @SPEEX_LT_CURRENT@
 SPEEX_LT_REVISION = @SPEEX_LT_REVISION@
+SPEEX_VERSION = @SPEEX_VERSION@
 STRIP = @STRIP@
 VERSION = @VERSION@
 ac_ct_AR = @ac_ct_AR@
@@ -225,7 +214,8 @@
 src = @src@
 sysconfdir = @sysconfdir@
 target_alias = @target_alias@
-INCLUDES = -I$(top_srcdir)/include
+EXTRA_DIST = testenc.c testenc_wb.c testenc_uwb.c testdenoise.c testecho.c
+INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_builddir) @OGG_CFLAGS@
 lib_LTLIBRARIES = libspeex.la
 
 # Sources for compilation in the library
@@ -242,6 +232,7 @@
 	filters.c \
 	bits.c \
 	modes.c \
+	speex.c \
 	vq.c \
 	high_lsp_tables.c \
 	vbr.c \
@@ -257,32 +248,50 @@
 	speex_header.c \
 	speex_callbacks.c \
 	math_approx.c \
-	stereo.c
+	stereo.c \
+	preprocess.c \
+	smallft.c \
+	lbr_48k_tables.c \
+	jitter.c \
+	mdf.c
 
 noinst_HEADERS = lsp.h \
 	nb_celp.h \
 	lpc.h \
+	lpc_bfin.h \
 	ltp.h \
 	quant_lsp.h \
 	cb_search.h \
 	filters.h \
 	stack_alloc.h \
 	vq.h \
+	vq_sse.h \
+	vq_arm4.h \
+	vq_bfin.h \
 	modes.h \
 	sb_celp.h \
 	vbr.h \
 	misc.h \
+	misc_bfin.h \
 	ltp_sse.h \
+	ltp_arm4.h \
+	ltp_bfin.h \
 	filters_sse.h \
-	math_approx.h
+	filters_arm4.h \
+	filters_bfin.h \
+	math_approx.h \
+	smallft.h \
+	arch.h \
+	fixed_arm4.h \
+	fixed_arm5e.h \
+	fixed_bfin.h \
+	fixed_debug.h \
+	fixed_generic.h \
+	cb_search_sse.h \
+	cb_search_arm4.h \
+	cb_search_bfin.h
 
 libspeex_la_LDFLAGS = -version-info @SPEEX_LT_CURRENT@:@SPEEX_LT_REVISION@:@SPEEX_LT_AGE@
-testenc_SOURCES = testenc.c
-testenc_LDADD = libspeex.la
-testenc_wb_SOURCES = testenc_wb.c
-testenc_wb_LDADD = libspeex.la
-testenc_uwb_SOURCES = testenc_uwb.c
-testenc_uwb_LDADD = libspeex.la
 all: all-am
 
 .SUFFIXES:
@@ -346,22 +355,6 @@
 libspeex.la: $(libspeex_la_OBJECTS) $(libspeex_la_DEPENDENCIES) 
 	$(LINK) -rpath $(libdir) $(libspeex_la_LDFLAGS) $(libspeex_la_OBJECTS) $(libspeex_la_LIBADD) $(LIBS)
 
-clean-noinstPROGRAMS:
-	@list='$(noinst_PROGRAMS)'; for p in $$list; do \
-	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
-	  echo " rm -f $$p $$f"; \
-	  rm -f $$p $$f ; \
-	done
-testenc$(EXEEXT): $(testenc_OBJECTS) $(testenc_DEPENDENCIES) 
-	@rm -f testenc$(EXEEXT)
-	$(LINK) $(testenc_LDFLAGS) $(testenc_OBJECTS) $(testenc_LDADD) $(LIBS)
-testenc_uwb$(EXEEXT): $(testenc_uwb_OBJECTS) $(testenc_uwb_DEPENDENCIES) 
-	@rm -f testenc_uwb$(EXEEXT)
-	$(LINK) $(testenc_uwb_LDFLAGS) $(testenc_uwb_OBJECTS) $(testenc_uwb_LDADD) $(LIBS)
-testenc_wb$(EXEEXT): $(testenc_wb_OBJECTS) $(testenc_wb_DEPENDENCIES) 
-	@rm -f testenc_wb$(EXEEXT)
-	$(LINK) $(testenc_wb_LDFLAGS) $(testenc_wb_OBJECTS) $(testenc_wb_LDADD) $(LIBS)
-
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
 
@@ -382,22 +375,25 @@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/hexc_10_32_table.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/hexc_table.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/high_lsp_tables.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/jitter.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/lbr_48k_tables.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/lpc.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/lsp.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/lsp_tables_nb.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ltp.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/math_approx.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mdf.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/misc.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/modes.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/nb_celp.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/preprocess.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/quant_lsp.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/sb_celp.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/smallft.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/speex.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/speex_callbacks.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/speex_header.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/stereo.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/testenc.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/testenc_uwb.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/testenc_wb.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/vbr.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/vq.Plo at am__quote@
 
@@ -512,7 +508,7 @@
 	done
 check-am: all-am
 check: check-am
-all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS)
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
 installdirs:
 	for dir in "$(DESTDIR)$(libdir)"; do \
 	  test -z "$$dir" || $(mkdir_p) "$$dir"; \
@@ -544,7 +540,7 @@
 clean: clean-am
 
 clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
-	clean-noinstPROGRAMS mostlyclean-am
+	mostlyclean-am
 
 distclean: distclean-am
 	-rm -rf ./$(DEPDIR)
@@ -593,17 +589,17 @@
 uninstall-am: uninstall-info-am uninstall-libLTLIBRARIES
 
 .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
-	clean-libLTLIBRARIES clean-libtool clean-noinstPROGRAMS ctags \
-	distclean distclean-compile distclean-generic \
-	distclean-libtool distclean-tags distdir dvi dvi-am html \
-	html-am info info-am install install-am install-data \
-	install-data-am install-exec install-exec-am install-info \
-	install-info-am install-libLTLIBRARIES install-man \
-	install-strip installcheck installcheck-am installdirs \
-	maintainer-clean maintainer-clean-generic mostlyclean \
-	mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
-	pdf pdf-am ps ps-am tags uninstall uninstall-am \
-	uninstall-info-am uninstall-libLTLIBRARIES
+	clean-libLTLIBRARIES clean-libtool ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-exec \
+	install-exec-am install-info install-info-am \
+	install-libLTLIBRARIES install-man install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-info-am \
+	uninstall-libLTLIBRARIES
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/arch.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/arch.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/arch.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,187 @@
+/* Copyright (C) 2003 Jean-Marc Valin */
+/**
+   @file arch.h
+   @brief Various architecture definitions Speex
+*/
+/*
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+   
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+   
+   - Neither the name of the Xiph.org Foundation nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+   
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef ARCH_H
+#define ARCH_H
+
+#include "speex/speex_types.h"
+
+#define ABS(x) ((x) < 0 ? (-(x)) : (x))
+#define ABS16(x) ((x) < 0 ? (-(x)) : (x))
+#define MAX16(a,b) ((a) > (b) ? (a) : (b))
+#define ABS32(x) ((x) < 0 ? (-(x)) : (x))
+
+#ifdef FIXED_POINT
+
+typedef spx_int16_t spx_word16_t;
+typedef spx_int32_t   spx_word32_t;
+#ifdef _MSC_VER
+typedef __int64      spx_word64_t;
+#else
+typedef long long    spx_word64_t;
+#endif
+typedef spx_word32_t spx_mem_t;
+typedef spx_word16_t spx_coef_t;
+typedef spx_word16_t spx_lsp_t;
+typedef spx_word32_t spx_sig_t;
+
+#define Q15ONE 32767
+
+#define LPC_SCALING  8192
+#define SIG_SCALING  16384
+#define LSP_SCALING  8192.
+#define GAMMA_SCALING 32768.
+#define GAIN_SCALING 64
+#define GAIN_SCALING_1 0.015625
+
+#define LPC_SHIFT    13
+#define LSP_SHIFT    13
+#define SIG_SHIFT    14
+
+#define VERY_SMALL 0
+#define VERY_LARGE32 ((spx_word32_t)2147483647)
+#define VERY_LARGE16 ((spx_word16_t)32767)
+
+
+#ifdef FIXED_DEBUG
+#include "fixed_debug.h"
+#else
+
+#include "fixed_generic.h"
+
+#ifdef ARM5E_ASM
+#include "fixed_arm5e.h"
+#elif defined (ARM4_ASM)
+#include "fixed_arm4.h"
+#elif defined (ARM5E_ASM)
+#include "fixed_arm5e.h"
+#elif defined (BFIN_ASM)
+#include "fixed_bfin.h"
+#endif
+
+#endif
+
+
+#else
+
+typedef float spx_mem_t;
+typedef float spx_coef_t;
+typedef float spx_lsp_t;
+typedef float spx_sig_t;
+typedef float spx_word16_t;
+typedef float spx_word32_t;
+typedef float spx_word64_t;
+
+#define Q15ONE 1.0f
+#define LPC_SCALING  1.f
+#define SIG_SCALING  1.f
+#define LSP_SCALING  1.f
+#define GAMMA_SCALING 1.f
+#define GAIN_SCALING 1.f
+#define GAIN_SCALING_1 1.f
+
+#define LPC_SHIFT    0
+#define LSP_SHIFT    0
+#define SIG_SHIFT    0
+
+#define VERY_SMALL 1e-15f
+#define VERY_LARGE32 1e15f
+#define VERY_LARGE16 1e15f
+
+#define NEG16(x) (-(x))
+#define NEG32(x) (-(x))
+#define EXTRACT16(x) (x)
+#define EXTEND32(x) (x)
+#define SHR16(a,shift) (a)
+#define SHL16(a,shift) (a)
+#define SHR32(a,shift) (a)
+#define SHL32(a,shift) (a)
+#define PSHR16(a,shift) (a)
+#define PSHR32(a,shift) (a)
+#define SATURATE16(x,a) (x)
+#define SATURATE32(x,a) (x)
+
+#define PSHR(a,shift)       (a)
+#define SHR(a,shift)       (a)
+#define SHL(a,shift)       (a)
+#define SATURATE(x,a) (x)
+
+#define ADD16(a,b) ((a)+(b))
+#define SUB16(a,b) ((a)-(b))
+#define ADD32(a,b) ((a)+(b))
+#define SUB32(a,b) ((a)-(b))
+#define ADD64(a,b) ((a)+(b))
+#define MULT16_16_16(a,b)     ((a)*(b))
+#define MULT16_16(a,b)     ((spx_word32_t)(a)*(spx_word32_t)(b))
+#define MAC16_16(c,a,b)     ((c)+(spx_word32_t)(a)*(spx_word32_t)(b))
+
+#define MULT16_32_Q11(a,b)     ((a)*(b))
+#define MULT16_32_Q13(a,b)     ((a)*(b))
+#define MULT16_32_Q14(a,b)     ((a)*(b))
+#define MULT16_32_Q15(a,b)     ((a)*(b))
+
+#define MAC16_32_Q11(c,a,b)     ((c)+(a)*(b))
+#define MAC16_32_Q15(c,a,b)     ((c)+(a)*(b))
+
+#define MAC16_16_Q11(c,a,b)     ((c)+(a)*(b))
+#define MAC16_16_Q13(c,a,b)     ((c)+(a)*(b))
+#define MULT16_16_Q11_32(a,b)     ((a)*(b))
+#define MULT16_16_Q13(a,b)     ((a)*(b))
+#define MULT16_16_Q14(a,b)     ((a)*(b))
+#define MULT16_16_Q15(a,b)     ((a)*(b))
+#define MULT16_16_P15(a,b)     ((a)*(b))
+
+#define DIV32_16(a,b)     ((a)/(b))
+#define DIV32(a,b)     ((a)/(b))
+
+
+#endif
+
+
+#ifdef CONFIG_TI_C55X
+
+/* 2 on TI C5x DSP */
+#define BYTES_PER_CHAR 2 
+#define BITS_PER_CHAR 16
+#define LOG2_BITS_PER_CHAR 4
+
+#else 
+
+#define BYTES_PER_CHAR 1
+#define BITS_PER_CHAR 8
+#define LOG2_BITS_PER_CHAR 3
+
+#endif
+
+#endif

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/bits.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/bits.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/bits.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -32,65 +32,63 @@
 
 */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <speex/speex_bits.h>
 #include "misc.h"
 
+/** Maximum size of the bit-stream (for fixed-size allocation) */
+#define MAX_BYTES_PER_FRAME (2000/BYTES_PER_CHAR)
+
 void speex_bits_init(SpeexBits *bits)
 {
-   int i;
-   bits->bytes = (char*)speex_alloc(MAX_BYTES_PER_FRAME);
+   bits->chars = (char*)speex_alloc(MAX_BYTES_PER_FRAME);
+   if (!bits->chars)
+      return;
+
    bits->buf_size = MAX_BYTES_PER_FRAME;
 
-   for (i=0;i<bits->buf_size;i++)
-      bits->bytes[i]=0;
-   bits->nbBits=0;
-   bits->bytePtr=0;
-   bits->bitPtr=0;
    bits->owner=1;
-   bits->overflow=0;
+
+   speex_bits_reset(bits);
 }
 
 void speex_bits_init_buffer(SpeexBits *bits, void *buff, int buf_size)
 {
-   int i;
-   bits->bytes = (char*)buff;
+   bits->chars = (char*)buff;
    bits->buf_size = buf_size;
 
-   for (i=0;i<buf_size;i++)
-      bits->bytes[i]=0;
-   bits->nbBits=0;
-   bits->bytePtr=0;
-   bits->bitPtr=0;
    bits->owner=0;
-   bits->overflow=0;
+
+   speex_bits_reset(bits);
 }
 
 void speex_bits_destroy(SpeexBits *bits)
 {
    if (bits->owner)
-      speex_free(bits->bytes);
+      speex_free(bits->chars);
    /* Will do something once the allocation is dynamic */
 }
 
 void speex_bits_reset(SpeexBits *bits)
 {
-   int i;
-   for (i=0;i<bits->buf_size;i++)
-      bits->bytes[i]=0;
+   bits->chars[0]=0;
    bits->nbBits=0;
-   bits->bytePtr=0;
+   bits->charPtr=0;
    bits->bitPtr=0;
    bits->overflow=0;
 }
 
 void speex_bits_rewind(SpeexBits *bits)
 {
-   bits->bytePtr=0;
+   bits->charPtr=0;
    bits->bitPtr=0;
    bits->overflow=0;
 }
 
-void speex_bits_read_from(SpeexBits *bits, char *bytes, int len)
+void speex_bits_read_from(SpeexBits *bits, char *chars, int len)
 {
    int i;
    if (len > bits->buf_size)
@@ -98,11 +96,11 @@
       speex_warning_int("Packet is larger than allocated buffer: ", len);
       if (bits->owner)
       {
-         char *tmp = (char*)speex_realloc(bits->bytes, len);
+         char *tmp = (char*)speex_realloc(bits->chars, len);
          if (tmp)
          {
             bits->buf_size=len;
-            bits->bytes=tmp;
+            bits->chars=tmp;
          } else {
             len=bits->buf_size;
             speex_warning("Could not resize input buffer: truncating input");
@@ -113,9 +111,9 @@
       }
    }
    for (i=0;i<len;i++)
-      bits->bytes[i]=bytes[i];
+      bits->chars[i]=chars[i];
    bits->nbBits=len<<3;
-   bits->bytePtr=0;
+   bits->charPtr=0;
    bits->bitPtr=0;
    bits->overflow=0;
 }
@@ -123,104 +121,111 @@
 static void speex_bits_flush(SpeexBits *bits)
 {
    int i;
-   if (bits->bytePtr>0)
+   int nchars = ((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR);
+   if (bits->charPtr>0)
    {
-      for (i=bits->bytePtr;i<((bits->nbBits+7)>>3);i++)
-         bits->bytes[i-bits->bytePtr]=bits->bytes[i];
+     for (i=bits->charPtr;i<nchars; i++) 
+       bits->chars[i-bits->charPtr]=bits->chars[i];
    }
-   bits->nbBits -= bits->bytePtr<<3;
-   bits->bytePtr=0;
+   bits->nbBits -= bits->charPtr<<LOG2_BITS_PER_CHAR;
+   bits->charPtr=0;
 }
 
-void speex_bits_read_whole_bytes(SpeexBits *bits, char *bytes, int len)
+void speex_bits_read_whole_bytes(SpeexBits *bits, char *chars, int nbytes)
 {
    int i,pos;
+   int nchars = nbytes/BYTES_PER_CHAR;
 
-   if ((bits->nbBits>>3)+len+1 > bits->buf_size)
+   if (((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR)+nchars > bits->buf_size)
    {
-      speex_warning_int("Packet is larger than allocated buffer: ", len);
+      /* Packet is larger than allocated buffer */
       if (bits->owner)
       {
-         char *tmp = (char*)speex_realloc(bits->bytes, (bits->nbBits>>3)+len+1);
+         char *tmp = (char*)speex_realloc(bits->chars, (bits->nbBits>>LOG2_BITS_PER_CHAR)+nchars+1);
          if (tmp)
          {
-            bits->buf_size=(bits->nbBits>>3)+len+1;
-            bits->bytes=tmp;
+            bits->buf_size=(bits->nbBits>>LOG2_BITS_PER_CHAR)+nchars+1;
+            bits->chars=tmp;
          } else {
-            len=bits->buf_size-(bits->nbBits>>3)-1;
+            nchars=bits->buf_size-(bits->nbBits>>LOG2_BITS_PER_CHAR)-1;
             speex_warning("Could not resize input buffer: truncating input");
          }
       } else {
          speex_warning("Do not own input buffer: truncating input");
-         len=bits->buf_size;
+         nchars=bits->buf_size;
       }
    }
 
    speex_bits_flush(bits);
-   pos=bits->nbBits>>3;
-   for (i=0;i<len;i++)
-      bits->bytes[pos+i]=bytes[i];
-   bits->nbBits+=len<<3;
+   pos=bits->nbBits>>LOG2_BITS_PER_CHAR;
+   for (i=0;i<nchars;i++)
+      bits->chars[pos+i]=chars[i];
+   bits->nbBits+=nchars<<LOG2_BITS_PER_CHAR;
 }
 
-int speex_bits_write(SpeexBits *bits, char *bytes, int max_len)
+int speex_bits_write(SpeexBits *bits, char *chars, int max_nbytes)
 {
    int i;
-   int bytePtr, bitPtr, nbBits;
-
+   int max_nchars = max_nbytes/BYTES_PER_CHAR;
+   int charPtr, bitPtr, nbBits;
+   
    /* Insert terminator, but save the data so we can put it back after */
    bitPtr=bits->bitPtr;
-   bytePtr=bits->bytePtr;
+   charPtr=bits->charPtr;
    nbBits=bits->nbBits;
    speex_bits_insert_terminator(bits);
    bits->bitPtr=bitPtr;
-   bits->bytePtr=bytePtr;
+   bits->charPtr=charPtr;
    bits->nbBits=nbBits;
 
-   if (max_len > ((bits->nbBits+7)>>3))
-      max_len = ((bits->nbBits+7)>>3);
-   for (i=0;i<max_len;i++)
-      bytes[i]=bits->bytes[i];
-   return max_len;
+   if (max_nchars > ((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR))
+      max_nchars = ((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR);
+#if BYTES_PER_CHAR==1
+#define HTOLS(A) (A)
+#else
+#define HTOLS(A) ((((A) >> 8)&0xff)|(((A) & 0xff)<<8))
+#endif
+   for (i=0;i<max_nchars;i++)
+      chars[i]=HTOLS(bits->chars[i]);
+   return max_nchars*BYTES_PER_CHAR;
 }
 
-int speex_bits_write_whole_bytes(SpeexBits *bits, char *bytes, int max_len)
+int speex_bits_write_whole_bytes(SpeexBits *bits, char *chars, int max_nbytes)
 {
+   int max_nchars = max_nbytes/BYTES_PER_CHAR;
    int i;
-   if (max_len > ((bits->nbBits)>>3))
-      max_len = ((bits->nbBits)>>3);
-   for (i=0;i<max_len;i++)
-      bytes[i]=bits->bytes[i];
+   if (max_nchars > ((bits->nbBits)>>LOG2_BITS_PER_CHAR))
+      max_nchars = ((bits->nbBits)>>LOG2_BITS_PER_CHAR);
+   for (i=0;i<max_nchars;i++)
+      chars[i]=bits->chars[i];
    
    if (bits->bitPtr>0)
-      bits->bytes[0]=bits->bytes[max_len];
+      bits->chars[0]=bits->chars[max_nchars];
    else
-      bits->bytes[0]=0;
-   for (i=1;i<((bits->nbBits)>>3)+1;i++)
-      bits->bytes[i]=0;
-   bits->bytePtr=0;
-   bits->nbBits &= 7;
-   return max_len;
+      bits->chars[0]=0;
+   for (i=1;i<((bits->nbBits)>>LOG2_BITS_PER_CHAR)+1;i++)
+      bits->chars[i]=0;
+   bits->charPtr=0;
+   bits->nbBits &= (BITS_PER_CHAR-1);
+   return max_nchars*BYTES_PER_CHAR;
 }
 
-
 void speex_bits_pack(SpeexBits *bits, int data, int nbBits)
 {
-   int i;
    unsigned int d=data;
 
-   if (bits->bytePtr+((nbBits+bits->bitPtr)>>3) >= bits->buf_size)
+   if (bits->charPtr+((nbBits+bits->bitPtr)>>LOG2_BITS_PER_CHAR) >= bits->buf_size)
    {
       speex_warning("Buffer too small to pack bits");
       if (bits->owner)
       {
-         char *tmp = (char*)speex_realloc(bits->bytes, ((bits->buf_size+5)*3)>>1);
+	int new_nchars = ((bits->buf_size+5)*3)>>1;
+         char *tmp = (char*)speex_realloc(bits->chars, new_nchars);
          if (tmp)
          {
-            for (i=bits->buf_size;i<(((bits->buf_size+5)*3)>>1);i++)
-               tmp[i]=0;
-            bits->buf_size=((bits->buf_size+5)*3)>>1;
-            bits->bytes=tmp;
+	    speex_memset_bytes(tmp, 0, new_nchars);
+            bits->buf_size=new_nchars;
+            bits->chars=tmp;
          } else {
             speex_warning("Could not resize input buffer: not packing");
             return;
@@ -235,13 +240,14 @@
    {
       int bit;
       bit = (d>>(nbBits-1))&1;
-      bits->bytes[bits->bytePtr] |= bit<<(7-bits->bitPtr);
+      bits->chars[bits->charPtr] |= bit<<(BITS_PER_CHAR-1-bits->bitPtr);
       bits->bitPtr++;
 
-      if (bits->bitPtr==8)
+      if (bits->bitPtr==BITS_PER_CHAR)
       {
          bits->bitPtr=0;
-         bits->bytePtr++;
+         bits->charPtr++;
+         bits->chars[bits->charPtr] = 0;
       }
       bits->nbBits++;
       nbBits--;
@@ -262,19 +268,19 @@
 unsigned int speex_bits_unpack_unsigned(SpeexBits *bits, int nbBits)
 {
    unsigned int d=0;
-   if ((bits->bytePtr<<3)+bits->bitPtr+nbBits>bits->nbBits)
+   if ((bits->charPtr<<LOG2_BITS_PER_CHAR)+bits->bitPtr+nbBits>bits->nbBits)
       bits->overflow=1;
    if (bits->overflow)
       return 0;
    while(nbBits)
    {
       d<<=1;
-      d |= (bits->bytes[bits->bytePtr]>>(7-bits->bitPtr))&1;
+      d |= (bits->chars[bits->charPtr]>>(BITS_PER_CHAR-1 - bits->bitPtr))&1;
       bits->bitPtr++;
-      if (bits->bitPtr==8)
+      if (bits->bitPtr==BITS_PER_CHAR)
       {
          bits->bitPtr=0;
-         bits->bytePtr++;
+         bits->charPtr++;
       }
       nbBits--;
    }
@@ -284,26 +290,26 @@
 unsigned int speex_bits_peek_unsigned(SpeexBits *bits, int nbBits)
 {
    unsigned int d=0;
-   int bitPtr, bytePtr;
-   char *bytes;
+   int bitPtr, charPtr;
+   char *chars;
 
-   if ((bits->bytePtr<<3)+bits->bitPtr+nbBits>bits->nbBits)
+   if ((bits->charPtr<<LOG2_BITS_PER_CHAR)+bits->bitPtr+nbBits>bits->nbBits)
      bits->overflow=1;
    if (bits->overflow)
       return 0;
 
    bitPtr=bits->bitPtr;
-   bytePtr=bits->bytePtr;
-   bytes = bits->bytes;
+   charPtr=bits->charPtr;
+   chars = bits->chars;
    while(nbBits)
    {
       d<<=1;
-      d |= (bytes[bytePtr]>>(7-bitPtr))&1;
+      d |= (chars[charPtr]>>(BITS_PER_CHAR-1 - bitPtr))&1;
       bitPtr++;
-      if (bitPtr==8)
+      if (bitPtr==BITS_PER_CHAR)
       {
          bitPtr=0;
-         bytePtr++;
+         charPtr++;
       }
       nbBits--;
    }
@@ -312,33 +318,21 @@
 
 int speex_bits_peek(SpeexBits *bits)
 {
-   if ((bits->bytePtr<<3)+bits->bitPtr+1>bits->nbBits)
+   if ((bits->charPtr<<LOG2_BITS_PER_CHAR)+bits->bitPtr+1>bits->nbBits)
       bits->overflow=1;
    if (bits->overflow)
       return 0;
-   return (bits->bytes[bits->bytePtr]>>(7-bits->bitPtr))&1;
+   return (bits->chars[bits->charPtr]>>(BITS_PER_CHAR-1 - bits->bitPtr))&1;
 }
 
 void speex_bits_advance(SpeexBits *bits, int n)
 {
-   int nbytes, nbits;
-
-   if ((bits->bytePtr<<3)+bits->bitPtr+n>bits->nbBits)
+    if (((bits->charPtr<<LOG2_BITS_PER_CHAR)+bits->bitPtr+n>bits->nbBits) || bits->overflow){
       bits->overflow=1;
-   if (bits->overflow)
       return;
-
-   nbytes = n >> 3;
-   nbits = n & 7;
-   
-   bits->bytePtr += nbytes;
-   bits->bitPtr += nbits;
-   
-   if (bits->bitPtr>7)
-   {
-      bits->bitPtr-=8;
-      bits->bytePtr++;
-   }
+    }
+   bits->charPtr += (bits->bitPtr+n) >> LOG2_BITS_PER_CHAR; /* divide by BITS_PER_CHAR */
+   bits->bitPtr = (bits->bitPtr+n) & (BITS_PER_CHAR-1);       /* modulo by BITS_PER_CHAR */
 }
 
 int speex_bits_remaining(SpeexBits *bits)
@@ -346,18 +340,18 @@
    if (bits->overflow)
       return -1;
    else
-      return bits->nbBits-((bits->bytePtr<<3)+bits->bitPtr);
+      return bits->nbBits-((bits->charPtr<<LOG2_BITS_PER_CHAR)+bits->bitPtr);
 }
 
 int speex_bits_nbytes(SpeexBits *bits)
 {
-   return ((bits->nbBits+7)>>3);
+   return ((bits->nbBits+BITS_PER_CHAR-1)>>LOG2_BITS_PER_CHAR);
 }
 
 void speex_bits_insert_terminator(SpeexBits *bits)
 {
-   if (bits->bitPtr<7)
+   if (bits->bitPtr<BITS_PER_CHAR-1)
       speex_bits_pack(bits, 0, 1);
-   while (bits->bitPtr<7)
+   while (bits->bitPtr<BITS_PER_CHAR-1)
       speex_bits_pack(bits, 1, 1);
 }

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/cb_search.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/cb_search.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/cb_search.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -29,6 +29,9 @@
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 
 #include "cb_search.h"
 #include "filters.h"
@@ -36,228 +39,428 @@
 #include "vq.h"
 #include "misc.h"
 
+#ifdef _USE_SSE
+#include "cb_search_sse.h"
+#elif defined(ARM4_ASM) || defined(ARM5E_ASM)
+#include "cb_search_arm4.h"
+#elif defined(BFIN_ASM)
+#include "cb_search_bfin.h"
+#endif
+
+#ifndef OVERRIDE_COMPUTE_WEIGHTED_CODEBOOK
+static void compute_weighted_codebook(const signed char *shape_cb, const spx_word16_t *r, spx_word16_t *resp, spx_word16_t *resp2, spx_word32_t *E, int shape_cb_size, int subvect_size, char *stack)
+{
+   int i, j, k;
+   VARDECL(spx_word16_t *shape);
+   ALLOC(shape, subvect_size, spx_word16_t);
+   for (i=0;i<shape_cb_size;i++)
+   {
+      spx_word16_t *res;
+      
+      res = resp+i*subvect_size;
+      for (k=0;k<subvect_size;k++)
+         shape[k] = (spx_word16_t)shape_cb[i*subvect_size+k];
+      E[i]=0;
+
+      /* Compute codeword response using convolution with impulse response */
+      for(j=0;j<subvect_size;j++)
+      {
+         spx_word32_t resj=0;
+         spx_word16_t res16;
+         for (k=0;k<=j;k++)
+            resj = MAC16_16(resj,shape[k],r[j-k]);
+#ifdef FIXED_POINT
+         res16 = EXTRACT16(SHR32(resj, 11));
+#else
+         res16 = 0.03125f*resj;
+#endif
+         /* Compute codeword energy */
+         E[i]=MAC16_16(E[i],res16,res16);
+         res[j] = res16;
+         /*printf ("%d\n", (int)res[j]);*/
+      }
+   }
+
+}
+#endif
+
+#ifndef OVERRIDE_TARGET_UPDATE
+static inline void target_update(spx_word16_t *t, spx_word16_t g, spx_word16_t *r, int len)
+{
+   int n;
+   int q=0;
+   for (n=0;n<len;n++,q++)
+      t[n] = SUB32(t[n],MULT16_16_Q11_32(g,r[q]));
+}
+#endif
+
+
+
+static void split_cb_search_shape_sign_N1(
+spx_sig_t target[],			/* target vector */
+spx_coef_t ak[],			/* LPCs for this subframe */
+spx_coef_t awk1[],			/* Weighted LPCs for this subframe */
+spx_coef_t awk2[],			/* Weighted LPCs for this subframe */
+const void *par,                      /* Codebook/search parameters*/
+int   p,                        /* number of LPC coeffs */
+int   nsf,                      /* number of samples in subframe */
+spx_sig_t *exc,
+spx_word16_t *r,
+SpeexBits *bits,
+char *stack,
+int   complexity,
+int   update_target
+)
+{
+   int i,j,m,n,q;
+   VARDECL(spx_word16_t *resp);
+#ifdef _USE_SSE
+   VARDECL(__m128 *resp2);
+   VARDECL(__m128 *E);
+#else
+   spx_word16_t *resp2;
+   VARDECL(spx_word32_t *E);
+#endif
+   VARDECL(spx_word16_t *t);
+   VARDECL(spx_sig_t *e);
+   const signed char *shape_cb;
+   int shape_cb_size, subvect_size, nb_subvect;
+   const split_cb_params *params;
+   int N=2;
+   int best_index;
+   spx_word32_t best_dist;
+   int have_sign;
+   N=complexity;
+   if (N>10)
+      N=10;
+   if (N<1)
+      N=1;
+   
+   params = (const split_cb_params *) par;
+   subvect_size = params->subvect_size;
+   nb_subvect = params->nb_subvect;
+   shape_cb_size = 1<<params->shape_bits;
+   shape_cb = params->shape_cb;
+   have_sign = params->have_sign;
+   ALLOC(resp, shape_cb_size*subvect_size, spx_word16_t);
+#ifdef _USE_SSE
+   ALLOC(resp2, (shape_cb_size*subvect_size)>>2, __m128);
+   ALLOC(E, shape_cb_size>>2, __m128);
+#else
+   resp2 = resp;
+   ALLOC(E, shape_cb_size, spx_word32_t);
+#endif
+   ALLOC(t, nsf, spx_word16_t);
+   ALLOC(e, nsf, spx_sig_t);
+   
+   /* FIXME: make that adaptive? */
+   for (i=0;i<nsf;i++)
+      t[i]=EXTRACT16(PSHR32(target[i],6));
+
+   compute_weighted_codebook(shape_cb, r, resp, resp2, E, shape_cb_size, subvect_size, stack);
+
+   for (i=0;i<nb_subvect;i++)
+   {
+      spx_word16_t *x=t+subvect_size*i;
+      /*Find new n-best based on previous n-best j*/
+      if (have_sign)
+         vq_nbest_sign(x, resp2, subvect_size, shape_cb_size, E, 1, &best_index, &best_dist, stack);
+      else
+         vq_nbest(x, resp2, subvect_size, shape_cb_size, E, 1, &best_index, &best_dist, stack);
+      
+      speex_bits_pack(bits,best_index,params->shape_bits+have_sign);
+      
+      {
+         int rind;
+         spx_word16_t *res;
+         spx_word16_t sign=1;
+         rind = best_index;
+         if (rind>=shape_cb_size)
+         {
+            sign=-1;
+            rind-=shape_cb_size;
+         }
+         res = resp+rind*subvect_size;
+         if (sign>0)
+            for (m=0;m<subvect_size;m++)
+               t[subvect_size*i+m] = SUB16(t[subvect_size*i+m], res[m]);
+         else
+            for (m=0;m<subvect_size;m++)
+               t[subvect_size*i+m] = ADD16(t[subvect_size*i+m], res[m]);
+
+#ifdef FIXED_POINT
+         if (sign)
+         {
+            for (j=0;j<subvect_size;j++)
+               e[subvect_size*i+j]=SHL32(EXTEND32(shape_cb[rind*subvect_size+j]),SIG_SHIFT-5);
+         } else {
+            for (j=0;j<subvect_size;j++)
+               e[subvect_size*i+j]=NEG32(SHL32(EXTEND32(shape_cb[rind*subvect_size+j]),SIG_SHIFT-5));
+         }
+#else
+         for (j=0;j<subvect_size;j++)
+            e[subvect_size*i+j]=sign*0.03125*shape_cb[rind*subvect_size+j];
+#endif
+      
+      }
+            
+      for (m=0;m<subvect_size;m++)
+      {
+         spx_word16_t g;
+         int rind;
+         spx_word16_t sign=1;
+         rind = best_index;
+         if (rind>=shape_cb_size)
+         {
+            sign=-1;
+            rind-=shape_cb_size;
+         }
+         
+         q=subvect_size-m;
+#ifdef FIXED_POINT
+         g=sign*shape_cb[rind*subvect_size+m];
+         target_update(t+subvect_size*(i+1), g, r+q, nsf-subvect_size*(i+1));
+#else
+         g=sign*0.03125*shape_cb[rind*subvect_size+m];
+         /*FIXME: I think that one too can be replaced by target_update */
+         for (n=subvect_size*(i+1);n<nsf;n++,q++)
+            t[n] = SUB32(t[n],g*r[q]);
+#endif
+      }
+   }
+
+   /* Update excitation */
+   /* FIXME: We could update the excitation directly above */
+   for (j=0;j<nsf;j++)
+      exc[j]=ADD32(exc[j],e[j]);
+   
+   /* Update target: only update target if necessary */
+   if (update_target)
+   {
+      VARDECL(spx_sig_t *r2);
+      ALLOC(r2, nsf, spx_sig_t);
+      syn_percep_zero(e, ak, awk1, awk2, r2, nsf,p, stack);
+      for (j=0;j<nsf;j++)
+         target[j]=SUB32(target[j],r2[j]);
+   }
+}
+
+
+
 void split_cb_search_shape_sign(
-float target[],			/* target vector */
-float ak[],			/* LPCs for this subframe */
-float awk1[],			/* Weighted LPCs for this subframe */
-float awk2[],			/* Weighted LPCs for this subframe */
-void *par,                      /* Codebook/search parameters*/
+spx_sig_t target[],			/* target vector */
+spx_coef_t ak[],			/* LPCs for this subframe */
+spx_coef_t awk1[],			/* Weighted LPCs for this subframe */
+spx_coef_t awk2[],			/* Weighted LPCs for this subframe */
+const void *par,                      /* Codebook/search parameters*/
 int   p,                        /* number of LPC coeffs */
 int   nsf,                      /* number of samples in subframe */
-float *exc,
-float *r,
+spx_sig_t *exc,
+spx_word16_t *r,
 SpeexBits *bits,
 char *stack,
-int   complexity
+int   complexity,
+int   update_target
 )
 {
    int i,j,k,m,n,q;
-   float *resp;
-   float *t, *e, *E, *r2;
-   float *tmp;
-   float *ndist, *odist;
-   int *itmp;
-   float **ot, **nt;
-   int **nind, **oind;
-   int *ind;
-   signed char *shape_cb;
+   VARDECL(spx_word16_t *resp);
+#ifdef _USE_SSE
+   VARDECL(__m128 *resp2);
+   VARDECL(__m128 *E);
+#else
+   spx_word16_t *resp2;
+   VARDECL(spx_word32_t *E);
+#endif
+   VARDECL(spx_word16_t *t);
+   VARDECL(spx_sig_t *e);
+   VARDECL(spx_sig_t *r2);
+   VARDECL(spx_word16_t *tmp);
+   VARDECL(spx_word32_t *ndist);
+   VARDECL(spx_word32_t *odist);
+   VARDECL(int *itmp);
+   VARDECL(spx_word16_t **ot2);
+   VARDECL(spx_word16_t **nt2);
+   spx_word16_t **ot, **nt;
+   VARDECL(int **nind);
+   VARDECL(int **oind);
+   VARDECL(int *ind);
+   const signed char *shape_cb;
    int shape_cb_size, subvect_size, nb_subvect;
-   split_cb_params *params;
+   const split_cb_params *params;
    int N=2;
-   int *best_index;
-   float *best_dist;
+   VARDECL(int *best_index);
+   VARDECL(spx_word32_t *best_dist);
+   VARDECL(int *best_nind);
+   VARDECL(int *best_ntarget);
    int have_sign;
-
    N=complexity;
    if (N>10)
       N=10;
+   if (N<1)
+      N=1;
+   
+   if (N==1)
+   {
+      split_cb_search_shape_sign_N1(target,ak,awk1,awk2,par,p,nsf,exc,r,bits,stack,complexity,update_target);
+      return;
+   }
+   ALLOC(ot2, N, spx_word16_t*);
+   ALLOC(nt2, N, spx_word16_t*);
+   ALLOC(oind, N, int*);
+   ALLOC(nind, N, int*);
 
-   ot=PUSH(stack, N, float*);
-   nt=PUSH(stack, N, float*);
-   oind=PUSH(stack, N, int*);
-   nind=PUSH(stack, N, int*);
-
-   params = (split_cb_params *) par;
+   params = (const split_cb_params *) par;
    subvect_size = params->subvect_size;
    nb_subvect = params->nb_subvect;
    shape_cb_size = 1<<params->shape_bits;
    shape_cb = params->shape_cb;
    have_sign = params->have_sign;
-   resp = PUSH(stack, shape_cb_size*subvect_size, float);
-   t = PUSH(stack, nsf, float);
-   e = PUSH(stack, nsf, float);
-   r2 = PUSH(stack, nsf, float);
-   E = PUSH(stack, shape_cb_size, float);
-   ind = PUSH(stack, nb_subvect, int);
+   ALLOC(resp, shape_cb_size*subvect_size, spx_word16_t);
+#ifdef _USE_SSE
+   ALLOC(resp2, (shape_cb_size*subvect_size)>>2, __m128);
+   ALLOC(E, shape_cb_size>>2, __m128);
+#else
+   resp2 = resp;
+   ALLOC(E, shape_cb_size, spx_word32_t);
+#endif
+   ALLOC(t, nsf, spx_word16_t);
+   ALLOC(e, nsf, spx_sig_t);
+   ALLOC(r2, nsf, spx_sig_t);
+   ALLOC(ind, nb_subvect, int);
 
-   tmp = PUSH(stack, 2*N*nsf, float);
+   ALLOC(tmp, 2*N*nsf, spx_word16_t);
    for (i=0;i<N;i++)
    {
-      ot[i]=tmp;
-      tmp += nsf;
-      nt[i]=tmp;
-      tmp += nsf;
+      ot2[i]=tmp+2*i*nsf;
+      nt2[i]=tmp+(2*i+1)*nsf;
    }
-
-   best_index = PUSH(stack, N, int);
-   best_dist = PUSH(stack, N, float);
-   ndist = PUSH(stack, N, float);
-   odist = PUSH(stack, N, float);
+   ot=ot2;
+   nt=nt2;
+   ALLOC(best_index, N, int);
+   ALLOC(best_dist, N, spx_word32_t);
+   ALLOC(best_nind, N, int);
+   ALLOC(best_ntarget, N, int);
+   ALLOC(ndist, N, spx_word32_t);
+   ALLOC(odist, N, spx_word32_t);
    
-   itmp = PUSH(stack, 2*N*nb_subvect, int);
+   ALLOC(itmp, 2*N*nb_subvect, int);
    for (i=0;i<N;i++)
    {
-      nind[i]=itmp;
-      itmp+=nb_subvect;
-      oind[i]=itmp;
-      itmp+=nb_subvect;
-      for (j=0;j<nb_subvect;j++)
-         nind[i][j]=oind[i][j]=-1;
+      nind[i]=itmp+2*i*nb_subvect;
+      oind[i]=itmp+(2*i+1)*nb_subvect;
    }
+   
+   /* FIXME: make that adaptive? */
+   for (i=0;i<nsf;i++)
+      t[i]=EXTRACT16(PSHR32(target[i],6));
 
    for (j=0;j<N;j++)
-      for (i=0;i<nsf;i++)
-         ot[j][i]=target[i];
+      speex_move(&ot[j][0], t, nsf*sizeof(spx_word16_t));
 
-   for (i=0;i<nsf;i++)
-      t[i]=target[i];
-
    /* Pre-compute codewords response and energy */
-   for (i=0;i<shape_cb_size;i++)
-   {
-      float *res;
-      signed char *shape;
+   compute_weighted_codebook(shape_cb, r, resp, resp2, E, shape_cb_size, subvect_size, stack);
 
-      res = resp+i*subvect_size;
-      shape = shape_cb+i*subvect_size;
-
-      /* Compute codeword response using convolution with impulse response */
-      for(j=0;j<subvect_size;j++)
-      {
-         res[j]=0;
-         for (k=0;k<=j;k++)
-            res[j] += 0.03125*shape[k]*r[j-k];
-      }
-      
-      /* Compute codeword energy */
-      E[i]=0;
-      for(j=0;j<subvect_size;j++)
-         E[i]+=res[j]*res[j];
-   }
-
    for (j=0;j<N;j++)
       odist[j]=0;
+   
    /*For all subvectors*/
    for (i=0;i<nb_subvect;i++)
    {
       /*"erase" nbest list*/
       for (j=0;j<N;j++)
-         ndist[j]=-1;
+         ndist[j]=VERY_LARGE32;
 
       /*For all n-bests of previous subvector*/
       for (j=0;j<N;j++)
       {
-         float *x=ot[j]+subvect_size*i;
+         spx_word16_t *x=ot[j]+subvect_size*i;
+         spx_word32_t tener = 0;
+         for (m=0;m<subvect_size;m++)
+            tener = MAC16_16(tener, x[m],x[m]);
+#ifdef FIXED_POINT
+         tener = SHR32(tener,1);
+#else
+         tener *= .5;
+#endif
          /*Find new n-best based on previous n-best j*/
          if (have_sign)
-            vq_nbest_sign(x, resp, subvect_size, shape_cb_size, E, N, best_index, best_dist);
+            vq_nbest_sign(x, resp2, subvect_size, shape_cb_size, E, N, best_index, best_dist, stack);
          else
-            vq_nbest(x, resp, subvect_size, shape_cb_size, E, N, best_index, best_dist);
+            vq_nbest(x, resp2, subvect_size, shape_cb_size, E, N, best_index, best_dist, stack);
 
          /*For all new n-bests*/
          for (k=0;k<N;k++)
          {
-            float *ct;
-            float err=0;
-            ct = ot[j];
-            /*update target*/
-
-            /*previous target*/
-            for (m=i*subvect_size;m<(i+1)*subvect_size;m++)
-               t[m]=ct[m];
-
-            /* New code: update only enough of the target to calculate error*/
-            {
-               int rind;
-               float *res;
-               float sign=1;
-               rind = best_index[k];
-               if (rind>=shape_cb_size)
-               {
-                  sign=-1;
-                  rind-=shape_cb_size;
-               }
-               res = resp+rind*subvect_size;
-               if (sign>0)
-                  for (m=0;m<subvect_size;m++)
-                     t[subvect_size*i+m] -= res[m];
-               else
-                  for (m=0;m<subvect_size;m++)
-                     t[subvect_size*i+m] += res[m];
-            }
+            /* Compute total distance (including previous sub-vectors */
+            spx_word32_t err = ADD32(ADD32(odist[j],best_dist[k]),tener);
             
-            /*compute error (distance)*/
-            err=odist[j];
-            for (m=i*subvect_size;m<(i+1)*subvect_size;m++)
-               err += t[m]*t[m];
             /*update n-best list*/
-            if (err<ndist[N-1] || ndist[N-1]<-.5)
+            if (err<ndist[N-1])
             {
-
-               /*previous target (we don't care what happened before*/
-               for (m=(i+1)*subvect_size;m<nsf;m++)
-                  t[m]=ct[m];
-               /* New code: update the rest of the target only if it's worth it */
-               for (m=0;m<subvect_size;m++)
-               {
-                  float g;
-                  int rind;
-                  float sign=1;
-                  rind = best_index[k];
-                  if (rind>=shape_cb_size)
-                  {
-                     sign=-1;
-                     rind-=shape_cb_size;
-                  }
-
-                  g=sign*0.03125*shape_cb[rind*subvect_size+m];
-                  q=subvect_size-m;
-                  for (n=subvect_size*(i+1);n<nsf;n++,q++)
-                     t[n] -= g*r[q];
-               }
-
-
                for (m=0;m<N;m++)
                {
-                  if (err < ndist[m] || ndist[m]<-.5)
+                  if (err < ndist[m])
                   {
                      for (n=N-1;n>m;n--)
                      {
-                        for (q=(i+1)*subvect_size;q<nsf;q++)
-                           nt[n][q]=nt[n-1][q];
-                        for (q=0;q<nb_subvect;q++)
-                           nind[n][q]=nind[n-1][q];
-                        ndist[n]=ndist[n-1];
+                        ndist[n] = ndist[n-1];
+                        best_nind[n] = best_nind[n-1];
+                        best_ntarget[n] = best_ntarget[n-1];
                      }
-                     for (q=(i+1)*subvect_size;q<nsf;q++)
-                        nt[m][q]=t[q];
-                     for (q=0;q<nb_subvect;q++)
-                        nind[m][q]=oind[j][q];
-                     nind[m][i]=best_index[k];
-                     ndist[m]=err;
+                     ndist[m] = err;
+                     best_nind[n] = best_index[k];
+                     best_ntarget[n] = j;
                      break;
                   }
                }
             }
          }
          if (i==0)
-           break;
+            break;
       }
+      for (j=0;j<N;j++)
+      {
+         //spx_word16_t *ct = ot[best_ntarget[j]];
+         
+         /*previous target (we don't care what happened before*/
+         for (m=(i+1)*subvect_size;m<nsf;m++)
+            nt[j][m]=ot[best_ntarget[j]][m];
+         
+         /* New code: update the rest of the target only if it's worth it */
+         for (m=0;m<subvect_size;m++)
+         {
+            spx_word16_t g;
+            int rind;
+            spx_word16_t sign=1;
+            rind = best_nind[j];
+            if (rind>=shape_cb_size)
+            {
+               sign=-1;
+               rind-=shape_cb_size;
+            }
 
+            q=subvect_size-m;
+#ifdef FIXED_POINT
+            g=sign*shape_cb[rind*subvect_size+m];
+            target_update(nt[j]+subvect_size*(i+1), g, r+q, nsf-subvect_size*(i+1));
+#else
+            g=sign*0.03125*shape_cb[rind*subvect_size+m];
+            /*FIXME: I think that one too can be replaced by target_update */
+            for (n=subvect_size*(i+1);n<nsf;n++,q++)
+               nt[j][n] = SUB32(nt[j][n],g*r[q]);
+#endif
+         }
+
+         for (q=0;q<nb_subvect;q++)
+            nind[j][q]=oind[best_ntarget[j]][q];
+         nind[j][i]=best_nind[j];
+      }
+
       /*update old-new data*/
       /* just swap pointers instead of a long copy */
       {
-         float **tmp2;
+         spx_word16_t **tmp2;
          tmp2=ot;
          ot=nt;
          nt=tmp2;
@@ -280,53 +483,66 @@
    for (i=0;i<nb_subvect;i++)
    {
       int rind;
-      float sign=1;
+      spx_word16_t sign=1;
       rind = ind[i];
       if (rind>=shape_cb_size)
       {
          sign=-1;
          rind-=shape_cb_size;
       }
-
+#ifdef FIXED_POINT
+      if (sign==1)
+      {
+         for (j=0;j<subvect_size;j++)
+            e[subvect_size*i+j]=SHL32(EXTEND32(shape_cb[rind*subvect_size+j]),SIG_SHIFT-5);
+      } else {
+         for (j=0;j<subvect_size;j++)
+            e[subvect_size*i+j]=NEG32(SHL32(EXTEND32(shape_cb[rind*subvect_size+j]),SIG_SHIFT-5));
+      }
+#else
       for (j=0;j<subvect_size;j++)
          e[subvect_size*i+j]=sign*0.03125*shape_cb[rind*subvect_size+j];
+#endif
    }   
    /* Update excitation */
    for (j=0;j<nsf;j++)
-      exc[j]+=e[j];
+      exc[j]=ADD32(exc[j],e[j]);
    
-   /* Update target */
-   syn_percep_zero(e, ak, awk1, awk2, r2, nsf,p, stack);
-   for (j=0;j<nsf;j++)
-      target[j]-=r2[j];
-
+   /* Update target: only update target if necessary */
+   if (update_target)
+   {
+      syn_percep_zero(e, ak, awk1, awk2, r2, nsf,p, stack);
+      for (j=0;j<nsf;j++)
+         target[j]=SUB32(target[j],r2[j]);
+   }
 }
 
 
 void split_cb_shape_sign_unquant(
-float *exc,
-void *par,                      /* non-overlapping codebook */
+spx_sig_t *exc,
+const void *par,                      /* non-overlapping codebook */
 int   nsf,                      /* number of samples in subframe */
 SpeexBits *bits,
 char *stack
 )
 {
    int i,j;
-   int *ind, *signs;
-   signed char *shape_cb;
+   VARDECL(int *ind);
+   VARDECL(int *signs);
+   const signed char *shape_cb;
    int shape_cb_size, subvect_size, nb_subvect;
-   split_cb_params *params;
+   const split_cb_params *params;
    int have_sign;
 
-   params = (split_cb_params *) par;
+   params = (const split_cb_params *) par;
    subvect_size = params->subvect_size;
    nb_subvect = params->nb_subvect;
    shape_cb_size = 1<<params->shape_bits;
    shape_cb = params->shape_cb;
    have_sign = params->have_sign;
 
-   ind = PUSH(stack, nb_subvect, int);
-   signs = PUSH(stack, nb_subvect, int);
+   ALLOC(ind, nb_subvect, int);
+   ALLOC(signs, nb_subvect, int);
 
    /* Decode codewords and gains */
    for (i=0;i<nb_subvect;i++)
@@ -340,31 +556,44 @@
    /* Compute decoded excitation */
    for (i=0;i<nb_subvect;i++)
    {
-      float s=1;
+      spx_word16_t s=1;
       if (signs[i])
          s=-1;
+#ifdef FIXED_POINT
+      if (s==1)
+      {
+         for (j=0;j<subvect_size;j++)
+            exc[subvect_size*i+j]=SHL32(EXTEND32(shape_cb[ind[i]*subvect_size+j]),SIG_SHIFT-5);
+      } else {
+         for (j=0;j<subvect_size;j++)
+            exc[subvect_size*i+j]=NEG32(SHL32(EXTEND32(shape_cb[ind[i]*subvect_size+j]),SIG_SHIFT-5));
+      }
+#else
       for (j=0;j<subvect_size;j++)
-         exc[subvect_size*i+j]+=s*0.03125*shape_cb[ind[i]*subvect_size+j];
+         exc[subvect_size*i+j]+=s*0.03125*shape_cb[ind[i]*subvect_size+j];      
+#endif
    }
 }
 
 void noise_codebook_quant(
-float target[],			/* target vector */
-float ak[],			/* LPCs for this subframe */
-float awk1[],			/* Weighted LPCs for this subframe */
-float awk2[],			/* Weighted LPCs for this subframe */
-void *par,                      /* Codebook/search parameters*/
+spx_sig_t target[],			/* target vector */
+spx_coef_t ak[],			/* LPCs for this subframe */
+spx_coef_t awk1[],			/* Weighted LPCs for this subframe */
+spx_coef_t awk2[],			/* Weighted LPCs for this subframe */
+const void *par,                      /* Codebook/search parameters*/
 int   p,                        /* number of LPC coeffs */
 int   nsf,                      /* number of samples in subframe */
-float *exc,
-float *r,
+spx_sig_t *exc,
+spx_word16_t *r,
 SpeexBits *bits,
 char *stack,
-int   complexity
+int   complexity,
+int   update_target
 )
 {
    int i;
-   float *tmp=PUSH(stack, nsf, float);
+   VARDECL(spx_sig_t *tmp);
+   ALLOC(tmp, nsf, spx_sig_t);
    residue_percep_zero(target, ak, awk1, awk2, tmp, nsf, p, stack);
 
    for (i=0;i<nsf;i++)
@@ -376,8 +605,8 @@
 
 
 void noise_codebook_unquant(
-float *exc,
-void *par,                      /* non-overlapping codebook */
+spx_sig_t *exc,
+const void *par,                      /* non-overlapping codebook */
 int   nsf,                      /* number of samples in subframe */
 SpeexBits *bits,
 char *stack

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/cb_search.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/cb_search.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/cb_search.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -1,5 +1,5 @@
 /* Copyright (C) 2002 Jean-Marc Valin & David Rowe
-   File: cb_search.c
+   File: cb_search.h
    Overlapped codebook search
 
    Redistribution and use in source and binary forms, with or without
@@ -34,34 +34,36 @@
 #define CB_SEARCH_H
 
 #include <speex/speex_bits.h>
+#include "misc.h"
 
 typedef struct split_cb_params {
    int     subvect_size;
    int     nb_subvect;
-   signed char  *shape_cb;
+   const signed char  *shape_cb;
    int     shape_bits;
    int     have_sign;
 } split_cb_params;
 
 
 void split_cb_search_shape_sign(
-float target[],			/* target vector */
-float ak[],			/* LPCs for this subframe */
-float awk1[],			/* Weighted LPCs for this subframe */
-float awk2[],			/* Weighted LPCs for this subframe */
-void *par,                      /* Codebook/search parameters*/
+spx_sig_t target[],			/* target vector */
+spx_coef_t ak[],			/* LPCs for this subframe */
+spx_coef_t awk1[],			/* Weighted LPCs for this subframe */
+spx_coef_t awk2[],			/* Weighted LPCs for this subframe */
+const void *par,                      /* Codebook/search parameters*/
 int   p,                        /* number of LPC coeffs */
 int   nsf,                      /* number of samples in subframe */
-float *exc,
-float *r,
+spx_sig_t *exc,
+spx_word16_t *r,
 SpeexBits *bits,
 char *stack,
-int   complexity
+int   complexity,
+int   update_target
 );
 
 void split_cb_shape_sign_unquant(
-float *exc,
-void *par,                      /* non-overlapping codebook */
+spx_sig_t *exc,
+const void *par,                      /* non-overlapping codebook */
 int   nsf,                      /* number of samples in subframe */
 SpeexBits *bits,
 char *stack
@@ -69,24 +71,25 @@
 
 
 void noise_codebook_quant(
-float target[],			/* target vector */
-float ak[],			/* LPCs for this subframe */
-float awk1[],			/* Weighted LPCs for this subframe */
-float awk2[],			/* Weighted LPCs for this subframe */
-void *par,                      /* Codebook/search parameters*/
+spx_sig_t target[],			/* target vector */
+spx_coef_t ak[],			/* LPCs for this subframe */
+spx_coef_t awk1[],			/* Weighted LPCs for this subframe */
+spx_coef_t awk2[],			/* Weighted LPCs for this subframe */
+const void *par,                      /* Codebook/search parameters*/
 int   p,                        /* number of LPC coeffs */
 int   nsf,                      /* number of samples in subframe */
-float *exc,
-float *r,
+spx_sig_t *exc,
+spx_word16_t *r,
 SpeexBits *bits,
 char *stack,
-int   complexity
+int   complexity,
+int   update_target
 );
 
 
 void noise_codebook_unquant(
-float *exc,
-void *par,                      /* non-overlapping codebook */
+spx_sig_t *exc,
+const void *par,                      /* non-overlapping codebook */
 int   nsf,                      /* number of samples in subframe */
 SpeexBits *bits,
 char *stack

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/cb_search_arm4.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/cb_search_arm4.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/cb_search_arm4.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,130 @@
+/* Copyright (C) 2004 Jean-Marc Valin 
+   File: cb_search.c (ARM4 version)
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+   
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+   
+   - Neither the name of the Xiph.org Foundation nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+   
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#define OVERRIDE_COMPUTE_WEIGHTED_CODEBOOK
+static void compute_weighted_codebook(const signed char *shape_cb, const spx_sig_t *r, spx_word16_t *resp, spx_word16_t *resp2, spx_word32_t *E, int shape_cb_size, int subvect_size, char *stack)
+{
+   int i, j, k;
+  //const signed char *shape;
+   for (i=0;i<shape_cb_size;i+=4)
+   {
+
+      //shape = shape_cb;
+      E[0]=0;
+      E[1]=0;
+      E[2]=0;
+      E[3]=0;
+
+      /* Compute codeword response using convolution with impulse response */
+      for(j=0;j<subvect_size;j++)
+      {
+#if 1
+          spx_word16_t *res;
+          res = resp+j;
+          spx_word32_t resj0,resj1,resj2,resj3;
+          spx_word32_t dead1, dead2, dead3, dead4, dead5, dead6, dead7, dead8;
+          __asm__ __volatile__ (
+                "mov %0, #0 \n\t"
+                "mov %1, #0 \n\t"
+                "mov %2, #0 \n\t"
+                "mov %3, #0 \n\t"
+                ".weighted%=: \n\t"
+                "ldrsb %8, [%6] \n\t"
+                "ldr %10, [%5], #-4 \n\t"
+                "mov %9, %6 \n\t"
+                "ldrsb %11, [%9, %7]! \n\t"
+                "mla %0, %10, %8, %0 \n\t"
+                "ldrsb %8, [%9, %7]! \n\t"
+                "mla %1, %10, %11, %1 \n\t"
+                "ldrsb %11, [%9, %7]! \n\t"
+                "mla %2, %10, %8, %2 \n\t"
+                "subs %4, %4, #1 \n\t"
+                "mla %3, %10, %11, %3 \n\t"
+                "add %6, %6, #1 \n\t"
+                "bne .weighted%= \n\t"
+            : "=r" (resj0), "=r" (resj1), "=r" (resj2), "=r" (resj3),
+          "=r" (dead1), "=r" (dead2), "=r" (dead3), "=r" (dead4),
+          "=r" (dead5), "=r" (dead6), "=r" (dead7), "=r" (dead8)
+            : "4" (j+1), "5" (r+j), "6" (shape_cb), "7" (subvect_size)
+            : "cc", "memory");
+#else
+          spx_word16_t *res;
+          res = resp+j;
+          spx_word32_t resj0=0;
+          spx_word32_t resj1=0;
+          spx_word32_t resj2=0;
+          spx_word32_t resj3=0;
+          for (k=0;k<=j;k++)
+          {
+             const signed char *shape=shape_cb+k;
+             resj0 = MAC16_16(resj0,*shape,r[j-k]);
+             shape += subvect_size;
+             resj1 = MAC16_16(resj1,*shape,r[j-k]);
+             shape += subvect_size;
+             resj2 = MAC16_16(resj2,*shape,r[j-k]);
+             shape += subvect_size;
+             resj3 = MAC16_16(resj3,*shape,r[j-k]);
+             shape += subvect_size;
+          }
+#endif
+
+#ifdef FIXED_POINT
+          resj0 = SHR(resj0, 11);
+          resj1 = SHR(resj1, 11);
+          resj2 = SHR(resj2, 11);
+          resj3 = SHR(resj3, 11);
+#else
+          resj0 *= 0.03125;
+          resj1 *= 0.03125;
+          resj2 *= 0.03125;
+          resj3 *= 0.03125;
+#endif
+
+          /* Compute codeword energy */
+          E[0]=ADD32(E[0],MULT16_16(resj0,resj0));
+          E[1]=ADD32(E[1],MULT16_16(resj1,resj1));
+          E[2]=ADD32(E[2],MULT16_16(resj2,resj2));
+          E[3]=ADD32(E[3],MULT16_16(resj3,resj3));
+          *res = resj0;
+          res += subvect_size;
+          *res = resj1;
+          res += subvect_size;
+          *res = resj2;
+          res += subvect_size;
+          *res = resj3;
+          res += subvect_size;
+      }
+      resp += subvect_size<<2;
+      shape_cb += subvect_size<<2;
+      E+=4;
+   }
+
+}

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/cb_search_bfin.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/cb_search_bfin.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/cb_search_bfin.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,103 @@
+/* Copyright (C) 2005 Analog Devices
+   Author: Jean-Marc Valin 
+   File: cb_search_bfin.h
+   Fixed codebook functions (Blackfin version)
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+   
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+   
+   - Neither the name of the Xiph.org Foundation nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+   
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#define OVERRIDE_COMPUTE_WEIGHTED_CODEBOOK 
+void compute_weighted_codebook(const signed char *shape_cb, const spx_word16_t *r, spx_word16_t *resp, spx_word16_t *resp2, spx_word32_t *E, int shape_cb_size, int subvect_size, char *stack)
+{
+   int i;
+   for (i=0;i<shape_cb_size;i++)
+   {
+      __asm__ __volatile__ (
+         "P0 = %0;\n\t"
+         "LC0 = P0;\n\t"
+         "P1 = %1;\n\t"
+         "P2 = %2;\n\t"
+         "P3 = %3;\n\t"
+         "P0 = 1;\n\t"
+         "L0 = 0;\n\t"
+         "L1 = 0;\n\t"
+         "R2 = 0;\n\t"
+         "A1 = 0;\n\t"
+         "LOOP outter%= LC0;\n\t"
+         "LOOP_BEGIN outter%=;\n\t"
+            "A0 = 0;\n\t"
+            "P4 = P1;\n\t"
+            "I1 = P2;\n\t"
+            "R0 = B[P4++] (X) || R1.L = W[I1--];\n\t"
+            "LOOP inner%= LC1 = P0;\n\t"
+            "LOOP_BEGIN inner%=;\n\t"
+               "A0 += R0.L*R1.L (IS) || R0 = B[P4++] (X) || R1.L = W[I1--];\n\t"
+            "LOOP_END inner%=;\n\t"
+            "R0 = A0;\n\t"
+            "R0 >>>= 11;\n\t"
+            "A1 += R0.L*R0.L (IS);\n\t"
+            "W[P3++] = R0;\n\t"
+            "P0 += 1;\n\t"
+            "P2 += 2;\n\t"
+         "LOOP_END outter%=;\n\t"
+         "P4 = %4;\n\t"
+         "R1 = A1;\n\t"
+         "[P4] = R1;\n\t"
+         :
+      : "m" (subvect_size), "m" (shape_cb), "m" (r), "m" (resp), "m" (E)
+      : "A0", "P0", "P1", "P2", "P3", "P4", "R0", "R1", "R2", "I0", "I1", "L0", "L1", "A0", "A1", "memory"
+      );
+      shape_cb += subvect_size;
+      resp += subvect_size;
+      E++;
+   }
+}
+
+#define OVERRIDE_TARGET_UPDATE
+static inline void target_update(spx_word16_t *t, spx_word16_t g, spx_word16_t *r, int len)
+{
+   __asm__ __volatile__
+         (
+         "I0 = %0;\n\t"
+         "I1 = %1;\n\t"
+         "L0 = 0;\n\t"
+         "L1 = 0;\n\t"
+         "LOOP tupdate%= LC0 = %3;\n\t"
+         "LOOP_BEGIN tupdate%=;\n\t"
+            "R0.L = W[I0] || R1.L = W[I1++];\n\t"
+            "R1 = (A1 = R1.L*%2.L) (IS);\n\t"
+            "R1 >>>= 11;\n\t"
+            "R0.L = R0.L - R1.L;\n\t"
+            "W[I0++] = R0.L;\n\t"
+         "LOOP_END tupdate%=;\n\t"
+   :
+   : "a" (t), "a" (r), "d" (g), "a" (len)
+   : "R0", "R1", "A1", "I0", "I1", "L0", "L1"
+         );
+}
+

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/cb_search_sse.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/cb_search_sse.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/cb_search_sse.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,81 @@
+/* Copyright (C) 2004 Jean-Marc Valin 
+   File: cb_search.c (SSE version)
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+   
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+   
+   - Neither the name of the Xiph.org Foundation nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+   
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <xmmintrin.h>
+
+static inline void _spx_mm_getr_ps (__m128 U, float *__Z, float *__Y, float *__X, float *__W)
+{
+  union {
+    float __a[4];
+    __m128 __v;
+  } __u;
+  
+  __u.__v = U;
+
+  *__Z = __u.__a[0];
+  *__Y = __u.__a[1];
+  *__X = __u.__a[2];
+  *__W = __u.__a[3];
+
+}
+
+#define OVERRIDE_COMPUTE_WEIGHTED_CODEBOOK
+static void compute_weighted_codebook(const signed char *shape_cb, const spx_sig_t *_r, float *resp, __m128 *resp2, __m128 *E, int shape_cb_size, int subvect_size, char *stack)
+{
+   int i, j, k;
+   __m128 resj, EE;
+   VARDECL(__m128 *r);
+   VARDECL(__m128 *shape);
+   ALLOC(r, subvect_size, __m128);
+   ALLOC(shape, subvect_size, __m128);
+   for(j=0;j<subvect_size;j++)
+      r[j] = _mm_load_ps1(_r+j);
+   for (i=0;i<shape_cb_size;i+=4)
+   {
+      float *_res = resp+i*subvect_size;
+      const signed char *_shape = shape_cb+i*subvect_size;
+      EE = _mm_setzero_ps();
+      for(j=0;j<subvect_size;j++)
+      {
+         shape[j] = _mm_setr_ps(0.03125*_shape[j], 0.03125*_shape[subvect_size+j], 0.03125*_shape[2*subvect_size+j], 0.03125*_shape[3*subvect_size+j]);
+      }
+      for(j=0;j<subvect_size;j++)
+      {
+         resj = _mm_setzero_ps();
+         for (k=0;k<=j;k++)
+            resj = _mm_add_ps(resj, _mm_mul_ps(shape[k],r[j-k]));
+         _spx_mm_getr_ps(resj, _res+j, _res+subvect_size+j, _res+2*subvect_size+j, _res+3*subvect_size+j);
+         *resp2++ = resj;
+         EE = _mm_add_ps(EE, _mm_mul_ps(resj, resj));
+      }
+      E[i>>2] = EE;
+   }
+}

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/exc_10_16_table.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/exc_10_16_table.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/exc_10_16_table.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -31,7 +31,7 @@
 */
 
 
-signed char exc_10_16_table[160] = {
+const signed char exc_10_16_table[160] = {
 22,39,14,44,11,35,-2,23,-4,6,
 46,-28,13,-27,-23,12,4,20,-5,9,
 37,-18,-23,23,0,9,-6,-20,4,-1,

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/exc_10_32_table.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/exc_10_32_table.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/exc_10_32_table.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -31,7 +31,7 @@
 */
 
 
-signed char exc_10_32_table[320] = {
+const signed char exc_10_32_table[320] = {
 7,17,17,27,25,22,12,4,-3,0,
 28,-36,39,-24,-15,3,-9,15,-5,10,
 31,-28,11,31,-21,9,-11,-11,-2,-7,

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/exc_20_32_table.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/exc_20_32_table.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/exc_20_32_table.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -31,7 +31,7 @@
 */
 
 
-signed char exc_20_32_table[640] = {
+const signed char exc_20_32_table[640] = {
 12,32,25,46,36,33,9,14,-3,6,1,-8,0,-10,-5,-7,-7,-7,-5,-5,
 31,-27,24,-32,-4,10,-11,21,-3,19,23,-9,22,24,-10,-1,-10,-13,-7,-11,
 42,-33,31,19,-8,0,-10,-16,1,-21,-17,10,-8,14,8,4,11,-2,5,-2,

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/exc_5_256_table.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/exc_5_256_table.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/exc_5_256_table.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -31,7 +31,7 @@
 */
 
 
-signed char exc_5_256_table[1280] = {
+const signed char exc_5_256_table[1280] = {
 -8,-37,5,-43,5,
 73,61,39,12,-3,
 -61,-32,2,42,30,

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/exc_5_64_table.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/exc_5_64_table.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/exc_5_64_table.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -31,7 +31,7 @@
 */
 
 
-signed char exc_5_64_table[320]={
+const signed char exc_5_64_table[320]={
 1,5,-15,49,-66,
 -48,-4,50,-44,7,
 37,16,-18,25,-26,

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/exc_8_128_table.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/exc_8_128_table.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/exc_8_128_table.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -31,7 +31,7 @@
 */
 
 
-signed char exc_8_128_table[1024] = {
+const signed char exc_8_128_table[1024] = {
 -14,9,13,-32,2,-10,31,-10,
 -8,-8,6,-4,-1,10,-64,23,
 6,20,13,6,8,-22,16,34,

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/filters.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/filters.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/filters.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -30,90 +30,334 @@
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include "filters.h"
 #include "stack_alloc.h"
+#include "misc.h"
+#include "math_approx.h"
+#include "ltp.h"
 #include <math.h>
 
+#ifdef _USE_SSE
+#include "filters_sse.h"
+#elif defined (ARM4_ASM) || defined(ARM5E_ASM)
+#include "filters_arm4.h"
+#elif defined (BFIN_ASM)
+#include "filters_bfin.h"
+#endif
 
-void bw_lpc(float gamma, float *lpc_in, float *lpc_out, int order)
+
+
+void bw_lpc(spx_word16_t gamma, const spx_coef_t *lpc_in, spx_coef_t *lpc_out, int order)
 {
    int i;
-   float tmp=1;
-   for (i=0;i<order+1;i++)
+   spx_word16_t tmp=gamma;
+   for (i=0;i<order;i++)
    {
-      lpc_out[i] = tmp * lpc_in[i];
-      tmp *= gamma;
+      lpc_out[i] = MULT16_16_P15(tmp,lpc_in[i]);
+      tmp = MULT16_16_P15(tmp, gamma);
    }
 }
 
-#ifdef _USE_SSE
-#include "filters_sse.h"
+
+#ifdef FIXED_POINT
+
+/* FIXME: These functions are ugly and probably introduce too much error */
+void signal_mul(const spx_sig_t *x, spx_sig_t *y, spx_word32_t scale, int len)
+{
+   int i;
+   for (i=0;i<len;i++)
+   {
+      y[i] = SHL32(MULT16_32_Q14(EXTRACT16(SHR32(x[i],7)),scale),7);
+   }
+}
+
+void signal_div(const spx_sig_t *x, spx_sig_t *y, spx_word32_t scale, int len)
+{
+   int i;
+   if (scale > SHL32(EXTEND32(SIG_SCALING), 8))
+   {
+      spx_word16_t scale_1;
+      scale = PSHR32(scale, SIG_SHIFT);
+      scale_1 = EXTRACT16(DIV32_16(SHL32(EXTEND32(SIG_SCALING),7),scale));
+      for (i=0;i<len;i++)
+      {
+         y[i] = SHR32(MULT16_16(scale_1, EXTRACT16(SHR32(x[i],SIG_SHIFT))),7);
+      }
+   } else {
+      spx_word16_t scale_1;
+      scale = PSHR32(scale, SIG_SHIFT-5);
+      scale_1 = DIV32_16(SHL32(EXTEND32(SIG_SCALING),3),scale);
+      for (i=0;i<len;i++)
+      {
+         y[i] = MULT16_16(scale_1, EXTRACT16(SHR32(x[i],SIG_SHIFT-2)));
+      }
+   }
+}
+
 #else
-void filter_mem2(float *x, float *num, float *den, float *y, int N, int ord, float *mem)
+
+void signal_mul(const spx_sig_t *x, spx_sig_t *y, spx_word32_t scale, int len)
 {
+   int i;
+   for (i=0;i<len;i++)
+      y[i] = scale*x[i];
+}
+
+void signal_div(const spx_sig_t *x, spx_sig_t *y, spx_word32_t scale, int len)
+{
+   int i;
+   float scale_1 = 1/scale;
+   for (i=0;i<len;i++)
+      y[i] = scale_1*x[i];
+}
+#endif
+
+
+
+#ifdef FIXED_POINT
+
+
+
+spx_word16_t compute_rms(const spx_sig_t *x, int len)
+{
+   int i;
+   spx_word32_t sum=0;
+   spx_sig_t max_val=1;
+   int sig_shift;
+
+   for (i=0;i<len;i++)
+   {
+      spx_sig_t tmp = x[i];
+      if (tmp<0)
+         tmp = -tmp;
+      if (tmp > max_val)
+         max_val = tmp;
+   }
+
+   sig_shift=0;
+   while (max_val>16383)
+   {
+      sig_shift++;
+      max_val >>= 1;
+   }
+
+   for (i=0;i<len;i+=4)
+   {
+      spx_word32_t sum2=0;
+      spx_word16_t tmp;
+      tmp = EXTRACT16(SHR32(x[i],sig_shift));
+      sum2 = MAC16_16(sum2,tmp,tmp);
+      tmp = EXTRACT16(SHR32(x[i+1],sig_shift));
+      sum2 = MAC16_16(sum2,tmp,tmp);
+      tmp = EXTRACT16(SHR32(x[i+2],sig_shift));
+      sum2 = MAC16_16(sum2,tmp,tmp);
+      tmp = EXTRACT16(SHR32(x[i+3],sig_shift));
+      sum2 = MAC16_16(sum2,tmp,tmp);
+      sum = ADD32(sum,SHR32(sum2,6));
+   }
+   
+   return EXTRACT16(SHR32(SHL32(EXTEND32(spx_sqrt(1+DIV32(sum,len))),(sig_shift+3)),SIG_SHIFT));
+}
+
+
+#ifndef OVERRIDE_NORMALIZE16
+int normalize16(const spx_sig_t *x, spx_word16_t *y, spx_sig_t max_scale, int len)
+{
+   int i;
+   spx_sig_t max_val=1;
+   int sig_shift;
+   
+   for (i=0;i<len;i++)
+   {
+      spx_sig_t tmp = x[i];
+      if (tmp<0)
+         tmp = NEG32(tmp);
+      if (tmp >= max_val)
+         max_val = tmp;
+   }
+
+   sig_shift=0;
+   while (max_val>max_scale)
+   {
+      sig_shift++;
+      max_val >>= 1;
+   }
+
+   for (i=0;i<len;i++)
+      y[i] = EXTRACT16(SHR32(x[i], sig_shift));
+   
+   return sig_shift;
+}
+#endif
+
+#else
+
+spx_word16_t compute_rms(const spx_sig_t *x, int len)
+{
+   int i;
+   float sum=0;
+   for (i=0;i<len;i++)
+   {
+      sum += x[i]*x[i];
+   }
+   return sqrt(.1+sum/len);
+}
+#endif
+
+
+
+#ifndef OVERRIDE_FILTER_MEM2
+#ifdef PRECISION16
+void filter_mem2(const spx_sig_t *x, const spx_coef_t *num, const spx_coef_t *den, spx_sig_t *y, int N, int ord, spx_mem_t *mem)
+{
    int i,j;
-   float xi,yi;
+   spx_word16_t xi,yi,nyi;
+
    for (i=0;i<N;i++)
    {
-      xi=x[i];
-      y[i] = num[0]*xi + mem[0];
-      yi=y[i];
+      xi= EXTRACT16(PSHR32(SATURATE(x[i],536870911),SIG_SHIFT));
+      yi = EXTRACT16(PSHR32(SATURATE(ADD32(x[i], SHL32(mem[0],1)),536870911),SIG_SHIFT));
+      nyi = NEG16(yi);
       for (j=0;j<ord-1;j++)
       {
-         mem[j] = mem[j+1] + num[j+1]*xi - den[j+1]*yi;
+         mem[j] = MAC16_16(MAC16_16(mem[j+1], num[j],xi), den[j],nyi);
       }
-      mem[ord-1] = num[ord]*xi - den[ord]*yi;
+      mem[ord-1] = ADD32(MULT16_16(num[ord-1],xi), MULT16_16(den[ord-1],nyi));
+      y[i] = SHL32(EXTEND32(yi),SIG_SHIFT);
    }
 }
+#else
+void filter_mem2(const spx_sig_t *x, const spx_coef_t *num, const spx_coef_t *den, spx_sig_t *y, int N, int ord, spx_mem_t *mem)
+{
+   int i,j;
+   spx_sig_t xi,yi,nyi;
 
+   for (i=0;i<N;i++)
+   {
+      xi=SATURATE(x[i],805306368);
+      yi = SATURATE(ADD32(xi, SHL32(mem[0],2)),805306368);
+      nyi = NEG32(yi);
+      for (j=0;j<ord-1;j++)
+      {
+         mem[j] = MAC16_32_Q15(MAC16_32_Q15(mem[j+1], num[j],xi), den[j],nyi);
+      }
+      mem[ord-1] = SUB32(MULT16_32_Q15(num[ord-1],xi), MULT16_32_Q15(den[ord-1],yi));
+      y[i] = yi;
+   }
+}
+#endif
+#endif
 
-void iir_mem2(float *x, float *den, float *y, int N, int ord, float *mem)
+#ifndef OVERRIDE_IIR_MEM2
+#ifdef PRECISION16
+void iir_mem2(const spx_sig_t *x, const spx_coef_t *den, spx_sig_t *y, int N, int ord, spx_mem_t *mem)
 {
    int i,j;
+   spx_word16_t yi,nyi;
+
    for (i=0;i<N;i++)
    {
-      y[i] = x[i] + mem[0];
+      yi = EXTRACT16(PSHR32(SATURATE(x[i] + SHL32(mem[0],1),536870911),SIG_SHIFT));
+      nyi = NEG16(yi);
       for (j=0;j<ord-1;j++)
       {
-         mem[j] = mem[j+1] - den[j+1]*y[i];
+         mem[j] = MAC16_16(mem[j+1],den[j],nyi);
       }
-      mem[ord-1] = - den[ord]*y[i];
+      mem[ord-1] = MULT16_16(den[ord-1],nyi);
+      y[i] = SHL32(EXTEND32(yi),SIG_SHIFT);
    }
 }
+#else
+void iir_mem2(const spx_sig_t *x, const spx_coef_t *den, spx_sig_t *y, int N, int ord, spx_mem_t *mem)
+{
+   int i,j;
+   spx_word32_t xi,yi,nyi;
+
+   for (i=0;i<N;i++)
+   {
+      xi=SATURATE(x[i],805306368);
+      yi = SATURATE(xi + SHL32(mem[0],2),805306368);
+      nyi = NEG32(yi);
+      for (j=0;j<ord-1;j++)
+      {
+         mem[j] = MAC16_32_Q15(mem[j+1],den[j],nyi);
+      }
+      mem[ord-1] = MULT16_32_Q15(den[ord-1],nyi);
+      y[i] = yi;
+   }
+}
 #endif
+#endif
 
-void fir_mem2(float *x, float *num, float *y, int N, int ord, float *mem)
+#ifndef OVERRIDE_FIR_MEM2
+#ifdef PRECISION16
+void fir_mem2(const spx_sig_t *x, const spx_coef_t *num, spx_sig_t *y, int N, int ord, spx_mem_t *mem)
 {
    int i,j;
-   float xi;
+   spx_word16_t xi,yi;
+
    for (i=0;i<N;i++)
    {
-      xi=x[i];
-      y[i] = num[0]*xi + mem[0];
+      xi= EXTRACT16(PSHR32(SATURATE(x[i],536870911),SIG_SHIFT));
+      yi = EXTRACT16(PSHR32(SATURATE(x[i] + SHL32(mem[0],1),536870911),SIG_SHIFT));
       for (j=0;j<ord-1;j++)
       {
-         mem[j] = mem[j+1] + num[j+1]*xi;
+         mem[j] = MAC16_16(mem[j+1], num[j],xi);
       }
-      mem[ord-1] = num[ord]*xi;
+      mem[ord-1] = MULT16_16(num[ord-1],xi);
+      y[i] = SHL32(EXTEND32(yi),SIG_SHIFT);
    }
 }
+#else
+void fir_mem2(const spx_sig_t *x, const spx_coef_t *num, spx_sig_t *y, int N, int ord, spx_mem_t *mem)
+{
+   int i,j;
+   spx_word32_t xi,yi;
 
-void syn_percep_zero(float *xx, float *ak, float *awk1, float *awk2, float *y, int N, int ord, char *stack)
+   for (i=0;i<N;i++)
+   {
+      xi=SATURATE(x[i],805306368);
+      yi = xi + SHL32(mem[0],2);
+      for (j=0;j<ord-1;j++)
+      {
+         mem[j] = MAC16_32_Q15(mem[j+1], num[j],xi);
+      }
+      mem[ord-1] = MULT16_32_Q15(num[ord-1],xi);
+      y[i] = SATURATE(yi,805306368);
+   }
+}
+#endif
+#endif
+
+
+
+
+
+
+
+
+void syn_percep_zero(const spx_sig_t *xx, const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_sig_t *y, int N, int ord, char *stack)
 {
    int i;
-   float *mem = PUSH(stack,ord, float);
+   VARDECL(spx_mem_t *mem);
+   ALLOC(mem, ord, spx_mem_t);
    for (i=0;i<ord;i++)
+     mem[i]=0;
+   iir_mem2(xx, ak, y, N, ord, mem);
+   for (i=0;i<ord;i++)
       mem[i]=0;
-   filter_mem2(xx, awk1, ak, y, N, ord, mem);
-   for (i=0;i<ord;i++)
-     mem[i]=0;
-   iir_mem2(y, awk2, y, N, ord, mem);
+   filter_mem2(y, awk1, awk2, y, N, ord, mem);
 }
 
-void residue_percep_zero(float *xx, float *ak, float *awk1, float *awk2, float *y, int N, int ord, char *stack)
+void residue_percep_zero(const spx_sig_t *xx, const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_sig_t *y, int N, int ord, char *stack)
 {
    int i;
-   float *mem = PUSH(stack,ord, float);
+   VARDECL(spx_mem_t *mem);
+   ALLOC(mem, ord, spx_mem_t);
    for (i=0;i<ord;i++)
       mem[i]=0;
    filter_mem2(xx, ak, awk1, y, N, ord, mem);
@@ -122,83 +366,122 @@
    fir_mem2(y, awk2, y, N, ord, mem);
 }
 
+#ifndef OVERRIDE_COMPUTE_IMPULSE_RESPONSE
+void compute_impulse_response(const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_word16_t *y, int N, int ord, char *stack)
+{
+   int i,j;
+   spx_word16_t y1, ny1i, ny2i;
+   VARDECL(spx_mem_t *mem1);
+   VARDECL(spx_mem_t *mem2);
+   ALLOC(mem1, ord, spx_mem_t);
+   ALLOC(mem2, ord, spx_mem_t);
+   
+   y[0] = LPC_SCALING;
+   for (i=0;i<ord;i++)
+      y[i+1] = awk1[i];
+   i++;
+   for (;i<N;i++)
+      y[i] = VERY_SMALL;
+   
+   for (i=0;i<ord;i++)
+      mem1[i] = mem2[i] = 0;
+   for (i=0;i<N;i++)
+   {
+      y1 = ADD16(y[i], EXTRACT16(PSHR32(mem1[0],LPC_SHIFT)));
+      ny1i = NEG16(y1);
+      y[i] = ADD16(SHL16(y1,1), EXTRACT16(PSHR32(mem2[0],LPC_SHIFT)));
+      ny2i = NEG16(y[i]);
+      for (j=0;j<ord-1;j++)
+      {
+         mem1[j] = MAC16_16(mem1[j+1], awk2[j],ny1i);
+         mem2[j] = MAC16_16(mem2[j+1], ak[j],ny2i);
+      }
+      mem1[ord-1] = MULT16_16(awk2[ord-1],ny1i);
+      mem2[ord-1] = MULT16_16(ak[ord-1],ny2i);
+   }
+}
+#endif
 
-void qmf_decomp(float *xx, float *aa, float *y1, float *y2, int N, int M, float *mem, char *stack)
+void qmf_decomp(const spx_word16_t *xx, const spx_word16_t *aa, spx_sig_t *y1, spx_sig_t *y2, int N, int M, spx_word16_t *mem, char *stack)
 {
    int i,j,k,M2;
-   float *a;
-   float *x;
-   float *x2;
+   VARDECL(spx_word16_t *a);
+   VARDECL(spx_word16_t *x);
+   spx_word16_t *x2;
    
-   a = PUSH(stack, M, float);
-   x = PUSH(stack, N+M-1, float);
+   ALLOC(a, M, spx_word16_t);
+   ALLOC(x, N+M-1, spx_word16_t);
    x2=x+M-1;
    M2=M>>1;
    for (i=0;i<M;i++)
-      a[M-i-1]=aa[i];
+      a[M-i-1]= aa[i];
+
    for (i=0;i<M-1;i++)
       x[i]=mem[M-i-2];
    for (i=0;i<N;i++)
-      x[i+M-1]=xx[i];
+      x[i+M-1]=SATURATE(PSHR(xx[i],1),16383);
    for (i=0,k=0;i<N;i+=2,k++)
    {
       y1[k]=0;
       y2[k]=0;
       for (j=0;j<M2;j++)
       {
-         y1[k]+=a[j]*(x[i+j]+x2[i-j]);
-         y2[k]-=a[j]*(x[i+j]-x2[i-j]);
+         y1[k]=ADD32(y1[k],SHR(MULT16_16(a[j],ADD16(x[i+j],x2[i-j])),1));
+         y2[k]=SUB32(y2[k],SHR(MULT16_16(a[j],SUB16(x[i+j],x2[i-j])),1));
          j++;
-         y1[k]+=a[j]*(x[i+j]+x2[i-j]);
-         y2[k]+=a[j]*(x[i+j]-x2[i-j]);
+         y1[k]=ADD32(y1[k],SHR(MULT16_16(a[j],ADD16(x[i+j],x2[i-j])),1));
+         y2[k]=ADD32(y2[k],SHR(MULT16_16(a[j],SUB16(x[i+j],x2[i-j])),1));
       }
    }
    for (i=0;i<M-1;i++)
-     mem[i]=xx[N-i-1];
+     mem[i]=SATURATE(PSHR(xx[N-i-1],1),16383);
 }
 
+
 /* By segher */
-void fir_mem_up(float *x, float *a, float *y, int N, int M, float *mem, char *stack)
+void fir_mem_up(const spx_sig_t *x, const spx_word16_t *a, spx_sig_t *y, int N, int M, spx_word32_t *mem, char *stack)
    /* assumptions:
       all odd x[i] are zero -- well, actually they are left out of the array now
       N and M are multiples of 4 */
 {
    int i, j;
-   float *xx=PUSH(stack, M+N-1, float);
+   VARDECL(spx_word16_t *xx);
+   
+   ALLOC(xx, M+N-1, spx_word16_t);
 
    for (i = 0; i < N/2; i++)
-      xx[2*i] = x[N/2-1-i];
+      xx[2*i] = SHR(x[N/2-1-i],SIG_SHIFT+1);
    for (i = 0; i < M - 1; i += 2)
       xx[N+i] = mem[i+1];
 
    for (i = 0; i < N; i += 4) {
-      float y0, y1, y2, y3;
-      float x0;
+      spx_sig_t y0, y1, y2, y3;
+      spx_word16_t x0;
 
-      y0 = y1 = y2 = y3 = 0.f;
+      y0 = y1 = y2 = y3 = 0;
       x0 = xx[N-4-i];
 
       for (j = 0; j < M; j += 4) {
-         float x1;
-         float a0, a1;
+         spx_word16_t x1;
+         spx_word16_t a0, a1;
 
          a0 = a[j];
          a1 = a[j+1];
          x1 = xx[N-2+j-i];
 
-         y0 += a0 * x1;
-         y1 += a1 * x1;
-         y2 += a0 * x0;
-         y3 += a1 * x0;
+         y0 = ADD32(y0,SHR(MULT16_16(a0, x1),1));
+         y1 = ADD32(y1,SHR(MULT16_16(a1, x1),1));
+         y2 = ADD32(y2,SHR(MULT16_16(a0, x0),1));
+         y3 = ADD32(y3,SHR(MULT16_16(a1, x0),1));
 
          a0 = a[j+2];
          a1 = a[j+3];
          x0 = xx[N+j-i];
 
-         y0 += a0 * x0;
-         y1 += a1 * x0;
-         y2 += a0 * x1;
-         y3 += a1 * x1;
+         y0 = ADD32(y0,SHR(MULT16_16(a0, x0),1));
+         y1 = ADD32(y1,SHR(MULT16_16(a1, x0),1));
+         y2 = ADD32(y2,SHR(MULT16_16(a0, x1),1));
+         y3 = ADD32(y3,SHR(MULT16_16(a1, x1),1));
       }
       y[i] = y0;
       y[i+1] = y1;
@@ -211,61 +494,80 @@
 }
 
 
-void comp_filter_mem_init (CombFilterMem *mem)
+
+void comb_filter_mem_init (CombFilterMem *mem)
 {
    mem->last_pitch=0;
    mem->last_pitch_gain[0]=mem->last_pitch_gain[1]=mem->last_pitch_gain[2]=0;
    mem->smooth_gain=1;
 }
 
+#ifdef FIXED_POINT
+#define COMB_STEP 32767
+#else
+#define COMB_STEP 1.0
+#endif
+
 void comb_filter(
-float *exc,          /*decoded excitation*/
-float *new_exc,      /*enhanced excitation*/
-float *ak,           /*LPC filter coefs*/
+spx_sig_t *exc,          /*decoded excitation*/
+spx_sig_t *new_exc,      /*enhanced excitation*/
+spx_coef_t *ak,           /*LPC filter coefs*/
 int p,               /*LPC order*/
 int nsf,             /*sub-frame size*/
 int pitch,           /*pitch period*/
-float *pitch_gain,   /*pitch gain (3-tap)*/
-float  comb_gain,    /*gain of comb filter*/
+spx_word16_t *pitch_gain,   /*pitch gain (3-tap)*/
+spx_word16_t  comb_gain,    /*gain of comb filter*/
 CombFilterMem *mem
 )
 {
    int i;
-   float exc_energy=0, new_exc_energy=0;
-   float gain;
-   float step;
-   float fact;
-   /*Compute excitation energy prior to enhancement*/
-   for (i=0;i<nsf;i++)
-      exc_energy+=exc[i]*exc[i];
+   spx_word16_t exc_energy=0, new_exc_energy=0;
+   spx_word16_t gain;
+   spx_word16_t step;
+   spx_word16_t fact;
 
-   /*Some gain adjustment is pitch is too high or if unvoiced*/
+   /*Compute excitation amplitude prior to enhancement*/
+   exc_energy = compute_rms(exc, nsf);
+   /*for (i=0;i<nsf;i++)
+     exc_energy+=((float)exc[i])*exc[i];*/
+
+   /*Some gain adjustment if pitch is too high or if unvoiced*/
+#ifdef FIXED_POINT
    {
+      spx_word16_t g = gain_3tap_to_1tap(pitch_gain)+gain_3tap_to_1tap(mem->last_pitch_gain);
+      if (g > 166)
+         comb_gain = MULT16_16_Q15(DIV32_16(SHL32(EXTEND32(165),15),g), comb_gain);
+      if (g < 64)
+         comb_gain = MULT16_16_Q15(SHL16(g, 9), comb_gain);
+   }
+#else
+   {
       float g=0;
-      g = .5*fabs(pitch_gain[0]+pitch_gain[1]+pitch_gain[2] +
-      mem->last_pitch_gain[0] + mem->last_pitch_gain[1] + mem->last_pitch_gain[2]);
+      g = GAIN_SCALING_1*.5*(gain_3tap_to_1tap(pitch_gain)+gain_3tap_to_1tap(mem->last_pitch_gain));
       if (g>1.3)
          comb_gain*=1.3/g;
       if (g<.5)
-         comb_gain*=2*g;
+         comb_gain*=2.*g;
    }
-   step = 1.0/nsf;
+#endif
+   step = DIV32(COMB_STEP, nsf);
    fact=0;
+
    /*Apply pitch comb-filter (filter out noise between pitch harmonics)*/
    for (i=0;i<nsf;i++)
    {
-      fact += step;
+      spx_word32_t exc1, exc2;
 
-      new_exc[i] = exc[i] + comb_gain * fact * (
-                                         pitch_gain[0]*exc[i-pitch+1] +
-                                         pitch_gain[1]*exc[i-pitch] +
-                                         pitch_gain[2]*exc[i-pitch-1]
-                                         )
-      + comb_gain * (1-fact) * (
-                                         mem->last_pitch_gain[0]*exc[i-mem->last_pitch+1] +
-                                         mem->last_pitch_gain[1]*exc[i-mem->last_pitch] +
-                                         mem->last_pitch_gain[2]*exc[i-mem->last_pitch-1]
-                                         );
+      fact = ADD16(fact,step);
+      
+      exc1 = SHL32(MULT16_32_Q15(SHL16(pitch_gain[0],7),exc[i-pitch+1]) +
+                 MULT16_32_Q15(SHL16(pitch_gain[1],7),exc[i-pitch]) +
+                 MULT16_32_Q15(SHL16(pitch_gain[2],7),exc[i-pitch-1]) , 2);
+      exc2 = SHL32(MULT16_32_Q15(SHL16(mem->last_pitch_gain[0],7),exc[i-mem->last_pitch+1]) +
+                 MULT16_32_Q15(SHL16(mem->last_pitch_gain[1],7),exc[i-mem->last_pitch]) +
+                 MULT16_32_Q15(SHL16(mem->last_pitch_gain[2],7),exc[i-mem->last_pitch-1]),2);
+
+      new_exc[i] = exc[i] + MULT16_32_Q15(comb_gain, ADD32(MULT16_32_Q15(fact,exc1), MULT16_32_Q15(SUB16(COMB_STEP,fact), exc2)));
    }
 
    mem->last_pitch_gain[0] = pitch_gain[0];
@@ -273,20 +575,33 @@
    mem->last_pitch_gain[2] = pitch_gain[2];
    mem->last_pitch = pitch;
 
-   /*Gain after enhancement*/
-   for (i=0;i<nsf;i++)
-      new_exc_energy+=new_exc[i]*new_exc[i];
+   /*Amplitude after enhancement*/
+   new_exc_energy = compute_rms(new_exc, nsf);
 
-   /*Compute scaling factor and normalize energy*/
-   gain = sqrt(exc_energy)/sqrt(.1+new_exc_energy);
+   if (exc_energy > new_exc_energy)
+      exc_energy = new_exc_energy;
+   
+   gain = DIV32_16(SHL32(EXTEND32(exc_energy),15),ADD16(1,new_exc_energy));
+
+#ifdef FIXED_POINT
+   if (gain < 16384)
+      gain = 16384;
+#else
    if (gain < .5)
       gain=.5;
-   if (gain>1)
-      gain=1;
+#endif
 
+#ifdef FIXED_POINT
    for (i=0;i<nsf;i++)
    {
+      mem->smooth_gain = ADD16(MULT16_16_Q15(31457,mem->smooth_gain), MULT16_16_Q15(1311,gain));
+      new_exc[i] = MULT16_32_Q15(mem->smooth_gain, new_exc[i]);
+   }
+#else
+   for (i=0;i<nsf;i++)
+   {
       mem->smooth_gain = .96*mem->smooth_gain + .04*gain;
       new_exc[i] *= mem->smooth_gain;
    }
+#endif
 }

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/filters.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/filters.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/filters.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -33,45 +33,55 @@
 #ifndef FILTERS_H
 #define FILTERS_H
 
+#include "misc.h"
 
+spx_word16_t compute_rms(const spx_sig_t *x, int len);
+void signal_mul(const spx_sig_t *x, spx_sig_t *y, spx_word32_t scale, int len);
+void signal_div(const spx_sig_t *x, spx_sig_t *y, spx_word32_t scale, int len);
+
+#ifdef FIXED_POINT
+
+int normalize16(const spx_sig_t *x, spx_word16_t *y, spx_sig_t max_scale, int len);
+
+#endif
+
 typedef struct CombFilterMem {
    int   last_pitch;
-   float last_pitch_gain[3];
-   float smooth_gain;
+   spx_word16_t last_pitch_gain[3];
+   spx_word16_t smooth_gain;
 } CombFilterMem;
 
 
-void qmf_decomp(float *xx, float *aa, float *y1, float *y2, int N, int M, float *mem, char *stack);
-void fir_mem_up(float *x, float *a, float *y, int N, int M, float *mem, char *stack);
+void qmf_decomp(const spx_word16_t *xx, const spx_word16_t *aa, spx_sig_t *, spx_sig_t *y2, int N, int M, spx_word16_t *mem, char *stack);
+void fir_mem_up(const spx_sig_t *x, const spx_word16_t *a, spx_sig_t *y, int N, int M, spx_word32_t *mem, char *stack);
 
 
-void filter_mem2(float *x, float *num, float *den, float *y, int N, int ord, float *mem);
-void fir_mem2(float *x, float *num, float *y, int N, int ord, float *mem);
-void iir_mem2(float *x, float *den, float *y, int N, int ord, float *mem);
+void filter_mem2(const spx_sig_t *x, const spx_coef_t *num, const spx_coef_t *den, spx_sig_t *y, int N, int ord, spx_mem_t *mem);
+void fir_mem2(const spx_sig_t *x, const spx_coef_t *num, spx_sig_t *y, int N, int ord, spx_mem_t *mem);
+void iir_mem2(const spx_sig_t *x, const spx_coef_t *den, spx_sig_t *y, int N, int ord, spx_mem_t *mem);
 
 /* Apply bandwidth expansion on LPC coef */
-void bw_lpc(float gamma, float *lpc_in, float *lpc_out, int order);
+void bw_lpc(spx_word16_t , const spx_coef_t *lpc_in, spx_coef_t *lpc_out, int order);
 
 
 
-/* FIR filter */
-void fir_decim_mem(float *x, float *a, float *y, int N, int M, float *mem);
+void syn_percep_zero(const spx_sig_t *x, const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_sig_t *y, int N, int ord, char *stack);
 
-void syn_percep_zero(float *x, float *ak, float *awk1, float *awk2, float *y, int N, int ord, char *stack);
+void residue_percep_zero(const spx_sig_t *xx, const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_sig_t *y, int N, int ord, char *stack);
 
-void residue_percep_zero(float *xx, float *ak, float *awk1, float *awk2, float *y, int N, int ord, char *stack);
+void compute_impulse_response(const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_word16_t *y, int N, int ord, char *stack);
 
-void comp_filter_mem_init (CombFilterMem *mem);
+void comb_filter_mem_init (CombFilterMem *mem);
 
 void comb_filter(
-float *exc,          /*decoded excitation*/
-float *new_exc,      /*enhanced excitation*/
-float *ak,           /*LPC filter coefs*/
+spx_sig_t *exc,          /*decoded excitation*/
+spx_sig_t *new_exc,      /*enhanced excitation*/
+spx_coef_t *ak,           /*LPC filter coefs*/
 int p,               /*LPC order*/
 int nsf,             /*sub-frame size*/
 int pitch,           /*pitch period*/
-float *pitch_gain,   /*pitch gain (3-tap)*/
-float  comb_gain,    /*gain of comb filter*/
+spx_word16_t *pitch_gain,   /*pitch gain (3-tap)*/
+spx_word16_t  comb_gain,    /*gain of comb filter*/
 CombFilterMem *mem
 );
 

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/filters_arm4.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/filters_arm4.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/filters_arm4.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,377 @@
+/* Copyright (C) 2004 Jean-Marc Valin 
+   File: filters_arm4.h
+   ARM4-optimized filtering routines
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+   
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+   
+   - Neither the name of the Xiph.org Foundation nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+   
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#define OVERRIDE_NORMALIZE16
+int normalize16(const spx_sig_t *x, spx_word16_t *y, int max_scale, int len)
+{
+   int i;
+   spx_sig_t max_val=1;
+   int sig_shift;
+   int dead1, dead2, dead3, dead4, dead5, dead6;
+
+   __asm__ __volatile__ (
+         "\tmov %1, #1 \n"
+         "\tmov %3, #0 \n"
+
+         ".normalize16loop1%=: \n"
+
+         "\tldr %4, [%0], #4 \n"
+         "\tcmps %4, %1 \n"
+         "\tmovgt %1, %4 \n"
+         "\tcmps %4, %3 \n"
+         "\tmovlt %3, %4 \n"
+
+         "\tsubs %2, %2, #1 \n"
+         "\tbne .normalize16loop1%=\n"
+
+         "\trsb %3, %3, #0 \n"
+         "\tcmp %1, %3 \n"
+         "\tmovlt %1, %3 \n"
+   : "=r" (dead1), "=r" (max_val), "=r" (dead3), "=r" (dead4),
+   "=r" (dead5), "=r" (dead6)
+   : "0" (x), "2" (len)
+   : "cc");
+
+   sig_shift=0;
+   while (max_val>max_scale)
+   {
+      sig_shift++;
+      max_val >>= 1;
+   }
+   
+   __asm__ __volatile__ (
+         ".normalize16loop%=: \n"
+
+         "\tldr %4, [%0], #4 \n"
+         "\tldr %5, [%0], #4 \n"
+         "\tmov %4, %4, asr %3 \n"
+         "\tstrh %4, [%1], #2 \n"
+         "\tldr %4, [%0], #4 \n"
+         "\tmov %5, %5, asr %3 \n"
+         "\tstrh %5, [%1], #2 \n"
+         "\tldr %5, [%0], #4 \n"
+         "\tmov %4, %4, asr %3 \n"
+         "\tstrh %4, [%1], #2 \n"
+         "\tsubs %2, %2, #1 \n"
+         "\tmov %5, %5, asr %3 \n"
+         "\tstrh %5, [%1], #2 \n"
+
+         "\tbge .normalize16loop%=\n"
+   : "=r" (dead1), "=r" (dead2), "=r" (dead3), "=r" (dead4),
+   "=r" (dead5), "=r" (dead6)
+   : "0" (x), "1" (y), "2" (len>>2), "3" (sig_shift)
+   : "cc", "memory");
+   return sig_shift;
+}
+
+#define OVERRIDE_FILTER_MEM2
+void filter_mem2(const spx_sig_t *x, const spx_coef_t *num, const spx_coef_t *den, spx_sig_t *y, int N, int ord, spx_mem_t *mem)
+{
+   int i,j;
+   spx_sig_t xi,yi,nyi;
+
+   for (i=0;i<N;i++)
+   {
+      int deadm, deadn, deadd, deadidx, x1, y1, dead1, dead2, dead3, dead4, dead5, dead6;
+      xi=SATURATE(x[i],805306368);
+      yi = SATURATE(ADD32(xi, SHL(mem[0],2)),805306368);
+      nyi = -yi;
+      y[i] = yi;
+      __asm__ __volatile__ (
+            "\tldrsh %6, [%1], #2\n"
+            "\tsmull %8, %9, %4, %6\n"
+#ifdef SHORTCUTS
+            "\tldrsh %6, [%2], #2\n"
+            "\tldr %10, [%0, #4]\n"
+            "\tmov %8, %8, lsr #15\n"
+            "\tsmull %7, %11, %5, %6\n"
+            "\tldrsh %6, [%1], #2\n"
+            "\tadd %8, %8, %9, lsl #17\n"
+            "\tadd %10, %10, %8\n"
+            "\tsmull %8, %9, %4, %6\n"
+            "\tadd %10, %10, %7, lsr #15\n"
+            "\tadd %10, %10, %11, lsl #17\n"
+            "\tstr %10, [%0], #4 \n"
+
+            "\tldrsh %6, [%2], #2\n"
+            "\tldr %10, [%0, #4]\n"
+            "\tmov %8, %8, lsr #15\n"
+            "\tsmull %7, %11, %5, %6\n"
+            "\tldrsh %6, [%1], #2\n"
+            "\tadd %8, %8, %9, lsl #17\n"
+            "\tadd %10, %10, %8\n"
+            "\tsmull %8, %9, %4, %6\n"
+            "\tadd %10, %10, %7, lsr #15\n"
+            "\tadd %10, %10, %11, lsl #17\n"
+            "\tstr %10, [%0], #4 \n"
+
+            "\tldrsh %6, [%2], #2\n"
+            "\tldr %10, [%0, #4]\n"
+            "\tmov %8, %8, lsr #15\n"
+            "\tsmull %7, %11, %5, %6\n"
+            "\tldrsh %6, [%1], #2\n"
+            "\tadd %8, %8, %9, lsl #17\n"
+            "\tadd %10, %10, %8\n"
+            "\tsmull %8, %9, %4, %6\n"
+            "\tadd %10, %10, %7, lsr #15\n"
+            "\tadd %10, %10, %11, lsl #17\n"
+            "\tstr %10, [%0], #4 \n"
+
+            "\tldrsh %6, [%2], #2\n"
+            "\tldr %10, [%0, #4]\n"
+            "\tmov %8, %8, lsr #15\n"
+            "\tsmull %7, %11, %5, %6\n"
+            "\tldrsh %6, [%1], #2\n"
+            "\tadd %8, %8, %9, lsl #17\n"
+            "\tadd %10, %10, %8\n"
+            "\tsmull %8, %9, %4, %6\n"
+            "\tadd %10, %10, %7, lsr #15\n"
+            "\tadd %10, %10, %11, lsl #17\n"
+            "\tstr %10, [%0], #4 \n"
+
+            "\tldrsh %6, [%2], #2\n"
+            "\tldr %10, [%0, #4]\n"
+            "\tmov %8, %8, lsr #15\n"
+            "\tsmull %7, %11, %5, %6\n"
+            "\tldrsh %6, [%1], #2\n"
+            "\tadd %8, %8, %9, lsl #17\n"
+            "\tadd %10, %10, %8\n"
+            "\tsmull %8, %9, %4, %6\n"
+            "\tadd %10, %10, %7, lsr #15\n"
+            "\tadd %10, %10, %11, lsl #17\n"
+            "\tstr %10, [%0], #4 \n"
+
+            "\tldrsh %6, [%2], #2\n"
+            "\tldr %10, [%0, #4]\n"
+            "\tmov %8, %8, lsr #15\n"
+            "\tsmull %7, %11, %5, %6\n"
+            "\tldrsh %6, [%1], #2\n"
+            "\tadd %8, %8, %9, lsl #17\n"
+            "\tadd %10, %10, %8\n"
+            "\tsmull %8, %9, %4, %6\n"
+            "\tadd %10, %10, %7, lsr #15\n"
+            "\tadd %10, %10, %11, lsl #17\n"
+            "\tstr %10, [%0], #4 \n"
+
+            "\tldrsh %6, [%2], #2\n"
+            "\tldr %10, [%0, #4]\n"
+            "\tmov %8, %8, lsr #15\n"
+            "\tsmull %7, %11, %5, %6\n"
+            "\tldrsh %6, [%1], #2\n"
+            "\tadd %8, %8, %9, lsl #17\n"
+            "\tadd %10, %10, %8\n"
+            "\tsmull %8, %9, %4, %6\n"
+            "\tadd %10, %10, %7, lsr #15\n"
+            "\tadd %10, %10, %11, lsl #17\n"
+            "\tstr %10, [%0], #4 \n"
+
+            "\tldrsh %6, [%2], #2\n"
+            "\tldr %10, [%0, #4]\n"
+            "\tmov %8, %8, lsr #15\n"
+            "\tsmull %7, %11, %5, %6\n"
+            "\tldrsh %6, [%1], #2\n"
+            "\tadd %8, %8, %9, lsl #17\n"
+            "\tadd %10, %10, %8\n"
+            "\tsmull %8, %9, %4, %6\n"
+            "\tadd %10, %10, %7, lsr #15\n"
+            "\tadd %10, %10, %11, lsl #17\n"
+            "\tstr %10, [%0], #4 \n"
+
+            "\tldrsh %6, [%2], #2\n"
+            "\tldr %10, [%0, #4]\n"
+            "\tmov %8, %8, lsr #15\n"
+            "\tsmull %7, %11, %5, %6\n"
+            "\tldrsh %6, [%1], #2\n"
+            "\tadd %8, %8, %9, lsl #17\n"
+            "\tadd %10, %10, %8\n"
+            "\tsmull %8, %9, %4, %6\n"
+            "\tadd %10, %10, %7, lsr #15\n"
+            "\tadd %10, %10, %11, lsl #17\n"
+            "\tstr %10, [%0], #4 \n"
+
+
+#else
+            ".filterloop%=: \n"
+            "\tldrsh %6, [%2], #2\n"
+            "\tldr %10, [%0, #4]\n"
+            "\tmov %8, %8, lsr #15\n"
+            "\tsmull %7, %11, %5, %6\n"
+            "\tadd %8, %8, %9, lsl #17\n"
+            "\tldrsh %6, [%1], #2\n"
+            "\tadd %10, %10, %8\n"
+            "\tsmull %8, %9, %4, %6\n"
+            "\tadd %10, %10, %7, lsr #15\n"
+            "\tsubs %3, %3, #1\n"
+            "\tadd %10, %10, %11, lsl #17\n"
+            "\tstr %10, [%0], #4 \n"
+            "\t bne .filterloop%=\n"
+#endif
+            "\tmov %8, %8, lsr #15\n"
+            "\tadd %10, %8, %9, lsl #17\n"
+            "\tldrsh %6, [%2], #2\n"
+            "\tsmull %8, %9, %5, %6\n"
+            "\tadd %10, %10, %8, lsr #15\n"
+            "\tadd %10, %10, %9, lsl #17\n"
+            "\tstr %10, [%0], #4 \n"
+
+         : "=r" (deadm), "=r" (deadn), "=r" (deadd), "=r" (deadidx),
+      "=r" (xi), "=r" (nyi), "=r" (dead1), "=r" (dead2),
+      "=r" (dead3), "=r" (dead4), "=r" (dead5), "=r" (dead6)
+         : "0" (mem), "1" (num), "2" (den), "3" (ord-1), "4" (xi), "5" (nyi)
+         : "cc", "memory");
+   
+   }
+}
+
+#define OVERRIDE_IIR_MEM2
+void iir_mem2(const spx_sig_t *x, const spx_coef_t *den, spx_sig_t *y, int N, int ord, spx_mem_t *mem)
+{
+   int i,j;
+   spx_sig_t xi,yi,nyi;
+
+   for (i=0;i<N;i++)
+   {
+      int deadm, deadd, deadidx, dead1, dead2, dead3, dead4, dead5, dead6;
+      xi=SATURATE(x[i],805306368);
+      yi = SATURATE(ADD32(xi, SHL(mem[0],2)),805306368);
+      nyi = -yi;
+      y[i] = yi;
+      __asm__ __volatile__ (
+            "\tldrsh %4, [%1], #2\n"
+            "\tsmull %5, %6, %3, %4\n"
+
+#ifdef SHORTCUTS
+                        
+            "\tldrsh %4, [%1], #2\n"
+            "\tmov %5, %5, lsr #15\n"
+            "\tldr %7, [%0, #4]\n"
+            "\tadd %8, %5, %6, lsl #17\n"
+            "\tsmull %5, %6, %3, %4\n"
+            "\tadd %7, %7, %8\n"
+            "\tstr %7, [%0], #4 \n"
+
+                 
+            "\tldrsh %4, [%1], #2\n"
+            "\tmov %5, %5, lsr #15\n"
+            "\tldr %9, [%0, #4]\n"
+            "\tadd %8, %5, %6, lsl #17\n"
+            "\tsmull %5, %6, %3, %4\n"
+            "\tadd %9, %9, %8\n"
+            "\tstr %9, [%0], #4 \n"
+
+            "\tldrsh %4, [%1], #2\n"
+            "\tmov %5, %5, lsr #15\n"
+            "\tldr %7, [%0, #4]\n"
+            "\tadd %8, %5, %6, lsl #17\n"
+            "\tsmull %5, %6, %3, %4\n"
+            "\tadd %7, %7, %8\n"
+            "\tstr %7, [%0], #4 \n"
+
+            
+            "\tldrsh %4, [%1], #2\n"
+            "\tmov %5, %5, lsr #15\n"
+            "\tldr %9, [%0, #4]\n"
+            "\tadd %8, %5, %6, lsl #17\n"
+            "\tsmull %5, %6, %3, %4\n"
+            "\tadd %9, %9, %8\n"
+            "\tstr %9, [%0], #4 \n"
+
+            "\tldrsh %4, [%1], #2\n"
+            "\tmov %5, %5, lsr #15\n"
+            "\tldr %7, [%0, #4]\n"
+            "\tadd %8, %5, %6, lsl #17\n"
+            "\tsmull %5, %6, %3, %4\n"
+            "\tadd %7, %7, %8\n"
+            "\tstr %7, [%0], #4 \n"
+
+            
+            "\tldrsh %4, [%1], #2\n"
+            "\tmov %5, %5, lsr #15\n"
+            "\tldr %9, [%0, #4]\n"
+            "\tadd %8, %5, %6, lsl #17\n"
+            "\tsmull %5, %6, %3, %4\n"
+            "\tadd %9, %9, %8\n"
+            "\tstr %9, [%0], #4 \n"
+
+            "\tldrsh %4, [%1], #2\n"
+            "\tmov %5, %5, lsr #15\n"
+            "\tldr %7, [%0, #4]\n"
+            "\tadd %8, %5, %6, lsl #17\n"
+            "\tsmull %5, %6, %3, %4\n"
+            "\tadd %7, %7, %8\n"
+            "\tstr %7, [%0], #4 \n"
+
+            
+            "\tldrsh %4, [%1], #2\n"
+            "\tmov %5, %5, lsr #15\n"
+            "\tldr %9, [%0, #4]\n"
+            "\tadd %8, %5, %6, lsl #17\n"
+            "\tsmull %5, %6, %3, %4\n"
+            "\tadd %9, %9, %8\n"
+            "\tstr %9, [%0], #4 \n"
+
+            "\tldrsh %4, [%1], #2\n"
+            "\tmov %5, %5, lsr #15\n"
+            "\tldr %7, [%0, #4]\n"
+            "\tadd %8, %5, %6, lsl #17\n"
+            "\tsmull %5, %6, %3, %4\n"
+            "\tadd %7, %7, %8\n"
+            "\tstr %7, [%0], #4 \n"
+
+            
+            
+#else
+            ".iirloop%=: \n"
+            "\tldr %7, [%0, #4]\n"
+
+            "\tldrsh %4, [%1], #2\n"
+            "\tmov %5, %5, lsr #15\n"
+            "\tadd %8, %5, %6, lsl #17\n"
+            "\tsmull %5, %6, %3, %4\n"
+            "\tadd %7, %7, %8\n"
+            "\tstr %7, [%0], #4 \n"
+            "\tsubs %2, %2, #1\n"
+            "\t bne .iirloop%=\n"
+            
+#endif
+            "\tmov %5, %5, lsr #15\n"
+            "\tadd %7, %5, %6, lsl #17\n"
+            "\tstr %7, [%0], #4 \n"
+
+         : "=r" (deadm), "=r" (deadd), "=r" (deadidx), "=r" (nyi),
+      "=r" (dead1), "=r" (dead2), "=r" (dead3), "=r" (dead4),
+      "=r" (dead5), "=r" (dead6)
+         : "0" (mem), "1" (den), "2" (ord-1), "3" (nyi)
+         : "cc", "memory");
+   
+   }
+}

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/filters_bfin.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/filters_bfin.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/filters_bfin.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,509 @@
+/* Copyright (C) 2005 Analog Devices
+   Author: Jean-Marc Valin 
+   File: filters_bfin.h
+   Various analysis/synthesis filters (Blackfin version)
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+   
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+   
+   - Neither the name of the Xiph.org Foundation nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+   
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <stdio.h>
+
+#define OVERRIDE_NORMALIZE16
+int normalize16(const spx_sig_t *x, spx_word16_t *y, spx_sig_t max_scale, int len)
+{
+   spx_sig_t max_val=1;
+   int sig_shift;
+
+   __asm__ 
+   (
+   "%0 = 0;\n\t"
+   "I0 = %1;\n\t"
+   "L0 = 0;\n\t"
+   "R1 = [I0++];\n\t"
+   "LOOP norm_max%= LC0 = %2;\n\t"
+   "LOOP_BEGIN norm_max%=;\n\t"
+      "R2 = ABS R1 || R1 = [I0++];\n\t"
+      "%0 = MAX(%0, R2);\n\t"
+   "LOOP_END norm_max%=;\n\t"
+   : "=&d" (max_val)
+   : "a" (x), "a" (len)
+   : "R1", "R2"
+   );
+
+   sig_shift=0;
+   while (max_val>max_scale)
+   {
+      sig_shift++;
+      max_val >>= 1;
+   }
+
+   __asm__ __volatile__ 
+   (
+   "I0 = %0;\n\t"
+   "L0 = 0;\n\t"
+   "I1 = %1;\n\t"
+   "L1 = 0;\n\t"
+   "R0 = [I0++];\n\t"
+   "LOOP norm_shift%= LC0 = %3 >> 1;\n\t"
+   "LOOP_BEGIN norm_shift%=;\n\t"
+      "R1 = ASHIFT R0 by %2.L || R2 = [I0++];\n\t"
+      "R3 = ASHIFT R2 by %2.L || R0 = [I0++];\n\t"
+      "R3 = PACK(R3.L, R1.L);\n\t"
+      "[I1++] = R3;\n\t"
+   "LOOP_END norm_shift%=;\n\t"
+   : : "a" (x), "a" (y), "d" (-sig_shift), "a" (len)
+   : "I0", "L0", "I1", "L1", "R0", "R1", "R2", "R3", "memory"
+   );
+   return sig_shift;
+}
+
+#define OVERRIDE_FILTER_MEM2
+void filter_mem2(const spx_sig_t *_x, const spx_coef_t *num, const spx_coef_t *den, spx_sig_t *_y, int N, int ord, spx_mem_t *mem)
+{
+   spx_word32_t xy2[N+1];
+   spx_word32_t *xy = xy2+1;
+   spx_word32_t numden_a[2*ord+2];
+   spx_word16_t *numden = (spx_word16_t*) numden_a;
+   int i;
+   for (i=0;i<ord;i++)
+   {
+      numden[2*i] = num[i];
+      numden[2*i+1] = den[i];
+   }
+   __asm__ __volatile__
+   (
+   /* Register setup */
+   "R0 = %5;\n\t"      /*ord */
+   
+   "P0 = %3;\n\t"
+   "I0 = P0;\n\t"
+   "B0 = P0;\n\t"
+   "L0 = 0;\n\t"
+      
+   "P2 = %0;\n\t"
+   "I2 = P2;\n\t"
+   "L2 = 0;\n\t"
+   
+   "P4 = %6;\n\t"
+   "P0 = %1;\n\t"
+   "P1 = %2;\n\t"
+   
+   /* First sample */
+   "R1 = [P4++];\n\t"
+   "R1 <<= 1;\n\t"
+   "R2 = [P0++];\n\t"
+   "R1 = R1 + R2;\n\t"
+   "[P1++] = R1;\n\t"
+   "R1 <<= 2;\n\t"
+   "R2 <<= 2;\n\t"
+   "R2 = PACK(R1.H, R2.H);\n\t"
+   "[P2] = R2;\n\t"
+               
+   /* Samples 1 to ord-1 (using memory) */
+   "R0 += -1;\n\t"
+   "R3 = 0;\n\t"
+   "LC0 = R0;\n\t"
+   "LOOP filter_start%= LC0;\n\t"
+   "LOOP_BEGIN filter_start%=;\n\t"
+      "R3 += 1;\n\t"
+      "LC1 = R3;\n\t"
+      
+      "R1 = [P4++];\n\t"
+      "A1 = R1;\n\t"
+      "A0 = 0;\n\t"
+      "I0 = B0;\n\t"
+      "I2 = P2;\n\t"
+      "P2 += 4;\n\t"
+      "R4 = [I0++] || R5 = [I2--];\n\t"
+      "LOOP filter_start_inner%= LC1;\n\t"
+      "LOOP_BEGIN filter_start_inner%=;\n\t"
+         "A0 += R4.L*R5.L (IS), A1 -= R4.H*R5.H (IS) || R4 = [I0++] || R5 = [I2--];\n\t"
+      "LOOP_END filter_start_inner%=;\n\t"
+      "A0 += A1;\n\t"
+      "R4 = A0;\n\t"
+      "R4 <<= 1;\n\t"
+      "R2 = [P0++];\n\t"
+      "R4 = R4 + R2;\n\t"
+      "[P1++] = R4;\n\t"
+      "R4 <<= 2;\n\t"
+      "R2 <<= 2;\n\t"
+      "R2 = PACK(R4.H, R2.H);\n\t"
+      "[P2] = R2;\n\t"
+
+   "LOOP_END filter_start%=;\n\t"
+
+   /* Samples ord to N*/   
+   "R0 = %5;\n\t"
+   "R0 <<= 1;\n\t"
+   "I0 = B0;\n\t"
+   "R0 <<= 1;\n\t"   
+   "L0 = R0;\n\t"
+   
+   "R0 = %5;\n\t"
+   "R2 = %4;\n\t"
+   "R2 = R2 - R0;\n\t"
+   "R4 = [I0++];\n\t"
+   "LC0 = R2;\n\t"
+   "P3 = R0;\n\t"
+   "R0 <<= 2;\n\t"
+   "R0 += 8;\n\t"
+   "I2 = P2;\n\t"
+   "M0 = R0;\n\t"
+   "A0 = A1 = 0;\n\t"
+   "R5 = [I2--];\n\t"
+   "LOOP filter_mid%= LC0;\n\t"
+   "LOOP_BEGIN filter_mid%=;\n\t"
+      "LOOP filter_mid_inner%= LC1=P3;\n\t"
+      "LOOP_BEGIN filter_mid_inner%=;\n\t"
+         "A0 += R4.L*R5.L (IS), A1 -= R4.H*R5.H (IS) || R4 = [I0++] || R5 = [I2--];\n\t"
+      "LOOP_END filter_mid_inner%=;\n\t"
+      "R0 = (A0 += A1) || I2 += M0;\n\t"
+      "R0 = R0 << 1 || R5 = [P0++];\n\t"
+      "R0 = R0 + R5;\n\t"
+      "R0 = R0 << 2 || [P1++] = R0;\n\t"
+      "R5 = R5 << 2;\n\t"
+      "R5 = PACK(R0.H, R5.H);\n\t"
+      "A0 = A1 = 0 || [I2--] = R5\n\t"
+      "LOOP_END filter_mid%=;\n\t"
+   "I2 += 4;\n\t"
+   "P2 = I2;\n\t"
+   /* Update memory */
+   "P4 = %6;\n\t"
+   "R0 = %5;\n\t"
+   "LC0 = R0;\n\t"
+   "P0 = B0;\n\t"
+   "A0 = A1 = 0;\n\t"
+   "LOOP mem_update%= LC0;\n\t"
+   "LOOP_BEGIN mem_update%=;\n\t"
+      "I2 = P2;\n\t"
+      "I0 = P0;\n\t"
+      "P0 += 4;\n\t"
+      "R0 = LC0;\n\t"
+      "LC1 = R0;\n\t"
+      "R5 = [I2--] || R4 = [I0++];\n\t"
+      "LOOP mem_accum%= LC1;\n\t"
+      "LOOP_BEGIN mem_accum%=;\n\t"
+         "A0 += R4.L*R5.L (IS), A1 -= R4.H*R5.H (IS) || R4 = [I0++] || R5 = [I2--];\n\t"
+      "LOOP_END mem_accum%=;\n\t"
+      "R0 = (A0 += A1);\n\t"
+      "A0 = A1 = 0 || [P4++] = R0;\n\t"
+   "LOOP_END mem_update%=;\n\t"
+   "L0 = 0;\n\t"
+   : : "m" (xy), "m" (_x), "m" (_y), "m" (numden), "m" (N), "m" (ord), "m" (mem)
+   : "A0", "A1", "R0", "R1", "R2", "R3", "R4", "R5", "P0", "P1", "P2", "P3", "P4", "B0", "I0", "I2", "L0", "L2", "M0", "memory"
+   );
+
+}
+
+
+
+
+#define OVERRIDE_IIR_MEM2
+void iir_mem2(const spx_sig_t *_x, const spx_coef_t *den, spx_sig_t *_y, int N, int ord, spx_mem_t *mem)
+{
+   spx_word16_t y[N+2];
+   spx_word16_t *yy;
+   yy = y+2;
+   __asm__ __volatile__
+   (
+   /* Register setup */
+   "R0 = %5;\n\t"      /*ord */
+   
+   "P1 = %3;\n\t"
+   "I1 = P1;\n\t"
+   "B1 = P1;\n\t"
+   "L1 = 0;\n\t"
+   
+   "P3 = %0;\n\t"
+   "I3 = P3;\n\t"
+   "L3 = 0;\n\t"
+   
+   "P4 = %6;\n\t"
+   "P0 = %1;\n\t"
+   "P1 = %2;\n\t"
+   
+   /* First sample */
+   "R1 = [P4++];\n\t"
+   "R1 <<= 1;\n\t"
+   "R2 = [P0++];\n\t"
+   "R1 = R1 + R2;\n\t"
+   "[P1++] = R1;\n\t"
+   "R1 <<= 2;\n\t"
+   "W[P3] = R1.H;\n\t"
+   "R2 <<= 2;\n\t"
+
+   /* Samples 1 to ord-1 (using memory) */
+   "R0 += -1;\n\t"
+   "R3 = 0;\n\t"
+   "LC0 = R0;\n\t"
+   "LOOP filter_start%= LC0;\n\t"
+   "LOOP_BEGIN filter_start%=;\n\t"
+      "R3 += 1;\n\t"
+      "LC1 = R3;\n\t"
+      
+      "R1 = [P4++];\n\t"
+      "A1 = R1;\n\t"
+      "I1 = B1;\n\t"
+      "I3 = P3;\n\t"
+      "P3 += 2;\n\t"
+      "LOOP filter_start_inner%= LC1;\n\t"
+      "LOOP_BEGIN filter_start_inner%=;\n\t"
+         "R4.L = W[I1++];\n\t"
+         "R5.L = W[I3--];\n\t"
+         "A1 -= R4.L*R5.L (IS);\n\t"
+      "LOOP_END filter_start_inner%=;\n\t"
+   
+      "R1 = A1;\n\t"
+      "R1 <<= 1;\n\t"
+      "R2 = [P0++];\n\t"
+      "R1 = R1 + R2;\n\t"
+      "[P1++] = R1;\n\t"
+      "R1 <<= 2;\n\t"
+      "W[P3] = R1.H;\n\t"
+      "R2 <<= 2;\n\t"
+   "LOOP_END filter_start%=;\n\t"
+
+   /* Samples ord to N*/   
+   "R0 = %5;\n\t"
+   "R0 <<= 1;\n\t"
+   "I1 = B1;\n\t"
+   "L1 = R0;\n\t"
+   
+   "R0 = %5;\n\t"
+   "R2 = %4;\n\t"
+   "R2 = R2 - R0;\n\t"
+   "R4.L = W[I1++];\n\t"
+   "LC0 = R2;\n\t"
+   "LOOP filter_mid%= LC0;\n\t"
+   "LOOP_BEGIN filter_mid%=;\n\t"
+      "LC1 = R0;\n\t"
+      "A1 = 0;\n\t"
+      "I3 = P3;\n\t"
+      "P3 += 2;\n\t"
+      "R5.L = W[I3--];\n\t"
+      "LOOP filter_mid_inner%= LC1;\n\t"
+      "LOOP_BEGIN filter_mid_inner%=;\n\t"
+         "A1 -= R4.L*R5.L (IS) || R4.L = W[I1++] || R5.L = W[I3--];\n\t"
+      "LOOP_END filter_mid_inner%=;\n\t"
+      "R1 = A1;\n\t"
+      "R1 = R1 << 1 || R2 = [P0++];\n\t"
+      "R1 = R1 + R2;\n\t"
+      "R1 = R1 << 2 || [P1++] = R1;\n\t"
+      "W[P3] = R1.H;\n\t"
+   "LOOP_END filter_mid%=;\n\t"
+     
+   /* Update memory */
+   "P4 = %6;\n\t"
+   "R0 = %5;\n\t"
+   "LC0 = R0;\n\t"
+   "P1 = B1;\n\t"
+   "LOOP mem_update%= LC0;\n\t"
+   "LOOP_BEGIN mem_update%=;\n\t"
+      "A0 = 0;\n\t"
+      "I3 = P3;\n\t"
+      "I1 = P1;\n\t"
+      "P1 += 2;\n\t"
+      "R0 = LC0;\n\t"
+      "LC1=R0;\n\t"
+      "R5.L = W[I3--] || R4.L = W[I1++];\n\t"
+      "LOOP mem_accum%= LC1;\n\t"
+      "LOOP_BEGIN mem_accum%=;\n\t"
+         "A0 -= R4.L*R5.L (IS) || R4.L = W[I1++] || R5.L = W[I3--];\n\t"
+      "LOOP_END mem_accum%=;\n\t"
+      "R0 = A0;\n\t"
+      "[P4++] = R0;\n\t"
+   "LOOP_END mem_update%=;\n\t"
+   "L1 = 0;\n\t"
+   : : "m" (yy), "m" (_x), "m" (_y), "m" (den), "m" (N), "m" (ord), "m" (mem)
+   : "A0", "A1", "R0", "R1", "R2", "R3", "R4", "R5", "P0", "P1", "P2", "P3", "P4", "B1", "I1", "I3", "L1", "L3", "memory"
+   );
+
+}
+
+#define OVERRIDE_FIR_MEM2
+void fir_mem2(const spx_sig_t *x, const spx_coef_t *num, spx_sig_t *y, int N, int ord, spx_mem_t *mem)
+{
+   int i;
+   spx_coef_t den2[12];
+   spx_coef_t *den;
+   den = (spx_coef_t*)((((int)den2)+4)&0xfffffffc);
+   for (i=0;i<10;i++)
+      den[i] = 0;
+   filter_mem2(x, num, den, y, N, ord, mem);
+}
+
+
+#define OVERRIDE_COMPUTE_IMPULSE_RESPONSE
+void compute_impulse_response(const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_word16_t *y, int N, int ord, char *stack)
+{
+   int i;
+   VARDECL(spx_word16_t *ytmp);
+   ALLOC(ytmp, N, spx_word16_t);
+   spx_word16_t *ytmp2 = ytmp;
+   y[0] = LPC_SCALING;
+   for (i=0;i<ord;i++)
+      y[i+1] = awk1[i];
+   i++;
+   for (;i<N;i++)
+      y[i] = 0;
+
+   N-=1;
+   __asm__ __volatile__
+   (
+         "I0 = %0;\n\t"
+         "I1 = %1;\n\t"
+         "L0 = 0;\n\t"
+         "L1 = 0;\n\t"
+         "L2 = 0;\n\t"
+         "L3 = 0;\n\t"
+         "R0 = 1;\n\t"
+         "R0 <<= 13;\n\t"
+         "W[I0] = R0.L;\n\t"
+         "R0 <<= 1;\n\t"
+         "W[I1] = R0.L;\n\t"
+         "R0 = %5;\n\t"
+         "LC0 = R0;\n\t"
+         "R2 = 0;\n\t"
+         "LOOP samples%= LC0;\n\t"
+         "LOOP_BEGIN samples%=;\n\t"
+            "R2 += 1;\n\t"
+            "R2 = MIN(R2, %4);\n\t"
+            "I0 = %0;\n\t"
+            "I1 = %1;\n\t"
+            "I2 = %2;\n\t"
+            "I3 = %3;\n\t"
+            "%0 += 2;\n\t"
+            "%1 += 2;\n\t"
+            "A0 = A1 = 0;\n\t"
+            "R0.L = W[I0--] || R1.L = W[I2++];\n\t"
+            "LC1 = R2;\n\t"
+            "LOOP filter%= LC1;\n\t"
+            "LOOP_BEGIN filter%=;\n\t"
+               "A0 -= R0.L*R1.L (IS) || R0.L = W[I1--] || R1.L = W[I3++];\n\t"
+               "A1 -= R0.L*R1.L (IS) || R0.L = W[I0--] || R1.L = W[I2++];\n\t"
+            "LOOP_END filter%=;\n\t"
+            "R0 = A0, R1 = A1;\n\t"
+            "R3 = W[%1] (X);\n\t"
+            "R3 <<= 13;\n\t"
+            "R0 = R0 + R3;\n\t"
+            "R3 = R0 >>> 13;\n\t"
+            "W[%0] = R3.L;\n\t"
+            "R0 <<= 1;\n\t"
+            "R1 = R1 + R0;\n\t"
+            "R1 >>>= 13;\n\t"
+            "W[%1] = R1.L;\n\t"
+         "LOOP_END samples%=;\n\t"
+   : "=a" (ytmp2), "=a" (y)
+   : "a" (awk2), "a" (ak), "d" (ord), "m" (N), "0" (ytmp2), "1" (y)
+   : "A0", "A1", "R0", "R1", "R2", "R3", "I0", "I1", "I2", "I3", "L0", "L1", "L2", "L3", "A0", "A1"
+   );
+}
+
+
+
+#if 0 /* Equivalent C function for filter_mem2 and compute_impulse_response */
+#define min(a,b) ((a)<(b) ? (a):(b))
+
+void compute_impulse_response(const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_word16_t *y, int N, int ord, char *stack)
+{
+   int i,j;
+   VARDECL(spx_word16_t *ytmp);
+   ALLOC(ytmp, N, spx_word16_t);
+   
+   y[0] = LPC_SCALING;
+   for (i=0;i<ord;i++)
+      y[i+1] = awk1[i];
+   i++;
+   for (;i<N;i++)
+      y[i] = 0;
+
+   for (i=0;i<N;i++)
+   {
+      spx_word32_t yi = SHL32(EXTEND32(y[i]),LPC_SHIFT);
+      spx_word32_t yi2 = 0;
+      for (j=0;j<min(i,ord);j++)
+      {
+         yi = MAC16_16(yi, awk2[j], -ytmp[i-j-1]);
+         yi2 = MAC16_16(yi2, ak[j], -y[i-j-1]);
+      }
+      ytmp[i] = EXTRACT16(SHR32(yi,LPC_SHIFT));
+      yi2 = ADD32(yi2,SHL32(yi,1));
+      y[i] = EXTRACT16(SHR32(yi2,LPC_SHIFT));
+   }
+
+}
+
+
+void filter_mem2(const spx_sig_t *_x, const spx_coef_t *num, const spx_coef_t *den, spx_sig_t *_y, int N, int ord, spx_mem_t *mem)
+{
+   int i,j;
+   spx_word16_t xi,yi,nyi;
+   spx_word16_t x[N],y[N];
+   spx_word16_t *xx, *yy;
+   xx = x;
+   yy = y;
+   for (i=0;i<N;i++)
+   {
+      x[i] = EXTRACT16(SHR32(_x[i],SIG_SHIFT));
+   }
+   
+   for (i=0;i<ord;i++)
+   {
+      spx_word32_t yi = mem[i];
+      for (j=0;j<i;j++)
+      {
+         yi = MAC16_16(yi, num[j], x[i-j-1]);
+         yi = MAC16_16(yi, den[j], -y[i-j-1]);
+      }
+      _y[i] = ADD32(_x[i],SHL32(yi,1));
+      y[i] = EXTRACT16(SHR32(_y[i],SIG_SHIFT));
+   }
+   for (i=ord;i<N;i++)
+   {
+      spx_word32_t yi = 0;
+      for (j=0;j<ord;j++)
+      {
+         yi = MAC16_16(yi, num[j], x[i-j-1]);
+         yi = MAC16_16(yi, den[j], -y[i-j-1]);
+      }
+      _y[i] = ADD32(_x[i],SHL32(yi,1));
+      y[i] = EXTRACT16(SHR32(_y[i],SIG_SHIFT));
+   }
+
+   for (i=0;i<ord;i++)
+   {
+      spx_mem_t m = 0;
+      for (j=0;j<ord-i;j++)
+      {
+         m = MAC16_16(m, x[N-1-j], num[j+i]);
+         m = MAC16_16(m, -y[N-1-j], den[j+i]);
+      }
+      mem[i] = m;
+   }
+}
+#endif

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/filters_sse.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/filters_sse.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/filters_sse.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -30,260 +30,305 @@
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-void filter_mem2(float *x, float *_num, float *_den, float *y, int N, int ord, float *_mem)
+#include <xmmintrin.h>
+
+void filter_mem2_10(const float *x, const float *_num, const float *_den, float *y, int N, int ord, float *_mem)
 {
-   float __num[20], __den[20], __mem[20];
-   float *num, *den, *mem;
+   __m128 num[3], den[3], mem[3];
+
    int i;
 
-   num = (float*)(((int)(__num+4))&0xfffffff0)-1;
-   den = (float*)(((int)(__den+4))&0xfffffff0)-1;
-   mem = (float*)(((int)(__mem+4))&0xfffffff0)-1;
-   for (i=0;i<=10;i++)
-      num[i]=den[i]=0;
-   for (i=0;i<10;i++)
-      mem[i]=0;
+   /* Copy numerator, denominator and memory to aligned xmm */
+   for (i=0;i<2;i++)
+   {
+      mem[i] = _mm_loadu_ps(_mem+4*i);
+      num[i] = _mm_loadu_ps(_num+4*i);
+      den[i] = _mm_loadu_ps(_den+4*i);
+   }
+   mem[2] = _mm_setr_ps(_mem[8], _mem[9], 0, 0);
+   num[2] = _mm_setr_ps(_num[9], _num[10], 0, 0);
+   den[2] = _mm_setr_ps(_den[9], _den[10], 0, 0);
+   
+   for (i=0;i<N;i++)
+   {
+      __m128 xx;
+      __m128 yy;
+      /* Compute next filter result */
+      xx = _mm_load_ps1(x+i);
+      yy = _mm_add_ss(xx, mem[0]);
+      _mm_store_ss(y+i, yy);
+      yy = _mm_shuffle_ps(yy, yy, 0);
+      
+      /* Update memory */
+      mem[0] = _mm_move_ss(mem[0], mem[1]);
+      mem[0] = _mm_shuffle_ps(mem[0], mem[0], 0x39);
 
-   for (i=0;i<ord+1;i++)
+      mem[0] = _mm_add_ps(mem[0], _mm_mul_ps(xx, num[0]));
+      mem[0] = _mm_sub_ps(mem[0], _mm_mul_ps(yy, den[0]));
+
+      mem[1] = _mm_move_ss(mem[1], mem[2]);
+      mem[1] = _mm_shuffle_ps(mem[1], mem[1], 0x39);
+
+      mem[1] = _mm_add_ps(mem[1], _mm_mul_ps(xx, num[1]));
+      mem[1] = _mm_sub_ps(mem[1], _mm_mul_ps(yy, den[1]));
+
+      mem[2] = _mm_shuffle_ps(mem[2], mem[2], 0xfd);
+
+      mem[2] = _mm_add_ps(mem[2], _mm_mul_ps(xx, num[2]));
+      mem[2] = _mm_sub_ps(mem[2], _mm_mul_ps(yy, den[2]));
+   }
+   /* Put memory back in its place */
+   _mm_storeu_ps(_mem, mem[0]);
+   _mm_storeu_ps(_mem+4, mem[1]);
+   _mm_store_ss(_mem+8, mem[2]);
+   mem[2] = _mm_shuffle_ps(mem[2], mem[2], 0x55);
+   _mm_store_ss(_mem+9, mem[2]);
+}
+
+void filter_mem2_8(const float *x, const float *_num, const float *_den, float *y, int N, int ord, float *_mem)
+{
+   __m128 num[2], den[2], mem[2];
+
+   int i;
+
+   /* Copy numerator, denominator and memory to aligned xmm */
+   for (i=0;i<2;i++)
    {
-      num[i]=_num[i];
-      den[i]=_den[i];
+      mem[i] = _mm_loadu_ps(_mem+4*i);
+      num[i] = _mm_loadu_ps(_num+4*i);
+      den[i] = _mm_loadu_ps(_den+4*i);
    }
-   for (i=0;i<ord;i++)
-      mem[i]=_mem[i];
-   for (i=0;i<N;i+=4)
+   
+   for (i=0;i<N;i++)
    {
+      __m128 xx;
+      __m128 yy;
+      /* Compute next filter result */
+      xx = _mm_load_ps1(x+i);
+      yy = _mm_add_ss(xx, mem[0]);
+      _mm_store_ss(y+i, yy);
+      yy = _mm_shuffle_ps(yy, yy, 0);
+      
+      /* Update memory */
+      mem[0] = _mm_move_ss(mem[0], mem[1]);
+      mem[0] = _mm_shuffle_ps(mem[0], mem[0], 0x39);
 
-      __asm__ __volatile__ 
-      (
-       "\tmovss (%1), %%xmm0\n"
-       "\tmovss (%0), %%xmm1\n"
-       "\taddss %%xmm0, %%xmm1\n"
-       "\tmovss %%xmm1, (%2)\n"
-       "\tshufps $0x00, %%xmm0, %%xmm0\n"
-       "\tshufps $0x00, %%xmm1, %%xmm1\n"
+      mem[0] = _mm_add_ps(mem[0], _mm_mul_ps(xx, num[0]));
+      mem[0] = _mm_sub_ps(mem[0], _mm_mul_ps(yy, den[0]));
 
-       "\tmovaps 4(%3),  %%xmm2\n"
-       "\tmovaps 4(%4),  %%xmm3\n"
-       "\tmulps  %%xmm0, %%xmm2\n"
-       "\tmulps  %%xmm1, %%xmm3\n"
-       "\tmovaps 20(%3), %%xmm4\n"
-       "\tmulps  %%xmm0, %%xmm4\n"
-       "\taddps  4(%0),  %%xmm2\n"
-       "\tmovaps 20(%4), %%xmm5\n"
-       "\tmulps  %%xmm1, %%xmm5\n"
-       "\taddps  20(%0), %%xmm4\n"
-       "\tsubps  %%xmm3, %%xmm2\n"
-       "\tmovups %%xmm2, (%0)\n"
-       "\tsubps  %%xmm5, %%xmm4\n"
-       "\tmovups %%xmm4, 16(%0)\n"
+      mem[1] = _mm_sub_ss(mem[1], mem[1]);
+      mem[1] = _mm_shuffle_ps(mem[1], mem[1], 0x39);
 
-       "\tmovss  36(%3), %%xmm2\n"
-       "\tmulss  %%xmm0, %%xmm2\n"
-       "\tmovss  36(%4), %%xmm3\n"
-       "\tmulss  %%xmm1, %%xmm3\n"
-       "\taddss  36(%0), %%xmm2\n"
-       "\tmovss  40(%3), %%xmm4\n"
-       "\tmulss  %%xmm0, %%xmm4\n"
-       "\tmovss  40(%4), %%xmm5\n"
-       "\tmulss  %%xmm1, %%xmm5\n"
-       "\tsubss  %%xmm3, %%xmm2\n"
-       "\tmovss  %%xmm2, 32(%0)       \n"
-       "\tsubss  %%xmm5, %%xmm4\n"
-       "\tmovss  %%xmm4, 36(%0)\n"
+      mem[1] = _mm_add_ps(mem[1], _mm_mul_ps(xx, num[1]));
+      mem[1] = _mm_sub_ps(mem[1], _mm_mul_ps(yy, den[1]));
+   }
+   /* Put memory back in its place */
+   _mm_storeu_ps(_mem, mem[0]);
+   _mm_storeu_ps(_mem+4, mem[1]);
+}
 
 
+#define OVERRIDE_FILTER_MEM2
+void filter_mem2(const float *x, const float *_num, const float *_den, float *y, int N, int ord, float *_mem)
+{
+   if(ord==10)
+      filter_mem2_10(x, _num, _den, y, N, ord, _mem);
+   else if (ord==8)
+      filter_mem2_8(x, _num, _den, y, N, ord, _mem);
+}
 
-       "\tmovss 4(%1), %%xmm0\n"
-       "\tmovss (%0), %%xmm1\n"
-       "\taddss %%xmm0, %%xmm1\n"
-       "\tmovss %%xmm1, 4(%2)\n"
-       "\tshufps $0x00, %%xmm0, %%xmm0\n"
-       "\tshufps $0x00, %%xmm1, %%xmm1\n"
 
-       "\tmovaps 4(%3),  %%xmm2\n"
-       "\tmovaps 4(%4),  %%xmm3\n"
-       "\tmulps  %%xmm0, %%xmm2\n"
-       "\tmulps  %%xmm1, %%xmm3\n"
-       "\tmovaps 20(%3), %%xmm4\n"
-       "\tmulps  %%xmm0, %%xmm4\n"
-       "\taddps  4(%0),  %%xmm2\n"
-       "\tmovaps 20(%4), %%xmm5\n"
-       "\tmulps  %%xmm1, %%xmm5\n"
-       "\taddps  20(%0), %%xmm4\n"
-       "\tsubps  %%xmm3, %%xmm2\n"
-       "\tmovups %%xmm2, (%0)\n"
-       "\tsubps  %%xmm5, %%xmm4\n"
-       "\tmovups %%xmm4, 16(%0)\n"
 
-       "\tmovss  36(%3), %%xmm2\n"
-       "\tmulss  %%xmm0, %%xmm2\n"
-       "\tmovss  36(%4), %%xmm3\n"
-       "\tmulss  %%xmm1, %%xmm3\n"
-       "\taddss  36(%0), %%xmm2\n"
-       "\tmovss  40(%3), %%xmm4\n"
-       "\tmulss  %%xmm0, %%xmm4\n"
-       "\tmovss  40(%4), %%xmm5\n"
-       "\tmulss  %%xmm1, %%xmm5\n"
-       "\tsubss  %%xmm3, %%xmm2\n"
-       "\tmovss  %%xmm2, 32(%0)       \n"
-       "\tsubss  %%xmm5, %%xmm4\n"
-       "\tmovss  %%xmm4, 36(%0)\n"
+void iir_mem2_10(const float *x, const float *_den, float *y, int N, int ord, float *_mem)
+{
+   __m128 den[3], mem[3];
 
+   int i;
 
+   /* Copy numerator, denominator and memory to aligned xmm */
+   for (i=0;i<2;i++)
+   {
+      mem[i] = _mm_loadu_ps(_mem+4*i);
+      den[i] = _mm_loadu_ps(_den+4*i);
+   }
+   mem[2] = _mm_setr_ps(_mem[8], _mem[9], 0, 0);
+   den[2] = _mm_setr_ps(_den[9], _den[10], 0, 0);
+   
+   for (i=0;i<N;i++)
+   {
+      __m128 xx;
+      __m128 yy;
+      /* Compute next filter result */
+      xx = _mm_load_ps1(x+i);
+      yy = _mm_add_ss(xx, mem[0]);
+      _mm_store_ss(y+i, yy);
+      yy = _mm_shuffle_ps(yy, yy, 0);
+      
+      /* Update memory */
+      mem[0] = _mm_move_ss(mem[0], mem[1]);
+      mem[0] = _mm_shuffle_ps(mem[0], mem[0], 0x39);
 
-       "\tmovss 8(%1), %%xmm0\n"
-       "\tmovss (%0), %%xmm1\n"
-       "\taddss %%xmm0, %%xmm1\n"
-       "\tmovss %%xmm1, 8(%2)\n"
-       "\tshufps $0x00, %%xmm0, %%xmm0\n"
-       "\tshufps $0x00, %%xmm1, %%xmm1\n"
+      mem[0] = _mm_sub_ps(mem[0], _mm_mul_ps(yy, den[0]));
 
-       "\tmovaps 4(%3),  %%xmm2\n"
-       "\tmovaps 4(%4),  %%xmm3\n"
-       "\tmulps  %%xmm0, %%xmm2\n"
-       "\tmulps  %%xmm1, %%xmm3\n"
-       "\tmovaps 20(%3), %%xmm4\n"
-       "\tmulps  %%xmm0, %%xmm4\n"
-       "\taddps  4(%0),  %%xmm2\n"
-       "\tmovaps 20(%4), %%xmm5\n"
-       "\tmulps  %%xmm1, %%xmm5\n"
-       "\taddps  20(%0), %%xmm4\n"
-       "\tsubps  %%xmm3, %%xmm2\n"
-       "\tmovups %%xmm2, (%0)\n"
-       "\tsubps  %%xmm5, %%xmm4\n"
-       "\tmovups %%xmm4, 16(%0)\n"
+      mem[1] = _mm_move_ss(mem[1], mem[2]);
+      mem[1] = _mm_shuffle_ps(mem[1], mem[1], 0x39);
 
-       "\tmovss  36(%3), %%xmm2\n"
-       "\tmulss  %%xmm0, %%xmm2\n"
-       "\tmovss  36(%4), %%xmm3\n"
-       "\tmulss  %%xmm1, %%xmm3\n"
-       "\taddss  36(%0), %%xmm2\n"
-       "\tmovss  40(%3), %%xmm4\n"
-       "\tmulss  %%xmm0, %%xmm4\n"
-       "\tmovss  40(%4), %%xmm5\n"
-       "\tmulss  %%xmm1, %%xmm5\n"
-       "\tsubss  %%xmm3, %%xmm2\n"
-       "\tmovss  %%xmm2, 32(%0)       \n"
-       "\tsubss  %%xmm5, %%xmm4\n"
-       "\tmovss  %%xmm4, 36(%0)\n"
+      mem[1] = _mm_sub_ps(mem[1], _mm_mul_ps(yy, den[1]));
 
+      mem[2] = _mm_shuffle_ps(mem[2], mem[2], 0xfd);
 
+      mem[2] = _mm_sub_ps(mem[2], _mm_mul_ps(yy, den[2]));
+   }
+   /* Put memory back in its place */
+   _mm_storeu_ps(_mem, mem[0]);
+   _mm_storeu_ps(_mem+4, mem[1]);
+   _mm_store_ss(_mem+8, mem[2]);
+   mem[2] = _mm_shuffle_ps(mem[2], mem[2], 0x55);
+   _mm_store_ss(_mem+9, mem[2]);
+}
 
-       "\tmovss 12(%1), %%xmm0\n"
-       "\tmovss (%0), %%xmm1\n"
-       "\taddss %%xmm0, %%xmm1\n"
-       "\tmovss %%xmm1, 12(%2)\n"
-       "\tshufps $0x00, %%xmm0, %%xmm0\n"
-       "\tshufps $0x00, %%xmm1, %%xmm1\n"
 
-       "\tmovaps 4(%3),  %%xmm2\n"
-       "\tmovaps 4(%4),  %%xmm3\n"
-       "\tmulps  %%xmm0, %%xmm2\n"
-       "\tmulps  %%xmm1, %%xmm3\n"
-       "\tmovaps 20(%3), %%xmm4\n"
-       "\tmulps  %%xmm0, %%xmm4\n"
-       "\taddps  4(%0),  %%xmm2\n"
-       "\tmovaps 20(%4), %%xmm5\n"
-       "\tmulps  %%xmm1, %%xmm5\n"
-       "\taddps  20(%0), %%xmm4\n"
-       "\tsubps  %%xmm3, %%xmm2\n"
-       "\tmovups %%xmm2, (%0)\n"
-       "\tsubps  %%xmm5, %%xmm4\n"
-       "\tmovups %%xmm4, 16(%0)\n"
+void iir_mem2_8(const float *x, const float *_den, float *y, int N, int ord, float *_mem)
+{
+   __m128 den[2], mem[2];
 
-       "\tmovss  36(%3), %%xmm2\n"
-       "\tmulss  %%xmm0, %%xmm2\n"
-       "\tmovss  36(%4), %%xmm3\n"
-       "\tmulss  %%xmm1, %%xmm3\n"
-       "\taddss  36(%0), %%xmm2\n"
-       "\tmovss  40(%3), %%xmm4\n"
-       "\tmulss  %%xmm0, %%xmm4\n"
-       "\tmovss  40(%4), %%xmm5\n"
-       "\tmulss  %%xmm1, %%xmm5\n"
-       "\tsubss  %%xmm3, %%xmm2\n"
-       "\tmovss  %%xmm2, 32(%0)       \n"
-       "\tsubss  %%xmm5, %%xmm4\n"
-       "\tmovss  %%xmm4, 36(%0)\n"
+   int i;
 
-       : : "r" (mem), "r" (x+i), "r" (y+i), "r" (num), "r" (den)
-       : "memory" );
+   /* Copy numerator, denominator and memory to aligned xmm */
+   for (i=0;i<2;i++)
+   {
+      mem[i] = _mm_loadu_ps(_mem+4*i);
+      den[i] = _mm_loadu_ps(_den+4*i);
+   }
+   
+   for (i=0;i<N;i++)
+   {
+      __m128 xx;
+      __m128 yy;
+      /* Compute next filter result */
+      xx = _mm_load_ps1(x+i);
+      yy = _mm_add_ss(xx, mem[0]);
+      _mm_store_ss(y+i, yy);
+      yy = _mm_shuffle_ps(yy, yy, 0);
+      
+      /* Update memory */
+      mem[0] = _mm_move_ss(mem[0], mem[1]);
+      mem[0] = _mm_shuffle_ps(mem[0], mem[0], 0x39);
 
+      mem[0] = _mm_sub_ps(mem[0], _mm_mul_ps(yy, den[0]));
+
+      mem[1] = _mm_sub_ss(mem[1], mem[1]);
+      mem[1] = _mm_shuffle_ps(mem[1], mem[1], 0x39);
+
+      mem[1] = _mm_sub_ps(mem[1], _mm_mul_ps(yy, den[1]));
    }
-   for (i=0;i<ord;i++)
-      _mem[i]=mem[i];
+   /* Put memory back in its place */
+   _mm_storeu_ps(_mem, mem[0]);
+   _mm_storeu_ps(_mem+4, mem[1]);
+}
 
+#define OVERRIDE_IIR_MEM2
+void iir_mem2(const float *x, const float *_den, float *y, int N, int ord, float *_mem)
+{
+   if(ord==10)
+      iir_mem2_10(x, _den, y, N, ord, _mem);
+   else if (ord==8)
+      iir_mem2_8(x, _den, y, N, ord, _mem);
 }
 
 
-void iir_mem2(float *x, float *_den, float *y, int N, int ord, float *_mem)
+void fir_mem2_10(const float *x, const float *_num, float *y, int N, int ord, float *_mem)
 {
-   float  __den[20], __mem[20];
-   float *den, *mem;
+   __m128 num[3], mem[3];
+
    int i;
 
-   den = (float*)(((int)(__den+4))&0xfffffff0)-1;
-   mem = (float*)(((int)(__mem+4))&0xfffffff0)-1;
-   for (i=0;i<=10;i++)
-      den[i]=0;
-   for (i=0;i<10;i++)
-      mem[i]=0;
-   for (i=0;i<ord+1;i++)
+   /* Copy numerator, denominator and memory to aligned xmm */
+   for (i=0;i<2;i++)
    {
-      den[i]=_den[i];
+      mem[i] = _mm_loadu_ps(_mem+4*i);
+      num[i] = _mm_loadu_ps(_num+4*i);
    }
-   for (i=0;i<ord;i++)
-      mem[i]=_mem[i];
-
+   mem[2] = _mm_setr_ps(_mem[8], _mem[9], 0, 0);
+   num[2] = _mm_setr_ps(_num[9], _num[10], 0, 0);
+   
    for (i=0;i<N;i++)
    {
-#if 0
-      y[i] = x[i] + mem[0];
-      for (j=0;j<ord-1;j++)
-      {
-         mem[j] = mem[j+1] - den[j+1]*y[i];
-      }
-      mem[ord-1] = - den[ord]*y[i];
-#else
-      __asm__ __volatile__ 
-      (
-       "\tmovss (%1), %%xmm0\n"
-       "\tmovss (%0), %%xmm1\n"
-       "\taddss %%xmm0, %%xmm1\n"
-       "\tmovss %%xmm1, (%2)\n"
-       "\tshufps $0x00, %%xmm0, %%xmm0\n"
-       "\tshufps $0x00, %%xmm1, %%xmm1\n"
+      __m128 xx;
+      __m128 yy;
+      /* Compute next filter result */
+      xx = _mm_load_ps1(x+i);
+      yy = _mm_add_ss(xx, mem[0]);
+      _mm_store_ss(y+i, yy);
+      yy = _mm_shuffle_ps(yy, yy, 0);
+      
+      /* Update memory */
+      mem[0] = _mm_move_ss(mem[0], mem[1]);
+      mem[0] = _mm_shuffle_ps(mem[0], mem[0], 0x39);
 
-       
-       "\tmovaps 4(%3),  %%xmm2\n"
-       "\tmovaps 20(%3), %%xmm3\n"
-       "\tmulps  %%xmm1, %%xmm2\n"
-       "\tmulps  %%xmm1, %%xmm3\n"
-       "\tmovss  36(%3), %%xmm4\n"
-       "\tmovss  40(%3), %%xmm5\n"
-       "\tmulss  %%xmm1, %%xmm4\n"
-       "\tmulss  %%xmm1, %%xmm5\n"
-       "\tmovaps 4(%0),  %%xmm6\n"
-       "\tsubps  %%xmm2, %%xmm6\n"
-       "\tmovups %%xmm6, (%0)\n"
-       "\tmovaps 20(%0), %%xmm7\n"
-       "\tsubps  %%xmm3, %%xmm7\n"
-       "\tmovups %%xmm7, 16(%0)\n"
+      mem[0] = _mm_add_ps(mem[0], _mm_mul_ps(xx, num[0]));
 
+      mem[1] = _mm_move_ss(mem[1], mem[2]);
+      mem[1] = _mm_shuffle_ps(mem[1], mem[1], 0x39);
 
-       "\tmovss  36(%0), %%xmm7\n"
-       "\tsubss  %%xmm4, %%xmm7\n"
-       "\tmovss  %%xmm7, 32(%0)       \n"
-       "\txorps  %%xmm2, %%xmm2\n"
-       "\tsubss  %%xmm5, %%xmm2\n"
-       "\tmovss  %%xmm2, 36(%0)\n"
+      mem[1] = _mm_add_ps(mem[1], _mm_mul_ps(xx, num[1]));
 
-       : : "r" (mem), "r" (x+i), "r" (y+i), "r" (den)
-       : "memory" );
-#endif
+      mem[2] = _mm_shuffle_ps(mem[2], mem[2], 0xfd);
+
+      mem[2] = _mm_add_ps(mem[2], _mm_mul_ps(xx, num[2]));
    }
-   for (i=0;i<ord;i++)
-      _mem[i]=mem[i];
+   /* Put memory back in its place */
+   _mm_storeu_ps(_mem, mem[0]);
+   _mm_storeu_ps(_mem+4, mem[1]);
+   _mm_store_ss(_mem+8, mem[2]);
+   mem[2] = _mm_shuffle_ps(mem[2], mem[2], 0x55);
+   _mm_store_ss(_mem+9, mem[2]);
+}
 
+void fir_mem2_8(const float *x, const float *_num, float *y, int N, int ord, float *_mem)
+{
+   __m128 num[2], mem[2];
+
+   int i;
+
+   /* Copy numerator, denominator and memory to aligned xmm */
+   for (i=0;i<2;i++)
+   {
+      mem[i] = _mm_loadu_ps(_mem+4*i);
+      num[i] = _mm_loadu_ps(_num+4*i);
+   }
+   
+   for (i=0;i<N;i++)
+   {
+      __m128 xx;
+      __m128 yy;
+      /* Compute next filter result */
+      xx = _mm_load_ps1(x+i);
+      yy = _mm_add_ss(xx, mem[0]);
+      _mm_store_ss(y+i, yy);
+      yy = _mm_shuffle_ps(yy, yy, 0);
+      
+      /* Update memory */
+      mem[0] = _mm_move_ss(mem[0], mem[1]);
+      mem[0] = _mm_shuffle_ps(mem[0], mem[0], 0x39);
+
+      mem[0] = _mm_add_ps(mem[0], _mm_mul_ps(xx, num[0]));
+
+      mem[1] = _mm_sub_ss(mem[1], mem[1]);
+      mem[1] = _mm_shuffle_ps(mem[1], mem[1], 0x39);
+
+      mem[1] = _mm_add_ps(mem[1], _mm_mul_ps(xx, num[1]));
+   }
+   /* Put memory back in its place */
+   _mm_storeu_ps(_mem, mem[0]);
+   _mm_storeu_ps(_mem+4, mem[1]);
 }
 
+#define OVERRIDE_FIR_MEM2
+void fir_mem2(const float *x, const float *_num, float *y, int N, int ord, float *_mem)
+{
+   if(ord==10)
+      fir_mem2_10(x, _num, y, N, ord, _mem);
+   else if (ord==8)
+      fir_mem2_8(x, _num, y, N, ord, _mem);
+}

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/fixed_arm4.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/fixed_arm4.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/fixed_arm4.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,148 @@
+/* Copyright (C) 2004 Jean-Marc Valin */
+/**
+   @file fixed_arm4.h
+   @brief ARM4 fixed-point operations
+*/
+/*
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+   
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+   
+   - Neither the name of the Xiph.org Foundation nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+   
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef FIXED_ARM4_H
+#define FIXED_ARM4_H
+
+#undef MULT16_32_Q14
+static inline spx_word32_t MULT16_32_Q14(spx_word16_t x, spx_word32_t y) {
+  int res;
+  int dummy;
+  asm (
+        "smull  %0,%1,%2,%3 \n\t"
+        "mov %0, %0, lsr #14 \n\t"
+        "add %0, %0, %1, lsl #18 \n\t"
+   : "=&r"(res), "=&r" (dummy)
+   : "r"(y),"r"((int)x));
+  return(res);
+}
+
+#undef MULT16_32_Q15
+static inline spx_word32_t MULT16_32_Q15(spx_word16_t x, spx_word32_t y) {
+  int res;
+  int dummy;
+  asm (
+        "smull  %0,%1,%2,%3 \n\t"
+        "mov %0, %0, lsr #15 \n\t"
+        "add %0, %0, %1, lsl #17 \n\t"
+   : "=&r"(res), "=&r" (dummy)
+   : "r"(y),"r"((int)x));
+  return(res);
+}
+
+#undef DIV32_16
+static inline short DIV32_16(int a, int b)
+{
+   int res=0;
+   int dead1, dead2, dead3, dead4, dead5;
+   __asm__ __volatile__ (
+         "\teor %5, %0, %1\n"
+         "\tmovs %4, %0\n"
+         "\trsbmi %0, %0, #0 \n"
+         "\tmovs %4, %1\n"
+         "\trsbmi %1, %1, #0 \n"
+         "\tmov %4, #1\n"
+
+         "\tsubs %3, %0, %1, asl #14 \n"
+         "\tmovpl %0, %3 \n"
+         "\torrpl %2, %2, %4, asl #14 \n"
+
+         "\tsubs %3, %0, %1, asl #13 \n"
+         "\tmovpl %0, %3 \n"
+         "\torrpl %2, %2, %4, asl #13 \n"
+
+         "\tsubs %3, %0, %1, asl #12 \n"
+         "\tmovpl %0, %3 \n"
+         "\torrpl %2, %2, %4, asl #12 \n"
+
+         "\tsubs %3, %0, %1, asl #11 \n"
+         "\tmovpl %0, %3 \n"
+         "\torrpl %2, %2, %4, asl #11 \n"
+
+         "\tsubs %3, %0, %1, asl #10 \n"
+         "\tmovpl %0, %3 \n"
+         "\torrpl %2, %2, %4, asl #10 \n"
+
+         "\tsubs %3, %0, %1, asl #9 \n"
+         "\tmovpl %0, %3 \n"
+         "\torrpl %2, %2, %4, asl #9 \n"
+
+         "\tsubs %3, %0, %1, asl #8 \n"
+         "\tmovpl %0, %3 \n"
+         "\torrpl %2, %2, %4, asl #8 \n"
+
+         "\tsubs %3, %0, %1, asl #7 \n"
+         "\tmovpl %0, %3 \n"
+         "\torrpl %2, %2, %4, asl #7 \n"
+
+         "\tsubs %3, %0, %1, asl #6 \n"
+         "\tmovpl %0, %3 \n"
+         "\torrpl %2, %2, %4, asl #6 \n"
+         
+         "\tsubs %3, %0, %1, asl #5 \n"
+         "\tmovpl %0, %3 \n"
+         "\torrpl %2, %2, %4, asl #5 \n"
+
+         "\tsubs %3, %0, %1, asl #4 \n"
+         "\tmovpl %0, %3 \n"
+         "\torrpl %2, %2, %4, asl #4 \n"
+
+         "\tsubs %3, %0, %1, asl #3 \n"
+         "\tmovpl %0, %3 \n"
+         "\torrpl %2, %2, %4, asl #3 \n"
+
+         "\tsubs %3, %0, %1, asl #2 \n"
+         "\tmovpl %0, %3 \n"
+         "\torrpl %2, %2, %4, asl #2 \n"
+
+         "\tsubs %3, %0, %1, asl #1 \n"
+         "\tmovpl %0, %3 \n"
+         "\torrpl %2, %2, %4, asl #1 \n"
+
+         "\tsubs %3, %0, %1 \n"
+         "\tmovpl %0, %3 \n"
+         "\torrpl %2, %2, %4 \n"
+
+         "\tmovs %5, %5, lsr #31 \n"
+         "\trsbne %2, %2, #0 \n"
+   : "=r" (dead1), "=r" (dead2), "=r" (res),
+   "=r" (dead3), "=r" (dead4), "=r" (dead5)
+   : "0" (a), "1" (b), "2" (res)
+   : "cc"
+                        );
+   return res;
+}
+
+
+#endif

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/fixed_arm5e.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/fixed_arm5e.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/fixed_arm5e.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,178 @@
+/* Copyright (C) 2003 Jean-Marc Valin */
+/**
+   @file fixed_generic.h
+   @brief ARM-tuned fixed-point operations
+*/
+/*
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+   
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+   
+   - Neither the name of the Xiph.org Foundation nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+   
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef FIXED_ARM5E_H
+#define FIXED_ARM5E_H
+
+#undef MULT16_16
+static inline spx_word32_t MULT16_16(spx_word16_t x, spx_word16_t y) {
+  int res;
+  asm ("smulbb  %0,%1,%2;\n"
+              : "=&r"(res)
+              : "%r"(x),"r"(y));
+  return(res);
+}
+
+#undef MAC16_16
+static inline spx_word32_t MAC16_16(spx_word32_t a, spx_word16_t x, spx_word32_t y) {
+  int res;
+  asm ("smlabb  %0,%1,%2,%3;\n"
+              : "=&r"(res)
+               : "%r"(x),"r"(y),"r"(a));
+  return(res);
+}
+
+#undef MULT16_32_Q15
+static inline spx_word32_t MULT16_32_Q15(spx_word16_t x, spx_word32_t y) {
+  int res;
+  asm ("smulwb  %0,%1,%2;\n"
+              : "=&r"(res)
+               : "%r"(y<<1),"r"(x));
+  return(res);
+}
+
+#undef MAC16_32_Q15
+static inline spx_word32_t MAC16_32_Q15(spx_word32_t a, spx_word16_t x, spx_word32_t y) {
+  int res;
+  asm ("smlawb  %0,%1,%2,%3;\n"
+              : "=&r"(res)
+               : "%r"(y<<1),"r"(x),"r"(a));
+  return(res);
+}
+
+#undef MULT16_32_Q11
+static inline spx_word32_t MULT16_32_Q11(spx_word16_t x, spx_word32_t y) {
+  int res;
+  asm ("smulwb  %0,%1,%2;\n"
+              : "=&r"(res)
+               : "%r"(y<<5),"r"(x));
+  return(res);
+}
+
+#undef MAC16_32_Q11
+static inline spx_word32_t MAC16_32_Q11(spx_word32_t a, spx_word16_t x, spx_word32_t y) {
+  int res;
+  asm ("smlawb  %0,%1,%2,%3;\n"
+              : "=&r"(res)
+               : "%r"(y<<5),"r"(x),"r"(a));
+  return(res);
+}
+
+#undef DIV32_16
+static inline short DIV32_16(int a, int b)
+{
+   int res=0;
+   int dead1, dead2, dead3, dead4, dead5;
+   __asm__ __volatile__ (
+         "\teor %5, %0, %1\n"
+         "\tmovs %4, %0\n"
+         "\trsbmi %0, %0, #0 \n"
+         "\tmovs %4, %1\n"
+         "\trsbmi %1, %1, #0 \n"
+         "\tmov %4, #1\n"
+
+         "\tsubs %3, %0, %1, asl #14 \n"
+         "\torrpl %2, %2, %4, asl #14 \n"
+         "\tmovpl %0, %3 \n"
+
+         "\tsubs %3, %0, %1, asl #13 \n"
+         "\torrpl %2, %2, %4, asl #13 \n"
+         "\tmovpl %0, %3 \n"
+
+         "\tsubs %3, %0, %1, asl #12 \n"
+         "\torrpl %2, %2, %4, asl #12 \n"
+         "\tmovpl %0, %3 \n"
+
+         "\tsubs %3, %0, %1, asl #11 \n"
+         "\torrpl %2, %2, %4, asl #11 \n"
+         "\tmovpl %0, %3 \n"
+
+         "\tsubs %3, %0, %1, asl #10 \n"
+         "\torrpl %2, %2, %4, asl #10 \n"
+         "\tmovpl %0, %3 \n"
+
+         "\tsubs %3, %0, %1, asl #9 \n"
+         "\torrpl %2, %2, %4, asl #9 \n"
+         "\tmovpl %0, %3 \n"
+
+         "\tsubs %3, %0, %1, asl #8 \n"
+         "\torrpl %2, %2, %4, asl #8 \n"
+         "\tmovpl %0, %3 \n"
+
+         "\tsubs %3, %0, %1, asl #7 \n"
+         "\torrpl %2, %2, %4, asl #7 \n"
+         "\tmovpl %0, %3 \n"
+
+         "\tsubs %3, %0, %1, asl #6 \n"
+         "\torrpl %2, %2, %4, asl #6 \n"
+         "\tmovpl %0, %3 \n"
+
+         "\tsubs %3, %0, %1, asl #5 \n"
+         "\torrpl %2, %2, %4, asl #5 \n"
+         "\tmovpl %0, %3 \n"
+
+         "\tsubs %3, %0, %1, asl #4 \n"
+         "\torrpl %2, %2, %4, asl #4 \n"
+         "\tmovpl %0, %3 \n"
+
+         "\tsubs %3, %0, %1, asl #3 \n"
+         "\torrpl %2, %2, %4, asl #3 \n"
+         "\tmovpl %0, %3 \n"
+
+         "\tsubs %3, %0, %1, asl #2 \n"
+         "\torrpl %2, %2, %4, asl #2 \n"
+         "\tmovpl %0, %3 \n"
+
+         "\tsubs %3, %0, %1, asl #1 \n"
+         "\torrpl %2, %2, %4, asl #1 \n"
+         "\tmovpl %0, %3 \n"
+
+         "\tsubs %3, %0, %1 \n"
+         "\torrpl %2, %2, %4 \n"
+         "\tmovpl %0, %3 \n"
+         
+         "\tmovs %5, %5, lsr #31 \n"
+         "\trsbne %2, %2, #0 \n"
+   : "=r" (dead1), "=r" (dead2), "=r" (res),
+   "=r" (dead3), "=r" (dead4), "=r" (dead5)
+   : "0" (a), "1" (b), "2" (res)
+   : "memory", "cc"
+                        );
+   return res;
+}
+
+
+
+
+#endif

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/fixed_bfin.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/fixed_bfin.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/fixed_bfin.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,148 @@
+/* Copyright (C) 2005 Analog Devices
+   Author: Jean-Marc Valin */
+/**
+   @file fixed_bfin.h
+   @brief Blackfin fixed-point operations
+*/
+/*
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+   
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+   
+   - Neither the name of the Xiph.org Foundation nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+   
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef FIXED_BFIN_H
+#define FIXED_BFIN_H
+
+#undef DIV32_16
+static inline spx_word16_t DIV32_16(spx_word32_t a, spx_word16_t b)
+{
+   spx_word32_t res, bb;
+   bb = b;
+   __asm__  (
+         "P0 = 15;\n\t"
+         "R0 = %1;\n\t"
+         "R1 = %2;\n\t"
+         "R0 <<= 1;\n\t"
+         "DIVS (R0, R1);\n\t"
+         "LOOP divide%= LC0 = P0;\n\t"
+         "LOOP_BEGIN divide%=;\n\t"
+            "DIVQ (R0, R1);\n\t"
+         "LOOP_END divide%=;\n\t"
+         "R0 = R0.L;\n\t"
+         "%0 = R0;\n\t"
+   : "=m" (res)
+   : "m" (a), "m" (bb)
+   : "P0", "R0", "R1", "cc");
+   return res;
+}
+
+#undef MAX16
+static inline spx_word16_t MAX16(spx_word16_t a, spx_word16_t b)
+{
+   spx_word32_t res;
+   __asm__  (
+         "%1 = %1.L (X);\n\t"
+         "%2 = %2.L (X);\n\t"
+         "%0 = MAX(%1,%2);"
+   : "=d" (res)
+   : "%d" (a), "d" (b)
+   );
+   return res;
+}
+
+#undef MULT16_32_Q15
+static inline spx_word32_t MULT16_32_Q15(spx_word16_t a, spx_word32_t b)
+{
+   spx_word32_t res;
+   __asm__
+   (
+         "%1 <<= 1;\n\t"
+         "A1 = %2.L*%1.L (M,IS);\n\t"
+         "A1 = A1 >>> 16;\n\t"
+         "R1 = (A1 += %2.L*%1.H) (IS);\n\t"
+         "%0 = R1;\n\t"
+   : "=&d" (res), "=&d" (b)
+   : "d" (a), "1" (b)
+   : "A1", "R1"
+   );
+   return res;
+}
+
+#undef MAC16_32_Q15
+static inline spx_word32_t MAC16_32_Q15(spx_word32_t c, spx_word16_t a, spx_word32_t b)
+{
+   spx_word32_t res;
+   __asm__
+         (
+         "%1 <<= 1;\n\t"
+         "A1 = %2.L*%1.L (M,IS);\n\t"
+         "A1 = A1 >>> 16;\n\t"
+         "R1 = (A1 += %2.L*%1.H) (IS);\n\t"
+         "%0 = R1 + %4;\n\t"
+   : "=&d" (res), "=&d" (b)
+   : "d" (a), "1" (b), "d" (c)
+   : "A1", "R1"
+         );
+   return res;
+}
+
+#undef MULT16_32_Q14
+static inline spx_word32_t MULT16_32_Q14(spx_word16_t a, spx_word32_t b)
+{
+   spx_word32_t res;
+   __asm__
+         (
+         "%2 <<= 2;\n\t"
+         "A1 = %1.L*%2.L (M,IS);\n\t"
+         "A1 = A1 >>> 16;\n\t"
+         "R1 = (A1 += %1.L*%2.H) (IS);\n\t"
+         "%0 = R1;\n\t"
+   : "=d" (res), "=d" (a), "=d" (b)
+   : "1" (a), "2" (b)
+   : "A1", "R1"
+         );
+   return res;
+}
+
+#undef MAC16_32_Q14
+static inline spx_word32_t MAC16_32_Q14(spx_word32_t c, spx_word16_t a, spx_word32_t b)
+{
+   spx_word32_t res;
+   __asm__
+         (
+         "%1 <<= 2;\n\t"
+         "A1 = %2.L*%1.L (M,IS);\n\t"
+         "A1 = A1 >>> 16;\n\t"
+         "R1 = (A1 += %2.L*%1.H) (IS);\n\t"
+         "%0 = R1 + %4;\n\t"
+   : "=&d" (res), "=&d" (b)
+   : "d" (a), "1" (b), "d" (c)
+   : "A1", "R1"
+         );
+   return res;
+}
+
+#endif

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/fixed_debug.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/fixed_debug.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/fixed_debug.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,440 @@
+/* Copyright (C) 2003 Jean-Marc Valin */
+/**
+   @file fixed_debug.h
+   @brief Fixed-point operations with debugging
+*/
+/*
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+   
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+   
+   - Neither the name of the Xiph.org Foundation nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+   
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef FIXED_DEBUG_H
+#define FIXED_DEBUG_H
+
+#include <stdio.h>
+
+extern long long spx_mips;
+#define MIPS_INC spx_mips++,
+
+#define VERIFY_SHORT(x) ((x)<=32767&&(x)>=-32768)
+#define VERIFY_INT(x) ((x)<=2147483647LL&&(x)>=-2147483648LL)
+
+static inline short NEG16(int x)
+{
+   int res;
+   if (!VERIFY_SHORT(x))
+   {
+      fprintf (stderr, "NEG16: input is not short: %d\n", (int)x);
+   }
+   res = -x;
+   if (!VERIFY_SHORT(res))
+      fprintf (stderr, "NEG16: output is not short: %d\n", (int)res);
+   spx_mips++;
+   return res;
+}
+static inline int NEG32(long long x)
+{
+   long long res;
+   if (!VERIFY_INT(x))
+   {
+      fprintf (stderr, "NEG16: input is not int: %d\n", (int)x);
+   }
+   res = -x;
+   if (!VERIFY_INT(res))
+      fprintf (stderr, "NEG16: output is not int: %d\n", (int)res);
+   spx_mips++;
+   return res;
+}
+
+static inline short EXTRACT16(int x)
+{
+   int res;
+   if (!VERIFY_SHORT(x))
+   {
+      fprintf (stderr, "EXTRACT16: input is not short: %d\n", x);
+   }
+   res = x;
+   spx_mips++;
+   return res;
+}
+
+static inline int EXTEND32(int x)
+{
+   int res;
+   if (!VERIFY_SHORT(x))
+   {
+      fprintf (stderr, "EXTRACT16: input is not short: %d\n", x);
+   }
+   res = x;
+   spx_mips++;
+   return res;
+}
+
+static inline short SHR16(int a, int shift) 
+{
+   int res;
+   if (!VERIFY_SHORT(a) || !VERIFY_SHORT(shift))
+   {
+      fprintf (stderr, "SHR16: inputs are not short: %d %d\n", a, shift);
+   }
+   res = a>>shift;
+   if (!VERIFY_SHORT(res))
+      fprintf (stderr, "SHR16: output is not short: %d\n", res);
+   spx_mips++;
+   return res;
+}
+static inline short SHL16(int a, int shift) 
+{
+   int res;
+   if (!VERIFY_SHORT(a) || !VERIFY_SHORT(shift))
+   {
+      fprintf (stderr, "SHR16: inputs are not short: %d %d\n", a, shift);
+   }
+   res = a<<shift;
+   if (!VERIFY_SHORT(res))
+      fprintf (stderr, "SHR16: output is not short: %d\n", res);
+   spx_mips++;
+   return res;
+}
+
+static inline int SHR32(long long a, int shift) 
+{
+   long long  res;
+   if (!VERIFY_INT(a) || !VERIFY_SHORT(shift))
+   {
+      fprintf (stderr, "SHR32: inputs are not int: %d %d\n", (int)a, shift);
+   }
+   res = a>>shift;
+   if (!VERIFY_INT(res))
+      fprintf (stderr, "SHR32: output is not int: %d\n", (int)res);
+   spx_mips++;
+   return res;
+}
+static inline int SHL32(long long a, int shift) 
+{
+   long long  res;
+   if (!VERIFY_INT(a) || !VERIFY_SHORT(shift))
+   {
+      fprintf (stderr, "SHR32: inputs are not int: %d %d\n", (int)a, shift);
+   }
+   res = a<<shift;
+   if (!VERIFY_INT(res))
+      fprintf (stderr, "SHR32: output is not int: %d\n", (int)res);
+   spx_mips++;
+   return res;
+}
+
+
+#define PSHR16(a,shift) (SHR16(ADD16(a,(1<<((shift)-1))),shift))
+#define PSHR32(a,shift) (SHR32(ADD32(a,(1<<((shift)-1))),shift))
+#define SATURATE16(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
+#define SATURATE32(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
+
+#define SHR(a,shift) ((a) >> (shift))
+#define SHL(a,shift) ((a) << (shift))
+
+static inline short ADD16(int a, int b) 
+{
+   int res;
+   if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
+   {
+      fprintf (stderr, "ADD16: inputs are not short: %d %d\n", a, b);
+   }
+   res = a+b;
+   if (!VERIFY_SHORT(res))
+      fprintf (stderr, "ADD16: output is not short: %d\n", res);
+   spx_mips++;
+   return res;
+}
+static inline short SUB16(int a, int b) 
+{
+   int res;
+   if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
+   {
+      fprintf (stderr, "SUB16: inputs are not short: %d %d\n", a, b);
+   }
+   res = a-b;
+   if (!VERIFY_SHORT(res))
+      fprintf (stderr, "SUB16: output is not short: %d\n", res);
+   spx_mips++;
+   return res;
+}
+
+static inline int ADD32(long long a, long long b) 
+{
+   long long res;
+   if (!VERIFY_INT(a) || !VERIFY_INT(b))
+   {
+      fprintf (stderr, "ADD32: inputs are not int: %d %d\n", (int)a, (int)b);
+   }
+   res = a+b;
+   if (!VERIFY_INT(res))
+      fprintf (stderr, "ADD32: output is not int: %d\n", (int)res);
+   spx_mips++;
+   return res;
+}
+
+static inline int SUB32(long long a, long long b) 
+{
+   long long res;
+   if (!VERIFY_INT(a) || !VERIFY_INT(b))
+   {
+      fprintf (stderr, "SUB32: inputs are not int: %d %d\n", (int)a, (int)b);
+   }
+   res = a-b;
+   if (!VERIFY_INT(res))
+      fprintf (stderr, "SUB32: output is not int: %d\n", (int)res);
+   spx_mips++;
+   return res;
+}
+
+#define ADD64(a,b) (MIPS_INC(a)+(b))
+
+#define PSHR(a,shift) (SHR((a)+(1<<((shift)-1)),shift))
+
+/* result fits in 16 bits */
+static inline short MULT16_16_16(int a, int b) 
+{
+   int res;
+   if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
+   {
+      fprintf (stderr, "MULT16_16_16: inputs are not short: %d %d\n", a, b);
+   }
+   res = a*b;
+   if (!VERIFY_SHORT(res))
+      fprintf (stderr, "MULT16_16_16: output is not short: %d\n", res);
+   spx_mips++;
+   return res;
+}
+
+static inline int MULT16_16(int a, int b) 
+{
+   long long res;
+   if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
+   {
+      fprintf (stderr, "MULT16_16: inputs are not short: %d %d\n", a, b);
+   }
+   res = ((long long)a)*b;
+   if (!VERIFY_INT(res))
+      fprintf (stderr, "MULT16_16: output is not int: %d\n", (int)res);
+   spx_mips++;
+   return res;
+}
+
+#define MAC16_16(c,a,b)     (spx_mips--,ADD32((c),MULT16_16((a),(b))))
+#define MAC16_16_Q11(c,a,b)     (ADD16((c),EXTRACT16(SHR32(MULT16_16((a),(b)),11))))
+#define MAC16_16_Q13(c,a,b)     (ADD16((c),EXTRACT16(SHR32(MULT16_16((a),(b)),13))))
+
+static inline int MULT16_32_QX(int a, long long b, int Q)
+{
+   long long res;
+   if (!VERIFY_SHORT(a) || !VERIFY_INT(b))
+   {
+      fprintf (stderr, "MULT16_32_Q%d: inputs are not short+int: %d %d\n", Q, (int)a, (int)b);
+   }
+   res = (((long long)a)*(long long)b) >> Q;
+   if (!VERIFY_INT(res))
+      fprintf (stderr, "MULT16_32_Q%d: output is not int: %d*%d=%d\n", Q, (int)a, (int)b,(int)res);
+   spx_mips+=5;
+   return res;
+}
+
+
+#define MULT16_32_Q11(a,b) MULT16_32_QX(a,b,11)
+#define MAC16_32_Q11(c,a,b) ADD32((c),MULT16_32_Q11((a),(b)))
+#define MULT16_32_Q12(a,b) MULT16_32_QX(a,b,12)
+#define MULT16_32_Q13(a,b) MULT16_32_QX(a,b,13)
+#define MULT16_32_Q14(a,b) MULT16_32_QX(a,b,14)
+#define MULT16_32_Q15(a,b) MULT16_32_QX(a,b,15)
+#define MAC16_32_Q15(c,a,b) ADD32((c),MULT16_32_Q15((a),(b)))
+
+static inline int SATURATE(int a, int b)
+{
+   if (a>b)
+      a=b;
+   if (a<-b)
+      a = -b;
+   return a;
+}
+
+static inline int MULT16_16_Q11_32(int a, int b) 
+{
+   long long res;
+   if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
+   {
+      fprintf (stderr, "MULT16_16_Q11: inputs are not short: %d %d\n", a, b);
+   }
+   res = ((long long)a)*b;
+   res >>= 11;
+   if (!VERIFY_INT(res))
+      fprintf (stderr, "MULT16_16_Q11: output is not short: %d*%d=%d\n", (int)a, (int)b, (int)res);
+   spx_mips+=3;
+   return res;
+}
+static inline short MULT16_16_Q13(int a, int b) 
+{
+   long long res;
+   if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
+   {
+      fprintf (stderr, "MULT16_16_Q13: inputs are not short: %d %d\n", a, b);
+   }
+   res = ((long long)a)*b;
+   res >>= 13;
+   if (!VERIFY_SHORT(res))
+      fprintf (stderr, "MULT16_16_Q13: output is not short: %d*%d=%d\n", a, b, (int)res);
+   spx_mips+=3;
+   return res;
+}
+static inline short MULT16_16_Q14(int a, int b) 
+{
+   long long res;
+   if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
+   {
+      fprintf (stderr, "MULT16_16_Q14: inputs are not short: %d %d\n", a, b);
+   }
+   res = ((long long)a)*b;
+   res >>= 14;
+   if (!VERIFY_SHORT(res))
+      fprintf (stderr, "MULT16_16_Q14: output is not short: %d\n", (int)res);
+   spx_mips+=3;
+   return res;
+}
+static inline short MULT16_16_Q15(int a, int b) 
+{
+   long long res;
+   if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
+   {
+      fprintf (stderr, "MULT16_16_Q15: inputs are not short: %d %d\n", a, b);
+   }
+   res = ((long long)a)*b;
+   res >>= 15;
+   if (!VERIFY_SHORT(res))
+      fprintf (stderr, "MULT16_16_Q15: output is not short: %d\n", (int)res);
+   spx_mips+=3;
+   return res;
+}
+
+static inline short MULT16_16_P13(int a, int b) 
+{
+   long long res;
+   if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
+   {
+      fprintf (stderr, "MULT16_16_P13: inputs are not short: %d %d\n", a, b);
+   }
+   res = ((long long)a)*b;
+   res += 4096;
+   if (!VERIFY_INT(res))
+      fprintf (stderr, "MULT16_16_P13: overflow: %d*%d=%d\n", a, b, (int)res);
+   res >>= 13;
+   if (!VERIFY_SHORT(res))
+      fprintf (stderr, "MULT16_16_P13: output is not short: %d*%d=%d\n", a, b, (int)res);
+   spx_mips+=4;
+   return res;
+}
+static inline short MULT16_16_P14(int a, int b) 
+{
+   long long res;
+   if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
+   {
+      fprintf (stderr, "MULT16_16_P14: inputs are not short: %d %d\n", a, b);
+   }
+   res = ((long long)a)*b;
+   res += 8192;
+   if (!VERIFY_INT(res))
+      fprintf (stderr, "MULT16_16_P14: overflow: %d*%d=%d\n", a, b, (int)res);
+   res >>= 14;
+   if (!VERIFY_SHORT(res))
+      fprintf (stderr, "MULT16_16_P14: output is not short: %d*%d=%d\n", a, b, (int)res);
+   spx_mips+=4;
+   return res;
+}
+static inline short MULT16_16_P15(int a, int b) 
+{
+   long long res;
+   if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
+   {
+      fprintf (stderr, "MULT16_16_P15: inputs are not short: %d %d\n", a, b);
+   }
+   res = ((long long)a)*b;
+   res += 16384;
+   if (!VERIFY_INT(res))
+      fprintf (stderr, "MULT16_16_P15: overflow: %d*%d=%d\n", a, b, (int)res);
+   res >>= 15;
+   if (!VERIFY_SHORT(res))
+      fprintf (stderr, "MULT16_16_P15: output is not short: %d*%d=%d\n", a, b, (int)res);
+   spx_mips+=4;
+   return res;
+}
+
+
+static inline int DIV32_16(long long a, long long b) 
+{
+   long long res;
+   if (b==0)
+   {
+      fprintf(stderr, "DIV32_16: divide by zero: %d/%d\n", (int)a, (int)b);
+      return 0;
+   }
+   if (!VERIFY_INT(a) || !VERIFY_SHORT(b))
+   {
+      fprintf (stderr, "DIV32_16: inputs are not int/short: %d %d\n", (int)a, (int)b);
+   }
+   res = a/b;
+   if (!VERIFY_SHORT(res))
+   {
+      fprintf (stderr, "DIV32_16: output is not short: %d / %d = %d\n", (int)a,(int)b,(int)res);
+      if (res>32767)
+         res = 32767;
+      if (res<-32768)
+         res = -32768;
+   }
+   spx_mips+=20;
+   return res;
+}
+static inline int DIV32(long long a, long long b) 
+{
+   long long res;
+   if (b==0)
+   {
+      fprintf(stderr, "DIV32: divide by zero: %d/%d\n", (int)a, (int)b);
+      return 0;
+   }
+
+   if (!VERIFY_INT(a) || !VERIFY_INT(b))
+   {
+      fprintf (stderr, "DIV32: inputs are not int/short: %d %d\n", (int)a, (int)b);
+   }
+   res = a/b;
+   if (!VERIFY_INT(res))
+      fprintf (stderr, "DIV32: output is not int: %d\n", (int)res);
+   spx_mips+=36;
+   return res;
+}
+
+
+
+#endif

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/fixed_generic.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/fixed_generic.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/fixed_generic.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,99 @@
+/* Copyright (C) 2003 Jean-Marc Valin */
+/**
+   @file fixed_generic.h
+   @brief Generic fixed-point operations
+*/
+/*
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+   
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+   
+   - Neither the name of the Xiph.org Foundation nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+   
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef FIXED_GENERIC_H
+#define FIXED_GENERIC_H
+
+#define NEG16(x) (-(x))
+#define NEG32(x) (-(x))
+#define EXTRACT16(x) ((spx_word16_t)x)
+#define EXTEND32(x) ((spx_word32_t)x)
+#define SHR16(a,shift) ((a) >> (shift))
+#define SHL16(a,shift) ((a) << (shift))
+#define SHR32(a,shift) ((a) >> (shift))
+#define SHL32(a,shift) ((a) << (shift))
+#define PSHR16(a,shift) (SHR16((a)+(1<<((shift)-1)),shift))
+#define PSHR32(a,shift) (SHR32((a)+(1<<((shift)-1)),shift))
+#define SATURATE16(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
+#define SATURATE32(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
+
+#define SHR(a,shift) ((a) >> (shift))
+#define SHL(a,shift) ((spx_word32_t)(a) << (shift))
+#define PSHR(a,shift) (SHR((a)+(1<<((shift)-1)),shift))
+#define SATURATE(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
+
+
+#define ADD16(a,b) ((spx_word16_t)((spx_word16_t)(a)+(spx_word16_t)(b)))
+#define SUB16(a,b) ((spx_word16_t)(a)-(spx_word16_t)(b))
+#define ADD32(a,b) ((spx_word32_t)(a)+(spx_word32_t)(b))
+#define SUB32(a,b) ((spx_word32_t)(a)-(spx_word32_t)(b))
+#define ADD64(a,b) ((spx_word64_t)(a)+(spx_word64_t)(b))
+
+
+/* result fits in 16 bits */
+#define MULT16_16_16(a,b)     ((((spx_word16_t)(a))*((spx_word16_t)(b))))
+
+/* (spx_word32_t)(spx_word16_t) gives TI compiler a hint that it's 16x16->32 multiply */
+#define MULT16_16(a,b)     (((spx_word32_t)(spx_word16_t)(a))*((spx_word32_t)(spx_word16_t)(b)))
+
+#define MAC16_16(c,a,b) (ADD32((c),MULT16_16((a),(b))))
+#define MULT16_32_Q12(a,b) ADD32(MULT16_16((a),SHR((b),12)), SHR(MULT16_16((a),((b)&0x00000fff)),12))
+#define MULT16_32_Q13(a,b) ADD32(MULT16_16((a),SHR((b),13)), SHR(MULT16_16((a),((b)&0x00001fff)),13))
+#define MULT16_32_Q14(a,b) ADD32(MULT16_16((a),SHR((b),14)), SHR(MULT16_16((a),((b)&0x00003fff)),14))
+
+#define MULT16_32_Q11(a,b) ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11))
+#define MAC16_32_Q11(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11)))
+
+#define MULT16_32_Q15(a,b) ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15))
+#define MAC16_32_Q15(c,a,b) ADD32(c,ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15)))
+
+
+#define MAC16_16_Q11(c,a,b)     (ADD32((c),SHR(MULT16_16((a),(b)),11)))
+#define MAC16_16_Q13(c,a,b)     (ADD32((c),SHR(MULT16_16((a),(b)),13)))
+
+#define MULT16_16_Q11_32(a,b) (SHR(MULT16_16((a),(b)),11))
+#define MULT16_16_Q13(a,b) (SHR(MULT16_16((a),(b)),13))
+#define MULT16_16_Q14(a,b) (SHR(MULT16_16((a),(b)),14))
+#define MULT16_16_Q15(a,b) (SHR(MULT16_16((a),(b)),15))
+
+#define MULT16_16_P13(a,b) (SHR(ADD32(4096,MULT16_16((a),(b))),13))
+#define MULT16_16_P14(a,b) (SHR(ADD32(8192,MULT16_16((a),(b))),14))
+#define MULT16_16_P15(a,b) (SHR(ADD32(16384,MULT16_16((a),(b))),15))
+
+#define MUL_16_32_R15(a,bh,bl) ADD32(MULT16_16((a),(bh)), SHR(MULT16_16((a),(bl)),15))
+
+#define DIV32_16(a,b) ((spx_word16_t)(((spx_word32_t)(a))/((spx_word16_t)(b))))
+#define DIV32(a,b) (((spx_word32_t)(a))/((spx_word32_t)(b)))
+
+#endif

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/gain_table.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/gain_table.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/gain_table.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -29,7 +29,7 @@
    POSSIBILITY OF SUCH DAMAGE.
 */
 
-signed char gain_cdbk_nb[384] = {
+const signed char gain_cdbk_nb[384] = {
 -32,-32,-32,
 -28,-67,-5,
 -42,-6,-32,

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/gain_table_lbr.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/gain_table_lbr.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/gain_table_lbr.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -29,7 +29,7 @@
    POSSIBILITY OF SUCH DAMAGE.
 */
 
-signed char gain_cdbk_lbr[96] = {
+const signed char gain_cdbk_lbr[96] = {
 -32,-32,-32,
 -31,-58,-16,
 -41,-24,-43,

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/hexc_10_32_table.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/hexc_10_32_table.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/hexc_10_32_table.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -30,7 +30,7 @@
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-signed char hexc_10_32_table[320] = {
+const signed char hexc_10_32_table[320] = {
 -3, -2, -1, 0, -4, 5, 35, -40, -9, 13, 
 -44, 5, -27, -1, -7, 6, -11, 7, -8, 7, 
 19, -14, 15, -4, 9, -10, 10, -8, 10, -9, 

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/hexc_table.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/hexc_table.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/hexc_table.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -30,7 +30,7 @@
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-signed char hexc_table[1024] = {
+const signed char hexc_table[1024] = {
 -24, 21, -20, 5, -5, -7, 14, -10, 
 2, -27, 16, -20, 0, -32, 26, 19, 
 8, -11, -41, 31, 28, -27, -32, 34, 

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/high_lsp_tables.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/high_lsp_tables.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/high_lsp_tables.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -29,7 +29,7 @@
    POSSIBILITY OF SUCH DAMAGE.
 */
  
-signed char high_lsp_cdbk[512]={
+const signed char high_lsp_cdbk[512]={
 39,12,-14,-20,-29,-61,-67,-76,
 -32,-71,-67,68,77,46,34,5,
 -13,-48,-46,-72,-81,-84,-60,-58,
@@ -96,7 +96,7 @@
 -42,-74,-48,21,-4,70,52,10};
 
 
-signed char high_lsp_cdbk2[512]={
+const signed char high_lsp_cdbk2[512]={
 -36,-62,6,-9,-10,-14,-56,23,
 1,-26,23,-48,-17,12,8,-7,
 23,29,-36,-28,-6,-29,-17,-5,

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/jitter.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/jitter.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/jitter.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,315 @@
+/* Copyright (C) 2002 Jean-Marc Valin 
+   File: speex_jitter.h
+
+   Adaptive jitter buffer for Speex
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+   
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+   
+   - Neither the name of the Xiph.org Foundation nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+   
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#include "misc.h"
+#include <speex/speex.h>
+#include <speex/speex_bits.h>
+#include <speex/speex_jitter.h>
+#include <stdio.h>
+
+#define LATE_BINS 4
+
+void speex_jitter_init(SpeexJitter *jitter, void *decoder, int sampling_rate)
+{
+   int i;
+   for (i=0;i<SPEEX_JITTER_MAX_BUFFER_SIZE;i++)
+   {
+      jitter->len[i]=-1;
+      jitter->timestamp[i]=-1;
+   }
+
+   jitter->dec = decoder;
+   speex_decoder_ctl(decoder, SPEEX_GET_FRAME_SIZE, &jitter->frame_size);
+   jitter->frame_time = 1000*jitter->frame_size / sampling_rate;
+
+   speex_bits_init(&jitter->current_packet);
+   jitter->valid_bits = 0;
+
+   jitter->buffer_size = 4;
+
+   jitter->pointer_timestamp = -jitter->frame_time * jitter->buffer_size;
+   jitter->reset_state = 1;
+   jitter->lost_count = 0;
+   jitter->loss_rate = 0;
+}
+
+void speex_jitter_destroy(SpeexJitter *jitter)
+{
+}
+
+
+void speex_jitter_put(SpeexJitter *jitter, char *packet, int len, int timestamp)
+{
+   int i,j;
+   int arrival_margin;
+
+   if (jitter->reset_state)
+   {
+      jitter->reset_state=0;
+      jitter->pointer_timestamp = timestamp-jitter->frame_time * jitter->buffer_size;
+      for (i=0;i<MAX_MARGIN;i++)
+      {
+         jitter->shortterm_margin[i] = 0;
+         jitter->longterm_margin[i] = 0;
+      }
+      for (i=0;i<SPEEX_JITTER_MAX_BUFFER_SIZE;i++)
+      {
+         jitter->len[i]=-1;
+         jitter->timestamp[i]=-1;
+      }
+      fprintf(stderr, "reset to %d\n", timestamp);
+   }
+   
+   /* Cleanup buffer (remove old packets that weren't played) */
+   for (i=0;i<SPEEX_JITTER_MAX_BUFFER_SIZE;i++)
+   {
+      if (jitter->timestamp[i]<jitter->pointer_timestamp)
+      {
+         jitter->len[i]=-1;
+         /*if (jitter->timestamp[i] != -1)
+            fprintf (stderr, "discarding %d %d\n", jitter->timestamp[i], jitter->pointer_timestamp);*/
+      }
+   }
+
+   /*Find an empty slot in the buffer*/
+   for (i=0;i<SPEEX_JITTER_MAX_BUFFER_SIZE;i++)
+   {
+      if (jitter->len[i]==-1)
+         break;
+   }
+
+   /*fprintf(stderr, "%d %d %f\n", timestamp, jitter->pointer_timestamp, jitter->drift_average);*/
+   if (i==SPEEX_JITTER_MAX_BUFFER_SIZE)
+   {
+      int earliest=jitter->timestamp[0];
+      i=0;
+      for (j=1;j<SPEEX_JITTER_MAX_BUFFER_SIZE;j++)
+      {
+         if (jitter->timestamp[j]<earliest)
+         {
+            earliest = jitter->timestamp[j];
+            i=j;
+         }
+      }
+      /*fprintf (stderr, "Buffer is full, discarding earliest frame %d (currently at %d)\n", timestamp, jitter->pointer_timestamp);*/
+      /*No place left in the buffer*/
+      
+      /*skip some frame(s) */
+      /*return;*/
+   }
+   
+   /* Copy packet in buffer */
+   if (len>SPEEX_JITTER_MAX_PACKET_SIZE)
+      len=SPEEX_JITTER_MAX_PACKET_SIZE;
+   for (j=0;j<len/BYTES_PER_CHAR;j++)
+      jitter->buf[i][j]=packet[j];
+   jitter->timestamp[i]=timestamp;
+   jitter->len[i]=len;
+   
+   /* Don't count late packets when adjusting the synchro (we're taking care of them elsewhere) */
+   /*if (timestamp <= jitter->pointer_timestamp)
+   {
+      fprintf (stderr, "frame for timestamp %d arrived too late (at time %d)\n", timestamp, jitter->pointer_timestamp);
+   }*/
+
+   /* Adjust the buffer size depending on network conditions */
+   arrival_margin = (timestamp - jitter->pointer_timestamp - jitter->frame_time);
+   
+   if (arrival_margin >= -LATE_BINS*jitter->frame_time)
+   {
+      int int_margin;
+      for (i=0;i<MAX_MARGIN;i++)
+      {
+         jitter->shortterm_margin[i] *= .98;
+         jitter->longterm_margin[i] *= .995;
+      }
+      int_margin = (arrival_margin + LATE_BINS*jitter->frame_time)/jitter->frame_time;
+      if (int_margin>MAX_MARGIN-1)
+         int_margin = MAX_MARGIN-1;
+      if (int_margin>=0)
+      {
+         jitter->shortterm_margin[int_margin] += .02;
+         jitter->longterm_margin[int_margin] += .005;
+      }
+   }
+   
+   /*fprintf (stderr, "margin : %d %d %f %f %f %f\n", arrival_margin, jitter->buffer_size, 100*jitter->loss_rate, 100*jitter->late_ratio, 100*jitter->ontime_ratio, 100*jitter->early_ratio);*/
+}
+
+void speex_jitter_get(SpeexJitter *jitter, short *out, int *current_timestamp)
+{
+   int i;
+   int ret;
+   float late_ratio_short;
+   float late_ratio_long;
+   float ontime_ratio_short;
+   float ontime_ratio_long;
+   float early_ratio_short;
+   float early_ratio_long;
+   
+   late_ratio_short = 0;
+   late_ratio_long = 0;
+   for (i=0;i<LATE_BINS;i++)
+   {
+      late_ratio_short += jitter->shortterm_margin[i];
+      late_ratio_long += jitter->longterm_margin[i];
+   }
+   ontime_ratio_short = jitter->shortterm_margin[LATE_BINS];
+   ontime_ratio_long = jitter->longterm_margin[LATE_BINS];
+   early_ratio_short = early_ratio_long = 0;
+   for (i=LATE_BINS+1;i<MAX_MARGIN;i++)
+   {
+      early_ratio_short += jitter->shortterm_margin[i];
+      early_ratio_long += jitter->longterm_margin[i];
+   }
+   if (0&&jitter->pointer_timestamp%1000==0)
+   {
+      fprintf (stderr, "%f %f %f %f %f %f\n", early_ratio_short, early_ratio_long, ontime_ratio_short, ontime_ratio_long, late_ratio_short, late_ratio_long);
+      /*fprintf (stderr, "%f %f\n", early_ratio_short + ontime_ratio_short + late_ratio_short, early_ratio_long + ontime_ratio_long + late_ratio_long);*/
+   }
+   
+   if (late_ratio_short > .1 || late_ratio_long > .03)
+   {
+      jitter->shortterm_margin[MAX_MARGIN-1] += jitter->shortterm_margin[MAX_MARGIN-2];
+      jitter->longterm_margin[MAX_MARGIN-1] += jitter->longterm_margin[MAX_MARGIN-2];
+      for (i=MAX_MARGIN-2;i>=0;i--)
+      {
+         jitter->shortterm_margin[i+1] = jitter->shortterm_margin[i];
+         jitter->longterm_margin[i+1] = jitter->longterm_margin[i];         
+      }
+      jitter->shortterm_margin[0] = 0;
+      jitter->longterm_margin[0] = 0;            
+      /*fprintf (stderr, "interpolate frame\n");*/
+      speex_decode_int(jitter->dec, NULL, out);
+      if (current_timestamp)
+         *current_timestamp = jitter->pointer_timestamp;
+      return;
+   }
+   
+   /* Increment timestamp */
+   jitter->pointer_timestamp += jitter->frame_time;
+   
+   if (late_ratio_short + ontime_ratio_short < .005 && late_ratio_long + ontime_ratio_long < .01 && early_ratio_short > .8)
+   {
+      jitter->shortterm_margin[0] += jitter->shortterm_margin[1];
+      jitter->longterm_margin[0] += jitter->longterm_margin[1];
+      for (i=1;i<MAX_MARGIN-1;i++)
+      {
+         jitter->shortterm_margin[i] = jitter->shortterm_margin[i+1];
+         jitter->longterm_margin[i] = jitter->longterm_margin[i+1];         
+      }
+      jitter->shortterm_margin[MAX_MARGIN-1] = 0;
+      jitter->longterm_margin[MAX_MARGIN-1] = 0;      
+      /*fprintf (stderr, "drop frame\n");*/
+      jitter->pointer_timestamp += jitter->frame_time;
+   }
+
+   if (current_timestamp)
+      *current_timestamp = jitter->pointer_timestamp;
+
+   /* Send zeros while we fill in the buffer */
+   if (jitter->pointer_timestamp<0)
+   {
+      for (i=0;i<jitter->frame_size;i++)
+         out[i]=0;
+      return;
+   }
+   
+   /* Search the buffer for a packet with the right timestamp */
+   for (i=0;i<SPEEX_JITTER_MAX_BUFFER_SIZE;i++)
+   {
+      if (jitter->len[i]!=-1 && jitter->timestamp[i]==jitter->pointer_timestamp)
+         break;
+   }
+   
+   if (i==SPEEX_JITTER_MAX_BUFFER_SIZE)
+   {
+      /* No packet found */
+      if (jitter->valid_bits)
+      {
+         /* Try decoding last received packet */
+         ret = speex_decode_int(jitter->dec, &jitter->current_packet, out);
+         if (ret == 0)
+         {
+            jitter->lost_count = 0;
+            return;
+         } else {
+            jitter->valid_bits = 0;
+         }
+      }
+
+      /*fprintf (stderr, "lost/late frame %d\n", jitter->pointer_timestamp);*/
+      /*Packet is late or lost*/
+      speex_decode_int(jitter->dec, NULL, out);
+      jitter->lost_count++;
+      if (jitter->lost_count>=25)
+      {
+         jitter->lost_count = 0;
+         jitter->reset_state = 1;
+         speex_decoder_ctl(jitter->dec, SPEEX_RESET_STATE, NULL);
+      }
+      jitter->loss_rate = .999*jitter->loss_rate + .001;
+   } else {
+      jitter->lost_count = 0;
+      /* Found the right packet */
+      speex_bits_read_from(&jitter->current_packet, jitter->buf[i], jitter->len[i]);
+      jitter->len[i]=-1;
+      /* Decode packet */
+      ret = speex_decode_int(jitter->dec, &jitter->current_packet, out);
+      if (ret == 0)
+      {
+         jitter->valid_bits = 1;
+      } else {
+         /* Error while decoding */
+         for (i=0;i<jitter->frame_size;i++)
+            out[i]=0;
+      }
+      jitter->loss_rate = .999*jitter->loss_rate;
+   }
+
+
+}
+
+int speex_jitter_get_pointer_timestamp(SpeexJitter *jitter)
+{
+   return jitter->pointer_timestamp;
+}

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/lbr_48k_tables.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/lbr_48k_tables.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/lbr_48k_tables.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,678 @@
+/* Copyright (C) 2002 Jean-Marc Valin 
+   File: lbr_48k_tables.c
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+   
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+   
+   - Neither the name of the Xiph.org Foundation nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+   
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+
+int dummy_epic_48k_variable=0;
+#ifdef EPIC_48K
+
+const signed char gain_cdbk_ulbr[192] = {
+-31, -48, -30, 
+-19, -10, -18, 
+-33, -22, -45, 
+-5, -56, -43, 
+-30, -56, -3, 
+-59, -17, -52, 
+-41, -60, -58, 
+-64, -47, -22, 
+-30, -31, -31, 
+-29, -14, -31, 
+-22, -37, -58, 
+-31, -44, 13, 
+-37, 0, 1, 
+-46, -55, -35, 
+-56, -14, -53, 
+-8, 1, -36, 
+-29, -15, -27, 
+-29, -39, -28, 
+-43, -5, 3, 
+-51, -27, -54, 
+10, -46, -36, 
+3, -3, -42, 
+-27, 16, -22, 
+-34, -52, 13, 
+-31, -21, -28, 
+-34, -45, -40, 
+-20, -48, 4, 
+-40, -27, 16, 
+-6, 11, -44, 
+-35, 12, -5, 
+19, -33, -37, 
+-29, 18, -32, 
+-29, -23, -19, 
+16, -47, -28, 
+-34, -30, 17, 
+-20, 2, -26, 
+-38, -40, -36, 
+15, -14, -40, 
+-39, 14, -9, 
+-15, 25, -39, 
+-26, 19, -32, 
+-39, 17, -14, 
+10, -36, -26, 
+14, -13, -40, 
+-29, -21, -12, 
+-8, 19, -39, 
+-36, -18, 15, 
+-32, -38, -38, 
+-19, 4, -23, 
+-38, -7, 11, 
+9, -10, -39, 
+-37, 24, -19, 
+-34, -5, -8, 
+-20, 23, -41, 
+-4, 17, -31, 
+-17, -26, -26, 
+-24, 28, -36, 
+-7, 15, -39, 
+-42, 16, -11, 
+-29, 14, -6, 
+-36, 28, -27, 
+-21, 5, -26, 
+11, -9, -39, 
+-38, -7, 13, 
+};
+
+
+const signed char exc_12_32_table[384] = {
+34, 55, 9, 55, 4, 44, -2, 25, 4, -6, 13, -22, 
+20, 26, -13, -56, -37, 18, 5, 28, 4, 10, 6, -7, 
+37, -24, -31, 22, 12, -6, -4, -7, 2, 0, -3, -2, 
+-16, -13, -1, 9, -2, 4, 6, 5, -3, 3, 8, -1, 
+-1, -6, -2, -1, 8, 24, 19, 33, -73, -53, 6, -18, 
+14, 7, 11, 8, -33, -94, -5, 7, 0, 44, 1, 19, 
+-9, -7, -34, -16, 8, 2, 5, 0, 3, 1, -2, 3, 
+-22, 6, -2, 12, 16, 30, 39, 25, 25, 2, 10, -2, 
+-1, -40, -6, -51, -5, -48, -9, -33, -14, -1, -24, 15, 
+104, 39, 12, -9, -20, -12, -30, -10, -31, -7, -30, -8, 
+-71, -53, -4, -11, 9, -10, 7, -10, 10, -1, 11, 8, 
+24, 14, 6, -3, 10, 8, 8, 11, -6, 11, 0, -2, 
+-6, -2, 1, -1, -3, 8, -41, 27, 57, -7, 11, -16, 
+-61, 50, 10, -10, 4, -13, 14, -7, 1, 5, -4, 4, 
+0, 2, -1, -2, -1, 1, 1, 0, -1, -1, -2, -3, 
+-3, -15, 69, 60, 10, -10, -10, -29, -21, -7, -16, 2, 
+24, -32, 24, -18, -14, -2, -11, 11, -6, 10, 1, 3, 
+24, -10, 14, 18, -13, 17, -16, 4, -3, -21, -3, -11, 
+-19, 12, -14, 26, 20, -9, 24, -15, 18, 1, -32, -2, 
+-1, 8, -3, 4, 11, -47, 7, 46, -4, -10, -10, -2, 
+-24, 29, -33, 6, -20, -3, 0, -12, 5, -30, 8, -13, 
+28, 9, 5, -11, 0, -14, -13, -22, -12, -8, -4, 1, 
+-6, 28, 45, -18, -31, -5, 1, 2, 1, 5, 0, -3, 
+-19, -10, 10, 27, 8, -16, -28, -9, 2, -5, 8, -1, 
+100, -49, 4, -43, 25, -7, 1, 9, -13, 13, -18, 13, 
+-1, -1, 0, 2, -2, -8, 9, -46, -7, 70, 23, 7, 
+-103, 20, 8, 42, -5, 21, -4, 4, 1, -8, 16, -8, 
+3, 3, 8, 4, 7, -3, -3, -4, 9, 6, 2, 13, 
+6, 3, -15, 11, -43, 31, 40, -13, 12, -21, -2, -3, 
+-10, -9, 16, -35, 31, -3, -12, 8, -34, 7, 12, 22, 
+-3, -4, -7, -12, 24, 53, -19, -43, 4, -3, -4, 6, 
+-18, -30, -58, -17, -11, 17, 23, 34, 30, 28, 28, 15, 
+};
+
+
+const signed char cdbk_lsp_vlbr[5120]={
+23, 34, 108, 100, 102, 82, 69, 48, 52, 25,
+0, -37, -55, -78, -111, -79, 58, 57, 45, 32,
+27, -9, -12, -14, -41, -29, -17, -41, 44, 35,
+-24, -68, -72, 61, 100, 73, 100, 80, 70, 37,
+12, -5, 22, 11, -10, -40, -33, -17, 19, 12,
+-20, -57, -94, -92, 56, 71, 48, 31, 22, -5,
+41, 28, 6, -6, -12, -39, -18, -16, -30, -23,
+65, 54, 41, 28, 23, 9, 26, 18, 22, 6,
+17, -16, -33, -54, -87, -79, 8, -8, 44, 35,
+-20, -62, -78, 22, 78, 47, 44, 33, 26, 14,
+8, 1, 45, 47, 72, 68, 55, 31, 36, 17,
+-27, -68, -86, -65, -10, 23, 8, -22, -31, 25,
+-4, -38, -55, -68, -96, -118, -39, 30, 28, 31,
+-21, -66, -47, 99, 91, 68, 78, 56, 64, 36,
+33, 22, 13, -13, -36, -22, 44, 37, 54, 33,
+-31, -76, -106, -100, -5, 21, 7, -17, 13, 48,
+-26, -65, -84, -84, -46, 67, 97, 66, 58, 31,
+-20, -52, -32, -20, 3, 16, 27, 40, 54, 29,
+-6, -35, -56, -64, -8, -31, -36, 21, 26, -3,
+32, 23, 1, -23, -19, -44, -45, -7, 10, -10,
+-24, -55, 2, 67, 72, 85, 90, 74, 77, 45,
+-21, -58, -45, -49, 16, 34, 13, -15, -16, 16,
+8, -31, -34, -61, -83, 10, 24, 8, 56, 25,
+-8, -49, -74, -95, -123, -77, 6, 40, 46, 42,
+-21, -60, -59, -34, -12, 27, 8, -19, -48, -17,
+-25, -66, -78, -73, -81, -16, 14, 0, -2, 33,
+78, 79, 69, 49, 44, 32, 50, 44, 46, 22,
+24, 9, -4, -18, -37, -56, 22, 34, 22, 11,
+-19, -59, -85, -41, 46, 72, 60, 33, 29, -3,
+-21, -66, -70, 65, 92, 57, 61, 41, 40, 23,
+-4, -41, -60, -72, -102, -106, 4, 56, 57, 31,
+-5, -48, -62, -91, -109, 1, 76, 54, 72, 39,
+-21, -61, -86, -46, -34, -39, 42, 25, 15, 12,
+5, -16, -36, -56, 5, 18, 11, 13, 52, 23,
+12, -6, 30, 40, 59, 40, 27, 8, 19, 6,
+25, 8, -9, -19, -25, -53, -40, -38, -46, -4,
+-17, -59, -83, 2, 58, 29, 18, -2, -17, -5,
+-35, -80, -111, -117, -41, -9, 14, 23, 36, 56,
+48, 67, 93, 71, 77, 91, 110, 95, 83, 47,
+-25, -62, -97, -93, 76, 96, 73, 52, 61, 28,
+-9, -55, -46, 49, 33, 8, 1, -25, 28, 23,
+-10, -47, -60, -45, -62, -58, 56, 57, 48, 28,
+34, 12, -9, 0, 34, 4, 6, 11, 3, -18,
+21, -9, -16, -13, -39, -41, 14, -8, 33, 28,
+-7, -49, -61, 15, 34, 3, 2, -13, -28, -17,
+-14, -50, -46, -65, -76, -13, -10, -29, -30, 22,
+-28, -68, -97, -98, -8, 38, 36, 26, 25, 15,
+6, -33, -9, 1, -28, -11, -19, -24, 61, 36,
+-15, -60, -19, 81, 58, 52, 42, 28, 66, 36,
+-15, -52, -71, -15, 11, -13, 38, 28, 11, -4,
+34, 1, -9, -27, -57, -19, 36, 6, 14, 0,
+-1, -43, -14, 16, -12, -5, -14, -29, -33, -32,
+-13, -57, -75, -100, -111, 1, 2, 13, 48, 33,
+12, 16, 100, 85, 69, 49, 40, 29, 46, 23,
+-4, -26, -41, -44, -7, -26, -39, -27, 18, 0,
+-4, -47, -51, 17, 7, -19, 13, -10, -16, 9,
+-24, -63, -93, -53, 25, 14, 73, 51, 35, 8,
+-34, -77, -106, -83, -51, -47, 2, 12, 41, 53,
+-13, -47, -67, -44, 42, 20, 24, 33, 21, -3,
+11, -15, -29, -51, -79, -88, 22, 56, 43, 20,
+11, -22, -37, -1, 61, 40, 28, 24, 22, -6,
+-3, -33, -50, -66, -93, -100, -16, -16, 3, 41,
+-18, -58, -82, -5, 95, 78, 56, 39, 30, 1,
+-6, -47, -28, -26, -36, 49, 55, 51, 71, 35,
+-6, -50, -42, -4, -32, -1, -1, -18, 67, 40,
+-23, -63, -56, -48, -32, 0, -14, -43, -46, 25,
+-17, -61, -63, 13, -1, 28, 23, 10, 67, 36,
+45, 92, 124, 111, 108, 86, 77, 56, 57, 28,
+50, 35, 13, 3, -2, -32, 3, 14, 6, -8,
+12, -17, -24, -42, -67, -23, 67, 49, 64, 38,
+-21, -60, -90, -45, 32, 6, 7, -3, -15, 9,
+-16, -62, -73, 50, 46, 18, 7, -13, 63, 39,
+19, -16, -19, 20, 5, -15, 16, -9, 5, 8,
+-11, -46, -42, -39, -55, -68, -62, -27, -18, 23,
+-23, -61, -67, -71, -29, 44, 32, 10, -15, -12,
+-6, -45, -43, -40, -67, -22, 42, 19, 61, 38,
+9, -13, -38, -37, 40, 30, 15, 9, 11, -16,
+0, -18, -29, -34, -17, -44, -50, -3, 47, 15,
+-3, -46, -26, 20, -10, 16, 20, -2, 43, 18,
+-23, -46, 46, 91, 99, 100, 99, 79, 72, 42,
+-1, -44, -33, -36, -56, 22, 17, 4, 71, 37,
+0, -38, -49, 0, -1, -30, -21, -35, -44, -6,
+-32, -74, -101, -98, -14, -21, -23, 7, 26, 45,
+8, -28, -44, -63, -96, -84, 34, 21, 13, 23,
+10, -24, -38, -17, -29, -53, -16, -41, -14, 23,
+-19, -61, -76, -12, 97, 99, 79, 60, 59, 25,
+5, -11, -26, -54, -26, -8, -13, 3, 25, 4,
+17, 16, 4, -24, -1, 42, 60, 63, 70, 37,
+10, -27, -22, -43, -62, -7, -16, 10, 75, 40,
+-26, -64, -96, -106, -3, 73, 73, 46, 55, 29,
+-2, -45, -43, 45, 46, 17, 37, 10, 30, 32,
+21, -2, -18, -28, -47, -63, -38, -56, -3, 27,
+-17, -48, -9, 9, 3, 28, 50, 58, 73, 44,
+8, -14, -32, -56, -81, -106, -35, 41, 53, 26,
+1, -38, -51, -66, -100, -61, 32, 17, 66, 42,
+17, 5, -6, -21, -26, -52, -36, 23, 56, 22,
+6, -20, -31, -22, -19, -48, 16, 38, 22, -2,
+-25, -67, -93, -51, 82, 62, 71, 69, 63, 35,
+-12, -51, -71, -60, -76, -91, -14, 41, 35, 20,
+-16, -31, 22, 32, 55, 80, 98, 91, 85, 49,
+-21, -63, -92, -6, 57, 27, 36, 11, 60, 39,
+-7, -45, -67, -81, -114, -110, 0, 24, 23, 45,
+-18, -55, -61, -56, -60, -64, -32, -2, 58, 36,
+-3, -33, -51, -24, 19, -10, -19, 4, 14, -15,
+-19, -59, -81, -12, 7, -12, 36, 16, 48, 36,
+17, -13, -32, -49, -78, -95, -1, -3, -10, 25,
+15, 5, 41, 59, 108, 101, 103, 81, 70, 35,
+-14, -52, -37, 15, 93, 83, 66, 50, 47, 15,
+-3, -31, -49, -52, -9, -31, -10, 37, 62, 27,
+-15, -56, -82, -17, 75, 56, 36, 22, 7, -16,
+-24, -63, -93, -84, 25, 94, 98, 65, 60, 31,
+-2, -45, -39, -61, -61, 48, 35, 32, 54, 18,
+-19, -51, -45, -57, -28, -8, 10, 14, 38, 26,
+-2, -46, -38, 45, 26, 22, 48, 21, 63, 40,
+-22, -61, -73, -75, -67, -31, 13, 18, 51, 34,
+-12, -2, -1, -17, -3, -27, -3, 6, -1, -15,
+-16, -59, -78, 10, 36, 9, 4, -18, 33, 22,
+-25, -62, -97, -107, 39, 87, 69, 46, 42, 12,
+11, -7, -30, -36, 19, 2, -10, -7, -4, -24,
+11, -8, 25, 28, 28, 5, -4, -10, 5, -2,
+-10, -48, -37, -17, -38, -9, -2, -19, -30, -22,
+-23, -61, -79, -81, -2, 15, -4, 17, 20, 2,
+25, -14, -3, -10, -38, 1, 14, -14, -9, -27,
+2, -18, -38, -36, -11, -39, -36, -28, -36, -11,
+32, 59, 127, 124, 127, 108, 91, 68, 64, 34,
+3, -32, -37, -10, -25, -46, 12, 1, -17, -24,
+-29, -69, -102, -100, 2, -7, 11, 14, 1, 31,
+30, -6, -4, -16, -44, -5, 3, -9, 66, 40,
+-9, -45, -52, -5, 37, 19, 26, 6, 51, 32,
+-31, -73, -96, -45, -25, -37, -15, -16, 32, 39,
+3, -15, 18, 21, 28, 33, 58, 58, 69, 42,
+-31, -73, -99, -99, -48, 14, 21, 5, 2, 39,
+7, -35, -20, 29, 2, -8, -8, -28, 38, 26,
+-5, -39, -64, -36, 15, -15, -11, -21, -23, 5,
+-8, -51, -56, 15, -1, -14, -8, -31, 36, 22,
+-8, -53, -68, -98, -101, 42, 49, 38, 41, 12,
+10, -27, -22, 4, -23, -21, 30, -1, 22, 26,
+-13, -56, -42, 31, 9, -1, -10, -2, 22, -4,
+15, 8, 56, 57, 45, 55, 57, 46, 72, 44,
+-7, -53, -26, 53, 21, 17, 0, 0, 74, 41,
+3, -18, -2, 0, 19, 17, 42, 36, 47, 26,
+24, -7, -23, -34, -62, -60, 6, -22, 18, 25,
+-11, -42, -46, -61, -83, -99, -67, -11, 28, 39,
+30, -3, -10, -1, -24, -30, -1, -28, 15, 18,
+19, -15, -10, -6, -35, -26, 33, 10, 56, 39,
+-13, -53, -82, -42, 53, 37, 18, 10, -3, -21,
+-21, -60, -89, -46, 89, 94, 71, 46, 42, 9,
+-2, -34, -44, -46, -64, -84, -1, 37, 16, 0,
+-17, -51, -65, -64, -7, -17, -29, -11, 52, 27,
+22, -15, -16, -39, -55, 26, 36, 21, 62, 28,
+-2, -26, -38, -49, -55, -80, -75, 8, 20, 9,
+-6, -47, -61, -82, -103, -17, -15, -25, 53, 40,
+-8, -47, -66, -18, 56, 43, 25, 29, 39, 3,
+-27, -66, -86, -69, -50, -59, -34, -1, 19, 42,
+3, -20, 2, 21, 72, 57, 52, 36, 31, 7,
+-12, -49, -61, -13, -1, -33, 5, 37, 26, 2,
+-27, -69, -92, -62, 2, 43, 88, 67, 64, 36,
+0, -40, -4, -6, -20, 43, 33, 25, 50, 20,
+14, -20, -30, -44, -73, -37, -24, -47, 26, 20,
+31, 53, 111, 118, 127, 126, 121, 99, 85, 46,
+-14, -45, -51, -39, 24, 5, -6, 17, 46, 14,
+-4, -43, -45, -70, -63, 8, 14, 58, 78, 39,
+-8, -47, -66, -84, -114, -55, 10, -8, 32, 40,
+28, 22, 42, 26, 8, -21, -16, -6, 22, 10,
+24, 10, 34, 31, 35, 31, 46, 39, 59, 36,
+-4, -43, -62, -10, 20, -14, 2, 14, -6, -19,
+-21, -62, -89, -22, 62, 33, 30, 16, 15, 15,
+0, -22, -31, -45, -58, -80, -66, 13, 68, 34,
+-16, -45, -6, 7, -6, -17, -14, -15, 2, 2,
+10, -5, -22, -38, -40, -70, -60, -15, -23, 0,
+22, -11, -22, -39, -67, -25, 30, 5, 58, 37,
+-21, -47, 6, 43, 37, 45, 65, 66, 73, 43,
+2, -25, -40, -53, -72, -94, -35, 24, 9, 8,
+-3, 0, -3, -9, 4, -23, -10, 20, 43, 14,
+-2, -41, -60, -9, 57, 32, 17, 16, 6, -19,
+1, -31, -36, -36, -54, -68, -77, -75, 21, 37,
+-19, -32, 79, 90, 92, 81, 67, 47, 52, 28,
+-6, -36, -57, -62, 27, 40, 21, 11, 9, -19,
+-10, -47, -49, -59, -74, -18, -14, -30, 25, 18,
+-23, -69, -82, 60, 66, 40, 75, 54, 65, 38,
+-19, -57, -92, -68, 66, 58, 34, 18, 1, -16,
+-29, -68, -99, -88, -37, -38, 13, 8, 5, 40,
+-22, -63, -75, 14, 15, 7, 75, 58, 59, 34,
+-23, -62, -82, -39, -31, -53, -27, 5, -3, 20,
+13, -26, -20, 22, 2, -3, 35, 13, 54, 39,
+32, 5, -13, -22, -45, -58, -1, -20, -19, 7,
+30, 46, 70, 55, 89, 88, 91, 67, 56, 28,
+-13, -50, -63, -25, -28, -50, -23, -32, -34, 19,
+-13, -54, -65, -9, -20, -37, 29, 6, 11, 25,
+0, -40, -55, -78, -107, -25, 47, 20, 34, 16,
+-20, -58, -96, -103, 38, 43, 27, 30, 15, -1,
+-16, -49, -52, -66, -80, -57, -44, -39, 6, 38,
+0, -38, 5, 13, -8, 23, 24, 1, 7, -9,
+-18, -56, -64, -7, 38, 13, 11, 32, 28, 0,
+14, -3, -20, -17, 4, -26, -34, -8, 19, -9,
+-23, -60, -83, -38, -8, -32, 11, 19, -1, -5,
+-5, -47, -12, 56, 38, 22, 18, -8, -5, -8,
+18, -4, -24, -16, 27, 2, -6, 5, 25, -5,
+13, 0, -19, -35, -23, -45, -59, -30, 19, 3,
+19, -12, -23, 1, -7, -35, -14, -32, -23, 4,
+-23, -64, -67, -22, -27, -5, -5, -20, 20, 5,
+20, 11, 83, 92, 85, 89, 69, 53, 80, 48,
+15, -2, -21, -29, -18, -48, -52, -12, -11, -21,
+-6, -38, -55, -68, -9, 33, 22, 19, 25, -1,
+-8, -46, -49, -67, -64, 16, 8, -6, 32, 15,
+3, -25, -46, -46, 39, 50, 34, 21, 46, 14,
+8, -33, -37, -68, -82, 31, 34, 13, 19, -6,
+33, 0, 5, -7, -32, 2, 22, -3, 35, 17,
+-23, -62, -91, -64, 6, 3, 36, 26, 7, -3,
+-12, -54, -60, 26, 46, 16, 30, 22, 8, -4,
+-23, -61, -40, 31, 58, 73, 88, 77, 74, 41,
+-2, -42, -49, 13, 5, -15, 22, -4, 26, 27,
+-13, -54, -39, 18, 2, -8, -12, 34, 56, 23,
+-20, -31, 27, 23, 24, 28, 39, 33, 47, 27,
+36, 17, -4, -20, -30, -61, -8, 20, 0, -15,
+-10, -51, -72, -82, -111, -73, 34, 25, 19, 38,
+-10, -45, -63, -55, -46, -75, -45, 34, 34, 12,
+6, -18, 29, 26, 7, -9, 0, 5, 38, 22,
+-7, -52, -16, 69, 43, 26, 23, 2, 51, 34,
+-12, -51, -59, -78, -88, 15, 20, 0, -14, 12,
+-3, -36, -59, -45, 60, 49, 28, 20, 16, -13,
+-28, -70, -90, 9, 67, 48, 90, 77, 70, 38,
+-10, -39, -58, -54, 15, -12, 3, 35, 27, -3,
+12, -1, 28, 29, 55, 53, 80, 65, 51, 23,
+-17, -61, -39, 74, 56, 43, 75, 51, 58, 36,
+-30, -71, -93, -43, -29, -26, 4, -19, -14, 37,
+3, -13, -31, -38, 11, -5, -22, -11, 43, 14,
+-25, -65, -80, -79, -71, 3, 37, 32, 20, 9,
+-20, -60, -77, -26, 18, 43, 44, 24, 22, -3,
+-4, -42, -22, -19, -45, -32, -35, -39, -46, 1,
+-25, -59, -27, -10, -7, -4, 7, 13, 25, 12,
+8, -25, -32, -47, -74, -32, 27, 6, 25, 7,
+41, 40, 62, 64, 64, 50, 54, 42, 49, 25,
+-21, -63, -88, -21, 16, -3, -4, -26, 57, 38,
+8, -25, -34, 2, -8, -28, 2, -22, 12, 23,
+-19, -49, 10, 71, 84, 71, 66, 48, 42, 22,
+-20, -58, -89, -57, 62, 44, 33, 36, 25, -1,
+-22, -55, -27, 1, 43, 37, 46, 50, 51, 26,
+1, -38, -46, 22, 34, 4, 20, -2, 3, 9,
+-4, -42, -49, -75, -89, -24, -25, 19, 71, 39,
+5, -28, -45, -43, -63, -75, -17, -38, 14, 30,
+-4, -36, -62, -59, -29, -43, -4, -16, 11, 23,
+-19, -57, -82, -39, 26, 2, -2, 20, 11, -10,
+-28, -68, -92, -70, 9, -1, -15, -30, 11, 31,
+1, -22, -41, -49, -30, -58, -48, 8, 4, -9,
+38, 41, 108, 115, 96, 98, 103, 84, 86, 51,
+15, 1, 58, 46, 26, 6, 16, 18, 41, 24,
+4, -34, -14, -27, -42, 20, 18, 2, 23, 1,
+-22, -59, -83, -70, -22, -42, -26, 29, 29, 15,
+-14, -34, 11, -1, -21, -35, -3, 1, 29, 16,
+-16, -57, -78, -7, 17, -13, 8, -13, -6, 22,
+-22, -32, -21, -20, 20, -4, 10, 13, 12, -4,
+8, -30, -30, -46, -71, -4, 3, -11, 4, -11,
+16, 5, -15, -21, 3, -23, -25, -19, -28, -32,
+-28, -68, -98, -101, -34, 19, 71, 52, 49, 30,
+-18, -57, -82, -56, -56, -66, 15, 12, 1, 29,
+-21, -62, -76, -27, -33, -38, 18, 30, 54, 32,
+3, -36, -10, -17, -34, -3, -8, 32, 63, 27,
+1, -30, -44, -20, -13, -49, -25, 3, -14, -18,
+-26, -68, -80, -46, -28, 17, 42, 37, 58, 34,
+30, 26, 57, 55, 49, 25, 16, 3, 24, 11,
+35, 35, 67, 57, 60, 82, 114, 103, 93, 55,
+18, -8, -23, -32, -53, -68, 15, 11, -6, -7,
+-2, -43, -29, 0, -28, -5, -5, -15, 25, -1,
+4, -13, -35, -45, 14, -6, -2, 19, 16, -9,
+-30, -72, -93, -93, -73, -10, -15, 6, 30, 45,
+-23, -58, -50, -55, -74, -60, -23, 0, 6, 21,
+-4, -40, -63, -24, 7, -19, 4, -18, 27, 28,
+-12, 1, 88, 76, 74, 88, 93, 90, 80, 44,
+-13, -59, -43, 52, 27, 21, 15, 12, 42, 11,
+22, -14, -17, -33, -57, -4, 5, -18, 40, 18,
+-3, -23, -43, -44, 8, -16, -14, -4, -20, -29,
+35, 45, 75, 82, 111, 117, 125, 105, 89, 51,
+-3, -38, -57, -30, 79, 71, 48, 33, 33, 0,
+-17, -62, -57, 66, 67, 35, 29, 5, 22, 17,
+3, -31, -34, -21, -44, -49, 42, 23, 24, 26,
+-23, -62, -74, -49, -30, -30, -37, -50, 9, 35,
+-17, -57, -71, -81, -45, 61, 58, 37, 31, 9,
+3, -7, 28, 14, -2, 0, 40, 41, 58, 33,
+-11, -51, -74, -17, 40, 12, 8, 13, -4, -22,
+-16, -46, -31, -35, -49, -49, -26, -9, -7, -7,
+17, -9, -24, -41, -68, -73, 38, 33, 19, 16,
+-15, -50, -47, -16, -24, -21, 59, 56, 53, 30,
+-14, -54, -57, 2, -17, -33, -34, -21, 4, -4,
+-23, -62, -93, -72, 48, 31, 21, 6, 3, 17,
+-18, -63, -79, 44, 68, 36, 45, 20, 57, 37,
+-29, -72, -99, -111, -86, -31, 7, 25, 39, 55,
+-14, -49, -53, -63, -80, -31, 24, 13, 1, -1,
+-9, -45, -55, -27, -31, -63, -23, 25, 13, -5,
+-20, -61, -80, 7, 44, 16, 54, 40, 32, 17,
+24, 7, -8, -43, -62, -54, -11, 7, 35, 27,
+-12, -55, -59, -48, -69, -4, -1, -12, 68, 39,
+-12, -31, 52, 63, 53, 34, 29, 22, 36, 19,
+-26, -66, -97, -79, 50, 41, 40, 48, 54, 28,
+-2, -37, -41, -2, -11, -30, 29, 16, 4, -2,
+40, 49, 56, 37, 39, 40, 64, 59, 67, 39,
+11, -5, 20, 14, 25, 16, 25, 22, 37, 17,
+-3, -43, -46, -10, -35, -38, -35, -39, 67, 43,
+-7, -47, -33, -39, -60, -12, -18, 11, 43, 11,
+-25, -65, -91, -76, -91, -81, 0, 13, 34, 50,
+-9, -50, -52, 17, 0, -4, 43, 18, 63, 42,
+-8, -15, 15, 41, 56, 35, 51, 45, 51, 29,
+0, -14, -24, -36, -43, -70, -39, 27, 33, 5,
+-25, -62, -81, -66, -12, -26, -16, -4, -13, 21,
+-29, -68, -60, -24, -3, 11, 18, 19, 30, 20,
+1, -35, -42, -30, -57, -51, 13, -17, 3, 22,
+-8, -27, -12, -2, -7, -21, 36, 41, 34, 12,
+-17, -56, -62, -72, -73, -17, -26, 9, 16, 13,
+11, -21, -37, -3, 16, -17, 1, -3, -18, -19,
+15, -20, -19, -22, -49, -30, -7, -29, 3, -2,
+17, -4, 11, 6, 51, 40, 36, 34, 48, 22,
+-19, -55, -29, 37, 68, 49, 45, 33, 42, 23,
+7, -30, -22, 3, -22, -36, -36, -54, 20, 22,
+20, 2, -15, -39, -59, -85, -10, 37, 21, 2,
+-15, -54, -77, -54, 74, 70, 48, 32, 51, 20,
+-25, -64, -70, -75, -52, 17, 6, -20, -30, 26,
+-13, -55, -15, 39, 16, 42, 30, 33, 62, 28,
+-21, -56, -30, -35, 6, 13, -4, -29, 33, 27,
+-17, -55, -75, -31, 3, -28, -26, 16, 18, -4,
+-13, -44, -60, -52, -9, -36, -38, 1, -9, -9,
+-12, -50, -77, -70, 43, 47, 28, 13, 43, 16,
+-13, -57, -80, -104, -113, -30, 43, 45, 52, 39,
+3, -28, -42, -37, -58, -67, 23, 4, 38, 33,
+-21, -64, -74, -22, 43, 83, 81, 56, 62, 32,
+34, 26, 23, 9, 14, 17, 26, 16, 37, 19,
+-5, -48, -49, -75, -65, 9, -6, 41, 45, 15,
+32, 30, 63, 83, 90, 91, 100, 84, 85, 52,
+-19, -54, -68, -71, 11, 30, 13, 1, 63, 37,
+44, 76, 99, 87, 117, 113, 103, 77, 64, 32,
+-16, -45, -12, 30, 27, 15, 57, 49, 42, 22,
+9, -15, -31, -28, -36, -61, -13, -18, -33, -5,
+-12, -55, -8, 82, 64, 47, 42, 21, 27, 9,
+-15, -56, -74, -12, -19, -28, 7, -16, 53, 38,
+-7, -45, -64, -55, -74, -80, 35, 45, 24, 15,
+-25, -48, -34, -42, -6, -27, -9, 9, 13, -7,
+-25, -65, -84, -35, 30, 14, 24, 39, 48, 28,
+-22, -62, -86, -51, 64, 104, 94, 61, 62, 31,
+16, -15, -25, -28, -55, -56, -10, -23, 52, 36,
+10, -10, -22, -46, -71, -92, -45, -13, 16, 26,
+-22, -65, -84, 17, 85, 55, 66, 48, 55, 31,
+-1, -38, -33, -25, -49, -15, 18, -10, 41, 30,
+-3, -24, -47, -60, -30, -46, -17, -13, -27, 1,
+-7, -41, -61, -54, -50, -78, -28, 5, -2, 20,
+17, -12, -27, -4, 8, -27, -5, 23, 14, -12,
+-36, -81, -111, -75, -17, -9, 9, 9, 39, 49,
+-13, -59, -54, 68, 51, 32, 35, 14, 64, 38,
+-11, -44, -69, -57, 11, -11, -5, 3, -16, -15,
+34, 36, 41, 16, -8, -24, 11, 23, 48, 28,
+-17, -42, 8, 17, 45, 69, 71, 55, 49, 23,
+3, -30, -46, -64, -95, -109, 2, 39, 19, 19,
+25, -13, -7, 16, -11, -5, 8, -11, 52, 33,
+-8, -37, -57, -60, 13, 7, -14, -4, 20, -7,
+7, -31, 9, 44, 20, 22, 29, 10, 52, 31,
+3, -22, -36, -53, -80, -77, -35, -41, 54, 41,
+-21, -59, -87, -83, 12, 69, 57, 36, 32, 2,
+6, -14, -34, -42, -4, -32, -27, 10, 4, -20,
+-11, -56, -59, 25, 8, -5, -9, -26, 68, 43,
+22, 13, 40, 39, 73, 81, 95, 88, 82, 45,
+-18, -62, -79, 28, 60, 28, 29, 3, 23, 25,
+6, -31, -39, -55, -85, -32, 7, -17, 48, 30,
+7, -24, -42, -8, 39, 10, 7, 11, 1, -20,
+-1, -36, -26, -30, -48, 2, 46, 26, 35, 14,
+-17, -57, -56, -10, -4, 26, 22, 6, -4, -16,
+-18, -55, -59, -67, -86, -50, 3, 29, 29, 16,
+-25, -61, -33, 2, 26, 25, 23, 10, 24, 16,
+26, 15, -8, -20, 6, -21, -16, 3, 0, -22,
+13, -17, -26, -12, -31, -48, 15, -3, 1, 14,
+4, -27, -33, -21, -29, -53, -52, -64, -42, 22,
+-11, -41, -42, -40, -42, -64, 0, 48, 50, 19,
+-13, -47, -42, -56, -50, 10, 3, -9, -30, -16,
+-4, -47, -12, 14, -13, 21, 13, 6, 73, 40,
+-15, -50, -63, -41, -31, -55, -60, -13, 28, 15,
+-6, -50, -56, -81, -95, 30, 29, 21, 71, 35,
+-14, -58, -65, 37, 40, 9, 18, -10, -4, 20,
+31, 33, 79, 106, 119, 103, 100, 77, 64, 33,
+14, 7, 56, 81, 97, 85, 85, 61, 45, 20,
+-24, -66, -74, -51, -17, 16, 5, -21, 22, 26,
+-1, -25, -38, -24, -2, -35, -26, 21, 34, 1,
+20, 15, 75, 59, 39, 26, 48, 43, 50, 29,
+26, 1, -15, -4, -9, -38, 9, 2, -9, -8,
+20, 14, 19, 13, 2, -16, 24, 25, 19, 3,
+-8, -41, -58, -78, -109, -106, -27, 9, 53, 46,
+17, 5, -13, -25, -24, -54, -20, 2, -21, -25,
+-11, -50, -48, 19, 10, -7, 46, 26, 24, 17,
+-28, -68, -69, -50, -49, -33, -7, 10, 20, 21,
+4, -36, -21, 38, 19, 1, 25, -3, 20, 22,
+-18, -58, -87, -44, 82, 73, 49, 31, 19, -7,
+-21, -61, -78, -44, -58, -66, -9, -23, 10, 40,
+-25, -66, -76, -33, -33, 6, 16, -6, -21, 5,
+-27, -69, -77, 5, -2, -7, 6, 9, 24, 6,
+1, -41, -41, -58, -79, 25, 69, 43, 68, 36,
+-28, -67, -85, -71, -34, 0, 14, 12, -2, 4,
+-2, -33, -55, -37, 37, 25, 6, 6, 29, -4,
+-8, -25, -11, -9, 40, 23, 17, 25, 37, 12,
+-21, -27, 52, 60, 47, 58, 76, 70, 69, 38,
+23, 15, 22, -8, -32, -50, -10, 3, 31, 21,
+-10, -44, -67, -61, -29, -54, 8, 39, 21, 4,
+31, 18, 30, 36, 46, 28, 50, 42, 35, 13,
+-21, -57, -24, -16, -15, 14, 3, -25, -17, 20,
+23, 6, 24, 35, 90, 72, 64, 55, 55, 23,
+7, -28, -42, -19, -36, -50, -15, -40, 29, 28,
+-21, -59, -66, -59, -6, 85, 83, 53, 54, 26,
+2, -20, -42, -52, -27, -49, 5, 9, -9, -8,
+-18, -56, -84, -72, 24, 51, 32, 20, 13, -10,
+-13, -53, -64, -39, -63, -40, 24, 0, 34, 29,
+0, -31, -45, -63, -90, -53, 3, -18, -9, 24,
+-13, -57, -71, 27, 19, -3, 25, -3, 45, 35,
+12, -9, -26, -40, -51, -78, -24, 11, -9, -6,
+-12, -49, -45, -33, -50, -48, -46, -52, 2, 25,
+-14, -56, -84, -108, -122, -50, 4, 22, 42, 53,
+-6, -44, -54, -28, -41, -61, 19, 25, 6, 1,
+-32, -75, -95, -38, -1, -15, 7, 14, 23, 23,
+11, 12, 37, 30, 38, 51, 80, 80, 82, 47,
+-19, -56, -69, -82, -98, -64, -29, 2, 28, 42,
+-18, -49, 3, 34, 41, 39, 32, 18, 21, 7,
+-8, 23, 39, 30, 30, 27, 41, 36, 44, 23,
+-16, -49, -69, -46, 1, -27, 41, 48, 35, 15,
+6, -32, -36, 5, -17, -30, 2, -16, 51, 35,
+-23, -64, -91, -21, 71, 44, 52, 44, 40, 21,
+-22, -55, -40, -20, 62, 52, 38, 29, 27, 5,
+-27, -69, -75, -6, -8, 3, -2, -30, -42, 13,
+2, -29, -42, -10, 29, 2, 15, 30, 26, 0,
+-27, -69, -85, -75, -54, -8, -14, -31, 16, 42,
+-2, -44, -54, -75, -101, -6, 4, -3, 32, 13,
+7, -3, -22, -43, -14, -27, -24, -11, -14, -12,
+-18, -57, -85, -66, 47, 86, 75, 45, 42, 10,
+18, 3, 39, 76, 80, 48, 48, 41, 44, 21,
+-13, -51, -73, -22, -15, -41, 3, -4, -22, 3,
+-10, -50, -63, -9, -23, -42, -6, -30, 11, 28,
+15, -11, -29, -39, -57, -71, -23, -40, -33, 20,
+-2, -40, -48, -5, -21, -25, 31, 7, 53, 35,
+-19, -63, -72, 39, 34, 16, 37, 17, 54, 31,
+-18, -49, -28, -27, -40, -29, 4, 4, 19, 11,
+-1, -43, -41, 24, 15, -12, -4, -31, -4, 23,
+-11, -46, -79, -74, 34, 21, 9, 15, 3, -13,
+-16, -51, -56, -55, 8, 62, 50, 30, 43, 14,
+-1, -25, -27, -32, -46, -62, -66, -36, 53, 32,
+-12, -49, -77, -50, 2, -21, 23, 6, 14, 21,
+-5, -47, -58, -77, -105, -14, 30, 9, 73, 44,
+-24, -52, -4, 10, 13, 13, 27, 27, 42, 24,
+-10, -38, -27, -15, -24, -52, -53, 1, 14, -6,
+-17, -45, -13, 2, 19, 53, 83, 79, 76, 43,
+-21, -62, -86, -48, 40, 17, 14, -9, 40, 30,
+-1, -32, -51, -33, -3, -35, 2, 17, -2, -12,
+-21, -60, -85, -70, 33, 73, 58, 37, 67, 36,
+-1, -45, -39, 37, 17, 3, 18, -8, 53, 35,
+-8, -47, -65, -61, -87, -93, 9, 9, 2, 33,
+-13, -55, -56, -19, -29, 14, 17, 6, 55, 28,
+5, 1, -7, -23, -26, -56, -39, 14, 11, -13,
+-28, -69, -89, -74, -83, -45, 1, 0, 16, 45,
+-3, 5, 91, 104, 119, 111, 97, 76, 72, 39,
+19, 5, -12, -34, -41, -72, -67, 14, 21, 1,
+-17, -49, 15, 27, 13, 6, 2, 12, 27, 10,
+-10, -30, 18, 36, 93, 87, 87, 69, 58, 26,
+37, 32, 64, 54, 53, 67, 78, 73, 80, 48,
+48, 46, 38, 9, -1, 8, 47, 44, 58, 33,
+-23, -61, -88, -76, 27, 14, 9, 36, 36, 10,
+-24, -66, -88, -97, -55, 20, 19, 16, 52, 31,
+4, -16, -1, -8, 2, 0, 15, 13, 29, 14,
+-9, -44, -66, -72, 8, 32, 37, 38, 46, 16,
+-22, -65, -62, 30, 22, 51, 57, 45, 68, 38,
+-4, -42, -53, -33, -54, -53, -4, -18, 62, 40,
+-5, -37, -61, -41, 35, 15, -2, -3, -12, -28,
+-18, -65, -55, 90, 80, 49, 44, 21, 59, 36,
+5, -16, -31, -32, -37, -62, -19, -11, 9, 16,
+-22, -60, -67, -51, -61, -35, -5, -18, -27, 24,
+-18, -55, -39, -42, -40, 20, 25, 6, 6, 7,
+0, -25, -42, -50, -59, -84, -31, -13, -22, 17,
+-32, -73, -100, -89, -21, -10, 18, 38, 31, 23,
+-15, -54, -57, -13, -18, -41, -32, 17, 50, 21,
+-16, -57, -71, -10, -8, -26, -38, -47, 42, 25,
+-17, -58, -82, -7, 33, 3, 30, 11, 13, 24,
+-23, -61, -97, -83, 82, 81, 57, 39, 31, 2,
+26, 32, 104, 86, 62, 55, 77, 70, 74, 43,
+-8, -29, -33, -52, -74, -73, -17, 14, 39, 25,
+-21, -60, -68, -22, 43, 37, 51, 54, 64, 36,
+-5, -30, -50, -52, 22, 7, 10, 13, 0, -20,
+-15, -53, -61, -34, -50, -25, 15, 6, 0, -14,
+-10, -51, -60, 20, 77, 50, 34, 22, 8, -8,
+-8, -45, -52, -59, -76, -35, -43, -49, 47, 40,
+41, 44, 53, 40, 41, 30, 38, 31, 46, 24,
+19, 3, -15, -26, -16, -45, -13, 24, 18, -5,
+-3, -39, -54, -35, -49, -70, 2, -6, -19, 15,
+-13, -53, -36, 6, -3, 45, 50, 30, 33, 10,
+15, -25, -16, -4, -32, 7, 23, 6, 67, 36,
+-21, -58, -87, -71, 10, -12, -16, 19, 10, 0,
+9, -15, -6, 25, 31, 7, 30, 28, 20, 2,
+2, -28, -42, -50, -67, -75, 12, 12, -4, 8,
+-17, -63, -58, 56, 49, 36, 60, 38, 37, 14,
+-13, -48, -38, -29, -44, -25, -20, -33, 38, 20,
+2, -37, -42, -1, -18, -42, 3, -17, -19, 12,
+-20, -60, -73, -7, 12, -13, -22, -38, 4, 10,
+-8, -41, -63, -65, 42, 63, 45, 31, 31, 0,
+-4, -46, -38, -9, -35, 15, 50, 27, 67, 39,
+3, -7, -13, -34, -51, -47, 9, 39, 54, 29,
+-29, -71, -89, -52, -39, -6, 3, 2, 38, 28,
+-14, -42, -13, -15, -19, 0, 20, 12, 37, 25,
+11, -26, -24, -40, -65, -11, -13, -27, 65, 37,
+0, -31, -46, -17, -21, -45, 11, -2, 25, 24,
+51, 91, 102, 87, 85, 63, 57, 42, 48, 23,
+-4, -34, -56, -70, -10, -14, 4, 18, 3, -8,
+-23, -59, -39, -44, -42, -14, -10, -23, -4, 17,
+-2, 4, 35, 63, 69, 75, 82, 63, 78, 48,
+-17, -55, -60, -3, -4, -19, 4, -4, -18, -29,
+2, -20, -36, -50, -32, -59, -16, 30, 16, -6,
+-12, -47, 24, 68, 45, 46, 41, 32, 65, 37,
+-4, -40, -54, -67, -96, -66, -9, -25, 42, 38,
+-15, 13, 58, 58, 84, 104, 119, 104, 89, 51,
+-15, -24, -9, -24, -27, -50, -7, 28, 29, 6,
+-7, -33, -35, -49, -65, -53, -37, -10, 33, 14,
+31, 19, 46, 72, 67, 45, 83, 68, 63, 41,
+-14, -53, -59, -17, 55, 79, 64, 39, 43, 10,
+};
+
+const signed char cdbk_lsp2_vlbr[160]={
+-20, -30, -24, 17, 7, -13, -21, 61, 56, 16,
+12, 1, 10, 77, 32, 3, 7, 3, -25, -31,
+-4, 2, -36, -83, 18, 5, -5, 5, 11, 23,
+-2, -1, -11, -12, -20, -28, 68, 50, -17, -20,
+5, 2, 1, 20, 17, 4, -52, -66, 36, 24,
+-4, -10, 7, -15, -32, 80, 37, 8, -13, -29,
+33, 37, 28, 15, 8, 14, 35, 18, 50, 36,
+-4, -1, 4, -7, 3, 3, -11, -58, -75, 13,
+13, 21, 24, -11, -12, -38, -72, 33, 15, -12,
+-44, -17, 83, 21, 2, 7, 0, 4, 0, -1,
+-25, -42, -51, 33, 20, 15, 30, -13, 9, 32,
+6, 2, -8, 7, -38, -77, 6, -13, -7, 32,
+48, 57, 32, -12, -10, -4, 2, -15, -29, -29,
+2, 10, -9, -16, 79, 44, 7, 12, -5, -18,
+-23, -29, -35, -3, -3, -18, -34, -3, -39, -50,
+-5, -10, -8, -37, -76, 11, -4, -19, 30, 16,
+};
+
+#endif

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/lpc.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/lpc.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/lpc.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -17,7 +17,7 @@
   Carsten Bormann
 
 
-   Code slightly modified by Jean-Marc Valin
+   Code modified by Jean-Marc Valin
 
    Speex License:
 
@@ -49,9 +49,17 @@
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 
+#include "lpc.h"
 
-/* LPC- and Reflection Coefficients
+#ifdef BFIN_ASM
+#include "lpc_bfin.h"
+#endif
+
+/* LPC analysis
  *
  * The next two functions calculate linear prediction coefficients
  * and/or the related reflection coefficients from the first P_MAX+1
@@ -61,59 +69,133 @@
 /* Invented by N. Levinson in 1947, modified by J. Durbin in 1959.
  */
 
-#include "lpc.h"
-
-float                      /* returns minimum mean square error    */
-wld(
-    float       * lpc, /*      [0...p-1] LPC coefficients      */
-    const float * ac,  /*  in: [0...p] autocorrelation values  */
-    float       * ref, /* out: [0...p-1] reflection coef's     */
-    int p
-    )
+/* returns minimum mean square error    */
+spx_word32_t _spx_lpc(
+spx_coef_t       *lpc, /* out: [0...p-1] LPC coefficients      */
+const spx_word16_t *ac,  /* in:  [0...p] autocorrelation values  */
+int          p
+)
 {
-   int i, j;  float r, error = ac[0];
+   int i, j;  
+   spx_word16_t r;
+   spx_word16_t error = ac[0];
 
-   if (ac[0] == 0) {
-      for (i = 0; i < p; i++) ref[i] = 0; return 0; }
+   if (ac[0] == 0)
+   {
+      for (i = 0; i < p; i++)
+         lpc[i] = 0;
+      return 0;
+   }
 
    for (i = 0; i < p; i++) {
 
-      /* Sum up this iteration's reflection coefficient.
-       */
-      r = -ac[i + 1];
-      for (j = 0; j < i; j++) r -= lpc[j] * ac[i - j];
-      ref[i] = r /= error;
-
-      /*  Update LPC coefficients and total error.
-       */
+      /* Sum up this iteration's reflection coefficient */
+      spx_word32_t rr = NEG32(SHL32(EXTEND32(ac[i + 1]),13));
+      for (j = 0; j < i; j++) 
+         rr = SUB32(rr,MULT16_16(lpc[j],ac[i - j]));
+#ifdef FIXED_POINT
+      r = DIV32_16(rr,ADD16(error,16));
+#else
+      r = rr/(error+.003*ac[0]);
+#endif
+      /*  Update LPC coefficients and total error */
       lpc[i] = r;
-      for (j = 0; j < i/2; j++) {
-         float tmp  = lpc[j];
-         lpc[j]     += r * lpc[i-1-j];
-         lpc[i-1-j] += r * tmp;
+      for (j = 0; j < i>>1; j++) 
+      {
+         spx_word16_t tmp  = lpc[j];
+         lpc[j]     = MAC16_16_Q13(lpc[j],r,lpc[i-1-j]);
+         lpc[i-1-j] = MAC16_16_Q13(lpc[i-1-j],r,tmp);
       }
-      if (i % 2) lpc[j] += lpc[j] * r;
+      if (i & 1) 
+         lpc[j] = MAC16_16_Q13(lpc[j],lpc[j],r);
 
-      error *= 1.0 - r * r;
+      error = SUB16(error,MULT16_16_Q13(r,MULT16_16_Q13(error,r)));
    }
    return error;
 }
 
 
+#ifdef FIXED_POINT
+
 /* Compute the autocorrelation
  *                      ,--,
  *              ac(i) = >  x(n) * x(n-i)  for all n
  *                      `--'
  * for lags between 0 and lag-1, and x == 0 outside 0...n-1
  */
+
+#ifndef OVERRIDE_SPEEX_AUTOCORR
 void _spx_autocorr(
-              const float * x,   /*  in: [0...n-1] samples x   */
-              float *ac,   /* out: [0...lag-1] ac values */
-              int lag, int   n)
+const spx_word16_t *x,   /*  in: [0...n-1] samples x   */
+spx_word16_t       *ac,  /* out: [0...lag-1] ac values */
+int          lag, 
+int          n
+)
 {
-   float d; int i;
-   while (lag--) {
-      for (i = lag, d = 0; i < n; i++) d += x[i] * x[i-lag];
+   spx_word32_t d;
+   int i, j;
+   spx_word32_t ac0=1;
+   int shift, ac_shift;
+   
+   for (j=0;j<n;j++)
+      ac0 = ADD32(ac0,SHR32(MULT16_16(x[j],x[j]),8));
+   ac0 = ADD32(ac0,n);
+   shift = 8;
+   while (shift && ac0<0x40000000)
+   {
+      shift--;
+      ac0 <<= 1;
+   }
+   ac_shift = 18;
+   while (ac_shift && ac0<0x40000000)
+   {
+      ac_shift--;
+      ac0 <<= 1;
+   }
+   
+   
+   for (i=0;i<lag;i++)
+   {
+      d=0;
+      for (j=i;j<n;j++)
+      {
+         d = ADD32(d,SHR32(MULT16_16(x[j],x[j-i]), shift));
+      }
+      
+      ac[i] = SHR32(d, ac_shift);
+   }
+}
+#endif
+
+
+#else
+
+
+
+/* Compute the autocorrelation
+ *                      ,--,
+ *              ac(i) = >  x(n) * x(n-i)  for all n
+ *                      `--'
+ * for lags between 0 and lag-1, and x == 0 outside 0...n-1
+ */
+void _spx_autocorr(
+const spx_word16_t *x,   /*  in: [0...n-1] samples x   */
+float       *ac,  /* out: [0...lag-1] ac values */
+int          lag, 
+int          n
+)
+{
+   float d;
+   int i;
+   while (lag--) 
+   {
+      for (i = lag, d = 0; i < n; i++) 
+         d += x[i] * x[i-lag];
       ac[lag] = d;
    }
+   ac[0] += 10;
 }
+
+#endif
+
+

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/lpc.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/lpc.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/lpc.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -33,16 +33,17 @@
 #ifndef LPC_H
 #define LPC_H
 
+#include "misc.h"
+
 void _spx_autocorr(
-              const float * x,   /*  in: [0...n-1] samples x   */
-              float *ac,   /* out: [0...lag-1] ac values */
+              const spx_word16_t * x,   /*  in: [0...n-1] samples x   */
+              spx_word16_t *ac,   /* out: [0...lag-1] ac values */
               int lag, int   n);
 
-float                      /* returns minimum mean square error    */
-wld(
-    float       * lpc, /*      [0...p-1] LPC coefficients      */
-    const float * ac,  /*  in: [0...p] autocorrelation values  */
-    float       * ref, /* out: [0...p-1] reflection coef's     */
+spx_word32_t                      /* returns minimum mean square error    */
+_spx_lpc(
+    spx_coef_t       * lpc, /*      [0...p-1] LPC coefficients      */
+    const spx_word16_t * ac,  /*  in: [0...p] autocorrelation values  */
     int p
     );
 

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/lpc_bfin.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/lpc_bfin.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/lpc_bfin.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,129 @@
+/* Copyright (C) 2005 Analog Devices
+   Author: Jean-Marc Valin 
+   File: lpc_bfin.h
+   LPC stuff (Blackfin version)
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+   
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+   
+   - Neither the name of the Xiph.org Foundation nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+   
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#define OVERRIDE_SPEEX_AUTOCORR
+void _spx_autocorr(
+const spx_word16_t *x,   /*  in: [0...n-1] samples x   */
+spx_word16_t       *ac,  /* out: [0...lag-1] ac values */
+int          lag, 
+int          n
+                  )
+{
+   spx_word32_t d;
+   const spx_word16_t *xs;
+   int i, j;
+   spx_word32_t ac0=1;
+   spx_word32_t ac32[11], *ac32top;
+   int shift, ac_shift;
+   ac32top = ac32+10;
+   int lag_1, N_lag;
+   int nshift;
+   lag_1 = lag-1;
+   N_lag = n-lag_1;
+   for (j=0;j<n;j++)
+      ac0 = ADD32(ac0,SHR32(MULT16_16(x[j],x[j]),8));
+   ac0 = ADD32(ac0,n);
+   shift = 8;
+   while (shift && ac0<0x40000000)
+   {
+      shift--;
+      ac0 <<= 1;
+   }
+   ac_shift = 18;
+   while (ac_shift && ac0<0x40000000)
+   {
+      ac_shift--;
+      ac0 <<= 1;
+   }
+   
+   xs = x+lag-1;
+   nshift = -shift;
+   __asm__ __volatile__ 
+   (
+         "P2 = %0;\n\t"
+         "I0 = P2;\n\t" /* x in I0 */
+         "B0 = P2;\n\t" /* x in B0 */
+         "R0 = %3;\n\t" /* len in R0 */
+         "P3 = %3;\n\t" /* len in R0 */
+         "P4 = %4;\n\t" /* nb_pitch in R0 */
+         "R1 = R0 << 1;\n\t" /* number of bytes in x */
+         "L0 = R1;\n\t"
+         "P0 = %1;\n\t"
+         "P1 = %2;\n\t"
+         "B1 = P1;\n\t"
+         "R4 = %5;\n\t"
+         "L1 = 0;\n\t" /*Disable looping on I1*/
+
+         "r0 = [I0++];\n\t"
+         "R2 = 0;R3=0;"
+         "LOOP pitch%= LC0 = P4 >> 1;\n\t"
+         "LOOP_BEGIN pitch%=;\n\t"
+            "I1 = P0;\n\t"
+            "A1 = A0 = 0;\n\t"
+            "R1 = [I1++];\n\t"
+            "LOOP inner_prod%= LC1 = P3 >> 1;\n\t"
+            "LOOP_BEGIN inner_prod%=;\n\t"
+               "A0 += R0.L*R1.L , A1 += R0.L*R1.H (is) || R1.L = W[I1++];\n\t"
+               "A0 += R0.H*R1.H , A1 += R0.H*R1.L (is) || R1.H = W[I1++] || R0 = [I0++];\n\t"
+            "LOOP_END inner_prod%=;\n\t"
+            "A0 = ASHIFT A0 by R4.L;\n\t"
+            "A1 = ASHIFT A1 by R4.L;\n\t"
+   
+            "R2 = A0, R3 = A1;\n\t"
+            "[P1--] = R2;\n\t"
+            "[P1--] = R3;\n\t"
+            "P0 += 4;\n\t"
+         "LOOP_END pitch%=;\n\t"
+   : : "m" (xs), "m" (x), "m" (ac32top), "m" (N_lag), "m" (lag_1), "m" (nshift)
+   : "A0", "A1", "P0", "P1", "P2", "P3", "P4", "R0", "R1", "R2", "R3", "R4", "I0", "I1", "L0", "L1", "B0", "B1", "memory"
+   );
+   d=0;
+   for (j=0;j<n;j++)
+   {
+      d = ADD32(d,SHR32(MULT16_16(x[j],x[j]), shift));
+   }
+   ac32[0] = d;
+   
+   for (i=0;i<lag;i++)
+   {
+      d=0;
+      for (j=i;j<lag_1;j++)
+      {
+         d = ADD32(d,SHR32(MULT16_16(x[j],x[j-i]), shift));
+      }
+      if (i)
+         ac32[i] += d;
+      ac[i] = SHR32(ac32[i], ac_shift);
+   }
+}
+

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/lsp.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/lsp.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/lsp.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -6,7 +6,8 @@
 	AUTHOR......: David Rowe
 	DATE CREATED: 24/2/93
 
-Modified by Jean-Marc Valin
+Heavily modified by Jean-Marc Valin (fixed-point, optimizations, 
+                                     additional functions, ...)
 
    This file contains functions for converting Linear Prediction
    Coefficients (LPC) to Line Spectral Pair (LSP) and back. Note that the
@@ -43,11 +44,15 @@
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <math.h>
 #include "lsp.h"
 #include "stack_alloc.h"
+#include "math_approx.h"
 
-
 #ifndef M_PI
 #define M_PI           3.14159265358979323846  /* pi */
 #endif
@@ -56,6 +61,70 @@
 #define NULL 0
 #endif
 
+#ifdef FIXED_POINT
+
+#define C1 8192
+#define C2 -4096
+#define C3 340
+#define C4 -10
+
+static spx_word16_t spx_cos(spx_word16_t x)
+{
+   spx_word16_t x2;
+
+   if (x<12868)
+   {
+      x2 = MULT16_16_P13(x,x);
+      return ADD32(C1, MULT16_16_P13(x2, ADD32(C2, MULT16_16_P13(x2, ADD32(C3, MULT16_16_P13(C4, x2))))));
+   } else {
+      x = SUB16(25736,x);
+      x2 = MULT16_16_P13(x,x);
+      return SUB32(-C1, MULT16_16_P13(x2, ADD32(C2, MULT16_16_P13(x2, ADD32(C3, MULT16_16_P13(C4, x2))))));
+      /*return SUB32(-C1, MULT16_16_Q13(x2, ADD32(C2, MULT16_16_Q13(C3, x2))));*/
+   }
+}
+
+
+#define FREQ_SCALE 16384
+
+/*#define ANGLE2X(a) (32768*cos(((a)/8192.)))*/
+#define ANGLE2X(a) (SHL16(spx_cos(a),2))
+
+/*#define X2ANGLE(x) (acos(.00006103515625*(x))*LSP_SCALING)*/
+#define X2ANGLE(x) (spx_acos(x))
+
+#else
+
+/*#define C1 0.99940307
+#define C2 -0.49558072
+#define C3 0.03679168*/
+
+#define C1 0.9999932946f
+#define C2 -0.4999124376f
+#define C3 0.0414877472f
+#define C4 -0.0012712095f
+
+
+#define SPX_PI_2 1.5707963268
+static inline spx_word16_t spx_cos(spx_word16_t x)
+{
+   if (x<SPX_PI_2)
+   {
+      x *= x;
+      return C1 + x*(C2+x*(C3+C4*x));
+   } else {
+      x = M_PI-x;
+      x *= x;
+      return NEG16(C1 + x*(C2+x*(C3+C4*x)));
+   }
+}
+#define FREQ_SCALE 1.
+#define ANGLE2X(a) (spx_cos(a))
+#define X2ANGLE(x) (acos(x))
+
+#endif
+
+
 /*---------------------------------------------------------------------------*\
 
 	FUNCTION....: cheb_poly_eva()
@@ -67,19 +136,67 @@
 
 \*---------------------------------------------------------------------------*/
 
+#ifdef FIXED_POINT
 
+static inline spx_word32_t cheb_poly_eva(spx_word32_t *coef,spx_word16_t x,int m,char *stack)
+/*  float coef[]  	coefficients of the polynomial to be evaluated 	*/
+/*  float x   		the point where polynomial is to be evaluated 	*/
+/*  int m 		order of the polynomial 			*/
+{
+    int i;
+    VARDECL(spx_word16_t *T);
+    spx_word32_t sum;
+    int m2=m>>1;
+    VARDECL(spx_word16_t *coefn);
 
-static float cheb_poly_eva(float *coef,float x,int m,char *stack)
+    /*Prevents overflows*/
+    if (x>16383)
+       x = 16383;
+    if (x<-16383)
+       x = -16383;
+
+    /* Allocate memory for Chebyshev series formulation */
+    ALLOC(T, m2+1, spx_word16_t);
+    ALLOC(coefn, m2+1, spx_word16_t);
+
+    for (i=0;i<m2+1;i++)
+    {
+       coefn[i] = coef[i];
+       /*printf ("%f ", coef[i]);*/
+    }
+    /*printf ("\n");*/
+
+    /* Initialise values */
+    T[0]=16384;
+    T[1]=x;
+
+    /* Evaluate Chebyshev series formulation using iterative approach  */
+    /* Evaluate polynomial and return value also free memory space */
+    sum = ADD32(EXTEND32(coefn[m2]), EXTEND32(MULT16_16_P14(coefn[m2-1],x)));
+    /*x *= 2;*/
+    for(i=2;i<=m2;i++)
+    {
+       T[i] = SUB16(MULT16_16_Q13(x,T[i-1]), T[i-2]);
+       sum = ADD32(sum, EXTEND32(MULT16_16_P14(coefn[m2-i],T[i])));
+       /*printf ("%f ", sum);*/
+    }
+    
+    /*printf ("\n");*/
+    return sum;
+}
+#else
+static float cheb_poly_eva(spx_word32_t *coef,float x,int m,char *stack)
 /*  float coef[]  	coefficients of the polynomial to be evaluated 	*/
 /*  float x   		the point where polynomial is to be evaluated 	*/
 /*  int m 		order of the polynomial 			*/
 {
     int i;
-    float *T,sum;
+    VARDECL(float *T);
+    float sum;
     int m2=m>>1;
 
     /* Allocate memory for Chebyshev series formulation */
-    T=PUSH(stack, m2+1, float);
+    ALLOC(T, m2+1, float);
 
     /* Initialise values */
     T[0]=1;
@@ -97,8 +214,8 @@
     
     return sum;
 }
+#endif
 
-
 /*---------------------------------------------------------------------------*\
 
 	FUNCTION....: lpc_to_lsp()
@@ -111,8 +228,14 @@
 
 \*---------------------------------------------------------------------------*/
 
+#ifdef FIXED_POINT
+#define SIGN_CHANGE(a,b) (((a)&0x70000000)^((b)&0x70000000)||(b==0))
+#else
+#define SIGN_CHANGE(a,b) (((a)*(b))<0.0)
+#endif
 
-int lpc_to_lsp (float *a,int lpcrdr,float *freq,int nb,float delta, char *stack)
+
+int lpc_to_lsp (spx_coef_t *a,int lpcrdr,spx_lsp_t *freq,int nb,spx_word16_t delta, char *stack)
 /*  float *a 		     	lpc coefficients			*/
 /*  int lpcrdr			order of LPC coefficients (10) 		*/
 /*  float *freq 	      	LSP frequencies in the x domain       	*/
@@ -121,27 +244,25 @@
 
 
 {
-
-    float psuml,psumr,psumm,temp_xr,xl,xr,xm=0;
-    float temp_psumr/*,temp_qsumr*/;
+    spx_word16_t temp_xr,xl,xr,xm=0;
+    spx_word32_t psuml,psumr,psumm,temp_psumr/*,temp_qsumr*/;
     int i,j,m,flag,k;
-    float *Q;                 	/* ptrs for memory allocation 		*/
-    float *P;
-    float *px;                	/* ptrs of respective P'(z) & Q'(z)	*/
-    float *qx;
-    float *p;
-    float *q;
-    float *pt;                	/* ptr used for cheb_poly_eval()
+    VARDECL(spx_word32_t *Q);                 	/* ptrs for memory allocation 		*/
+    VARDECL(spx_word32_t *P);
+    spx_word32_t *px;                	/* ptrs of respective P'(z) & Q'(z)	*/
+    spx_word32_t *qx;
+    spx_word32_t *p;
+    spx_word32_t *q;
+    spx_word32_t *pt;                	/* ptr used for cheb_poly_eval()
 				whether P' or Q' 			*/
     int roots=0;              	/* DR 8/2/94: number of roots found 	*/
     flag = 1;                	/*  program is searching for a root when,
 				1 else has found one 			*/
     m = lpcrdr/2;            	/* order of P'(z) & Q'(z) polynomials 	*/
 
-
     /* Allocate memory space for polynomials */
-    Q = PUSH(stack, (m+1), float);
-    P = PUSH(stack, (m+1), float);
+    ALLOC(Q, (m+1), spx_word32_t);
+    ALLOC(P, (m+1), spx_word32_t);
 
     /* determine P'(z)'s and Q'(z)'s coefficients where
       P'(z) = P(z)/(1 + z^(-1)) and Q'(z) = Q(z)/(1-z^(-1)) */
@@ -150,20 +271,47 @@
     qx = Q;
     p = px;
     q = qx;
-    *px++ = 1.0;
-    *qx++ = 1.0;
-    for(i=1;i<=m;i++){
-	*px++ = a[i]+a[lpcrdr+1-i]-*p++;
-	*qx++ = a[i]-a[lpcrdr+1-i]+*q++;
+
+#ifdef FIXED_POINT
+    *px++ = LPC_SCALING;
+    *qx++ = LPC_SCALING;
+    for(i=0;i<m;i++){
+       *px++ = SUB32(ADD32(EXTEND32(a[i]),EXTEND32(a[lpcrdr-i-1])), *p++);
+       *qx++ = ADD32(SUB32(EXTEND32(a[i]),EXTEND32(a[lpcrdr-i-1])), *q++);
     }
     px = P;
     qx = Q;
+    for(i=0;i<m;i++)
+    {
+       /*if (fabs(*px)>=32768)
+          speex_warning_int("px", *px);
+       if (fabs(*qx)>=32768)
+       speex_warning_int("qx", *qx);*/
+       *px = PSHR32(*px,2);
+       *qx = PSHR32(*qx,2);
+       px++;
+       qx++;
+    }
+    /* The reason for this lies in the way cheb_poly_eva() is implemented for fixed-point */
+    P[m] = PSHR32(P[m],3);
+    Q[m] = PSHR32(Q[m],3);
+#else
+    *px++ = LPC_SCALING;
+    *qx++ = LPC_SCALING;
     for(i=0;i<m;i++){
-	*px = 2**px;
-	*qx = 2**qx;
-	 px++;
-	 qx++;
+       *px++ = (a[i]+a[lpcrdr-1-i]) - *p++;
+       *qx++ = (a[i]-a[lpcrdr-1-i]) + *q++;
     }
+    px = P;
+    qx = Q;
+    for(i=0;i<m;i++){
+       *px = 2**px;
+       *qx = 2**qx;
+       px++;
+       qx++;
+    }
+#endif
+
     px = P;             	/* re-initialise ptrs 			*/
     qx = Q;
 
@@ -171,25 +319,30 @@
     Keep alternating between the two polynomials as each zero is found 	*/
 
     xr = 0;             	/* initialise xr to zero 		*/
-    xl = 1.0;               	/* start at point xl = 1 		*/
+    xl = FREQ_SCALE;               	/* start at point xl = 1 		*/
 
 
     for(j=0;j<lpcrdr;j++){
-	if(j%2)            	/* determines whether P' or Q' is eval. */
+	if(j&1)            	/* determines whether P' or Q' is eval. */
 	    pt = qx;
 	else
 	    pt = px;
 
 	psuml = cheb_poly_eva(pt,xl,lpcrdr,stack);	/* evals poly. at xl 	*/
 	flag = 1;
-	while(flag && (xr >= -1.0)){
-           float dd;
+	while(flag && (xr >= -FREQ_SCALE)){
+           spx_word16_t dd;
            /* Modified by JMV to provide smaller steps around x=+-1 */
-           dd=(delta*(1-.9*xl*xl));
+#ifdef FIXED_POINT
+           dd = MULT16_16_Q15(delta,SUB16(FREQ_SCALE, MULT16_16_Q14(MULT16_16_Q14(xl,xl),14000)));
+           if (psuml<512 && psuml>-512)
+              dd = PSHR16(dd,1);
+#else
+           dd=delta*(1-.9*xl*xl);
            if (fabs(psuml)<.2)
               dd *= .5;
-
-           xr = xl - dd;                        	/* interval spacing 	*/
+#endif
+           xr = SUB16(xl, dd);                        	/* interval spacing 	*/
 	    psumr = cheb_poly_eva(pt,xr,lpcrdr,stack);/* poly(xl-delta_x) 	*/
 	    temp_psumr = psumr;
 	    temp_xr = xr;
@@ -203,25 +356,31 @@
     between xm and xr else set interval between xl and xr and repeat till
     root is located within the specified limits 			*/
 
-	    if((psumr*psuml)<0.0){
+	    if(SIGN_CHANGE(psumr,psuml))
+            {
 		roots++;
 
 		psumm=psuml;
 		for(k=0;k<=nb;k++){
-		    xm = (xl+xr)/2;        	/* bisect the interval 	*/
+#ifdef FIXED_POINT
+		    xm = ADD16(PSHR16(xl,1),PSHR16(xr,1));        	/* bisect the interval 	*/
+#else
+                    xm = .5*(xl+xr);        	/* bisect the interval 	*/
+#endif
 		    psumm=cheb_poly_eva(pt,xm,lpcrdr,stack);
-		    if(psumm*psuml>0.){
+		    /*if(psumm*psuml>0.)*/
+		    if(!SIGN_CHANGE(psumm,psuml))
+                    {
 			psuml=psumm;
 			xl=xm;
-		    }
-		    else{
+		    } else {
 			psumr=psumm;
 			xr=xm;
 		    }
 		}
 
 	       /* once zero is found, reset initial interval to xr 	*/
-	       freq[j] = (xm);
+	       freq[j] = X2ANGLE(xm);
 	       xl = xm;
 	       flag = 0;       		/* reset flag for next search 	*/
 	    }
@@ -247,8 +406,9 @@
 
 \*---------------------------------------------------------------------------*/
 
+#ifdef FIXED_POINT
 
-void lsp_to_lpc(float *freq,float *ak,int lpcrdr, char *stack)
+void lsp_to_lpc(spx_lsp_t *freq,spx_coef_t *ak,int lpcrdr, char *stack)
 /*  float *freq 	array of LSP frequencies in the x domain	*/
 /*  float *ak 		array of LPC coefficients 			*/
 /*  int lpcrdr  	order of LPC coefficients 			*/
@@ -256,12 +416,90 @@
 
 {
     int i,j;
+    spx_word32_t xout1,xout2,xin1,xin2;
+    VARDECL(spx_word32_t *Wp);
+    spx_word32_t *pw,*n1,*n2,*n3,*n4=NULL;
+    VARDECL(spx_word16_t *freqn);
+    int m = lpcrdr>>1;
+    
+    ALLOC(freqn, lpcrdr, spx_word16_t);
+    for (i=0;i<lpcrdr;i++)
+       freqn[i] = ANGLE2X(freq[i]);
+
+    ALLOC(Wp, 4*m+2, spx_word32_t);
+    pw = Wp;
+
+
+    /* initialise contents of array */
+
+    for(i=0;i<=4*m+1;i++){       	/* set contents of buffer to 0 */
+	*pw++ = 0;
+    }
+
+    /* Set pointers up */
+
+    pw = Wp;
+    xin1 = 1048576;
+    xin2 = 1048576;
+
+    /* reconstruct P(z) and Q(z) by  cascading second order
+      polynomials in form 1 - 2xz(-1) +z(-2), where x is the
+      LSP coefficient */
+
+    for(j=0;j<=lpcrdr;j++){
+       spx_word16_t *fr=freqn;
+	for(i=0;i<m;i++){
+	    n1 = pw+(i<<2);
+	    n2 = n1 + 1;
+	    n3 = n2 + 1;
+	    n4 = n3 + 1;
+	    xout1 = ADD32(SUB32(xin1, MULT16_32_Q14(*fr,*n1)), *n2);
+            fr++;
+            xout2 = ADD32(SUB32(xin2, MULT16_32_Q14(*fr,*n3)), *n4);
+            fr++;
+	    *n2 = *n1;
+	    *n4 = *n3;
+	    *n1 = xin1;
+	    *n3 = xin2;
+	    xin1 = xout1;
+	    xin2 = xout2;
+	}
+	xout1 = xin1 + *(n4+1);
+	xout2 = xin2 - *(n4+2);
+        /* FIXME: perhaps apply bandwidth expansion in case of overflow? */
+	if (j>0)
+	{
+        if (xout1 + xout2>SHL32(EXTEND32(32766),8))
+           ak[j-1] = 32767;
+        else if (xout1 + xout2 < -SHL32(EXTEND32(32766),8))
+           ak[j-1] = -32767;
+        else
+           ak[j-1] = EXTRACT16(PSHR32(ADD32(xout1,xout2),8));
+	} else {/*speex_warning_int("ak[0] = ", EXTRACT16(PSHR32(ADD32(xout1,xout2),8)));*/}
+	*(n4+1) = xin1;
+	*(n4+2) = xin2;
+
+	xin1 = 0;
+	xin2 = 0;
+    }
+}
+#else
+
+void lsp_to_lpc(spx_lsp_t *freq,spx_coef_t *ak,int lpcrdr, char *stack)
+/*  float *freq 	array of LSP frequencies in the x domain	*/
+/*  float *ak 		array of LPC coefficients 			*/
+/*  int lpcrdr  	order of LPC coefficients 			*/
+
+
+{
+    int i,j;
     float xout1,xout2,xin1,xin2;
-    float *Wp;
+    VARDECL(float *Wp);
     float *pw,*n1,*n2,*n3,*n4=NULL;
-    int m = lpcrdr/2;
+    VARDECL(float *x_freq);
+    int m = lpcrdr>>1;
 
-    Wp = PUSH(stack, 4*m+2, float);
+    ALLOC(Wp, 4*m+2, float);
     pw = Wp;
 
     /* initialise contents of array */
@@ -276,6 +514,10 @@
     xin1 = 1.0;
     xin2 = 1.0;
 
+    ALLOC(x_freq, lpcrdr, float);
+    for (i=0;i<lpcrdr;i++)
+       x_freq[i] = ANGLE2X(freq[i]);
+
     /* reconstruct P(z) and Q(z) by  cascading second order
       polynomials in form 1 - 2xz(-1) +z(-2), where x is the
       LSP coefficient */
@@ -287,8 +529,8 @@
 	    n2 = n1 + 1;
 	    n3 = n2 + 1;
 	    n4 = n3 + 1;
-	    xout1 = xin1 - 2*(freq[i2]) * *n1 + *n2;
-	    xout2 = xin2 - 2*(freq[i2+1]) * *n3 + *n4;
+	    xout1 = xin1 - 2.f*x_freq[i2] * *n1 + *n2;
+	    xout2 = xin2 - 2.f*x_freq[i2+1] * *n3 + *n4;
 	    *n2 = *n1;
 	    *n4 = *n3;
 	    *n1 = xin1;
@@ -298,7 +540,8 @@
 	}
 	xout1 = xin1 + *(n4+1);
 	xout2 = xin2 - *(n4+2);
-	ak[j] = (xout1 + xout2)*0.5;
+	if (j>0)
+	   ak[j-1] = (xout1 + xout2)*0.5f;
 	*(n4+1) = xin1;
 	*(n4+2) = xin2;
 
@@ -307,22 +550,73 @@
     }
 
 }
+#endif
 
-/*Added by JMV
-  Makes sure the LSPs are stable*/
-void lsp_enforce_margin(float *lsp, int len, float margin)
+
+#ifdef FIXED_POINT
+
+/*Makes sure the LSPs are stable*/
+void lsp_enforce_margin(spx_lsp_t *lsp, int len, spx_word16_t margin)
 {
    int i;
-   if (lsp[0]<margin)
-      lsp[0]=margin;
-   if (lsp[len-1]>M_PI-margin)
-      lsp[len-1]=M_PI-margin;
+   spx_word16_t m = margin;
+   spx_word16_t m2 = 25736-margin;
+  
+   if (lsp[0]<m)
+      lsp[0]=m;
+   if (lsp[len-1]>m2)
+      lsp[len-1]=m2;
    for (i=1;i<len-1;i++)
    {
-      if (lsp[i]<lsp[i-1]+margin)
-         lsp[i]=lsp[i-1]+margin;
+      if (lsp[i]<lsp[i-1]+m)
+         lsp[i]=lsp[i-1]+m;
 
-      if (lsp[i]>lsp[i+1]-margin)
-         lsp[i]= .5* (lsp[i] + lsp[i+1]-margin);
+      if (lsp[i]>lsp[i+1]-m)
+         lsp[i]= SHR16(lsp[i],1) + SHR16(lsp[i+1]-m,1);
    }
 }
+
+
+void lsp_interpolate(spx_lsp_t *old_lsp, spx_lsp_t *new_lsp, spx_lsp_t *interp_lsp, int len, int subframe, int nb_subframes)
+{
+   int i;
+   spx_word16_t tmp = DIV32_16(SHL32(EXTEND32(1 + subframe),14),nb_subframes);
+   spx_word16_t tmp2 = 16384-tmp;
+   for (i=0;i<len;i++)
+   {
+      interp_lsp[i] = MULT16_16_P14(tmp2,old_lsp[i]) + MULT16_16_P14(tmp,new_lsp[i]);
+   }
+}
+
+#else
+
+/*Makes sure the LSPs are stable*/
+void lsp_enforce_margin(spx_lsp_t *lsp, int len, spx_word16_t margin)
+{
+   int i;
+   if (lsp[0]<LSP_SCALING*margin)
+      lsp[0]=LSP_SCALING*margin;
+   if (lsp[len-1]>LSP_SCALING*(M_PI-margin))
+      lsp[len-1]=LSP_SCALING*(M_PI-margin);
+   for (i=1;i<len-1;i++)
+   {
+      if (lsp[i]<lsp[i-1]+LSP_SCALING*margin)
+         lsp[i]=lsp[i-1]+LSP_SCALING*margin;
+
+      if (lsp[i]>lsp[i+1]-LSP_SCALING*margin)
+         lsp[i]= .5f* (lsp[i] + lsp[i+1]-LSP_SCALING*margin);
+   }
+}
+
+
+void lsp_interpolate(spx_lsp_t *old_lsp, spx_lsp_t *new_lsp, spx_lsp_t *interp_lsp, int len, int subframe, int nb_subframes)
+{
+   int i;
+   float tmp = (1.0f + subframe)/nb_subframes;
+   for (i=0;i<len;i++)
+   {
+      interp_lsp[i] = (1-tmp)*old_lsp[i] + tmp*new_lsp[i];
+   }
+}
+
+#endif

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/lsp.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/lsp.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/lsp.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -47,11 +47,14 @@
 #ifndef __AK2LSPD__
 #define __AK2LSPD__
 
-int lpc_to_lsp (float *a, int lpcrdr, float *freq, int nb, float delta, char *stack);
-void lsp_to_lpc(float *freq, float *ak, int lpcrdr, char *stack);
+#include "misc.h"
 
+int lpc_to_lsp (spx_coef_t *a, int lpcrdr, spx_lsp_t *freq, int nb, spx_word16_t delta, char *stack);
+void lsp_to_lpc(spx_lsp_t *freq, spx_coef_t *ak, int lpcrdr, char *stack);
+
 /*Added by JMV*/
-void lsp_enforce_margin(float *lsp, int len, float margin);
+void lsp_enforce_margin(spx_lsp_t *lsp, int len, spx_word16_t margin);
 
+void lsp_interpolate(spx_lsp_t *old_lsp, spx_lsp_t *new_lsp, spx_lsp_t *interp_lsp, int len, int subframe, int nb_subframes);
 
 #endif	/* __AK2LSPD__ */

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/lsp_tables_nb.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/lsp_tables_nb.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/lsp_tables_nb.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -29,7 +29,7 @@
    POSSIBILITY OF SUCH DAMAGE.
 */
 
-signed char cdbk_nb[640]={
+const signed char cdbk_nb[640]={
 30,19,38,34,40,32,46,43,58,43,
 5,-18,-25,-40,-33,-55,-52,20,34,28,
 -20,-63,-97,-92,61,53,47,49,53,75,
@@ -95,7 +95,7 @@
 -6,-41,-67,6,-2,-9,19,2,85,74,
 -22,-67,-84,-71,-50,3,11,-9,2,62};
 
-signed char cdbk_nb_low1[320]={
+const signed char cdbk_nb_low1[320]={
 -34,-52,-15,45,2,
 23,21,52,24,-33,
 -9,-1,9,-44,-41,
@@ -161,7 +161,7 @@
 13,20,20,-19,-22,
 -2,-8,2,51,-51};
 
-signed char cdbk_nb_low2[320]={
+const signed char cdbk_nb_low2[320]={
 -6,53,-21,-24,4,
 26,17,-4,-37,25,
 17,-36,-13,31,3,
@@ -227,7 +227,7 @@
 -23,-29,-16,1,-3,
 -8,-10,31,64,-65};
 
-signed char cdbk_nb_high1[320]={
+const signed char cdbk_nb_high1[320]={
 -26,-8,29,21,4,
 19,-39,33,-7,-36,
 56,54,48,40,29,
@@ -293,7 +293,7 @@
 29,17,8,-29,-39,
 -69,18,15,-15,-5};
 
-signed char cdbk_nb_high2[320]={
+const signed char cdbk_nb_high2[320]={
 11,47,16,-9,-46,
 -32,26,-64,34,-5,
 38,-7,47,20,2,

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/ltp.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/ltp.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/ltp.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -30,94 +30,232 @@
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <math.h>
 #include "ltp.h"
 #include "stack_alloc.h"
 #include "filters.h"
 #include <speex/speex_bits.h>
+#include "math_approx.h"
 
+#ifndef NULL
+#define NULL 0
+#endif
+
+
 #ifdef _USE_SSE
 #include "ltp_sse.h"
+#elif defined (ARM4_ASM) || defined(ARM5E_ASM)
+#include "ltp_arm4.h"
+#elif defined (BFIN_ASM)
+#include "ltp_bfin.h"
+#endif
+
+#ifndef OVERRIDE_INNER_PROD
+static spx_word32_t inner_prod(const spx_word16_t *x, const spx_word16_t *y, int len)
+{
+   spx_word32_t sum=0;
+   len >>= 2;
+   while(len--)
+   {
+      spx_word32_t part=0;
+      part = MAC16_16(part,*x++,*y++);
+      part = MAC16_16(part,*x++,*y++);
+      part = MAC16_16(part,*x++,*y++);
+      part = MAC16_16(part,*x++,*y++);
+      /* HINT: If you had a 40-bit accumulator, you could shift only at the end */
+      sum = ADD32(sum,SHR32(part,6));
+   }
+   return sum;
+}
+#endif
+
+#ifndef OVERRIDE_PITCH_XCORR
+#if 0 /* HINT: Enable this for machines with enough registers (i.e. not x86) */
+static void pitch_xcorr(const spx_word16_t *_x, const spx_word16_t *_y, spx_word32_t *corr, int len, int nb_pitch, char *stack)
+{
+   int i,j;
+   for (i=0;i<nb_pitch;i+=4)
+   {
+      /* Compute correlation*/
+      /*corr[nb_pitch-1-i]=inner_prod(x, _y+i, len);*/
+      spx_word32_t sum1=0;
+      spx_word32_t sum2=0;
+      spx_word32_t sum3=0;
+      spx_word32_t sum4=0;
+      const spx_word16_t *y = _y+i;
+      const spx_word16_t *x = _x;
+      spx_word16_t y0, y1, y2, y3;
+      /*y0=y[0];y1=y[1];y2=y[2];y3=y[3];*/
+      y0=*y++;
+      y1=*y++;
+      y2=*y++;
+      y3=*y++;
+      for (j=0;j<len;j+=4)
+      {
+         spx_word32_t part1;
+         spx_word32_t part2;
+         spx_word32_t part3;
+         spx_word32_t part4;
+         part1 = MULT16_16(*x,y0);
+         part2 = MULT16_16(*x,y1);
+         part3 = MULT16_16(*x,y2);
+         part4 = MULT16_16(*x,y3);
+         x++;
+         y0=*y++;
+         part1 = MAC16_16(part1,*x,y1);
+         part2 = MAC16_16(part2,*x,y2);
+         part3 = MAC16_16(part3,*x,y3);
+         part4 = MAC16_16(part4,*x,y0);
+         x++;
+         y1=*y++;
+         part1 = MAC16_16(part1,*x,y2);
+         part2 = MAC16_16(part2,*x,y3);
+         part3 = MAC16_16(part3,*x,y0);
+         part4 = MAC16_16(part4,*x,y1);
+         x++;
+         y2=*y++;
+         part1 = MAC16_16(part1,*x,y3);
+         part2 = MAC16_16(part2,*x,y0);
+         part3 = MAC16_16(part3,*x,y1);
+         part4 = MAC16_16(part4,*x,y2);
+         x++;
+         y3=*y++;
+         
+         sum1 = ADD32(sum1,SHR32(part1,6));
+         sum2 = ADD32(sum2,SHR32(part2,6));
+         sum3 = ADD32(sum3,SHR32(part3,6));
+         sum4 = ADD32(sum4,SHR32(part4,6));
+      }
+      corr[nb_pitch-1-i]=sum1;
+      corr[nb_pitch-2-i]=sum2;
+      corr[nb_pitch-3-i]=sum3;
+      corr[nb_pitch-4-i]=sum4;
+   }
+
+}
 #else
-static float inner_prod(float *x, float *y, int len)
+static void pitch_xcorr(const spx_word16_t *_x, const spx_word16_t *_y, spx_word32_t *corr, int len, int nb_pitch, char *stack)
 {
    int i;
-   float sum1=0,sum2=0,sum3=0,sum4=0;
-   for (i=0;i<len;)
+   for (i=0;i<nb_pitch;i++)
    {
-      sum1 += x[i]*y[i];
-      sum2 += x[i+1]*y[i+1];
-      sum3 += x[i+2]*y[i+2];
-      sum4 += x[i+3]*y[i+3];
-      i+=4;
+      /* Compute correlation*/
+      corr[nb_pitch-1-i]=inner_prod(_x, _y+i, len);
    }
-   return sum1+sum2+sum3+sum4;
+
 }
 #endif
+#endif
 
-/*Original, non-optimized version*/
-/*static float inner_prod(float *x, float *y, int len)
+#ifndef OVERRIDE_COMPUTE_PITCH_ERROR
+static inline spx_word32_t compute_pitch_error(spx_word32_t *C, spx_word16_t *g, spx_word16_t pitch_control)
 {
-   int i;
-   float sum=0;
-   for (i=0;i<len;i++)
-      sum += x[i]*y[i];
+   spx_word32_t sum = 0;
+   sum = ADD32(sum,MULT16_32_Q15(MULT16_16_16(g[0],pitch_control),C[0]));
+   sum = ADD32(sum,MULT16_32_Q15(MULT16_16_16(g[1],pitch_control),C[1]));
+   sum = ADD32(sum,MULT16_32_Q15(MULT16_16_16(g[2],pitch_control),C[2]));
+   sum = SUB32(sum,MULT16_32_Q15(MULT16_16_16(g[0],g[1]),C[3]));
+   sum = SUB32(sum,MULT16_32_Q15(MULT16_16_16(g[2],g[1]),C[4]));
+   sum = SUB32(sum,MULT16_32_Q15(MULT16_16_16(g[2],g[0]),C[5]));
+   sum = SUB32(sum,MULT16_32_Q15(MULT16_16_16(g[0],g[0]),C[6]));
+   sum = SUB32(sum,MULT16_32_Q15(MULT16_16_16(g[1],g[1]),C[7]));
+   sum = SUB32(sum,MULT16_32_Q15(MULT16_16_16(g[2],g[2]),C[8]));
    return sum;
 }
-*/
+#endif
 
-
-void open_loop_nbest_pitch(float *sw, int start, int end, int len, int *pitch, float *gain, int N, char *stack)
+void open_loop_nbest_pitch(spx_sig_t *sw, int start, int end, int len, int *pitch, spx_word16_t *gain, int N, char *stack)
 {
    int i,j,k;
-   /*float corr=0;*/
-   /*float energy;*/
-   float *best_score;
-   float e0;
-   float *corr, *energy, *score;
+   VARDECL(spx_word32_t *best_score);
+   spx_word32_t e0;
+   VARDECL(spx_word32_t *corr);
+   VARDECL(spx_word32_t *energy);
+   VARDECL(spx_word32_t *score);
+   VARDECL(spx_word16_t *swn2);
+   spx_word16_t *swn;
 
-   best_score = PUSH(stack,N, float);
-   corr = PUSH(stack,end-start+1, float);
-   energy = PUSH(stack,end-start+2, float);
-   score = PUSH(stack,end-start+1, float);
+   ALLOC(best_score, N, spx_word32_t);
+   ALLOC(corr, end-start+1, spx_word32_t);
+   ALLOC(energy, end-start+2, spx_word32_t);
+   ALLOC(score, end-start+1, spx_word32_t);
+
+#ifdef FIXED_POINT
+   ALLOC(swn2, end+len, spx_word16_t);
+   normalize16(sw-end, swn2, 16384, end+len);
+   swn = swn2 + end;
+#else
+   swn = sw;
+#endif
+
    for (i=0;i<N;i++)
    {
         best_score[i]=-1;
-        gain[i]=0;
         pitch[i]=start;
    }
-   energy[0]=inner_prod(sw-start, sw-start, len);
-   e0=inner_prod(sw, sw, len);
+
+
+   energy[0]=inner_prod(swn-start, swn-start, len);
+   e0=inner_prod(swn, swn, len);
    for (i=start;i<=end;i++)
    {
       /* Update energy for next pitch*/
-      energy[i-start+1] = energy[i-start] + sw[-i-1]*sw[-i-1] - sw[-i+len-1]*sw[-i+len-1];
-      if (energy[i-start+1] < 1)
-         energy[i-start+1]=1; 
+      energy[i-start+1] = SUB32(ADD32(energy[i-start],SHR32(MULT16_16(swn[-i-1],swn[-i-1]),6)), SHR32(MULT16_16(swn[-i+len-1],swn[-i+len-1]),6));
    }
-   for (i=start;i<=end;i++)
+
+   pitch_xcorr(swn, swn-end, corr, len, end-start+1, stack);
+
+#ifdef FIXED_POINT
    {
-      corr[i-start]=0;
-      score[i-start]=0;
+      VARDECL(spx_word16_t *corr16);
+      VARDECL(spx_word16_t *ener16);
+      ALLOC(corr16, end-start+1, spx_word16_t);
+      ALLOC(ener16, end-start+1, spx_word16_t);
+      normalize16(corr, corr16, 16384, end-start+1);
+      normalize16(energy, ener16, 16384, end-start+1);
+
+      for (i=start;i<=end;i++)
+      {
+         spx_word16_t g;
+         spx_word32_t tmp;
+         tmp = corr16[i-start];
+         if (tmp>0)
+         {
+            if (SHR16(corr16[i-start],4)>ener16[i-start])
+               tmp = SHL32(EXTEND32(ener16[i-start]),14);
+            else if (-SHR16(corr16[i-start],4)>ener16[i-start])
+               tmp = -SHL32(EXTEND32(ener16[i-start]),14);
+            else
+               tmp = SHL32(tmp,10);
+            g = DIV32_16(tmp, 8+ener16[i-start]);
+            score[i-start] = MULT16_16(corr16[i-start],g);
+         } else
+         {
+            score[i-start] = 1;
+         }
+      }
    }
-
+#else
    for (i=start;i<=end;i++)
    {
-      /* Compute correlation*/
-      corr[i-start]=inner_prod(sw, sw-i, len);
-      score[i-start]=corr[i-start]*corr[i-start]/(energy[i-start]+1);
+      float g = corr[i-start]/(1+energy[i-start]);
+      if (g>16)
+         g = 16;
+      else if (g<-16)
+         g = -16;
+      score[i-start] = g*corr[i-start];
    }
+#endif
+
+   /* Extract best scores */
    for (i=start;i<=end;i++)
    {
       if (score[i-start]>best_score[N-1])
       {
-         float g1, g;
-         g1 = corr[i-start]/(energy[i-start]+10);
-         g = sqrt(g1*corr[i-start]/(e0+10));
-         if (g>g1)
-            g=g1;
-         if (g<0)
-            g=0;
          for (j=0;j<N;j++)
          {
             if (score[i-start] > best_score[j])
@@ -126,66 +264,79 @@
                {
                   best_score[k]=best_score[k-1];
                   pitch[k]=pitch[k-1];
-                  gain[k] = gain[k-1];
                }
                best_score[j]=score[i-start];
                pitch[j]=i;
-               gain[j]=g;
                break;
             }
          }
       }
    }
 
+   /* Compute open-loop gain */
+   if (gain)
+   {
+       for (j=0;j<N;j++)
+       {
+          spx_word16_t g;
+          i=pitch[j];
+          g = DIV32(corr[i-start], 10+SHR32(MULT16_16(spx_sqrt(e0),spx_sqrt(energy[i-start])),6));
+          /* FIXME: g = max(g,corr/energy) */
+                   if (g<0)
+                   g = 0;
+             gain[j]=g;
+       }
+   }
 }
 
 
-
-
 /** Finds the best quantized 3-tap pitch predictor by analysis by synthesis */
-float pitch_gain_search_3tap(
-float target[],                 /* Target vector */
-float ak[],                     /* LPCs for this subframe */
-float awk1[],                   /* Weighted LPCs #1 for this subframe */
-float awk2[],                   /* Weighted LPCs #2 for this subframe */
-float exc[],                    /* Excitation */
-void *par,
+static spx_word64_t pitch_gain_search_3tap(
+const spx_sig_t target[],       /* Target vector */
+const spx_coef_t ak[],          /* LPCs for this subframe */
+const spx_coef_t awk1[],        /* Weighted LPCs #1 for this subframe */
+const spx_coef_t awk2[],        /* Weighted LPCs #2 for this subframe */
+spx_sig_t exc[],                /* Excitation */
+const void *par,
 int   pitch,                    /* Pitch value */
 int   p,                        /* Number of LPC coeffs */
 int   nsf,                      /* Number of samples in subframe */
 SpeexBits *bits,
 char *stack,
-float *exc2,
-float *r,
-int  *cdbk_index
+const spx_sig_t *exc2,
+const spx_word16_t *r,
+spx_sig_t *new_target,
+int  *cdbk_index,
+int cdbk_offset,
+int plc_tuning
 )
 {
    int i,j;
-   float *tmp, *tmp2;
-   float *x[3];
-   float *e[3];
-   float corr[3];
-   float A[3][3];
-   float gain[3];
+   VARDECL(spx_sig_t *tmp1);
+   VARDECL(spx_sig_t *tmp2);
+   spx_sig_t *x[3];
+   spx_sig_t *e[3];
+   spx_word32_t corr[3];
+   spx_word32_t A[3][3];
    int   gain_cdbk_size;
-   signed char *gain_cdbk;
-   float err1,err2;
+   const signed char *gain_cdbk;
+   spx_word16_t gain[3];
+   spx_word64_t err;
 
-   ltp_params *params;
-   params = (ltp_params*) par;
-   gain_cdbk=params->gain_cdbk;
-   gain_cdbk_size=1<<params->gain_bits;
-   tmp = PUSH(stack, 3*nsf, float);
-   tmp2 = PUSH(stack, 3*nsf, float);
+   const ltp_params *params;
+   params = (const ltp_params*) par;
+   gain_cdbk_size = 1<<params->gain_bits;
+   gain_cdbk = params->gain_cdbk + 3*gain_cdbk_size*cdbk_offset;
+   ALLOC(tmp1, 3*nsf, spx_sig_t);
+   ALLOC(tmp2, 3*nsf, spx_sig_t);
 
-   x[0]=tmp;
-   x[1]=tmp+nsf;
-   x[2]=tmp+2*nsf;
-
+   x[0]=tmp1;
+   x[1]=tmp1+nsf;
+   x[2]=tmp1+2*nsf;
+   
    e[0]=tmp2;
    e[1]=tmp2+nsf;
    e[2]=tmp2+2*nsf;
-   
    for (i=2;i>=0;i--)
    {
       int pp=pitch+1-i;
@@ -206,130 +357,253 @@
             x[i][j+1]=x[i+1][j];
          x[i][0]=0;
          for (j=0;j<nsf;j++)
-            x[i][j]+=e[i][0]*r[j];
+         {
+            x[i][j]=ADD32(x[i][j],SHL32(MULT16_32_Q15(r[j], e[i][0]),1));
+         }
       }
    }
 
-   for (i=0;i<3;i++)
-      corr[i]=inner_prod(x[i],target,nsf);
-   
-   for (i=0;i<3;i++)
-      for (j=0;j<=i;j++)
-         A[i][j]=A[j][i]=inner_prod(x[i],x[j],nsf);
-   
+#ifdef FIXED_POINT
    {
-      float C[9];
-      signed char *ptr=gain_cdbk;
+      /* If using fixed-point, we need to normalize the signals first */
+      spx_word16_t *y[3];
+      VARDECL(spx_word16_t *ytmp);
+      VARDECL(spx_word16_t *t);
+
+      spx_sig_t max_val=1;
+      int sig_shift;
+      
+      ALLOC(ytmp, 3*nsf, spx_word16_t);
+#if 0
+      ALLOC(y[0], nsf, spx_word16_t);
+      ALLOC(y[1], nsf, spx_word16_t);
+      ALLOC(y[2], nsf, spx_word16_t);
+#else
+      y[0] = ytmp;
+      y[1] = ytmp+nsf;
+      y[2] = ytmp+2*nsf;
+#endif
+      ALLOC(t, nsf, spx_word16_t);
+      for (j=0;j<3;j++)
+      {
+         for (i=0;i<nsf;i++)
+         {
+            spx_sig_t tmp = x[j][i];
+            if (tmp<0)
+               tmp = -tmp;
+            if (tmp > max_val)
+               max_val = tmp;
+         }
+      }
+      for (i=0;i<nsf;i++)
+      {
+         spx_sig_t tmp = target[i];
+         if (tmp<0)
+            tmp = -tmp;
+         if (tmp > max_val)
+            max_val = tmp;
+      }
+
+      sig_shift=0;
+      while (max_val>16384)
+      {
+         sig_shift++;
+         max_val >>= 1;
+      }
+
+      for (j=0;j<3;j++)
+      {
+         for (i=0;i<nsf;i++)
+         {
+            y[j][i] = EXTRACT16(SHR32(x[j][i],sig_shift));
+         }
+      }
+      for (i=0;i<nsf;i++)
+      {
+         t[i] = EXTRACT16(SHR32(target[i],sig_shift));
+      }
+
+      for (i=0;i<3;i++)
+         corr[i]=inner_prod(y[i],t,nsf);
+      
+      for (i=0;i<3;i++)
+         for (j=0;j<=i;j++)
+            A[i][j]=A[j][i]=inner_prod(y[i],y[j],nsf);
+   }
+#else
+   {
+      for (i=0;i<3;i++)
+         corr[i]=inner_prod(x[i],target,nsf);
+      
+      for (i=0;i<3;i++)
+         for (j=0;j<=i;j++)
+            A[i][j]=A[j][i]=inner_prod(x[i],x[j],nsf);
+   }
+#endif
+
+   {
+      spx_word32_t C[9];
+      const signed char *ptr=gain_cdbk;
       int best_cdbk=0;
-      float best_sum=0;
+      spx_word32_t best_sum=0;
       C[0]=corr[2];
       C[1]=corr[1];
       C[2]=corr[0];
       C[3]=A[1][2];
       C[4]=A[0][1];
-      C[5]=A[0][2];
+      C[5]=A[0][2];      
       C[6]=A[2][2];
       C[7]=A[1][1];
       C[8]=A[0][0];
       
+      /*plc_tuning *= 2;*/
+      if (plc_tuning<2)
+         plc_tuning=2;
+#ifdef FIXED_POINT
+      C[0] = MAC16_32_Q15(C[0],MULT16_16_16(plc_tuning,-327),C[0]);
+      C[1] = MAC16_32_Q15(C[1],MULT16_16_16(plc_tuning,-327),C[1]);
+      C[2] = MAC16_32_Q15(C[2],MULT16_16_16(plc_tuning,-327),C[2]);
+      C[0] = SHL32(C[0],1);
+      C[1] = SHL32(C[1],1);
+      C[2] = SHL32(C[2],1);
+      C[3] = SHL32(C[3],1);
+      C[4] = SHL32(C[4],1);
+      C[5] = SHL32(C[5],1);
+#else
+      C[0]*=1-.01*plc_tuning;
+      C[1]*=1-.01*plc_tuning;
+      C[2]*=1-.01*plc_tuning;
+      C[6]*=.5*(1+.01*plc_tuning);
+      C[7]*=.5*(1+.01*plc_tuning);
+      C[8]*=.5*(1+.01*plc_tuning);
+#endif
       for (i=0;i<gain_cdbk_size;i++)
       {
-         float sum=0;
-         float g0,g1,g2;
+         spx_word32_t sum=0;
+         spx_word16_t g[3];
+         spx_word16_t pitch_control=64;
+         spx_word16_t gain_sum;
+         
          ptr = gain_cdbk+3*i;
-         g0=0.015625*ptr[0]+.5;
-         g1=0.015625*ptr[1]+.5;
-         g2=0.015625*ptr[2]+.5;
+         g[0]=ADD16((spx_word16_t)ptr[0],32);
+         g[1]=ADD16((spx_word16_t)ptr[1],32);
+         g[2]=ADD16((spx_word16_t)ptr[2],32);
 
-         sum += C[0]*g0;
-         sum += C[1]*g1;
-         sum += C[2]*g2;
-         sum -= C[3]*g0*g1;
-         sum -= C[4]*g2*g1;
-         sum -= C[5]*g2*g0;
-         sum -= .5*C[6]*g0*g0;
-         sum -= .5*C[7]*g1*g1;
-         sum -= .5*C[8]*g2*g2;
-
-         /* If 1, force "safe" pitch values to handle packet loss better */
-         if (0) {
-            float tot = fabs(ptr[1]);
-            if (ptr[0]>0)
-               tot+=ptr[0];
-            if (ptr[2]>0)
-               tot+=ptr[2];
-            if (tot>1)
-               continue;
+         /* We favor "safe" pitch values to handle packet loss better */
+         gain_sum = ADD16(ADD16(g[1],MAX16(g[0], 0)),MAX16(g[2], 0));
+         if (gain_sum > 64)
+         {
+            gain_sum = SUB16(gain_sum, 64);
+            if (gain_sum > 127)
+               gain_sum = 127;
+#ifdef FIXED_POINT
+            pitch_control =  SUB16(64,EXTRACT16(PSHR32(MULT16_16(64,MULT16_16_16(plc_tuning, gain_sum)),10)));
+#else
+            pitch_control = 64*(1.-.001*plc_tuning*gain_sum);
+#endif
+            if (pitch_control < 0)
+               pitch_control = 0;
          }
-
+         
+         sum = compute_pitch_error(C, g, pitch_control);
+         
          if (sum>best_sum || i==0)
          {
             best_sum=sum;
             best_cdbk=i;
          }
       }
+#ifdef FIXED_POINT
+      gain[0] = ADD16(32,(spx_word16_t)gain_cdbk[best_cdbk*3]);
+      gain[1] = ADD16(32,(spx_word16_t)gain_cdbk[best_cdbk*3+1]);
+      gain[2] = ADD16(32,(spx_word16_t)gain_cdbk[best_cdbk*3+2]);
+      /*printf ("%d %d %d %d\n",gain[0],gain[1],gain[2], best_cdbk);*/
+#else
       gain[0] = 0.015625*gain_cdbk[best_cdbk*3]  + .5;
       gain[1] = 0.015625*gain_cdbk[best_cdbk*3+1]+ .5;
       gain[2] = 0.015625*gain_cdbk[best_cdbk*3+2]+ .5;
-
+#endif
       *cdbk_index=best_cdbk;
    }
+
+#ifdef FIXED_POINT
+   for (i=0;i<nsf;i++)
+     exc[i]=SHL32(ADD32(ADD32(MULT16_32_Q15(SHL16(gain[0],7),e[2][i]), MULT16_32_Q15(SHL16(gain[1],7),e[1][i])),
+                        MULT16_32_Q15(SHL16(gain[2],7),e[0][i])), 2);
    
+   err=0;
    for (i=0;i<nsf;i++)
+   {
+      spx_word16_t perr2;
+      spx_sig_t tmp = SHL32(ADD32(ADD32(MULT16_32_Q15(SHL16(gain[0],7),x[2][i]),MULT16_32_Q15(SHL16(gain[1],7),x[1][i])),
+                                  MULT16_32_Q15(SHL16(gain[2],7),x[0][i])),2);
+      spx_sig_t perr=SUB32(target[i],tmp);
+      new_target[i] = SUB32(target[i], tmp);
+      perr2 = EXTRACT16(PSHR32(perr,15));
+      err = ADD64(err,MULT16_16(perr2,perr2));
+      
+   }
+#else
+   for (i=0;i<nsf;i++)
       exc[i]=gain[0]*e[2][i]+gain[1]*e[1][i]+gain[2]*e[0][i];
    
-   err1=0;
-   err2=0;
+   err=0;
    for (i=0;i<nsf;i++)
-      err1+=target[i]*target[i];
-   for (i=0;i<nsf;i++)
-      err2+=(target[i]-gain[2]*x[0][i]-gain[1]*x[1][i]-gain[0]*x[2][i])
-      * (target[i]-gain[2]*x[0][i]-gain[1]*x[1][i]-gain[0]*x[2][i]);
+   {
+      spx_sig_t tmp = gain[2]*x[0][i]+gain[1]*x[1][i]+gain[0]*x[2][i];
+      new_target[i] = target[i] - tmp;
+      err+=new_target[i]*new_target[i];
+   }
+#endif
 
-   return err2;
+   return err;
 }
 
 
 /** Finds the best quantized 3-tap pitch predictor by analysis by synthesis */
 int pitch_search_3tap(
-float target[],                 /* Target vector */
-float *sw,
-float ak[],                     /* LPCs for this subframe */
-float awk1[],                   /* Weighted LPCs #1 for this subframe */
-float awk2[],                   /* Weighted LPCs #2 for this subframe */
-float exc[],                    /* Excitation */
-void *par,
+spx_sig_t target[],                 /* Target vector */
+spx_sig_t *sw,
+spx_coef_t ak[],                     /* LPCs for this subframe */
+spx_coef_t awk1[],                   /* Weighted LPCs #1 for this subframe */
+spx_coef_t awk2[],                   /* Weighted LPCs #2 for this subframe */
+spx_sig_t exc[],                    /* Excitation */
+const void *par,
 int   start,                    /* Smallest pitch value allowed */
 int   end,                      /* Largest pitch value allowed */
-float pitch_coef,               /* Voicing (pitch) coefficient */
+spx_word16_t pitch_coef,               /* Voicing (pitch) coefficient */
 int   p,                        /* Number of LPC coeffs */
 int   nsf,                      /* Number of samples in subframe */
 SpeexBits *bits,
 char *stack,
-float *exc2,
-float *r,
-int complexity
+spx_sig_t *exc2,
+spx_word16_t *r,
+int complexity,
+int cdbk_offset,
+int plc_tuning
 )
 {
    int i,j;
    int cdbk_index, pitch=0, best_gain_index=0;
-   float *best_exc;
+   VARDECL(spx_sig_t *best_exc);
+   VARDECL(spx_sig_t *new_target);
+   VARDECL(spx_sig_t *best_target);
    int best_pitch=0;
-   float err, best_err=-1;
+   spx_word64_t err, best_err=-1;
    int N;
-   ltp_params *params;
-   int *nbest;
-   float *gains;
+   const ltp_params *params;
+   VARDECL(int *nbest);
 
    N=complexity;
    if (N>10)
       N=10;
+   if (N<1)
+      N=1;
 
-   nbest=PUSH(stack, N, int);
-   gains = PUSH(stack, N, float);
-   params = (ltp_params*) par;
+   ALLOC(nbest, N, int);
+   params = (const ltp_params*) par;
 
-   if (N==0 || end<start)
+   if (end<start)
    {
       speex_bits_pack(bits, 0, params->pitch_bits);
       speex_bits_pack(bits, 0, params->gain_bits);
@@ -338,22 +612,29 @@
       return start;
    }
    
-   best_exc=PUSH(stack,nsf, float);
+   ALLOC(best_exc, nsf, spx_sig_t);
+   ALLOC(new_target, nsf, spx_sig_t);
+   ALLOC(best_target, nsf, spx_sig_t);
    
    if (N>end-start+1)
       N=end-start+1;
-   open_loop_nbest_pitch(sw, start, end, nsf, nbest, gains, N, stack);
+   if (end != start)
+      open_loop_nbest_pitch(sw, start, end, nsf, nbest, NULL, N, stack);
+   else
+      nbest[0] = start;
    for (i=0;i<N;i++)
    {
       pitch=nbest[i];
       for (j=0;j<nsf;j++)
          exc[j]=0;
       err=pitch_gain_search_3tap(target, ak, awk1, awk2, exc, par, pitch, p, nsf,
-                                 bits, stack, exc2, r, &cdbk_index);
+                                 bits, stack, exc2, r, new_target, &cdbk_index, cdbk_offset, plc_tuning);
       if (err<best_err || best_err<0)
       {
          for (j=0;j<nsf;j++)
             best_exc[j]=exc[j];
+         for (j=0;j<nsf;j++)
+            best_target[j]=new_target[j];
          best_err=err;
          best_pitch=pitch;
          best_gain_index=cdbk_index;
@@ -366,88 +647,90 @@
    /*printf ("encode pitch: %d %d\n", best_pitch, best_gain_index);*/
    for (i=0;i<nsf;i++)
       exc[i]=best_exc[i];
+   for (i=0;i<nsf;i++)
+      target[i]=best_target[i];
 
    return pitch;
 }
 
 void pitch_unquant_3tap(
-float exc[],                    /* Excitation */
+spx_sig_t exc[],                    /* Excitation */
 int   start,                    /* Smallest pitch value allowed */
 int   end,                      /* Largest pitch value allowed */
-float pitch_coef,               /* Voicing (pitch) coefficient */
-void *par,
+spx_word16_t pitch_coef,               /* Voicing (pitch) coefficient */
+const void *par,
 int   nsf,                      /* Number of samples in subframe */
 int *pitch_val,
-float *gain_val,
+spx_word16_t *gain_val,
 SpeexBits *bits,
 char *stack,
 int count_lost,
 int subframe_offset,
-float last_pitch_gain)
+spx_word16_t last_pitch_gain,
+int cdbk_offset
+)
 {
    int i;
    int pitch;
    int gain_index;
-   float gain[3];
-   signed char *gain_cdbk;
-   ltp_params *params;
-   params = (ltp_params*) par;
-   gain_cdbk=params->gain_cdbk;
+   spx_word16_t gain[3];
+   const signed char *gain_cdbk;
+   int gain_cdbk_size;
+   const ltp_params *params;
 
+   params = (const ltp_params*) par;
+   gain_cdbk_size = 1<<params->gain_bits;
+   gain_cdbk = params->gain_cdbk + 3*gain_cdbk_size*cdbk_offset;
+
    pitch = speex_bits_unpack_unsigned(bits, params->pitch_bits);
    pitch += start;
    gain_index = speex_bits_unpack_unsigned(bits, params->gain_bits);
    /*printf ("decode pitch: %d %d\n", pitch, gain_index);*/
+#ifdef FIXED_POINT
+   gain[0] = ADD16(32,(spx_word16_t)gain_cdbk[gain_index*3]);
+   gain[1] = ADD16(32,(spx_word16_t)gain_cdbk[gain_index*3+1]);
+   gain[2] = ADD16(32,(spx_word16_t)gain_cdbk[gain_index*3+2]);
+#else
    gain[0] = 0.015625*gain_cdbk[gain_index*3]+.5;
    gain[1] = 0.015625*gain_cdbk[gain_index*3+1]+.5;
    gain[2] = 0.015625*gain_cdbk[gain_index*3+2]+.5;
+#endif
 
    if (count_lost && pitch > subframe_offset)
    {
-      float gain_sum;
-
+      spx_word16_t gain_sum;
       if (1) {
-	 float tmp = count_lost < 4 ? last_pitch_gain : 0.4 * last_pitch_gain;
+#ifdef FIXED_POINT
+         spx_word16_t tmp = count_lost < 4 ? last_pitch_gain : SHR16(last_pitch_gain,1);
+         if (tmp>62)
+            tmp=62;
+#else
+         spx_word16_t tmp = count_lost < 4 ? last_pitch_gain : 0.5 * last_pitch_gain;
          if (tmp>.95)
             tmp=.95;
-         gain_sum = fabs(gain[1]);
-         if (gain[0]>0)
-            gain_sum += gain[0];
-         else
-            gain_sum -= .5*gain[0];
-         if (gain[2]>0)
-            gain_sum += gain[2];
-         else
-            gain_sum -= .5*gain[2];
-	 if (gain_sum > tmp) {
-	    float fact = tmp/gain_sum;
-	    for (i=0;i<3;i++)
-	       gain[i]*=fact;
+#endif
+         gain_sum = gain_3tap_to_1tap(gain);
 
-	 }
+         if (gain_sum > tmp)
+         {
+            spx_word16_t fact = DIV32_16(SHL32(EXTEND32(tmp),14),gain_sum);
+            for (i=0;i<3;i++)
+               gain[i]=MULT16_16_Q14(fact,gain[i]);
+         }
 
       }
 
-      if (0) {
-      gain_sum = fabs(gain[0])+fabs(gain[1])+fabs(gain[2]);
-	 if (gain_sum>.95) {
-         float fact = .95/gain_sum;
-         for (i=0;i<3;i++)
-            gain[i]*=fact;
-      }
    }
-   }
 
    *pitch_val = pitch;
-   /**gain_val = gain[0]+gain[1]+gain[2];*/
    gain_val[0]=gain[0];
    gain_val[1]=gain[1];
    gain_val[2]=gain[2];
 
    {
-      float *e[3];
-      float *tmp2;
-      tmp2=PUSH(stack, 3*nsf, float);
+      spx_sig_t *e[3];
+      VARDECL(spx_sig_t *tmp2);
+      ALLOC(tmp2, 3*nsf, spx_sig_t);
       e[0]=tmp2;
       e[1]=tmp2+nsf;
       e[2]=tmp2+2*nsf;
@@ -484,66 +767,80 @@
          }
 #endif
       }
+
+#ifdef FIXED_POINT
+      {
+         for (i=0;i<nsf;i++)
+            exc[i]=SHL32(ADD32(ADD32(MULT16_32_Q15(SHL16(gain[0],7),e[2][i]), MULT16_32_Q15(SHL16(gain[1],7),e[1][i])),
+                               MULT16_32_Q15(SHL16(gain[2],7),e[0][i])), 2);
+      }
+#else
       for (i=0;i<nsf;i++)
-           exc[i]=gain[0]*e[2][i]+gain[1]*e[1][i]+gain[2]*e[0][i];
+         exc[i]=VERY_SMALL+gain[0]*e[2][i]+gain[1]*e[1][i]+gain[2]*e[0][i];
+#endif
    }
 }
 
 
 /** Forced pitch delay and gain */
 int forced_pitch_quant(
-float target[],                 /* Target vector */
-float *sw,
-float ak[],                     /* LPCs for this subframe */
-float awk1[],                   /* Weighted LPCs #1 for this subframe */
-float awk2[],                   /* Weighted LPCs #2 for this subframe */
-float exc[],                    /* Excitation */
-void *par,
+spx_sig_t target[],                 /* Target vector */
+spx_sig_t *sw,
+spx_coef_t ak[],                     /* LPCs for this subframe */
+spx_coef_t awk1[],                   /* Weighted LPCs #1 for this subframe */
+spx_coef_t awk2[],                   /* Weighted LPCs #2 for this subframe */
+spx_sig_t exc[],                    /* Excitation */
+const void *par,
 int   start,                    /* Smallest pitch value allowed */
 int   end,                      /* Largest pitch value allowed */
-float pitch_coef,               /* Voicing (pitch) coefficient */
+spx_word16_t pitch_coef,               /* Voicing (pitch) coefficient */
 int   p,                        /* Number of LPC coeffs */
 int   nsf,                      /* Number of samples in subframe */
 SpeexBits *bits,
 char *stack,
-float *exc2,
-float *r,
-int complexity
+spx_sig_t *exc2,
+spx_word16_t *r,
+int complexity,
+int cdbk_offset,
+int plc_tuning
 )
 {
    int i;
-   if (pitch_coef>.99)
-      pitch_coef=.99;
+   float coef = GAIN_SCALING_1*pitch_coef;
+   if (coef>.99)
+      coef=.99;
    for (i=0;i<nsf;i++)
    {
-      exc[i]=exc[i-start]*pitch_coef;
+      exc[i]=exc[i-start]*coef;
    }
    return start;
 }
 
 /** Unquantize forced pitch delay and gain */
 void forced_pitch_unquant(
-float exc[],                    /* Excitation */
+spx_sig_t exc[],                    /* Excitation */
 int   start,                    /* Smallest pitch value allowed */
 int   end,                      /* Largest pitch value allowed */
-float pitch_coef,               /* Voicing (pitch) coefficient */
-void *par,
+spx_word16_t pitch_coef,               /* Voicing (pitch) coefficient */
+const void *par,
 int   nsf,                      /* Number of samples in subframe */
 int *pitch_val,
-float *gain_val,
+spx_word16_t *gain_val,
 SpeexBits *bits,
 char *stack,
 int count_lost,
 int subframe_offset,
-float last_pitch_gain)
+spx_word16_t last_pitch_gain,
+int cdbk_offset
+)
 {
    int i;
-   /*pitch_coef=.9;*/
-   if (pitch_coef>.99)
-      pitch_coef=.99;
+   float coef = GAIN_SCALING_1*pitch_coef;
+   if (coef>.99)
+      coef=.99;
    for (i=0;i<nsf;i++)
    {
-      exc[i]=exc[i-start]*pitch_coef;
+      exc[i]=exc[i-start]*coef;
    }
    *pitch_val = start;
    gain_val[0]=gain_val[2]=0;

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/ltp.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/ltp.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/ltp.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -31,108 +31,101 @@
 */
 
 #include <speex/speex_bits.h>
+#include "misc.h"
 
-
 typedef struct ltp_params {
-   signed char *gain_cdbk;
+   const signed char *gain_cdbk;
    int     gain_bits;
    int     pitch_bits;
 } ltp_params;
 
+#ifdef FIXED_POINT
+#define gain_3tap_to_1tap(g) (ABS(g[1]) + (g[0]>0 ? g[0] : -SHR16(g[0],1)) + (g[2]>0 ? g[2] : -SHR16(g[2],1)))
+#else
+#define gain_3tap_to_1tap(g) (ABS(g[1]) + (g[0]>0 ? g[0] : -.5*g[0]) + (g[2]>0 ? g[2] : -.5*g[2]))
+#endif
 
-void open_loop_nbest_pitch(float *sw, int start, int end, int len, int *pitch, float *gain, int N, char *stack);
+void open_loop_nbest_pitch(spx_sig_t *sw, int start, int end, int len, int *pitch, spx_word16_t *gain, int N, char *stack);
 
 
 /** Finds the best quantized 3-tap pitch predictor by analysis by synthesis */
 int pitch_search_3tap(
-float target[],                 /* Target vector */
-float *sw,
-float ak[],                     /* LPCs for this subframe */
-float awk1[],                   /* Weighted LPCs #1 for this subframe */
-float awk2[],                   /* Weighted LPCs #2 for this subframe */
-float exc[],                    /* Overlapping codebook */
-void *par,
+spx_sig_t target[],                 /* Target vector */
+spx_sig_t *sw,
+spx_coef_t ak[],                     /* LPCs for this subframe */
+spx_coef_t awk1[],                   /* Weighted LPCs #1 for this subframe */
+spx_coef_t awk2[],                   /* Weighted LPCs #2 for this subframe */
+spx_sig_t exc[],                    /* Overlapping codebook */
+const void *par,
 int   start,                    /* Smallest pitch value allowed */
 int   end,                      /* Largest pitch value allowed */
-float pitch_coef,               /* Voicing (pitch) coefficient */
+spx_word16_t pitch_coef,               /* Voicing (pitch) coefficient */
 int   p,                        /* Number of LPC coeffs */
 int   nsf,                      /* Number of samples in subframe */
 SpeexBits *bits,
 char *stack,
-float *exc2,
-float *r,
-int   complexity
+spx_sig_t *exc2,
+spx_word16_t *r,
+int   complexity,
+int   cdbk_offset,
+int plc_tuning
 );
 
 /*Unquantize adaptive codebook and update pitch contribution*/
 void pitch_unquant_3tap(
-float exc[],                    /* Excitation */
+spx_sig_t exc[],                    /* Excitation */
 int   start,                    /* Smallest pitch value allowed */
 int   end,                      /* Largest pitch value allowed */
-float pitch_coef,               /* Voicing (pitch) coefficient */
-void *par,
+spx_word16_t pitch_coef,               /* Voicing (pitch) coefficient */
+const void *par,
 int   nsf,                      /* Number of samples in subframe */
 int *pitch_val,
-float *gain_val,
+spx_word16_t *gain_val,
 SpeexBits *bits,
 char *stack,
 int lost,
 int subframe_offset,
-float last_pitch_gain
+spx_word16_t last_pitch_gain,
+int cdbk_offset
 );
 
-float pitch_gain_search_3tap(
-float target[],                 /* Target vector */
-float ak[],                     /* LPCs for this subframe */
-float awk1[],                   /* Weighted LPCs #1 for this subframe */
-float awk2[],                   /* Weighted LPCs #2 for this subframe */
-float exc[],                    /* Excitation */
-void *par,
-int   pitch,                    /* Pitch value */
-int   p,                        /* Number of LPC coeffs */
-int   nsf,                      /* Number of samples in subframe */
-SpeexBits *bits,
-char *stack,
-float *exc2,
-float *r,
-int  *cdbk_index
-);
-
-
 /** Forced pitch delay and gain */
 int forced_pitch_quant(
-float target[],                 /* Target vector */
-float *sw,
-float ak[],                     /* LPCs for this subframe */
-float awk1[],                   /* Weighted LPCs #1 for this subframe */
-float awk2[],                   /* Weighted LPCs #2 for this subframe */
-float exc[],                    /* Excitation */
-void *par,
+spx_sig_t target[],                 /* Target vector */
+spx_sig_t *sw,
+spx_coef_t ak[],                     /* LPCs for this subframe */
+spx_coef_t awk1[],                   /* Weighted LPCs #1 for this subframe */
+spx_coef_t awk2[],                   /* Weighted LPCs #2 for this subframe */
+spx_sig_t exc[],                    /* Excitation */
+const void *par,
 int   start,                    /* Smallest pitch value allowed */
 int   end,                      /* Largest pitch value allowed */
-float pitch_coef,               /* Voicing (pitch) coefficient */
+spx_word16_t pitch_coef,               /* Voicing (pitch) coefficient */
 int   p,                        /* Number of LPC coeffs */
 int   nsf,                      /* Number of samples in subframe */
 SpeexBits *bits,
 char *stack,
-float *exc2,
-float *r,
-int complexity
+spx_sig_t *exc2,
+spx_word16_t *r,
+int complexity,
+int cdbk_offset,
+int plc_tuning
 );
 
 /** Unquantize forced pitch delay and gain */
 void forced_pitch_unquant(
-float exc[],                    /* Excitation */
+spx_sig_t exc[],                    /* Excitation */
 int   start,                    /* Smallest pitch value allowed */
 int   end,                      /* Largest pitch value allowed */
-float pitch_coef,               /* Voicing (pitch) coefficient */
-void *par,
+spx_word16_t pitch_coef,               /* Voicing (pitch) coefficient */
+const void *par,
 int   nsf,                      /* Number of samples in subframe */
 int *pitch_val,
-float *gain_val,
+spx_word16_t *gain_val,
 SpeexBits *bits,
 char *stack,
 int lost,
 int subframe_offset,
-float last_pitch_gain
+spx_word16_t last_pitch_gain,
+int cdbk_offset
 );

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/ltp_arm4.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/ltp_arm4.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/ltp_arm4.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,186 @@
+/* Copyright (C) 2004 Jean-Marc Valin 
+   File: ltp.c
+   Lont-Term Prediction functions (SSE version)
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+   
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+   
+   - Neither the name of the Xiph.org Foundation nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+   
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#define OVERRIDE_INNER_PROD
+static spx_word32_t inner_prod(const spx_word16_t *x, const spx_word16_t *y, int len)
+{
+   spx_word32_t sum1=0,sum2=0;
+   spx_word16_t *deadx, *deady;
+   int deadlen, dead1, dead2, dead3, dead4, dead5, dead6;
+   __asm__ __volatile__ (
+         "\tldrsh %5, [%0], #2 \n"
+         "\tldrsh %6, [%1], #2 \n"
+         ".inner_prod_loop%=:\n"
+         "\tsub %7, %7, %7\n"
+         "\tsub %10, %10, %10\n"
+
+         "\tldrsh %8, [%0], #2 \n"
+         "\tldrsh %9, [%1], #2 \n"
+         "\tmla %7, %5, %6, %7\n"
+         "\tldrsh %5, [%0], #2 \n"
+         "\tldrsh %6, [%1], #2 \n"
+         "\tmla %10, %8, %9, %10\n"
+         "\tldrsh %8, [%0], #2 \n"
+         "\tldrsh %9, [%1], #2 \n"
+         "\tmla %7, %5, %6, %7\n"
+         "\tldrsh %5, [%0], #2 \n"
+         "\tldrsh %6, [%1], #2 \n"
+         "\tmla %10, %8, %9, %10\n"
+
+         "\tldrsh %8, [%0], #2 \n"
+         "\tldrsh %9, [%1], #2 \n"
+         "\tmla %7, %5, %6, %7\n"
+         "\tldrsh %5, [%0], #2 \n"
+         "\tldrsh %6, [%1], #2 \n"
+         "\tmla %10, %8, %9, %10\n"
+         "\tldrsh %8, [%0], #2 \n"
+         "\tldrsh %9, [%1], #2 \n"
+         "\tmla %7, %5, %6, %7\n"
+         "\tldrsh %5, [%0], #2 \n"
+         "\tldrsh %6, [%1], #2 \n"
+         "\tmla %10, %8, %9, %10\n"
+
+         "\tsubs %4, %4, #1\n"
+         "\tadd %2, %2, %7, asr #5\n"
+         "\tadd %3, %3, %10, asr #5\n"
+         "\tbne .inner_prod_loop%=\n"
+   : "=r" (deadx), "=r" (deady), "=r" (sum1),  "=r" (sum2), "=r" (deadlen),
+   "=r" (dead1), "=r" (dead2), "=r" (dead3), "=r" (dead4), "=r" (dead5), "=r" (dead6)
+   : "0" (x), "1" (y), "2" (sum1), "3" (sum2), "4" (len>>3)
+   : "cc"
+                        );
+   return (sum1+sum2)>>1;
+}
+
+#define OVERRIDE_PITCH_XCORR
+static void pitch_xcorr(const spx_word16_t *_x, const spx_word16_t *_y, spx_word32_t *corr, int len, int nb_pitch, char *stack)
+{
+   int i,j;
+   for (i=0;i<nb_pitch;i+=4)
+   {
+      /* Compute correlation*/
+      //corr[nb_pitch-1-i]=inner_prod(x, _y+i, len);
+      spx_word32_t sum1=0;
+      spx_word32_t sum2=0;
+      spx_word32_t sum3=0;
+      spx_word32_t sum4=0;
+      const spx_word16_t *y = _y+i;
+      const spx_word16_t *x = _x;
+      spx_word32_t y0, y1, y2, y3;
+      y0=*y++;
+      y1=*y++;
+      y2=*y++;
+      y3=*y++;
+      for (j=0;j<len;j+=4)
+      {
+         spx_word32_t part1, part2, part3, part4, x0;
+         spx_word32_t dead1;
+         __asm__ __volatile__ (
+#ifdef SHORTCUTS
+               "\tldrsh %10, [%8], #4 \n"
+               "\tmul %4, %10, %0 \n"
+               "\tldrsh %15, [%8], #4 \n"
+               "\tmul %5, %10, %1 \n"
+               "\tldrsh %0, [%9], #2 \n"
+               "\tmul %6, %10, %2 \n"
+               "\tldrsh %1, [%9], #2 \n"
+               "\tmul %7, %10, %3 \n"
+               
+               
+               "\tmla %4, %15, %2, %4 \n"
+               "\tldrsh %2, [%9], #2 \n"
+               "\tmla %5, %15, %3, %5 \n"
+               "\tldrsh %3, [%9], #2 \n"
+               "\tmla %6, %15, %0, %6 \n"
+               "\tmla %7, %15, %1, %7 \n"
+
+#else
+               "\tldrsh %10, [%8], #2 \n"
+               "\tmul %4, %10, %0 \n"
+               "\tmul %5, %10, %1 \n"
+               "\tmul %6, %10, %2 \n"
+               "\tmul %7, %10, %3 \n"
+
+               "\tldrsh %10, [%8], #2 \n"
+               "\tldrsh %0, [%9], #2 \n"
+               "\tmla %4, %10, %1, %4 \n"
+               "\tmla %5, %10, %2, %5 \n"
+               "\tmla %6, %10, %3, %6 \n"
+               "\tmla %7, %10, %0, %7 \n"
+
+               "\tldrsh %10, [%8], #2 \n"
+               "\tldrsh %1, [%9], #2 \n"
+               "\tmla %4, %10, %2, %4 \n"
+               "\tmla %5, %10, %3, %5 \n"
+               "\tmla %6, %10, %0, %6 \n"
+               "\tmla %7, %10, %1, %7 \n"
+
+               "\tldrsh %10, [%8], #2 \n"
+               "\tldrsh %2, [%9], #2 \n"
+               "\tmla %4, %10, %3, %4 \n"
+               "\tmla %5, %10, %0, %5 \n"
+               "\tmla %6, %10, %1, %6 \n"
+               "\tmla %7, %10, %2, %7 \n"
+
+               "\tldrsh %3, [%9], #2 \n"
+#endif
+
+               "\tldr %10, %11 \n"
+               "\tldr %15, %12 \n"
+               "\tadd %4, %10, %4, asr #6 \n"
+               "\tstr %4, %11 \n"
+               "\tldr %10, %13 \n"
+               "\tadd %5, %15, %5, asr #6 \n"
+               "\tstr %5, %12 \n"
+               "\tldr %15, %14 \n"
+               "\tadd %6, %10, %6, asr #6 \n"
+               "\tadd %7, %15, %7, asr #6 \n"
+               "\tstr %6, %13 \n"
+               "\tstr %7, %14 \n"
+
+            : "=r" (y0), "=r" (y1), "=r" (y2), "=r" (y3),
+         "=r" (part1),  "=r" (part2),  "=r" (part3),  "=r" (part4),
+         "=r" (x), "=r" (y), "=r" (x0),
+         "=m" (sum1), "=m" (sum2), "=m" (sum3), "=m" (sum4), "=r" (dead1)
+            : "0" (y0), "1" (y1), "2" (y2), "3" (y3),
+            "8" (x), "9" (y),
+            "11" (sum1), "12" (sum2), "13" (sum3), "14" (sum4)
+            : "cc", "memory"
+                              );
+      }
+      corr[nb_pitch-1-i]=sum1;
+      corr[nb_pitch-2-i]=sum2;
+      corr[nb_pitch-3-i]=sum3;
+      corr[nb_pitch-4-i]=sum4;
+   }
+
+}

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/ltp_bfin.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/ltp_bfin.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/ltp_bfin.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,163 @@
+/* Copyright (C) 2005 Analog Devices
+   Author: Jean-Marc Valin 
+   File: ltp_bfin.h
+   Long-Term Prediction functions (Blackfin version)
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+   
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+   
+   - Neither the name of the Xiph.org Foundation nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+   
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#define OVERRIDE_INNER_PROD
+static spx_word32_t inner_prod(const spx_word16_t *x, const spx_word16_t *y, int len)
+{
+   spx_word32_t sum=0;
+   __asm__ __volatile__ (
+      "P0 = %3;\n\t"
+      "P1 = %1;\n\t"
+      "P2 = %2;\n\t"
+      "I0 = P1;\n\t"
+      "I1 = P2;\n\t"
+      "L0 = 0;\n\t"
+      "L1 = 0;\n\t"
+      "A0 = 0;\n\t"
+      "R0.L = W[I0++] || R1.L = W[I1++];\n\t"
+      "LOOP inner%= LC0 = P0;\n\t"
+      "LOOP_BEGIN inner%=;\n\t"
+         "A0 += R0.L*R1.L (IS) || R0.L = W[I0++] || R1.L = W[I1++];\n\t"
+      "LOOP_END inner%=;\n\t"
+      "A0 += R0.L*R1.L (IS);\n\t"
+      "A0 = A0 >>> 6;\n\t"
+      "R0 = A0;\n\t"
+      "%0 = R0;\n\t"
+   : "=m" (sum)
+   : "m" (x), "m" (y), "d" (len-1)
+   : "P0", "P1", "P2", "R0", "R1", "A0", "I0", "I1", "L0", "L1", "R3"
+   );
+   return sum;
+}
+
+#define OVERRIDE_PITCH_XCORR
+static void pitch_xcorr(const spx_word16_t *_x, const spx_word16_t *_y, spx_word32_t *corr, int len, int nb_pitch, char *stack)
+{
+   corr += nb_pitch - 1;
+   __asm__ __volatile__ (
+      "P2 = %0;\n\t"
+      "I0 = P2;\n\t" /* x in I0 */
+      "B0 = P2;\n\t" /* x in B0 */
+      "R0 = %3;\n\t" /* len in R0 */
+      "P3 = %3;\n\t"
+      "P3 += -2;\n\t" /* len in R0 */
+      "P4 = %4;\n\t" /* nb_pitch in R0 */
+      "R1 = R0 << 1;\n\t" /* number of bytes in x */
+      "L0 = R1;\n\t"
+      "P0 = %1;\n\t"
+
+      "P1 = %2;\n\t"
+      "B1 = P1;\n\t"
+      "L1 = 0;\n\t" /*Disable looping on I1*/
+
+      "r0 = [I0++];\n\t"
+      "LOOP pitch%= LC0 = P4 >> 1;\n\t"
+      "LOOP_BEGIN pitch%=;\n\t"
+         "I1 = P0;\n\t"
+         "A1 = A0 = 0;\n\t"
+         "R1 = [I1++];\n\t"
+         "LOOP inner_prod%= LC1 = P3 >> 1;\n\t"
+         "LOOP_BEGIN inner_prod%=;\n\t"
+            "A0 += R0.L*R1.L , A1 += R0.L*R1.H (is) || R1.L = W[I1++];\n\t"
+            "A0 += R0.H*R1.H , A1 += R0.H*R1.L (is) || R1.H = W[I1++] || R0 = [I0++];\n\t"
+         "LOOP_END inner_prod%=;\n\t"
+         "A0 += R0.L*R1.L , A1 += R0.L*R1.H (is) || R1.L = W[I1++];\n\t"
+         "A0 += R0.H*R1.H , A1 += R0.H*R1.L (is) || R0 = [I0++];\n\t"
+         "A0 = A0 >>> 6;\n\t"
+         "A1 = A1 >>> 6;\n\t"
+         "R2 = A0, R3 = A1;\n\t"
+         "[P1--] = r2;\n\t"
+         "[P1--] = r3;\n\t"
+         "P0 += 4;\n\t"
+      "LOOP_END pitch%=;\n\t"
+      "L0 = 0;\n\t"
+   : : "m" (_x), "m" (_y), "m" (corr), "m" (len), "m" (nb_pitch)
+   : "A0", "A1", "P0", "P1", "P2", "P3", "P4", "R0", "R1", "R2", "R3", "I0", "I1", "L0", "L1", "B0", "B1", "memory"
+   );
+}
+
+#define OVERRIDE_COMPUTE_PITCH_ERROR
+static inline spx_word32_t compute_pitch_error(spx_word32_t *C, spx_word16_t *g, spx_word16_t pitch_control)
+{
+   spx_word32_t sum;
+   __asm__ __volatile__
+         (
+         "A0 = A1 = 0;\n\t"
+         
+         "R0 = [%1++];\n\t"
+         "R1.L = %2.L*%5.L (IS);\n\t"
+         "R0 <<= 1;\n\t"
+         "A0 += R1.L*R0.H (IS), A1 += R1.L*R0.L (M,IS) || R0 = [%1++];\n\t"
+         
+         "R1.L = %3.L*%5.L (IS);\n\t"
+         "R0 <<= 1;\n\t"
+         "A0 += R1.L*R0.H (IS), A1 += R1.L*R0.L (M,IS) || R0 = [%1++];\n\t"
+         
+         "R1.L = %4.L*%5.L (IS);\n\t"
+         "R0 <<= 1;\n\t"
+         "A0 += R1.L*R0.H (IS), A1 += R1.L*R0.L (M,IS) || R0 = [%1++];\n\t"
+         
+         "R1.L = %2.L*%3.L (IS);\n\t"
+         "R0 <<= 1;\n\t"
+         "A0 -= R1.L*R0.H (IS), A1 -= R1.L*R0.L (M,IS) || R0 = [%1++];\n\t"
+
+         "R1.L = %4.L*%3.L (IS);\n\t"
+         "R0 <<= 1;\n\t"
+         "A0 -= R1.L*R0.H (IS), A1 -= R1.L*R0.L (M,IS) || R0 = [%1++];\n\t"
+         
+         "R1.L = %4.L*%2.L (IS);\n\t"
+         "R0 <<= 1;\n\t"
+         "A0 -= R1.L*R0.H (IS), A1 -= R1.L*R0.L (M,IS) || R0 = [%1++];\n\t"
+         
+         "R1.L = %2.L*%2.L (IS);\n\t"
+         "R0 <<= 1;\n\t"
+         "A0 -= R1.L*R0.H (IS), A1 -= R1.L*R0.L (M,IS) || R0 = [%1++];\n\t"
+
+         "R1.L = %3.L*%3.L (IS);\n\t"
+         "R0 <<= 1;\n\t"
+         "A0 -= R1.L*R0.H (IS), A1 -= R1.L*R0.L (M,IS) || R0 = [%1++];\n\t"
+         
+         "R1.L = %4.L*%4.L (IS);\n\t"
+         "R0 <<= 1;\n\t"
+         "A0 -= R1.L*R0.H (IS), A1 -= R1.L*R0.L (M,IS);\n\t"
+         
+         "A1 = A1 >>> 16;\n\t"
+         "A0 += A1;\n\t"
+         "%0 = A0;\n\t"
+   : "=&D" (sum), "=a" (C)
+   : "d" (g[0]), "d" (g[1]), "d" (g[2]), "d" (pitch_control), "1" (C)
+   : "R0", "R1", "R2", "A0"
+         );
+   return sum;
+}
+

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/ltp_sse.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/ltp_sse.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/ltp_sse.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -1,6 +1,6 @@
 /* Copyright (C) 2002 Jean-Marc Valin 
    File: ltp.c
-   Lont-Term Prediction functions
+   Lont-Term Prediction functions (SSE version)
 
    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions
@@ -30,66 +30,61 @@
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
+#include <xmmintrin.h>
 
-static float inner_prod(float *a, float *b, int len)
+#define OVERRIDE_INNER_PROD
+static float inner_prod(const float *a, const float *b, int len)
 {
-  float sum;
-  __asm__ __volatile__ (
-  "\tpush %%eax\n"
-  "\tpush %%edi\n"
-  "\tpush %%ecx\n"
-  "\txorps %%xmm3, %%xmm3\n"
-  "\txorps %%xmm4, %%xmm4\n"
+   int i;
+   float ret;
+   __m128 sum = _mm_setzero_ps();
+   for (i=0;i<(len>>2);i+=2)
+   {
+      sum = _mm_add_ps(sum, _mm_mul_ps(_mm_loadu_ps(a+0), _mm_loadu_ps(b+0)));
+      sum = _mm_add_ps(sum, _mm_mul_ps(_mm_loadu_ps(a+4), _mm_loadu_ps(b+4)));
+      a += 8;
+      b += 8;
+   }
+   sum = _mm_add_ps(sum, _mm_movehl_ps(sum, sum));
+   sum = _mm_add_ss(sum, _mm_shuffle_ps(sum, sum, 0x55));
+   _mm_store_ss(&ret, sum);
+   return ret;
+}
 
-  "\tsub $20, %%ecx\n"
-
-".mul20_loop%=:\n"
-
-  "\tmovups (%%eax), %%xmm0\n"
-  "\tmovups (%%edi), %%xmm1\n"
-  "\tmulps %%xmm0, %%xmm1\n"
-
-  "\tmovups 16(%%eax), %%xmm5\n"
-  "\tmovups 16(%%edi), %%xmm6\n"
-  "\tmulps %%xmm5, %%xmm6\n"
-  "\taddps %%xmm1, %%xmm3\n"
-
-  "\tmovups 32(%%eax), %%xmm0\n"
-  "\tmovups 32(%%edi), %%xmm1\n"
-  "\tmulps %%xmm0, %%xmm1\n"
-  "\taddps %%xmm6, %%xmm4\n"
-
-  "\tmovups 48(%%eax), %%xmm5\n"
-  "\tmovups 48(%%edi), %%xmm6\n"
-  "\tmulps %%xmm5, %%xmm6\n"
-  "\taddps %%xmm1, %%xmm3\n"
-
-  "\tmovups 64(%%eax), %%xmm0\n"
-  "\tmovups 64(%%edi), %%xmm1\n"
-  "\tmulps %%xmm0, %%xmm1\n"
-  "\taddps %%xmm6, %%xmm4\n"
-  "\taddps %%xmm1, %%xmm3\n"
-
-
-  "\tadd $80, %%eax\n"
-  "\tadd $80, %%edi\n"
-
-  "\tsub $20,  %%ecx\n"
-
-  "\tjae .mul20_loop%=\n"
-
-  "\taddps %%xmm4, %%xmm3\n"
-
-  "\tmovhlps %%xmm3, %%xmm4\n"
-  "\taddps %%xmm4, %%xmm3\n"
-  "\tmovaps %%xmm3, %%xmm4\n"
-  "\tshufps $0x55, %%xmm4, %%xmm4\n"
-  "\taddss %%xmm4, %%xmm3\n"
-  "\tmovss %%xmm3, (%%edx)\n"
-  
-  "\tpop %%ecx\n"
-  "\tpop %%edi\n"
-  "\tpop %%eax\n"
-  : : "a" (a), "D" (b), "c" (len), "d" (&sum) : "memory");
-  return sum;
+#define OVERRIDE_PITCH_XCORR
+static void pitch_xcorr(const float *_x, const float *_y, float *corr, int len, int nb_pitch, char *stack)
+{
+   int i, offset;
+   VARDECL(__m128 *x);
+   VARDECL(__m128 *y);
+   int N, L;
+   N = len>>2;
+   L = nb_pitch>>2;
+   ALLOC(x, N, __m128);
+   ALLOC(y, N+L, __m128);
+   for (i=0;i<N;i++)
+      x[i] = _mm_loadu_ps(_x+(i<<2));
+   for (offset=0;offset<4;offset++)
+   {
+      for (i=0;i<N+L;i++)
+         y[i] = _mm_loadu_ps(_y+(i<<2)+offset);
+      for (i=0;i<L;i++)
+      {
+         int j;
+         __m128 sum, *xx, *yy;
+         sum = _mm_setzero_ps();
+         yy = y+i;
+         xx = x;
+         for (j=0;j<N;j+=2)
+         {
+            sum = _mm_add_ps(sum, _mm_mul_ps(xx[0], yy[0]));
+            sum = _mm_add_ps(sum, _mm_mul_ps(xx[1], yy[1]));
+            xx += 2;
+            yy += 2;
+         }
+         sum = _mm_add_ps(sum, _mm_movehl_ps(sum, sum));
+         sum = _mm_add_ss(sum, _mm_shuffle_ps(sum, sum, 0x55));
+         _mm_store_ss(corr+nb_pitch-1-(i<<2)-offset, sum);
+      }
+   }
 }

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/math_approx.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/math_approx.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/math_approx.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -30,76 +30,102 @@
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#include <math.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include "math_approx.h"
+#include "misc.h"
 
-#ifdef SLOW_TRIG
+#ifdef FIXED_POINT
 
-float cos_sin[102] = {
-   1.00000000, 0.00000000,
-   0.99804751, 0.06245932,
-   0.99219767, 0.12467473,
-   0.98247331, 0.18640330,
-   0.96891242, 0.24740396,
-   0.95156795, 0.30743851,
-   0.93050762, 0.36627253,
-   0.90581368, 0.42367626,
-   0.87758256, 0.47942554,
-   0.84592450, 0.53330267,
-   0.81096312, 0.58509727,
-   0.77283495, 0.63460708,
-   0.73168887, 0.68163876,
-   0.68768556, 0.72600866,
-   0.64099686, 0.76754350,
-   0.59180508, 0.80608111,
-   0.54030231, 0.84147098,
-   0.48668967, 0.87357494,
-   0.43117652, 0.90226759,
-   0.37397963, 0.92743692,
-   0.31532236, 0.94898462,
-   0.25543377, 0.96682656,
-   0.19454771, 0.98089306,
-   0.13290194, 0.99112919,
-   0.07073720, 0.99749499,
-   0.00829623, 0.99996559,
-   -0.05417714, 0.99853134,
-   -0.11643894, 0.99319785,
-   -0.17824606, 0.98398595,
-   -0.23935712, 0.97093160,
-   -0.29953351, 0.95408578,
-   -0.35854022, 0.93351428,
-   -0.41614684, 0.90929743,
-   -0.47212841, 0.88152979,
-   -0.52626633, 0.85031979,
-   -0.57834920, 0.81578931,
-   -0.62817362, 0.77807320,
-   -0.67554504, 0.73731872,
-   -0.72027847, 0.69368503,
-   -0.76219923, 0.64734252,
-   -0.80114362, 0.59847214,
-   -0.83695955, 0.54726475,
-   -0.86950718, 0.49392030,
-   -0.89865940, 0.43864710,
-   -0.92430238, 0.38166099,
-   -0.94633597, 0.32318451,
-   -0.96467415, 0.26344599,
-   -0.97924529, 0.20267873,
-   -0.98999250, 0.14112001,
-   -0.99687381, 0.07901022,
-   -0.99986235, 0.01659189
-};
+/* sqrt(x) ~= 0.22178 + 1.29227*x - 0.77070*x^2 + 0.25723*x^3 (for .25 < x < 1) */
+#define C0 3634
+#define C1 21173
+#define C2 -12627
+#define C3 4215
 
-float speex_cos(float x)
+spx_word16_t spx_sqrt(spx_word32_t x)
 {
-   int ind;
-   float delta;
-   ind = (int)floor(x*16+.5);
-   delta = x-0.062500*ind;
-   ind <<= 1;
-   return cos_sin[ind] - delta*(cos_sin[ind+1] + 
-                                  .5*delta*(cos_sin[ind] - 
-                                            .3333333*delta*cos_sin[ind+1]));
+   int k=0;
+   spx_word32_t rt;
+
+   if (x==0)
+      return 0;
+#if 1
+   if (x>16777216)
+   {
+      x>>=10;
+      k+=5;
+   }
+   if (x>1048576)
+   {
+      x>>=6;
+      k+=3;
+   }
+   if (x>262144)
+   {
+      x>>=4;
+      k+=2;
+   }
+   if (x>32768)
+   {
+      x>>=2;
+      k+=1;
+   }
+   if (x>16384)
+   {
+      x>>=2;
+      k+=1;
+   }
+#else
+   while (x>16384)
+   {
+      x>>=2;
+      k++;
+      }
+#endif
+   while (x<4096)
+   {
+      x<<=2;
+      k--;
+   }
+   rt = ADD16(C0, MULT16_16_Q14(x, ADD16(C1, MULT16_16_Q14(x, ADD16(C2, MULT16_16_Q14(x, (C3)))))));
+   if (k>0)
+      rt <<= k;
+   else
+      rt >>= -k;
+   rt >>=7;
+   return rt;
 }
 
+/* log(x) ~= -2.18151 + 4.20592*x - 2.88938*x^2 + 0.86535*x^3 (for .5 < x < 1) */
+
+
+#define A1 16469
+#define A2 2242
+#define A3 1486
+
+spx_word16_t spx_acos(spx_word16_t x)
+{
+   int s=0;
+   spx_word16_t ret;
+   spx_word16_t sq;
+   if (x<0)
+   {
+      s=1;
+      x = NEG16(x);
+   }
+   x = SUB16(16384,x);
+   
+   x = x >> 1;
+   sq = MULT16_16_Q13(x, ADD16(A1, MULT16_16_Q13(x, ADD16(A2, MULT16_16_Q13(x, (A3))))));
+   ret = spx_sqrt(SHL32(EXTEND32(sq),13));
+   
+   /*ret = spx_sqrt(67108864*(-1.6129e-04 + 2.0104e+00*f + 2.7373e-01*f*f + 1.8136e-01*f*f*f));*/
+   if (s)
+      ret = SUB16(25736,ret);
+   return ret;
+}
+
 #endif
-

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/math_approx.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/math_approx.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/math_approx.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -33,7 +33,14 @@
 #ifndef MATH_APPROX_H
 #define MATH_APPROX_H
 
-float speex_cos(float x);
+#include "misc.h"
 
+#ifdef FIXED_POINT
+spx_word16_t spx_sqrt(spx_word32_t x);
+spx_word16_t spx_acos(spx_word16_t x);
+#else
+#define spx_sqrt sqrt
+#define spx_acos acos
+#endif
 
 #endif

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/mdf.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/mdf.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/mdf.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,539 @@
+/* Copyright (C) 2003-2005 Jean-Marc Valin
+
+   File: speex_echo.c
+   Echo cancelling based on the MDF algorithm described in:
+
+   J. S. Soo, K. K. Pang Multidelay block frequency adaptive filter, 
+   IEEE Trans. Acoust. Speech Signal Process., Vol. ASSP-38, No. 2, 
+   February 1990.
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions are
+   met:
+
+   1. Redistributions of source code must retain the above copyright notice,
+   this list of conditions and the following disclaimer.
+
+   2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+   3. The name of the author may not be used to endorse or promote products
+   derived from this software without specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+   IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+   OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+   DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+   ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+   POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "misc.h"
+#include "speex/speex_echo.h"
+#include "smallft.h"
+#include <math.h>
+
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+#undef BETA
+#define BETA .65
+
+#define min(a,b) ((a)<(b) ? (a) : (b))
+#define max(a,b) ((a)>(b) ? (a) : (b))
+
+/** Compute inner product of two real vectors */
+static inline float inner_prod(float *x, float *y, int N)
+{
+   int i;
+   float ret=0;
+   for (i=0;i<N;i++)
+      ret += x[i]*y[i];
+   return ret;
+}
+
+/** Compute power spectrum of a half-complex (packed) vector */
+static inline void power_spectrum(float *X, float *ps, int N)
+{
+   int i, j;
+   ps[0]=X[0]*X[0];
+   for (i=1,j=1;i<N-1;i+=2,j++)
+   {
+      ps[j] =  X[i]*X[i] + X[i+1]*X[i+1];
+   }
+   ps[j]=X[i]*X[i];
+}
+
+/** Compute cross-power spectrum of a half-complex (packed) vectors and add to acc */
+static inline void spectral_mul_accum(float *X, float *Y, float *acc, int N)
+{
+   int i;
+   acc[0] += X[0]*Y[0];
+   for (i=1;i<N-1;i+=2)
+   {
+      acc[i] += (X[i]*Y[i] - X[i+1]*Y[i+1]);
+      acc[i+1] += (X[i+1]*Y[i] + X[i]*Y[i+1]);
+   }
+   acc[i] += X[i]*Y[i];
+}
+
+/** Compute cross-power spectrum of a half-complex (packed) vector with conjugate */
+static inline void spectral_mul_conj(float *X, float *Y, float *prod, int N)
+{
+   int i;
+   prod[0] = X[0]*Y[0];
+   for (i=1;i<N-1;i+=2)
+   {
+      prod[i] = (X[i]*Y[i] + X[i+1]*Y[i+1]);
+      prod[i+1] = (-X[i+1]*Y[i] + X[i]*Y[i+1]);
+   }
+   prod[i] = X[i]*Y[i];
+}
+
+
+/** Compute weighted cross-power spectrum of a half-complex (packed) vector with conjugate */
+static inline void weighted_spectral_mul_conj(float *w, float *X, float *Y, float *prod, int N)
+{
+   int i, j;
+   prod[0] = w[0]*X[0]*Y[0];
+   for (i=1,j=1;i<N-1;i+=2,j++)
+   {
+      prod[i] = w[j]*(X[i]*Y[i] + X[i+1]*Y[i+1]);
+      prod[i+1] = w[j]*(-X[i+1]*Y[i] + X[i]*Y[i+1]);
+   }
+   prod[i] = w[j]*X[i]*Y[i];
+}
+
+
+/** Creates a new echo canceller state */
+SpeexEchoState *speex_echo_state_init(int frame_size, int filter_length)
+{
+   int i,j,N,M;
+   SpeexEchoState *st = (SpeexEchoState *)speex_alloc(sizeof(SpeexEchoState));
+
+   st->frame_size = frame_size;
+   st->window_size = 2*frame_size;
+   N = st->window_size;
+   M = st->M = (filter_length+st->frame_size-1)/frame_size;
+   st->cancel_count=0;
+   st->adapt_rate = .01f;
+   st->sum_adapt = 0;
+   st->Sey = 0;
+   st->Syy = 0;
+   st->See = 0;
+         
+   st->fft_lookup = (struct drft_lookup*)speex_alloc(sizeof(struct drft_lookup));
+   spx_drft_init(st->fft_lookup, N);
+   
+   st->x = (float*)speex_alloc(N*sizeof(float));
+   st->d = (float*)speex_alloc(N*sizeof(float));
+   st->y = (float*)speex_alloc(N*sizeof(float));
+   st->y2 = (float*)speex_alloc(N*sizeof(float));
+   st->Yps = (float*)speex_alloc(N*sizeof(float));
+   st->last_y = (float*)speex_alloc(N*sizeof(float));
+   st->Yf = (float*)speex_alloc((st->frame_size+1)*sizeof(float));
+   st->Rf = (float*)speex_alloc((st->frame_size+1)*sizeof(float));
+   st->Xf = (float*)speex_alloc((st->frame_size+1)*sizeof(float));
+   st->fratio = (float*)speex_alloc((st->frame_size+1)*sizeof(float));
+   st->regul = (float*)speex_alloc(N*sizeof(float));
+
+   st->X = (float*)speex_alloc(M*N*sizeof(float));
+   st->D = (float*)speex_alloc(N*sizeof(float));
+   st->Y = (float*)speex_alloc(N*sizeof(float));
+   st->Y2 = (float*)speex_alloc(N*sizeof(float));
+   st->E = (float*)speex_alloc(N*sizeof(float));
+   st->W = (float*)speex_alloc(M*N*sizeof(float));
+   st->PHI = (float*)speex_alloc(M*N*sizeof(float));
+   st->power = (float*)speex_alloc((frame_size+1)*sizeof(float));
+   st->power_1 = (float*)speex_alloc((frame_size+1)*sizeof(float));
+   st->grad = (float*)speex_alloc(N*M*sizeof(float));
+   
+   for (i=0;i<N*M;i++)
+   {
+      st->W[i] = st->PHI[i] = 0;
+   }
+   
+   st->regul[0] = (.01+(10.)/((4.)*(4.)))/M;
+   for (i=1,j=1;i<N-1;i+=2,j++)
+   {
+      st->regul[i] = .01+((10.)/((j+4.)*(j+4.)))/M;
+      st->regul[i+1] = .01+((10.)/((j+4.)*(j+4.)))/M;
+   }
+   st->regul[i] = .01+((10.)/((j+4.)*(j+4.)))/M;
+         
+   st->adapted = 0;
+   return st;
+}
+
+/** Resets echo canceller state */
+void speex_echo_state_reset(SpeexEchoState *st)
+{
+   int i, M, N;
+   st->cancel_count=0;
+   st->adapt_rate = .01f;
+   N = st->window_size;
+   M = st->M;
+   for (i=0;i<N*M;i++)
+   {
+      st->W[i] = 0;
+      st->X[i] = 0;
+   }
+   for (i=0;i<=st->frame_size;i++)
+      st->power[i] = 0;
+   
+   st->adapted = 0;
+   st->adapt_rate = .01f;
+   st->sum_adapt = 0;
+   st->Sey = 0;
+   st->Syy = 0;
+   st->See = 0;
+
+}
+
+/** Destroys an echo canceller state */
+void speex_echo_state_destroy(SpeexEchoState *st)
+{
+   spx_drft_clear(st->fft_lookup);
+   speex_free(st->fft_lookup);
+   speex_free(st->x);
+   speex_free(st->d);
+   speex_free(st->y);
+   speex_free(st->last_y);
+   speex_free(st->Yps);
+   speex_free(st->Yf);
+   speex_free(st->Rf);
+   speex_free(st->Xf);
+   speex_free(st->fratio);
+   speex_free(st->regul);
+
+   speex_free(st->X);
+   speex_free(st->D);
+   speex_free(st->Y);
+   speex_free(st->E);
+   speex_free(st->W);
+   speex_free(st->PHI);
+   speex_free(st->power);
+   speex_free(st->power_1);
+   speex_free(st->grad);
+
+   speex_free(st);
+}
+
+      
+/** Performs echo cancellation on a frame */
+void speex_echo_cancel(SpeexEchoState *st, short *ref, short *echo, short *out, float *Yout)
+{
+   int i,j,m;
+   int N,M;
+   float scale;
+   float ESR;
+   float SER;
+   float Sry=0,Srr=0,Syy=0,Sey=0,See=0,Sxx=0;
+   float leak_estimate;
+   
+   /*leak_estimate = .1+(.9/(1+2*st->sum_adapt));*/
+   leak_estimate = (.1 + (1-st->sum_adapt)*(1-st->sum_adapt))/(.9*st->sum_adapt*st->sum_adapt + .1);
+         
+   N = st->window_size;
+   M = st->M;
+   scale = 1.0f/N;
+   st->cancel_count++;
+
+   /* Copy input data to buffer */
+   for (i=0;i<st->frame_size;i++)
+   {
+      st->x[i] = st->x[i+st->frame_size];
+      st->x[i+st->frame_size] = echo[i];
+
+      st->d[i] = st->d[i+st->frame_size];
+      st->d[i+st->frame_size] = ref[i];
+   }
+
+   /* Shift memory: this could be optimized eventually*/
+   for (i=0;i<N*(M-1);i++)
+      st->X[i]=st->X[i+N];
+
+   /* Copy new echo frame */
+   for (i=0;i<N;i++)
+      st->X[(M-1)*N+i]=st->x[i];
+
+   /* Convert x (echo input) to frequency domain */
+   spx_drft_forward(st->fft_lookup, &st->X[(M-1)*N]);
+
+   /* Compute filter response Y */
+   for (i=0;i<N;i++)
+      st->Y[i] = 0;
+   for (j=0;j<M;j++)
+      spectral_mul_accum(&st->X[j*N], &st->W[j*N], st->Y, N);
+   
+   /* Convert Y (filter response) to time domain */
+   for (i=0;i<N;i++)
+      st->y[i] = st->Y[i];
+   spx_drft_backward(st->fft_lookup, st->y);
+   for (i=0;i<N;i++)
+      st->y[i] *= scale;
+
+   /* Transform d (reference signal) to frequency domain */
+   for (i=0;i<N;i++)
+      st->D[i]=st->d[i];
+   spx_drft_forward(st->fft_lookup, st->D);
+
+   /* Compute error signal (signal with echo removed) */ 
+   for (i=0;i<st->frame_size;i++)
+   {
+      float tmp_out;
+      tmp_out = (float)ref[i] - st->y[i+st->frame_size];
+      
+      st->E[i] = 0;
+      st->E[i+st->frame_size] = tmp_out;
+      
+      /* Saturation */
+      if (tmp_out>32767)
+         tmp_out = 32767;
+      else if (tmp_out<-32768)
+         tmp_out = -32768;
+      out[i] = tmp_out;
+   }
+   
+   /* This bit of code is optional and provides faster adaptation by doing a projection 
+      of the previous gradient on the "MMSE surface" */
+   if (1)
+   {
+      float Sge, Sgg, Syy;
+      float gain;
+      Syy = inner_prod(st->y+st->frame_size, st->y+st->frame_size, st->frame_size);
+      for (i=0;i<N;i++)
+         st->Y2[i] = 0;
+      for (j=0;j<M;j++)
+         spectral_mul_accum(&st->X[j*N], &st->PHI[j*N], st->Y2, N);
+      for (i=0;i<N;i++)
+         st->y2[i] = st->Y2[i];
+      spx_drft_backward(st->fft_lookup, st->y2);
+      for (i=0;i<N;i++)
+         st->y2[i] *= scale;
+      Sge = inner_prod(st->y2+st->frame_size, st->E+st->frame_size, st->frame_size);
+      Sgg = inner_prod(st->y2+st->frame_size, st->y2+st->frame_size, st->frame_size);
+      /* Compute projection gain */
+      gain = Sge/(N+.03*Syy+Sgg);
+      if (gain>2)
+         gain = 2;
+      if (gain < -2)
+         gain = -2;
+      
+      /* Apply gain to weights, echo estimates, output */
+      for (i=0;i<N;i++)
+         st->Y[i] += gain*st->Y2[i];
+      for (i=0;i<st->frame_size;i++)
+      {
+         st->y[i+st->frame_size] += gain*st->y2[i+st->frame_size];
+         st->E[i+st->frame_size] -= gain*st->y2[i+st->frame_size];
+      }
+      for (i=0;i<M*N;i++)
+         st->W[i] += gain*st->PHI[i];
+   }
+
+   /* Compute power spectrum of output (D-Y) and filter response (Y) */
+   for (i=0;i<N;i++)
+      st->D[i] -= st->Y[i];
+   power_spectrum(st->D, st->Rf, N);
+   power_spectrum(st->Y, st->Yf, N);
+   
+   /* Compute frequency-domain adaptation mask */
+   for (j=0;j<=st->frame_size;j++)
+   {
+      float r;
+      r = leak_estimate*st->Yf[j] / (1+st->Rf[j]);
+      if (r>1)
+         r = 1;
+      st->fratio[j] = r;
+   }
+
+   /* Compute a bunch of correlations */
+   Sry = inner_prod(st->y+st->frame_size, st->d+st->frame_size, st->frame_size);
+   Sey = inner_prod(st->y+st->frame_size, st->E+st->frame_size, st->frame_size);
+   See = inner_prod(st->E+st->frame_size, st->E+st->frame_size, st->frame_size);
+   Syy = inner_prod(st->y+st->frame_size, st->y+st->frame_size, st->frame_size);
+   Srr = inner_prod(st->d+st->frame_size, st->d+st->frame_size, st->frame_size);
+   Sxx = inner_prod(st->x+st->frame_size, st->x+st->frame_size, st->frame_size);
+
+   /* Compute smoothed cross-correlation and energy */   
+   st->Sey = .98*st->Sey + .02*Sey;
+   st->Syy = .98*st->Syy + .02*Syy;
+   st->See = .98*st->See + .02*See;
+   
+   /* Check if filter is completely mis-adapted (if so, reset filter) */
+   if (st->Sey/(1+st->Syy + .01*st->See) < -1)
+   {
+      /*fprintf (stderr, "reset at %d\n", st->cancel_count);*/
+      speex_echo_state_reset(st);
+      return;
+   }
+
+   SER = Srr / (1+Sxx);
+   ESR = leak_estimate*Syy / (1+See);
+   if (ESR>1)
+      ESR = 1;
+#if 1
+   /* If over-cancellation (creating echo with 180 phase) damp filter */
+   if (st->Sey/(1+st->Syy) < -.1 && (ESR > .3))
+   {
+      for (i=0;i<M*N;i++)
+         st->W[i] *= .95;
+      st->Sey *= .5;
+      st->sum_adapt*= .95;
+      /*fprintf (stderr, "corrected down\n");*/
+   }
+#endif
+#if 1
+   /* If under-cancellation (leaving echo with 0 phase) scale filter up */
+   if (st->Sey/(1+st->Syy) > .1 && (ESR > .1 || SER < 10))
+   {
+      for (i=0;i<M*N;i++)
+         st->W[i] *= 1.05;
+      st->Sey *= .5;
+      /*fprintf (stderr, "corrected up %d\n", st->cancel_count);*/
+   }
+#endif
+   
+   /* We consider that the filter is adapted if the following is true*/
+   if (ESR>.6 && st->sum_adapt > .7 && !st->adapted)
+   {
+      /*fprintf(stderr, "Adapted at %d %f\n", st->cancel_count, st->sum_adapt);*/
+      st->adapted = 1;
+   } else if (st->sum_adapt < .5 && st->adapted)
+   {
+      /*fprintf(stderr, "Un-adapted at %d %f\n", st->cancel_count, st->sum_adapt);*/
+      st->adapted = 0;
+   }
+   
+   /* Update frequency-dependent energy ratio with the total energy ratio */
+   for (i=0;i<=st->frame_size;i++)
+   {
+      st->fratio[i]  = (.2*ESR+.8*min(ESR,st->fratio[i]));
+   }   
+
+   if (st->adapted)
+   {
+      st->adapt_rate = .95f/(2+M);
+      /* How much have we adapted so far? */
+      st->sum_adapt = (1-st->adapt_rate)*st->sum_adapt + st->adapt_rate;
+   } else {
+      /* Temporary adaption rate if filter is not adapted correctly */
+      if (SER<.1)
+         st->adapt_rate =.5/(2+M);
+      else if (SER<1)
+         st->adapt_rate =.3/(2+M);
+      else if (SER<10)
+         st->adapt_rate =.2/(2+M);
+      else if (SER<30)
+         st->adapt_rate =.08/(2+M);
+      else
+         st->adapt_rate = 0;
+      /* How much have we adapted so far? */
+      st->sum_adapt = (1-ESR*st->adapt_rate)*st->sum_adapt + ESR*st->adapt_rate;
+   }
+   
+   /* How much have we adapted so far? */
+   /*st->sum_adapt += st->adapt_rate;*/
+
+   /* Compute echo power in each frequency bin */
+   {
+      float ss = 1.0f/st->cancel_count;
+      if (ss < .3/M)
+         ss=.3/M;
+      power_spectrum(&st->X[(M-1)*N], st->Xf, N);
+      /* Smooth echo energy estimate over time */
+      for (j=0;j<=st->frame_size;j++)
+         st->power[j] = (1-ss)*st->power[j] + ss*st->Xf[j];
+      
+      
+      /* Combine adaptation rate to the the inverse energy estimate */
+      if (st->adapted)
+      {
+         /* If filter is adapted, include the frequency-dependent ratio too */
+         for (i=0;i<=st->frame_size;i++)
+            st->power_1[i] = st->adapt_rate*st->fratio[i] /(1.f+st->power[i]);
+      } else {
+         for (i=0;i<=st->frame_size;i++)
+            st->power_1[i] = st->adapt_rate/(1.f+st->power[i]);
+      }
+   }
+
+   
+   /* Convert error to frequency domain */
+   spx_drft_forward(st->fft_lookup, st->E);
+
+   /* Do some regularization (prevents problems when system is ill-conditoned) */
+   for (m=0;m<M;m++)
+      for (i=0;i<N;i++)
+         st->W[m*N+i] *= 1-st->regul[i]*ESR;
+   
+   /* Compute weight gradient */
+   for (j=0;j<M;j++)
+   {
+      weighted_spectral_mul_conj(st->power_1, &st->X[j*N], st->E, st->PHI+N*j, N);
+   }
+
+   /* Gradient descent */
+   for (i=0;i<M*N;i++)
+      st->W[i] += st->PHI[i];
+   
+   /* AUMDF weight constraint */
+   for (j=0;j<M;j++)
+   {
+      /* Remove the "if" to make this an MDF filter */
+      if (st->cancel_count%M == j)
+      {
+         spx_drft_backward(st->fft_lookup, &st->W[j*N]);
+         for (i=0;i<N;i++)
+            st->W[j*N+i]*=scale;
+         for (i=st->frame_size;i<N;i++)
+         {
+            st->W[j*N+i]=0;
+         }
+         spx_drft_forward(st->fft_lookup, &st->W[j*N]);
+      }
+   }
+
+   /* Compute spectrum of estimated echo for use in an echo post-filter (if necessary)*/
+   if (Yout)
+   {
+      if (st->adapted)
+      {
+         /* If the filter is adapted, take the filtered echo */
+         for (i=0;i<st->frame_size;i++)
+            st->last_y[i] = st->last_y[st->frame_size+i];
+         for (i=0;i<st->frame_size;i++)
+            st->last_y[st->frame_size+i] = st->y[st->frame_size+i];
+      } else {
+         /* If filter isn't adapted yet, all we can do is take the echo signal directly */
+         for (i=0;i<N;i++)
+            st->last_y[i] = st->x[i];
+      }
+      
+      /* Apply hanning window (should pre-compute it)*/
+      for (i=0;i<N;i++)
+         st->Yps[i] = (.5-.5*cos(2*M_PI*i/N))*st->last_y[i];
+      
+      /* Compute power spectrum of the echo */
+      spx_drft_forward(st->fft_lookup, st->Yps);
+      power_spectrum(st->Yps, st->Yps, N);
+      
+      /* Estimate residual echo */
+      for (i=0;i<=st->frame_size;i++)
+         Yout[i] = 2*leak_estimate*st->Yps[i];
+   }
+
+}
+

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/misc.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/misc.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/misc.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 Jean-Marc Valin 
+/* Copyright (C) 2002-2005 Jean-Marc Valin 
    File: mics.c
    Various utility routines for Speex
 
@@ -30,11 +30,19 @@
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#include "misc.h"
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
+#include "misc.h"
 
+#ifdef BFIN_ASM
+#include "misc_bfin.h"
+#endif
+
 #ifndef RELEASE
 void print_vec(float *vec, int len, char *name)
 {
@@ -46,9 +54,14 @@
 }
 #endif
 
-unsigned int be_int(unsigned int i)
+#ifdef FIXED_DEBUG
+long long spx_mips=0;
+#endif
+
+
+spx_uint32_t be_int(spx_uint32_t i)
 {
-   unsigned int ret=i;
+   spx_uint32_t ret=i;
 #ifndef WORDS_BIGENDIAN
    ret =  i>>24;
    ret += (i>>8)&0x0000ff00;
@@ -58,9 +71,9 @@
    return ret;
 }
 
-unsigned int le_int(unsigned int i)
+spx_uint32_t le_int(spx_uint32_t i)
 {
-   unsigned int ret=i;
+   spx_uint32_t ret=i;
 #ifdef WORDS_BIGENDIAN
    ret =  i>>24;
    ret += (i>>8)&0x0000ff00;
@@ -70,30 +83,58 @@
    return ret;
 }
 
-unsigned short be_short(unsigned short s)
+#if BYTES_PER_CHAR == 2
+void speex_memcpy_bytes(char *dst, char *src, int nbytes)
 {
-   unsigned short ret=s;
-#ifndef WORDS_BIGENDIAN
-   ret =  s>>8;
-   ret += s<<8;
-#endif
-   return ret;
+  int i;
+  int nchars = nbytes/BYTES_PER_CHAR;
+  for (i=0;i<nchars;i++)
+    dst[i]=src[i];
+  if (nbytes & 1) {
+    /* copy in the last byte */
+    int last_i = nchars;
+    char last_dst_char = dst[last_i];
+    char last_src_char = src[last_i];
+    last_dst_char &= 0xff00;
+    last_dst_char |= (last_src_char & 0x00ff);
+    dst[last_i] = last_dst_char;
+  }
 }
-
-unsigned short le_short(unsigned short s)
+void speex_memset_bytes(char *dst, char c, int nbytes)
 {
-   unsigned short ret=s;
-#ifdef WORDS_BIGENDIAN
-   ret =  s>>8;
-   ret += s<<8;
+  int i;
+  spx_int16_t cc = ((c << 8) | c);
+  int nchars = nbytes/BYTES_PER_CHAR;
+  for (i=0;i<nchars;i++)
+    dst[i]=cc;
+  if (nbytes & 1) {
+    /* copy in the last byte */
+    int last_i = nchars;
+    char last_dst_char = dst[last_i];
+    last_dst_char &= 0xff00;
+    last_dst_char |= (c & 0x00ff);
+    dst[last_i] = last_dst_char;
+  }
+}
+#else
+void speex_memcpy_bytes(char *dst, char *src, int nbytes)
+{
+  memcpy(dst, src, nbytes);
+}
+void speex_memset_bytes(char *dst, char src, int nbytes)
+{
+  memset(dst, src, nbytes);
+}
 #endif
-   return ret;
-}
 
 void *speex_alloc (int size)
 {
    return calloc(size,1);
 }
+void *speex_alloc_scratch (int size)
+{
+   return calloc(size,1);
+}
 
 void *speex_realloc (void *ptr, int size)
 {
@@ -104,42 +145,68 @@
 {
    free(ptr);
 }
+void speex_free_scratch (void *ptr)
+{
+   free(ptr);
+}
 
+#ifndef OVERRIDE_SPEEX_MOVE
 void *speex_move (void *dest, void *src, int n)
 {
    return memmove(dest,src,n);
 }
+#endif
 
-void speex_error(char *str)
+void speex_error(const char *str)
 {
    fprintf (stderr, "Fatal error: %s\n", str);
    exit(1);
 }
 
-void speex_warning(char *str)
+void speex_warning(const char *str)
 {
    fprintf (stderr, "warning: %s\n", str);
 }
 
-void speex_warning_int(char *str, int val)
+void speex_warning_int(const char *str, int val)
 {
    fprintf (stderr, "warning: %s %d\n", str, val);
 }
 
-void speex_rand_vec(float std, float *data, int len)
+#ifdef FIXED_POINT
+spx_word32_t speex_rand(spx_word16_t std, spx_int32_t *seed)
 {
+   *seed = 1664525 * *seed + 1013904223;
+   return MULT16_16(EXTRACT16(SHR32(*seed,16)),std);
+}
+#else
+spx_word16_t speex_rand(spx_word16_t std, spx_int32_t *seed)
+{
+   const unsigned int jflone = 0x3f800000;
+   const unsigned int jflmsk = 0x007fffff;
+   union {int i; float f;} ran;
+   *seed = 1664525 * *seed + 1013904223;
+   ran.i = jflone | (jflmsk & *seed);
+   ran.f -= 1;
+   return 1.7321*std*ran.f;
+}
+#endif
+
+void speex_rand_vec(float std, spx_sig_t *data, int len)
+{
    int i;
    for (i=0;i<len;i++)
-      data[i]+=3*std*((((float)rand())/RAND_MAX)-.5);
+      data[i]+=SIG_SCALING*3*std*((((float)rand())/RAND_MAX)-.5);
 }
 
-float speex_rand(float std)
+
+/*float speex_rand(float std)
 {
    return 3*std*((((float)rand())/RAND_MAX)-.5);
-}
+}*/
 
 void _speex_putc(int ch, void *file)
 {
    FILE *f = (FILE *)file;
-   fputc(ch, f);
+   fprintf(f, "%c", ch);
 }

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/misc.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/misc.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/misc.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -37,53 +37,52 @@
 
 #ifndef SPEEX_VERSION
 #define SPEEX_MAJOR_VERSION 1
-#define SPEEX_MINOR_VERSION 0
-#define SPEEX_MICRO_VERSION 4
+#define SPEEX_MINOR_VERSION 1
+#define SPEEX_MICRO_VERSION 10
 #define SPEEX_EXTRA_VERSION ""
-#define SPEEX_VERSION "speex-1.0.4"
+#define SPEEX_VERSION "speex-1.1.10"
 #endif
 
-/*Disable some warnings on VC++*/
-#ifdef _MSC_VER
-#pragma warning(disable : 4244)
-#pragma warning(disable : 4305)
-#endif
+#include "arch.h"
 
-#define VERY_SMALL 1e-30
-
 #ifndef RELEASE
 void print_vec(float *vec, int len, char *name);
 #endif
 
-unsigned int be_int(unsigned int i);
-unsigned int le_int(unsigned int i);
+spx_uint32_t be_int(spx_uint32_t i);
+spx_uint32_t le_int(spx_uint32_t i);
 
-
-unsigned short be_short(unsigned short s);
-unsigned short le_short(unsigned short s);
-
 /** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_free */
 void *speex_alloc (int size);
 
+/** Same as speex_alloc, except that the area is only needed inside a Speex call (might cause problem with wideband though) */
+void *speex_alloc_scratch (int size);
+
 /** Speex wrapper for realloc. To do your own dynamic allocation, all you need to do is replace this function, speex_alloc and speex_free */
 void *speex_realloc (void *ptr, int size);
 
 /** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_alloc */
 void speex_free (void *ptr);
 
+/** Same as speex_alloc, except that the area is only needed inside a Speex call (might cause problem with wideband though) */
+void speex_free_scratch (void *ptr);
+
 /** Speex wrapper for mem_move */
 void *speex_move (void *dest, void *src, int n);
 
-void speex_error(char *str);
+void speex_memcpy_bytes(char *dst, char *src, int nbytes);
+void speex_memset_bytes(char *dst, char src, int nbytes);
 
-void speex_warning(char *str);
+void speex_error(const char *str);
 
-void speex_warning_int(char *str, int val);
+void speex_warning(const char *str);
 
-void speex_rand_vec(float std, float *data, int len);
+void speex_warning_int(const char *str, int val);
 
-float speex_rand(float std);
+void speex_rand_vec(float std, spx_sig_t *data, int len);
 
+spx_word32_t speex_rand(spx_word16_t std, spx_int32_t *seed);
+
 void _speex_putc(int ch, void *file);
 
 #endif

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/misc_bfin.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/misc_bfin.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/misc_bfin.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,52 @@
+/* Copyright (C) 2005 Analog Devices
+   Author:  Jean-Marc Valin 
+   File: mics_bfin.h
+   Various utility routines for Speex
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+   
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+   
+   - Neither the name of the Xiph.org Foundation nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+   
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#define OVERRIDE_SPEEX_MOVE
+void *speex_move (void *dest, void *src, int n)
+{
+   __asm__ __volatile__
+         (
+         "L0 = 0;\n\t"
+         "I0 = %0;\n\t"
+         "R0 = [I0++];\n\t"
+         "LOOP move%= LC0 = %2;\n\t"
+         "LOOP_BEGIN move%=;\n\t"
+            "[%1++] = R0 || R0 = [I0++];\n\t"
+         "LOOP_END move%=;\n\t"
+         "[%1++] = R0;\n\t"
+   : "=a" (src), "=a" (dest)
+   : "a" ((n>>2)-1), "0" (src), "1" (dest)
+   : "R0", "I0", "L0", "memory"
+         );
+   return dest;
+}

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/modes.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/modes.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/modes.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -32,6 +32,10 @@
 
 */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include "modes.h"
 #include "ltp.h"
 #include "quant_lsp.h"
@@ -40,58 +44,59 @@
 #include "nb_celp.h"
 #include "vbr.h"
 #include "misc.h"
+#include <math.h>
 
 #ifndef NULL
 #define NULL 0
 #endif
 
-SpeexMode *speex_mode_list[SPEEX_NB_MODES] = {&speex_nb_mode, &speex_wb_mode, &speex_uwb_mode};
+#define MAX_IN_SAMPLES 640
 
+const SpeexMode * const speex_mode_list[SPEEX_NB_MODES] = {&speex_nb_mode, &speex_wb_mode, &speex_uwb_mode};
+
 /* Extern declarations for all codebooks we use here */
-extern signed char gain_cdbk_nb[];
-extern signed char gain_cdbk_lbr[];
-extern signed char hexc_table[];
-extern signed char exc_5_256_table[];
-extern signed char exc_5_64_table[];
-extern signed char exc_8_128_table[];
-extern signed char exc_10_32_table[];
-extern signed char exc_10_16_table[];
-extern signed char exc_20_32_table[];
-extern signed char hexc_10_32_table[];
+extern const signed char gain_cdbk_nb[];
+extern const signed char gain_cdbk_lbr[];
+extern const signed char hexc_table[];
+extern const signed char exc_5_256_table[];
+extern const signed char exc_5_64_table[];
+extern const signed char exc_8_128_table[];
+extern const signed char exc_10_32_table[];
+extern const signed char exc_10_16_table[];
+extern const signed char exc_20_32_table[];
+extern const signed char hexc_10_32_table[];
 
-static int nb_mode_query(void *mode, int request, void *ptr);
-static int wb_mode_query(void *mode, int request, void *ptr);
 
 /* Parameters for Long-Term Prediction (LTP)*/
-static ltp_params ltp_params_nb = {
+static const ltp_params ltp_params_nb = {
    gain_cdbk_nb,
    7,
    7
 };
 
 /* Parameters for Long-Term Prediction (LTP)*/
-static ltp_params ltp_params_vlbr = {
+static const ltp_params ltp_params_vlbr = {
    gain_cdbk_lbr,
    5,
    0
 };
 
 /* Parameters for Long-Term Prediction (LTP)*/
-static ltp_params ltp_params_lbr = {
+static const ltp_params ltp_params_lbr = {
    gain_cdbk_lbr,
    5,
    7
 };
 
 /* Parameters for Long-Term Prediction (LTP)*/
-static ltp_params ltp_params_med = {
+static const ltp_params ltp_params_med = {
    gain_cdbk_lbr,
    5,
    7
 };
 
 /* Split-VQ innovation parameters for very low bit-rate narrowband */
-static split_cb_params split_cb_nb_vlbr = {
+static const split_cb_params split_cb_nb_vlbr = {
    10,               /*subvect_size*/
    4,               /*nb_subvect*/
    exc_10_16_table, /*shape_cb*/
@@ -100,7 +105,7 @@
 };
 
 /* Split-VQ innovation parameters for very low bit-rate narrowband */
-static split_cb_params split_cb_nb_ulbr = {
+static const split_cb_params split_cb_nb_ulbr = {
    20,               /*subvect_size*/
    2,               /*nb_subvect*/
    exc_20_32_table, /*shape_cb*/
@@ -109,7 +114,7 @@
 };
 
 /* Split-VQ innovation parameters for low bit-rate narrowband */
-static split_cb_params split_cb_nb_lbr = {
+static const split_cb_params split_cb_nb_lbr = {
    10,              /*subvect_size*/
    4,               /*nb_subvect*/
    exc_10_32_table, /*shape_cb*/
@@ -119,7 +124,7 @@
 
 
 /* Split-VQ innovation parameters narrowband */
-static split_cb_params split_cb_nb = {
+static const split_cb_params split_cb_nb = {
    5,               /*subvect_size*/
    8,               /*nb_subvect*/
    exc_5_64_table, /*shape_cb*/
@@ -128,7 +133,7 @@
 };
 
 /* Split-VQ innovation parameters narrowband */
-static split_cb_params split_cb_nb_med = {
+static const split_cb_params split_cb_nb_med = {
    8,               /*subvect_size*/
    5,               /*nb_subvect*/
    exc_8_128_table, /*shape_cb*/
@@ -137,7 +142,7 @@
 };
 
 /* Split-VQ innovation for low-band wideband */
-static split_cb_params split_cb_sb = {
+static const split_cb_params split_cb_sb = {
    5,               /*subvect_size*/
    8,              /*nb_subvect*/
    exc_5_256_table,    /*shape_cb*/
@@ -145,8 +150,10 @@
    0,
 };
 
+#ifndef DISABLE_WIDEBAND
+
 /* Split-VQ innovation for high-band wideband */
-static split_cb_params split_cb_high = {
+static const split_cb_params split_cb_high = {
    8,               /*subvect_size*/
    5,               /*nb_subvect*/
    hexc_table,       /*shape_cb*/
@@ -156,7 +163,7 @@
 
 
 /* Split-VQ innovation for high-band wideband */
-static split_cb_params split_cb_high_lbr = {
+static const split_cb_params split_cb_high_lbr = {
    10,               /*subvect_size*/
    4,               /*nb_subvect*/
    hexc_10_32_table,       /*shape_cb*/
@@ -164,8 +171,10 @@
    0,
 };
 
+#endif
+
 /* 2150 bps "vocoder-like" mode for comfort noise */
-static SpeexSubmode nb_submode1 = {
+static const SpeexSubmode nb_submode1 = {
    0,
    1,
    0,
@@ -181,12 +190,16 @@
    noise_codebook_quant,
    noise_codebook_unquant,
    NULL,
-   .7, .7, -1,
+#ifdef FIXED_POINT
+   22938, 22938, 0, -1,
+#else
+   .7, .7, 0, -1,
+#endif
    43
 };
 
 /* 3.95 kbps very low bit-rate mode */
-static SpeexSubmode nb_submode8 = {
+static const SpeexSubmode nb_submode8 = {
    0,
    1,
    0,
@@ -202,13 +215,16 @@
    split_cb_search_shape_sign,
    split_cb_shape_sign_unquant,
    &split_cb_nb_ulbr,
-
-   0.7, 0.5, .65,
+#ifdef FIXED_POINT
+   22938, 16384, 11796, 21299,
+#else
+   0.7, 0.5, .36, .65,
+#endif
    79
 };
 
 /* 5.95 kbps very low bit-rate mode */
-static SpeexSubmode nb_submode2 = {
+static const SpeexSubmode nb_submode2 = {
    0,
    0,
    0,
@@ -224,13 +240,16 @@
    split_cb_search_shape_sign,
    split_cb_shape_sign_unquant,
    &split_cb_nb_vlbr,
-
-   0.7, 0.5, .55,
+#ifdef FIXED_POINT
+   22938, 16384, 11796, 18022,
+#else
+   0.7, 0.5, .36, .55,
+#endif
    119
 };
 
 /* 8 kbps low bit-rate mode */
-static SpeexSubmode nb_submode3 = {
+static const SpeexSubmode nb_submode3 = {
    -1,
    0,
    1,
@@ -246,13 +265,16 @@
    split_cb_search_shape_sign,
    split_cb_shape_sign_unquant,
    &split_cb_nb_lbr,
-
-   0.7, 0.55, .45,
+#ifdef FIXED_POINT
+   22938, 18022, 9830, 14746,
+#else
+   0.7, 0.55, .30, .45,
+#endif
    160
 };
 
 /* 11 kbps medium bit-rate mode */
-static SpeexSubmode nb_submode4 = {
+static const SpeexSubmode nb_submode4 = {
    -1,
    0,
    1,
@@ -268,13 +290,16 @@
    split_cb_search_shape_sign,
    split_cb_shape_sign_unquant,
    &split_cb_nb_med,
-
-   0.7, 0.63, .35,
+#ifdef FIXED_POINT
+   22938, 20644, 5243, 11469,
+#else
+   0.7, 0.63, .16, .35,
+#endif
    220
 };
 
 /* 15 kbps high bit-rate mode */
-static SpeexSubmode nb_submode5 = {
+static const SpeexSubmode nb_submode5 = {
    -1,
    0,
    3,
@@ -290,13 +315,16 @@
    split_cb_search_shape_sign,
    split_cb_shape_sign_unquant,
    &split_cb_nb,
-
-   0.7, 0.65, .25,
+#ifdef FIXED_POINT
+   22938, 21299, 3932, 8192,
+#else
+   0.7, 0.65, .12, .25,
+#endif
    300
 };
 
 /* 18.2 high bit-rate mode */
-static SpeexSubmode nb_submode6 = {
+static const SpeexSubmode nb_submode6 = {
    -1,
    0,
    3,
@@ -312,13 +340,16 @@
    split_cb_search_shape_sign,
    split_cb_shape_sign_unquant,
    &split_cb_sb,
-
-   0.68, 0.65, .1,
+#ifdef FIXED_POINT
+   22282, 21299, 2294, 3277,
+#else
+   0.68, 0.65, .07, .1,
+#endif
    364
 };
 
 /* 24.6 kbps high bit-rate mode */
-static SpeexSubmode nb_submode7 = {
+static const SpeexSubmode nb_submode7 = {
    -1,
    0,
    3,
@@ -334,25 +365,32 @@
    split_cb_search_shape_sign,
    split_cb_shape_sign_unquant,
    &split_cb_nb,
-
-   0.65, 0.65, -1,
+#ifdef FIXED_POINT
+   21299, 21299, 0, -1,
+#else
+   0.65, 0.65, .0, -1,
+#endif
    492
 };
 
 
 /* Default mode for narrowband */
-static SpeexNBMode nb_mode = {
+static const SpeexNBMode nb_mode = {
    160,    /*frameSize*/
    40,     /*subframeSize*/
    10,     /*lpcSize*/
-   640,    /*bufSize*/
    17,     /*pitchStart*/
    144,    /*pitchEnd*/
-   0.9,    /*gamma1*/
-   0.6,    /*gamma2*/
-   .01,   /*lag_factor*/
-   1.0001, /*lpc_floor*/
-   0.0,    /*preemph*/
+#ifdef FIXED_POINT
+   29491, 19661, /* gamma1, gamma2 */
+#else
+   0.9, 0.6, /* gamma1, gamma2 */
+#endif
+   .012,   /*lag_factor*/
+   1.0002, /*lpc_floor*/
+#ifdef EPIC_48K
+   0,
+#endif
    {NULL, &nb_submode1, &nb_submode2, &nb_submode3, &nb_submode4, &nb_submode5, &nb_submode6, &nb_submode7,
    &nb_submode8, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
    5,
@@ -361,7 +399,7 @@
 
 
 /* Default mode for narrowband */
-SpeexMode speex_nb_mode = {
+const SpeexMode speex_nb_mode = {
    &nb_mode,
    nb_mode_query,
    "narrowband",
@@ -380,7 +418,7 @@
 
 /* Wideband part */
 
-static SpeexSubmode wb_submode1 = {
+static const SpeexSubmode wb_submode1 = {
    0,
    0,
    1,
@@ -396,13 +434,16 @@
    NULL,
    NULL,
    NULL,
-
-   .75, .75, -1,
+#ifdef FIXED_POINT
+   24576, 24576, 0, -1,
+#else
+   .75, .75, .0, -1,
+#endif
    36
 };
 
 
-static SpeexSubmode wb_submode2 = {
+static const SpeexSubmode wb_submode2 = {
    0,
    0,
    1,
@@ -417,14 +458,21 @@
    /*Innovation quantization*/
    split_cb_search_shape_sign,
    split_cb_shape_sign_unquant,
+#ifdef DISABLE_WIDEBAND
+   NULL,
+#else
    &split_cb_high_lbr,
-
-   .85, .6, -1,
+#endif
+#ifdef FIXED_POINT
+   27853, 19661, 8192, -1,
+#else
+   .85, .6, .25, -1,
+#endif
    112
 };
 
 
-static SpeexSubmode wb_submode3 = {
+static const SpeexSubmode wb_submode3 = {
    0,
    0,
    1,
@@ -439,13 +487,21 @@
    /*Innovation quantization*/
    split_cb_search_shape_sign,
    split_cb_shape_sign_unquant,
+#ifdef DISABLE_WIDEBAND
+   NULL,
+#else
    &split_cb_high,
+#endif
 
-   .75, .7, -1,
+#ifdef FIXED_POINT
+   24576, 22938, 1638, -1,
+#else
+   .75, .7, .05, -1,
+#endif
    192
 };
 
-static SpeexSubmode wb_submode4 = {
+static const SpeexSubmode wb_submode4 = {
    0,
    0,
    1,
@@ -460,25 +516,34 @@
    /*Innovation quantization*/
    split_cb_search_shape_sign,
    split_cb_shape_sign_unquant,
+#ifdef DISABLE_WIDEBAND
+   NULL,
+#else
    &split_cb_high,
-
-   .75, .75, -1,
+#endif
+#ifdef FIXED_POINT
+   24576, 24576, 0, -1,
+#else
+   .75, .75, .0, -1,
+#endif
    352
 };
 
 
 /* Split-band wideband CELP mode*/
-static SpeexSBMode sb_wb_mode = {
+static const SpeexSBMode sb_wb_mode = {
    &speex_nb_mode,
    160,    /*frameSize*/
    40,     /*subframeSize*/
    8,     /*lpcSize*/
    640,    /*bufSize*/
-   .9,    /*gamma1*/
-   0.6,    /*gamma2*/
-   .002,   /*lag_factor*/
+#ifdef FIXED_POINT
+   29491, 19661, /* gamma1, gamma2 */
+#else
+   0.9, 0.6, /* gamma1, gamma2 */
+#endif
+   .001,   /*lag_factor*/
    1.0001, /*lpc_floor*/
-   0.0,    /*preemph*/
    0.9,
    {NULL, &wb_submode1, &wb_submode2, &wb_submode3, &wb_submode4, NULL, NULL, NULL},
    3,
@@ -489,7 +554,7 @@
 };
 
 
-SpeexMode speex_wb_mode = {
+const SpeexMode speex_wb_mode = {
    &sb_wb_mode,
    wb_mode_query,
    "wideband (sub-band CELP)",
@@ -512,17 +577,19 @@
 
 
 /* Split-band "ultra-wideband" (32 kbps) CELP mode*/
-static SpeexSBMode sb_uwb_mode = {
+static const SpeexSBMode sb_uwb_mode = {
    &speex_wb_mode,
    320,    /*frameSize*/
    80,     /*subframeSize*/
    8,     /*lpcSize*/
    1280,    /*bufSize*/
-   .9,    /*gamma1*/
-   0.6,    /*gamma2*/
+#ifdef FIXED_POINT
+   29491, 19661, /* gamma1, gamma2 */
+#else
+   0.9, 0.6, /* gamma1, gamma2 */
+#endif
    .002,   /*lag_factor*/
    1.0001, /*lpc_floor*/
-   0.0,    /*preemph*/
    0.7,
    {NULL, &wb_submode1, NULL, NULL, NULL, NULL, NULL, NULL},
    1,
@@ -533,7 +600,7 @@
 };
 
 
-SpeexMode speex_uwb_mode = {
+const SpeexMode speex_uwb_mode = {
    &sb_uwb_mode,
    wb_mode_query,
    "ultra-wideband (sub-band CELP)",
@@ -552,134 +619,104 @@
 
 
 
-void *speex_encoder_init(SpeexMode *mode)
-{
-   return mode->enc_init(mode);
-}
+#ifdef EPIC_48K
 
-void *speex_decoder_init(SpeexMode *mode)
-{
-   return mode->dec_init(mode);
-}
+extern const signed char gain_cdbk_ulbr[];
+extern const signed char exc_12_32_table[];
 
-void speex_encoder_destroy(void *state)
-{
-   (*((SpeexMode**)state))->enc_destroy(state);
-}
+/* Parameters for Long-Term Prediction (LTP)*/
+static const ltp_params ltp_params_48k = {
+   gain_cdbk_ulbr,
+   3,
+   0
+};
 
-int speex_encode(void *state, float *in, SpeexBits *bits)
-{
-   return (*((SpeexMode**)state))->enc(state, in, bits);
-}
+static const split_cb_params split_cb_nb_48k = {
+   12,               /*subvect_size*/
+   4,               /*nb_subvect*/
+   exc_12_32_table, /*shape_cb*/
+   5,               /*shape_bits*/
+   0,
+};
 
-void speex_decoder_destroy(void *state)
-{
-   (*((SpeexMode**)state))->dec_destroy(state);
-}
 
-int speex_decode(void *state, SpeexBits *bits, float *out)
-{
-   return (*((SpeexMode**)state))->dec(state, bits, out);
-}
+/* 4.8 kbps very low bit-rate mode */
+static const SpeexSubmode nb_48k_submode = {
+   0,
+   0,
+   0,
+   0,
+   /*LSP quantization*/
+   lsp_quant_48k,
+   lsp_unquant_48k,
+   /*No pitch quantization*/
+   pitch_search_3tap,
+   pitch_unquant_3tap,
+   &ltp_params_48k,
+   /*Innovation quantization*/
+   split_cb_search_shape_sign,
+   split_cb_shape_sign_unquant,
+   &split_cb_nb_48k,
+#ifdef FIXED_POINT
+   22938, 16384, 11796, 18022,
+#else
+   0.7, 0.5, .36, .55,
+#endif
+   144
+};
 
 
-int speex_encoder_ctl(void *state, int request, void *ptr)
-{
-   return (*((SpeexMode**)state))->enc_ctl(state, request, ptr);
-}
+/* Special, non-standard 4.8 kbps mode */
+static const SpeexNBMode nb_48k_mode = {
+   240,    /*frameSize*/
+   48,     /*subframeSize*/
+   10,     /*lpcSize*/
+   640,    /*bufSize*/
+   17,     /*pitchStart*/
+   144,    /*pitchEnd*/
+   0.9,    /*gamma1*/
+   0.6,    /*gamma2*/
+   .01,   /*lag_factor*/
+   1.0003, /*lpc_floor*/
+   1,
+   {NULL, NULL, &nb_48k_submode, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
+   2,
+   {2,2,2,2,2,2,2,2,2,2,2}
+};
 
-int speex_decoder_ctl(void *state, int request, void *ptr)
-{
-   return (*((SpeexMode**)state))->dec_ctl(state, request, ptr);
-}
 
+/* Default mode for narrowband */
+const SpeexMode speex_nb_48k_mode = {
+   &nb_48k_mode,
+   nb_mode_query,
+   "narrowband 4.8 kbps",
+   1000,
+   4,
+   &nb_encoder_init,
+   &nb_encoder_destroy,
+   &nb_encode,
+   &nb_decoder_init,
+   &nb_decoder_destroy,
+   &nb_decode,
+   &nb_encoder_ctl,
+   &nb_decoder_ctl,
+};
 
 
-static int nb_mode_query(void *mode, int request, void *ptr)
+#endif
+
+int speex_mode_query(const SpeexMode *mode, int request, void *ptr)
 {
-   SpeexNBMode *m = (SpeexNBMode*)mode;
-   
-   switch (request)
-   {
-   case SPEEX_MODE_FRAME_SIZE:
-      *((int*)ptr)=m->frameSize;
-      break;
-   case SPEEX_SUBMODE_BITS_PER_FRAME:
-      if (*((int*)ptr)==0)
-         *((int*)ptr) = NB_SUBMODE_BITS+1;
-      else if (m->submodes[*((int*)ptr)]==NULL)
-         *((int*)ptr) = -1;
-      else
-         *((int*)ptr) = m->submodes[*((int*)ptr)]->bits_per_frame;
-      break;
-   default:
-      speex_warning_int("Unknown nb_mode_query request: ", request);
-      return -1;
-   }
-   return 0;
+   return mode->query(mode->mode, request, ptr);
 }
 
-static int wb_mode_query(void *mode, int request, void *ptr)
+const SpeexMode * speex_lib_get_mode (int mode)
 {
-   SpeexSBMode *m = (SpeexSBMode*)mode;
+#ifdef EPIC_48K
+  if (mode == SPEEX_MODEID_NB_48K) return &speex_nb_48k_mode;
+#endif
 
-   switch (request)
-   {
-   case SPEEX_MODE_FRAME_SIZE:
-      *((int*)ptr)=2*m->frameSize;
-      break;
-   case SPEEX_SUBMODE_BITS_PER_FRAME:
-      if (*((int*)ptr)==0)
-         *((int*)ptr) = SB_SUBMODE_BITS+1;
-      else if (m->submodes[*((int*)ptr)]==NULL)
-         *((int*)ptr) = -1;
-      else
-         *((int*)ptr) = m->submodes[*((int*)ptr)]->bits_per_frame;
-      break;
-   default:
-      speex_warning_int("Unknown wb_mode_query request: ", request);
-      return -1;
-   }
-   return 0;
-}
+  if (mode < 0 || mode > SPEEX_NB_MODES) return NULL;
 
-
-int speex_mode_query(SpeexMode *mode, int request, void *ptr)
-{
-   return mode->query(mode->mode, request, ptr);
+  return speex_mode_list[mode];
 }
-
-int speex_lib_ctl(int request, void *ptr)
-{
-   switch (request)
-   {
-      case SPEEX_LIB_GET_MAJOR_VERSION:
-         *((int*)ptr) = SPEEX_MAJOR_VERSION;
-         break;
-      case SPEEX_LIB_GET_MINOR_VERSION:
-         *((int*)ptr) = SPEEX_MINOR_VERSION;
-         break;
-      case SPEEX_LIB_GET_MICRO_VERSION:
-         *((int*)ptr) = SPEEX_MICRO_VERSION;
-         break;
-      case SPEEX_LIB_GET_EXTRA_VERSION:
-         *((char**)ptr) = SPEEX_EXTRA_VERSION;
-         break;
-      case SPEEX_LIB_GET_VERSION_STRING:
-         *((char**)ptr) = SPEEX_VERSION;
-         break;
-      /*case SPEEX_LIB_SET_ALLOC_FUNC:
-         break;
-      case SPEEX_LIB_GET_ALLOC_FUNC:
-         break;
-      case SPEEX_LIB_SET_FREE_FUNC:
-         break;
-      case SPEEX_LIB_GET_FREE_FUNC:
-         break;*/
-      default:
-         speex_warning_int("Unknown wb_mode_query request: ", request);
-         return -1;
-         break;
-   }
-   return 0;
-}

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/modes.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/modes.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/modes.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -38,8 +38,8 @@
 
 #include <speex/speex.h>
 #include <speex/speex_bits.h>
+#include "misc.h"
 
-
 #define NB_SUBMODES 16
 #define NB_SUBMODE_BITS 4
 
@@ -48,28 +48,28 @@
 
 
 /** Quantizes LSPs */
-typedef void (*lsp_quant_func)(float *, float *, int, SpeexBits *);
+typedef void (*lsp_quant_func)(spx_lsp_t *, spx_lsp_t *, int, SpeexBits *);
 
 /** Decodes quantized LSPs */
-typedef void (*lsp_unquant_func)(float *, int, SpeexBits *);
+typedef void (*lsp_unquant_func)(spx_lsp_t *, int, SpeexBits *);
 
 
 /** Long-term predictor quantization */
-typedef int (*ltp_quant_func)(float *, float *, float *, float *, 
-                              float *, float *, void *, int, int, float, 
-                              int, int, SpeexBits*, char *, float *, float *, int);
+typedef int (*ltp_quant_func)(spx_sig_t *, spx_sig_t *, spx_coef_t *, spx_coef_t *, 
+                              spx_coef_t *, spx_sig_t *, const void *, int, int, spx_word16_t, 
+                              int, int, SpeexBits*, char *, spx_sig_t *, spx_word16_t *, int, int, int);
 
 /** Long-term un-quantize */
-typedef void (*ltp_unquant_func)(float *, int, int, float, void *, int, int *,
-                                 float *, SpeexBits*, char*, int, int, float);
+typedef void (*ltp_unquant_func)(spx_sig_t *, int, int, spx_word16_t, const void *, int, int *,
+                                 spx_word16_t *, SpeexBits*, char*, int, int, spx_word16_t, int);
 
 
 /** Innovation quantization function */
-typedef void (*innovation_quant_func)(float *, float *, float *, float *, void *, int, int, 
-                                      float *, float *, SpeexBits *, char *, int);
+typedef void (*innovation_quant_func)(spx_sig_t *, spx_coef_t *, spx_coef_t *, spx_coef_t *, const void *, int, int, 
+                                      spx_sig_t *, spx_word16_t *, SpeexBits *, char *, int, int);
 
 /** Innovation unquantization function */
-typedef void (*innovation_unquant_func)(float *, void *, int, SpeexBits*, char *);
+typedef void (*innovation_unquant_func)(spx_sig_t *, const void *, int, SpeexBits*, char *);
 
 /** Description of a Speex sub-mode (wither narrowband or wideband */
 typedef struct SpeexSubmode {
@@ -84,17 +84,18 @@
    /*Lont-term predictor functions*/
    ltp_quant_func    ltp_quant; /**< Long-term predictor (pitch) quantizer */
    ltp_unquant_func  ltp_unquant; /**< Long-term predictor (pitch) un-quantizer */
-   void             *ltp_params; /**< Pitch parameters (options) */
+   const void             *ltp_params; /**< Pitch parameters (options) */
 
    /*Quantization of innovation*/
    innovation_quant_func innovation_quant; /**< Innovation quantization */
    innovation_unquant_func innovation_unquant; /**< Innovation un-quantization */
-   void             *innovation_params; /**< Innovation quantization parameters*/
+   const void             *innovation_params; /**< Innovation quantization parameters*/
 
    /*Synthesis filter enhancement*/
-   float             lpc_enh_k1; /**< Enhancer constant */
-   float             lpc_enh_k2; /**< Enhancer constant */
-   float             comb_gain;  /**< Gain of enhancer comb filter */
+   spx_word16_t      lpc_enh_k1; /**< Enhancer constant */
+   spx_word16_t      lpc_enh_k2; /**< Enhancer constant */
+   spx_word16_t      lpc_enh_k3; /**< Enhancer constant */
+   spx_word16_t      comb_gain;  /**< Gain of enhancer comb filter */
 
    int               bits_per_frame; /**< Number of bits per frame after encoding*/
 } SpeexSubmode;
@@ -104,17 +105,19 @@
    int     frameSize;      /**< Size of frames used for encoding */
    int     subframeSize;   /**< Size of sub-frames used for encoding */
    int     lpcSize;        /**< Order of LPC filter */
-   int     bufSize;        /**< Size of signal buffer to use in encoder */
    int     pitchStart;     /**< Smallest pitch value allowed */
    int     pitchEnd;       /**< Largest pitch value allowed */
 
-   float   gamma1;         /**< Perceptual filter parameter #1 */
-   float   gamma2;         /**< Perceptual filter parameter #2 */
+   spx_word16_t gamma1;    /**< Perceptual filter parameter #1 */
+   spx_word16_t gamma2;    /**< Perceptual filter parameter #2 */
    float   lag_factor;     /**< Lag-windowing parameter */
    float   lpc_floor;      /**< Noise floor for LPC analysis */
-   float   preemph;        /**< Pre-emphasis */
 
-   SpeexSubmode *submodes[NB_SUBMODES]; /**< Sub-mode data for the mode */
+#ifdef EPIC_48K
+   int     lbr48k;         /**< 1 for the special 4.8 kbps mode */
+#endif
+
+   const SpeexSubmode *submodes[NB_SUBMODES]; /**< Sub-mode data for the mode */
    int     defaultSubmode; /**< Default sub-mode to use when encoding */
    int     quality_map[11]; /**< Mode corresponding to each quality setting */
 } SpeexNBMode;
@@ -122,25 +125,29 @@
 
 /** Struct defining the encoding/decoding mode for SB-CELP (wideband) */
 typedef struct SpeexSBMode {
-   SpeexMode *nb_mode;    /**< Embedded narrowband mode */
+   const SpeexMode *nb_mode;    /**< Embedded narrowband mode */
    int     frameSize;     /**< Size of frames used for encoding */
    int     subframeSize;  /**< Size of sub-frames used for encoding */
    int     lpcSize;       /**< Order of LPC filter */
    int     bufSize;       /**< Signal buffer size in encoder */
-   float   gamma1;        /**< Perceptual filter parameter #1 */
-   float   gamma2;        /**< Perceptual filter parameter #1 */
+   spx_word16_t gamma1;   /**< Perceptual filter parameter #1 */
+   spx_word16_t gamma2;   /**< Perceptual filter parameter #1 */
    float   lag_factor;    /**< Lag-windowing parameter */
    float   lpc_floor;     /**< Noise floor for LPC analysis */
-   float   preemph;       /**< Pre-emphasis */
    float   folding_gain;
 
-   SpeexSubmode *submodes[SB_SUBMODES]; /**< Sub-mode data for the mode */
+   const SpeexSubmode *submodes[SB_SUBMODES]; /**< Sub-mode data for the mode */
    int     defaultSubmode; /**< Default sub-mode to use when encoding */
    int     low_quality_map[11]; /**< Mode corresponding to each quality setting */
    int     quality_map[11]; /**< Mode corresponding to each quality setting */
-   float   (*vbr_thresh)[11];
+   const float (*vbr_thresh)[11];
    int     nb_modes;
 } SpeexSBMode;
 
+int speex_encode_native(void *state, spx_word16_t *in, SpeexBits *bits);
+int speex_decode_native(void *state, SpeexBits *bits, spx_word16_t *out);
 
+int nb_mode_query(const void *mode, int request, void *ptr);
+int wb_mode_query(const void *mode, int request, void *ptr);
+
 #endif

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/nb_celp.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/nb_celp.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/nb_celp.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -29,6 +29,10 @@
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <math.h>
 #include "nb_celp.h"
 #include "lpc.h"
@@ -44,11 +48,6 @@
 #include "misc.h"
 #include <speex/speex_callbacks.h>
 
-#ifdef SLOW_TRIG
-#include "math_approx.h"
-#define cos speex_cos
-#endif
-
 #ifndef M_PI
 #define M_PI           3.14159265358979323846  /* pi */
 #endif
@@ -59,24 +58,61 @@
 
 #define SUBMODE(x) st->submodes[st->submodeID]->x
 
-float exc_gain_quant_scal3[8]={-2.794750, -1.810660, -1.169850, -0.848119, -0.587190, -0.329818, -0.063266, 0.282826};
+/* Default size for the encoder and decoder stack (can be changed at compile time).
+   This does not apply when using variable-size arrays or alloca. */
+#ifndef NB_ENC_STACK
+#define NB_ENC_STACK (8000*sizeof(spx_sig_t))
+#endif
 
-float exc_gain_quant_scal1[2]={-0.35, 0.05};
+#ifndef NB_DEC_STACK
+#define NB_DEC_STACK (4000*sizeof(spx_sig_t))
+#endif
 
+
+#ifdef FIXED_POINT
+const spx_word32_t ol_gain_table[32]={18900, 25150, 33468, 44536, 59265, 78865, 104946, 139653, 185838, 247297, 329081, 437913, 582736, 775454, 1031906, 1373169, 1827293, 2431601, 3235761, 4305867, 5729870, 7624808, 10146425, 13501971, 17967238, 23909222, 31816294, 42338330, 56340132, 74972501, 99766822, 132760927};
+const spx_word16_t exc_gain_quant_scal3_bound[7]={1841, 3883, 6051, 8062, 10444, 13580, 18560};
+const spx_word16_t exc_gain_quant_scal3[8]={1002, 2680, 5086, 7016, 9108, 11781, 15380, 21740};
+const spx_word16_t exc_gain_quant_scal1_bound[1]={14385};
+const spx_word16_t exc_gain_quant_scal1[2]={11546, 17224};
+
+#define LSP_MARGIN 16
+#define LSP_DELTA1 6553
+#define LSP_DELTA2 1638
+
+#else
+
+const float exc_gain_quant_scal3_bound[7]={0.112338, 0.236980, 0.369316, 0.492054, 0.637471, 0.828874, 1.132784};
+const float exc_gain_quant_scal3[8]={0.061130, 0.163546, 0.310413, 0.428220, 0.555887, 0.719055, 0.938694, 1.326874};
+const float exc_gain_quant_scal1_bound[1]={0.87798};
+const float exc_gain_quant_scal1[2]={0.70469, 1.05127};
+
+#define LSP_MARGIN .002
+#define LSP_DELTA1 .2
+#define LSP_DELTA2 .05
+
+#endif
+
+
+
+
 #define sqr(x) ((x)*(x))
 
-void *nb_encoder_init(SpeexMode *m)
+void *nb_encoder_init(const SpeexMode *m)
 {
    EncState *st;
-   SpeexNBMode *mode;
+   const SpeexNBMode *mode;
    int i;
 
-   mode=(SpeexNBMode *)m->mode;
-   st = (EncState*)speex_alloc(sizeof(EncState)+8000*sizeof(float));
+   mode=(const SpeexNBMode *)m->mode;
+   st = (EncState*)speex_alloc(sizeof(EncState));
    if (!st)
       return NULL;
-
-   st->stack = ((char*)st) + sizeof(EncState);
+#if defined(VAR_ARRAYS) || defined (USE_ALLOCA)
+   st->stack = NULL;
+#else
+   st->stack = (char*)speex_alloc_scratch(NB_ENC_STACK);
+#endif
    
    st->mode=m;
 
@@ -85,84 +121,80 @@
    st->nbSubframes=mode->frameSize/mode->subframeSize;
    st->subframeSize=mode->subframeSize;
    st->lpcSize = mode->lpcSize;
-   st->bufSize = mode->bufSize;
    st->gamma1=mode->gamma1;
    st->gamma2=mode->gamma2;
    st->min_pitch=mode->pitchStart;
    st->max_pitch=mode->pitchEnd;
    st->lag_factor=mode->lag_factor;
    st->lpc_floor = mode->lpc_floor;
-   st->preemph = mode->preemph;
   
    st->submodes=mode->submodes;
    st->submodeID=st->submodeSelect=mode->defaultSubmode;
-   st->pre_mem=0;
-   st->pre_mem2=0;
    st->bounded_pitch = 1;
 
+   st->encode_submode = 1;
+#ifdef EPIC_48K
+   st->lbr_48k=mode->lbr48k;
+#endif
+
    /* Allocating input buffer */
-   st->inBuf = PUSH(st->stack, st->bufSize, float);
-   st->frame = st->inBuf + st->bufSize - st->windowSize;
+   st->inBuf = speex_alloc((st->windowSize)*sizeof(spx_sig_t));
+   st->frame = st->inBuf;
    /* Allocating excitation buffer */
-   st->excBuf = PUSH(st->stack, st->bufSize, float);
-   st->exc = st->excBuf + st->bufSize - st->windowSize;
-   st->swBuf = PUSH(st->stack, st->bufSize, float);
-   st->sw = st->swBuf + st->bufSize - st->windowSize;
+   st->excBuf = speex_alloc((mode->frameSize+mode->pitchEnd+1)*sizeof(spx_sig_t));
+   st->exc = st->excBuf + mode->pitchEnd + 1;
+   st->swBuf = speex_alloc((mode->frameSize+mode->pitchEnd+1)*sizeof(spx_sig_t));
+   st->sw = st->swBuf + mode->pitchEnd + 1;
 
-   st->exc2Buf = PUSH(st->stack, st->bufSize, float);
-   st->exc2 = st->exc2Buf + st->bufSize - st->windowSize;
+   st->innov = speex_alloc((st->frameSize)*sizeof(spx_sig_t));
 
-   st->innov = PUSH(st->stack, st->frameSize, float);
-
    /* Asymmetric "pseudo-Hamming" window */
    {
       int part1, part2;
-      part1 = st->subframeSize*7/2;
-      part2 = st->subframeSize*5/2;
-      st->window = PUSH(st->stack, st->windowSize, float);
+      part1=st->frameSize - (st->subframeSize>>1);
+      part2=(st->frameSize>>1) + (st->subframeSize>>1);
+      st->window = speex_alloc((st->windowSize)*sizeof(spx_word16_t));
       for (i=0;i<part1;i++)
-         st->window[i]=.54-.46*cos(M_PI*i/part1);
+         st->window[i]=(spx_word16_t)(SIG_SCALING*(.54-.46*cos(M_PI*i/part1)));
       for (i=0;i<part2;i++)
-         st->window[part1+i]=.54+.46*cos(M_PI*i/part2);
+         st->window[part1+i]=(spx_word16_t)(SIG_SCALING*(.54+.46*cos(M_PI*i/part2)));
    }
    /* Create the window for autocorrelation (lag-windowing) */
-   st->lagWindow = PUSH(st->stack, st->lpcSize+1, float);
+   st->lagWindow = speex_alloc((st->lpcSize+1)*sizeof(spx_word16_t));
    for (i=0;i<st->lpcSize+1;i++)
-      st->lagWindow[i]=exp(-.5*sqr(2*M_PI*st->lag_factor*i));
+      st->lagWindow[i]=16384*exp(-.5*sqr(2*M_PI*st->lag_factor*i));
 
-   st->autocorr = PUSH(st->stack, st->lpcSize+1, float);
+   st->autocorr = speex_alloc((st->lpcSize+1)*sizeof(spx_word16_t));
 
-   st->buf2 = PUSH(st->stack, st->windowSize, float);
+   st->lpc = speex_alloc((st->lpcSize)*sizeof(spx_coef_t));
+   st->interp_lpc = speex_alloc((st->lpcSize)*sizeof(spx_coef_t));
+   st->interp_qlpc = speex_alloc((st->lpcSize)*sizeof(spx_coef_t));
+   st->bw_lpc1 = speex_alloc((st->lpcSize)*sizeof(spx_coef_t));
+   st->bw_lpc2 = speex_alloc((st->lpcSize)*sizeof(spx_coef_t));
 
-   st->lpc = PUSH(st->stack, st->lpcSize+1, float);
-   st->interp_lpc = PUSH(st->stack, st->lpcSize+1, float);
-   st->interp_qlpc = PUSH(st->stack, st->lpcSize+1, float);
-   st->bw_lpc1 = PUSH(st->stack, st->lpcSize+1, float);
-   st->bw_lpc2 = PUSH(st->stack, st->lpcSize+1, float);
+   st->lsp = speex_alloc((st->lpcSize)*sizeof(spx_lsp_t));
+   st->qlsp = speex_alloc((st->lpcSize)*sizeof(spx_lsp_t));
+   st->old_lsp = speex_alloc((st->lpcSize)*sizeof(spx_lsp_t));
+   st->old_qlsp = speex_alloc((st->lpcSize)*sizeof(spx_lsp_t));
+   st->interp_lsp = speex_alloc((st->lpcSize)*sizeof(spx_lsp_t));
+   st->interp_qlsp = speex_alloc((st->lpcSize)*sizeof(spx_lsp_t));
 
-   st->lsp = PUSH(st->stack, st->lpcSize, float);
-   st->qlsp = PUSH(st->stack, st->lpcSize, float);
-   st->old_lsp = PUSH(st->stack, st->lpcSize, float);
-   st->old_qlsp = PUSH(st->stack, st->lpcSize, float);
-   st->interp_lsp = PUSH(st->stack, st->lpcSize, float);
-   st->interp_qlsp = PUSH(st->stack, st->lpcSize, float);
-   st->rc = PUSH(st->stack, st->lpcSize, float);
    st->first = 1;
    for (i=0;i<st->lpcSize;i++)
    {
-      st->lsp[i]=(M_PI*((float)(i+1)))/(st->lpcSize+1);
+      st->lsp[i]=LSP_SCALING*(M_PI*((float)(i+1)))/(st->lpcSize+1);
    }
 
-   st->mem_sp = PUSH(st->stack, st->lpcSize, float);
-   st->mem_sw = PUSH(st->stack, st->lpcSize, float);
-   st->mem_sw_whole = PUSH(st->stack, st->lpcSize, float);
-   st->mem_exc = PUSH(st->stack, st->lpcSize, float);
+   st->mem_sp = speex_alloc((st->lpcSize)*sizeof(spx_mem_t));
+   st->mem_sw = speex_alloc((st->lpcSize)*sizeof(spx_mem_t));
+   st->mem_sw_whole = speex_alloc((st->lpcSize)*sizeof(spx_mem_t));
+   st->mem_exc = speex_alloc((st->lpcSize)*sizeof(spx_mem_t));
 
-   st->pi_gain = PUSH(st->stack, st->nbSubframes, float);
+   st->pi_gain = speex_alloc((st->nbSubframes)*sizeof(spx_word32_t));
 
-   st->pitch = PUSH(st->stack, st->nbSubframes, int);
+   st->pitch = speex_alloc((st->nbSubframes)*sizeof(int));
 
-   st->vbr = PUSHS(st->stack, VBRState);
+   st->vbr = speex_alloc(sizeof(VBRState));
    vbr_init(st->vbr);
    st->vbr_quality = 8;
    st->vbr_enabled = 0;
@@ -171,10 +203,14 @@
    st->abr_enabled = 0;
    st->abr_drift = 0;
 
+   st->plc_tuning = 2;
    st->complexity=2;
    st->sampling_rate=8000;
    st->dtx_count=0;
 
+#ifdef ENABLE_VALGRIND
+   VALGRIND_MAKE_READABLE(st, (st->stack-(char*)st));
+#endif
    return st;
 }
 
@@ -182,78 +218,104 @@
 {
    EncState *st=(EncState *)state;
    /* Free all allocated memory */
+#if !(defined(VAR_ARRAYS) || defined (USE_ALLOCA))
+   speex_free_scratch(st->stack);
+#endif
 
+   speex_free (st->inBuf);
+   speex_free (st->excBuf);
+   speex_free (st->innov);
+   speex_free (st->interp_qlpc);
+   speex_free (st->qlsp);
+   speex_free (st->old_qlsp);
+   speex_free (st->interp_qlsp);
+   speex_free (st->swBuf);
+
+   speex_free (st->window);
+   speex_free (st->lagWindow);
+   speex_free (st->autocorr);
+   speex_free (st->lpc);
+   speex_free (st->lsp);
+
+   speex_free (st->interp_lpc);
+   speex_free (st->bw_lpc1);
+   speex_free (st->bw_lpc2);
+   speex_free (st->old_lsp);
+   speex_free (st->interp_lsp);
+   speex_free (st->mem_sp);
+   speex_free (st->mem_sw);
+   speex_free (st->mem_sw_whole);
+   speex_free (st->mem_exc);
+   speex_free (st->pi_gain);
+   speex_free (st->pitch);
+
    vbr_destroy(st->vbr);
+   speex_free (st->vbr);
 
    /*Free state memory... should be last*/
    speex_free(st);
 }
 
-int nb_encode(void *state, float *in, SpeexBits *bits)
+int nb_encode(void *state, void *vin, SpeexBits *bits)
 {
    EncState *st;
    int i, sub, roots;
    int ol_pitch;
-   float ol_pitch_coef;
-   float ol_gain;
-   float *res, *target, *mem;
+   spx_word16_t ol_pitch_coef;
+   spx_word32_t ol_gain;
+   VARDECL(spx_sig_t *res);
+   VARDECL(spx_sig_t *target);
+   VARDECL(spx_mem_t *mem);
    char *stack;
-   float *syn_resp;
-   float lsp_dist=0;
-   float *orig;
+   VARDECL(spx_word16_t *syn_resp);
+   VARDECL(spx_sig_t *real_exc);
+#ifdef EPIC_48K
+   int pitch_half[2];
+   int ol_pitch_id=0;
+#endif
+   spx_word16_t *in = vin;
 
    st=(EncState *)state;
    stack=st->stack;
 
    /* Copy new data in input buffer */
-   speex_move(st->inBuf, st->inBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
-   st->inBuf[st->bufSize-st->frameSize] = in[0] - st->preemph*st->pre_mem;
-   for (i=1;i<st->frameSize;i++)
-      st->inBuf[st->bufSize-st->frameSize+i] = in[i] - st->preemph*in[i-1];
-   st->pre_mem = in[st->frameSize-1];
+   speex_move(st->inBuf, st->inBuf+st->frameSize, (st->windowSize-st->frameSize)*sizeof(spx_sig_t));
+   for (i=0;i<st->frameSize;i++)
+      st->inBuf[st->windowSize-st->frameSize+i] = SHL32(EXTEND32(in[i]), SIG_SHIFT);
 
    /* Move signals 1 frame towards the past */
-   speex_move(st->exc2Buf, st->exc2Buf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
-   speex_move(st->excBuf, st->excBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
-   speex_move(st->swBuf, st->swBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
+   speex_move(st->excBuf, st->excBuf+st->frameSize, (st->max_pitch+1)*sizeof(spx_sig_t));
+   speex_move(st->swBuf, st->swBuf+st->frameSize, (st->max_pitch+1)*sizeof(spx_sig_t));
 
+   {
+      VARDECL(spx_word16_t *w_sig);
+      ALLOC(w_sig, st->windowSize, spx_word16_t);
+      /* Window for analysis */
+      for (i=0;i<st->windowSize;i++)
+         w_sig[i] = EXTRACT16(SHR32(MULT16_16(EXTRACT16(SHR32(st->frame[i],SIG_SHIFT)),st->window[i]),SIG_SHIFT));
 
-   /* Window for analysis */
-   for (i=0;i<st->windowSize;i++)
-      st->buf2[i] = st->frame[i] * st->window[i];
+      /* Compute auto-correlation */
+      _spx_autocorr(w_sig, st->autocorr, st->lpcSize+1, st->windowSize);
+   }
+   st->autocorr[0] = (spx_word16_t) (st->autocorr[0]*st->lpc_floor); /* Noise floor in auto-correlation domain */
 
-   /* Compute auto-correlation */
-   _spx_autocorr(st->buf2, st->autocorr, st->lpcSize+1, st->windowSize);
-
-   st->autocorr[0] += 10;        /* prevents NANs */
-   st->autocorr[0] *= st->lpc_floor; /* Noise floor in auto-correlation domain */
-
    /* Lag windowing: equivalent to filtering in the power-spectrum domain */
    for (i=0;i<st->lpcSize+1;i++)
-      st->autocorr[i] *= st->lagWindow[i];
+      st->autocorr[i] = MULT16_16_Q14(st->autocorr[i],st->lagWindow[i]);
 
    /* Levinson-Durbin */
-   wld(st->lpc+1, st->autocorr, st->rc, st->lpcSize);
-   st->lpc[0]=1;
+   _spx_lpc(st->lpc, st->autocorr, st->lpcSize);
 
    /* LPC to LSPs (x-domain) transform */
-   roots=lpc_to_lsp (st->lpc, st->lpcSize, st->lsp, 15, 0.2, stack);
+   roots=lpc_to_lsp (st->lpc, st->lpcSize, st->lsp, 15, LSP_DELTA1, stack);
    /* Check if we found all the roots */
-   if (roots==st->lpcSize)
+   if (roots!=st->lpcSize)
    {
-      /* LSP x-domain to angle domain*/
-      for (i=0;i<st->lpcSize;i++)
-         st->lsp[i] = acos(st->lsp[i]);
-   } else {
       /* Search again if we can afford it */
       if (st->complexity>1)
-         roots = lpc_to_lsp (st->lpc, st->lpcSize, st->lsp, 11, 0.05, stack);
-      if (roots==st->lpcSize) 
+         roots = lpc_to_lsp (st->lpc, st->lpcSize, st->lsp, 11, LSP_DELTA2, stack);
+      if (roots!=st->lpcSize) 
       {
-         /* LSP x-domain to angle domain*/
-         for (i=0;i<st->lpcSize;i++)
-            st->lsp[i] = acos(st->lsp[i]);
-      } else {
          /*If we can't find all LSP's, do some damage control and use previous filter*/
          for (i=0;i<st->lpcSize;i++)
          {
@@ -263,9 +325,6 @@
    }
 
 
-   lsp_dist=0;
-   for (i=0;i<st->lpcSize;i++)
-      lsp_dist += (st->old_lsp[i] - st->lsp[i])*(st->old_lsp[i] - st->lsp[i]);
 
    /* Whole frame analysis (open-loop estimation of pitch and excitation gain) */
    {
@@ -273,14 +332,11 @@
          for (i=0;i<st->lpcSize;i++)
             st->interp_lsp[i] = st->lsp[i];
       else
-         for (i=0;i<st->lpcSize;i++)
-            st->interp_lsp[i] = .375*st->old_lsp[i] + .625*st->lsp[i];
+         lsp_interpolate(st->old_lsp, st->lsp, st->interp_lsp, st->lpcSize, st->nbSubframes, st->nbSubframes<<1);
 
-      lsp_enforce_margin(st->interp_lsp, st->lpcSize, .002);
+      lsp_enforce_margin(st->interp_lsp, st->lpcSize, LSP_MARGIN);
 
       /* Compute interpolated LPCs (unquantized) for whole frame*/
-      for (i=0;i<st->lpcSize;i++)
-         st->interp_lsp[i] = cos(st->interp_lsp[i]);
       lsp_to_lpc(st->interp_lsp, st->interp_lpc, st->lpcSize,stack);
 
 
@@ -289,7 +345,7 @@
           SUBMODE(lbr_pitch) != -1)
       {
          int nol_pitch[6];
-         float nol_pitch_coef[6];
+         spx_word16_t nol_pitch_coef[6];
          
          bw_lpc(st->gamma1, st->interp_lpc, st->bw_lpc1, st->lpcSize);
          bw_lpc(st->gamma2, st->interp_lpc, st->bw_lpc2, st->lpcSize);
@@ -303,9 +359,13 @@
          /*Try to remove pitch multiples*/
          for (i=1;i<6;i++)
          {
-            if ((nol_pitch_coef[i]>.85*ol_pitch_coef) && 
-                (fabs(nol_pitch[i]-ol_pitch/2.0)<=1 || fabs(nol_pitch[i]-ol_pitch/3.0)<=1 || 
-                 fabs(nol_pitch[i]-ol_pitch/4.0)<=1 || fabs(nol_pitch[i]-ol_pitch/5.0)<=1))
+#ifdef FIXED_POINT
+            if ((nol_pitch_coef[i]>MULT16_16_Q15(nol_pitch_coef[0],27853)) && 
+#else
+            if ((nol_pitch_coef[i]>.85*nol_pitch_coef[0]) && 
+#endif
+                (ABS(2*nol_pitch[i]-ol_pitch)<=2 || ABS(3*nol_pitch[i]-ol_pitch)<=3 || 
+                 ABS(4*nol_pitch[i]-ol_pitch)<=4 || ABS(5*nol_pitch[i]-ol_pitch)<=5))
             {
                /*ol_pitch_coef=nol_pitch_coef[i];*/
                ol_pitch = nol_pitch[i];
@@ -314,6 +374,20 @@
          /*if (ol_pitch>50)
            ol_pitch/=2;*/
          /*ol_pitch_coef = sqrt(ol_pitch_coef);*/
+
+#ifdef EPIC_48K
+         if (st->lbr_48k)
+         {
+            if (ol_pitch < st->min_pitch+2)
+               ol_pitch = st->min_pitch+2;
+            if (ol_pitch > st->max_pitch-2)
+               ol_pitch = st->max_pitch-2;
+            open_loop_nbest_pitch(st->sw, ol_pitch-2, ol_pitch+2, st->frameSize>>1, 
+                                  &pitch_half[0], nol_pitch_coef, 1, stack);
+            open_loop_nbest_pitch(st->sw+(st->frameSize>>1), pitch_half[0]-1, pitch_half[0]+2, st->frameSize>>1, 
+                                  &pitch_half[1], nol_pitch_coef, 1, stack);
+         }
+#endif
       } else {
          ol_pitch=0;
          ol_pitch_coef=0;
@@ -322,16 +396,38 @@
       fir_mem2(st->frame, st->interp_lpc, st->exc, st->frameSize, st->lpcSize, st->mem_exc);
 
       /* Compute open-loop excitation gain */
-      ol_gain=0;
-      for (i=0;i<st->frameSize;i++)
-         ol_gain += st->exc[i]*st->exc[i];
+#ifdef EPIC_48K
+      if (st->lbr_48k)
+      {
+         float ol1=0,ol2=0;
+         float ol_gain2;
+         ol1 = compute_rms(st->exc, st->frameSize>>1);
+         ol2 = compute_rms(st->exc+(st->frameSize>>1), st->frameSize>>1);
+         ol1 *= ol1*(st->frameSize>>1);
+         ol2 *= ol2*(st->frameSize>>1);
+
+         ol_gain2=ol1;
+         if (ol2>ol1)
+            ol_gain2=ol2;
+         ol_gain2 = sqrt(2*ol_gain2*(ol1+ol2))*1.3*(1-.5*GAIN_SCALING_1*GAIN_SCALING_1*ol_pitch_coef*ol_pitch_coef);
       
-      ol_gain=sqrt(1+ol_gain/st->frameSize);
+         ol_gain=SHR(sqrt(1+ol_gain2/st->frameSize),SIG_SHIFT);
+
+      } else {
+#endif
+         ol_gain = SHL32(EXTEND32(compute_rms(st->exc, st->frameSize)),SIG_SHIFT);
+#ifdef EPIC_48K
+      }
+#endif
    }
 
    /*VBR stuff*/
    if (st->vbr && (st->vbr_enabled||st->vad_enabled))
    {
+      float lsp_dist=0;
+      for (i=0;i<st->lpcSize;i++)
+         lsp_dist += (st->old_lsp[i] - st->lsp[i])*(st->old_lsp[i] - st->lsp[i]);
+      lsp_dist /= LSP_SCALING*LSP_SCALING;
       
       if (st->abr_enabled)
       {
@@ -352,7 +448,7 @@
             st->vbr_quality=0;
       }
 
-      st->relative_quality = vbr_analysis(st->vbr, in, st->frameSize, ol_pitch, ol_pitch_coef);
+      st->relative_quality = vbr_analysis(st->vbr, in, st->frameSize, ol_pitch, GAIN_SCALING_1*ol_pitch_coef);
       /*if (delta_qual<0)*/
       /*  delta_qual*=.1*(3+st->vbr_quality);*/
       if (st->vbr_enabled) 
@@ -428,18 +524,28 @@
       st->relative_quality = -1;
    }
 
+   if (st->encode_submode)
+   {
+#ifdef EPIC_48K
+   if (!st->lbr_48k) {
+#endif
+
    /* First, transmit a zero for narrowband */
    speex_bits_pack(bits, 0, 1);
 
    /* Transmit the sub-mode we use for this frame */
    speex_bits_pack(bits, st->submodeID, NB_SUBMODE_BITS);
 
+#ifdef EPIC_48K
+   }
+#endif
+   }
 
    /* If null mode (no transmission), just set a couple things to zero*/
    if (st->submodes[st->submodeID] == NULL)
    {
       for (i=0;i<st->frameSize;i++)
-         st->exc[i]=st->exc2[i]=st->sw[i]=VERY_SMALL;
+         st->exc[i]=st->sw[i]=VERY_SMALL;
 
       for (i=0;i<st->lpcSize;i++)
          st->mem_sw[i]=0;
@@ -449,11 +555,10 @@
       /* Final signal synthesis from excitation */
       iir_mem2(st->exc, st->interp_qlpc, st->frame, st->frameSize, st->lpcSize, st->mem_sp);
 
-      in[0] = st->frame[0] + st->preemph*st->pre_mem2;
-      for (i=1;i<st->frameSize;i++)
-         in[i]=st->frame[i] + st->preemph*in[i-1];
-      st->pre_mem2=in[st->frameSize-1];
-
+#ifdef RESYNTH
+      for (i=0;i<st->frameSize;i++)
+         in[i]=st->frame[i];
+#endif
       return 0;
 
    }
@@ -474,36 +579,80 @@
      st->qlsp[i]=st->lsp[i];
 #endif
 
+#ifdef EPIC_48K
+   if (st->lbr_48k) {
+      speex_bits_pack(bits, pitch_half[0]-st->min_pitch, 7);
+      speex_bits_pack(bits, pitch_half[1]-pitch_half[0]+1, 2);
+      
+      {
+         int quant = (int)floor(.5+7.4*GAIN_SCALING_1*ol_pitch_coef);
+         if (quant>7)
+            quant=7;
+         if (quant<0)
+            quant=0;
+         ol_pitch_id=quant;
+         speex_bits_pack(bits, quant, 3);
+         ol_pitch_coef=GAIN_SCALING*0.13514*quant;
+         
+      }
+      {
+         int qe = (int)(floor(.5+2.1*log(ol_gain*1.0/SIG_SCALING)))-2;
+         if (qe<0)
+            qe=0;
+         if (qe>15)
+            qe=15;
+         ol_gain = exp((qe+2)/2.1)*SIG_SCALING;
+         speex_bits_pack(bits, qe, 4);
+      }
+
+   } else {
+#endif
+
    /*If we use low bit-rate pitch mode, transmit open-loop pitch*/
    if (SUBMODE(lbr_pitch)!=-1)
    {
       speex_bits_pack(bits, ol_pitch-st->min_pitch, 7);
    } 
-   
+
    if (SUBMODE(forced_pitch_gain))
    {
       int quant;
-      quant = (int)floor(.5+15*ol_pitch_coef);
+      quant = (int)floor(.5+15*ol_pitch_coef*GAIN_SCALING_1);
       if (quant>15)
          quant=15;
       if (quant<0)
          quant=0;
       speex_bits_pack(bits, quant, 4);
-      ol_pitch_coef=0.066667*quant;
+      ol_pitch_coef=GAIN_SCALING*0.066667*quant;
    }
    
    
    /*Quantize and transmit open-loop excitation gain*/
+#ifdef FIXED_POINT
    {
-      int qe = (int)(floor(.5+3.5*log(ol_gain)));
+      int qe = scal_quant32(ol_gain, ol_gain_table, 32);
+      /*ol_gain = exp(qe/3.5)*SIG_SCALING;*/
+      ol_gain = MULT16_32_Q15(28406,ol_gain_table[qe]);
+      speex_bits_pack(bits, qe, 5);
+   }
+#else
+   {
+      int qe = (int)(floor(.5+3.5*log(ol_gain*1.0/SIG_SCALING)));
       if (qe<0)
          qe=0;
       if (qe>31)
          qe=31;
-      ol_gain = exp(qe/3.5);
+      ol_gain = exp(qe/3.5)*SIG_SCALING;
       speex_bits_pack(bits, qe, 5);
    }
+#endif
 
+
+#ifdef EPIC_48K
+   }
+#endif
+
+
    /* Special case for first frame */
    if (st->first)
    {
@@ -512,22 +661,29 @@
    }
 
    /* Filter response */
-   res = PUSH(stack, st->subframeSize, float);
+   ALLOC(res, st->subframeSize, spx_sig_t);
    /* Target signal */
-   target = PUSH(stack, st->subframeSize, float);
-   syn_resp = PUSH(stack, st->subframeSize, float);
-   mem = PUSH(stack, st->lpcSize, float);
-   orig = PUSH(stack, st->frameSize, float);
-   for (i=0;i<st->frameSize;i++)
-      orig[i]=st->frame[i];
+   ALLOC(target, st->subframeSize, spx_sig_t);
+   ALLOC(syn_resp, st->subframeSize, spx_word16_t);
+   ALLOC(real_exc, st->subframeSize, spx_sig_t);
+   ALLOC(mem, st->lpcSize, spx_mem_t);
 
    /* Loop on sub-frames */
    for (sub=0;sub<st->nbSubframes;sub++)
    {
-      float tmp;
       int   offset;
-      float *sp, *sw, *exc, *exc2;
+      spx_sig_t *sp, *sw, *exc;
       int pitch;
+      int response_bound = st->subframeSize;
+#ifdef EPIC_48K
+      if (st->lbr_48k)
+      {
+         if (sub*2 < st->nbSubframes)
+            ol_pitch = pitch_half[0];
+         else
+            ol_pitch = pitch_half[1];
+      }
+#endif
 
       /* Offset relative to start of frame */
       offset = st->subframeSize*sub;
@@ -538,38 +694,31 @@
       /* Weighted signal */
       sw=st->sw+offset;
 
-      exc2=st->exc2+offset;
-
-
       /* LSP interpolation (quantized and unquantized) */
-      tmp = (1.0 + sub)/st->nbSubframes;
-      for (i=0;i<st->lpcSize;i++)
-         st->interp_lsp[i] = (1-tmp)*st->old_lsp[i] + tmp*st->lsp[i];
-      for (i=0;i<st->lpcSize;i++)
-         st->interp_qlsp[i] = (1-tmp)*st->old_qlsp[i] + tmp*st->qlsp[i];
+      lsp_interpolate(st->old_lsp, st->lsp, st->interp_lsp, st->lpcSize, sub, st->nbSubframes);
+      lsp_interpolate(st->old_qlsp, st->qlsp, st->interp_qlsp, st->lpcSize, sub, st->nbSubframes);
 
       /* Make sure the filters are stable */
-      lsp_enforce_margin(st->interp_lsp, st->lpcSize, .002);
-      lsp_enforce_margin(st->interp_qlsp, st->lpcSize, .002);
+      lsp_enforce_margin(st->interp_lsp, st->lpcSize, LSP_MARGIN);
+      lsp_enforce_margin(st->interp_qlsp, st->lpcSize, LSP_MARGIN);
 
       /* Compute interpolated LPCs (quantized and unquantized) */
-      for (i=0;i<st->lpcSize;i++)
-         st->interp_lsp[i] = cos(st->interp_lsp[i]);
       lsp_to_lpc(st->interp_lsp, st->interp_lpc, st->lpcSize,stack);
 
-      for (i=0;i<st->lpcSize;i++)
-         st->interp_qlsp[i] = cos(st->interp_qlsp[i]);
       lsp_to_lpc(st->interp_qlsp, st->interp_qlpc, st->lpcSize, stack);
 
       /* Compute analysis filter gain at w=pi (for use in SB-CELP) */
-      tmp=1;
-      st->pi_gain[sub]=0;
-      for (i=0;i<=st->lpcSize;i++)
       {
-         st->pi_gain[sub] += tmp*st->interp_qlpc[i];
-         tmp = -tmp;
+         spx_word32_t pi_g=LPC_SCALING;
+         for (i=0;i<st->lpcSize;i+=2)
+         {
+            /*pi_g += -st->interp_qlpc[i] +  st->interp_qlpc[i+1];*/
+            pi_g = ADD32(pi_g, SUB32(st->interp_qlpc[i+1],st->interp_qlpc[i]));
+         }
+         st->pi_gain[sub] = pi_g;
       }
 
+
       /* Compute bandwidth-expanded (unquantized) LPCs for perceptual weighting */
       bw_lpc(st->gamma1, st->interp_lpc, st->bw_lpc1, st->lpcSize);
       if (st->gamma2>=0)
@@ -577,43 +726,55 @@
       else
       {
          st->bw_lpc2[0]=1;
-         st->bw_lpc2[1]=-st->preemph;
-         for (i=2;i<=st->lpcSize;i++)
+         for (i=1;i<=st->lpcSize;i++)
             st->bw_lpc2[i]=0;
       }
 
-      /* Compute impulse response of A(z/g1) / ( A(z)*A(z/g2) )*/
       for (i=0;i<st->subframeSize;i++)
-         exc[i]=0;
-      exc[0]=1;
-      syn_percep_zero(exc, st->interp_qlpc, st->bw_lpc1, st->bw_lpc2, syn_resp, st->subframeSize, st->lpcSize, stack);
-
+         real_exc[i] = exc[i];
+      
+      if (st->complexity==0)
+         response_bound >>= 1;
+      compute_impulse_response(st->interp_qlpc, st->bw_lpc1, st->bw_lpc2, syn_resp, response_bound, st->lpcSize, stack);
+      for (i=response_bound;i<st->subframeSize;i++)
+         syn_resp[i]=VERY_SMALL;
+      
       /* Reset excitation */
       for (i=0;i<st->subframeSize;i++)
-         exc[i]=0;
-      for (i=0;i<st->subframeSize;i++)
-         exc2[i]=0;
+         exc[i]=VERY_SMALL;
 
       /* Compute zero response of A(z/g1) / ( A(z/g2) * A(z) ) */
       for (i=0;i<st->lpcSize;i++)
          mem[i]=st->mem_sp[i];
+#ifdef SHORTCUTS2
+      iir_mem2(exc, st->interp_qlpc, exc, response_bound, st->lpcSize, mem);
+      for (i=0;i<st->lpcSize;i++)
+         mem[i]=st->mem_sw[i];
+      filter_mem2(exc, st->bw_lpc1, st->bw_lpc2, res, response_bound, st->lpcSize, mem);
+      for (i=response_bound;i<st->subframeSize;i++)
+         res[i]=0;
+#else
       iir_mem2(exc, st->interp_qlpc, exc, st->subframeSize, st->lpcSize, mem);
-      
       for (i=0;i<st->lpcSize;i++)
          mem[i]=st->mem_sw[i];
       filter_mem2(exc, st->bw_lpc1, st->bw_lpc2, res, st->subframeSize, st->lpcSize, mem);
+#endif
       
       /* Compute weighted signal */
       for (i=0;i<st->lpcSize;i++)
          mem[i]=st->mem_sw[i];
       filter_mem2(sp, st->bw_lpc1, st->bw_lpc2, sw, st->subframeSize, st->lpcSize, mem);
       
+      if (st->complexity==0)
+         for (i=0;i<st->lpcSize;i++)
+            st->mem_sw[i]=mem[i];
+      
       /* Compute target signal */
       for (i=0;i<st->subframeSize;i++)
          target[i]=sw[i]-res[i];
 
       for (i=0;i<st->subframeSize;i++)
-         exc[i]=exc2[i]=0;
+         exc[i]=0;
 
       /* If we have a long-term predictor (otherwise, something's wrong) */
       if (SUBMODE(ltp_quant))
@@ -645,85 +806,93 @@
          if (st->bounded_pitch && pit_max>offset)
             pit_max=offset;
 
+#ifdef EPIC_48K
+         if (st->lbr_48k)
+         {
+            pitch = SUBMODE(ltp_quant)(target, sw, st->interp_qlpc, st->bw_lpc1, st->bw_lpc2,
+                                       exc, SUBMODE(ltp_params), pit_min, pit_max, ol_pitch_coef,
+                                       st->lpcSize, st->subframeSize, bits, stack, 
+                                       exc, syn_resp, st->complexity, ol_pitch_id, st->plc_tuning);
+         } else {
+#endif
+
          /* Perform pitch search */
          pitch = SUBMODE(ltp_quant)(target, sw, st->interp_qlpc, st->bw_lpc1, st->bw_lpc2,
                                     exc, SUBMODE(ltp_params), pit_min, pit_max, ol_pitch_coef,
                                     st->lpcSize, st->subframeSize, bits, stack, 
-                                    exc2, syn_resp, st->complexity);
+                                    exc, syn_resp, st->complexity, 0, st->plc_tuning);
+#ifdef EPIC_48K
+         }
+#endif
 
          st->pitch[sub]=pitch;
       } else {
          speex_error ("No pitch prediction, what's wrong");
       }
 
-      /* Update target for adaptive codebook contribution */
-      syn_percep_zero(exc, st->interp_qlpc, st->bw_lpc1, st->bw_lpc2, res, st->subframeSize, st->lpcSize, stack);
-      for (i=0;i<st->subframeSize;i++)
-         target[i]-=res[i];
-
-
       /* Quantization of innovation */
       {
-         float *innov;
-         float ener=0, ener_1;
+         spx_sig_t *innov;
+         spx_word32_t ener=0;
+         spx_word16_t fine_gain;
 
          innov = st->innov+sub*st->subframeSize;
          for (i=0;i<st->subframeSize;i++)
             innov[i]=0;
          
-         residue_percep_zero(target, st->interp_qlpc, st->bw_lpc1, st->bw_lpc2, st->buf2, st->subframeSize, st->lpcSize, stack);
          for (i=0;i<st->subframeSize;i++)
-            ener+=st->buf2[i]*st->buf2[i];
-         ener=sqrt(.1+ener/st->subframeSize);
-         /*for (i=0;i<st->subframeSize;i++)
-            printf ("%f\n", st->buf2[i]/ener);
-         */
+            real_exc[i] = SUB32(real_exc[i], exc[i]);
+
+         ener = SHL32(EXTEND32(compute_rms(real_exc, st->subframeSize)),SIG_SHIFT);
          
-         ener /= ol_gain;
-
+         /*FIXME: Should use DIV32_16 and make sure result fits in 16 bits */
+#ifdef FIXED_POINT
+         {
+            spx_word32_t f = DIV32(ener,PSHR32(ol_gain,SIG_SHIFT));
+            if (f<=32767)
+               fine_gain = f;
+            else
+               fine_gain = 32767;
+         }
+#else
+         fine_gain = DIV32_16(ener,PSHR32(ol_gain,SIG_SHIFT));
+#endif
          /* Calculate gain correction for the sub-frame (if any) */
          if (SUBMODE(have_subframe_gain)) 
          {
             int qe;
-            ener=log(ener);
             if (SUBMODE(have_subframe_gain)==3)
             {
-               qe = vq_index(&ener, exc_gain_quant_scal3, 1, 8);
+               qe = scal_quant(fine_gain, exc_gain_quant_scal3_bound, 8);
                speex_bits_pack(bits, qe, 3);
-               ener=exc_gain_quant_scal3[qe];
+               ener=MULT16_32_Q14(exc_gain_quant_scal3[qe],ol_gain);
             } else {
-               qe = vq_index(&ener, exc_gain_quant_scal1, 1, 2);
+               qe = scal_quant(fine_gain, exc_gain_quant_scal1_bound, 2);
                speex_bits_pack(bits, qe, 1);
-               ener=exc_gain_quant_scal1[qe];               
+               ener=MULT16_32_Q14(exc_gain_quant_scal1[qe],ol_gain);               
             }
-            ener=exp(ener);
          } else {
-            ener=1;
+            ener=ol_gain;
          }
 
-         ener*=ol_gain;
-
          /*printf ("%f %f\n", ener, ol_gain);*/
 
-         ener_1 = 1/ener;
+         /* Normalize innovation */
+         signal_div(target, target, ener, st->subframeSize);
 
-         /* Normalize innovation */
-         for (i=0;i<st->subframeSize;i++)
-            target[i]*=ener_1;
-         
          /* Quantize innovation */
          if (SUBMODE(innovation_quant))
          {
             /* Codebook search */
             SUBMODE(innovation_quant)(target, st->interp_qlpc, st->bw_lpc1, st->bw_lpc2, 
                                       SUBMODE(innovation_params), st->lpcSize, st->subframeSize, 
-                                      innov, syn_resp, bits, stack, st->complexity);
+                                      innov, syn_resp, bits, stack, st->complexity, SUBMODE(double_codebook));
             
             /* De-normalize innovation and update excitation */
+            signal_mul(innov, innov, ener, st->subframeSize);
+
             for (i=0;i<st->subframeSize;i++)
-               innov[i]*=ener;
-            for (i=0;i<st->subframeSize;i++)
-               exc[i] += innov[i];
+               exc[i] = ADD32(exc[i],innov[i]);
          } else {
             speex_error("No fixed codebook");
          }
@@ -731,35 +900,30 @@
          /* In some (rare) modes, we do a second search (more bits) to reduce noise even more */
          if (SUBMODE(double_codebook)) {
             char *tmp_stack=stack;
-            float *innov2 = PUSH(tmp_stack, st->subframeSize, float);
+            VARDECL(spx_sig_t *innov2);
+            ALLOC(innov2, st->subframeSize, spx_sig_t);
             for (i=0;i<st->subframeSize;i++)
                innov2[i]=0;
             for (i=0;i<st->subframeSize;i++)
                target[i]*=2.2;
             SUBMODE(innovation_quant)(target, st->interp_qlpc, st->bw_lpc1, st->bw_lpc2, 
                                       SUBMODE(innovation_params), st->lpcSize, st->subframeSize, 
-                                      innov2, syn_resp, bits, tmp_stack, st->complexity);
+                                      innov2, syn_resp, bits, stack, st->complexity, 0);
+            signal_mul(innov2, innov2, (spx_word32_t) (ener*(1/2.2)), st->subframeSize);
             for (i=0;i<st->subframeSize;i++)
-               innov2[i]*=ener*(1/2.2);
-            for (i=0;i<st->subframeSize;i++)
-               exc[i] += innov2[i];
+               exc[i] = ADD32(exc[i],innov2[i]);
+            stack = tmp_stack;
          }
 
-         for (i=0;i<st->subframeSize;i++)
-            target[i]*=ener;
-
       }
 
-      /*Keep the previous memory*/
-      for (i=0;i<st->lpcSize;i++)
-         mem[i]=st->mem_sp[i];
       /* Final signal synthesis from excitation */
       iir_mem2(exc, st->interp_qlpc, sp, st->subframeSize, st->lpcSize, st->mem_sp);
 
       /* Compute weighted signal again, from synthesized speech (not sure it's the right thing) */
-      filter_mem2(sp, st->bw_lpc1, st->bw_lpc2, sw, st->subframeSize, st->lpcSize, st->mem_sw);
-      for (i=0;i<st->subframeSize;i++)
-         exc2[i]=exc[i];
+      if (st->complexity!=0)
+         filter_mem2(sp, st->bw_lpc1, st->bw_lpc2, sw, st->subframeSize, st->lpcSize, st->mem_sw);
+      
    }
 
    /* Store the LSPs for interpolation in the next frame */
@@ -782,24 +946,19 @@
    /* The next frame will not be the first (Duh!) */
    st->first = 0;
 
+#ifdef RESYNTH
+   /* Replace input by synthesized speech */
+   for (i=0;i<st->frameSize;i++)
    {
-      float ener=0, err=0;
-      float snr;
-      for (i=0;i<st->frameSize;i++)
-      {
-         ener+=st->frame[i]*st->frame[i];
-         err += (st->frame[i]-orig[i])*(st->frame[i]-orig[i]);
-      }
-      snr = 10*log10((ener+1)/(err+1));
-      /*printf ("%f %f %f\n", snr, ener, err);*/
+      spx_word32_t sig = PSHR32(st->frame[i],SIG_SHIFT);
+      if (sig>32767)
+         sig = 32767;
+      if (sig<-32767)
+         sig = -32767;
+     in[i]=sig;
    }
+#endif
 
-   /* Replace input by synthesized speech */
-   in[0] = st->frame[0] + st->preemph*st->pre_mem2;
-   for (i=1;i<st->frameSize;i++)
-     in[i]=st->frame[i] + st->preemph*in[i-1];
-   st->pre_mem2=in[st->frameSize-1];
-
    if (SUBMODE(innovation_quant) == noise_codebook_quant || st->submodeID==0)
       st->bounded_pitch = 1;
    else
@@ -809,63 +968,70 @@
 }
 
 
-void *nb_decoder_init(SpeexMode *m)
+void *nb_decoder_init(const SpeexMode *m)
 {
    DecState *st;
-   SpeexNBMode *mode;
+   const SpeexNBMode *mode;
    int i;
 
-   mode=(SpeexNBMode*)m->mode;
-   st = (DecState *)speex_alloc(sizeof(DecState)+4000*sizeof(float));
+   mode=(const SpeexNBMode*)m->mode;
+   st = (DecState *)speex_alloc(sizeof(DecState));
+   if (!st)
+      return NULL;
+#if defined(VAR_ARRAYS) || defined (USE_ALLOCA)
+   st->stack = NULL;
+#else
+   st->stack = (char*)speex_alloc_scratch(NB_DEC_STACK);
+#endif
+
    st->mode=m;
 
-   st->stack = ((char*)st) + sizeof(DecState);
 
+   st->encode_submode = 1;
+#ifdef EPIC_48K
+   st->lbr_48k=mode->lbr48k;
+#endif
+
    st->first=1;
    /* Codec parameters, should eventually have several "modes"*/
    st->frameSize = mode->frameSize;
-   st->windowSize = st->frameSize*3/2;
    st->nbSubframes=mode->frameSize/mode->subframeSize;
    st->subframeSize=mode->subframeSize;
    st->lpcSize = mode->lpcSize;
-   st->bufSize = mode->bufSize;
-   st->gamma1=mode->gamma1;
-   st->gamma2=mode->gamma2;
    st->min_pitch=mode->pitchStart;
    st->max_pitch=mode->pitchEnd;
-   st->preemph = mode->preemph;
 
    st->submodes=mode->submodes;
    st->submodeID=mode->defaultSubmode;
 
-   st->pre_mem=0;
    st->lpc_enh_enabled=0;
 
 
-   st->inBuf = PUSH(st->stack, st->bufSize, float);
-   st->frame = st->inBuf + st->bufSize - st->windowSize;
-   st->excBuf = PUSH(st->stack, st->bufSize, float);
-   st->exc = st->excBuf + st->bufSize - st->windowSize;
-   for (i=0;i<st->bufSize;i++)
+   st->inBuf = speex_alloc((st->frameSize)*sizeof(spx_sig_t));
+   st->frame = st->inBuf;
+   st->excBuf = speex_alloc((st->frameSize + st->max_pitch + 1)*sizeof(spx_sig_t));
+   st->exc = st->excBuf + st->max_pitch + 1;
+   for (i=0;i<st->frameSize;i++)
       st->inBuf[i]=0;
-   for (i=0;i<st->bufSize;i++)
+   for (i=0;i<st->frameSize + st->max_pitch + 1;i++)
       st->excBuf[i]=0;
-   st->innov = PUSH(st->stack, st->frameSize, float);
+   st->innov = speex_alloc((st->frameSize)*sizeof(spx_sig_t));
 
-   st->interp_qlpc = PUSH(st->stack, st->lpcSize+1, float);
-   st->qlsp = PUSH(st->stack, st->lpcSize, float);
-   st->old_qlsp = PUSH(st->stack, st->lpcSize, float);
-   st->interp_qlsp = PUSH(st->stack, st->lpcSize, float);
-   st->mem_sp = PUSH(st->stack, 5*st->lpcSize, float);
-   st->comb_mem = PUSHS(st->stack, CombFilterMem);
-   comp_filter_mem_init (st->comb_mem);
+   st->interp_qlpc = speex_alloc(st->lpcSize*sizeof(spx_coef_t));
+   st->qlsp = speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
+   st->old_qlsp = speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
+   st->interp_qlsp = speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
+   st->mem_sp = speex_alloc((5*st->lpcSize)*sizeof(spx_mem_t));
+   st->comb_mem = speex_alloc(sizeof(CombFilterMem));
+   comb_filter_mem_init (st->comb_mem);
 
-   st->pi_gain = PUSH(st->stack, st->nbSubframes, float);
+   st->pi_gain = speex_alloc((st->nbSubframes)*sizeof(spx_word32_t));
    st->last_pitch = 40;
    st->count_lost=0;
    st->pitch_gain_buf[0] = st->pitch_gain_buf[1] = st->pitch_gain_buf[2] = 0;
    st->pitch_gain_buf_idx = 0;
-
+   st->seed = 1000;
+   
    st->sampling_rate=8000;
    st->last_ol_gain = 0;
 
@@ -877,6 +1043,9 @@
    st->voc_m1=st->voc_m2=st->voc_mean=0;
    st->voc_offset=0;
    st->dtx_enabled=0;
+#ifdef ENABLE_VALGRIND
+   VALGRIND_MAKE_READABLE(st, (st->stack-(char*)st));
+#endif
    return st;
 }
 
@@ -885,40 +1054,78 @@
    DecState *st;
    st=(DecState*)state;
    
+#if !(defined(VAR_ARRAYS) || defined (USE_ALLOCA))
+   speex_free_scratch(st->stack);
+#endif
+
+   speex_free (st->inBuf);
+   speex_free (st->excBuf);
+   speex_free (st->innov);
+   speex_free (st->interp_qlpc);
+   speex_free (st->qlsp);
+   speex_free (st->old_qlsp);
+   speex_free (st->interp_qlsp);
+   speex_free (st->mem_sp);
+   speex_free (st->comb_mem);
+   speex_free (st->pi_gain);
+
    speex_free(state);
 }
 
 #define median3(a, b, c)	((a) < (b) ? ((b) < (c) ? (b) : ((a) < (c) ? (c) : (a))) : ((c) < (b) ? (b) : ((c) < (a) ? (c) : (a))))
 
-static void nb_decode_lost(DecState *st, float *out, char *stack)
+#ifdef FIXED_POINT
+const spx_word16_t attenuation[10] = {32767, 31483, 27923, 22861, 17278, 12055, 7764, 4616, 2533, 1283};
+#else
+const spx_word16_t attenuation[10] = {1., 0.961, 0.852, 0.698, 0.527, 0.368, 0.237, 0.141, 0.077, 0.039};
+
+#endif
+
+static void nb_decode_lost(DecState *st, spx_word16_t *out, char *stack)
 {
    int i, sub;
-   float *awk1, *awk2, *awk3;
-   float pitch_gain, fact, gain_med;
+   VARDECL(spx_coef_t *awk1);
+   VARDECL(spx_coef_t *awk2);
+   VARDECL(spx_coef_t *awk3);
+   spx_word16_t pitch_gain;
+   spx_word16_t fact;
+   spx_word16_t gain_med;
+   spx_word16_t innov_gain;
+   
+   if (st->count_lost<10)
+      fact = attenuation[st->count_lost];
+   else
+      fact = 0;
 
-   fact = exp(-.04*st->count_lost*st->count_lost);
    gain_med = median3(st->pitch_gain_buf[0], st->pitch_gain_buf[1], st->pitch_gain_buf[2]);
    if (gain_med < st->last_pitch_gain)
       st->last_pitch_gain = gain_med;
    
+#ifdef FIXED_POINT
    pitch_gain = st->last_pitch_gain;
+   if (pitch_gain>62)
+      pitch_gain = 62;
+   pitch_gain = SHL(pitch_gain, 9);
+#else   
+   pitch_gain = GAIN_SCALING_1*st->last_pitch_gain;
    if (pitch_gain>.95)
       pitch_gain=.95;
+#endif
 
-   pitch_gain *= fact;
+   pitch_gain = MULT16_16_Q15(fact,pitch_gain) + VERY_SMALL;
 
    /* Shift all buffers by one frame */
-   speex_move(st->inBuf, st->inBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
-   speex_move(st->excBuf, st->excBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
+   /*speex_move(st->inBuf, st->inBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(spx_sig_t));*/
+   speex_move(st->excBuf, st->excBuf+st->frameSize, (st->max_pitch + 1)*sizeof(spx_sig_t));
 
-   awk1=PUSH(stack, (st->lpcSize+1), float);
-   awk2=PUSH(stack, (st->lpcSize+1), float);
-   awk3=PUSH(stack, (st->lpcSize+1), float);
+   ALLOC(awk1, (st->lpcSize+1), spx_coef_t);
+   ALLOC(awk2, (st->lpcSize+1), spx_coef_t);
+   ALLOC(awk3, (st->lpcSize+1), spx_coef_t);
 
    for (sub=0;sub<st->nbSubframes;sub++)
    {
       int offset;
-      float *sp, *exc;
+      spx_sig_t *sp, *exc;
       /* Offset relative to start of frame */
       offset = st->subframeSize*sub;
       /* Original signal */
@@ -930,49 +1137,32 @@
       /* Calculate perceptually enhanced LPC filter */
       if (st->lpc_enh_enabled)
       {
-         float r=.9;
-         
-         float k1,k2,k3;
+         spx_word16_t k1,k2,k3;
          if (st->submodes[st->submodeID] != NULL)
          {
             k1=SUBMODE(lpc_enh_k1);
             k2=SUBMODE(lpc_enh_k2);
+            k3=SUBMODE(lpc_enh_k3);
          } else {
-            k1=k2=.7;
+            k1=k2=.7*GAMMA_SCALING;
+            k3=.0;
          }
-         k3=(1-(1-r*k1)/(1-r*k2))/r;
-         if (!st->lpc_enh_enabled)
-         {
-            k1=k2;
-            k3=0;
-         }
          bw_lpc(k1, st->interp_qlpc, awk1, st->lpcSize);
          bw_lpc(k2, st->interp_qlpc, awk2, st->lpcSize);
          bw_lpc(k3, st->interp_qlpc, awk3, st->lpcSize);
       }
         
       /* Make up a plausible excitation */
-      /* THIS CAN BE IMPROVED */
+      /* FIXME: THIS CAN BE IMPROVED */
       /*if (pitch_gain>.95)
         pitch_gain=.95;*/
-      {
-         float innov_gain=0;
-         for (i=0;i<st->frameSize;i++)
-            innov_gain += st->innov[i]*st->innov[i];
-         innov_gain=sqrt(innov_gain/st->frameSize);
+      innov_gain = compute_rms(st->innov, st->frameSize);
       for (i=0;i<st->subframeSize;i++)
       {
-#if 0
-         exc[i] = pitch_gain * exc[i - st->last_pitch] + fact*sqrt(1-pitch_gain)*st->innov[i+offset];
-         /*Just so it give the same lost packets as with if 0*/
-         /*rand();*/
-#else
-         /*exc[i]=pitch_gain*exc[i-st->last_pitch] +  fact*st->innov[i+offset];*/
-         exc[i]=pitch_gain*exc[i-st->last_pitch] + 
-         fact*sqrt(1-pitch_gain)*speex_rand(innov_gain);
-#endif
+         exc[i]= MULT16_32_Q15(pitch_gain, (exc[i-st->last_pitch]+VERY_SMALL)) + 
+               MULT16_32_Q15(fact, MULT16_32_Q15(sqrt(SHL(Q15ONE,15)-SHL(pitch_gain,15)),speex_rand(innov_gain, &st->seed)));
       }
-      }
+      
       for (i=0;i<st->subframeSize;i++)
          sp[i]=exc[i];
       
@@ -991,38 +1181,56 @@
       }      
    }
 
-   out[0] = st->frame[0] + st->preemph*st->pre_mem;
-   for (i=1;i<st->frameSize;i++)
-      out[i]=st->frame[i] + st->preemph*out[i-1];
-   st->pre_mem=out[st->frameSize-1];
+   for (i=0;i<st->frameSize;i++)
+   {
+      spx_word32_t sig = PSHR32(st->frame[i],SIG_SHIFT);
+      if (sig>32767)
+         sig = 32767;
+      if (sig<-32767)
+         sig = -32767;
+     out[i]=sig;
+   }
    
    st->first = 0;
    st->count_lost++;
-   st->pitch_gain_buf[st->pitch_gain_buf_idx++] = pitch_gain;
+   st->pitch_gain_buf[st->pitch_gain_buf_idx++] = PSHR(pitch_gain,9);
    if (st->pitch_gain_buf_idx > 2) /* rollover */
       st->pitch_gain_buf_idx = 0;
 }
 
-int nb_decode(void *state, SpeexBits *bits, float *out)
+int nb_decode(void *state, SpeexBits *bits, void *vout)
 {
    DecState *st;
    int i, sub;
    int pitch;
-   float pitch_gain[3];
-   float ol_gain=0;
+   spx_word16_t pitch_gain[3];
+   spx_word32_t ol_gain=0;
    int ol_pitch=0;
-   float ol_pitch_coef=0;
+   spx_word16_t ol_pitch_coef=0;
    int best_pitch=40;
-   float best_pitch_gain=0;
+   spx_word16_t best_pitch_gain=0;
    int wideband;
    int m;
    char *stack;
-   float *awk1, *awk2, *awk3;
-   float pitch_average=0;
+   VARDECL(spx_coef_t *awk1);
+   VARDECL(spx_coef_t *awk2);
+   VARDECL(spx_coef_t *awk3);
+   spx_word16_t pitch_average=0;
+#ifdef EPIC_48K
+   int pitch_half[2];
+   int ol_pitch_id=0;
+#endif
+   spx_word16_t *out = vout;
 
    st=(DecState*)state;
    stack=st->stack;
 
+   if (st->encode_submode)
+   {
+#ifdef EPIC_48K
+   if (!st->lbr_48k) {
+#endif
+
    /* Check if we're in DTX mode*/
    if (!bits && st->dtx_enabled)
    {
@@ -1038,6 +1246,8 @@
 
       /* Search for next narrowband block (handle requests, skip wideband blocks) */
       do {
+         if (speex_bits_remaining(bits)<5)
+            return -1;
          wideband = speex_bits_unpack_unsigned(bits, 1);
          if (wideband) /* Skip wideband block (for compatibility) */
          {
@@ -1052,6 +1262,9 @@
             } 
             advance -= (SB_SUBMODE_BITS+1);
             speex_bits_advance(bits, advance);
+            
+            if (speex_bits_remaining(bits)<5)
+               return -1;
             wideband = speex_bits_unpack_unsigned(bits, 1);
             if (wideband)
             {
@@ -1067,13 +1280,14 @@
                wideband = speex_bits_unpack_unsigned(bits, 1);
                if (wideband)
                {
-                  speex_warning ("More than to wideband layers found: corrupted stream?");
+                  speex_warning ("More than two wideband layers found: corrupted stream?");
                   return -2;
                }
 
             }
          }
-
+         if (speex_bits_remaining(bits)<4)
+            return -1;
          /* FIXME: Check for overflow */
          m = speex_bits_unpack_unsigned(bits, 4);
          if (m==15) /* We found a terminator */
@@ -1101,29 +1315,28 @@
       st->submodeID = m;
 
    }
+#ifdef EPIC_48K
+   }
+#endif
+   }
 
    /* Shift all buffers by one frame */
-   speex_move(st->inBuf, st->inBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
-   speex_move(st->excBuf, st->excBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
+   speex_move(st->excBuf, st->excBuf+st->frameSize, (st->max_pitch + 1)*sizeof(spx_sig_t));
 
    /* If null mode (no transmission), just set a couple things to zero*/
    if (st->submodes[st->submodeID] == NULL)
    {
-      float *lpc;
-      lpc = PUSH(stack,11, float);
-      bw_lpc(.93, st->interp_qlpc, lpc, 10);
-      /*for (i=0;i<st->frameSize;i++)
-        st->exc[i]=0;*/
+      VARDECL(spx_coef_t *lpc);
+      ALLOC(lpc, st->lpcSize, spx_coef_t);
+      bw_lpc(GAMMA_SCALING*.93, st->interp_qlpc, lpc, st->lpcSize);
       {
          float innov_gain=0;
-         float pgain=st->last_pitch_gain;
+         float pgain=GAIN_SCALING_1*st->last_pitch_gain;
          if (pgain>.6)
             pgain=.6;
+	 innov_gain = compute_rms(st->innov, st->frameSize);
          for (i=0;i<st->frameSize;i++)
-            innov_gain += st->innov[i]*st->innov[i];
-         innov_gain=sqrt(innov_gain/st->frameSize);
-         for (i=0;i<st->frameSize;i++)
-            st->exc[i]=0;
+            st->exc[i]=VERY_SMALL;
          speex_rand_vec(innov_gain, st->exc, st->frameSize);
       }
 
@@ -1133,10 +1346,16 @@
       /* Final signal synthesis from excitation */
       iir_mem2(st->exc, lpc, st->frame, st->frameSize, st->lpcSize, st->mem_sp);
 
-      out[0] = st->frame[0] + st->preemph*st->pre_mem;
-      for (i=1;i<st->frameSize;i++)
-         out[i]=st->frame[i] + st->preemph*out[i-1];
-      st->pre_mem=out[st->frameSize-1];
+      for (i=0;i<st->frameSize;i++)
+      {
+         spx_word32_t sig = PSHR32(st->frame[i],SIG_SHIFT);
+         if (sig>32767)
+            sig = 32767;
+         if (sig<-32767)
+            sig = -32767;
+         out[i]=sig;
+      }
+
       st->count_lost=0;
       return 0;
    }
@@ -1147,12 +1366,17 @@
    /*Damp memory if a frame was lost and the LSP changed too much*/
    if (st->count_lost)
    {
-      float lsp_dist=0, fact;
+      spx_word16_t fact;
+      spx_word32_t lsp_dist=0;
       for (i=0;i<st->lpcSize;i++)
-         lsp_dist += fabs(st->old_qlsp[i] - st->qlsp[i]);
+         lsp_dist = ADD32(lsp_dist, EXTEND32(ABS(st->old_qlsp[i] - st->qlsp[i])));
+#ifdef FIXED_POINT
+      fact = SHR16(19661,SHR32(lsp_dist,LSP_SHIFT+2));      
+#else
       fact = .6*exp(-.2*lsp_dist);
+#endif
       for (i=0;i<2*st->lpcSize;i++)
-         st->mem_sp[i] *= fact;
+         st->mem_sp[i] = MULT16_32_Q15(fact,st->mem_sp[i]);
    }
 
 
@@ -1163,6 +1387,23 @@
          st->old_qlsp[i] = st->qlsp[i];
    }
 
+#ifdef EPIC_48K
+   if (st->lbr_48k) {
+      pitch_half[0] = st->min_pitch+speex_bits_unpack_unsigned(bits, 7);
+      pitch_half[1] = pitch_half[0]+speex_bits_unpack_unsigned(bits, 2)-1;
+
+      ol_pitch_id = speex_bits_unpack_unsigned(bits, 3);
+      ol_pitch_coef=GAIN_SCALING*0.13514*ol_pitch_id;
+
+      {
+         int qe;
+         qe = speex_bits_unpack_unsigned(bits, 4);
+         ol_gain = SIG_SCALING*exp((qe+2)/2.1),SIG_SHIFT;
+      }
+
+   } else {
+#endif
+
    /* Get open-loop pitch estimation for low bit-rate pitch coding */
    if (SUBMODE(lbr_pitch)!=-1)
    {
@@ -1173,19 +1414,26 @@
    {
       int quant;
       quant = speex_bits_unpack_unsigned(bits, 4);
-      ol_pitch_coef=0.066667*quant;
+      ol_pitch_coef=GAIN_SCALING*0.066667*quant;
    }
    
    /* Get global excitation gain */
    {
       int qe;
       qe = speex_bits_unpack_unsigned(bits, 5);
-      ol_gain = exp(qe/3.5);
+#ifdef FIXED_POINT
+      ol_gain = MULT16_32_Q15(28406,ol_gain_table[qe]);
+#else
+      ol_gain = SIG_SCALING*exp(qe/3.5);
+#endif
    }
+#ifdef EPIC_48K
+   }
+#endif
 
-   awk1=PUSH(stack, st->lpcSize+1, float);
-   awk2=PUSH(stack, st->lpcSize+1, float);
-   awk3=PUSH(stack, st->lpcSize+1, float);
+   ALLOC(awk1, st->lpcSize+1, spx_coef_t);
+   ALLOC(awk2, st->lpcSize+1, spx_coef_t);
+   ALLOC(awk3, st->lpcSize+1, spx_coef_t);
 
    if (st->submodeID==1)
    {
@@ -1204,8 +1452,19 @@
    for (sub=0;sub<st->nbSubframes;sub++)
    {
       int offset;
-      float *sp, *exc, tmp;
+      spx_sig_t *sp, *exc;
+      spx_word16_t tmp;
 
+#ifdef EPIC_48K
+      if (st->lbr_48k)
+      {
+         if (sub*2 < st->nbSubframes)
+            ol_pitch = pitch_half[0];
+         else
+            ol_pitch = pitch_half[1];
+      }
+#endif
+
       /* Offset relative to start of frame */
       offset = st->subframeSize*sub;
       /* Original signal */
@@ -1215,46 +1474,32 @@
       /* Excitation after post-filter*/
 
       /* LSP interpolation (quantized and unquantized) */
-      tmp = (1.0 + sub)/st->nbSubframes;
-      for (i=0;i<st->lpcSize;i++)
-         st->interp_qlsp[i] = (1-tmp)*st->old_qlsp[i] + tmp*st->qlsp[i];
+      lsp_interpolate(st->old_qlsp, st->qlsp, st->interp_qlsp, st->lpcSize, sub, st->nbSubframes);
 
       /* Make sure the LSP's are stable */
-      lsp_enforce_margin(st->interp_qlsp, st->lpcSize, .002);
+      lsp_enforce_margin(st->interp_qlsp, st->lpcSize, LSP_MARGIN);
 
 
       /* Compute interpolated LPCs (unquantized) */
-      for (i=0;i<st->lpcSize;i++)
-         st->interp_qlsp[i] = cos(st->interp_qlsp[i]);
       lsp_to_lpc(st->interp_qlsp, st->interp_qlpc, st->lpcSize, stack);
 
       /* Compute enhanced synthesis filter */
       if (st->lpc_enh_enabled)
       {
-         float r=.9;
-         
-         float k1,k2,k3;
-         k1=SUBMODE(lpc_enh_k1);
-         k2=SUBMODE(lpc_enh_k2);
-         k3=(1-(1-r*k1)/(1-r*k2))/r;
-         if (!st->lpc_enh_enabled)
-         {
-            k1=k2;
-            k3=0;
-         }
-         bw_lpc(k1, st->interp_qlpc, awk1, st->lpcSize);
-         bw_lpc(k2, st->interp_qlpc, awk2, st->lpcSize);
-         bw_lpc(k3, st->interp_qlpc, awk3, st->lpcSize);
-         
+         bw_lpc(SUBMODE(lpc_enh_k1), st->interp_qlpc, awk1, st->lpcSize);
+         bw_lpc(SUBMODE(lpc_enh_k2), st->interp_qlpc, awk2, st->lpcSize);
+         bw_lpc(SUBMODE(lpc_enh_k3), st->interp_qlpc, awk3, st->lpcSize);
       }
 
       /* Compute analysis filter at w=pi */
-      tmp=1;
-      st->pi_gain[sub]=0;
-      for (i=0;i<=st->lpcSize;i++)
       {
-         st->pi_gain[sub] += tmp*st->interp_qlpc[i];
-         tmp = -tmp;
+         spx_word32_t pi_g=LPC_SCALING;
+         for (i=0;i<st->lpcSize;i+=2)
+         {
+            /*pi_g += -st->interp_qlpc[i] +  st->interp_qlpc[i+1];*/
+            pi_g = ADD32(pi_g, SUB32(st->interp_qlpc[i+1],st->interp_qlpc[i]));
+         }
+         st->pi_gain[sub] = pi_g;
       }
 
       /* Reset excitation */
@@ -1294,38 +1539,43 @@
             pit_max = st->max_pitch;
          }
 
-         /* Pitch synthesis */
-         SUBMODE(ltp_unquant)(exc, pit_min, pit_max, ol_pitch_coef, SUBMODE(ltp_params), 
-                              st->subframeSize, &pitch, &pitch_gain[0], bits, stack, st->count_lost, offset, st->last_pitch_gain);
+
+#ifdef EPIC_48K
+         if (st->lbr_48k)
+         {
+             SUBMODE(ltp_unquant)(exc, pit_min, pit_max, ol_pitch_coef, SUBMODE(ltp_params), 
+                                  st->subframeSize, &pitch, &pitch_gain[0], bits, stack, 
+                                  st->count_lost, offset, st->last_pitch_gain, ol_pitch_id);
+         } else {
+#endif
+
+             SUBMODE(ltp_unquant)(exc, pit_min, pit_max, ol_pitch_coef, SUBMODE(ltp_params), 
+                                  st->subframeSize, &pitch, &pitch_gain[0], bits, stack, 
+                                  st->count_lost, offset, st->last_pitch_gain, 0);
+
+#ifdef EPIC_48K
+         }
+#endif
+
          
          /* If we had lost frames, check energy of last received frame */
          if (st->count_lost && ol_gain < st->last_ol_gain)
          {
-            float fact = ol_gain/(st->last_ol_gain+1);
+            /*float fact = (float)ol_gain/(st->last_ol_gain+1);
             for (i=0;i<st->subframeSize;i++)
-               exc[i]*=fact;
+            exc[i]*=fact;*/
+            spx_word16_t fact = DIV32_16(SHL32(EXTEND32(ol_gain),15),st->last_ol_gain+1);
+            for (i=0;i<st->subframeSize;i++)
+               exc[i] = MULT16_32_Q15(fact, exc[i]);
          }
 
-         tmp = fabs(pitch_gain[0]+pitch_gain[1]+pitch_gain[2]);
-         tmp = fabs(pitch_gain[1]);
-         if (pitch_gain[0]>0)
-            tmp += pitch_gain[0];
-         else
-            tmp -= .5*pitch_gain[0];
-         if (pitch_gain[2]>0)
-            tmp += pitch_gain[2];
-         else
-            tmp -= .5*pitch_gain[0];
+         tmp = gain_3tap_to_1tap(pitch_gain);
 
-
          pitch_average += tmp;
          if (tmp>best_pitch_gain)
          {
             best_pitch = pitch;
 	    best_pitch_gain = tmp;
-	    /*            best_pitch_gain = tmp*.9;
-	                if (best_pitch_gain>.85)
-                        best_pitch_gain=.85;*/
          }
       } else {
          speex_error("No pitch prediction, what's wrong");
@@ -1334,8 +1584,8 @@
       /* Unquantize the innovation */
       {
          int q_energy;
-         float ener;
-         float *innov;
+         spx_word32_t ener;
+         spx_sig_t *innov;
          
          innov = st->innov+sub*st->subframeSize;
          for (i=0;i<st->subframeSize;i++)
@@ -1345,11 +1595,11 @@
          if (SUBMODE(have_subframe_gain)==3)
          {
             q_energy = speex_bits_unpack_unsigned(bits, 3);
-            ener = ol_gain*exp(exc_gain_quant_scal3[q_energy]);
+            ener = MULT16_32_Q14(exc_gain_quant_scal3[q_energy],ol_gain);
          } else if (SUBMODE(have_subframe_gain)==1)
          {
             q_energy = speex_bits_unpack_unsigned(bits, 1);
-            ener = ol_gain*exp(exc_gain_quant_scal1[q_energy]);
+            ener = MULT16_32_Q14(exc_gain_quant_scal1[q_energy],ol_gain);
          } else {
             ener = ol_gain;
          }
@@ -1363,13 +1613,15 @@
          }
 
          /* De-normalize innovation and update excitation */
-         for (i=0;i<st->subframeSize;i++)
-            innov[i]*=ener;
-
+#ifdef FIXED_POINT
+         signal_mul(innov, innov, ener, st->subframeSize);
+#else
+         signal_mul(innov, innov, ener, st->subframeSize);
+#endif
          /*Vocoder mode*/
          if (st->submodeID==1) 
          {
-            float g=ol_pitch_coef;
+            float g=ol_pitch_coef*GAIN_SCALING_1;
 
             
             for (i=0;i<st->subframeSize;i++)
@@ -1377,7 +1629,7 @@
             while (st->voc_offset<st->subframeSize)
             {
                if (st->voc_offset>=0)
-                  exc[st->voc_offset]=sqrt(1.0*ol_pitch);
+                  exc[st->voc_offset]=SIG_SCALING*sqrt(1.0*ol_pitch);
                st->voc_offset+=ol_pitch;
             }
             st->voc_offset -= st->subframeSize;
@@ -1390,7 +1642,7 @@
             for (i=0;i<st->subframeSize;i++)
             {
                float exci=exc[i];
-               exc[i]=.8*g*exc[i]*ol_gain + .6*g*st->voc_m1*ol_gain + .5*g*innov[i] - .5*g*st->voc_m2 + (1-g)*innov[i];
+               exc[i]=.8*g*exc[i]*ol_gain/SIG_SCALING + .6*g*st->voc_m1*ol_gain/SIG_SCALING + .5*g*innov[i] - .5*g*st->voc_m2 + (1-g)*innov[i];
                st->voc_m1 = exci;
                st->voc_m2=innov[i];
                st->voc_mean = .95*st->voc_mean + .05*exc[i];
@@ -1398,20 +1650,22 @@
             }
          } else {
             for (i=0;i<st->subframeSize;i++)
-               exc[i]+=innov[i];
+               exc[i]=ADD32(exc[i],innov[i]);
+            /*print_vec(exc, 40, "innov");*/
          }
          /* Decode second codebook (only for some modes) */
          if (SUBMODE(double_codebook))
          {
             char *tmp_stack=stack;
-            float *innov2 = PUSH(tmp_stack, st->subframeSize, float);
+            VARDECL(spx_sig_t *innov2);
+            ALLOC(innov2, st->subframeSize, spx_sig_t);
             for (i=0;i<st->subframeSize;i++)
                innov2[i]=0;
-            SUBMODE(innovation_unquant)(innov2, SUBMODE(innovation_params), st->subframeSize, bits, tmp_stack);
+            SUBMODE(innovation_unquant)(innov2, SUBMODE(innovation_params), st->subframeSize, bits, stack);
+            signal_mul(innov2, innov2, (spx_word32_t) (ener*(1/2.2)), st->subframeSize);
             for (i=0;i<st->subframeSize;i++)
-               innov2[i]*=ener*(1/2.2);
-            for (i=0;i<st->subframeSize;i++)
-               exc[i] += innov2[i];
+               exc[i] = ADD32(exc[i],innov2[i]);
+            stack = tmp_stack;
          }
 
       }
@@ -1423,6 +1677,7 @@
       if (st->lpc_enh_enabled && SUBMODE(comb_gain)>0)
          comb_filter(exc, sp, st->interp_qlpc, st->lpcSize, st->subframeSize,
                               pitch, pitch_gain, SUBMODE(comb_gain), st->comb_mem);
+
       if (st->lpc_enh_enabled)
       {
          /* Use enhanced LPC filter */
@@ -1439,12 +1694,19 @@
       }
    }
    
-   /*Copy output signal*/
-   out[0] = st->frame[0] + st->preemph*st->pre_mem;
-   for (i=1;i<st->frameSize;i++)
-     out[i]=st->frame[i] + st->preemph*out[i-1];
-   st->pre_mem=out[st->frameSize-1];
+   /*Copy output signal*/   
+   for (i=0;i<st->frameSize;i++)
+   {
+      spx_word32_t sig = PSHR32(st->frame[i],SIG_SHIFT);
+      if (sig>32767)
+         sig = 32767;
+      if (sig<-32767)
+         sig = -32767;
+     out[i]=sig;
+   }
 
+   /*for (i=0;i<st->frameSize;i++)
+     printf ("%d\n", (int)st->frame[i]);*/
 
    /* Store the LSPs for interpolation in the next frame */
    for (i=0;i<st->lpcSize;i++)
@@ -1454,7 +1716,11 @@
    st->first = 0;
    st->count_lost=0;
    st->last_pitch = best_pitch;
-   st->last_pitch_gain = .25*pitch_average;
+#ifdef FIXED_POINT
+   st->last_pitch_gain = PSHR16(pitch_average,2);
+#else
+   st->last_pitch_gain = .25*pitch_average;   
+#endif
    st->pitch_gain_buf[st->pitch_gain_buf_idx++] = st->last_pitch_gain;
    if (st->pitch_gain_buf_idx > 2) /* rollover */
       st->pitch_gain_buf_idx = 0;
@@ -1540,13 +1806,13 @@
             quality = 0;
          if (quality > 10)
             quality = 10;
-         st->submodeSelect = st->submodeID = ((SpeexNBMode*)(st->mode->mode))->quality_map[quality];
+         st->submodeSelect = st->submodeID = ((const SpeexNBMode*)(st->mode->mode))->quality_map[quality];
       }
       break;
    case SPEEX_SET_COMPLEXITY:
       st->complexity = (*(int*)ptr);
-      if (st->complexity<1)
-         st->complexity=1;
+      if (st->complexity<0)
+         st->complexity=0;
       break;
    case SPEEX_GET_COMPLEXITY:
       (*(int*)ptr) = st->complexity;
@@ -1586,17 +1852,33 @@
             st->lsp[i]=(M_PI*((float)(i+1)))/(st->lpcSize+1);
          for (i=0;i<st->lpcSize;i++)
             st->mem_sw[i]=st->mem_sw_whole[i]=st->mem_sp[i]=st->mem_exc[i]=0;
-         for (i=0;i<st->bufSize;i++)
-            st->excBuf[i]=st->swBuf[i]=st->inBuf[i]=st->exc2Buf[i]=0;
+         for (i=0;i<st->frameSize+st->max_pitch+1;i++)
+            st->excBuf[i]=st->swBuf[i]=0;
+         for (i=0;i<st->windowSize;i++)
+            st->inBuf[i]=0;
       }
       break;
+   case SPEEX_SET_SUBMODE_ENCODING:
+      st->encode_submode = (*(int*)ptr);
+      break;
+   case SPEEX_GET_SUBMODE_ENCODING:
+      (*(int*)ptr) = st->encode_submode;
+      break;
    case SPEEX_GET_LOOKAHEAD:
       (*(int*)ptr)=(st->windowSize-st->frameSize);
       break;
+   case SPEEX_SET_PLC_TUNING:
+      st->plc_tuning = (*(int*)ptr);
+      if (st->plc_tuning>100)
+         st->plc_tuning=100;
+      break;
+   case SPEEX_GET_PLC_TUNING:
+      (*(int*)ptr)=(st->plc_tuning);
+      break;
    case SPEEX_GET_PI_GAIN:
       {
          int i;
-         float *g = (float*)ptr;
+         spx_word32_t *g = (spx_word32_t*)ptr;
          for (i=0;i<st->nbSubframes;i++)
             g[i]=st->pi_gain[i];
       }
@@ -1604,7 +1886,7 @@
    case SPEEX_GET_EXC:
       {
          int i;
-         float *e = (float*)ptr;
+         spx_sig_t *e = (spx_sig_t*)ptr;
          for (i=0;i<st->frameSize;i++)
             e[i]=st->exc[i];
       }
@@ -1612,7 +1894,7 @@
    case SPEEX_GET_INNOV:
       {
          int i;
-         float *e = (float*)ptr;
+         spx_sig_t *e = (spx_sig_t*)ptr;
          for (i=0;i<st->frameSize;i++)
             e[i]=st->innov[i];
       }
@@ -1633,6 +1915,10 @@
    st=(DecState*)state;
    switch(request)
    {
+   case SPEEX_SET_LOW_MODE:
+   case SPEEX_SET_MODE:
+      st->submodeID = (*(int*)ptr);
+      break;
    case SPEEX_GET_LOW_MODE:
    case SPEEX_GET_MODE:
       (*(int*)ptr) = st->submodeID;
@@ -1679,14 +1965,22 @@
          int i;
          for (i=0;i<2*st->lpcSize;i++)
             st->mem_sp[i]=0;
-         for (i=0;i<st->bufSize;i++)
-            st->excBuf[i]=st->inBuf[i]=0;
+         for (i=0;i<st->frameSize + st->max_pitch + 1;i++)
+            st->excBuf[i]=0;
+         for (i=0;i<st->frameSize;i++)
+            st->inBuf[i] = 0;
       }
       break;
+   case SPEEX_SET_SUBMODE_ENCODING:
+      st->encode_submode = (*(int*)ptr);
+      break;
+   case SPEEX_GET_SUBMODE_ENCODING:
+      (*(int*)ptr) = st->encode_submode;
+      break;
    case SPEEX_GET_PI_GAIN:
       {
          int i;
-         float *g = (float*)ptr;
+         spx_word32_t *g = (spx_word32_t*)ptr;
          for (i=0;i<st->nbSubframes;i++)
             g[i]=st->pi_gain[i];
       }
@@ -1694,7 +1988,7 @@
    case SPEEX_GET_EXC:
       {
          int i;
-         float *e = (float*)ptr;
+         spx_sig_t *e = (spx_sig_t*)ptr;
          for (i=0;i<st->frameSize;i++)
             e[i]=st->exc[i];
       }
@@ -1702,7 +1996,7 @@
    case SPEEX_GET_INNOV:
       {
          int i;
-         float *e = (float*)ptr;
+         spx_sig_t *e = (spx_sig_t*)ptr;
          for (i=0;i<st->frameSize;i++)
             e[i]=st->innov[i];
       }

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/nb_celp.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/nb_celp.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/nb_celp.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -44,14 +44,13 @@
 
 /**Structure representing the full state of the narrowband encoder*/
 typedef struct EncState {
-   SpeexMode *mode;       /**< Mode corresponding to the state */
+   const SpeexMode *mode;       /**< Mode corresponding to the state */
    int    first;          /**< Is this the first frame? */
    int    frameSize;      /**< Size of frames */
    int    subframeSize;   /**< Size of sub-frames */
    int    nbSubframes;    /**< Number of sub-frames */
    int    windowSize;     /**< Analysis (LPC) window length */
    int    lpcSize;        /**< LPC order */
-   int    bufSize;        /**< Buffer size */
    int    min_pitch;      /**< Minimum pitch value allowed */
    int    max_pitch;      /**< Maximum pitch value allowed */
 
@@ -60,44 +59,42 @@
    int    ol_pitch;       /**< Open-loop pitch */
    int    ol_voiced;      /**< Open-loop voiced/non-voiced decision */
    int   *pitch;
-   float  gamma1;         /**< Perceptual filter: A(z/gamma1) */
-   float  gamma2;         /**< Perceptual filter: A(z/gamma2) */
+
+#ifdef EPIC_48K
+   int    lbr_48k;
+#endif
+
+   spx_word16_t  gamma1;         /**< Perceptual filter: A(z/gamma1) */
+   spx_word16_t  gamma2;         /**< Perceptual filter: A(z/gamma2) */
    float  lag_factor;     /**< Lag windowing Gaussian width */
    float  lpc_floor;      /**< Noise floor multiplier for A[0] in LPC analysis*/
-   float  preemph;        /**< Pre-emphasis: P(z) = 1 - a*z^-1*/
-   float  pre_mem;        /**< 1-element memory for pre-emphasis */
-   float  pre_mem2;       /**< 1-element memory for pre-emphasis */
    char  *stack;          /**< Pseudo-stack allocation for temporary memory */
-   float *inBuf;          /**< Input buffer (original signal) */
-   float *frame;          /**< Start of original frame */
-   float *excBuf;         /**< Excitation buffer */
-   float *exc;            /**< Start of excitation frame */
-   float *exc2Buf;        /**< "Pitch enhanced" excitation */
-   float *exc2;           /**< "Pitch enhanced" excitation */
-   float *swBuf;          /**< Weighted signal buffer */
-   float *sw;             /**< Start of weighted signal frame */
-   float *innov;          /**< Innovation for the frame */
-   float *window;         /**< Temporary (Hanning) window */
-   float *buf2;           /**< 2nd temporary buffer */
-   float *autocorr;       /**< auto-correlation */
-   float *lagWindow;      /**< Window applied to auto-correlation */
-   float *lpc;            /**< LPCs for current frame */
-   float *lsp;            /**< LSPs for current frame */
-   float *qlsp;           /**< Quantized LSPs for current frame */
-   float *old_lsp;        /**< LSPs for previous frame */
-   float *old_qlsp;       /**< Quantized LSPs for previous frame */
-   float *interp_lsp;     /**< Interpolated LSPs */
-   float *interp_qlsp;    /**< Interpolated quantized LSPs */
-   float *interp_lpc;     /**< Interpolated LPCs */
-   float *interp_qlpc;    /**< Interpolated quantized LPCs */
-   float *bw_lpc1;        /**< LPCs after bandwidth expansion by gamma1 for perceptual weighting*/
-   float *bw_lpc2;        /**< LPCs after bandwidth expansion by gamma2 for perceptual weighting*/
-   float *rc;             /**< Reflection coefficients */
-   float *mem_sp;         /**< Filter memory for signal synthesis */
-   float *mem_sw;         /**< Filter memory for perceptually-weighted signal */
-   float *mem_sw_whole;   /**< Filter memory for perceptually-weighted signal (whole frame)*/
-   float *mem_exc;        /**< Filter memory for excitation (whole frame) */
-   float *pi_gain;        /**< Gain of LPC filter at theta=pi (fe/2) */
+   spx_sig_t *inBuf;          /**< Input buffer (original signal) */
+   spx_sig_t *frame;          /**< Start of original frame */
+   spx_sig_t *excBuf;         /**< Excitation buffer */
+   spx_sig_t *exc;            /**< Start of excitation frame */
+   spx_sig_t *swBuf;          /**< Weighted signal buffer */
+   spx_sig_t *sw;             /**< Start of weighted signal frame */
+   spx_sig_t *innov;          /**< Innovation for the frame */
+   spx_word16_t *window;         /**< Temporary (Hanning) window */
+   spx_word16_t *autocorr;       /**< auto-correlation */
+   spx_word16_t *lagWindow;      /**< Window applied to auto-correlation */
+   spx_coef_t *lpc;            /**< LPCs for current frame */
+   spx_lsp_t *lsp;            /**< LSPs for current frame */
+   spx_lsp_t *qlsp;           /**< Quantized LSPs for current frame */
+   spx_lsp_t *old_lsp;        /**< LSPs for previous frame */
+   spx_lsp_t *old_qlsp;       /**< Quantized LSPs for previous frame */
+   spx_lsp_t *interp_lsp;     /**< Interpolated LSPs */
+   spx_lsp_t *interp_qlsp;    /**< Interpolated quantized LSPs */
+   spx_coef_t *interp_lpc;     /**< Interpolated LPCs */
+   spx_coef_t *interp_qlpc;    /**< Interpolated quantized LPCs */
+   spx_coef_t *bw_lpc1;        /**< LPCs after bandwidth expansion by gamma1 for perceptual weighting*/
+   spx_coef_t *bw_lpc2;        /**< LPCs after bandwidth expansion by gamma2 for perceptual weighting*/
+   spx_mem_t *mem_sp;         /**< Filter memory for signal synthesis */
+   spx_mem_t *mem_sw;         /**< Filter memory for perceptually-weighted signal */
+   spx_mem_t *mem_sw_whole;   /**< Filter memory for perceptually-weighted signal (whole frame)*/
+   spx_mem_t *mem_exc;        /**< Filter memory for excitation (whole frame) */
+   spx_word32_t *pi_gain;        /**< Gain of LPC filter at theta=pi (fe/2) */
 
    VBRState *vbr;         /**< State of the VBR data */
    float  vbr_quality;    /**< Quality setting for VBR encoding */
@@ -112,51 +109,52 @@
    float  abr_count;
    int    complexity;     /**< Complexity setting (0-10 from least complex to most complex) */
    int    sampling_rate;
-
-   SpeexSubmode **submodes; /**< Sub-mode data */
+   int    plc_tuning;
+   int    encode_submode;
+   const SpeexSubmode * const *submodes; /**< Sub-mode data */
    int    submodeID;      /**< Activated sub-mode */
    int    submodeSelect;  /**< Mode chosen by the user (may differ from submodeID if VAD is on) */
 } EncState;
 
 /**Structure representing the full state of the narrowband decoder*/
 typedef struct DecState {
-   SpeexMode *mode;       /**< Mode corresponding to the state */
+   const SpeexMode *mode;       /**< Mode corresponding to the state */
    int    first;          /**< Is this the first frame? */
    int    count_lost;     /**< Was the last frame lost? */
    int    frameSize;      /**< Size of frames */
    int    subframeSize;   /**< Size of sub-frames */
    int    nbSubframes;    /**< Number of sub-frames */
-   int    windowSize;     /**< Analysis (LPC) window length */
    int    lpcSize;        /**< LPC order */
-   int    bufSize;        /**< Buffer size */
    int    min_pitch;      /**< Minimum pitch value allowed */
    int    max_pitch;      /**< Maximum pitch value allowed */
    int    sampling_rate;
-   float  last_ol_gain;   /**< Open-loop gain for previous frame */
 
+#ifdef EPIC_48K
+   int    lbr_48k;
+#endif
 
-   float  gamma1;         /**< Perceptual filter: A(z/gamma1) */
-   float  gamma2;         /**< Perceptual filter: A(z/gamma2) */
-   float  preemph;        /**< Pre-emphasis: P(z) = 1 - a*z^-1*/
-   float  pre_mem;        /**< 1-element memory for pre-emphasis */
+   spx_word16_t  last_ol_gain;   /**< Open-loop gain for previous frame */
+
    char  *stack;          /**< Pseudo-stack allocation for temporary memory */
-   float *inBuf;          /**< Input buffer (original signal) */
-   float *frame;          /**< Start of original frame */
-   float *excBuf;         /**< Excitation buffer */
-   float *exc;            /**< Start of excitation frame */
-   float *innov;          /**< Innovation for the frame */
-   float *qlsp;           /**< Quantized LSPs for current frame */
-   float *old_qlsp;       /**< Quantized LSPs for previous frame */
-   float *interp_qlsp;    /**< Interpolated quantized LSPs */
-   float *interp_qlpc;    /**< Interpolated quantized LPCs */
-   float *mem_sp;         /**< Filter memory for synthesis signal */
-   float *pi_gain;        /**< Gain of LPC filter at theta=pi (fe/2) */
+   spx_sig_t *inBuf;          /**< Input buffer (original signal) */
+   spx_sig_t *frame;          /**< Start of original frame */
+   spx_sig_t *excBuf;         /**< Excitation buffer */
+   spx_sig_t *exc;            /**< Start of excitation frame */
+   spx_sig_t *innov;          /**< Innovation for the frame */
+   spx_lsp_t *qlsp;           /**< Quantized LSPs for current frame */
+   spx_lsp_t *old_qlsp;       /**< Quantized LSPs for previous frame */
+   spx_lsp_t *interp_qlsp;    /**< Interpolated quantized LSPs */
+   spx_coef_t *interp_qlpc;    /**< Interpolated quantized LPCs */
+   spx_mem_t *mem_sp;         /**< Filter memory for synthesis signal */
+   spx_word32_t *pi_gain;        /**< Gain of LPC filter at theta=pi (fe/2) */
    int    last_pitch;     /**< Pitch of last correctly decoded frame */
-   float  last_pitch_gain; /**< Pitch gain of last correctly decoded frame */
-   float  pitch_gain_buf[3];  /**< Pitch gain of last decoded frames */
+   spx_word16_t  last_pitch_gain; /**< Pitch gain of last correctly decoded frame */
+   spx_word16_t  pitch_gain_buf[3];  /**< Pitch gain of last decoded frames */
    int    pitch_gain_buf_idx; /**< Tail of the buffer */
-
-   SpeexSubmode **submodes; /**< Sub-mode data */
+   spx_int32_t seed;          /** Seed used for random number generation */
+   
+   int    encode_submode;
+   const SpeexSubmode * const *submodes; /**< Sub-mode data */
    int    submodeID;      /**< Activated sub-mode */
    int    lpc_enh_enabled; /**< 1 when LPC enhancer is on, 0 otherwise */
    CombFilterMem *comb_mem;
@@ -174,23 +172,23 @@
 } DecState;
 
 /** Initializes encoder state*/
-void *nb_encoder_init(SpeexMode *m);
+void *nb_encoder_init(const SpeexMode *m);
 
 /** De-allocates encoder state resources*/
 void nb_encoder_destroy(void *state);
 
 /** Encodes one frame*/
-int nb_encode(void *state, float *in, SpeexBits *bits);
+int nb_encode(void *state, void *in, SpeexBits *bits);
 
 
 /** Initializes decoder state*/
-void *nb_decoder_init(SpeexMode *m);
+void *nb_decoder_init(const SpeexMode *m);
 
 /** De-allocates decoder state resources*/
 void nb_decoder_destroy(void *state);
 
 /** Decodes one frame*/
-int nb_decode(void *state, SpeexBits *bits, float *out);
+int nb_decode(void *state, SpeexBits *bits, void *out);
 
 /** ioctl-like function for controlling a narrowband encoder */
 int nb_encoder_ctl(void *state, int request, void *ptr);

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/preprocess.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/preprocess.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/preprocess.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,1045 @@
+/* Copyright (C) 2003 Epic Games 
+   Written by Jean-Marc Valin
+
+   File: preprocess.c
+   Preprocessor with denoising based on the algorithm by Ephraim and Malah
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions are
+   met:
+
+   1. Redistributions of source code must retain the above copyright notice,
+   this list of conditions and the following disclaimer.
+
+   2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+   3. The name of the author may not be used to endorse or promote products
+   derived from this software without specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+   IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+   OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+   DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+   ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+   POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <math.h>
+#include "speex/speex_preprocess.h"
+#include "misc.h"
+#include "smallft.h"
+
+#define max(a,b) ((a) > (b) ? (a) : (b))
+#define min(a,b) ((a) < (b) ? (a) : (b))
+
+#ifndef M_PI
+#define M_PI 3.14159263
+#endif
+
+#define SQRT_M_PI_2 0.88623
+#define LOUDNESS_EXP 2.5
+
+#define NB_BANDS 8
+
+#define ZMIN .1
+#define ZMAX .316
+#define ZMIN_1 10
+#define LOG_MIN_MAX_1 0.86859
+
+static void conj_window(float *w, int len)
+{
+   int i;
+   for (i=0;i<len;i++)
+   {
+      float x=4*((float)i)/len;
+      int inv=0;
+      if (x<1)
+      {
+      } else if (x<2)
+      {
+         x=2-x;
+         inv=1;
+      } else if (x<3)
+      {
+         x=x-2;
+         inv=1;
+      } else {
+         x=4-x;
+      }
+      x*=1.9979;
+      w[i]=(.5-.5*cos(x))*(.5-.5*cos(x));
+      if (inv)
+         w[i]=1-w[i];
+      w[i]=sqrt(w[i]);
+   }
+}
+
+/* This function approximates the gain function 
+   y = gamma(1.25)^2 * M(-.25;1;-x) / sqrt(x)  
+   which multiplied by xi/(1+xi) is the optimal gain
+   in the loudness domain ( sqrt[amplitude] )
+*/
+static float hypergeom_gain(float x)
+{
+   int ind;
+   float integer, frac;
+   static const float table[21] = {
+      0.82157f, 1.02017f, 1.20461f, 1.37534f, 1.53363f, 1.68092f, 1.81865f, 
+      1.94811f, 2.07038f, 2.18638f, 2.29688f, 2.40255f, 2.50391f, 2.60144f, 
+      2.69551f, 2.78647f, 2.87458f, 2.96015f, 3.04333f, 3.12431f, 3.20326f};
+   
+   if (x>9.5)
+      return 1+.12/x;
+
+   integer = floor(2*x);
+   frac = 2*x-integer;
+   ind = (int)integer;
+   /*if (ind > 20 || ind < 0)
+   fprintf (stderr, "error: %d %f\n", ind, x);*/
+   return ((1-frac)*table[ind] + frac*table[ind+1])/sqrt(x+.0001f);
+}
+
+SpeexPreprocessState *speex_preprocess_state_init(int frame_size, int sampling_rate)
+{
+   int i;
+   int N, N3, N4;
+
+   SpeexPreprocessState *st = (SpeexPreprocessState *)speex_alloc(sizeof(SpeexPreprocessState));
+   st->frame_size = frame_size;
+
+   /* Round ps_size down to the nearest power of two */
+#if 0
+   i=1;
+   st->ps_size = st->frame_size;
+   while(1)
+   {
+      if (st->ps_size & ~i)
+      {
+         st->ps_size &= ~i;
+         i<<=1;
+      } else {
+         break;
+      }
+   }
+   
+   
+   if (st->ps_size < 3*st->frame_size/4)
+      st->ps_size = st->ps_size * 3 / 2;
+#else
+   st->ps_size = st->frame_size;
+#endif
+
+   N = st->ps_size;
+   N3 = 2*N - st->frame_size;
+   N4 = st->frame_size - N3;
+   
+   st->sampling_rate = sampling_rate;
+   st->denoise_enabled = 1;
+   st->agc_enabled = 0;
+   st->agc_level = 8000;
+   st->vad_enabled = 0;
+   st->dereverb_enabled = 0;
+   st->reverb_decay = .5;
+   st->reverb_level = .2;
+
+   st->frame = (float*)speex_alloc(2*N*sizeof(float));
+   st->ps = (float*)speex_alloc(N*sizeof(float));
+   st->gain2 = (float*)speex_alloc(N*sizeof(float));
+   st->window = (float*)speex_alloc(2*N*sizeof(float));
+   st->noise = (float*)speex_alloc(N*sizeof(float));
+   st->reverb_estimate = (float*)speex_alloc(N*sizeof(float));
+   st->old_ps = (float*)speex_alloc(N*sizeof(float));
+   st->gain = (float*)speex_alloc(N*sizeof(float));
+   st->prior = (float*)speex_alloc(N*sizeof(float));
+   st->post = (float*)speex_alloc(N*sizeof(float));
+   st->loudness_weight = (float*)speex_alloc(N*sizeof(float));
+   st->inbuf = (float*)speex_alloc(N3*sizeof(float));
+   st->outbuf = (float*)speex_alloc(N3*sizeof(float));
+   st->echo_noise = (float*)speex_alloc(N*sizeof(float));
+
+   st->S = (float*)speex_alloc(N*sizeof(float));
+   st->Smin = (float*)speex_alloc(N*sizeof(float));
+   st->Stmp = (float*)speex_alloc(N*sizeof(float));
+   st->update_prob = (float*)speex_alloc(N*sizeof(float));
+
+   st->zeta = (float*)speex_alloc(N*sizeof(float));
+   st->Zpeak = 0;
+   st->Zlast = 0;
+
+   st->noise_bands = (float*)speex_alloc(NB_BANDS*sizeof(float));
+   st->noise_bands2 = (float*)speex_alloc(NB_BANDS*sizeof(float));
+   st->speech_bands = (float*)speex_alloc(NB_BANDS*sizeof(float));
+   st->speech_bands2 = (float*)speex_alloc(NB_BANDS*sizeof(float));
+   st->noise_bandsN = st->speech_bandsN = 1;
+
+   conj_window(st->window, 2*N3);
+   for (i=2*N3;i<2*st->ps_size;i++)
+      st->window[i]=1;
+   
+   if (N4>0)
+   {
+      for (i=N3-1;i>=0;i--)
+      {
+         st->window[i+N3+N4]=st->window[i+N3];
+         st->window[i+N3]=1;
+      }
+   }
+   for (i=0;i<N;i++)
+   {
+      st->noise[i]=1e4;
+      st->reverb_estimate[i]=0.;
+      st->old_ps[i]=1e4;
+      st->gain[i]=1;
+      st->post[i]=1;
+      st->prior[i]=1;
+   }
+
+   for (i=0;i<N3;i++)
+   {
+      st->inbuf[i]=0;
+      st->outbuf[i]=0;
+   }
+
+   for (i=0;i<N;i++)
+   {
+      float ff=((float)i)*.5*sampling_rate/((float)N);
+      st->loudness_weight[i] = .35f-.35f*ff/16000.f+.73f*exp(-.5f*(ff-3800)*(ff-3800)/9e5f);
+      if (st->loudness_weight[i]<.01f)
+         st->loudness_weight[i]=.01f;
+      st->loudness_weight[i] *= st->loudness_weight[i];
+   }
+
+   st->speech_prob = 0;
+   st->last_speech = 1000;
+   st->loudness = pow(6000,LOUDNESS_EXP);
+   st->loudness2 = 6000;
+   st->nb_loudness_adapt = 0;
+
+   st->fft_lookup = (struct drft_lookup*)speex_alloc(sizeof(struct drft_lookup));
+   spx_drft_init(st->fft_lookup,2*N);
+
+   st->nb_adapt=0;
+   st->consec_noise=0;
+   st->nb_preprocess=0;
+   return st;
+}
+
+void speex_preprocess_state_destroy(SpeexPreprocessState *st)
+{
+   speex_free(st->frame);
+   speex_free(st->ps);
+   speex_free(st->gain2);
+   speex_free(st->window);
+   speex_free(st->noise);
+   speex_free(st->reverb_estimate);
+   speex_free(st->old_ps);
+   speex_free(st->gain);
+   speex_free(st->prior);
+   speex_free(st->post);
+   speex_free(st->loudness_weight);
+   speex_free(st->echo_noise);
+
+   speex_free(st->S);
+   speex_free(st->Smin);
+   speex_free(st->Stmp);
+   speex_free(st->update_prob);
+   speex_free(st->zeta);
+
+   speex_free(st->noise_bands);
+   speex_free(st->noise_bands2);
+   speex_free(st->speech_bands);
+   speex_free(st->speech_bands2);
+
+   speex_free(st->inbuf);
+   speex_free(st->outbuf);
+
+   spx_drft_clear(st->fft_lookup);
+   speex_free(st->fft_lookup);
+
+   speex_free(st);
+}
+
+static void update_noise(SpeexPreprocessState *st, float *ps, float *echo)
+{
+   int i;
+   float beta;
+   st->nb_adapt++;
+   beta=1.0f/st->nb_adapt;
+   if (beta < .05f)
+      beta=.05f;
+   
+   if (!echo)
+   {
+      for (i=0;i<st->ps_size;i++)
+         st->noise[i] = (1.f-beta)*st->noise[i] + beta*ps[i];
+   } else {
+      for (i=0;i<st->ps_size;i++)
+         st->noise[i] = (1.f-beta)*st->noise[i] + beta*max(1.f,ps[i]-echo[i]); 
+#if 0
+      for (i=0;i<st->ps_size;i++)
+         st->noise[i] = 0;
+#endif
+   }
+}
+
+static int speex_compute_vad(SpeexPreprocessState *st, float *ps, float mean_prior, float mean_post)
+{
+   int i, is_speech=0;
+   int N = st->ps_size;
+   float scale=.5f/N;
+
+   /* FIXME: Clean this up a bit */
+   {
+      float bands[NB_BANDS];
+      int j;
+      float p0, p1;
+      float tot_loudness=0;
+      float x = sqrt(mean_post);
+
+      for (i=5;i<N-10;i++)
+      {
+         tot_loudness += scale*st->ps[i] * st->loudness_weight[i];
+      }
+
+      for (i=0;i<NB_BANDS;i++)
+      {
+         bands[i]=1e4f;
+         for (j=i*N/NB_BANDS;j<(i+1)*N/NB_BANDS;j++)
+         {
+            bands[i] += ps[j];
+         }
+         bands[i]=log(bands[i]);
+      }
+      
+      /*p1 = .0005+.6*exp(-.5*(x-.4)*(x-.4)*11)+.1*exp(-1.2*x);
+      if (x<1.5)
+         p0=.1*exp(2*(x-1.5));
+      else
+         p0=.02+.1*exp(-.2*(x-1.5));
+      */
+
+      p0=1.f/(1.f+exp(3.f*(1.5f-x)));
+      p1=1.f-p0;
+
+      /*fprintf (stderr, "%f %f ", p0, p1);*/
+      /*p0 *= .99*st->speech_prob + .01*(1-st->speech_prob);
+      p1 *= .01*st->speech_prob + .99*(1-st->speech_prob);
+      
+      st->speech_prob = p0/(p1+p0);
+      */
+
+      if (st->noise_bandsN < 50 || st->speech_bandsN < 50)
+      {
+         if (mean_post > 5.f)
+         {
+            float adapt = 1./st->speech_bandsN++;
+            if (adapt<.005f)
+               adapt = .005f;
+            for (i=0;i<NB_BANDS;i++)
+            {
+               st->speech_bands[i] = (1.f-adapt)*st->speech_bands[i] + adapt*bands[i];
+               /*st->speech_bands2[i] = (1-adapt)*st->speech_bands2[i] + adapt*bands[i]*bands[i];*/
+               st->speech_bands2[i] = (1.f-adapt)*st->speech_bands2[i] + adapt*(bands[i]-st->speech_bands[i])*(bands[i]-st->speech_bands[i]);
+            }
+         } else {
+            float adapt = 1./st->noise_bandsN++;
+            if (adapt<.005f)
+               adapt = .005f;
+            for (i=0;i<NB_BANDS;i++)
+            {
+               st->noise_bands[i] = (1.f-adapt)*st->noise_bands[i] + adapt*bands[i];
+               /*st->noise_bands2[i] = (1-adapt)*st->noise_bands2[i] + adapt*bands[i]*bands[i];*/
+               st->noise_bands2[i] = (1.f-adapt)*st->noise_bands2[i] + adapt*(bands[i]-st->noise_bands[i])*(bands[i]-st->noise_bands[i]);
+            }
+         }
+      }
+      p0=p1=1;
+      for (i=0;i<NB_BANDS;i++)
+      {
+         float noise_var, speech_var;
+         float noise_mean, speech_mean;
+         float tmp1, tmp2, pr;
+
+         /*noise_var = 1.01*st->noise_bands2[i] - st->noise_bands[i]*st->noise_bands[i];
+           speech_var = 1.01*st->speech_bands2[i] - st->speech_bands[i]*st->speech_bands[i];*/
+         noise_var = st->noise_bands2[i];
+         speech_var = st->speech_bands2[i];
+         if (noise_var < .1f)
+            noise_var = .1f;
+         if (speech_var < .1f)
+            speech_var = .1f;
+         
+         /*speech_var = sqrt(speech_var*noise_var);
+           noise_var = speech_var;*/
+         if (speech_var < .05f*speech_var)
+            noise_var = .05f*speech_var; 
+         if (speech_var < .05f*noise_var)
+            speech_var = .05f*noise_var;
+         
+         if (bands[i] < st->noise_bands[i])
+            speech_var = noise_var;
+         if (bands[i] > st->speech_bands[i])
+            noise_var = speech_var;
+
+         speech_mean = st->speech_bands[i];
+         noise_mean = st->noise_bands[i];
+         if (noise_mean < speech_mean - 5.f)
+            noise_mean = speech_mean - 5.f;
+
+         tmp1 = exp(-.5f*(bands[i]-speech_mean)*(bands[i]-speech_mean)/speech_var)/sqrt(2.f*M_PI*speech_var);
+         tmp2 = exp(-.5f*(bands[i]-noise_mean)*(bands[i]-noise_mean)/noise_var)/sqrt(2.f*M_PI*noise_var);
+         /*fprintf (stderr, "%f ", (float)(p0/(.01+p0+p1)));*/
+         /*fprintf (stderr, "%f ", (float)(bands[i]));*/
+         pr = tmp1/(1e-25+tmp1+tmp2);
+         /*if (bands[i] < st->noise_bands[i])
+            pr=.01;
+         if (bands[i] > st->speech_bands[i] && pr < .995)
+         pr=.995;*/
+         if (pr>.999f)
+            pr=.999f;
+         if (pr<.001f)
+            pr=.001f;
+         /*fprintf (stderr, "%f ", pr);*/
+         p0 *= pr;
+         p1 *= (1-pr);
+      }
+
+      p0 = pow(p0,.2);
+      p1 = pow(p1,.2);      
+      
+#if 1
+      p0 *= 2.f;
+      p0=p0/(p1+p0);
+      if (st->last_speech>20) 
+      {
+         float tmp = sqrt(tot_loudness)/st->loudness2;
+         tmp = 1.f-exp(-10.f*tmp);
+         if (p0>tmp)
+            p0=tmp;
+      }
+      p1=1-p0;
+#else
+      if (sqrt(tot_loudness) < .6f*st->loudness2 && p0>15.f*p1)
+         p0=15.f*p1;
+      if (sqrt(tot_loudness) < .45f*st->loudness2 && p0>7.f*p1)
+         p0=7.f*p1;
+      if (sqrt(tot_loudness) < .3f*st->loudness2 && p0>3.f*p1)
+         p0=3.f*p1;
+      if (sqrt(tot_loudness) < .15f*st->loudness2 && p0>p1)
+         p0=p1;
+      /*fprintf (stderr, "%f %f ", (float)(sqrt(tot_loudness) /( .25*st->loudness2)), p0/(p1+p0));*/
+#endif
+
+      p0 *= .99f*st->speech_prob + .01f*(1-st->speech_prob);
+      p1 *= .01f*st->speech_prob + .99f*(1-st->speech_prob);
+      
+      st->speech_prob = p0/(1e-25f+p1+p0);
+      /*fprintf (stderr, "%f %f %f ", tot_loudness, st->loudness2, st->speech_prob);*/
+
+      if (st->speech_prob>.35 || (st->last_speech < 20 && st->speech_prob>.1))
+      {
+         is_speech = 1;
+         st->last_speech = 0;
+      } else {
+         st->last_speech++;
+         if (st->last_speech<20)
+           is_speech = 1;
+      }
+
+      if (st->noise_bandsN > 50 && st->speech_bandsN > 50)
+      {
+         if (mean_post > 5)
+         {
+            float adapt = 1./st->speech_bandsN++;
+            if (adapt<.005f)
+               adapt = .005f;
+            for (i=0;i<NB_BANDS;i++)
+            {
+               st->speech_bands[i] = (1-adapt)*st->speech_bands[i] + adapt*bands[i];
+               /*st->speech_bands2[i] = (1-adapt)*st->speech_bands2[i] + adapt*bands[i]*bands[i];*/
+               st->speech_bands2[i] = (1-adapt)*st->speech_bands2[i] + adapt*(bands[i]-st->speech_bands[i])*(bands[i]-st->speech_bands[i]);
+            }
+         } else {
+            float adapt = 1./st->noise_bandsN++;
+            if (adapt<.005f)
+               adapt = .005f;
+            for (i=0;i<NB_BANDS;i++)
+            {
+               st->noise_bands[i] = (1-adapt)*st->noise_bands[i] + adapt*bands[i];
+               /*st->noise_bands2[i] = (1-adapt)*st->noise_bands2[i] + adapt*bands[i]*bands[i];*/
+               st->noise_bands2[i] = (1-adapt)*st->noise_bands2[i] + adapt*(bands[i]-st->noise_bands[i])*(bands[i]-st->noise_bands[i]);
+            }
+         }
+      }
+
+
+   }
+
+   return is_speech;
+}
+
+static void speex_compute_agc(SpeexPreprocessState *st, float mean_prior)
+{
+   int i;
+   int N = st->ps_size;
+   float scale=.5f/N;
+   float agc_gain;
+   int freq_start, freq_end;
+   float active_bands = 0;
+
+   freq_start = (int)(300.0f*2*N/st->sampling_rate);
+   freq_end   = (int)(2000.0f*2*N/st->sampling_rate);
+   for (i=freq_start;i<freq_end;i++)
+   {
+      if (st->S[i] > 20.f*st->Smin[i]+1000.f)
+         active_bands+=1;
+   }
+   active_bands /= (freq_end-freq_start+1);
+
+   if (active_bands > .2f)
+   {
+      float loudness=0.f;
+      float rate, rate2=.2f;
+      st->nb_loudness_adapt++;
+      rate=2.0f/(1+st->nb_loudness_adapt);
+      if (rate < .05f)
+         rate = .05f;
+      if (rate < .1f && pow(loudness, LOUDNESS_EXP) > st->loudness)
+         rate = .1f;
+      if (rate < .2f && pow(loudness, LOUDNESS_EXP) > 3.f*st->loudness)
+         rate = .2f;
+      if (rate < .4f && pow(loudness, LOUDNESS_EXP) > 10.f*st->loudness)
+         rate = .4f;
+
+      for (i=2;i<N;i++)
+      {
+         loudness += scale*st->ps[i] * st->gain2[i] * st->gain2[i] * st->loudness_weight[i];
+      }
+      loudness=sqrt(loudness);
+      /*if (loudness < 2*pow(st->loudness, 1.0/LOUDNESS_EXP) &&
+        loudness*2 > pow(st->loudness, 1.0/LOUDNESS_EXP))*/
+      st->loudness = (1-rate)*st->loudness + (rate)*pow(loudness, LOUDNESS_EXP);
+      
+      st->loudness2 = (1-rate2)*st->loudness2 + rate2*pow(st->loudness, 1.0f/LOUDNESS_EXP);
+
+      loudness = pow(st->loudness, 1.0f/LOUDNESS_EXP);
+
+      /*fprintf (stderr, "%f %f %f\n", loudness, st->loudness2, rate);*/
+   }
+   
+   agc_gain = st->agc_level/st->loudness2;
+   /*fprintf (stderr, "%f %f %f %f\n", active_bands, st->loudness, st->loudness2, agc_gain);*/
+   if (agc_gain>200)
+      agc_gain = 200;
+
+   for (i=0;i<N;i++)
+      st->gain2[i] *= agc_gain;
+   
+}
+
+static void preprocess_analysis(SpeexPreprocessState *st, spx_int16_t *x)
+{
+   int i;
+   int N = st->ps_size;
+   int N3 = 2*N - st->frame_size;
+   int N4 = st->frame_size - N3;
+   float *ps=st->ps;
+
+   /* 'Build' input frame */
+   for (i=0;i<N3;i++)
+      st->frame[i]=st->inbuf[i];
+   for (i=0;i<st->frame_size;i++)
+      st->frame[N3+i]=x[i];
+   
+   /* Update inbuf */
+   for (i=0;i<N3;i++)
+      st->inbuf[i]=x[N4+i];
+
+   /* Windowing */
+   for (i=0;i<2*N;i++)
+      st->frame[i] *= st->window[i];
+
+   /* Perform FFT */
+   spx_drft_forward(st->fft_lookup, st->frame);
+
+   /* Power spectrum */
+   ps[0]=1;
+   for (i=1;i<N;i++)
+      ps[i]=1+st->frame[2*i-1]*st->frame[2*i-1] + st->frame[2*i]*st->frame[2*i];
+
+}
+
+static void update_noise_prob(SpeexPreprocessState *st)
+{
+   int i;
+   int N = st->ps_size;
+
+   for (i=1;i<N-1;i++)
+      st->S[i] = 100.f+ .8f*st->S[i] + .05f*st->ps[i-1]+.1f*st->ps[i]+.05f*st->ps[i+1];
+   
+   if (st->nb_preprocess<1)
+   {
+      for (i=1;i<N-1;i++)
+         st->Smin[i] = st->Stmp[i] = st->S[i]+100.f;
+   }
+
+   if (st->nb_preprocess%200==0)
+   {
+      for (i=1;i<N-1;i++)
+      {
+         st->Smin[i] = min(st->Stmp[i], st->S[i]);
+         st->Stmp[i] = st->S[i];
+      }
+   } else {
+      for (i=1;i<N-1;i++)
+      {
+         st->Smin[i] = min(st->Smin[i], st->S[i]);
+         st->Stmp[i] = min(st->Stmp[i], st->S[i]);      
+      }
+   }
+   for (i=1;i<N-1;i++)
+   {
+      st->update_prob[i] *= .2f;
+      if (st->S[i] > 2.5*st->Smin[i])
+         st->update_prob[i] += .8f;
+      /*fprintf (stderr, "%f ", st->S[i]/st->Smin[i]);*/
+      /*fprintf (stderr, "%f ", st->update_prob[i]);*/
+   }
+
+}
+
+#define NOISE_OVERCOMPENS 1.4
+
+int speex_preprocess(SpeexPreprocessState *st, spx_int16_t *x, float *echo)
+{
+   int i;
+   int is_speech=1;
+   float mean_post=0;
+   float mean_prior=0;
+   int N = st->ps_size;
+   int N3 = 2*N - st->frame_size;
+   int N4 = st->frame_size - N3;
+   float scale=.5f/N;
+   float *ps=st->ps;
+   float Zframe=0, Pframe;
+
+   preprocess_analysis(st, x);
+
+   update_noise_prob(st);
+
+   st->nb_preprocess++;
+
+   /* Noise estimation always updated for the 20 first times */
+   if (st->nb_adapt<10)
+   {
+      update_noise(st, ps, echo);
+   }
+
+   /* Deal with residual echo if provided */
+   if (echo)
+      for (i=1;i<N;i++)
+         st->echo_noise[i] = (.3f*st->echo_noise[i] + echo[i]);
+
+   /* Compute a posteriori SNR */
+   for (i=1;i<N;i++)
+   {
+      st->post[i] = ps[i]/(1.f+NOISE_OVERCOMPENS*st->noise[i]+st->echo_noise[i]+st->reverb_estimate[i]) - 1.f;
+      if (st->post[i]>100.f)
+         st->post[i]=100.f;
+      /*if (st->post[i]<0)
+        st->post[i]=0;*/
+      mean_post+=st->post[i];
+   }
+   mean_post /= N;
+   if (mean_post<0.f)
+      mean_post=0.f;
+
+   /* Special case for first frame */
+   if (st->nb_adapt==1)
+      for (i=1;i<N;i++)
+         st->old_ps[i] = ps[i];
+
+   /* Compute a priori SNR */
+   {
+      /* A priori update rate */
+      float gamma;
+      float min_gamma=0.12f;
+      gamma = 1.0f/st->nb_preprocess;
+
+      /*Make update rate smaller when there's no speech*/
+#if 0
+      if (mean_post<3.5 && mean_prior < 1)
+         min_gamma *= (mean_post+.5);
+      else
+         min_gamma *= 4.;
+#else
+      min_gamma = .1f*fabs(mean_prior - mean_post)*fabs(mean_prior - mean_post);
+      if (min_gamma>.15f)
+         min_gamma = .15f;
+      if (min_gamma<.02f)
+         min_gamma = .02f;
+#endif
+      /*min_gamma = .08;*/
+
+      /*if (gamma<min_gamma)*/
+         gamma=min_gamma;
+      gamma = .1;
+      for (i=1;i<N;i++)
+      {
+         
+         /* A priori SNR update */
+         st->prior[i] = gamma*max(0.0f,st->post[i]) +
+         (1.f-gamma)*st->gain[i]*st->gain[i]*st->old_ps[i]/(1.f+NOISE_OVERCOMPENS*st->noise[i]+st->echo_noise[i]+st->reverb_estimate[i]);
+         
+         if (st->prior[i]>100.f)
+            st->prior[i]=100.f;
+         
+         mean_prior+=st->prior[i];
+      }
+   }
+   mean_prior /= N;
+
+#if 0
+   for (i=0;i<N;i++)
+   {
+      fprintf (stderr, "%f ", st->prior[i]);
+   }
+   fprintf (stderr, "\n");
+#endif
+   /*fprintf (stderr, "%f %f\n", mean_prior,mean_post);*/
+
+   if (st->nb_preprocess>=20)
+   {
+      int do_update = 0;
+      float noise_ener=0, sig_ener=0;
+      /* If SNR is low (both a priori and a posteriori), update the noise estimate*/
+      /*if (mean_prior<.23 && mean_post < .5)*/
+      if (mean_prior<.23f && mean_post < .5f)
+         do_update = 1;
+      for (i=1;i<N;i++)
+      {
+         noise_ener += st->noise[i];
+         sig_ener += ps[i];
+      }
+      if (noise_ener > 3.f*sig_ener)
+         do_update = 1;
+      /*do_update = 0;*/
+      if (do_update)
+      {
+         st->consec_noise++;
+      } else {
+         st->consec_noise=0;
+      }
+   }
+
+   if (st->vad_enabled)
+      is_speech = speex_compute_vad(st, ps, mean_prior, mean_post);
+
+
+   if (st->consec_noise>=3)
+   {
+      update_noise(st, st->old_ps, echo);
+   } else {
+      for (i=1;i<N-1;i++)
+      {
+         if (st->update_prob[i]<.5f || st->ps[i] < st->noise[i])
+         {
+            if (echo)
+               st->noise[i] = .90f*st->noise[i] + .1f*max(1.0f,st->ps[i]-echo[i]);
+            else
+               st->noise[i] = .90f*st->noise[i] + .1f*st->ps[i];
+         }
+      }
+   }
+
+   for (i=1;i<N;i++)
+   {
+      st->zeta[i] = .7f*st->zeta[i] + .3f*st->prior[i];
+   }
+
+   {
+      int freq_start = (int)(300.0f*2.f*N/st->sampling_rate);
+      int freq_end   = (int)(2000.0f*2.f*N/st->sampling_rate);
+      for (i=freq_start;i<freq_end;i++)
+      {
+         Zframe += st->zeta[i];         
+      }
+   }
+
+   Zframe /= N;
+   if (Zframe<ZMIN)
+   {
+      Pframe = 0;
+   } else {
+      if (Zframe > 1.5f*st->Zlast)
+      {
+         Pframe = 1.f;
+         st->Zpeak = Zframe;
+         if (st->Zpeak > 10.f)
+            st->Zpeak = 10.f;
+         if (st->Zpeak < 1.f)
+            st->Zpeak = 1.f;
+      } else {
+         if (Zframe < st->Zpeak*ZMIN)
+         {
+            Pframe = 0;
+         } else if (Zframe > st->Zpeak*ZMAX)
+         {
+            Pframe = 1;
+         } else {
+            Pframe = log(Zframe/(st->Zpeak*ZMIN)) / log(ZMAX/ZMIN);
+         }
+      }
+   }
+   st->Zlast = Zframe;
+
+   /*fprintf (stderr, "%f\n", Pframe);*/
+   /* Compute gain according to the Ephraim-Malah algorithm */
+   for (i=1;i<N;i++)
+   {
+      float MM;
+      float theta;
+      float prior_ratio;
+      float p, q;
+      float zeta1;
+      float P1;
+
+      prior_ratio = st->prior[i]/(1.0001f+st->prior[i]);
+      theta = (1.f+st->post[i])*prior_ratio;
+
+      if (i==1 || i==N-1)
+         zeta1 = st->zeta[i];
+      else
+         zeta1 = .25f*st->zeta[i-1] + .5f*st->zeta[i] + .25f*st->zeta[i+1];
+      if (zeta1<ZMIN)
+         P1 = 0.f;
+      else if (zeta1>ZMAX)
+         P1 = 1.f;
+      else
+         P1 = LOG_MIN_MAX_1 * log(ZMIN_1*zeta1);
+  
+      /*P1 = log(zeta1/ZMIN)/log(ZMAX/ZMIN);*/
+      
+      /* FIXME: add global prob (P2) */
+      q = 1-Pframe*P1;
+      q = 1-P1;
+      if (q>.95f)
+         q=.95f;
+      p=1.f/(1.f + (q/(1.f-q))*(1.f+st->prior[i])*exp(-theta));
+      /*p=1;*/
+
+#if 0
+      /* log-spectral magnitude estimator */
+      if (theta<6)
+         MM = 0.74082*pow(theta+1,.61)/sqrt(.0001+theta);
+      else
+         MM=1;
+#else
+      /* Optimal estimator for loudness domain */
+      MM = hypergeom_gain(theta);
+#endif
+
+      st->gain[i] = prior_ratio * MM;
+      /*Put some (very arbitraty) limit on the gain*/
+      if (st->gain[i]>2.f)
+      {
+         st->gain[i]=2.f;
+      }
+      
+      st->reverb_estimate[i] = st->reverb_decay*st->reverb_estimate[i] + st->reverb_decay*st->reverb_level*st->gain[i]*st->gain[i]*st->ps[i];
+      if (st->denoise_enabled)
+      {
+         st->gain2[i]=p*p*st->gain[i];
+      } else {
+         st->gain2[i]=1.f;
+      }
+   }
+   st->gain2[0]=st->gain[0]=0.f;
+   st->gain2[N-1]=st->gain[N-1]=0.f;
+
+   if (st->agc_enabled)
+      speex_compute_agc(st, mean_prior);
+
+#if 0
+   if (!is_speech)
+   {
+      for (i=0;i<N;i++)
+         st->gain2[i] = 0;
+   }
+#if 0
+ else {
+      for (i=0;i<N;i++)
+         st->gain2[i] = 1;
+   }
+#endif
+#endif
+
+   /* Apply computed gain */
+   for (i=1;i<N;i++)
+   {
+      st->frame[2*i-1] *= st->gain2[i];
+      st->frame[2*i] *= st->gain2[i];
+   }
+
+   /* Get rid of the DC and very low frequencies */
+   st->frame[0]=0;
+   st->frame[1]=0;
+   st->frame[2]=0;
+   /* Nyquist frequency is mostly useless too */
+   st->frame[2*N-1]=0;
+
+   /* Inverse FFT with 1/N scaling */
+   spx_drft_backward(st->fft_lookup, st->frame);
+
+   for (i=0;i<2*N;i++)
+      st->frame[i] *= scale;
+
+   {
+      float max_sample=0;
+      for (i=0;i<2*N;i++)
+         if (fabs(st->frame[i])>max_sample)
+            max_sample = fabs(st->frame[i]);
+      if (max_sample>28000.f)
+      {
+         float damp = 28000.f/max_sample;
+         for (i=0;i<2*N;i++)
+            st->frame[i] *= damp;
+      }
+   }
+
+   for (i=0;i<2*N;i++)
+      st->frame[i] *= st->window[i];
+
+   /* Perform overlap and add */
+   for (i=0;i<N3;i++)
+      x[i] = st->outbuf[i] + st->frame[i];
+   for (i=0;i<N4;i++)
+      x[N3+i] = st->frame[N3+i];
+   
+   /* Update outbuf */
+   for (i=0;i<N3;i++)
+      st->outbuf[i] = st->frame[st->frame_size+i];
+
+   /* Save old power spectrum */
+   for (i=1;i<N;i++)
+      st->old_ps[i] = ps[i];
+
+   return is_speech;
+}
+
+void speex_preprocess_estimate_update(SpeexPreprocessState *st, spx_int16_t *x, float *echo)
+{
+   int i;
+   int N = st->ps_size;
+   int N3 = 2*N - st->frame_size;
+
+   float *ps=st->ps;
+
+   preprocess_analysis(st, x);
+
+   update_noise_prob(st);
+
+   st->nb_preprocess++;
+   
+   for (i=1;i<N-1;i++)
+   {
+      if (st->update_prob[i]<.5f || st->ps[i] < st->noise[i])
+      {
+         if (echo)
+            st->noise[i] = .90f*st->noise[i] + .1f*max(1.0f,st->ps[i]-echo[i]);
+         else
+            st->noise[i] = .90f*st->noise[i] + .1f*st->ps[i];
+      }
+   }
+
+   for (i=0;i<N3;i++)
+      st->outbuf[i] = x[st->frame_size-N3+i]*st->window[st->frame_size+i];
+
+   /* Save old power spectrum */
+   for (i=1;i<N;i++)
+      st->old_ps[i] = ps[i];
+
+   for (i=1;i<N;i++)
+      st->reverb_estimate[i] *= st->reverb_decay;
+}
+
+
+int speex_preprocess_ctl(SpeexPreprocessState *state, int request, void *ptr)
+{
+   int i;
+   SpeexPreprocessState *st;
+   st=(SpeexPreprocessState*)state;
+   switch(request)
+   {
+   case SPEEX_PREPROCESS_SET_DENOISE:
+      st->denoise_enabled = (*(int*)ptr);
+      break;
+   case SPEEX_PREPROCESS_GET_DENOISE:
+      (*(int*)ptr) = st->denoise_enabled;
+      break;
+
+   case SPEEX_PREPROCESS_SET_AGC:
+      st->agc_enabled = (*(int*)ptr);
+      break;
+   case SPEEX_PREPROCESS_GET_AGC:
+      (*(int*)ptr) = st->agc_enabled;
+      break;
+
+   case SPEEX_PREPROCESS_SET_AGC_LEVEL:
+      st->agc_level = (*(float*)ptr);
+      if (st->agc_level<1)
+         st->agc_level=1;
+      if (st->agc_level>32768)
+         st->agc_level=32768;
+      break;
+   case SPEEX_PREPROCESS_GET_AGC_LEVEL:
+      (*(float*)ptr) = st->agc_level;
+      break;
+
+   case SPEEX_PREPROCESS_SET_VAD:
+      st->vad_enabled = (*(int*)ptr);
+      break;
+   case SPEEX_PREPROCESS_GET_VAD:
+      (*(int*)ptr) = st->vad_enabled;
+      break;
+   
+   case SPEEX_PREPROCESS_SET_DEREVERB:
+      st->dereverb_enabled = (*(int*)ptr);
+      for (i=0;i<st->ps_size;i++)
+         st->reverb_estimate[i]=0;
+      break;
+   case SPEEX_PREPROCESS_GET_DEREVERB:
+      (*(int*)ptr) = st->dereverb_enabled;
+      break;
+
+   case SPEEX_PREPROCESS_SET_DEREVERB_LEVEL:
+      st->reverb_level = (*(float*)ptr);
+      break;
+   case SPEEX_PREPROCESS_GET_DEREVERB_LEVEL:
+      (*(float*)ptr) = st->reverb_level;
+      break;
+   
+   case SPEEX_PREPROCESS_SET_DEREVERB_DECAY:
+      st->reverb_decay = (*(float*)ptr);
+      break;
+   case SPEEX_PREPROCESS_GET_DEREVERB_DECAY:
+      (*(float*)ptr) = st->reverb_decay;
+      break;
+
+      default:
+      speex_warning_int("Unknown speex_preprocess_ctl request: ", request);
+      return -1;
+   }
+   return 0;
+}

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/quant_lsp.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/quant_lsp.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/quant_lsp.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -30,24 +30,81 @@
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include "quant_lsp.h"
 #include <math.h>
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
 
+
+#include "misc.h"
+
+#ifdef FIXED_POINT
+
+#define LSP_LINEAR(i) (SHL16(i+1,11))
+#define LSP_LINEAR_HIGH(i) (ADD16(MULT16_16_16(i,2560),6144))
+#define LSP_DIV_256(x) (SHL16((spx_word16_t)x, 5))
+#define LSP_DIV_512(x) (SHL16((spx_word16_t)x, 4))
+#define LSP_DIV_1024(x) (SHL16((spx_word16_t)x, 3))
+#define LSP_PI 25736
+
+#else
+
+#define LSP_LINEAR(i) (.25*(i)+.25)
+#define LSP_LINEAR_HIGH(i) (.3125*(i)+.75)
+#define LSP_SCALE 256.
+#define LSP_DIV_256(x) (0.0039062*(x))
+#define LSP_DIV_512(x) (0.0019531*(x))
+#define LSP_DIV_1024(x) (0.00097656*(x))
+#define LSP_PI M_PI
+
+#endif
+
+static void compute_quant_weights(spx_lsp_t *qlsp, spx_word16_t *quant_weight, int order)
+{
+   int i;
+   spx_word16_t tmp1, tmp2;
+   for (i=0;i<order;i++)
+   {
+      if (i==0)
+         tmp1 = qlsp[i];
+      else
+         tmp1 = qlsp[i]-qlsp[i-1];
+      if (i==order-1)
+         tmp2 = LSP_PI-qlsp[i];
+      else
+         tmp2 = qlsp[i+1]-qlsp[i];
+      if (tmp2<tmp1)
+         tmp1 = tmp2;
+#ifdef FIXED_POINT
+      quant_weight[i] = DIV32_16(81920,ADD16(300,tmp1));
+#else
+      quant_weight[i] = 10/(.04+tmp1);
+#endif
+   }
+
+}
+
 /* Note: x is modified*/
-static int lsp_quant(float *x, signed char *cdbk, int nbVec, int nbDim)
+static int lsp_quant(spx_word16_t *x, const signed char *cdbk, int nbVec, int nbDim)
 {
    int i,j;
-   float dist, tmp;
-   float best_dist=0;
+   spx_word32_t dist;
+   spx_word16_t tmp;
+   spx_word32_t best_dist=0;
    int best_id=0;
-   signed char *ptr=cdbk;
+   const signed char *ptr=cdbk;
    for (i=0;i<nbVec;i++)
    {
       dist=0;
       for (j=0;j<nbDim;j++)
       {
-         tmp=(x[j]-*ptr++);
-         dist+=tmp*tmp;
+         tmp=SUB16(x[j],SHL16((spx_word16_t)*ptr++,5));
+         dist=MAC16_16(dist,tmp,tmp);
       }
       if (dist<best_dist || i==0)
       {
@@ -57,26 +114,27 @@
    }
 
    for (j=0;j<nbDim;j++)
-      x[j] -= cdbk[best_id*nbDim+j];
+      x[j] = SUB16(x[j],SHL16((spx_word16_t)cdbk[best_id*nbDim+j],5));
     
    return best_id;
 }
 
 /* Note: x is modified*/
-static int lsp_weight_quant(float *x, float *weight, signed char *cdbk, int nbVec, int nbDim)
+static int lsp_weight_quant(spx_word16_t *x, spx_word16_t *weight, const signed char *cdbk, int nbVec, int nbDim)
 {
    int i,j;
-   float dist, tmp;
-   float best_dist=0;
+   spx_word32_t dist;
+   spx_word16_t tmp;
+   spx_word32_t best_dist=0;
    int best_id=0;
-   signed char *ptr=cdbk;
+   const signed char *ptr=cdbk;
    for (i=0;i<nbVec;i++)
    {
       dist=0;
       for (j=0;j<nbDim;j++)
       {
-         tmp=(x[j]-*ptr++);
-         dist+=weight[j]*tmp*tmp;
+         tmp=SUB16(x[j],SHL16((spx_word16_t)*ptr++,5));
+         dist=MAC16_32_Q15(dist,weight[j],MULT16_16(tmp,tmp));
       }
       if (dist<best_dist || i==0)
       {
@@ -86,39 +144,29 @@
    }
    
    for (j=0;j<nbDim;j++)
-      x[j] -= cdbk[best_id*nbDim+j];
+      x[j] = SUB16(x[j],SHL16((spx_word16_t)cdbk[best_id*nbDim+j],5));
    return best_id;
 }
 
 
-void lsp_quant_nb(float *lsp, float *qlsp, int order, SpeexBits *bits)
+void lsp_quant_nb(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits)
 {
    int i;
-   float tmp1, tmp2;
    int id;
-   float quant_weight[MAX_LSP_SIZE];
-
+   spx_word16_t quant_weight[10];
+   
    for (i=0;i<order;i++)
       qlsp[i]=lsp[i];
 
-   quant_weight[0] = 1/(qlsp[1]-qlsp[0]);
-   quant_weight[order-1] = 1/(qlsp[order-1]-qlsp[order-2]);
-   for (i=1;i<order-1;i++)
-   {
-#if 1
-      tmp1 = 1/((.15+qlsp[i]-qlsp[i-1])*(.15+qlsp[i]-qlsp[i-1]));
-      tmp2 = 1/((.15+qlsp[i+1]-qlsp[i])*(.15+qlsp[i+1]-qlsp[i]));
-#else
-      tmp1 = 1/(qlsp[i]-qlsp[i-1]);
-      tmp2 = 1/(qlsp[i+1]-qlsp[i]);
-#endif
-      quant_weight[i] = tmp1 > tmp2 ? tmp1 : tmp2;
-   }
+   compute_quant_weights(qlsp, quant_weight, order);
+
    for (i=0;i<order;i++)
-      qlsp[i]-=(.25*i+.25);
+      qlsp[i]=SUB16(qlsp[i],LSP_LINEAR(i));
+
+#ifndef FIXED_POINT
    for (i=0;i<order;i++)
-      qlsp[i]*=256;
-
+      qlsp[i] = LSP_SCALE*qlsp[i];
+#endif
    id = lsp_quant(qlsp, cdbk_nb, NB_CDBK_SIZE, order);
    speex_bits_pack(bits, id, 6);
 
@@ -143,74 +191,67 @@
    id = lsp_weight_quant(qlsp+5, quant_weight+5, cdbk_nb_high2, NB_CDBK_SIZE_HIGH2, 5);
    speex_bits_pack(bits, id, 6);
 
+#ifdef FIXED_POINT
    for (i=0;i<order;i++)
-      qlsp[i]*=.00097656;
+      qlsp[i]=PSHR16(qlsp[i],2);
+#else
+   for (i=0;i<order;i++)
+      qlsp[i]=qlsp[i] * .00097656;
+#endif
 
    for (i=0;i<order;i++)
       qlsp[i]=lsp[i]-qlsp[i];
 }
 
-void lsp_unquant_nb(float *lsp, int order, SpeexBits *bits)
+void lsp_unquant_nb(spx_lsp_t *lsp, int order, SpeexBits *bits)
 {
    int i, id;
    for (i=0;i<order;i++)
-      lsp[i]=.25*i+.25;
+      lsp[i]=LSP_LINEAR(i);
 
 
    id=speex_bits_unpack_unsigned(bits, 6);
    for (i=0;i<10;i++)
-      lsp[i] += 0.0039062*cdbk_nb[id*10+i];
+      lsp[i] = ADD32(lsp[i], LSP_DIV_256(cdbk_nb[id*10+i]));
 
    id=speex_bits_unpack_unsigned(bits, 6);
    for (i=0;i<5;i++)
-      lsp[i] += 0.0019531 * cdbk_nb_low1[id*5+i];
+      lsp[i] = ADD16(lsp[i], LSP_DIV_512(cdbk_nb_low1[id*5+i]));
 
    id=speex_bits_unpack_unsigned(bits, 6);
    for (i=0;i<5;i++)
-      lsp[i] +=  0.00097656 * cdbk_nb_low2[id*5+i];
+      lsp[i] = ADD32(lsp[i], LSP_DIV_1024(cdbk_nb_low2[id*5+i]));
 
    id=speex_bits_unpack_unsigned(bits, 6);
    for (i=0;i<5;i++)
-      lsp[i+5] += 0.0019531 * cdbk_nb_high1[id*5+i];
+      lsp[i+5] = ADD32(lsp[i+5], LSP_DIV_512(cdbk_nb_high1[id*5+i]));
    
    id=speex_bits_unpack_unsigned(bits, 6);
    for (i=0;i<5;i++)
-      lsp[i+5] += 0.00097656 * cdbk_nb_high2[id*5+i];
+      lsp[i+5] = ADD32(lsp[i+5], LSP_DIV_1024(cdbk_nb_high2[id*5+i]));
 }
 
 
-void lsp_quant_lbr(float *lsp, float *qlsp, int order, SpeexBits *bits)
+void lsp_quant_lbr(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits)
 {
    int i;
-   float tmp1, tmp2;
    int id;
-   float quant_weight[MAX_LSP_SIZE];
+   spx_word16_t quant_weight[10];
 
    for (i=0;i<order;i++)
       qlsp[i]=lsp[i];
 
-   quant_weight[0] = 1/(qlsp[1]-qlsp[0]);
-   quant_weight[order-1] = 1/(qlsp[order-1]-qlsp[order-2]);
-   for (i=1;i<order-1;i++)
-   {
-#if 1
-      tmp1 = 1/((.15+qlsp[i]-qlsp[i-1])*(.15+qlsp[i]-qlsp[i-1]));
-      tmp2 = 1/((.15+qlsp[i+1]-qlsp[i])*(.15+qlsp[i+1]-qlsp[i]));
-#else
-      tmp1 = 1/(qlsp[i]-qlsp[i-1]);
-      tmp2 = 1/(qlsp[i+1]-qlsp[i]);
-#endif
-      quant_weight[i] = tmp1 > tmp2 ? tmp1 : tmp2;
-   }
+   compute_quant_weights(qlsp, quant_weight, order);
 
    for (i=0;i<order;i++)
-      qlsp[i]-=(.25*i+.25);
+      qlsp[i]=SUB16(qlsp[i],LSP_LINEAR(i));
+#ifndef FIXED_POINT
    for (i=0;i<order;i++)
-      qlsp[i]*=256;
-   
+      qlsp[i]=qlsp[i]*LSP_SCALE;
+#endif
    id = lsp_quant(qlsp, cdbk_nb, NB_CDBK_SIZE, order);
    speex_bits_pack(bits, id, 6);
-
+   
    for (i=0;i<order;i++)
       qlsp[i]*=2;
    
@@ -220,63 +261,80 @@
    id = lsp_weight_quant(qlsp+5, quant_weight+5, cdbk_nb_high1, NB_CDBK_SIZE_HIGH1, 5);
    speex_bits_pack(bits, id, 6);
 
+#ifdef FIXED_POINT
    for (i=0;i<order;i++)
-      qlsp[i]*=0.0019531;
+      qlsp[i] = PSHR16(qlsp[i],1);
+#else
+   for (i=0;i<order;i++)
+      qlsp[i] = qlsp[i]*0.0019531;
+#endif
 
    for (i=0;i<order;i++)
       qlsp[i]=lsp[i]-qlsp[i];
 }
 
-void lsp_unquant_lbr(float *lsp, int order, SpeexBits *bits)
+void lsp_unquant_lbr(spx_lsp_t *lsp, int order, SpeexBits *bits)
 {
    int i, id;
    for (i=0;i<order;i++)
-      lsp[i]=.25*i+.25;
+      lsp[i]=LSP_LINEAR(i);
 
 
    id=speex_bits_unpack_unsigned(bits, 6);
    for (i=0;i<10;i++)
-      lsp[i] += 0.0039062*cdbk_nb[id*10+i];
+      lsp[i] += LSP_DIV_256(cdbk_nb[id*10+i]);
 
    id=speex_bits_unpack_unsigned(bits, 6);
    for (i=0;i<5;i++)
-      lsp[i] += 0.0019531*cdbk_nb_low1[id*5+i];
+      lsp[i] += LSP_DIV_512(cdbk_nb_low1[id*5+i]);
 
    id=speex_bits_unpack_unsigned(bits, 6);
    for (i=0;i<5;i++)
-      lsp[i+5] += 0.0019531*cdbk_nb_high1[id*5+i];
+      lsp[i+5] += LSP_DIV_512(cdbk_nb_high1[id*5+i]);
    
 }
 
 
-extern signed char high_lsp_cdbk[];
-extern signed char high_lsp_cdbk2[];
+#ifdef DISABLE_WIDEBAND
+void lsp_quant_high(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits)
+{
+   speex_error("Wideband and Ultra-wideband are disabled");
+}
+void lsp_unquant_high(spx_lsp_t *lsp, int order, SpeexBits *bits)
+{
+   speex_error("Wideband and Ultra-wideband are disabled");
+}
+#else
+extern const signed char high_lsp_cdbk[];
+extern const signed char high_lsp_cdbk2[];
 
 
-void lsp_quant_high(float *lsp, float *qlsp, int order, SpeexBits *bits)
+void lsp_quant_high(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits)
 {
    int i;
-   float tmp1, tmp2;
    int id;
-   float quant_weight[MAX_LSP_SIZE];
+   spx_word16_t quant_weight[10];
 
    for (i=0;i<order;i++)
       qlsp[i]=lsp[i];
 
-   quant_weight[0] = 1/(qlsp[1]-qlsp[0]);
-   quant_weight[order-1] = 1/(qlsp[order-1]-qlsp[order-2]);
+   compute_quant_weights(qlsp, quant_weight, order);
+
+   /*   quant_weight[0] = 10/(qlsp[1]-qlsp[0]);
+   quant_weight[order-1] = 10/(qlsp[order-1]-qlsp[order-2]);
    for (i=1;i<order-1;i++)
    {
-      tmp1 = 1/(qlsp[i]-qlsp[i-1]);
-      tmp2 = 1/(qlsp[i+1]-qlsp[i]);
+      tmp1 = 10/(qlsp[i]-qlsp[i-1]);
+      tmp2 = 10/(qlsp[i+1]-qlsp[i]);
       quant_weight[i] = tmp1 > tmp2 ? tmp1 : tmp2;
-   }
+      }*/
 
    for (i=0;i<order;i++)
-      qlsp[i]-=(.3125*i+.75);
+      qlsp[i]=SUB16(qlsp[i],LSP_LINEAR_HIGH(i));
+#ifndef FIXED_POINT
    for (i=0;i<order;i++)
-      qlsp[i]*=256;
-
+      qlsp[i] = qlsp[i]*LSP_SCALE;
+#endif
    id = lsp_quant(qlsp, high_lsp_cdbk, 64, order);
    speex_bits_pack(bits, id, 6);
 
@@ -286,27 +344,98 @@
    id = lsp_weight_quant(qlsp, quant_weight, high_lsp_cdbk2, 64, order);
    speex_bits_pack(bits, id, 6);
 
+#ifdef FIXED_POINT
    for (i=0;i<order;i++)
-      qlsp[i]*=0.0019531;
+      qlsp[i] = PSHR16(qlsp[i],1);
+#else
+   for (i=0;i<order;i++)
+      qlsp[i] = qlsp[i]*0.0019531;
+#endif
 
    for (i=0;i<order;i++)
       qlsp[i]=lsp[i]-qlsp[i];
 }
 
-void lsp_unquant_high(float *lsp, int order, SpeexBits *bits)
+void lsp_unquant_high(spx_lsp_t *lsp, int order, SpeexBits *bits)
 {
 
    int i, id;
    for (i=0;i<order;i++)
-      lsp[i]=.3125*i+.75;
+      lsp[i]=LSP_LINEAR_HIGH(i);
 
 
    id=speex_bits_unpack_unsigned(bits, 6);
    for (i=0;i<order;i++)
-      lsp[i] += 0.0039062*high_lsp_cdbk[id*order+i];
+      lsp[i] += LSP_DIV_256(high_lsp_cdbk[id*order+i]);
 
 
    id=speex_bits_unpack_unsigned(bits, 6);
    for (i=0;i<order;i++)
-      lsp[i] += 0.0019531*high_lsp_cdbk2[id*order+i];
+      lsp[i] += LSP_DIV_512(high_lsp_cdbk2[id*order+i]);
 }
+
+#endif
+
+
+#ifdef EPIC_48K
+
+extern const signed char cdbk_lsp_vlbr[5120];
+extern const signed char cdbk_lsp2_vlbr[160];
+
+void lsp_quant_48k(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits)
+{
+   int i;
+   int id;
+   spx_word16_t quant_weight[10];
+
+   for (i=0;i<order;i++)
+      qlsp[i]=lsp[i];
+
+   compute_quant_weights(qlsp, quant_weight, order);
+
+   for (i=0;i<order;i++)
+      qlsp[i]=SUB16(qlsp[i],LSP_SCALING*(.25*i+.3125));
+#ifndef FIXED_POINT
+   for (i=0;i<order;i++)
+      qlsp[i] = qlsp[i]*LSP_SCALE;
+#endif
+   
+   id = lsp_quant(qlsp, cdbk_lsp_vlbr, 512, order);
+   speex_bits_pack(bits, id, 9);
+
+   for (i=0;i<order;i++)
+      qlsp[i]*=4;
+   
+   id = lsp_weight_quant(qlsp, quant_weight, cdbk_lsp2_vlbr, 16, 10);
+   speex_bits_pack(bits, id, 4);
+
+#ifdef FIXED_POINT
+   for (i=0;i<order;i++)
+      qlsp[i]=PSHR(qlsp[i],2);
+#else
+   for (i=0;i<order;i++)
+      qlsp[i]=qlsp[i]*0.00097655;
+#endif
+
+   for (i=0;i<order;i++)
+      qlsp[i]=lsp[i]-qlsp[i];
+}
+
+void lsp_unquant_48k(spx_lsp_t *lsp, int order, SpeexBits *bits)
+{
+   int i, id;
+   for (i=0;i<order;i++)
+      lsp[i]=LSP_SCALING*(.25*i+.3125);
+
+
+   id=speex_bits_unpack_unsigned(bits, 9);
+   for (i=0;i<10;i++)
+      lsp[i] += LSP_SCALING*0.0039062*cdbk_lsp_vlbr[id*10+i];
+
+   id=speex_bits_unpack_unsigned(bits, 4);
+   for (i=0;i<10;i++)
+      lsp[i] += LSP_SCALING*0.00097655*cdbk_lsp2_vlbr[id*10+i];
+   
+}
+
+#endif

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/quant_lsp.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/quant_lsp.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/quant_lsp.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -34,6 +34,7 @@
 #define QUANT_LSP_H
 
 #include <speex/speex_bits.h>
+#include "misc.h"
 
 #define MAX_LSP_SIZE 20
 
@@ -44,28 +45,37 @@
 #define NB_CDBK_SIZE_HIGH2 64
 
 /*Narrowband codebooks*/
-extern signed char cdbk_nb[];
-extern signed char cdbk_nb_low1[];
-extern signed char cdbk_nb_low2[];
-extern signed char cdbk_nb_high1[];
-extern signed char cdbk_nb_high2[];
+extern const signed char cdbk_nb[];
+extern const signed char cdbk_nb_low1[];
+extern const signed char cdbk_nb_low2[];
+extern const signed char cdbk_nb_high1[];
+extern const signed char cdbk_nb_high2[];
 
 /* Quantizes narrowband LSPs with 30 bits */
-void lsp_quant_nb(float *lsp, float *qlsp, int order, SpeexBits *bits);
+void lsp_quant_nb(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits);
 
 /* Decodes quantized narrowband LSPs */
-void lsp_unquant_nb(float *lsp, int order, SpeexBits *bits);
+void lsp_unquant_nb(spx_lsp_t *lsp, int order, SpeexBits *bits);
 
 /* Quantizes low bit-rate narrowband LSPs with 18 bits */
-void lsp_quant_lbr(float *lsp, float *qlsp, int order, SpeexBits *bits);
+void lsp_quant_lbr(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits);
 
 /* Decodes quantized low bit-rate narrowband LSPs */
-void lsp_unquant_lbr(float *lsp, int order, SpeexBits *bits);
+void lsp_unquant_lbr(spx_lsp_t *lsp, int order, SpeexBits *bits);
 
 /* Quantizes high-band LSPs with 12 bits */
-void lsp_quant_high(float *lsp, float *qlsp, int order, SpeexBits *bits);
+void lsp_quant_high(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits);
 
 /* Decodes high-band LSPs */
-void lsp_unquant_high(float *lsp, int order, SpeexBits *bits);
+void lsp_unquant_high(spx_lsp_t *lsp, int order, SpeexBits *bits);
 
+#ifdef EPIC_48K
+/* Quantizes narrowband LSPs with 14 bits */
+void lsp_quant_48k(spx_lsp_t *lsp, spx_lsp_t *qlsp, int order, SpeexBits *bits);
+
+/* Decodes quantized narrowband LSPs (14 bits) */
+void lsp_unquant_48k(spx_lsp_t *lsp, int order, SpeexBits *bits);
 #endif
+
+
+#endif

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/sb_celp.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/sb_celp.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/sb_celp.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -29,6 +29,9 @@
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 
 #include <math.h>
 #include "sb_celp.h"
@@ -43,6 +46,59 @@
 #include "ltp.h"
 #include "misc.h"
 
+/* Default size for the encoder and decoder stack (can be changed at compile time).
+   This does not apply when using variable-size arrays or alloca. */
+#ifndef SB_ENC_STACK
+#define SB_ENC_STACK (10000*sizeof(spx_sig_t))
+#endif
+
+#ifndef SB_DEC_STACK
+#define SB_DEC_STACK (6000*sizeof(spx_sig_t))
+#endif
+
+
+#ifdef DISABLE_WIDEBAND
+void *sb_encoder_init(const SpeexMode *m)
+{
+   speex_error("Wideband and Ultra-wideband are disabled");
+   return NULL;
+}
+void sb_encoder_destroy(void *state)
+{
+   speex_error("Wideband and Ultra-wideband are disabled");
+}
+int sb_encode(void *state, void *vin, SpeexBits *bits)
+{
+   speex_error("Wideband and Ultra-wideband are disabled");
+   return -2;
+}
+void *sb_decoder_init(const SpeexMode *m)
+{
+   speex_error("Wideband and Ultra-wideband are disabled");
+   return NULL;
+}
+void sb_decoder_destroy(void *state)
+{
+   speex_error("Wideband and Ultra-wideband are disabled");
+}
+int sb_decode(void *state, SpeexBits *bits, void *vout)
+{
+   speex_error("Wideband and Ultra-wideband are disabled");
+   return -2;
+}
+int sb_encoder_ctl(void *state, int request, void *ptr)
+{
+   speex_error("Wideband and Ultra-wideband are disabled");
+   return -2;
+}
+int sb_decoder_ctl(void *state, int request, void *ptr)
+{
+   speex_error("Wideband and Ultra-wideband are disabled");
+   return -2;
+}
+#else
+
+
 #ifndef M_PI
 #define M_PI           3.14159265358979323846  /* pi */
 #endif
@@ -51,8 +107,30 @@
 
 #define SUBMODE(x) st->submodes[st->submodeID]->x
 
+#ifdef FIXED_POINT
+static const spx_word16_t gc_quant_bound[16] = {125, 164, 215, 282, 370, 484, 635, 832, 1090, 1428, 1871, 2452, 3213, 4210, 5516, 7228};
+#define LSP_MARGIN 410
+#define LSP_DELTA1 6553
+#define LSP_DELTA2 1638
+
+#else
+
+#define LSP_MARGIN .05
+#define LSP_DELTA1 .2
+#define LSP_DELTA2 .05
+
+#endif
+
 #define QMF_ORDER 64
-static float h0[64] = {
+
+#ifdef FIXED_POINT
+static const spx_word16_t h0[64] = {2, -7, -7, 18, 15, -39, -25, 75, 35, -130, -41, 212, 38, -327, -17, 483, -32, -689, 124, 956, -283, -1307, 543, 1780, -973, -2467, 1733, 3633, -3339, -6409, 9059, 30153, 30153, 9059, -6409, -3339, 3633, 1733, -2467, -973, 1780, 543, -1307, -283, 956, 124, -689, -32, 483, -17, -327, 38, 212, -41, -130, 35, 75, -25, -39, 15, 18, -7, -7, 2};
+
+static const spx_word16_t h1[64] = {2, 7, -7, -18, 15, 39, -25, -75, 35, 130, -41, -212, 38, 327, -17, -483, -32, 689, 124, -956, -283, 1307, 543, -1780, -973, 2467, 1733, -3633, -3339, 6409, 9059, -30153, 30153, -9059, -6409, 3339, 3633, -1733, -2467, 973, 1780, -543, -1307, 283, 956, -124, -689, 32, 483, 17, -327, -38, 212, 41, -130, -35, 75, 25, -39, -15, 18, 7, -7, -2};
+
+
+#else
+static const float h0[64] = {
    3.596189e-05, -0.0001123515,
    -0.0001104587, 0.0002790277,
    0.0002298438, -0.0005953563,
@@ -87,7 +165,7 @@
    -0.0001123515, 3.596189e-05
 };
 
-static float h1[64] = {
+static const float h1[64] = {
    3.596189e-05, 0.0001123515,
    -0.0001104587, -0.0002790277,
    0.0002298438, 0.0005953563,
@@ -121,18 +199,45 @@
    0.0002790277, 0.0001104587,
    -0.0001123515, -3.596189e-05
 };
+#endif
 
-void *sb_encoder_init(SpeexMode *m)
+static void mix_and_saturate(spx_word32_t *x0, spx_word32_t *x1, spx_word16_t *out, int len)
 {
    int i;
+   for (i=0;i<len;i++)
+   {
+      spx_word32_t tmp;
+#ifdef FIXED_POINT
+      tmp=PSHR(x0[i]-x1[i],SIG_SHIFT-1);
+#else
+      tmp=2*(x0[i]-x1[i]);
+#endif
+      if (tmp>32767)
+         out[i] = 32767;
+      else if (tmp<-32767)
+         out[i] = -32767;
+      else
+         out[i] = tmp;
+   }
+}
+
+void *sb_encoder_init(const SpeexMode *m)
+{
+   int i;
    SBEncState *st;
-   SpeexSBMode *mode;
+   const SpeexSBMode *mode;
 
-   st = (SBEncState*)speex_alloc(sizeof(SBEncState)+8000*sizeof(float));
+   st = (SBEncState*)speex_alloc(sizeof(SBEncState));
+   if (!st)
+      return NULL;
+#if defined(VAR_ARRAYS) || defined (USE_ALLOCA)
+   st->stack = NULL;
+#else
+   st->stack = (char*)speex_alloc_scratch(SB_ENC_STACK);
+#endif
    st->mode = m;
-   mode = (SpeexSBMode*)m->mode;
+   mode = (const SpeexSBMode*)m->mode;
 
-   st->stack = ((char*)st) + sizeof(SBEncState);
 
    st->st_low = speex_encoder_init(mode->nb_mode);
    st->full_frame_size = 2*mode->frameSize;
@@ -143,6 +248,7 @@
    st->lpcSize=mode->lpcSize;
    st->bufSize=mode->bufSize;
 
+   st->encode_submode = 1;
    st->submodes=mode->submodes;
    st->submodeSelect = st->submodeID=mode->defaultSubmode;
    
@@ -155,58 +261,57 @@
    st->gamma2=mode->gamma2;
    st->first=1;
 
-   st->x0d=PUSH(st->stack, st->frame_size, float);
-   st->x1d=PUSH(st->stack, st->frame_size, float);
-   st->high=PUSH(st->stack, st->full_frame_size, float);
-   st->y0=PUSH(st->stack, st->full_frame_size, float);
-   st->y1=PUSH(st->stack, st->full_frame_size, float);
+   st->x0d=speex_alloc((st->frame_size)*sizeof(spx_sig_t));
+   st->x1d=speex_alloc((st->frame_size)*sizeof(spx_sig_t));
+   st->high=speex_alloc((st->full_frame_size)*sizeof(spx_sig_t));
+   st->y0=speex_alloc((st->full_frame_size)*sizeof(spx_sig_t));
+   st->y1=speex_alloc((st->full_frame_size)*sizeof(spx_sig_t));
 
-   st->h0_mem=PUSH(st->stack, QMF_ORDER, float);
-   st->h1_mem=PUSH(st->stack, QMF_ORDER, float);
-   st->g0_mem=PUSH(st->stack, QMF_ORDER, float);
-   st->g1_mem=PUSH(st->stack, QMF_ORDER, float);
+   st->h0_mem=speex_alloc((QMF_ORDER)*sizeof(spx_word16_t));
+   st->h1_mem=speex_alloc((QMF_ORDER)*sizeof(spx_word16_t));
+   st->g0_mem=speex_alloc((QMF_ORDER)*sizeof(spx_word32_t));
+   st->g1_mem=speex_alloc((QMF_ORDER)*sizeof(spx_word32_t));
 
-   st->buf=PUSH(st->stack, st->windowSize, float);
-   st->excBuf=PUSH(st->stack, st->bufSize, float);
+   st->buf=speex_alloc((st->windowSize)*sizeof(spx_sig_t));
+   st->excBuf=speex_alloc((st->bufSize)*sizeof(spx_sig_t));
    st->exc = st->excBuf + st->bufSize - st->windowSize;
 
-   st->res=PUSH(st->stack, st->frame_size, float);
-   st->sw=PUSH(st->stack, st->frame_size, float);
-   st->target=PUSH(st->stack, st->frame_size, float);
+   st->res=speex_alloc((st->frame_size)*sizeof(spx_sig_t));
+   st->sw=speex_alloc((st->frame_size)*sizeof(spx_sig_t));
+   st->target=speex_alloc((st->frame_size)*sizeof(spx_sig_t));
    /*Asymmetric "pseudo-Hamming" window*/
    {
       int part1, part2;
       part1 = st->subframeSize*7/2;
       part2 = st->subframeSize*5/2;
-      st->window = PUSH(st->stack, st->windowSize, float);
+      st->window = speex_alloc((st->windowSize)*sizeof(spx_word16_t));
       for (i=0;i<part1;i++)
-         st->window[i]=.54-.46*cos(M_PI*i/part1);
+         st->window[i]=(spx_word16_t)(SIG_SCALING*(.54-.46*cos(M_PI*i/part1)));
       for (i=0;i<part2;i++)
-         st->window[part1+i]=.54+.46*cos(M_PI*i/part2);
+         st->window[part1+i]=(spx_word16_t)(SIG_SCALING*(.54+.46*cos(M_PI*i/part2)));
    }
 
-   st->lagWindow = PUSH(st->stack, st->lpcSize+1, float);
+   st->lagWindow = speex_alloc((st->lpcSize+1)*sizeof(spx_word16_t));
    for (i=0;i<st->lpcSize+1;i++)
-      st->lagWindow[i]=exp(-.5*sqr(2*M_PI*st->lag_factor*i));
+      st->lagWindow[i]=16384*exp(-.5*sqr(2*M_PI*st->lag_factor*i));
 
-   st->rc = PUSH(st->stack, st->lpcSize, float);
-   st->autocorr = PUSH(st->stack, st->lpcSize+1, float);
-   st->lpc = PUSH(st->stack, st->lpcSize+1, float);
-   st->bw_lpc1 = PUSH(st->stack, st->lpcSize+1, float);
-   st->bw_lpc2 = PUSH(st->stack, st->lpcSize+1, float);
-   st->lsp = PUSH(st->stack, st->lpcSize, float);
-   st->qlsp = PUSH(st->stack, st->lpcSize, float);
-   st->old_lsp = PUSH(st->stack, st->lpcSize, float);
-   st->old_qlsp = PUSH(st->stack, st->lpcSize, float);
-   st->interp_lsp = PUSH(st->stack, st->lpcSize, float);
-   st->interp_qlsp = PUSH(st->stack, st->lpcSize, float);
-   st->interp_lpc = PUSH(st->stack, st->lpcSize+1, float);
-   st->interp_qlpc = PUSH(st->stack, st->lpcSize+1, float);
-   st->pi_gain = PUSH(st->stack, st->nbSubframes, float);
+   st->autocorr = speex_alloc((st->lpcSize+1)*sizeof(spx_word16_t));
+   st->lpc = speex_alloc(st->lpcSize*sizeof(spx_coef_t));
+   st->bw_lpc1 = speex_alloc(st->lpcSize*sizeof(spx_coef_t));
+   st->bw_lpc2 = speex_alloc(st->lpcSize*sizeof(spx_coef_t));
+   st->lsp = speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
+   st->qlsp = speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
+   st->old_lsp = speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
+   st->old_qlsp = speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
+   st->interp_lsp = speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
+   st->interp_qlsp = speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
+   st->interp_lpc = speex_alloc(st->lpcSize*sizeof(spx_coef_t));
+   st->interp_qlpc = speex_alloc(st->lpcSize*sizeof(spx_coef_t));
+   st->pi_gain = speex_alloc((st->nbSubframes)*sizeof(spx_word32_t));
 
-   st->mem_sp = PUSH(st->stack, st->lpcSize, float);
-   st->mem_sp2 = PUSH(st->stack, st->lpcSize, float);
-   st->mem_sw = PUSH(st->stack, st->lpcSize, float);
+   st->mem_sp = speex_alloc((st->lpcSize)*sizeof(spx_mem_t));
+   st->mem_sp2 = speex_alloc((st->lpcSize)*sizeof(spx_mem_t));
+   st->mem_sw = speex_alloc((st->lpcSize)*sizeof(spx_mem_t));
 
    st->vbr_quality = 8;
    st->vbr_enabled = 0;
@@ -218,6 +323,9 @@
    speex_encoder_ctl(st->st_low, SPEEX_GET_SAMPLING_RATE, &st->sampling_rate);
    st->sampling_rate*=2;
 
+#ifdef ENABLE_VALGRIND
+   VALGRIND_MAKE_READABLE(st, (st->stack-(char*)st));
+#endif
    return st;
 }
 
@@ -226,43 +334,99 @@
    SBEncState *st=(SBEncState*)state;
 
    speex_encoder_destroy(st->st_low);
+#if !(defined(VAR_ARRAYS) || defined (USE_ALLOCA))
+   speex_free_scratch(st->stack);
+#endif
 
+   speex_free(st->x0d);
+   speex_free(st->x1d);
+   speex_free(st->high);
+   speex_free(st->y0);
+   speex_free(st->y1);
+
+   speex_free(st->h0_mem);
+   speex_free(st->h1_mem);
+   speex_free(st->g0_mem);
+   speex_free(st->g1_mem);
+
+   speex_free(st->buf);
+   speex_free(st->excBuf);
+   speex_free(st->res);
+   speex_free(st->sw);
+   speex_free(st->target);
+   speex_free(st->window);
+   speex_free(st->lagWindow);
+
+   speex_free(st->autocorr);
+   speex_free(st->lpc);
+   speex_free(st->bw_lpc1);
+   speex_free(st->bw_lpc2);
+   speex_free(st->lsp);
+   speex_free(st->qlsp);
+   speex_free(st->old_lsp);
+   speex_free(st->old_qlsp);
+   speex_free(st->interp_lsp);
+   speex_free(st->interp_qlsp);
+   speex_free(st->interp_lpc);
+   speex_free(st->interp_qlpc);
+   speex_free(st->pi_gain);
+
+   speex_free(st->mem_sp);
+   speex_free(st->mem_sp2);
+   speex_free(st->mem_sw);
+
+   
    speex_free(st);
 }
 
 
-int sb_encode(void *state, float *in, SpeexBits *bits)
+int sb_encode(void *state, void *vin, SpeexBits *bits)
 {
    SBEncState *st;
    int i, roots, sub;
    char *stack;
-   float *mem, *innov, *syn_resp;
-   float *low_pi_gain, *low_exc, *low_innov;
-   SpeexSBMode *mode;
+   VARDECL(spx_mem_t *mem);
+   VARDECL(spx_sig_t *innov);
+   VARDECL(spx_word16_t *syn_resp);
+   VARDECL(spx_word32_t *low_pi_gain);
+   VARDECL(spx_sig_t *low_exc);
+   VARDECL(spx_sig_t *low_innov);
+   const SpeexSBMode *mode;
    int dtx;
+   spx_word16_t *in = vin;
 
    st = (SBEncState*)state;
    stack=st->stack;
-   mode = (SpeexSBMode*)(st->mode->mode);
+   mode = (const SpeexSBMode*)(st->mode->mode);
 
-   /* Compute the two sub-bands by filtering with h0 and h1*/
-   qmf_decomp(in, h0, st->x0d, st->x1d, st->full_frame_size, QMF_ORDER, st->h0_mem, stack);
-    
-   /* Encode the narrowband part*/
-   speex_encode(st->st_low, st->x0d, bits);
+   {
+      VARDECL(spx_word16_t *low);
+      ALLOC(low, st->frame_size, spx_word16_t);
 
+      /* Compute the two sub-bands by filtering with h0 and h1*/
+      qmf_decomp(in, h0, st->x0d, st->x1d, st->full_frame_size, QMF_ORDER, st->h0_mem, stack);
+      
+      for (i=0;i<st->frame_size;i++)
+         low[i] = SATURATE(PSHR(st->x0d[i],SIG_SHIFT),32767);
+      
+      /* Encode the narrowband part*/
+      speex_encode_native(st->st_low, low, bits);
+
+      for (i=0;i<st->frame_size;i++)
+         st->x0d[i] = SHL(low[i],SIG_SHIFT);
+   }
    /* High-band buffering / sync with low band */
    for (i=0;i<st->windowSize-st->frame_size;i++)
       st->high[i] = st->high[st->frame_size+i];
    for (i=0;i<st->frame_size;i++)
-      st->high[st->windowSize-st->frame_size+i]=st->x1d[i];
+      st->high[st->windowSize-st->frame_size+i]=SATURATE(st->x1d[i],536854528);
 
-   speex_move(st->excBuf, st->excBuf+st->frame_size, (st->bufSize-st->frame_size)*sizeof(float));
+   speex_move(st->excBuf, st->excBuf+st->frame_size, (st->bufSize-st->frame_size)*sizeof(spx_sig_t));
 
 
-   low_pi_gain = PUSH(stack, st->nbSubframes, float);
-   low_exc = PUSH(stack, st->frame_size, float);
-   low_innov = PUSH(stack, st->frame_size, float);
+   ALLOC(low_pi_gain, st->nbSubframes, spx_word32_t);
+   ALLOC(low_exc, st->frame_size, spx_sig_t);
+   ALLOC(low_innov, st->frame_size, spx_sig_t);
    speex_encoder_ctl(st->st_low, SPEEX_GET_PI_GAIN, low_pi_gain);
    speex_encoder_ctl(st->st_low, SPEEX_GET_EXC, low_exc);
    speex_encoder_ctl(st->st_low, SPEEX_GET_INNOV, low_innov);
@@ -274,41 +438,40 @@
    else
       dtx=0;
 
-   /* Start encoding the high-band */
-   for (i=0;i<st->windowSize;i++)
-      st->buf[i] = st->high[i] * st->window[i];
+   {
+      VARDECL(spx_word16_t *w_sig);
+      ALLOC(w_sig, st->windowSize, spx_word16_t);
+      /* Window for analysis */
+      for (i=0;i<st->windowSize;i++)
+         w_sig[i] = SHR(MULT16_16(SHR((spx_word32_t)(st->high[i]),SIG_SHIFT),st->window[i]),SIG_SHIFT);
 
-   /* Compute auto-correlation */
-   _spx_autocorr(st->buf, st->autocorr, st->lpcSize+1, st->windowSize);
+      /* Compute auto-correlation */
+      _spx_autocorr(w_sig, st->autocorr, st->lpcSize+1, st->windowSize);
+   }
 
-   st->autocorr[0] += 1;        /* prevents NANs */
-   st->autocorr[0] *= st->lpc_floor; /* Noise floor in auto-correlation domain */
+   st->autocorr[0] = (spx_word16_t)(st->autocorr[0]*st->lpc_floor); /* Noise floor in auto-correlation domain */
+
    /* Lag windowing: equivalent to filtering in the power-spectrum domain */
    for (i=0;i<st->lpcSize+1;i++)
-      st->autocorr[i] *= st->lagWindow[i];
+      st->autocorr[i] = MULT16_16_Q14(st->autocorr[i],st->lagWindow[i]);
 
    /* Levinson-Durbin */
-   wld(st->lpc+1, st->autocorr, st->rc, st->lpcSize);
-   st->lpc[0]=1;
+   _spx_lpc(st->lpc, st->autocorr, st->lpcSize);
 
    /* LPC to LSPs (x-domain) transform */
-   roots=lpc_to_lsp (st->lpc, st->lpcSize, st->lsp, 15, 0.2, stack);
+   roots=lpc_to_lsp (st->lpc, st->lpcSize, st->lsp, 15, LSP_DELTA1, stack);
    if (roots!=st->lpcSize)
    {
-      roots = lpc_to_lsp (st->lpc, st->lpcSize, st->lsp, 11, 0.02, stack);
+      roots = lpc_to_lsp (st->lpc, st->lpcSize, st->lsp, 11, LSP_DELTA2, stack);
       if (roots!=st->lpcSize) {
          /*If we can't find all LSP's, do some damage control and use a flat filter*/
          for (i=0;i<st->lpcSize;i++)
          {
-            st->lsp[i]=cos(M_PI*((float)(i+1))/(st->lpcSize+1));
+            st->lsp[i]=M_PI*((float)(i+1))/(st->lpcSize+1);
          }
       }
    }
 
-   /* x-domain to angle domain*/
-   for (i=0;i<st->lpcSize;i++)
-      st->lsp[i] = acos(st->lsp[i]);
-
    /* VBR code */
    if ((st->vbr_enabled || st->vad_enabled) && !dtx)
    {
@@ -334,12 +497,11 @@
       }
 
 
-      for (i=0;i<st->frame_size;i++)
-      {
-         e_low  += st->x0d[i]* st->x0d[i];
-         e_high += st->high[i]* st->high[i];
-      }
-      ratio = log((1+e_high)/(1+e_low));
+      /*FIXME: Are the two signals (low, high) in sync? */
+      e_low = compute_rms(st->x0d, st->frame_size);
+      e_high = compute_rms(st->high, st->frame_size);
+      ratio = 2*log((1+e_high)/(1+e_low));
+      
       speex_encoder_ctl(st->st_low, SPEEX_GET_RELATIVE_QUALITY, &st->relative_quality);
       if (ratio<-4)
          ratio=-4;
@@ -391,11 +553,14 @@
       /*fprintf (stderr, "%f %f\n", ratio, low_qual);*/
    }
 
-   speex_bits_pack(bits, 1, 1);
-   if (dtx)
-      speex_bits_pack(bits, 0, SB_SUBMODE_BITS);
-   else
-      speex_bits_pack(bits, st->submodeID, SB_SUBMODE_BITS);
+   if (st->encode_submode)
+   {
+      speex_bits_pack(bits, 1, 1);
+      if (dtx)
+         speex_bits_pack(bits, 0, SB_SUBMODE_BITS);
+      else
+         speex_bits_pack(bits, st->submodeID, SB_SUBMODE_BITS);
+   }
 
    /* If null mode (no transmission), just set a couple things to zero*/
    if (dtx || st->submodes[st->submodeID] == NULL)
@@ -408,16 +573,15 @@
       st->first=1;
 
       /* Final signal synthesis from excitation */
-      iir_mem2(st->exc, st->interp_qlpc, st->high, st->subframeSize, st->lpcSize, st->mem_sp);
+      iir_mem2(st->exc, st->interp_qlpc, st->high, st->frame_size, st->lpcSize, st->mem_sp);
 
-#ifndef RELEASE
-
+#ifdef RESYNTH
       /* Reconstruct the original */
       fir_mem_up(st->x0d, h0, st->y0, st->full_frame_size, QMF_ORDER, st->g0_mem, stack);
       fir_mem_up(st->high, h1, st->y1, st->full_frame_size, QMF_ORDER, st->g1_mem, stack);
 
       for (i=0;i<st->full_frame_size;i++)
-         in[i]=2*(st->y0[i]-st->y1[i]);
+         in[i]=SHR(st->y0[i]-st->y1[i], SIG_SHIFT-1);
 #endif
 
       if (dtx)
@@ -438,16 +602,17 @@
          st->old_qlsp[i] = st->qlsp[i];
    }
    
-   mem=PUSH(stack, st->lpcSize, float);
-   syn_resp=PUSH(stack, st->subframeSize, float);
-   innov = PUSH(stack, st->subframeSize, float);
+   ALLOC(mem, st->lpcSize, spx_mem_t);
+   ALLOC(syn_resp, st->subframeSize, spx_word16_t);
+   ALLOC(innov, st->subframeSize, spx_sig_t);
 
    for (sub=0;sub<st->nbSubframes;sub++)
    {
-      float *exc, *sp, *res, *target, *sw, tmp, filter_ratio;
+      spx_sig_t *exc, *sp, *res, *target, *sw;
+      spx_word16_t filter_ratio;
       int offset;
-      float rl, rh, eh=0, el=0;
-      int fold;
+      spx_word32_t rl, rh;
+      spx_word16_t eh=0;
 
       offset = st->subframeSize*sub;
       sp=st->high+offset;
@@ -457,20 +622,11 @@
       sw=st->sw+offset;
       
       /* LSP interpolation (quantized and unquantized) */
-      tmp = (1.0 + sub)/st->nbSubframes;
-      for (i=0;i<st->lpcSize;i++)
-         st->interp_lsp[i] = (1-tmp)*st->old_lsp[i] + tmp*st->lsp[i];
-      for (i=0;i<st->lpcSize;i++)
-         st->interp_qlsp[i] = (1-tmp)*st->old_qlsp[i] + tmp*st->qlsp[i];
-      
-      lsp_enforce_margin(st->interp_lsp, st->lpcSize, .05);
-      lsp_enforce_margin(st->interp_qlsp, st->lpcSize, .05);
+      lsp_interpolate(st->old_lsp, st->lsp, st->interp_lsp, st->lpcSize, sub, st->nbSubframes);
+      lsp_interpolate(st->old_qlsp, st->qlsp, st->interp_qlsp, st->lpcSize, sub, st->nbSubframes);
 
-      /* Compute interpolated LPCs (quantized and unquantized) */
-      for (i=0;i<st->lpcSize;i++)
-         st->interp_lsp[i] = cos(st->interp_lsp[i]);
-      for (i=0;i<st->lpcSize;i++)
-         st->interp_qlsp[i] = cos(st->interp_qlsp[i]);
+      lsp_enforce_margin(st->interp_lsp, st->lpcSize, LSP_MARGIN);
+      lsp_enforce_margin(st->interp_qlsp, st->lpcSize, LSP_MARGIN);
 
       lsp_to_lpc(st->interp_lsp, st->interp_lpc, st->lpcSize,stack);
       lsp_to_lpc(st->interp_qlsp, st->interp_qlpc, st->lpcSize, stack);
@@ -480,42 +636,56 @@
 
       /* Compute mid-band (4000 Hz for wideband) response of low-band and high-band
          filters */
-      rl=rh=0;
-      tmp=1;
-      st->pi_gain[sub]=0;
-      for (i=0;i<=st->lpcSize;i++)
+      st->pi_gain[sub]=LPC_SCALING;
+      rh = LPC_SCALING;
+      for (i=0;i<st->lpcSize;i+=2)
       {
-         rh += tmp*st->interp_qlpc[i];
-         tmp = -tmp;
-         st->pi_gain[sub]+=st->interp_qlpc[i];
+         rh += st->interp_qlpc[i+1] - st->interp_qlpc[i];
+         st->pi_gain[sub] += st->interp_qlpc[i] + st->interp_qlpc[i+1];
       }
+      
       rl = low_pi_gain[sub];
-      rl=1/(fabs(rl)+.01);
-      rh=1/(fabs(rh)+.01);
-      /* Compute ratio, will help predict the gain */
-      filter_ratio=fabs(.01+rh)/(.01+fabs(rl));
-
-      fold = filter_ratio<5;
-      /*printf ("filter_ratio %f\n", filter_ratio);*/
-      fold=0;
-
+#ifdef FIXED_POINT
+      filter_ratio=DIV32_16(SHL(rl+82,2),SHR(82+rh,5));
+#else
+      filter_ratio=(rl+.01)/(rh+.01);
+#endif
+      
       /* Compute "real excitation" */
       fir_mem2(sp, st->interp_qlpc, exc, st->subframeSize, st->lpcSize, st->mem_sp2);
       /* Compute energy of low-band and high-band excitation */
-      for (i=0;i<st->subframeSize;i++)
-         eh+=sqr(exc[i]);
 
+      eh = compute_rms(exc, st->subframeSize);
+
       if (!SUBMODE(innovation_quant)) {/* 1 for spectral folding excitation, 0 for stochastic */
          float g;
-         /*speex_bits_pack(bits, 1, 1);*/
-         for (i=0;i<st->subframeSize;i++)
-            el+=sqr(low_innov[offset+i]);
+         spx_word16_t el;
+         el = compute_rms(low_innov+offset, st->subframeSize);
 
          /* Gain to use if we want to use the low-band excitation for high-band */
          g=eh/(.01+el);
-         g=sqrt(g);
+         
+#if 0
+         {
+            char *tmp_stack=stack;
+            float *tmp_sig;
+            float g2;
+            ALLOC(tmp_sig, st->subframeSize, spx_sig_t);
+            for (i=0;i<st->lpcSize;i++)
+               mem[i]=st->mem_sp[i];
+            iir_mem2(low_innov+offset, st->interp_qlpc, tmp_sig, st->subframeSize, st->lpcSize, mem);
+            g2 = compute_rms(sp, st->subframeSize)/(.01+compute_rms(tmp_sig, st->subframeSize));
+            /*fprintf (stderr, "gains: %f %f\n", g, g2);*/
+            g = g2;
+            stack = tmp_stack;
+         }
+#endif
 
+#ifdef FIXED_POINT
+         g *= filter_ratio/128.;
+#else
          g *= filter_ratio;
+#endif
          /*print_vec(&g, 1, "gain factor");*/
          /* Gain quantization */
          {
@@ -526,40 +696,48 @@
             if (quant>31)
                quant=31;
             speex_bits_pack(bits, quant, 5);
-            g= .1*exp(quant/9.4);
          }
-         /*printf ("folding gain: %f\n", g);*/
-         g /= filter_ratio;
 
       } else {
-         float gc, scale, scale_1;
+         spx_word16_t gc;
+         spx_word32_t scale;
+         spx_word16_t el;
+         el = compute_rms(low_exc+offset, st->subframeSize);
 
-         for (i=0;i<st->subframeSize;i++)
-            el+=sqr(low_exc[offset+i]);
-         /*speex_bits_pack(bits, 0, 1);*/
+         gc = DIV32_16(MULT16_16(filter_ratio,1+eh),1+el);
 
-         gc = sqrt(1+eh)*filter_ratio/sqrt((1+el)*st->subframeSize);
+         /* This is a kludge that cleans up a historical bug */
+         if (st->subframeSize==80)
+            gc *= 0.70711;
+         /*printf ("%f %f %f %f\n", el, eh, filter_ratio, gc);*/
+#ifdef FIXED_POINT
          {
-            int qgc = (int)floor(.5+3.7*(log(gc)+2));
+            int qgc = scal_quant(gc, gc_quant_bound, 16);
+            speex_bits_pack(bits, qgc, 4);
+            gc = MULT16_32_Q15(28626,gc_quant_bound[qgc]);
+         }
+#else
+         {
+            int qgc = (int)floor(.5+3.7*(log(gc)+0.15556));
             if (qgc<0)
                qgc=0;
             if (qgc>15)
                qgc=15;
             speex_bits_pack(bits, qgc, 4);
-            gc = exp((1/3.7)*qgc-2);
-         }
+            gc = exp((1/3.7)*qgc-0.15556);
+         }         
+#endif
+         if (st->subframeSize==80)
+            gc *= 1.4142;
 
-         scale = gc*sqrt(1+el)/filter_ratio;
-         scale_1 = 1/scale;
+         scale = SHL(MULT16_16(DIV32_16(SHL(gc,SIG_SHIFT-4),filter_ratio),(1+el)),4);
 
-         for (i=0;i<st->subframeSize;i++)
-            exc[i]=0;
-         exc[0]=1;
-         syn_percep_zero(exc, st->interp_qlpc, st->bw_lpc1, st->bw_lpc2, syn_resp, st->subframeSize, st->lpcSize, stack);
+         compute_impulse_response(st->interp_qlpc, st->bw_lpc1, st->bw_lpc2, syn_resp, st->subframeSize, st->lpcSize, stack);
+
          
          /* Reset excitation */
          for (i=0;i<st->subframeSize;i++)
-            exc[i]=0;
+            exc[i]=VERY_SMALL;
          
          /* Compute zero response (ringing) of A(z/g1) / ( A(z/g2) * Aq(z) ) */
          for (i=0;i<st->lpcSize;i++)
@@ -582,10 +760,8 @@
          for (i=0;i<st->subframeSize;i++)
            exc[i]=0;
 
+         signal_div(target, target, scale, st->subframeSize);
 
-         for (i=0;i<st->subframeSize;i++)
-            target[i]*=scale_1;
-         
          /* Reset excitation */
          for (i=0;i<st->subframeSize;i++)
             innov[i]=0;
@@ -593,49 +769,52 @@
          /*print_vec(target, st->subframeSize, "\ntarget");*/
          SUBMODE(innovation_quant)(target, st->interp_qlpc, st->bw_lpc1, st->bw_lpc2, 
                                    SUBMODE(innovation_params), st->lpcSize, st->subframeSize, 
-                                   innov, syn_resp, bits, stack, (st->complexity+1)>>1);
+                                   innov, syn_resp, bits, stack, (st->complexity+1)>>1, SUBMODE(double_codebook));
          /*print_vec(target, st->subframeSize, "after");*/
 
+         signal_mul(innov, innov, scale, st->subframeSize);
+
          for (i=0;i<st->subframeSize;i++)
-            exc[i] += innov[i]*scale;
+            exc[i] = ADD32(exc[i], innov[i]);
 
          if (SUBMODE(double_codebook)) {
             char *tmp_stack=stack;
-            float *innov2 = PUSH(tmp_stack, st->subframeSize, float);
+            VARDECL(spx_sig_t *innov2);
+            ALLOC(innov2, st->subframeSize, spx_sig_t);
             for (i=0;i<st->subframeSize;i++)
                innov2[i]=0;
             for (i=0;i<st->subframeSize;i++)
                target[i]*=2.5;
             SUBMODE(innovation_quant)(target, st->interp_qlpc, st->bw_lpc1, st->bw_lpc2, 
                                       SUBMODE(innovation_params), st->lpcSize, st->subframeSize, 
-                                      innov2, syn_resp, bits, tmp_stack, (st->complexity+1)>>1);
+                                      innov2, syn_resp, bits, stack, (st->complexity+1)>>1, 0);
             for (i=0;i<st->subframeSize;i++)
-               innov2[i]*=scale*(1/2.5);
+               innov2[i]*=scale*(1/2.5)/SIG_SCALING;
             for (i=0;i<st->subframeSize;i++)
-               exc[i] += innov2[i];
+               exc[i] = ADD32(exc[i],innov2[i]);
+            stack = tmp_stack;
          }
 
       }
 
-         /*Keep the previous memory*/
-         for (i=0;i<st->lpcSize;i++)
-            mem[i]=st->mem_sp[i];
-         /* Final signal synthesis from excitation */
-         iir_mem2(exc, st->interp_qlpc, sp, st->subframeSize, st->lpcSize, st->mem_sp);
-         
-         /* Compute weighted signal again, from synthesized speech (not sure it's the right thing) */
-         filter_mem2(sp, st->bw_lpc1, st->bw_lpc2, sw, st->subframeSize, st->lpcSize, st->mem_sw);
+      /*Keep the previous memory*/
+      for (i=0;i<st->lpcSize;i++)
+         mem[i]=st->mem_sp[i];
+      /* Final signal synthesis from excitation */
+      iir_mem2(exc, st->interp_qlpc, sp, st->subframeSize, st->lpcSize, st->mem_sp);
+      
+      /* Compute weighted signal again, from synthesized speech (not sure it's the right thing) */
+      filter_mem2(sp, st->bw_lpc1, st->bw_lpc2, sw, st->subframeSize, st->lpcSize, st->mem_sw);
    }
 
 
-#ifndef RELEASE
-
+#ifdef RESYNTH
    /* Reconstruct the original */
    fir_mem_up(st->x0d, h0, st->y0, st->full_frame_size, QMF_ORDER, st->g0_mem, stack);
    fir_mem_up(st->high, h1, st->y1, st->full_frame_size, QMF_ORDER, st->g1_mem, stack);
 
    for (i=0;i<st->full_frame_size;i++)
-      in[i]=2*(st->y0[i]-st->y1[i]);
+      in[i]=SHR(st->y0[i]-st->y1[i], SIG_SHIFT-1);
 #endif
    for (i=0;i<st->lpcSize;i++)
       st->old_lsp[i] = st->lsp[i];
@@ -651,24 +830,32 @@
 
 
 
-void *sb_decoder_init(SpeexMode *m)
+void *sb_decoder_init(const SpeexMode *m)
 {
    SBDecState *st;
-   SpeexSBMode *mode;
-   st = (SBDecState*)speex_alloc(sizeof(SBDecState)+6000*sizeof(float));
+   const SpeexSBMode *mode;
+   st = (SBDecState*)speex_alloc(sizeof(SBDecState));
+   if (!st)
+      return NULL;
+#if defined(VAR_ARRAYS) || defined (USE_ALLOCA)
+   st->stack = NULL;
+#else
+   st->stack = (char*)speex_alloc_scratch(SB_DEC_STACK);
+#endif
    st->mode = m;
-   mode=(SpeexSBMode*)m->mode;
+   mode=(const SpeexSBMode*)m->mode;
 
-   st->stack = ((char*)st) + sizeof(SBDecState);
+   st->encode_submode = 1;
 
 
 
+
    st->st_low = speex_decoder_init(mode->nb_mode);
    st->full_frame_size = 2*mode->frameSize;
    st->frame_size = mode->frameSize;
    st->subframeSize = mode->subframeSize;
    st->nbSubframes = mode->frameSize/mode->subframeSize;
-   st->lpcSize=8;
+   st->lpcSize=mode->lpcSize;
    speex_decoder_ctl(st->st_low, SPEEX_GET_SAMPLING_RATE, &st->sampling_rate);
    st->sampling_rate*=2;
 
@@ -678,29 +865,30 @@
    st->first=1;
 
 
-   st->x0d=PUSH(st->stack, st->frame_size, float);
-   st->x1d=PUSH(st->stack, st->frame_size, float);
-   st->high=PUSH(st->stack, st->full_frame_size, float);
-   st->y0=PUSH(st->stack, st->full_frame_size, float);
-   st->y1=PUSH(st->stack, st->full_frame_size, float);
+   st->x0d=speex_alloc((st->frame_size)*sizeof(spx_sig_t));
+   st->x1d=speex_alloc((st->frame_size)*sizeof(spx_sig_t));
+   st->high=speex_alloc((st->full_frame_size)*sizeof(spx_sig_t));
+   st->y0=speex_alloc((st->full_frame_size)*sizeof(spx_sig_t));
+   st->y1=speex_alloc((st->full_frame_size)*sizeof(spx_sig_t));
 
-   st->h0_mem=PUSH(st->stack, QMF_ORDER, float);
-   st->h1_mem=PUSH(st->stack, QMF_ORDER, float);
-   st->g0_mem=PUSH(st->stack, QMF_ORDER, float);
-   st->g1_mem=PUSH(st->stack, QMF_ORDER, float);
+   st->g0_mem=speex_alloc((QMF_ORDER)*sizeof(spx_word32_t));
+   st->g1_mem=speex_alloc((QMF_ORDER)*sizeof(spx_word32_t));
 
-   st->exc=PUSH(st->stack, st->frame_size, float);
+   st->exc=speex_alloc((st->frame_size)*sizeof(spx_sig_t));
 
-   st->qlsp = PUSH(st->stack, st->lpcSize, float);
-   st->old_qlsp = PUSH(st->stack, st->lpcSize, float);
-   st->interp_qlsp = PUSH(st->stack, st->lpcSize, float);
-   st->interp_qlpc = PUSH(st->stack, st->lpcSize+1, float);
+   st->qlsp = speex_alloc((st->lpcSize)*sizeof(spx_lsp_t));
+   st->old_qlsp = speex_alloc((st->lpcSize)*sizeof(spx_lsp_t));
+   st->interp_qlsp = speex_alloc(st->lpcSize*sizeof(spx_lsp_t));
+   st->interp_qlpc = speex_alloc(st->lpcSize*sizeof(spx_coef_t));
 
-   st->pi_gain = PUSH(st->stack, st->nbSubframes, float);
-   st->mem_sp = PUSH(st->stack, 2*st->lpcSize, float);
+   st->pi_gain = speex_alloc((st->nbSubframes)*sizeof(spx_word32_t));
+   st->mem_sp = speex_alloc((2*st->lpcSize)*sizeof(spx_mem_t));
    
    st->lpc_enh_enabled=0;
 
+#ifdef ENABLE_VALGRIND
+   VALGRIND_MAKE_READABLE(st, (st->stack-(char*)st));
+#endif
    return st;
 }
 
@@ -709,14 +897,34 @@
    SBDecState *st;
    st = (SBDecState*)state;
    speex_decoder_destroy(st->st_low);
+#if !(defined(VAR_ARRAYS) || defined (USE_ALLOCA))
+   speex_free_scratch(st->stack);
+#endif
 
+   speex_free(st->x0d);
+   speex_free(st->x1d);
+   speex_free(st->high);
+   speex_free(st->y0);
+   speex_free(st->y1);
+   speex_free(st->g0_mem);
+   speex_free(st->g1_mem);
+   speex_free(st->exc);
+   speex_free(st->qlsp);
+   speex_free(st->old_qlsp);
+   speex_free(st->interp_qlsp);
+   speex_free(st->interp_qlpc);
+   speex_free(st->pi_gain);
+   speex_free(st->mem_sp);
+
    speex_free(state);
 }
 
-static void sb_decode_lost(SBDecState *st, float *out, int dtx, char *stack)
+static void sb_decode_lost(SBDecState *st, spx_word16_t *out, int dtx, char *stack)
 {
    int i;
-   float *awk1, *awk2, *awk3;
+   VARDECL(spx_coef_t *awk1);
+   VARDECL(spx_coef_t *awk2);
+   VARDECL(spx_coef_t *awk3);
    int saved_modeid=0;
 
    if (dtx)
@@ -724,34 +932,27 @@
       saved_modeid=st->submodeID;
       st->submodeID=1;
    } else {
-      bw_lpc(0.99, st->interp_qlpc, st->interp_qlpc, st->lpcSize);
+      bw_lpc(GAMMA_SCALING*0.99, st->interp_qlpc, st->interp_qlpc, st->lpcSize);
    }
 
    st->first=1;
    
-   awk1=PUSH(stack, st->lpcSize+1, float);
-   awk2=PUSH(stack, st->lpcSize+1, float);
-   awk3=PUSH(stack, st->lpcSize+1, float);
+   ALLOC(awk1, st->lpcSize+1, spx_coef_t);
+   ALLOC(awk2, st->lpcSize+1, spx_coef_t);
+   ALLOC(awk3, st->lpcSize+1, spx_coef_t);
    
    if (st->lpc_enh_enabled)
    {
-      float r=.9;
-      
-      float k1,k2,k3;
+      spx_word16_t k1,k2,k3;
       if (st->submodes[st->submodeID] != NULL)
       {
          k1=SUBMODE(lpc_enh_k1);
          k2=SUBMODE(lpc_enh_k2);
+         k3=SUBMODE(lpc_enh_k3);
       } else {
-         k1=k2=.7;
+         k1=k2=.7*GAMMA_SCALING;
+         k3 = 0;
       }
-      k3=(1-(1-r*k1)/(1-r*k2))/r;
-      k3=k1-k2;
-      if (!st->lpc_enh_enabled)
-      {
-         k1=k2;
-         k3=0;
-      }
       bw_lpc(k1, st->interp_qlpc, awk1, st->lpcSize);
       bw_lpc(k2, st->interp_qlpc, awk2, st->lpcSize);
       bw_lpc(k3, st->interp_qlpc, awk3, st->lpcSize);
@@ -790,9 +991,8 @@
    fir_mem_up(st->x0d, h0, st->y0, st->full_frame_size, QMF_ORDER, st->g0_mem, stack);
    fir_mem_up(st->high, h1, st->y1, st->full_frame_size, QMF_ORDER, st->g1_mem, stack);
 
-   for (i=0;i<st->full_frame_size;i++)
-      out[i]=2*(st->y0[i]-st->y1[i]);
-   
+   mix_and_saturate(st->y0, st->y1, out, st->full_frame_size);
+
    if (dtx)
    {
       st->submodeID=saved_modeid;
@@ -801,24 +1001,37 @@
    return;
 }
 
-int sb_decode(void *state, SpeexBits *bits, float *out)
+int sb_decode(void *state, SpeexBits *bits, void *vout)
 {
    int i, sub;
    SBDecState *st;
    int wideband;
    int ret;
    char *stack;
-   float *low_pi_gain, *low_exc, *low_innov;
-   float *awk1, *awk2, *awk3;
+   VARDECL(spx_word32_t *low_pi_gain);
+   VARDECL(spx_sig_t *low_exc);
+   VARDECL(spx_sig_t *low_innov);
+   VARDECL(spx_coef_t *awk1);
+   VARDECL(spx_coef_t *awk2);
+   VARDECL(spx_coef_t *awk3);
    int dtx;
-   SpeexSBMode *mode;
-
+   const SpeexSBMode *mode;
+   spx_word16_t *out = vout;
+   
    st = (SBDecState*)state;
    stack=st->stack;
-   mode = (SpeexSBMode*)(st->mode->mode);
+   mode = (const SpeexSBMode*)(st->mode->mode);
 
-   /* Decode the low-band */
-   ret = speex_decode(st->st_low, bits, st->x0d);
+   {
+      VARDECL(spx_word16_t *low);
+      ALLOC(low, st->frame_size, spx_word16_t);
+      
+      /* Decode the low-band */
+      ret = speex_decode_native(st->st_low, bits, low);
+      
+      for (i=0;i<st->frame_size;i++)
+         st->x0d[i] = SHL((spx_sig_t)low[i], SIG_SHIFT);
+   }
 
    speex_decoder_ctl(st->st_low, SPEEX_GET_DTX_STATUS, &dtx);
 
@@ -834,26 +1047,30 @@
       return 0;
    }
 
-   /*Check "wideband bit"*/
-   if (speex_bits_remaining(bits)>0)
-      wideband = speex_bits_peek(bits);
-   else
-      wideband = 0;
-   if (wideband)
+   if (st->encode_submode)
    {
-      /*Regular wideband frame, read the submode*/
-      wideband = speex_bits_unpack_unsigned(bits, 1);
-      st->submodeID = speex_bits_unpack_unsigned(bits, SB_SUBMODE_BITS);
-   } else
-   {
-      /*Was a narrowband frame, set "null submode"*/
-      st->submodeID = 0;
+
+      /*Check "wideband bit"*/
+      if (speex_bits_remaining(bits)>0)
+         wideband = speex_bits_peek(bits);
+      else
+         wideband = 0;
+      if (wideband)
+      {
+         /*Regular wideband frame, read the submode*/
+         wideband = speex_bits_unpack_unsigned(bits, 1);
+         st->submodeID = speex_bits_unpack_unsigned(bits, SB_SUBMODE_BITS);
+      } else
+      {
+         /*Was a narrowband frame, set "null submode"*/
+         st->submodeID = 0;
+      }
+      if (st->submodeID != 0 && st->submodes[st->submodeID] == NULL)
+      {
+         speex_warning("Invalid mode encountered: corrupted stream?");
+         return -2;
+      }
    }
-   if (st->submodeID != 0 && st->submodes[st->submodeID] == NULL)
-   {
-      speex_warning("Invalid mode encountered: corrupted stream?");
-      return -2;
-   }
 
    /* If null mode (no transmission), just set a couple things to zero*/
    if (st->submodes[st->submodeID] == NULL)
@@ -875,8 +1092,7 @@
       fir_mem_up(st->x0d, h0, st->y0, st->full_frame_size, QMF_ORDER, st->g0_mem, stack);
       fir_mem_up(st->high, h1, st->y1, st->full_frame_size, QMF_ORDER, st->g1_mem, stack);
 
-      for (i=0;i<st->full_frame_size;i++)
-         out[i]=2*(st->y0[i]-st->y1[i]);
+      mix_and_saturate(st->y0, st->y1, out, st->full_frame_size);
 
       return 0;
 
@@ -885,9 +1101,9 @@
    for (i=0;i<st->frame_size;i++)
       st->exc[i]=0;
 
-   low_pi_gain = PUSH(stack, st->nbSubframes, float);
-   low_exc = PUSH(stack, st->frame_size, float);
-   low_innov = PUSH(stack, st->frame_size, float);
+   ALLOC(low_pi_gain, st->nbSubframes, spx_word32_t);
+   ALLOC(low_exc, st->frame_size, spx_sig_t);
+   ALLOC(low_innov, st->frame_size, spx_sig_t);
    speex_decoder_ctl(st->st_low, SPEEX_GET_PI_GAIN, low_pi_gain);
    speex_decoder_ctl(st->st_low, SPEEX_GET_EXC, low_exc);
    speex_decoder_ctl(st->st_low, SPEEX_GET_INNOV, low_innov);
@@ -900,49 +1116,37 @@
          st->old_qlsp[i] = st->qlsp[i];
    }
    
-   awk1=PUSH(stack, st->lpcSize+1, float);
-   awk2=PUSH(stack, st->lpcSize+1, float);
-   awk3=PUSH(stack, st->lpcSize+1, float);
+   ALLOC(awk1, st->lpcSize+1, spx_coef_t);
+   ALLOC(awk2, st->lpcSize+1, spx_coef_t);
+   ALLOC(awk3, st->lpcSize+1, spx_coef_t);
 
    for (sub=0;sub<st->nbSubframes;sub++)
    {
-      float *exc, *sp, tmp, filter_ratio, el=0;
+      spx_sig_t *exc, *sp;
+      spx_word16_t filter_ratio;
+      spx_word16_t el=0;
       int offset;
-      float rl=0,rh=0;
+      spx_word32_t rl=0,rh=0;
       
       offset = st->subframeSize*sub;
       sp=st->high+offset;
       exc=st->exc+offset;
       
       /* LSP interpolation */
-      tmp = (1.0 + sub)/st->nbSubframes;
-      for (i=0;i<st->lpcSize;i++)
-         st->interp_qlsp[i] = (1-tmp)*st->old_qlsp[i] + tmp*st->qlsp[i];
+      lsp_interpolate(st->old_qlsp, st->qlsp, st->interp_qlsp, st->lpcSize, sub, st->nbSubframes);
 
-      lsp_enforce_margin(st->interp_qlsp, st->lpcSize, .05);
+      lsp_enforce_margin(st->interp_qlsp, st->lpcSize, LSP_MARGIN);
 
-      /* LSPs to x-domain */
-      for (i=0;i<st->lpcSize;i++)
-         st->interp_qlsp[i] = cos(st->interp_qlsp[i]);
-
       /* LSP to LPC */
       lsp_to_lpc(st->interp_qlsp, st->interp_qlpc, st->lpcSize, stack);
 
 
       if (st->lpc_enh_enabled)
       {
-         float r=.9;
-         
-         float k1,k2,k3;
+         spx_word16_t k1,k2,k3;
          k1=SUBMODE(lpc_enh_k1);
          k2=SUBMODE(lpc_enh_k2);
-         k3=(1-(1-r*k1)/(1-r*k2))/r;
-         k3=k1-k2;
-         if (!st->lpc_enh_enabled)
-         {
-            k1=k2;
-            k3=0;
-         }
+         k3=SUBMODE(lpc_enh_k3);
          bw_lpc(k1, st->interp_qlpc, awk1, st->lpcSize);
          bw_lpc(k2, st->interp_qlpc, awk2, st->lpcSize);
          bw_lpc(k3, st->interp_qlpc, awk3, st->lpcSize);
@@ -953,20 +1157,21 @@
       /* Calculate reponse ratio between the low and high filter in the middle
          of the band (4000 Hz) */
       
-         tmp=1;
-         st->pi_gain[sub]=0;
-         for (i=0;i<=st->lpcSize;i++)
+         st->pi_gain[sub]=LPC_SCALING;
+         rh = LPC_SCALING;
+         for (i=0;i<st->lpcSize;i+=2)
          {
-            rh += tmp*st->interp_qlpc[i];
-            tmp = -tmp;
-            st->pi_gain[sub]+=st->interp_qlpc[i];
+            rh += st->interp_qlpc[i+1] - st->interp_qlpc[i];
+            st->pi_gain[sub] += st->interp_qlpc[i] + st->interp_qlpc[i+1];
          }
+
          rl = low_pi_gain[sub];
-         rl=1/(fabs(rl)+.01);
-         rh=1/(fabs(rh)+.01);
-         filter_ratio=fabs(.01+rh)/(.01+fabs(rl));
+#ifdef FIXED_POINT
+         filter_ratio=DIV32_16(SHL(rl+82,2),SHR(82+rh,5));
+#else
+         filter_ratio=(rl+.01)/(rh+.01);
+#endif
       
-      
       for (i=0;i<st->subframeSize;i++)
          exc[i]=0;
       if (!SUBMODE(innovation_unquant))
@@ -974,46 +1179,54 @@
          float g;
          int quant;
 
-         for (i=0;i<st->subframeSize;i++)
-            el+=sqr(low_innov[offset+i]);
          quant = speex_bits_unpack_unsigned(bits, 5);
          g= exp(((float)quant-10)/8.0);
          
-         /*printf ("unquant folding gain: %f\n", g);*/
+#ifdef FIXED_POINT
+         g /= filter_ratio/128.;
+#else
          g /= filter_ratio;
-         
+#endif
          /* High-band excitation using the low-band excitation and a gain */
          for (i=0;i<st->subframeSize;i++)
             exc[i]=mode->folding_gain*g*low_innov[offset+i];
          /*speex_rand_vec(mode->folding_gain*g*sqrt(el/st->subframeSize), exc, st->subframeSize);*/
       } else {
-         float gc, scale;
+         spx_word16_t gc;
+         spx_word32_t scale;
          int qgc = speex_bits_unpack_unsigned(bits, 4);
-         for (i=0;i<st->subframeSize;i++)
-            el+=sqr(low_exc[offset+i]);
 
+         el = compute_rms(low_exc+offset, st->subframeSize);
 
-         gc = exp((1/3.7)*qgc-2);
+#ifdef FIXED_POINT
+         gc = MULT16_32_Q15(28626,gc_quant_bound[qgc]);
+#else
+         gc = exp((1/3.7)*qgc-0.15556);
+#endif
 
-         scale = gc*sqrt(1+el)/filter_ratio;
+         if (st->subframeSize==80)
+            gc *= 1.4142;
 
+         scale = SHL(MULT16_16(DIV32_16(SHL(gc,SIG_SHIFT-4),filter_ratio),(1+el)),4);
 
          SUBMODE(innovation_unquant)(exc, SUBMODE(innovation_params), st->subframeSize, 
                                 bits, stack);
-         for (i=0;i<st->subframeSize;i++)
-            exc[i]*=scale;
 
+         signal_mul(exc,exc,scale,st->subframeSize);
+
          if (SUBMODE(double_codebook)) {
             char *tmp_stack=stack;
-            float *innov2 = PUSH(tmp_stack, st->subframeSize, float);
+            VARDECL(spx_sig_t *innov2);
+            ALLOC(innov2, st->subframeSize, spx_sig_t);
             for (i=0;i<st->subframeSize;i++)
                innov2[i]=0;
             SUBMODE(innovation_unquant)(innov2, SUBMODE(innovation_params), st->subframeSize, 
-                                bits, tmp_stack);
+                                bits, stack);
             for (i=0;i<st->subframeSize;i++)
-               innov2[i]*=scale*(1/2.5);
+               innov2[i]*=scale/(float)SIG_SCALING*(1/2.5);
             for (i=0;i<st->subframeSize;i++)
-               exc[i] += innov2[i];
+               exc[i] = ADD32(exc[i],innov2[i]);
+            stack = tmp_stack;
          }
 
       }
@@ -1041,8 +1254,7 @@
    fir_mem_up(st->x0d, h0, st->y0, st->full_frame_size, QMF_ORDER, st->g0_mem, stack);
    fir_mem_up(st->high, h1, st->y1, st->full_frame_size, QMF_ORDER, st->g1_mem, stack);
 
-   for (i=0;i<st->full_frame_size;i++)
-      out[i]=2*(st->y0[i]-st->y1[i]);
+   mix_and_saturate(st->y0, st->y1, out, st->full_frame_size);
 
    for (i=0;i<st->lpcSize;i++)
       st->old_qlsp[i] = st->qlsp[i];
@@ -1108,6 +1320,9 @@
          speex_encoder_ctl(state, SPEEX_SET_QUALITY, &q);
          break;
       }
+   case SPEEX_GET_VBR_QUALITY:
+      (*(float*)ptr) = st->vbr_quality;
+      break;
    case SPEEX_SET_ABR:
       st->abr_enabled = (*(int*)ptr);
       st->vbr_enabled = 1;
@@ -1145,8 +1360,8 @@
             quality = 0;
          if (quality > 10)
             quality = 10;
-         st->submodeSelect = st->submodeID = ((SpeexSBMode*)(st->mode->mode))->quality_map[quality];
-         nb_qual = ((SpeexSBMode*)(st->mode->mode))->low_quality_map[quality];
+         st->submodeSelect = st->submodeID = ((const SpeexSBMode*)(st->mode->mode))->quality_map[quality];
+         nb_qual = ((const SpeexSBMode*)(st->mode->mode))->low_quality_map[quality];
          speex_encoder_ctl(st->st_low, SPEEX_SET_MODE, &nb_qual);
       }
       break;
@@ -1207,6 +1422,13 @@
             st->h0_mem[i]=st->h1_mem[i]=st->g0_mem[i]=st->g1_mem[i]=0;
       }
       break;
+   case SPEEX_SET_SUBMODE_ENCODING:
+      st->encode_submode = (*(int*)ptr);
+      speex_encoder_ctl(st->st_low, SPEEX_SET_SUBMODE_ENCODING, &ptr);
+      break;
+   case SPEEX_GET_SUBMODE_ENCODING:
+      (*(int*)ptr) = st->encode_submode;
+      break;
    case SPEEX_GET_LOOKAHEAD:
       speex_encoder_ctl(st->st_low, SPEEX_GET_LOOKAHEAD, ptr);
       (*(int*)ptr) = 2*(*(int*)ptr) + QMF_ORDER - 1;
@@ -1214,7 +1436,7 @@
    case SPEEX_GET_PI_GAIN:
       {
          int i;
-         float *g = (float*)ptr;
+         spx_word32_t *g = (spx_word32_t*)ptr;
          for (i=0;i<st->nbSubframes;i++)
             g[i]=st->pi_gain[i];
       }
@@ -1222,7 +1444,7 @@
    case SPEEX_GET_EXC:
       {
          int i;
-         float *e = (float*)ptr;
+         spx_sig_t *e = (spx_sig_t*)ptr;
          for (i=0;i<st->full_frame_size;i++)
             e[i]=0;
          for (i=0;i<st->frame_size;i++)
@@ -1232,7 +1454,7 @@
    case SPEEX_GET_INNOV:
       {
          int i;
-         float *e = (float*)ptr;
+         spx_sig_t *e = (spx_sig_t*)ptr;
          for (i=0;i<st->full_frame_size;i++)
             e[i]=0;
          for (i=0;i<st->frame_size;i++)
@@ -1255,6 +1477,12 @@
    st=(SBDecState*)state;
    switch(request)
    {
+   case SPEEX_SET_HIGH_MODE:
+      st->submodeID = (*(int*)ptr);
+      break;
+   case SPEEX_SET_LOW_MODE:
+      speex_decoder_ctl(st->st_low, SPEEX_SET_LOW_MODE, ptr);
+      break;
    case SPEEX_GET_LOW_MODE:
       speex_decoder_ctl(st->st_low, SPEEX_GET_LOW_MODE, ptr);
       break;
@@ -1265,6 +1493,23 @@
       speex_decoder_ctl(st->st_low, request, ptr);
       st->lpc_enh_enabled = *((int*)ptr);
       break;
+   case SPEEX_GET_ENH:
+      *((int*)ptr) = st->lpc_enh_enabled;
+      break;
+   case SPEEX_SET_MODE:
+   case SPEEX_SET_QUALITY:
+      {
+         int nb_qual;
+         int quality = (*(int*)ptr);
+         if (quality < 0)
+            quality = 0;
+         if (quality > 10)
+            quality = 10;
+         st->submodeID = ((const SpeexSBMode*)(st->mode->mode))->quality_map[quality];
+         nb_qual = ((const SpeexSBMode*)(st->mode->mode))->low_quality_map[quality];
+         speex_decoder_ctl(st->st_low, SPEEX_SET_MODE, &nb_qual);
+      }
+      break;
    case SPEEX_GET_BITRATE:
       speex_decoder_ctl(st->st_low, request, ptr);
       if (st->submodes[st->submodeID])
@@ -1295,13 +1540,20 @@
          for (i=0;i<2*st->lpcSize;i++)
             st->mem_sp[i]=0;
          for (i=0;i<QMF_ORDER;i++)
-            st->h0_mem[i]=st->h1_mem[i]=st->g0_mem[i]=st->g1_mem[i]=0;
+            st->g0_mem[i]=st->g1_mem[i]=0;
       }
       break;
+   case SPEEX_SET_SUBMODE_ENCODING:
+      st->encode_submode = (*(int*)ptr);
+      speex_decoder_ctl(st->st_low, SPEEX_SET_SUBMODE_ENCODING, &ptr);
+      break;
+   case SPEEX_GET_SUBMODE_ENCODING:
+      (*(int*)ptr) = st->encode_submode;
+      break;
    case SPEEX_GET_PI_GAIN:
       {
          int i;
-         float *g = (float*)ptr;
+         spx_word32_t *g = (spx_word32_t*)ptr;
          for (i=0;i<st->nbSubframes;i++)
             g[i]=st->pi_gain[i];
       }
@@ -1309,7 +1561,7 @@
    case SPEEX_GET_EXC:
       {
          int i;
-         float *e = (float*)ptr;
+         spx_sig_t *e = (spx_sig_t*)ptr;
          for (i=0;i<st->full_frame_size;i++)
             e[i]=0;
          for (i=0;i<st->frame_size;i++)
@@ -1319,7 +1571,7 @@
    case SPEEX_GET_INNOV:
       {
          int i;
-         float *e = (float*)ptr;
+         spx_sig_t *e = (spx_sig_t*)ptr;
          for (i=0;i<st->full_frame_size;i++)
             e[i]=0;
          for (i=0;i<st->frame_size;i++)
@@ -1335,3 +1587,6 @@
    }
    return 0;
 }
+
+#endif
+

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/sb_celp.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/sb_celp.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/sb_celp.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -42,7 +42,7 @@
 
 /**Structure representing the full state of the sub-band encoder*/
 typedef struct SBEncState {
-   SpeexMode *mode;            /**< Pointer to the mode (containing for vtable info) */
+   const SpeexMode *mode;            /**< Pointer to the mode (containing for vtable info) */
    void *st_low;               /**< State of the low-band (narrowband) encoder */
    int    full_frame_size;     /**< Length of full-band frames*/
    int    frame_size;          /**< Length of high-band frames*/
@@ -54,41 +54,41 @@
    int    first;               /**< First frame? */
    float  lag_factor;          /**< Lag-windowing control parameter */
    float  lpc_floor;           /**< Controls LPC analysis noise floor */
-   float  gamma1;              /**< Perceptual weighting coef 1 */
-   float  gamma2;              /**< Perceptual weighting coef 2 */
+   spx_word16_t  gamma1;              /**< Perceptual weighting coef 1 */
+   spx_word16_t  gamma2;              /**< Perceptual weighting coef 2 */
 
    char  *stack;               /**< Temporary allocation stack */
-   float *x0d, *x1d; /**< QMF filter signals*/
-   float *high;                /**< High-band signal (buffer) */
-   float *y0, *y1;             /**< QMF synthesis signals */
-   float *h0_mem, *h1_mem, *g0_mem, *g1_mem; /**< QMF memories */
+   spx_sig_t *x0d, *x1d; /**< QMF filter signals*/
+   spx_sig_t *high;                /**< High-band signal (buffer) */
+   spx_sig_t *y0, *y1;             /**< QMF synthesis signals */
+   spx_word16_t *h0_mem, *h1_mem;
+   spx_word32_t *g0_mem, *g1_mem; /**< QMF memories */
 
-   float *excBuf;              /**< High-band excitation */
-   float *exc;                 /**< High-band excitation (for QMF only)*/
-   float *buf;                 /**< Temporary buffer */
-   float *res;                 /**< Zero-input response (ringing) */
-   float *sw;                  /**< Perceptually weighted signal */
-   float *target;              /**< Weighted target signal (analysis by synthesis) */
-   float *window;              /**< LPC analysis window */
-   float *lagWindow;           /**< Auto-correlation window */
-   float *autocorr;            /**< Auto-correlation (for LPC analysis) */
-   float *rc;                  /**< Reflection coefficients (unused) */
-   float *lpc;                 /**< LPC coefficients */
-   float *lsp;                 /**< LSP coefficients */
-   float *qlsp;                /**< Quantized LSPs */
-   float *old_lsp;             /**< LSPs of previous frame */
-   float *old_qlsp;            /**< Quantized LSPs of previous frame */
-   float *interp_lsp;          /**< Interpolated LSPs for current sub-frame */
-   float *interp_qlsp;         /**< Interpolated quantized LSPs for current sub-frame */
-   float *interp_lpc;          /**< Interpolated LPCs for current sub-frame */
-   float *interp_qlpc;         /**< Interpolated quantized LPCs for current sub-frame */
-   float *bw_lpc1;             /**< Bandwidth-expanded version of LPCs (#1) */
-   float *bw_lpc2;             /**< Bandwidth-expanded version of LPCs (#2) */
+   spx_sig_t *excBuf;              /**< High-band excitation */
+   spx_sig_t *exc;                 /**< High-band excitation (for QMF only)*/
+   spx_sig_t *buf;                 /**< Temporary buffer */
+   spx_sig_t *res;                 /**< Zero-input response (ringing) */
+   spx_sig_t *sw;                  /**< Perceptually weighted signal */
+   spx_sig_t *target;              /**< Weighted target signal (analysis by synthesis) */
+   spx_word16_t *window;              /**< LPC analysis window */
+   spx_word16_t *lagWindow;           /**< Auto-correlation window */
+   spx_word16_t *autocorr;            /**< Auto-correlation (for LPC analysis) */
+   spx_coef_t *lpc;                 /**< LPC coefficients */
+   spx_lsp_t *lsp;                 /**< LSP coefficients */
+   spx_lsp_t *qlsp;                /**< Quantized LSPs */
+   spx_lsp_t *old_lsp;             /**< LSPs of previous frame */
+   spx_lsp_t *old_qlsp;            /**< Quantized LSPs of previous frame */
+   spx_lsp_t *interp_lsp;          /**< Interpolated LSPs for current sub-frame */
+   spx_lsp_t *interp_qlsp;         /**< Interpolated quantized LSPs for current sub-frame */
+   spx_coef_t *interp_lpc;          /**< Interpolated LPCs for current sub-frame */
+   spx_coef_t *interp_qlpc;         /**< Interpolated quantized LPCs for current sub-frame */
+   spx_coef_t *bw_lpc1;             /**< Bandwidth-expanded version of LPCs (#1) */
+   spx_coef_t *bw_lpc2;             /**< Bandwidth-expanded version of LPCs (#2) */
 
-   float *mem_sp;              /**< Synthesis signal memory */
-   float *mem_sp2;
-   float *mem_sw;              /**< Perceptual signal memory */
-   float *pi_gain;
+   spx_mem_t *mem_sp;              /**< Synthesis signal memory */
+   spx_mem_t *mem_sp2;
+   spx_mem_t *mem_sw;              /**< Perceptual signal memory */
+   spx_word32_t *pi_gain;
 
    float  vbr_quality;         /**< Quality setting for VBR encoding */
    int    vbr_enabled;         /**< 1 for enabling VBR, 0 otherwise */
@@ -99,7 +99,8 @@
    int    vad_enabled;         /**< 1 for enabling VAD, 0 otherwise */
    float  relative_quality;
 
-   SpeexSubmode **submodes;
+   int    encode_submode;
+   const SpeexSubmode * const *submodes;
    int    submodeID;
    int    submodeSelect;
    int    complexity;
@@ -110,7 +111,7 @@
 
 /**Structure representing the full state of the sub-band decoder*/
 typedef struct SBDecState {
-   SpeexMode *mode;            /**< Pointer to the mode (containing for vtable info) */
+   const SpeexMode *mode;            /**< Pointer to the mode (containing for vtable info) */
    void *st_low;               /**< State of the low-band (narrowband) encoder */
    int    full_frame_size;
    int    frame_size;
@@ -122,43 +123,44 @@
    int    lpc_enh_enabled;
 
    char  *stack;
-   float *x0d, *x1d;
-   float *high;
-   float *y0, *y1;
-   float *h0_mem, *h1_mem, *g0_mem, *g1_mem;
+   spx_sig_t *x0d, *x1d;
+   spx_sig_t *high;
+   spx_sig_t *y0, *y1;
+   spx_word32_t *g0_mem, *g1_mem;
 
-   float *exc;
-   float *qlsp;
-   float *old_qlsp;
-   float *interp_qlsp;
-   float *interp_qlpc;
+   spx_sig_t *exc;
+   spx_lsp_t *qlsp;
+   spx_lsp_t *old_qlsp;
+   spx_lsp_t *interp_qlsp;
+   spx_coef_t *interp_qlpc;
 
-   float *mem_sp;
-   float *pi_gain;
+   spx_mem_t *mem_sp;
+   spx_word32_t *pi_gain;
 
-   SpeexSubmode **submodes;
+   int    encode_submode;
+   const SpeexSubmode * const *submodes;
    int    submodeID;
 } SBDecState;
 
 
 /**Initializes encoder state*/
-void *sb_encoder_init(SpeexMode *m);
+void *sb_encoder_init(const SpeexMode *m);
 
 /**De-allocates encoder state resources*/
 void sb_encoder_destroy(void *state);
 
 /**Encodes one frame*/
-int sb_encode(void *state, float *in, SpeexBits *bits);
+int sb_encode(void *state, void *in, SpeexBits *bits);
 
 
 /**Initializes decoder state*/
-void *sb_decoder_init(SpeexMode *m);
+void *sb_decoder_init(const SpeexMode *m);
 
 /**De-allocates decoder state resources*/
 void sb_decoder_destroy(void *state);
 
 /**Decodes one frame*/
-int sb_decode(void *state, SpeexBits *bits, float *out);
+int sb_decode(void *state, SpeexBits *bits, void *out);
 
 int sb_encoder_ctl(void *state, int request, void *ptr);
 

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/smallft.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/smallft.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/smallft.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,1260 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001             *
+ * by the XIPHOPHORUS Company http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+ function: *unnormalized* fft transform
+ last mod: $Id: smallft.c,v 1.19 2003/10/08 05:12:37 jm Exp $
+
+ ********************************************************************/
+
+/* FFT implementation from OggSquish, minus cosine transforms,
+ * minus all but radix 2/4 case.  In Vorbis we only need this
+ * cut-down version.
+ *
+ * To do more than just power-of-two sized vectors, see the full
+ * version I wrote for NetLib.
+ *
+ * Note that the packing is a little strange; rather than the FFT r/i
+ * packing following R_0, I_n, R_1, I_1, R_2, I_2 ... R_n-1, I_n-1,
+ * it follows R_0, R_1, I_1, R_2, I_2 ... R_n-1, I_n-1, I_n like the
+ * FORTRAN version
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <math.h>
+#include "smallft.h"
+#include "misc.h"
+
+static void drfti1(int n, float *wa, int *ifac){
+  static int ntryh[4] = { 4,2,3,5 };
+  static float tpi = 6.28318530717958648f;
+  float arg,argh,argld,fi;
+  int ntry=0,i,j=-1;
+  int k1, l1, l2, ib;
+  int ld, ii, ip, is, nq, nr;
+  int ido, ipm, nfm1;
+  int nl=n;
+  int nf=0;
+
+ L101:
+  j++;
+  if (j < 4)
+    ntry=ntryh[j];
+  else
+    ntry+=2;
+
+ L104:
+  nq=nl/ntry;
+  nr=nl-ntry*nq;
+  if (nr!=0) goto L101;
+
+  nf++;
+  ifac[nf+1]=ntry;
+  nl=nq;
+  if(ntry!=2)goto L107;
+  if(nf==1)goto L107;
+
+  for (i=1;i<nf;i++){
+    ib=nf-i+1;
+    ifac[ib+1]=ifac[ib];
+  }
+  ifac[2] = 2;
+
+ L107:
+  if(nl!=1)goto L104;
+  ifac[0]=n;
+  ifac[1]=nf;
+  argh=tpi/n;
+  is=0;
+  nfm1=nf-1;
+  l1=1;
+
+  if(nfm1==0)return;
+
+  for (k1=0;k1<nfm1;k1++){
+    ip=ifac[k1+2];
+    ld=0;
+    l2=l1*ip;
+    ido=n/l2;
+    ipm=ip-1;
+
+    for (j=0;j<ipm;j++){
+      ld+=l1;
+      i=is;
+      argld=(float)ld*argh;
+      fi=0.f;
+      for (ii=2;ii<ido;ii+=2){
+	fi+=1.f;
+	arg=fi*argld;
+	wa[i++]=cos(arg);
+	wa[i++]=sin(arg);
+      }
+      is+=ido;
+    }
+    l1=l2;
+  }
+}
+
+static void fdrffti(int n, float *wsave, int *ifac){
+
+  if (n == 1) return;
+  drfti1(n, wsave+n, ifac);
+}
+
+static void dradf2(int ido,int l1,float *cc,float *ch,float *wa1){
+  int i,k;
+  float ti2,tr2;
+  int t0,t1,t2,t3,t4,t5,t6;
+
+  t1=0;
+  t0=(t2=l1*ido);
+  t3=ido<<1;
+  for(k=0;k<l1;k++){
+    ch[t1<<1]=cc[t1]+cc[t2];
+    ch[(t1<<1)+t3-1]=cc[t1]-cc[t2];
+    t1+=ido;
+    t2+=ido;
+  }
+    
+  if(ido<2)return;
+  if(ido==2)goto L105;
+
+  t1=0;
+  t2=t0;
+  for(k=0;k<l1;k++){
+    t3=t2;
+    t4=(t1<<1)+(ido<<1);
+    t5=t1;
+    t6=t1+t1;
+    for(i=2;i<ido;i+=2){
+      t3+=2;
+      t4-=2;
+      t5+=2;
+      t6+=2;
+      tr2=wa1[i-2]*cc[t3-1]+wa1[i-1]*cc[t3];
+      ti2=wa1[i-2]*cc[t3]-wa1[i-1]*cc[t3-1];
+      ch[t6]=cc[t5]+ti2;
+      ch[t4]=ti2-cc[t5];
+      ch[t6-1]=cc[t5-1]+tr2;
+      ch[t4-1]=cc[t5-1]-tr2;
+    }
+    t1+=ido;
+    t2+=ido;
+  }
+
+  if(ido%2==1)return;
+
+ L105:
+  t3=(t2=(t1=ido)-1);
+  t2+=t0;
+  for(k=0;k<l1;k++){
+    ch[t1]=-cc[t2];
+    ch[t1-1]=cc[t3];
+    t1+=ido<<1;
+    t2+=ido;
+    t3+=ido;
+  }
+}
+
+static void dradf4(int ido,int l1,float *cc,float *ch,float *wa1,
+	    float *wa2,float *wa3){
+  static float hsqt2 = .70710678118654752f;
+  int i,k,t0,t1,t2,t3,t4,t5,t6;
+  float ci2,ci3,ci4,cr2,cr3,cr4,ti1,ti2,ti3,ti4,tr1,tr2,tr3,tr4;
+  t0=l1*ido;
+  
+  t1=t0;
+  t4=t1<<1;
+  t2=t1+(t1<<1);
+  t3=0;
+
+  for(k=0;k<l1;k++){
+    tr1=cc[t1]+cc[t2];
+    tr2=cc[t3]+cc[t4];
+
+    ch[t5=t3<<2]=tr1+tr2;
+    ch[(ido<<2)+t5-1]=tr2-tr1;
+    ch[(t5+=(ido<<1))-1]=cc[t3]-cc[t4];
+    ch[t5]=cc[t2]-cc[t1];
+
+    t1+=ido;
+    t2+=ido;
+    t3+=ido;
+    t4+=ido;
+  }
+
+  if(ido<2)return;
+  if(ido==2)goto L105;
+
+
+  t1=0;
+  for(k=0;k<l1;k++){
+    t2=t1;
+    t4=t1<<2;
+    t5=(t6=ido<<1)+t4;
+    for(i=2;i<ido;i+=2){
+      t3=(t2+=2);
+      t4+=2;
+      t5-=2;
+
+      t3+=t0;
+      cr2=wa1[i-2]*cc[t3-1]+wa1[i-1]*cc[t3];
+      ci2=wa1[i-2]*cc[t3]-wa1[i-1]*cc[t3-1];
+      t3+=t0;
+      cr3=wa2[i-2]*cc[t3-1]+wa2[i-1]*cc[t3];
+      ci3=wa2[i-2]*cc[t3]-wa2[i-1]*cc[t3-1];
+      t3+=t0;
+      cr4=wa3[i-2]*cc[t3-1]+wa3[i-1]*cc[t3];
+      ci4=wa3[i-2]*cc[t3]-wa3[i-1]*cc[t3-1];
+
+      tr1=cr2+cr4;
+      tr4=cr4-cr2;
+      ti1=ci2+ci4;
+      ti4=ci2-ci4;
+
+      ti2=cc[t2]+ci3;
+      ti3=cc[t2]-ci3;
+      tr2=cc[t2-1]+cr3;
+      tr3=cc[t2-1]-cr3;
+
+      ch[t4-1]=tr1+tr2;
+      ch[t4]=ti1+ti2;
+
+      ch[t5-1]=tr3-ti4;
+      ch[t5]=tr4-ti3;
+
+      ch[t4+t6-1]=ti4+tr3;
+      ch[t4+t6]=tr4+ti3;
+
+      ch[t5+t6-1]=tr2-tr1;
+      ch[t5+t6]=ti1-ti2;
+    }
+    t1+=ido;
+  }
+  if(ido&1)return;
+
+ L105:
+  
+  t2=(t1=t0+ido-1)+(t0<<1);
+  t3=ido<<2;
+  t4=ido;
+  t5=ido<<1;
+  t6=ido;
+
+  for(k=0;k<l1;k++){
+    ti1=-hsqt2*(cc[t1]+cc[t2]);
+    tr1=hsqt2*(cc[t1]-cc[t2]);
+
+    ch[t4-1]=tr1+cc[t6-1];
+    ch[t4+t5-1]=cc[t6-1]-tr1;
+
+    ch[t4]=ti1-cc[t1+t0];
+    ch[t4+t5]=ti1+cc[t1+t0];
+
+    t1+=ido;
+    t2+=ido;
+    t4+=t3;
+    t6+=ido;
+  }
+}
+
+static void dradfg(int ido,int ip,int l1,int idl1,float *cc,float *c1,
+                          float *c2,float *ch,float *ch2,float *wa){
+
+  static float tpi=6.283185307179586f;
+  int idij,ipph,i,j,k,l,ic,ik,is;
+  int t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
+  float dc2,ai1,ai2,ar1,ar2,ds2;
+  int nbd;
+  float dcp,arg,dsp,ar1h,ar2h;
+  int idp2,ipp2;
+  
+  arg=tpi/(float)ip;
+  dcp=cos(arg);
+  dsp=sin(arg);
+  ipph=(ip+1)>>1;
+  ipp2=ip;
+  idp2=ido;
+  nbd=(ido-1)>>1;
+  t0=l1*ido;
+  t10=ip*ido;
+
+  if(ido==1)goto L119;
+  for(ik=0;ik<idl1;ik++)ch2[ik]=c2[ik];
+
+  t1=0;
+  for(j=1;j<ip;j++){
+    t1+=t0;
+    t2=t1;
+    for(k=0;k<l1;k++){
+      ch[t2]=c1[t2];
+      t2+=ido;
+    }
+  }
+
+  is=-ido;
+  t1=0;
+  if(nbd>l1){
+    for(j=1;j<ip;j++){
+      t1+=t0;
+      is+=ido;
+      t2= -ido+t1;
+      for(k=0;k<l1;k++){
+        idij=is-1;
+        t2+=ido;
+        t3=t2;
+        for(i=2;i<ido;i+=2){
+          idij+=2;
+          t3+=2;
+          ch[t3-1]=wa[idij-1]*c1[t3-1]+wa[idij]*c1[t3];
+          ch[t3]=wa[idij-1]*c1[t3]-wa[idij]*c1[t3-1];
+        }
+      }
+    }
+  }else{
+
+    for(j=1;j<ip;j++){
+      is+=ido;
+      idij=is-1;
+      t1+=t0;
+      t2=t1;
+      for(i=2;i<ido;i+=2){
+        idij+=2;
+        t2+=2;
+        t3=t2;
+        for(k=0;k<l1;k++){
+          ch[t3-1]=wa[idij-1]*c1[t3-1]+wa[idij]*c1[t3];
+          ch[t3]=wa[idij-1]*c1[t3]-wa[idij]*c1[t3-1];
+          t3+=ido;
+        }
+      }
+    }
+  }
+
+  t1=0;
+  t2=ipp2*t0;
+  if(nbd<l1){
+    for(j=1;j<ipph;j++){
+      t1+=t0;
+      t2-=t0;
+      t3=t1;
+      t4=t2;
+      for(i=2;i<ido;i+=2){
+        t3+=2;
+        t4+=2;
+        t5=t3-ido;
+        t6=t4-ido;
+        for(k=0;k<l1;k++){
+          t5+=ido;
+          t6+=ido;
+          c1[t5-1]=ch[t5-1]+ch[t6-1];
+          c1[t6-1]=ch[t5]-ch[t6];
+          c1[t5]=ch[t5]+ch[t6];
+          c1[t6]=ch[t6-1]-ch[t5-1];
+        }
+      }
+    }
+  }else{
+    for(j=1;j<ipph;j++){
+      t1+=t0;
+      t2-=t0;
+      t3=t1;
+      t4=t2;
+      for(k=0;k<l1;k++){
+        t5=t3;
+        t6=t4;
+        for(i=2;i<ido;i+=2){
+          t5+=2;
+          t6+=2;
+          c1[t5-1]=ch[t5-1]+ch[t6-1];
+          c1[t6-1]=ch[t5]-ch[t6];
+          c1[t5]=ch[t5]+ch[t6];
+          c1[t6]=ch[t6-1]-ch[t5-1];
+        }
+        t3+=ido;
+        t4+=ido;
+      }
+    }
+  }
+
+L119:
+  for(ik=0;ik<idl1;ik++)c2[ik]=ch2[ik];
+
+  t1=0;
+  t2=ipp2*idl1;
+  for(j=1;j<ipph;j++){
+    t1+=t0;
+    t2-=t0;
+    t3=t1-ido;
+    t4=t2-ido;
+    for(k=0;k<l1;k++){
+      t3+=ido;
+      t4+=ido;
+      c1[t3]=ch[t3]+ch[t4];
+      c1[t4]=ch[t4]-ch[t3];
+    }
+  }
+
+  ar1=1.f;
+  ai1=0.f;
+  t1=0;
+  t2=ipp2*idl1;
+  t3=(ip-1)*idl1;
+  for(l=1;l<ipph;l++){
+    t1+=idl1;
+    t2-=idl1;
+    ar1h=dcp*ar1-dsp*ai1;
+    ai1=dcp*ai1+dsp*ar1;
+    ar1=ar1h;
+    t4=t1;
+    t5=t2;
+    t6=t3;
+    t7=idl1;
+
+    for(ik=0;ik<idl1;ik++){
+      ch2[t4++]=c2[ik]+ar1*c2[t7++];
+      ch2[t5++]=ai1*c2[t6++];
+    }
+
+    dc2=ar1;
+    ds2=ai1;
+    ar2=ar1;
+    ai2=ai1;
+
+    t4=idl1;
+    t5=(ipp2-1)*idl1;
+    for(j=2;j<ipph;j++){
+      t4+=idl1;
+      t5-=idl1;
+
+      ar2h=dc2*ar2-ds2*ai2;
+      ai2=dc2*ai2+ds2*ar2;
+      ar2=ar2h;
+
+      t6=t1;
+      t7=t2;
+      t8=t4;
+      t9=t5;
+      for(ik=0;ik<idl1;ik++){
+        ch2[t6++]+=ar2*c2[t8++];
+        ch2[t7++]+=ai2*c2[t9++];
+      }
+    }
+  }
+
+  t1=0;
+  for(j=1;j<ipph;j++){
+    t1+=idl1;
+    t2=t1;
+    for(ik=0;ik<idl1;ik++)ch2[ik]+=c2[t2++];
+  }
+
+  if(ido<l1)goto L132;
+
+  t1=0;
+  t2=0;
+  for(k=0;k<l1;k++){
+    t3=t1;
+    t4=t2;
+    for(i=0;i<ido;i++)cc[t4++]=ch[t3++];
+    t1+=ido;
+    t2+=t10;
+  }
+
+  goto L135;
+
+ L132:
+  for(i=0;i<ido;i++){
+    t1=i;
+    t2=i;
+    for(k=0;k<l1;k++){
+      cc[t2]=ch[t1];
+      t1+=ido;
+      t2+=t10;
+    }
+  }
+
+ L135:
+  t1=0;
+  t2=ido<<1;
+  t3=0;
+  t4=ipp2*t0;
+  for(j=1;j<ipph;j++){
+
+    t1+=t2;
+    t3+=t0;
+    t4-=t0;
+
+    t5=t1;
+    t6=t3;
+    t7=t4;
+
+    for(k=0;k<l1;k++){
+      cc[t5-1]=ch[t6];
+      cc[t5]=ch[t7];
+      t5+=t10;
+      t6+=ido;
+      t7+=ido;
+    }
+  }
+
+  if(ido==1)return;
+  if(nbd<l1)goto L141;
+
+  t1=-ido;
+  t3=0;
+  t4=0;
+  t5=ipp2*t0;
+  for(j=1;j<ipph;j++){
+    t1+=t2;
+    t3+=t2;
+    t4+=t0;
+    t5-=t0;
+    t6=t1;
+    t7=t3;
+    t8=t4;
+    t9=t5;
+    for(k=0;k<l1;k++){
+      for(i=2;i<ido;i+=2){
+        ic=idp2-i;
+        cc[i+t7-1]=ch[i+t8-1]+ch[i+t9-1];
+        cc[ic+t6-1]=ch[i+t8-1]-ch[i+t9-1];
+        cc[i+t7]=ch[i+t8]+ch[i+t9];
+        cc[ic+t6]=ch[i+t9]-ch[i+t8];
+      }
+      t6+=t10;
+      t7+=t10;
+      t8+=ido;
+      t9+=ido;
+    }
+  }
+  return;
+
+ L141:
+
+  t1=-ido;
+  t3=0;
+  t4=0;
+  t5=ipp2*t0;
+  for(j=1;j<ipph;j++){
+    t1+=t2;
+    t3+=t2;
+    t4+=t0;
+    t5-=t0;
+    for(i=2;i<ido;i+=2){
+      t6=idp2+t1-i;
+      t7=i+t3;
+      t8=i+t4;
+      t9=i+t5;
+      for(k=0;k<l1;k++){
+        cc[t7-1]=ch[t8-1]+ch[t9-1];
+        cc[t6-1]=ch[t8-1]-ch[t9-1];
+        cc[t7]=ch[t8]+ch[t9];
+        cc[t6]=ch[t9]-ch[t8];
+        t6+=t10;
+        t7+=t10;
+        t8+=ido;
+        t9+=ido;
+      }
+    }
+  }
+}
+
+static void drftf1(int n,float *c,float *ch,float *wa,int *ifac){
+  int i,k1,l1,l2;
+  int na,kh,nf;
+  int ip,iw,ido,idl1,ix2,ix3;
+
+  nf=ifac[1];
+  na=1;
+  l2=n;
+  iw=n;
+
+  for(k1=0;k1<nf;k1++){
+    kh=nf-k1;
+    ip=ifac[kh+1];
+    l1=l2/ip;
+    ido=n/l2;
+    idl1=ido*l1;
+    iw-=(ip-1)*ido;
+    na=1-na;
+
+    if(ip!=4)goto L102;
+
+    ix2=iw+ido;
+    ix3=ix2+ido;
+    if(na!=0)
+      dradf4(ido,l1,ch,c,wa+iw-1,wa+ix2-1,wa+ix3-1);
+    else
+      dradf4(ido,l1,c,ch,wa+iw-1,wa+ix2-1,wa+ix3-1);
+    goto L110;
+
+ L102:
+    if(ip!=2)goto L104;
+    if(na!=0)goto L103;
+
+    dradf2(ido,l1,c,ch,wa+iw-1);
+    goto L110;
+
+  L103:
+    dradf2(ido,l1,ch,c,wa+iw-1);
+    goto L110;
+
+  L104:
+    if(ido==1)na=1-na;
+    if(na!=0)goto L109;
+
+    dradfg(ido,ip,l1,idl1,c,c,c,ch,ch,wa+iw-1);
+    na=1;
+    goto L110;
+
+  L109:
+    dradfg(ido,ip,l1,idl1,ch,ch,ch,c,c,wa+iw-1);
+    na=0;
+
+  L110:
+    l2=l1;
+  }
+
+  if(na==1)return;
+
+  for(i=0;i<n;i++)c[i]=ch[i];
+}
+
+static void dradb2(int ido,int l1,float *cc,float *ch,float *wa1){
+  int i,k,t0,t1,t2,t3,t4,t5,t6;
+  float ti2,tr2;
+
+  t0=l1*ido;
+  
+  t1=0;
+  t2=0;
+  t3=(ido<<1)-1;
+  for(k=0;k<l1;k++){
+    ch[t1]=cc[t2]+cc[t3+t2];
+    ch[t1+t0]=cc[t2]-cc[t3+t2];
+    t2=(t1+=ido)<<1;
+  }
+
+  if(ido<2)return;
+  if(ido==2)goto L105;
+
+  t1=0;
+  t2=0;
+  for(k=0;k<l1;k++){
+    t3=t1;
+    t5=(t4=t2)+(ido<<1);
+    t6=t0+t1;
+    for(i=2;i<ido;i+=2){
+      t3+=2;
+      t4+=2;
+      t5-=2;
+      t6+=2;
+      ch[t3-1]=cc[t4-1]+cc[t5-1];
+      tr2=cc[t4-1]-cc[t5-1];
+      ch[t3]=cc[t4]-cc[t5];
+      ti2=cc[t4]+cc[t5];
+      ch[t6-1]=wa1[i-2]*tr2-wa1[i-1]*ti2;
+      ch[t6]=wa1[i-2]*ti2+wa1[i-1]*tr2;
+    }
+    t2=(t1+=ido)<<1;
+  }
+
+  if(ido%2==1)return;
+
+L105:
+  t1=ido-1;
+  t2=ido-1;
+  for(k=0;k<l1;k++){
+    ch[t1]=cc[t2]+cc[t2];
+    ch[t1+t0]=-(cc[t2+1]+cc[t2+1]);
+    t1+=ido;
+    t2+=ido<<1;
+  }
+}
+
+static void dradb3(int ido,int l1,float *cc,float *ch,float *wa1,
+                          float *wa2){
+  static float taur = -.5f;
+  static float taui = .8660254037844386f;
+  int i,k,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
+  float ci2,ci3,di2,di3,cr2,cr3,dr2,dr3,ti2,tr2;
+  t0=l1*ido;
+
+  t1=0;
+  t2=t0<<1;
+  t3=ido<<1;
+  t4=ido+(ido<<1);
+  t5=0;
+  for(k=0;k<l1;k++){
+    tr2=cc[t3-1]+cc[t3-1];
+    cr2=cc[t5]+(taur*tr2);
+    ch[t1]=cc[t5]+tr2;
+    ci3=taui*(cc[t3]+cc[t3]);
+    ch[t1+t0]=cr2-ci3;
+    ch[t1+t2]=cr2+ci3;
+    t1+=ido;
+    t3+=t4;
+    t5+=t4;
+  }
+
+  if(ido==1)return;
+
+  t1=0;
+  t3=ido<<1;
+  for(k=0;k<l1;k++){
+    t7=t1+(t1<<1);
+    t6=(t5=t7+t3);
+    t8=t1;
+    t10=(t9=t1+t0)+t0;
+
+    for(i=2;i<ido;i+=2){
+      t5+=2;
+      t6-=2;
+      t7+=2;
+      t8+=2;
+      t9+=2;
+      t10+=2;
+      tr2=cc[t5-1]+cc[t6-1];
+      cr2=cc[t7-1]+(taur*tr2);
+      ch[t8-1]=cc[t7-1]+tr2;
+      ti2=cc[t5]-cc[t6];
+      ci2=cc[t7]+(taur*ti2);
+      ch[t8]=cc[t7]+ti2;
+      cr3=taui*(cc[t5-1]-cc[t6-1]);
+      ci3=taui*(cc[t5]+cc[t6]);
+      dr2=cr2-ci3;
+      dr3=cr2+ci3;
+      di2=ci2+cr3;
+      di3=ci2-cr3;
+      ch[t9-1]=wa1[i-2]*dr2-wa1[i-1]*di2;
+      ch[t9]=wa1[i-2]*di2+wa1[i-1]*dr2;
+      ch[t10-1]=wa2[i-2]*dr3-wa2[i-1]*di3;
+      ch[t10]=wa2[i-2]*di3+wa2[i-1]*dr3;
+    }
+    t1+=ido;
+  }
+}
+
+static void dradb4(int ido,int l1,float *cc,float *ch,float *wa1,
+			  float *wa2,float *wa3){
+  static float sqrt2=1.414213562373095f;
+  int i,k,t0,t1,t2,t3,t4,t5,t6,t7,t8;
+  float ci2,ci3,ci4,cr2,cr3,cr4,ti1,ti2,ti3,ti4,tr1,tr2,tr3,tr4;
+  t0=l1*ido;
+  
+  t1=0;
+  t2=ido<<2;
+  t3=0;
+  t6=ido<<1;
+  for(k=0;k<l1;k++){
+    t4=t3+t6;
+    t5=t1;
+    tr3=cc[t4-1]+cc[t4-1];
+    tr4=cc[t4]+cc[t4]; 
+    tr1=cc[t3]-cc[(t4+=t6)-1];
+    tr2=cc[t3]+cc[t4-1];
+    ch[t5]=tr2+tr3;
+    ch[t5+=t0]=tr1-tr4;
+    ch[t5+=t0]=tr2-tr3;
+    ch[t5+=t0]=tr1+tr4;
+    t1+=ido;
+    t3+=t2;
+  }
+
+  if(ido<2)return;
+  if(ido==2)goto L105;
+
+  t1=0;
+  for(k=0;k<l1;k++){
+    t5=(t4=(t3=(t2=t1<<2)+t6))+t6;
+    t7=t1;
+    for(i=2;i<ido;i+=2){
+      t2+=2;
+      t3+=2;
+      t4-=2;
+      t5-=2;
+      t7+=2;
+      ti1=cc[t2]+cc[t5];
+      ti2=cc[t2]-cc[t5];
+      ti3=cc[t3]-cc[t4];
+      tr4=cc[t3]+cc[t4];
+      tr1=cc[t2-1]-cc[t5-1];
+      tr2=cc[t2-1]+cc[t5-1];
+      ti4=cc[t3-1]-cc[t4-1];
+      tr3=cc[t3-1]+cc[t4-1];
+      ch[t7-1]=tr2+tr3;
+      cr3=tr2-tr3;
+      ch[t7]=ti2+ti3;
+      ci3=ti2-ti3;
+      cr2=tr1-tr4;
+      cr4=tr1+tr4;
+      ci2=ti1+ti4;
+      ci4=ti1-ti4;
+
+      ch[(t8=t7+t0)-1]=wa1[i-2]*cr2-wa1[i-1]*ci2;
+      ch[t8]=wa1[i-2]*ci2+wa1[i-1]*cr2;
+      ch[(t8+=t0)-1]=wa2[i-2]*cr3-wa2[i-1]*ci3;
+      ch[t8]=wa2[i-2]*ci3+wa2[i-1]*cr3;
+      ch[(t8+=t0)-1]=wa3[i-2]*cr4-wa3[i-1]*ci4;
+      ch[t8]=wa3[i-2]*ci4+wa3[i-1]*cr4;
+    }
+    t1+=ido;
+  }
+
+  if(ido%2 == 1)return;
+
+ L105:
+
+  t1=ido;
+  t2=ido<<2;
+  t3=ido-1;
+  t4=ido+(ido<<1);
+  for(k=0;k<l1;k++){
+    t5=t3;
+    ti1=cc[t1]+cc[t4];
+    ti2=cc[t4]-cc[t1];
+    tr1=cc[t1-1]-cc[t4-1];
+    tr2=cc[t1-1]+cc[t4-1];
+    ch[t5]=tr2+tr2;
+    ch[t5+=t0]=sqrt2*(tr1-ti1);
+    ch[t5+=t0]=ti2+ti2;
+    ch[t5+=t0]=-sqrt2*(tr1+ti1);
+
+    t3+=ido;
+    t1+=t2;
+    t4+=t2;
+  }
+}
+
+static void dradbg(int ido,int ip,int l1,int idl1,float *cc,float *c1,
+            float *c2,float *ch,float *ch2,float *wa){
+  static float tpi=6.283185307179586f;
+  int idij,ipph,i,j,k,l,ik,is,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,
+      t11,t12;
+  float dc2,ai1,ai2,ar1,ar2,ds2;
+  int nbd;
+  float dcp,arg,dsp,ar1h,ar2h;
+  int ipp2;
+
+  t10=ip*ido;
+  t0=l1*ido;
+  arg=tpi/(float)ip;
+  dcp=cos(arg);
+  dsp=sin(arg);
+  nbd=(ido-1)>>1;
+  ipp2=ip;
+  ipph=(ip+1)>>1;
+  if(ido<l1)goto L103;
+  
+  t1=0;
+  t2=0;
+  for(k=0;k<l1;k++){
+    t3=t1;
+    t4=t2;
+    for(i=0;i<ido;i++){
+      ch[t3]=cc[t4];
+      t3++;
+      t4++;
+    }
+    t1+=ido;
+    t2+=t10;
+  }
+  goto L106;
+
+ L103:
+  t1=0;
+  for(i=0;i<ido;i++){
+    t2=t1;
+    t3=t1;
+    for(k=0;k<l1;k++){
+      ch[t2]=cc[t3];
+      t2+=ido;
+      t3+=t10;
+    }
+    t1++;
+  }
+
+ L106:
+  t1=0;
+  t2=ipp2*t0;
+  t7=(t5=ido<<1);
+  for(j=1;j<ipph;j++){
+    t1+=t0;
+    t2-=t0;
+    t3=t1;
+    t4=t2;
+    t6=t5;
+    for(k=0;k<l1;k++){
+      ch[t3]=cc[t6-1]+cc[t6-1];
+      ch[t4]=cc[t6]+cc[t6];
+      t3+=ido;
+      t4+=ido;
+      t6+=t10;
+    }
+    t5+=t7;
+  }
+
+  if (ido == 1)goto L116;
+  if(nbd<l1)goto L112;
+
+  t1=0;
+  t2=ipp2*t0;
+  t7=0;
+  for(j=1;j<ipph;j++){
+    t1+=t0;
+    t2-=t0;
+    t3=t1;
+    t4=t2;
+
+    t7+=(ido<<1);
+    t8=t7;
+    for(k=0;k<l1;k++){
+      t5=t3;
+      t6=t4;
+      t9=t8;
+      t11=t8;
+      for(i=2;i<ido;i+=2){
+        t5+=2;
+        t6+=2;
+        t9+=2;
+        t11-=2;
+        ch[t5-1]=cc[t9-1]+cc[t11-1];
+        ch[t6-1]=cc[t9-1]-cc[t11-1];
+        ch[t5]=cc[t9]-cc[t11];
+        ch[t6]=cc[t9]+cc[t11];
+      }
+      t3+=ido;
+      t4+=ido;
+      t8+=t10;
+    }
+  }
+  goto L116;
+
+ L112:
+  t1=0;
+  t2=ipp2*t0;
+  t7=0;
+  for(j=1;j<ipph;j++){
+    t1+=t0;
+    t2-=t0;
+    t3=t1;
+    t4=t2;
+    t7+=(ido<<1);
+    t8=t7;
+    t9=t7;
+    for(i=2;i<ido;i+=2){
+      t3+=2;
+      t4+=2;
+      t8+=2;
+      t9-=2;
+      t5=t3;
+      t6=t4;
+      t11=t8;
+      t12=t9;
+      for(k=0;k<l1;k++){
+        ch[t5-1]=cc[t11-1]+cc[t12-1];
+        ch[t6-1]=cc[t11-1]-cc[t12-1];
+        ch[t5]=cc[t11]-cc[t12];
+        ch[t6]=cc[t11]+cc[t12];
+        t5+=ido;
+        t6+=ido;
+        t11+=t10;
+        t12+=t10;
+      }
+    }
+  }
+
+L116:
+  ar1=1.f;
+  ai1=0.f;
+  t1=0;
+  t9=(t2=ipp2*idl1);
+  t3=(ip-1)*idl1;
+  for(l=1;l<ipph;l++){
+    t1+=idl1;
+    t2-=idl1;
+
+    ar1h=dcp*ar1-dsp*ai1;
+    ai1=dcp*ai1+dsp*ar1;
+    ar1=ar1h;
+    t4=t1;
+    t5=t2;
+    t6=0;
+    t7=idl1;
+    t8=t3;
+    for(ik=0;ik<idl1;ik++){
+      c2[t4++]=ch2[t6++]+ar1*ch2[t7++];
+      c2[t5++]=ai1*ch2[t8++];
+    }
+    dc2=ar1;
+    ds2=ai1;
+    ar2=ar1;
+    ai2=ai1;
+
+    t6=idl1;
+    t7=t9-idl1;
+    for(j=2;j<ipph;j++){
+      t6+=idl1;
+      t7-=idl1;
+      ar2h=dc2*ar2-ds2*ai2;
+      ai2=dc2*ai2+ds2*ar2;
+      ar2=ar2h;
+      t4=t1;
+      t5=t2;
+      t11=t6;
+      t12=t7;
+      for(ik=0;ik<idl1;ik++){
+        c2[t4++]+=ar2*ch2[t11++];
+        c2[t5++]+=ai2*ch2[t12++];
+      }
+    }
+  }
+
+  t1=0;
+  for(j=1;j<ipph;j++){
+    t1+=idl1;
+    t2=t1;
+    for(ik=0;ik<idl1;ik++)ch2[ik]+=ch2[t2++];
+  }
+
+  t1=0;
+  t2=ipp2*t0;
+  for(j=1;j<ipph;j++){
+    t1+=t0;
+    t2-=t0;
+    t3=t1;
+    t4=t2;
+    for(k=0;k<l1;k++){
+      ch[t3]=c1[t3]-c1[t4];
+      ch[t4]=c1[t3]+c1[t4];
+      t3+=ido;
+      t4+=ido;
+    }
+  }
+
+  if(ido==1)goto L132;
+  if(nbd<l1)goto L128;
+
+  t1=0;
+  t2=ipp2*t0;
+  for(j=1;j<ipph;j++){
+    t1+=t0;
+    t2-=t0;
+    t3=t1;
+    t4=t2;
+    for(k=0;k<l1;k++){
+      t5=t3;
+      t6=t4;
+      for(i=2;i<ido;i+=2){
+        t5+=2;
+        t6+=2;
+        ch[t5-1]=c1[t5-1]-c1[t6];
+        ch[t6-1]=c1[t5-1]+c1[t6];
+        ch[t5]=c1[t5]+c1[t6-1];
+        ch[t6]=c1[t5]-c1[t6-1];
+      }
+      t3+=ido;
+      t4+=ido;
+    }
+  }
+  goto L132;
+
+ L128:
+  t1=0;
+  t2=ipp2*t0;
+  for(j=1;j<ipph;j++){
+    t1+=t0;
+    t2-=t0;
+    t3=t1;
+    t4=t2;
+    for(i=2;i<ido;i+=2){
+      t3+=2;
+      t4+=2;
+      t5=t3;
+      t6=t4;
+      for(k=0;k<l1;k++){
+        ch[t5-1]=c1[t5-1]-c1[t6];
+        ch[t6-1]=c1[t5-1]+c1[t6];
+        ch[t5]=c1[t5]+c1[t6-1];
+        ch[t6]=c1[t5]-c1[t6-1];
+        t5+=ido;
+        t6+=ido;
+      }
+    }
+  }
+
+L132:
+  if(ido==1)return;
+
+  for(ik=0;ik<idl1;ik++)c2[ik]=ch2[ik];
+
+  t1=0;
+  for(j=1;j<ip;j++){
+    t2=(t1+=t0);
+    for(k=0;k<l1;k++){
+      c1[t2]=ch[t2];
+      t2+=ido;
+    }
+  }
+
+  if(nbd>l1)goto L139;
+
+  is= -ido-1;
+  t1=0;
+  for(j=1;j<ip;j++){
+    is+=ido;
+    t1+=t0;
+    idij=is;
+    t2=t1;
+    for(i=2;i<ido;i+=2){
+      t2+=2;
+      idij+=2;
+      t3=t2;
+      for(k=0;k<l1;k++){
+        c1[t3-1]=wa[idij-1]*ch[t3-1]-wa[idij]*ch[t3];
+        c1[t3]=wa[idij-1]*ch[t3]+wa[idij]*ch[t3-1];
+        t3+=ido;
+      }
+    }
+  }
+  return;
+
+ L139:
+  is= -ido-1;
+  t1=0;
+  for(j=1;j<ip;j++){
+    is+=ido;
+    t1+=t0;
+    t2=t1;
+    for(k=0;k<l1;k++){
+      idij=is;
+      t3=t2;
+      for(i=2;i<ido;i+=2){
+        idij+=2;
+        t3+=2;
+        c1[t3-1]=wa[idij-1]*ch[t3-1]-wa[idij]*ch[t3];
+        c1[t3]=wa[idij-1]*ch[t3]+wa[idij]*ch[t3-1];
+      }
+      t2+=ido;
+    }
+  }
+}
+
+static void drftb1(int n, float *c, float *ch, float *wa, int *ifac){
+  int i,k1,l1,l2;
+  int na;
+  int nf,ip,iw,ix2,ix3,ido,idl1;
+
+  nf=ifac[1];
+  na=0;
+  l1=1;
+  iw=1;
+
+  for(k1=0;k1<nf;k1++){
+    ip=ifac[k1 + 2];
+    l2=ip*l1;
+    ido=n/l2;
+    idl1=ido*l1;
+    if(ip!=4)goto L103;
+    ix2=iw+ido;
+    ix3=ix2+ido;
+
+    if(na!=0)
+      dradb4(ido,l1,ch,c,wa+iw-1,wa+ix2-1,wa+ix3-1);
+    else
+      dradb4(ido,l1,c,ch,wa+iw-1,wa+ix2-1,wa+ix3-1);
+    na=1-na;
+    goto L115;
+
+  L103:
+    if(ip!=2)goto L106;
+
+    if(na!=0)
+      dradb2(ido,l1,ch,c,wa+iw-1);
+    else
+      dradb2(ido,l1,c,ch,wa+iw-1);
+    na=1-na;
+    goto L115;
+
+  L106:
+    if(ip!=3)goto L109;
+
+    ix2=iw+ido;
+    if(na!=0)
+      dradb3(ido,l1,ch,c,wa+iw-1,wa+ix2-1);
+    else
+      dradb3(ido,l1,c,ch,wa+iw-1,wa+ix2-1);
+    na=1-na;
+    goto L115;
+
+  L109:
+/*    The radix five case can be translated later..... */
+/*    if(ip!=5)goto L112;
+
+    ix2=iw+ido;
+    ix3=ix2+ido;
+    ix4=ix3+ido;
+    if(na!=0)
+      dradb5(ido,l1,ch,c,wa+iw-1,wa+ix2-1,wa+ix3-1,wa+ix4-1);
+    else
+      dradb5(ido,l1,c,ch,wa+iw-1,wa+ix2-1,wa+ix3-1,wa+ix4-1);
+    na=1-na;
+    goto L115;
+
+  L112:*/
+    if(na!=0)
+      dradbg(ido,ip,l1,idl1,ch,ch,ch,c,c,wa+iw-1);
+    else
+      dradbg(ido,ip,l1,idl1,c,c,c,ch,ch,wa+iw-1);
+    if(ido==1)na=1-na;
+
+  L115:
+    l1=l2;
+    iw+=(ip-1)*ido;
+  }
+
+  if(na==0)return;
+
+  for(i=0;i<n;i++)c[i]=ch[i];
+}
+
+void spx_drft_forward(struct drft_lookup *l,float *data){
+  if(l->n==1)return;
+  drftf1(l->n,data,l->trigcache,l->trigcache+l->n,l->splitcache);
+}
+
+void spx_drft_backward(struct drft_lookup *l,float *data){
+  if (l->n==1)return;
+  drftb1(l->n,data,l->trigcache,l->trigcache+l->n,l->splitcache);
+}
+
+void spx_drft_init(struct drft_lookup *l,int n)
+{
+  l->n=n;
+  l->trigcache=(float*)speex_alloc(3*n*sizeof(*l->trigcache));
+  l->splitcache=(int*)speex_alloc(32*sizeof(*l->splitcache));
+  fdrffti(n, l->trigcache, l->splitcache);
+}
+
+void spx_drft_clear(struct drft_lookup *l)
+{
+  if(l)
+  {
+    if(l->trigcache)
+      speex_free(l->trigcache);
+    if(l->splitcache)
+      speex_free(l->splitcache);
+  }
+}

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/smallft.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/smallft.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/smallft.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,42 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001             *
+ * by the XIPHOPHORUS Company http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+ function: fft transform
+ last mod: $Id: smallft.h,v 1.3 2003/09/16 18:35:45 jm Exp $
+
+ ********************************************************************/
+
+#ifndef _V_SMFT_H_
+#define _V_SMFT_H_
+
+/*#include "vorbis/codec.h"*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct drft_lookup{
+  int n;
+  float *trigcache;
+  int *splitcache;
+};
+
+extern void spx_drft_forward(struct drft_lookup *l,float *data);
+extern void spx_drft_backward(struct drft_lookup *l,float *data);
+extern void spx_drft_init(struct drft_lookup *l,int n);
+extern void spx_drft_clear(struct drft_lookup *l);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/speex.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/speex.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/speex.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,268 @@
+/* Copyright (C) 2002 Jean-Marc Valin 
+   File: speex.c
+
+   Basic Speex functions
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+   
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+   
+   - Neither the name of the Xiph.org Foundation nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+   
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "modes.h"
+#include <math.h>
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#define MAX_IN_SAMPLES 640
+
+
+
+void *speex_encoder_init(const SpeexMode *mode)
+{
+   return mode->enc_init(mode);
+}
+
+void *speex_decoder_init(const SpeexMode *mode)
+{
+   return mode->dec_init(mode);
+}
+
+void speex_encoder_destroy(void *state)
+{
+   (*((SpeexMode**)state))->enc_destroy(state);
+}
+
+void speex_decoder_destroy(void *state)
+{
+   (*((SpeexMode**)state))->dec_destroy(state);
+}
+
+
+
+int speex_encode_native(void *state, spx_word16_t *in, SpeexBits *bits)
+{
+   return (*((SpeexMode**)state))->enc(state, in, bits);
+}
+
+int speex_decode_native(void *state, SpeexBits *bits, spx_word16_t *out)
+{
+   return (*((SpeexMode**)state))->dec(state, bits, out);
+}
+
+
+
+#ifdef FIXED_POINT
+
+int speex_encode(void *state, float *in, SpeexBits *bits)
+{
+   int i;
+   int N;
+   spx_int16_t short_in[MAX_IN_SAMPLES];
+   speex_encoder_ctl(state, SPEEX_GET_FRAME_SIZE, &N);
+   for (i=0;i<N;i++)
+   {
+      if (in[i]>32767.f)
+         short_in[i] = 32767;
+      else if (in[i]<-32768.f)
+         short_in[i] = -32768;
+      else
+         short_in[i] = (spx_int16_t)floor(.5+in[i]);
+   }
+   return (*((SpeexMode**)state))->enc(state, short_in, bits);
+}
+
+int speex_encode_int(void *state, spx_int16_t *in, SpeexBits *bits)
+{
+   SpeexMode *mode;
+   mode = *(SpeexMode**)state;
+   return (mode)->enc(state, in, bits);
+}
+
+int speex_decode(void *state, SpeexBits *bits, float *out)
+{
+   int i, ret;
+   int N;
+   spx_int16_t short_out[MAX_IN_SAMPLES];
+   speex_decoder_ctl(state, SPEEX_GET_FRAME_SIZE, &N);
+   ret = (*((SpeexMode**)state))->dec(state, bits, short_out);
+   for (i=0;i<N;i++)
+      out[i] = short_out[i];
+   return ret;
+}
+
+int speex_decode_int(void *state, SpeexBits *bits, spx_int16_t *out)
+{
+   SpeexMode *mode = *(SpeexMode**)state;
+   return (mode)->dec(state, bits, out);
+}
+
+#else
+
+int speex_encode(void *state, float *in, SpeexBits *bits)
+{
+   return (*((SpeexMode**)state))->enc(state, in, bits);
+}
+
+int speex_encode_int(void *state, spx_int16_t *in, SpeexBits *bits)
+{
+   int i;
+   int N;
+   float float_in[MAX_IN_SAMPLES];
+   speex_encoder_ctl(state, SPEEX_GET_FRAME_SIZE, &N);
+   for (i=0;i<N;i++)
+      float_in[i] = in[i];
+   return (*((SpeexMode**)state))->enc(state, float_in, bits);
+}
+
+int speex_decode(void *state, SpeexBits *bits, float *out)
+{
+   return (*((SpeexMode**)state))->dec(state, bits, out);
+}
+
+int speex_decode_int(void *state, SpeexBits *bits, spx_int16_t *out)
+{
+   int i;
+   int N;
+   float float_out[MAX_IN_SAMPLES];
+   int ret;
+   speex_decoder_ctl(state, SPEEX_GET_FRAME_SIZE, &N);
+   ret = (*((SpeexMode**)state))->dec(state, bits, float_out);
+   for (i=0;i<N;i++)
+   {
+      if (float_out[i]>32767.f)
+         out[i] = 32767;
+      else if (float_out[i]<-32768.f)
+         out[i] = -32768;
+      else
+         out[i] = (spx_int16_t)floor(.5+float_out[i]);
+   }
+   return ret;
+}
+#endif
+
+
+
+int speex_encoder_ctl(void *state, int request, void *ptr)
+{
+   return (*((SpeexMode**)state))->enc_ctl(state, request, ptr);
+}
+
+int speex_decoder_ctl(void *state, int request, void *ptr)
+{
+   return (*((SpeexMode**)state))->dec_ctl(state, request, ptr);
+}
+
+
+
+int nb_mode_query(const void *mode, int request, void *ptr)
+{
+   const SpeexNBMode *m = (const SpeexNBMode*)mode;
+   
+   switch (request)
+   {
+   case SPEEX_MODE_FRAME_SIZE:
+      *((int*)ptr)=m->frameSize;
+      break;
+   case SPEEX_SUBMODE_BITS_PER_FRAME:
+      if (*((int*)ptr)==0)
+         *((int*)ptr) = NB_SUBMODE_BITS+1;
+      else if (m->submodes[*((int*)ptr)]==NULL)
+         *((int*)ptr) = -1;
+      else
+         *((int*)ptr) = m->submodes[*((int*)ptr)]->bits_per_frame;
+      break;
+   default:
+      speex_warning_int("Unknown nb_mode_query request: ", request);
+      return -1;
+   }
+   return 0;
+}
+
+int wb_mode_query(const void *mode, int request, void *ptr)
+{
+   const SpeexSBMode *m = (const SpeexSBMode*)mode;
+
+   switch (request)
+   {
+   case SPEEX_MODE_FRAME_SIZE:
+      *((int*)ptr)=2*m->frameSize;
+      break;
+   case SPEEX_SUBMODE_BITS_PER_FRAME:
+      if (*((int*)ptr)==0)
+         *((int*)ptr) = SB_SUBMODE_BITS+1;
+      else if (m->submodes[*((int*)ptr)]==NULL)
+         *((int*)ptr) = -1;
+      else
+         *((int*)ptr) = m->submodes[*((int*)ptr)]->bits_per_frame;
+      break;
+   default:
+      speex_warning_int("Unknown wb_mode_query request: ", request);
+      return -1;
+   }
+   return 0;
+}
+
+
+int speex_lib_ctl(int request, void *ptr)
+{
+   switch (request)
+   {
+      case SPEEX_LIB_GET_MAJOR_VERSION:
+         *((int*)ptr) = SPEEX_MAJOR_VERSION;
+         break;
+      case SPEEX_LIB_GET_MINOR_VERSION:
+         *((int*)ptr) = SPEEX_MINOR_VERSION;
+         break;
+      case SPEEX_LIB_GET_MICRO_VERSION:
+         *((int*)ptr) = SPEEX_MICRO_VERSION;
+         break;
+      case SPEEX_LIB_GET_EXTRA_VERSION:
+         *((const char**)ptr) = SPEEX_EXTRA_VERSION;
+         break;
+      case SPEEX_LIB_GET_VERSION_STRING:
+         *((const char**)ptr) = SPEEX_VERSION;
+         break;
+      /*case SPEEX_LIB_SET_ALLOC_FUNC:
+         break;
+      case SPEEX_LIB_GET_ALLOC_FUNC:
+         break;
+      case SPEEX_LIB_SET_FREE_FUNC:
+         break;
+      case SPEEX_LIB_GET_FREE_FUNC:
+         break;*/
+      default:
+         speex_warning_int("Unknown wb_mode_query request: ", request);
+         return -1;
+   }
+   return 0;
+}

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/speex_callbacks.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/speex_callbacks.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/speex_callbacks.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -32,6 +32,10 @@
 
 */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <speex/speex_callbacks.h>
 #include "misc.h"
 
@@ -121,6 +125,7 @@
    unsigned char ch;
    ch = speex_bits_unpack_unsigned(bits, 8);
    _speex_putc(ch, data);
+   /*printf("speex_std_char_handler ch=%x\n", ch);*/
    return 0;
 }
 

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/speex_header.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/speex_header.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/speex_header.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -31,8 +31,12 @@
 
 */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "misc.h"
 #include <speex/speex_header.h>
-#include "misc.h"
 #include <speex/speex.h>
 
 #ifndef NULL
@@ -62,10 +66,10 @@
 } SpeexHeader;
 */
 
-void speex_init_header(SpeexHeader *header, int rate, int nb_channels, SpeexMode *m)
+void speex_init_header(SpeexHeader *header, int rate, int nb_channels, const SpeexMode *m)
 {
    int i;
-   char *h="Speex   ";
+   const char *h="Speex   ";
    /*
    strncpy(header->speex_string, "Speex   ", 8);
    strncpy(header->speex_version, SPEEX_VERSION, SPEEX_HEADER_VERSION_LENGTH-1);
@@ -125,7 +129,7 @@
 {
    int i;
    SpeexHeader *le_header;
-   char *h = "Speex   ";
+   const char *h = "Speex   ";
    for (i=0;i<8;i++)
       if (packet[i]!=h[i])
       {

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/stack_alloc.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/stack_alloc.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/stack_alloc.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -34,21 +34,27 @@
 #ifndef STACK_ALLOC_H
 #define STACK_ALLOC_H
 
-#if 0
+#ifdef USE_ALLOCA
+#include <alloca.h>
+#endif
 
+#ifdef ENABLE_VALGRIND
+
+#include <valgrind/memcheck.h>
 /*Aligns the stack to a 'size' boundary */
-#define ALIGN(stack, size) (stack=(void*)((((int)stack)+((size)-1)) & (-(size))))
-/*Aligns the stack to a 'size' boundary minus k */
-#define ALIGN_1(stack, size, k) (stack=(void*)(((((int)stack)+((size)-1+(k))) & (-(size)))-(k)))
+#define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1))
 
 /* Allocates 'size' elements of type 'type' on the stack */
-#define PUSH(stack, size, type) (ALIGN(stack,sizeof(type)),stack=(void*)(((int)stack)+((size)*sizeof(type))),(type*)(((int)stack)-((size)*sizeof(type))))
+#define PUSH(stack, size, type) (VALGRIND_MAKE_NOACCESS(stack, 1000),ALIGN((stack),sizeof(type)),VALGRIND_MAKE_WRITABLE(stack, ((size)*sizeof(type))),(stack)+=((size)*sizeof(type)),(type*)((stack)-((size)*sizeof(type))))
 
+/* Allocates a struct stack */
+#define PUSHS(stack, type) (VALGRIND_MAKE_NOACCESS(stack, 1000),ALIGN((stack),sizeof(long)),VALGRIND_MAKE_WRITABLE(stack, (sizeof(type))),(stack)+=(sizeof(type)),(type*)((stack)-(sizeof(type))))
 
 #else
 
+
 /*Aligns the stack to a 'size' boundary */
-#define ALIGN(stack, size) ((stack) += ((size) - (int)(stack)) & ((size) - 1))
+#define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1))
 
 /* Allocates 'size' elements of type 'type' on the stack */
 #define PUSH(stack, size, type) (ALIGN((stack),sizeof(type)),(stack)+=((size)*sizeof(type)),(type*)((stack)-((size)*sizeof(type))))
@@ -56,7 +62,18 @@
 /* Allocates a struct stack */
 #define PUSHS(stack, type) (ALIGN((stack),sizeof(long)),(stack)+=(sizeof(type)),(type*)((stack)-(sizeof(type))))
 
+#endif
 
+#if defined(VAR_ARRAYS)
+#define VARDECL(var) 
+#define ALLOC(var, size, type) type var[size]
+#elif defined(USE_ALLOCA)
+#define VARDECL(var) var
+#define ALLOC(var, size, type) var = alloca(sizeof(type)*size)
+#else
+#define VARDECL(var) var
+#define ALLOC(var, size, type) var = PUSH(stack, size, type)
 #endif
 
+
 #endif

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/stereo.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/stereo.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/stereo.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -29,13 +29,17 @@
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <speex/speex_stereo.h>
 #include <speex/speex_callbacks.h>
 #include "vq.h"
 #include <math.h>
 
 /*float e_ratio_quant[4] = {1, 1.26, 1.587, 2};*/
-static float e_ratio_quant[4] = {.25, .315, .397, .5};
+static const float e_ratio_quant[4] = {.25f, .315f, .397f, .5f};
 
 void speex_encode_stereo(float *data, int frame_size, SpeexBits *bits)
 {
@@ -44,10 +48,10 @@
    float balance, e_ratio;
    for (i=0;i<frame_size;i++)
    {
-      e_left  += data[2*i]*data[2*i];
-      e_right += data[2*i+1]*data[2*i+1];
-      data[i] =  .5*(data[2*i]+data[2*i+1]);
-      e_tot   += data[i]*data[i];
+      e_left  += ((float)data[2*i])*data[2*i];
+      e_right += ((float)data[2*i+1])*data[2*i+1];
+      data[i] =  .5*(((float)data[2*i])+data[2*i+1]);
+      e_tot   += ((float)data[i])*data[i];
    }
    balance=(e_left+1)/(e_right+1);
    e_ratio = e_tot/(1+e_left+e_right);
@@ -74,6 +78,43 @@
    speex_bits_pack(bits, tmp, 2);
 }
 
+void speex_encode_stereo_int(spx_int16_t *data, int frame_size, SpeexBits *bits)
+{
+   int i, tmp;
+   float e_left=0, e_right=0, e_tot=0;
+   float balance, e_ratio;
+   for (i=0;i<frame_size;i++)
+   {
+      e_left  += ((float)data[2*i])*data[2*i];
+      e_right += ((float)data[2*i+1])*data[2*i+1];
+      data[i] =  .5*(((float)data[2*i])+data[2*i+1]);
+      e_tot   += ((float)data[i])*data[i];
+   }
+   balance=(e_left+1)/(e_right+1);
+   e_ratio = e_tot/(1+e_left+e_right);
+
+   /*Quantization*/
+   speex_bits_pack(bits, 14, 5);
+   speex_bits_pack(bits, SPEEX_INBAND_STEREO, 4);
+   
+   balance=4*log(balance);
+
+   /*Pack sign*/
+   if (balance>0)
+      speex_bits_pack(bits, 0, 1);
+   else
+      speex_bits_pack(bits, 1, 1);
+   balance=floor(.5+fabs(balance));
+   if (balance>30)
+      balance=31;
+   
+   speex_bits_pack(bits, (int)balance, 5);
+   
+   /*Quantize energy ratio*/
+   tmp=vq_index(&e_ratio, e_ratio_quant, 1, 4);
+   speex_bits_pack(bits, tmp, 2);
+}
+
 void speex_decode_stereo(float *data, int frame_size, SpeexStereoState *stereo)
 {
    float balance, e_ratio;
@@ -84,7 +125,7 @@
    e_ratio=stereo->e_ratio;
    for (i=frame_size-1;i>=0;i--)
    {
-      e_tot += data[i]*data[i];
+      e_tot += ((float)data[i])*data[i];
    }
    e_sum=e_tot/e_ratio;
    e_left  = e_sum*balance / (1+balance);
@@ -103,6 +144,35 @@
    }
 }
 
+void speex_decode_stereo_int(spx_int16_t *data, int frame_size, SpeexStereoState *stereo)
+{
+   float balance, e_ratio;
+   int i;
+   float e_tot=0, e_left, e_right, e_sum;
+
+   balance=stereo->balance;
+   e_ratio=stereo->e_ratio;
+   for (i=frame_size-1;i>=0;i--)
+   {
+      e_tot += ((float)data[i])*data[i];
+   }
+   e_sum=e_tot/e_ratio;
+   e_left  = e_sum*balance / (1+balance);
+   e_right = e_sum-e_left;
+
+   e_left  = sqrt(e_left/(e_tot+.01));
+   e_right = sqrt(e_right/(e_tot+.01));
+
+   for (i=frame_size-1;i>=0;i--)
+   {
+      float ftmp=data[i];
+      stereo->smooth_left  = .98*stereo->smooth_left  + .02*e_left;
+      stereo->smooth_right = .98*stereo->smooth_right + .02*e_right;
+      data[2*i] = stereo->smooth_left*ftmp;
+      data[2*i+1] = stereo->smooth_right*ftmp;
+   }
+}
+
 int speex_std_stereo_request_handler(SpeexBits *bits, void *state, void *data)
 {
    SpeexStereoState *stereo;

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/testdenoise.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/testdenoise.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/testdenoise.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,44 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <speex/speex_preprocess.h>
+#include <stdio.h>
+
+#define NN 160
+
+int main()
+{
+   short in[NN];
+   int i;
+   SpeexPreprocessState *st;
+   int count=0;
+   float f;
+
+   st = speex_preprocess_state_init(NN, 8000);
+   i=1;
+   speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_DENOISE, &i);
+   i=0;
+   speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_AGC, &i);
+   f=8000;
+   speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_AGC_LEVEL, &f);
+   i=0;
+   speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_DEREVERB, &i);
+   f=.4;
+   speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_DEREVERB_DECAY, &f);
+   f=.3;
+   speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_DEREVERB_LEVEL, &f);
+   while (1)
+   {
+      int vad;
+      fread(in, sizeof(short), NN, stdin);
+      if (feof(stdin))
+         break;
+      vad = speex_preprocess(st, in, NULL);
+      /*fprintf (stderr, "%d\n", vad);*/
+      fwrite(in, sizeof(short), NN, stdout);
+      count++;
+   }
+   speex_preprocess_state_destroy(st);
+   return 0;
+}

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/testecho.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/testecho.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/testecho.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,50 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include "speex/speex_echo.h"
+#include "speex/speex_preprocess.h"
+
+
+#define NN 160
+
+int main(int argc, char **argv)
+{
+   int echo_fd, ref_fd, e_fd;
+   float noise[NN+1];
+   short echo_buf[NN], ref_buf[NN], e_buf[NN];
+   SpeexEchoState *st;
+   SpeexPreprocessState *den;
+
+   if (argc != 4)
+   {
+      fprintf (stderr, "testecho mic_signal.sw speaker_signal.sw output.sw\n");
+      exit(1);
+   }
+   echo_fd = open (argv[2], O_RDONLY);
+   ref_fd  = open (argv[1],  O_RDONLY);
+   e_fd    = open (argv[3], O_WRONLY | O_CREAT | O_TRUNC, 0644);
+
+   st = speex_echo_state_init(NN, 8*NN);
+   den = speex_preprocess_state_init(NN, 8000);
+
+   while (read(ref_fd, ref_buf, NN*2))
+   {
+      read(echo_fd, echo_buf, NN*2);
+      speex_echo_cancel(st, ref_buf, echo_buf, e_buf, noise);
+      speex_preprocess(den, e_buf, noise);
+      write(e_fd, e_buf, NN*2);
+   }
+   speex_echo_state_destroy(st);
+   speex_preprocess_state_destroy(den);
+   close(e_fd);
+   close(echo_fd);
+   close(ref_fd);
+   return 0;
+}

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/testenc.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/testenc.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/testenc.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -1,3 +1,7 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <speex/speex.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -3,4 +7,8 @@
 #include <speex/speex_callbacks.h>
 
+#ifdef FIXED_DEBUG
+extern long long spx_mips;
+#endif
+
 #define FRAME_SIZE 160
 #include <math.h>
@@ -9,8 +17,10 @@
 {
    char *inFile, *outFile, *bitsFile;
    FILE *fin, *fout, *fbits=NULL;
-   short in[FRAME_SIZE];
-   float input[FRAME_SIZE], bak[FRAME_SIZE], bak2[FRAME_SIZE];
+   short in_short[FRAME_SIZE];
+   short out_short[FRAME_SIZE];
+   float sigpow,errpow,snr, seg_snr=0;
+   int snr_frames = 0;
    char cbits[200];
    int nbBits;
    int i;
@@ -19,10 +29,12 @@
    SpeexBits bits;
    int tmp;
    int bitCount=0;
+   int skip_group_delay;
    SpeexCallback callback;
 
-   for (i=0;i<FRAME_SIZE;i++)
-      bak2[i]=0;
+   sigpow = 0;
+   errpow = 0;
+
    st = speex_encoder_init(&speex_nb_mode);
    dec = speex_decoder_init(&speex_nb_mode);
 
@@ -47,6 +59,7 @@
 
    speex_mode_query(&speex_nb_mode, SPEEX_MODE_FRAME_SIZE, &tmp);
    fprintf (stderr, "frame size: %d\n", tmp);
+   skip_group_delay = tmp / 2;
 
    if (argc != 4 && argc != 3)
    {
@@ -56,7 +69,7 @@
    inFile = argv[1];
    fin = fopen(inFile, "r");
    outFile = argv[2];
-   fout = fopen(outFile, "w");
+   fout = fopen(outFile, "w+");
    if (argc==4)
    {
       bitsFile = argv[3];
@@ -65,63 +78,57 @@
    speex_bits_init(&bits);
    while (!feof(fin))
    {
-      fread(in, sizeof(short), FRAME_SIZE, fin);
+      fread(in_short, sizeof(short), FRAME_SIZE, fin);
       if (feof(fin))
          break;
-      for (i=0;i<FRAME_SIZE;i++)
-         bak[i]=input[i]=in[i];
       speex_bits_reset(&bits);
-      /*
-      speex_bits_pack(&bits, 14, 5);
-      speex_bits_pack(&bits, SPEEX_INBAND_CHAR, 4);
-      speex_bits_pack(&bits, 'A', 8);
-      
-      speex_bits_pack(&bits, 14, 5);
-      speex_bits_pack(&bits, SPEEX_INBAND_MODE_REQUEST, 4);
-      speex_bits_pack(&bits, 7, 4);
 
-      speex_bits_pack(&bits, 15, 5);
-      speex_bits_pack(&bits, 2, 4);
-      speex_bits_pack(&bits, 0, 16);
-      */
-      speex_encode(st, input, &bits);
+      speex_encode_int(st, in_short, &bits);
       nbBits = speex_bits_write(&bits, cbits, 200);
       bitCount+=bits.nbBits;
-      printf ("Encoding frame in %d bits\n", nbBits*8);
+
       if (argc==4)
          fwrite(cbits, 1, nbBits, fbits);
-      {
-         float enoise=0, esig=0, snr;
-         for (i=0;i<FRAME_SIZE;i++)
-         {
-            enoise+=(bak2[i]-input[i])*(bak2[i]-input[i]);
-            esig += bak2[i]*bak2[i];
-         }
-         snr = 10*log10((esig+1)/(enoise+1));
-         printf ("real SNR = %f\n", snr);
-      }
       speex_bits_rewind(&bits);
-      
-      speex_decode(dec, &bits, input);
-      
-      /* Save the bits here */
-      for (i=0;i<FRAME_SIZE;i++)
-      {
-         if (input[i]>32000)
-            input[i]=32000;
-         else if (input[i]<-32000)
-            input[i]=-32000;
-      }
+
+      speex_decode_int(dec, &bits, out_short);
       speex_bits_reset(&bits);
-      for (i=0;i<FRAME_SIZE;i++)
-         in[i]=(short)input[i];
-      for (i=0;i<FRAME_SIZE;i++)
-         bak2[i]=bak[i];
-      fwrite(in, sizeof(short), FRAME_SIZE, fout);
+
+      fwrite(&out_short[skip_group_delay], sizeof(short), FRAME_SIZE-skip_group_delay, fout);
+      skip_group_delay = 0;
    }
    fprintf (stderr, "Total encoded size: %d bits\n", bitCount);
-   
    speex_encoder_destroy(st);
    speex_decoder_destroy(dec);
-   return 1;
+   speex_bits_destroy(&bits);
+
+   rewind(fin);
+   rewind(fout);
+
+   while ( FRAME_SIZE == fread(in_short, sizeof(short), FRAME_SIZE, fin) 
+           &&
+           FRAME_SIZE ==  fread(out_short, sizeof(short), FRAME_SIZE,fout) )
+   {
+	float s=0, e=0;
+        for (i=0;i<FRAME_SIZE;++i) {
+            s += (float)in_short[i] * in_short[i];
+            e += ((float)in_short[i]-out_short[i]) * ((float)in_short[i]-out_short[i]);
+        }
+	seg_snr += 10*log10((s+160)/(e+160));
+	sigpow += s;
+	errpow += e;
+	snr_frames++;
+   }
+   fclose(fin);
+   fclose(fout);
+
+   snr = 10 * log10( sigpow / errpow );
+   seg_snr /= snr_frames;
+   fprintf(stderr,"SNR = %f\nsegmental SNR = %f\n",snr, seg_snr);
+
+#ifdef FIXED_DEBUG
+   printf ("Total: %f MIPS\n", (float)(1e-6*50*spx_mips/snr_frames));
+#endif
+   
+   return 0;
 }

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/testenc_uwb.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/testenc_uwb.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/testenc_uwb.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -1,15 +1,27 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <speex/speex.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <speex/speex_callbacks.h>
 
+#ifdef FIXED_DEBUG
+extern long long spx_mips;
+#endif
+
 #define FRAME_SIZE 640
 #include <math.h>
 int main(int argc, char **argv)
 {
    char *inFile, *outFile, *bitsFile;
    FILE *fin, *fout, *fbits=NULL;
-   short in[FRAME_SIZE];
-   float input[FRAME_SIZE], bak[FRAME_SIZE], bak2[FRAME_SIZE];
+   short in_short[FRAME_SIZE];
+   short out_short[FRAME_SIZE];
+   float in_float[FRAME_SIZE];
+   float sigpow,errpow,snr, seg_snr=0;
+   int snr_frames = 0;
    char cbits[200];
    int nbBits;
    int i;
@@ -18,34 +30,47 @@
    SpeexBits bits;
    int tmp;
    int bitCount=0;
+   int skip_group_delay;
+   SpeexCallback callback;
 
-   for (i=0;i<FRAME_SIZE;i++)
-      bak2[i]=0;
+   sigpow = 0;
+   errpow = 0;
+
    st = speex_encoder_init(&speex_uwb_mode);
    dec = speex_decoder_init(&speex_uwb_mode);
-   
+
+   callback.callback_id = SPEEX_INBAND_CHAR;
+   callback.func = speex_std_char_handler;
+   callback.data = stderr;
+   speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
+
+   callback.callback_id = SPEEX_INBAND_MODE_REQUEST;
+   callback.func = speex_std_mode_request_handler;
+   callback.data = st;
+   speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
+
    tmp=0;
-   /*speex_decoder_ctl(dec, SPEEX_SET_ENH, &tmp);
+   speex_decoder_ctl(dec, SPEEX_SET_ENH, &tmp);
    tmp=0;
    speex_encoder_ctl(st, SPEEX_SET_VBR, &tmp);
-   tmp=10;
+   tmp=7;
    speex_encoder_ctl(st, SPEEX_SET_QUALITY, &tmp);
-   tmp=3;
+   tmp=1;
    speex_encoder_ctl(st, SPEEX_SET_COMPLEXITY, &tmp);
-   tmp=3;
-   speex_encoder_ctl(st, SPEEX_SET_HIGH_MODE, &tmp);
-   tmp=6;
-   speex_encoder_ctl(st, SPEEX_SET_LOW_MODE, &tmp);
-   */
+
+   speex_mode_query(&speex_nb_mode, SPEEX_MODE_FRAME_SIZE, &tmp);
+   fprintf (stderr, "frame size: %d\n", tmp);
+   skip_group_delay = 509;
+
    if (argc != 4 && argc != 3)
-   { 
+   {
       fprintf (stderr, "Usage: encode [in file] [out file] [bits file]\nargc = %d", argc);
       exit(1);
    }
    inFile = argv[1];
    fin = fopen(inFile, "r");
    outFile = argv[2];
-   fout = fopen(outFile, "w");
+   fout = fopen(outFile, "w+");
    if (argc==4)
    {
       bitsFile = argv[3];
@@ -54,53 +79,58 @@
    speex_bits_init(&bits);
    while (!feof(fin))
    {
-      fread(in, sizeof(short), FRAME_SIZE, fin);
+      fread(in_short, sizeof(short), FRAME_SIZE, fin);
       if (feof(fin))
          break;
       for (i=0;i<FRAME_SIZE;i++)
-         bak[i]=input[i]=in[i];
+         in_float[i]=in_short[i];
       speex_bits_reset(&bits);
-      speex_encode(st, input, &bits);
+
+      speex_encode_int(st, in_short, &bits);
       nbBits = speex_bits_write(&bits, cbits, 200);
       bitCount+=bits.nbBits;
-      printf ("Encoding frame in %d bits\n", nbBits*8);
+
       if (argc==4)
          fwrite(cbits, 1, nbBits, fbits);
-      {
-         float enoise=0, esig=0, snr;
-         for (i=0;i<FRAME_SIZE;i++)
-         {
-            enoise+=(bak2[i]-input[i])*(bak2[i]-input[i]);
-            esig += bak2[i]*bak2[i];
-         }
-         snr = 10*log10((esig+1)/(enoise+1));
-         printf ("real SNR = %f\n", snr);
-      }
       speex_bits_rewind(&bits);
-      
-      speex_decode(dec, &bits, input);
 
-      /* Save the bits here */
-      for (i=0;i<FRAME_SIZE;i++)
-      {
-         if (input[i]>32000)
-            input[i]=32000;
-         else if (input[i]<-32000)
-            input[i]=-32000;
-      }
+      speex_decode_int(dec, &bits, out_short);
       speex_bits_reset(&bits);
-      for (i=0;i<FRAME_SIZE;i++)
-         in[i]=(short)input[i];
-      for (i=0;i<FRAME_SIZE;i++)
-         bak2[i]=bak[i];
-      fwrite(in, sizeof(short), FRAME_SIZE, fout);
+
+      fwrite(&out_short[skip_group_delay], sizeof(short), FRAME_SIZE-skip_group_delay, fout);
+      skip_group_delay = 0;
    }
-   
    fprintf (stderr, "Total encoded size: %d bits\n", bitCount);
    speex_encoder_destroy(st);
    speex_decoder_destroy(dec);
-   speex_bits_destroy(&bits);
+
+   rewind(fin);
+   rewind(fout);
+
+   while ( FRAME_SIZE == fread(in_short, sizeof(short), FRAME_SIZE, fin) 
+           &&
+           FRAME_SIZE ==  fread(out_short, sizeof(short), FRAME_SIZE,fout) )
+   {
+	float s=0, e=0;
+        for (i=0;i<FRAME_SIZE;++i) {
+            s += (float)in_short[i] * in_short[i];
+            e += ((float)in_short[i]-out_short[i]) * ((float)in_short[i]-out_short[i]);
+        }
+	seg_snr += 10*log10((s+1)/(e+1));
+	sigpow += s;
+	errpow += e;
+	snr_frames++;
+   }
    fclose(fin);
    fclose(fout);
+
+   snr = 10 * log10( sigpow / errpow );
+   seg_snr /= snr_frames;
+   fprintf(stderr,"SNR = %f\nsegmental SNR = %f\n",snr, seg_snr);
+
+#ifdef FIXED_DEBUG
+   printf ("Total: %f MIPS\n", (float)(1e-6*50*spx_mips/snr_frames));
+#endif
+   
    return 1;
 }

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/testenc_wb.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/testenc_wb.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/testenc_wb.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -1,15 +1,27 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <speex/speex.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <speex/speex_callbacks.h>
 
+#ifdef FIXED_DEBUG
+extern long long spx_mips;
+#endif
+
 #define FRAME_SIZE 320
 #include <math.h>
 int main(int argc, char **argv)
 {
    char *inFile, *outFile, *bitsFile;
    FILE *fin, *fout, *fbits=NULL;
-   short in[FRAME_SIZE];
-   float input[FRAME_SIZE], bak[FRAME_SIZE], bak2[FRAME_SIZE];
+   short in_short[FRAME_SIZE];
+   short out_short[FRAME_SIZE];
+   float in_float[FRAME_SIZE];
+   float sigpow,errpow,snr, seg_snr=0;
+   int snr_frames = 0;
    char cbits[200];
    int nbBits;
    int i;
@@ -18,34 +30,52 @@
    SpeexBits bits;
    int tmp;
    int bitCount=0;
+   int skip_group_delay;
+   SpeexCallback callback;
 
-   for (i=0;i<FRAME_SIZE;i++)
-      bak2[i]=0;
+   sigpow = 0;
+   errpow = 0;
+
    st = speex_encoder_init(&speex_wb_mode);
    dec = speex_decoder_init(&speex_wb_mode);
-   
+
+   callback.callback_id = SPEEX_INBAND_CHAR;
+   callback.func = speex_std_char_handler;
+   callback.data = stderr;
+   speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
+
+   callback.callback_id = SPEEX_INBAND_MODE_REQUEST;
+   callback.func = speex_std_mode_request_handler;
+   callback.data = st;
+   speex_decoder_ctl(dec, SPEEX_SET_HANDLER, &callback);
+
    tmp=0;
    speex_decoder_ctl(dec, SPEEX_SET_ENH, &tmp);
    tmp=0;
    speex_encoder_ctl(st, SPEEX_SET_VBR, &tmp);
-   tmp=10;
+   tmp=8;
    speex_encoder_ctl(st, SPEEX_SET_QUALITY, &tmp);
-   tmp=3;
+   tmp=2;
    speex_encoder_ctl(st, SPEEX_SET_COMPLEXITY, &tmp);
    tmp=3;
    speex_encoder_ctl(st, SPEEX_SET_HIGH_MODE, &tmp);
    tmp=6;
    speex_encoder_ctl(st, SPEEX_SET_LOW_MODE, &tmp);
-   
+
+
+   speex_mode_query(&speex_wb_mode, SPEEX_MODE_FRAME_SIZE, &tmp);
+   fprintf (stderr, "frame size: %d\n", tmp);
+   skip_group_delay = 223;
+
    if (argc != 4 && argc != 3)
-   { 
+   {
       fprintf (stderr, "Usage: encode [in file] [out file] [bits file]\nargc = %d", argc);
       exit(1);
    }
    inFile = argv[1];
    fin = fopen(inFile, "r");
    outFile = argv[2];
-   fout = fopen(outFile, "w");
+   fout = fopen(outFile, "w+");
    if (argc==4)
    {
       bitsFile = argv[3];
@@ -54,53 +84,58 @@
    speex_bits_init(&bits);
    while (!feof(fin))
    {
-      fread(in, sizeof(short), FRAME_SIZE, fin);
+      fread(in_short, sizeof(short), FRAME_SIZE, fin);
       if (feof(fin))
          break;
       for (i=0;i<FRAME_SIZE;i++)
-         bak[i]=input[i]=in[i];
+         in_float[i]=in_short[i];
       speex_bits_reset(&bits);
-      speex_encode(st, input, &bits);
+
+      speex_encode_int(st, in_short, &bits);
       nbBits = speex_bits_write(&bits, cbits, 200);
       bitCount+=bits.nbBits;
-      printf ("Encoding frame in %d bits\n", nbBits*8);
+
       if (argc==4)
          fwrite(cbits, 1, nbBits, fbits);
-      {
-         float enoise=0, esig=0, snr;
-         for (i=0;i<FRAME_SIZE;i++)
-         {
-            enoise+=(bak2[i]-input[i])*(bak2[i]-input[i]);
-            esig += bak2[i]*bak2[i];
-         }
-         snr = 10*log10((esig+1)/(enoise+1));
-         printf ("real SNR = %f\n", snr);
-      }
       speex_bits_rewind(&bits);
-      
-      speex_decode(dec, &bits, input);
 
-      /* Save the bits here */
-      for (i=0;i<FRAME_SIZE;i++)
-      {
-         if (input[i]>32000)
-            input[i]=32000;
-         else if (input[i]<-32000)
-            input[i]=-32000;
-      }
+      speex_decode_int(dec, &bits, out_short);
       speex_bits_reset(&bits);
-      for (i=0;i<FRAME_SIZE;i++)
-         in[i]=(short)input[i];
-      for (i=0;i<FRAME_SIZE;i++)
-         bak2[i]=bak[i];
-      fwrite(in, sizeof(short), FRAME_SIZE, fout);
+
+      fwrite(&out_short[skip_group_delay], sizeof(short), FRAME_SIZE-skip_group_delay, fout);
+      skip_group_delay = 0;
    }
-   
    fprintf (stderr, "Total encoded size: %d bits\n", bitCount);
    speex_encoder_destroy(st);
    speex_decoder_destroy(dec);
-   speex_bits_destroy(&bits);
+
+   rewind(fin);
+   rewind(fout);
+
+   while ( FRAME_SIZE == fread(in_short, sizeof(short), FRAME_SIZE, fin) 
+           &&
+           FRAME_SIZE ==  fread(out_short, sizeof(short), FRAME_SIZE,fout) )
+   {
+	float s=0, e=0;
+        for (i=0;i<FRAME_SIZE;++i) {
+            s += (float)in_short[i] * in_short[i];
+            e += ((float)in_short[i]-out_short[i]) * ((float)in_short[i]-out_short[i]);
+        }
+	seg_snr += 10*log10((s+160)/(e+160));
+	sigpow += s;
+	errpow += e;
+	snr_frames++;
+   }
    fclose(fin);
    fclose(fout);
+
+   snr = 10 * log10( sigpow / errpow );
+   seg_snr /= snr_frames;
+   fprintf(stderr,"SNR = %f\nsegmental SNR = %f\n",snr, seg_snr);
+
+#ifdef FIXED_DEBUG
+   printf ("Total: %f MIPS\n", (float)(1e-6*50*spx_mips/snr_frames));
+#endif
+   
    return 1;
 }

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/vbr.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/vbr.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/vbr.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -32,6 +32,10 @@
 
 */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include "vbr.h"
 #include <math.h>
 
@@ -42,7 +46,7 @@
 #define NOISE_POW .3
 
 
-float vbr_nb_thresh[9][11]={
+const float vbr_nb_thresh[9][11]={
    {-1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}, /*   CNG   */
    { 3.5,  2.5,  2.0,  1.2,  0.5,  0.0, -0.5, -0.7, -0.8, -0.9, -1.0}, /*  2 kbps */
    {10.0,  6.5,  5.2,  4.5,  3.9,  3.5,  3.0,  2.5,  2.3,  1.8,  1.0}, /*  6 kbps */
@@ -55,7 +59,7 @@
 };
 
 
-float vbr_hb_thresh[5][11]={
+const float vbr_hb_thresh[5][11]={
    {-1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}, /* silence */
    {-1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}, /*  2 kbps */
    {11.0, 11.0,  9.5,  8.5,  7.5,  6.0,  5.0,  3.9,  3.0,  2.0,  1.0}, /*  6 kbps */
@@ -63,7 +67,7 @@
    {11.0, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0,  9.8,  7.5,  5.5}  /* 18 kbps */ 
 };
 
-float vbr_uhb_thresh[2][11]={
+const float vbr_uhb_thresh[2][11]={
    {-1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0}, /* silence */
    { 3.9,  2.5,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0, -1.0}  /*  2 kbps */
 };
@@ -116,7 +120,7 @@
 
 */
 
-float vbr_analysis(VBRState *vbr, float *sig, int len, int pitch, float pitch_coef)
+float vbr_analysis(VBRState *vbr, spx_word16_t *sig, int len, int pitch, float pitch_coef)
 {
    int i;
    float ener=0, ener1=0, ener2=0;
@@ -128,10 +132,10 @@
    float pow_ener;
 
    for (i=0;i<len>>1;i++)
-      ener1 += sig[i]*sig[i];
+      ener1 += ((float)sig[i])*sig[i];
 
    for (i=len>>1;i<len;i++)
-      ener2 += sig[i]*sig[i];
+      ener2 += ((float)sig[i])*sig[i];
    ener=ener1+ener2;
 
    log_energy = log(ener+MIN_ENERGY);

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/vbr.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/vbr.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/vbr.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -36,11 +36,13 @@
 #ifndef VBR_H
 #define VBR_H
 
+#include "misc.h"
+
 #define VBR_MEMORY_SIZE 5
 
-extern float vbr_nb_thresh[9][11];
-extern float vbr_hb_thresh[5][11];
-extern float vbr_uhb_thresh[2][11];
+extern const float vbr_nb_thresh[9][11];
+extern const float vbr_hb_thresh[5][11];
+extern const float vbr_uhb_thresh[2][11];
 
 typedef struct VBRState {
    float energy_alpha;
@@ -59,7 +61,7 @@
 
 void vbr_init(VBRState *vbr);
 
-float vbr_analysis(VBRState *vbr, float *sig, int len, int pitch, float pitch_coef);
+float vbr_analysis(VBRState *vbr, spx_word16_t *sig, int len, int pitch, float pitch_coef);
 
 void vbr_destroy(VBRState *vbr);
 

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/vq.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/vq.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/vq.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -30,10 +30,47 @@
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include "vq.h"
+#include "stack_alloc.h"
+#include "misc.h"
 
+#ifdef _USE_SSE
+#include <xmmintrin.h>
+#elif defined(SHORTCUTS) && (defined(ARM4_ASM) || defined(ARM5E_ASM))
+#include "vq_arm4.h"
+#elif defined(BFIN_ASM)
+#include "vq_bfin.h"
+#endif
+
+
+int scal_quant(spx_word16_t in, const spx_word16_t *boundary, int entries)
+{
+   int i=0;
+   while (i<entries-1 && in>boundary[0])
+   {
+      boundary++;
+      i++;
+   }
+   return i;
+}
+
+int scal_quant32(spx_word32_t in, const spx_word32_t *boundary, int entries)
+{
+   int i=0;
+   while (i<entries-1 && in>boundary[0])
+   {
+      boundary++;
+      i++;
+   }
+   return i;
+}
+
 /*Finds the index of the entry in a codebook that best matches the input*/
-int vq_index(float *in, float *codebook, int len, int entries)
+int vq_index(float *in, const float *codebook, int len, int entries)
 {
    int i,j;
    float min_dist=0;
@@ -56,16 +93,22 @@
 }
 
 
+#ifndef OVERRIDE_VQ_NBEST
 /*Finds the indices of the n-best entries in a codebook*/
-void vq_nbest(float *in, float *codebook, int len, int entries, float *E, int N, int *nbest, float *best_dist)
+void vq_nbest(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack)
 {
    int i,j,k,used;
    used = 0;
    for (i=0;i<entries;i++)
    {
-      float dist=.5*E[i];
+      spx_word32_t dist=0;
       for (j=0;j<len;j++)
-         dist -= in[j]**codebook++;
+         dist = MAC16_16(dist,in[j],*codebook++);
+#ifdef FIXED_POINT
+      dist=SUB32(SHR32(E[i],1),dist);
+#else
+      dist=.5f*E[i]-dist;
+#endif
       if (i<N || dist<best_dist[N-1])
       {
          for (k=N-1; (k >= 1) && (k > used || dist < best_dist[k-1]); k--)
@@ -79,26 +122,35 @@
       }
    }
 }
+#endif
 
+
+
+
+#ifndef OVERRIDE_VQ_NBEST_SIGN
 /*Finds the indices of the n-best entries in a codebook with sign*/
-void vq_nbest_sign(float *in, float *codebook, int len, int entries, float *E, int N, int *nbest, float *best_dist)
+void vq_nbest_sign(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack)
 {
    int i,j,k, sign, used;
    used=0;
    for (i=0;i<entries;i++)
    {
-      float dist=0;
+      spx_word32_t dist=0;
       for (j=0;j<len;j++)
-         dist -= in[j]**codebook++;
+         dist = MAC16_16(dist,in[j],*codebook++);
       if (dist>0)
       {
-         sign=1;
+         sign=0;
          dist=-dist;
       } else
       {
-         sign=0;
+         sign=1;
       }
-      dist += .5*E[i];
+#ifdef FIXED_POINT
+      dist = ADD32(dist,SHR32(E[i],1));
+#else
+      dist = ADD32(dist,.5f*E[i]);
+#endif
       if (i<N || dist<best_dist[N-1])
       {
          for (k=N-1; (k >= 1) && (k > used || dist < best_dist[k-1]); k--)
@@ -114,3 +166,4 @@
       }
    }
 }
+#endif

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/vq.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/vq.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/vq.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -33,10 +33,21 @@
 #ifndef VQ_H
 #define VQ_H
 
-int vq_index(float *in, float *codebook, int len, int entries);
+#include "misc.h"
 
-void vq_nbest(float *in, float *codebook, int len, int entries, float *E, int N, int *nbest, float *best_dist);
+int scal_quant(spx_word16_t in, const spx_word16_t *boundary, int entries);
+int scal_quant32(spx_word32_t in, const spx_word32_t *boundary, int entries);
 
-void vq_nbest_sign(float *in, float *codebook, int len, int entries, float *E, int N, int *nbest, float *best_dist);
+int vq_index(float *in, const float *codebook, int len, int entries);
+#ifdef _USE_SSE
+#include <xmmintrin.h>
+void vq_nbest(spx_word16_t *in, const __m128 *codebook, int len, int entries, __m128 *E, int N, int *nbest, spx_word32_t *best_dist, char *stack);
 
+void vq_nbest_sign(spx_word16_t *in, const __m128 *codebook, int len, int entries, __m128 *E, int N, int *nbest, spx_word32_t *best_dist, char *stack);
+#else
+void vq_nbest(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack);
+
+void vq_nbest_sign(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack);
 #endif
+
+#endif

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/vq_arm4.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/vq_arm4.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/vq_arm4.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,113 @@
+/* Copyright (C) 2004 Jean-Marc Valin 
+   File: vq_arm4.h
+   ARM4-optimized vq routine
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+   
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+   
+   - Neither the name of the Xiph.org Foundation nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+   
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#define OVERRIDE_VQ_NBEST
+void vq_nbest(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack)
+{
+   int i,j;
+   for (i=0;i<entries;i+=4)
+   {
+#if 1
+      spx_word32_t dist1, dist2, dist3, dist4;
+      int dead1, dead2, dead3, dead4, dead5, dead6, dead7, dead8;
+      __asm__ __volatile__ (
+            "mov %0, #0 \n\t"
+            "mov %1, #0 \n\t"
+            "mov %2, #0 \n\t"
+            "mov %3, #0 \n\t"
+            "mov %10, %4 \n\t"
+            "add %4, %4, %4\n\t"
+            ".vqloop%=:\n\t"
+            "ldrsh %7, [%5], #2 \n\t"
+            "ldrsh %8, [%6] \n\t"
+            "mov %9, %6 \n\t"
+            "mla %0, %7, %8, %0 \n\t"
+            "ldrsh %8, [%9, %4]! \n\t"
+            "mla %1, %7, %8, %1 \n\t"
+            "ldrsh %8, [%9, %4]!\n\t"
+            "mla %2, %7, %8, %2 \n\t"
+            "ldrsh %8, [%9, %4]! \n\t"
+            "mla %3, %7, %8, %3 \n\t"
+            "subs %10, %10, #1 \n\t"
+            "add %6, %6, #2 \n\t"
+            "bne .vqloop%="
+         : "=r" (dist1), "=r" (dist2), "=r" (dist3), "=r" (dist4),
+      "=r" (dead1), "=r" (dead2), "=r" (codebook), "=r" (dead4),
+      "=r" (dead5), "=r" (dead6), "=r" (dead7)
+         : "4" (len), "5" (in), "6" (codebook)
+         : "cc");
+#else
+dist1=dist2=dist3=dist4=0;
+   /*   spx_word32_t dist1=0;
+      spx_word32_t dist2=0;
+      spx_word32_t dist3=0;
+      spx_word32_t dist4=0;*/
+      for (j=0;j<2;j++)
+      {
+         const spx_word16_t *code = codebook;
+         dist1 = MAC16_16(dist1,in[j],*code);
+         code += len;
+         dist2 = MAC16_16(dist2,in[j],*code);
+         code += len;
+         dist3 = MAC16_16(dist3,in[j],*code);
+         code += len;
+         dist4 = MAC16_16(dist4,in[j],*code);
+         codebook++;
+      }
+#endif
+      dist1=SUB32(SHR(*E++,1),dist1);
+      if (dist1<*best_dist || i==0)
+      {
+         *best_dist=dist1;
+         *nbest=i;
+      }
+      dist2=SUB32(SHR(*E++,1),dist2);
+      if (dist2<*best_dist)
+      {
+         *best_dist=dist2;
+         *nbest=i+1;
+      }
+      dist3=SUB32(SHR(*E++,1),dist3);
+      if (dist3<*best_dist)
+      {
+         *best_dist=dist3;
+         *nbest=i+2;
+      }
+      dist4=SUB32(SHR(*E++,1),dist4);
+      if (dist4<*best_dist)
+      {
+         *best_dist=dist4;
+         *nbest=i+3;
+      }
+      codebook += 3*len;
+   }
+}
\ No newline at end of file

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/vq_bfin.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/vq_bfin.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/vq_bfin.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,105 @@
+/* Copyright (C) 2005 Analog Devices
+   Author:  Jean-Marc Valin 
+   File: vq_arm4.h
+   Blackfin-optimized vq routine
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+   
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+   
+   - Neither the name of the Xiph.org Foundation nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+   
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#define OVERRIDE_VQ_NBEST
+void vq_nbest(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack)
+{
+   if (N==1)
+   {
+      best_dist[0] = 2147483647;
+      {
+         spx_word32_t dist;
+         __asm__ __volatile__
+               (
+            "LC0 = %8;\n\t"
+            "R2 = 0;\n\t"
+            "I0 = %6;\n\t"
+            "B0 = %6;\n\t"
+            "L0 = %9;\n\t"
+            "LOOP entries_loop%= LC0;\n\t"
+            "LOOP_BEGIN entries_loop%=;\n\t"
+               "%0 = [%4++];\n\t"
+               "%0 >>= 1;\n\t"
+               "A0 = %0;\n\t"
+               "R0.L = W[%1++%7] || R1.L = W[I0++];\n\t"
+               "LOOP vq_loop%= LC1 = %5;\n\t"
+               "LOOP_BEGIN vq_loop%=;\n\t"
+                  "%0 = (A0 -= R0.L*R1.L) (IS) || R0.L = W[%1++%7] || R1.L = W[I0++];\n\t"
+               "LOOP_END vq_loop%=;\n\t"
+               "%0 = (A0 -= R0.L*R1.L) (IS);\n\t"
+               "cc = %0 < %2;\n\t"
+               "if cc %2 = %0;\n\t"
+               "if cc %3 = R2;\n\t"
+               "R2 += 1;\n\t"
+            "LOOP_END entries_loop%=;\n\t"
+            : "=&D" (dist), "=&a" (codebook), "=&d" (best_dist[0]), "=&d" (nbest[0]), "=&a" (E)
+            : "a" (len-1), "a" (in), "a" (2), "d" (entries), "d" (len<<1), "1" (codebook), "4" (E), "2" (best_dist[0]), "3" (nbest[0])
+            : "R0", "R1", "R2", "I0", "L0", "B0", "A0", "cc", "memory"
+               );
+      }
+   } else {
+   int i,k,used;
+   used = 0;
+   for (i=0;i<entries;i++)
+   {
+      spx_word32_t dist;
+      __asm__
+            (
+            "%0 >>= 1;\n\t"
+            "A0 = %0;\n\t"
+            "I0 = %3;\n\t"
+            "L0 = 0;\n\t"
+            "R0.L = W[%1++%4] || R1.L = W[I0++];\n\t"
+            "LOOP vq_loop%= LC0 = %2;\n\t"
+            "LOOP_BEGIN vq_loop%=;\n\t"
+               "%0 = (A0 -= R0.L*R1.L) (IS) || R0.L = W[%1++%4] || R1.L = W[I0++];\n\t"
+            "LOOP_END vq_loop%=;\n\t"
+            "%0 = (A0 -= R0.L*R1.L) (IS);\n\t"
+         : "=D" (dist), "=a" (codebook)
+         : "a" (len-1), "a" (in), "a" (2), "1" (codebook), "0" (E[i])
+         : "R0", "R1", "I0", "L0", "A0"
+            );
+      if (i<N || dist<best_dist[N-1])
+      {
+         for (k=N-1; (k >= 1) && (k > used || dist < best_dist[k-1]); k--)
+         {
+            best_dist[k]=best_dist[k-1];
+            nbest[k] = nbest[k-1];
+         }
+         best_dist[k]=dist;
+         nbest[k]=i;
+         used++;
+      }
+   }
+   }
+}

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/vq_sse.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/vq_sse.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/libspeex/vq_sse.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,118 @@
+/* Copyright (C) 2004 Jean-Marc Valin 
+   File: vq_arm4.h
+   ARM4-optimized vq routine
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+   
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+   
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+   
+   - Neither the name of the Xiph.org Foundation nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+   
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#define OVERRIDE_VQ_NBEST
+void vq_nbest(spx_word16_t *_in, const __m128 *codebook, int len, int entries, __m128 *E, int N, int *nbest, spx_word32_t *best_dist, char *stack)
+{
+   int i,j,k,used;
+   VARDECL(float *dist);
+   VARDECL(__m128 *in);
+   __m128 half;
+   used = 0;
+   ALLOC(dist, entries, float);
+   half = _mm_set_ps1(.5f);
+   ALLOC(in, len, __m128);
+   for (i=0;i<len;i++)
+      in[i] = _mm_set_ps1(_in[i]);
+   for (i=0;i<entries>>2;i++)
+   {
+      __m128 d = _mm_mul_ps(E[i], half);
+      for (j=0;j<len;j++)
+         d = _mm_sub_ps(d, _mm_mul_ps(in[j], *codebook++));
+      _mm_storeu_ps(dist+4*i, d);
+   }
+   for (i=0;i<entries;i++)
+   {
+      if (i<N || dist[i]<best_dist[N-1])
+      {
+         for (k=N-1; (k >= 1) && (k > used || dist[i] < best_dist[k-1]); k--)
+         {
+            best_dist[k]=best_dist[k-1];
+            nbest[k] = nbest[k-1];
+         }
+         best_dist[k]=dist[i];
+         nbest[k]=i;
+         used++;
+      }
+   }
+}
+
+
+
+
+#define OVERRIDE_VQ_NBEST_SIGN
+void vq_nbest_sign(spx_word16_t *_in, const __m128 *codebook, int len, int entries, __m128 *E, int N, int *nbest, spx_word32_t *best_dist, char *stack)
+{
+   int i,j,k,used;
+   VARDECL(float *dist);
+   VARDECL(__m128 *in);
+   __m128 half;
+   used = 0;
+   ALLOC(dist, entries, float);
+   half = _mm_set_ps1(.5f);
+   ALLOC(in, len, __m128);
+   for (i=0;i<len;i++)
+      in[i] = _mm_set_ps1(_in[i]);
+   for (i=0;i<entries>>2;i++)
+   {
+      __m128 d = _mm_setzero_ps();
+      for (j=0;j<len;j++)
+         d = _mm_add_ps(d, _mm_mul_ps(in[j], *codebook++));
+      _mm_storeu_ps(dist+4*i, d);
+   }
+   for (i=0;i<entries;i++)
+   {
+      int sign;
+      if (dist[i]>0)
+      {
+         sign=0;
+         dist[i]=-dist[i];
+      } else
+      {
+         sign=1;
+      }
+      dist[i] += .5f*((float*)E)[i];
+      if (i<N || dist[i]<best_dist[N-1])
+      {
+         for (k=N-1; (k >= 1) && (k > used || dist[i] < best_dist[k-1]); k--)
+         {
+            best_dist[k]=best_dist[k-1];
+            nbest[k] = nbest[k-1];
+         }
+         best_dist[k]=dist[i];
+         nbest[k]=i;
+         used++;
+         if (sign)
+            nbest[k]+=entries;
+      }
+   }
+}

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/ltmain.sh
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/ltmain.sh	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/ltmain.sh	2005-10-20 12:42:06 UTC (rev 10202)
@@ -44,7 +44,7 @@
 PROGRAM=ltmain.sh
 PACKAGE=libtool
 VERSION=1.5.6
-TIMESTAMP=" (1.1220.2.95 2004/04/11 05:50:42) Debian$Rev: 215 $"
+TIMESTAMP=" (1.1220.2.95 2004/04/11 05:50:42) Debian$Rev: 224 $"
 
 
 # Check that we have a working $echo.
@@ -1867,10 +1867,6 @@
 	    $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
 	    continue
 	  fi
-	  if test "$pass" = conv; then
-	    deplibs="$deplib $deplibs"
-	    continue
-	  fi
 	  name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
 	  for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
 	    for search_ext in .la $std_shrext .so .a; do
@@ -2949,7 +2945,7 @@
 
 	# Check that each of the things are valid numbers.
 	case $current in
-	0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
+	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
 	*)
 	  $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2
 	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
@@ -2958,7 +2954,7 @@
 	esac
 
 	case $revision in
-	0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
+	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
 	*)
 	  $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2
 	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
@@ -2967,7 +2963,7 @@
 	esac
 
 	case $age in
-	0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
+	0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
 	*)
 	  $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2
 	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/missing
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/missing	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/missing	2005-10-20 12:42:06 UTC (rev 10202)
@@ -1,10 +1,6 @@
 #! /bin/sh
 # Common stub for a few missing GNU programs while installing.
-
-scriptversion=2003-09-02.23
-
-# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003 
-#   Free Software Foundation, Inc.
+# Copyright (C) 1996, 1997, 1999, 2000, 2002 Free Software Foundation, Inc.
 # Originally by Fran,cois Pinard <pinard at iro.umontreal.ca>, 1996.
 
 # This program is free software; you can redistribute it and/or modify
@@ -42,23 +38,12 @@
   configure_ac=configure.in
 fi
 
-msg="missing on your system"
-
 case "$1" in
 --run)
   # Try to run requested program, and just exit if it succeeds.
   run=
   shift
   "$@" && exit 0
-  # Exit code 63 means version mismatch.  This often happens
-  # when the user try to use an ancient version of a tool on
-  # a file that requires a minimum version.  In this case we
-  # we should proceed has if the program had been absent, or
-  # if --run hadn't been passed.
-  if test $? = 63; then
-    run=:
-    msg="probably too old"
-  fi
   ;;
 esac
 
@@ -89,13 +74,11 @@
   lex          create \`lex.yy.c', if possible, from existing .c
   makeinfo     touch the output file
   tar          try tar, gnutar, gtar, then tar without non-portable flags
-  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
-
-Send bug reports to <bug-automake at gnu.org>."
+  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]"
     ;;
 
   -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
-    echo "missing $scriptversion (GNU Automake)"
+    echo "missing 0.4 - GNU automake"
     ;;
 
   -*)
@@ -111,7 +94,7 @@
     fi
 
     echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
+WARNING: \`$1' is missing on your system.  You should only need it if
          you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
          to install the \`Automake' and \`Perl' packages.  Grab them from
          any GNU archive site."
@@ -125,7 +108,7 @@
     fi
 
     echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
+WARNING: \`$1' is missing on your system.  You should only need it if
          you modified \`${configure_ac}'.  You might want to install the
          \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
          archive site."
@@ -139,7 +122,7 @@
     fi
 
     echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
+WARNING: \`$1' is missing on your system.  You should only need it if
          you modified \`acconfig.h' or \`${configure_ac}'.  You might want
          to install the \`Autoconf' and \`GNU m4' packages.  Grab them
          from any GNU archive site."
@@ -163,7 +146,7 @@
     fi
 
     echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
+WARNING: \`$1' is missing on your system.  You should only need it if
          you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
          You might want to install the \`Automake' and \`Perl' packages.
          Grab them from any GNU archive site."
@@ -179,10 +162,10 @@
     fi
 
     echo 1>&2 "\
-WARNING: \`$1' is needed, but is $msg.
-         You might have modified some files without having the
+WARNING: \`$1' is needed, and you do not seem to have it handy on your
+         system.  You might have modified some files without having the
          proper tools for further handling them.
-         You can get \`$1' as part of \`Autoconf' from any GNU
+         You can get \`$1Help2man' as part of \`Autoconf' from any GNU
          archive site."
 
     file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
@@ -202,7 +185,7 @@
 
   bison|yacc)
     echo 1>&2 "\
-WARNING: \`$1' $msg.  You should only need it if
+WARNING: \`$1' is missing on your system.  You should only need it if
          you modified a \`.y' file.  You may need the \`Bison' package
          in order for those modifications to take effect.  You can get
          \`Bison' from any GNU archive site."
@@ -232,7 +215,7 @@
 
   lex|flex)
     echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
+WARNING: \`$1' is missing on your system.  You should only need it if
          you modified a \`.l' file.  You may need the \`Flex' package
          in order for those modifications to take effect.  You can get
          \`Flex' from any GNU archive site."
@@ -260,7 +243,7 @@
     fi
 
     echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
+WARNING: \`$1' is missing on your system.  You should only need it if
 	 you modified a dependency of a manual page.  You may need the
 	 \`Help2man' package in order for those modifications to take
 	 effect.  You can get \`Help2man' from any GNU archive site."
@@ -285,7 +268,7 @@
     fi
 
     echo 1>&2 "\
-WARNING: \`$1' is $msg.  You should only need it if
+WARNING: \`$1' is missing on your system.  You should only need it if
          you modified a \`.texi' or \`.texinfo' file, or any other file
          indirectly affecting the aspect of the manual.  The spurious
          call might also be the consequence of using a buggy \`make' (AIX,
@@ -340,10 +323,10 @@
 
   *)
     echo 1>&2 "\
-WARNING: \`$1' is needed, and is $msg.
-         You might have modified some files without having the
+WARNING: \`$1' is needed, and you do not seem to have it handy on your
+         system.  You might have modified some files without having the
          proper tools for further handling them.  Check the \`README' file,
-         it often tells you about the needed prerequisites for installing
+         it often tells you about the needed prerequirements for installing
          this package.  You may also peek at any GNU archive site, in case
          some other package would contain this missing \`$1' program."
     exit 1
@@ -351,10 +334,3 @@
 esac
 
 exit 0
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
-# End:

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/speex.m4
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/speex.m4	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/speex.m4	2005-10-20 12:42:06 UTC (rev 10202)
@@ -7,7 +7,7 @@
 dnl XIPH_PATH_SPEEX([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
 dnl Test for libspeex, and define SPEEX_CFLAGS and SPEEX_LIBS
 dnl
-AC_DEFUN(XIPH_PATH_SPEEX,
+AC_DEFUN([XIPH_PATH_SPEEX],
 [dnl 
 dnl Get the cflags and libraries
 dnl

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/speex.pc.in
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/speex.pc.in	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/speex.pc.in	2005-10-20 12:42:06 UTC (rev 10202)
@@ -1,4 +1,4 @@
-# libogg pkg-config source file
+# libspeex pkg-config source file
 
 prefix=@prefix@
 exec_prefix=@exec_prefix@
@@ -8,7 +8,7 @@
 Name: speex
 Description: Speex is an audio codec tuned for speech
 Version: @SPEEX_VERSION@
-Requires: ogg
+Requires:
 Conflicts:
 Libs: -L${libdir} -lspeex
 Cflags: -I${includedir}

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/Makefile.am
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/Makefile.am	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/Makefile.am	2005-10-20 12:42:06 UTC (rev 10202)
@@ -1,11 +1,11 @@
 ## Process this file with automake to produce Makefile.in. -*-Makefile-*-
 
-# $Id: Makefile.am,v 1.9.2.1 2003/05/31 06:10:43 jm Exp $
+# $Id: Makefile.am,v 1.11 2004/02/18 06:59:40 jm Exp $
 
 # Disable automatic dependency tracking if using other tools than gcc and gmake
 #AUTOMAKE_OPTIONS = no-dependencies
 
-INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/libspeex  $(OGG_INCLUDES)
+INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_builddir) @OGG_CFLAGS@
 
 mandir = $(prefix)/share/man
 man_MANS = speexenc.1 speexdec.1
@@ -18,7 +18,9 @@
 bin_PROGRAMS = speexenc speexdec
 
 speexenc_SOURCES = speexenc.c wav_io.c
-speexenc_LDADD = $(top_builddir)/libspeex/libspeex.la $(OGG_LDFLAGS) $(OGG_LIBS)
+speexenc_LDADD = $(top_builddir)/libspeex/libspeex.la \
+	$(OGG_LIBS)
 
 speexdec_SOURCES = speexdec.c wav_io.c
-speexdec_LDADD = $(top_builddir)/libspeex/libspeex.la $(OGG_LDFLAGS) $(OGG_LIBS)
+speexdec_LDADD = $(top_builddir)/libspeex/libspeex.la \
+	$(OGG_LIBS)

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/Makefile.in
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/Makefile.in	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/Makefile.in	2005-10-20 12:42:06 UTC (rev 10202)
@@ -14,7 +14,7 @@
 
 @SET_MAKE@
 
-# $Id: Makefile.am,v 1.9.2.1 2003/05/31 06:10:43 jm Exp $
+# $Id: Makefile.am,v 1.11 2004/02/18 06:59:40 jm Exp $
 
 # Disable automatic dependency tracking if using other tools than gcc and gmake
 #AUTOMAKE_OPTIONS = no-dependencies
@@ -49,10 +49,11 @@
 	$(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(includedir)"
 binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
@@ -61,12 +62,12 @@
 speexdec_OBJECTS = $(am_speexdec_OBJECTS)
 am__DEPENDENCIES_1 =
 speexdec_DEPENDENCIES = $(top_builddir)/libspeex/libspeex.la \
-	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+	$(am__DEPENDENCIES_1)
 am_speexenc_OBJECTS = speexenc.$(OBJEXT) wav_io.$(OBJEXT)
 speexenc_OBJECTS = $(am_speexenc_OBJECTS)
 speexenc_DEPENDENCIES = $(top_builddir)/libspeex/libspeex.la \
-	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
-DEFAULT_INCLUDES = -I. -I$(srcdir)
+	$(am__DEPENDENCIES_1)
+DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
 @AMDEP_TRUE at DEP_FILES = ./$(DEPDIR)/speexdec.Po \
@@ -133,8 +134,7 @@
 MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 OBJEXT = @OBJEXT@
-OGG_INCLUDES = @OGG_INCLUDES@
-OGG_LDFLAGS = @OGG_LDFLAGS@
+OGG_CFLAGS = @OGG_CFLAGS@
 OGG_LIBS = @OGG_LIBS@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -146,9 +146,12 @@
 RANLIB = @RANLIB@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
+SIZE16 = @SIZE16@
+SIZE32 = @SIZE32@
 SPEEX_LT_AGE = @SPEEX_LT_AGE@
 SPEEX_LT_CURRENT = @SPEEX_LT_CURRENT@
 SPEEX_LT_REVISION = @SPEEX_LT_REVISION@
+SPEEX_VERSION = @SPEEX_VERSION@
 STRIP = @STRIP@
 VERSION = @VERSION@
 ac_ct_AR = @ac_ct_AR@
@@ -193,15 +196,19 @@
 src = @src@
 sysconfdir = @sysconfdir@
 target_alias = @target_alias@
-INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/libspeex  $(OGG_INCLUDES)
+INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_builddir) @OGG_CFLAGS@
 man_MANS = speexenc.1 speexdec.1
 EXTRA_DIST = $(man_MANS) getopt_win.h getopt.c getopt1.c wave_out.c wave_out.h
 include_HEADERS = 
 noinst_HEADERS = wav_io.h
 speexenc_SOURCES = speexenc.c wav_io.c
-speexenc_LDADD = $(top_builddir)/libspeex/libspeex.la $(OGG_LDFLAGS) $(OGG_LIBS)
+speexenc_LDADD = $(top_builddir)/libspeex/libspeex.la \
+	$(OGG_LIBS)
+
 speexdec_SOURCES = speexdec.c wav_io.c
-speexdec_LDADD = $(top_builddir)/libspeex/libspeex.la $(OGG_LDFLAGS) $(OGG_LIBS)
+speexdec_LDADD = $(top_builddir)/libspeex/libspeex.la \
+	$(OGG_LIBS)
+
 all: all-am
 
 .SUFFIXES:

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/speexdec.1
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/speexdec.1	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/speexdec.1	2005-10-20 12:42:06 UTC (rev 10202)
@@ -1,7 +1,7 @@
 .\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.29.
-.TH SPEEXDEC "1" "September 2003" "speexdec version 1.0.3" "User Commands"
+.TH SPEEXDEC "1" "September 2003" "speexdec version 1.1" "User Commands"
 .SH NAME
-speexdec \- manual page for speexdec version 1.0.3
+speexdec \- manual page for speexdec version 1.1
 .SH SYNOPSIS
 .B speexdec
 [\fIoptions\fR] \fIinput_file.spx \fR[\fIoutput_file\fR]

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/speexdec.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/speexdec.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/speexdec.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -29,11 +29,18 @@
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <stdio.h>
 #if !defined WIN32 && !defined _WIN32
 #include <unistd.h>
 #include <getopt.h>
 #endif
+#ifndef HAVE_GETOPT_LONG
+#include "getopt_win.h"
+#endif
 #include <stdlib.h>
 #include <string.h>
 
@@ -77,7 +84,7 @@
 #include <speex/speex_header.h>
 #include <speex/speex_stereo.h>
 #include <speex/speex_callbacks.h>
-#include "misc.h"
+#include "wav_io.h"
 
 #define MAX_FRAME_SIZE 2000
 
@@ -295,7 +302,7 @@
 static void *process_header(ogg_packet *op, int enh_enabled, int *frame_size, int *rate, int *nframes, int forceMode, int *channels, SpeexStereoState *stereo, int *extra_headers, int quiet)
 {
    void *st;
-   SpeexMode *mode;
+   const SpeexMode *mode;
    SpeexHeader *header;
    int modeID;
    SpeexCallback callback;
@@ -316,7 +323,8 @@
    modeID = header->mode;
    if (forceMode!=-1)
       modeID = forceMode;
-   mode = speex_mode_list[modeID];
+
+   mode = speex_lib_get_mode (modeID);
    
    if (header->speex_version_id > 1)
    {
@@ -400,7 +408,7 @@
    char *inFile, *outFile;
    FILE *fin, *fout=NULL;
    short out[MAX_FRAME_SIZE];
-   float output[MAX_FRAME_SIZE];
+   short output[MAX_FRAME_SIZE];
    int frame_size=0;
    void *st=NULL;
    SpeexBits bits;
@@ -541,7 +549,7 @@
       outFile = "";
    wav_format = strlen(outFile)>=4 && (
                                        strcmp(outFile+strlen(outFile)-4,".wav")==0
-                                       || strcmp(inFile+strlen(inFile)-4,".WAV")==0);
+                                       || strcmp(outFile+strlen(outFile)-4,".WAV")==0);
    /*Open input file*/
    if (strcmp(inFile, "-")==0)
    {
@@ -624,7 +632,7 @@
             {
                /* Ignore extra headers */
             } else {
-               int lost=0;
+               int lost=0;
                packet_no++;
                if (loss_percent>0 && 100*((float)rand())/RAND_MAX<loss_percent)
                   lost=1;
@@ -640,10 +648,13 @@
                   int ret;
                   /*Decode frame*/
                   if (!lost)
-                     ret = speex_decode(st, &bits, output);
+                     ret = speex_decode_int(st, &bits, output);
                   else
-                     ret = speex_decode(st, NULL, output);
+                     ret = speex_decode_int(st, NULL, output);
 
+                  /*for (i=0;i<frame_size*channels;i++)
+                    printf ("%d\n", (int)output[i]);*/
+
                   if (ret==-1)
                      break;
                   if (ret==-2)
@@ -657,7 +668,7 @@
                      break;
                   }
                   if (channels==2)
-                     speex_decode_stereo(output, frame_size, &stereo);
+                     speex_decode_stereo_int(output, frame_size, &stereo);
 
                   if (print_bitrate) {
                      int tmp;
@@ -666,22 +677,14 @@
                      fputc (ch, stderr);
                      fprintf (stderr, "Bitrate is use: %d bps     ", tmp);
                   }
-                  /*PCM saturation (just in case)*/
-                  for (i=0;i<frame_size*channels;i++)
-                  {
-                     if (output[i]>32000.0)
-                        output[i]=32000.0;
-                     else if (output[i]<-32000.0)
-                        output[i]=-32000.0;
-                  }
                   /*Convert to short and save to output file*/
 		  if (strlen(outFile)!=0)
                   {
                      for (i=0;i<frame_size*channels;i++)
-                        out[i]=(short)le_short((short)floor(.5+output[i]));
+                        out[i]=le_short(output[i]);
 		  } else {
                      for (i=0;i<frame_size*channels;i++)
-                        out[i]=(short)floor(.5+output[i]);
+                        out[i]=output[i];
 		  }
                   {
                      int frame_offset = 0;

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/speexenc.1
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/speexenc.1	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/speexenc.1	2005-10-20 12:42:06 UTC (rev 10202)
@@ -1,7 +1,7 @@
 .\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.29.
-.TH SPEEXENC "1" "September 2003" "speexenc version 1.0.3" "User Commands"
+.TH SPEEXENC "1" "September 2003" "speexenc version 1.1" "User Commands"
 .SH NAME
-speexenc \- manual page for speexenc version 1.0.3
+speexenc \- manual page for speexenc version 1.1
 .SH SYNOPSIS
 .B speexenc
 [\fIoptions\fR] \fIinput_file output_file\fR

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/speexenc.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/speexenc.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/speexenc.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -29,11 +29,18 @@
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <stdio.h>
 #if !defined WIN32 && !defined _WIN32
 #include <unistd.h>
 #include <getopt.h>
 #endif
+#ifndef HAVE_GETOPT_LONG
+#include "getopt_win.h"
+#endif
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
@@ -43,7 +50,7 @@
 #include "wav_io.h"
 #include <speex/speex_header.h>
 #include <speex/speex_stereo.h>
-#include "misc.h"
+#include <speex/speex_preprocess.h>
 
 #if defined WIN32 || defined _WIN32
 #include "getopt_win.h"
@@ -71,7 +78,7 @@
 #define MAX_FRAME_BYTES 2000
 
 /* Convert input audio bits, endians and channels */
-static int read_samples(FILE *fin,int frame_size, int bits, int channels, int lsb, float * input, char *buff, int *size)
+static int read_samples(FILE *fin,int frame_size, int bits, int channels, int lsb, short * input, char *buff, int *size)
 {   
    unsigned char in[MAX_FRAME_BYTES*2];
    int i;
@@ -176,6 +183,8 @@
    printf (" --dtx              Enable file-based discontinuous transmission (DTX)\n"); 
    printf (" --comp n           Set encoding complexity (0-10), default 3\n"); 
    printf (" --nframes n        Number of frames per Ogg packet (1-10), default 1\n"); 
+   printf (" --denoise          Denoise the input before encoding\n"); 
+   printf (" --agc              Apply adaptive gain control (AGC) before encoding\n"); 
    printf (" --comment          Add the given string as an extra comment. This may be\n");
    printf ("                     used multiple times\n");
    printf (" --author           Author of this track\n");
@@ -205,7 +214,7 @@
    int option_index = 0;
    char *inFile, *outFile;
    FILE *fin, *fout;
-   float input[MAX_FRAME_SIZE];
+   short input[MAX_FRAME_SIZE];
    int frame_size;
    int quiet=0;
    int vbr_enabled=0;
@@ -213,7 +222,8 @@
    int vad_enabled=0;
    int dtx_enabled=0;
    int nbBytes;
-   SpeexMode *mode=NULL;
+   const SpeexMode *mode=NULL;
+   int modeID = -1;
    void *st;
    SpeexBits bits;
    char cbits[MAX_FRAME_BYTES];
@@ -230,6 +240,8 @@
       {"bitrate", required_argument, NULL, 0},
       {"nframes", required_argument, NULL, 0},
       {"comp", required_argument, NULL, 0},
+      {"denoise", no_argument, NULL, 0},
+      {"agc", no_argument, NULL, 0},
       {"help", no_argument, NULL, 0},
       {"quiet", no_argument, NULL, 0},
       {"le", no_argument, NULL, 0},
@@ -270,8 +282,10 @@
    char first_bytes[12];
    int wave_input=0;
    int tmp;
-   int lookahead = 0;   
-
+   SpeexPreprocessState *preprocess = NULL;
+   int denoise_enabled=0, agc_enabled=0;
+   int lookahead = 0;
+   
    comment_init(&comments, &comments_length, vendor_string);
 
    /*Process command-line options*/
@@ -287,13 +301,13 @@
       case 0:
          if (strcmp(long_options[option_index].name,"narrowband")==0)
          {
-            mode=&speex_nb_mode;
+            modeID = SPEEX_MODEID_NB;
          } else if (strcmp(long_options[option_index].name,"wideband")==0)
          {
-            mode=&speex_wb_mode;
+            modeID = SPEEX_MODEID_WB;
          } else if (strcmp(long_options[option_index].name,"ultra-wideband")==0)
          {
-            mode=&speex_uwb_mode;
+            modeID = SPEEX_MODEID_UWB;
          } else if (strcmp(long_options[option_index].name,"vbr")==0)
          {
             vbr_enabled=1;
@@ -328,6 +342,12 @@
          } else if (strcmp(long_options[option_index].name,"comp")==0)
          {
             complexity = atoi (optarg);
+         } else if (strcmp(long_options[option_index].name,"denoise")==0)
+         {
+            denoise_enabled=1;
+         } else if (strcmp(long_options[option_index].name,"agc")==0)
+         {
+            agc_enabled=1;
          } else if (strcmp(long_options[option_index].name,"help")==0)
          {
             usage();
@@ -363,6 +383,12 @@
             rate=atoi (optarg);
          } else if (strcmp(long_options[option_index].name,"comment")==0)
          {
+	   if (!strchr(optarg, '='))
+	   {
+	     fprintf (stderr, "Invalid comment: %s\n", optarg);
+	     fprintf (stderr, "Comments must be of the form name=value\n");
+	     exit(1);
+	   }
            comment_add(&comments, &comments_length, NULL, optarg); 
          } else if (strcmp(long_options[option_index].name,"author")==0)
          {
@@ -374,7 +400,7 @@
 
          break;
       case 'n':
-         mode=&speex_nb_mode;
+         modeID = SPEEX_MODEID_NB;
          break;
       case 'h':
          usage();
@@ -388,10 +414,10 @@
          print_bitrate=1;
          break;
       case 'w':
-         mode=&speex_wb_mode;
+         modeID = SPEEX_MODEID_WB;
          break;
       case 'u':
-         mode=&speex_uwb_mode;
+         modeID = SPEEX_MODEID_UWB;
          break;
       case '?':
          usage();
@@ -444,12 +470,12 @@
       }
    }
 
-   if (!mode && !rate)
+   if (modeID==-1 && !rate)
    {
       /* By default, use narrowband/8 kHz */
-      mode=&speex_nb_mode;
+      modeID = SPEEX_MODEID_NB;
       rate=8000;
-   } else if (mode && rate)
+   } else if (modeID!=-1 && rate)
    {
       if (rate>48000)
       {
@@ -457,19 +483,19 @@
          exit(1);
       } else if (rate>25000)
       {
-         if (mode!=&speex_uwb_mode)
+         if (modeID != SPEEX_MODEID_UWB)
          {
             fprintf (stderr, "Warning: Trying to encode in %s at %d Hz. I'll do it but I suggest you try ultra-wideband instead\n", mode->modeName , rate);
          }
       } else if (rate>12500)
       {
-         if (mode!=&speex_wb_mode)
+         if (modeID != SPEEX_MODEID_WB)
          {
             fprintf (stderr, "Warning: Trying to encode in %s at %d Hz. I'll do it but I suggest you try wideband instead\n", mode->modeName , rate);
          }
       } else if (rate>=6000)
       {
-         if (mode!=&speex_nb_mode)
+         if (modeID != SPEEX_MODEID_NB)
          {
             fprintf (stderr, "Warning: Trying to encode in %s at %d Hz. I'll do it but I suggest you try narrowband instead\n", mode->modeName , rate);
          }
@@ -477,7 +503,7 @@
          fprintf (stderr, "Error: sampling rate too low: %d Hz\n", rate);
          exit(1);
       }
-   } else if (!mode)
+   } else if (modeID==-1)
    {
       if (rate>48000)
       {
@@ -485,24 +511,24 @@
          exit(1);
       } else if (rate>25000)
       {
-         mode=&speex_uwb_mode;
+         modeID = SPEEX_MODEID_UWB;
       } else if (rate>12500)
       {
-         mode=&speex_wb_mode;
+         modeID = SPEEX_MODEID_WB;
       } else if (rate>=6000)
       {
-         mode=&speex_nb_mode;
+         modeID = SPEEX_MODEID_NB;
       } else {
          fprintf (stderr, "Error: Sampling rate too low: %d Hz\n", rate);
          exit(1);
       }
    } else if (!rate)
    {
-      if (mode==&speex_nb_mode)
+      if (modeID == SPEEX_MODEID_NB)
          rate=8000;
-      else if (mode==&speex_wb_mode)
+      else if (modeID == SPEEX_MODEID_WB)
          rate=16000;
-      else if (mode==&speex_uwb_mode)
+      else if (modeID == SPEEX_MODEID_UWB)
          rate=32000;
    }
 
@@ -510,6 +536,8 @@
       if (rate!=8000 && rate!=16000 && rate!=32000)
          fprintf (stderr, "Warning: Speex is only optimized for 8, 16 and 32 kHz. It will still work at %d Hz but your mileage may vary\n", rate); 
 
+   mode = speex_lib_get_mode (modeID);
+
    speex_init_header(&header, rate, 1, mode);
    header.frames_per_packet=nframes;
    header.vbr=vbr_enabled;
@@ -590,6 +618,14 @@
 
    speex_encoder_ctl(st, SPEEX_GET_LOOKAHEAD, &lookahead);
    
+   if (denoise_enabled || agc_enabled)
+   {
+      preprocess = speex_preprocess_state_init(frame_size, rate);
+      speex_preprocess_ctl(preprocess, SPEEX_PREPROCESS_SET_DENOISE, &denoise_enabled);
+      speex_preprocess_ctl(preprocess, SPEEX_PREPROCESS_SET_AGC, &agc_enabled);
+      lookahead += frame_size;
+   }
+
    /*Write header*/
    {
 
@@ -643,8 +679,13 @@
       id++;
       /*Encode current frame*/
       if (chan==2)
-         speex_encode_stereo(input, frame_size, &bits);
-      speex_encode(st, input, &bits);
+         speex_encode_stereo_int(input, frame_size, &bits);
+
+      if (preprocess)
+         speex_preprocess(preprocess, input, NULL);
+
+      speex_encode_int(st, input, &bits);
+      
       nb_encoded += frame_size;
       if (print_bitrate) {
          int tmp;
@@ -743,7 +784,6 @@
       else
          bytes_written += ret;
    }
-   
 
    speex_encoder_destroy(st);
    speex_bits_destroy(&bits);

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/wav_io.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/wav_io.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/wav_io.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -30,10 +30,47 @@
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <stdio.h>
 #include <string.h>
-#include "misc.h"
+#include "speex/speex_types.h"
 
+static spx_uint32_t le_int(spx_uint32_t i)
+{
+   spx_uint32_t ret=i;
+#ifdef WORDS_BIGENDIAN
+   ret =  i>>24;
+   ret += (i>>8)&0x0000ff00;
+   ret += (i<<8)&0x00ff0000;
+   ret += (i<<24);
+#endif
+   return ret;
+}
+
+unsigned short be_short(unsigned short s)
+{
+   unsigned short ret=s;
+#ifndef WORDS_BIGENDIAN
+   ret =  s>>8;
+   ret += s<<8;
+#endif
+   return ret;
+}
+
+unsigned short le_short(unsigned short s)
+{
+   unsigned short ret=s;
+#ifdef WORDS_BIGENDIAN
+   ret =  s>>8;
+   ret += s<<8;
+#endif
+   return ret;
+}
+
+
 int read_wav_header(FILE *file, int *rate, int *channels, int *format, int *size)
 {
    char ch[5];

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/wav_io.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/wav_io.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/wav_io.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -30,9 +30,14 @@
 */
 
 #ifndef WAV_IO_H
+#define WAV_IO_H
 
 #include <stdio.h>
 
+unsigned short be_short(unsigned short s);
+unsigned short le_short(unsigned short s);
+unsigned short le_int(unsigned int s);
+
 int read_wav_header(FILE *file, int *rate, int *channels, int *format, int *size);
 
 void write_wav_header(FILE *file, int rate, int channels, int format, int size);

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/wave_out.c
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/wave_out.c	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/wave_out.c	2005-10-20 12:42:06 UTC (rev 10202)
@@ -28,6 +28,10 @@
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 /* Set TABS = 4 */
 /********************************************************************
 

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/wave_out.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/wave_out.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/src/wave_out.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -30,9 +30,14 @@
 
 //    WAVE_OUT.H - Necessary stuff for WIN_AUDIO
 
+#ifndef WAVE_OUT_H
+#define WAVE_OUT_H
 
 #include <stdio.h>
 #include <windows.h>
+#ifdef __MINGW32__
+#include <mmsystem.h>
+#endif
 
 #define VERSION_STRING "\n 0.7.0\n"
 
@@ -63,3 +68,4 @@
 int        WIN_Play_Samples           ( const void* buff, size_t len );
 int        WIN_Audio_close            ( void );
 
+#endif /* WAVE_OUT_H */

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/symbian/Makefile.am
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/symbian/Makefile.am	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/symbian/Makefile.am	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,6 @@
+## Process this file with automake to produce Makefile.in. -*-Makefile-*-
+
+# Disable automatic dependency tracking if using other tools than gcc and gmake
+#AUTOMAKE_OPTIONS = no-dependencies
+
+EXTRA_DIST = bld.inf  config.h  speex.mmp

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/symbian/Makefile.in
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/symbian/Makefile.in	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/symbian/Makefile.in	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,322 @@
+# Makefile.in generated by automake 1.8.5 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+# Disable automatic dependency tracking if using other tools than gcc and gmake
+#AUTOMAKE_OPTIONS = no-dependencies
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ..
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+host_triplet = @host@
+subdir = symbian
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+SOURCES =
+DIST_SOURCES =
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
+MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
+MAKEINFO = @MAKEINFO@
+OBJEXT = @OBJEXT@
+OGG_CFLAGS = @OGG_CFLAGS@
+OGG_LIBS = @OGG_LIBS@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIZE16 = @SIZE16@
+SIZE32 = @SIZE32@
+SPEEX_LT_AGE = @SPEEX_LT_AGE@
+SPEEX_LT_CURRENT = @SPEEX_LT_CURRENT@
+SPEEX_LT_REVISION = @SPEEX_LT_REVISION@
+SPEEX_VERSION = @SPEEX_VERSION@
+STRIP = @STRIP@
+VERSION = @VERSION@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
+am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+datadir = @datadir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+src = @src@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+EXTRA_DIST = bld.inf  config.h  speex.mmp
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  symbian/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu  symbian/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+distclean-libtool:
+	-rm -f libtool
+uninstall-info-am:
+tags: TAGS
+TAGS:
+
+ctags: CTAGS
+CTAGS:
+
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+	list='$(DISTFILES)'; for file in $$list; do \
+	  case $$file in \
+	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+	  esac; \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+	    dir="/$$dir"; \
+	    $(mkdir_p) "$(distdir)$$dir"; \
+	  else \
+	    dir=''; \
+	  fi; \
+	  if test -d $$d/$$file; then \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+	-rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-libtool
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-exec-am:
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-info-am
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+	distclean distclean-generic distclean-libtool distdir dvi \
+	dvi-am html html-am info info-am install install-am \
+	install-data install-data-am install-exec install-exec-am \
+	install-info install-info-am install-man install-strip \
+	installcheck installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-generic \
+	mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am \
+	uninstall-info-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/symbian/bld.inf
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/symbian/bld.inf	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/symbian/bld.inf	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,35 @@
+/*
+   Copyright (C) 2003 Commonwealth Scientific and Industrial Research
+   Organisation (CSIRO) Australia
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+   - Neither the name of CSIRO Australia nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+   PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE ORGANISATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+PRJ_MMPFILES
+
+speex.mmp

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/symbian/config.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/symbian/config.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/symbian/config.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,57 @@
+/*
+   Copyright (C) 2003 Commonwealth Scientific and Industrial Research
+   Organisation (CSIRO) Australia
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+   - Neither the name of CSIRO Australia nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+   PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE ORGANISATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef CONFIG_H
+#define CONFIG_H
+
+/* An inline macro is required for use of the inline keyword as not all C compilers support */
+/* inline.  It is officially C99 and C++ only */
+
+#ifdef __WINS__
+
+#define inline __inline
+
+/* Disable some pointless/stupid warnings */
+
+#pragma warning(disable: 4100) /* unreferenced formal parameter */
+#pragma warning(disable: 4127) /* conditional expression is constant */
+#pragma warning(disable: 4305) /* truncation from '...' to '...' */
+#pragma warning(disable: 4244) /* conversion from '...' to '...', possible loss of data */
+#pragma warning(disable: 4701) /* local variable may be be used without having been initialized */
+
+#endif /* ! __WINS__ */
+
+/* Use only fixed point arithmetic */
+
+#define FIXED_POINT 1
+
+#endif /* ! CONFIG_H */

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/symbian/speex.mmp
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/symbian/speex.mmp	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/symbian/speex.mmp	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,45 @@
+/*
+   Copyright (C) 2003 Commonwealth Scientific and Industrial Research
+   Organisation (CSIRO) Australia
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+   - Neither the name of CSIRO Australia nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+   PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE ORGANISATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+TARGET        speex.lib
+TARGETTYPE    lib
+UID           0
+MACRO         HAVE_CONFIG_H
+SOURCEPATH    ..\libspeex
+SOURCE        bits.c cb_search.c exc_5_64_table.c exc_5_256_table.c exc_8_128_table.c
+SOURCE        exc_10_16_table.c exc_10_32_table.c exc_20_32_table.c filters.c gain_table.c
+SOURCE        gain_table_lbr.c hexc_10_32_table.c hexc_table.c high_lsp_tables.c jitter.c
+SOURCE        lbr_48k_tables.c lpc.c lsp.c lsp_tables_nb.c ltp.c math_approx.c mdf.c misc.c
+SOURCE        modes.c nb_celp.c preprocess.c quant_lsp.c sb_celp.c smallft.c
+SOURCE        speex.c speex_callbacks.c speex_header.c stereo.c vbr.c vq.c
+USERINCLUDE   . ..\include\speex
+SYSTEMINCLUDE \epoc32\include \epoc32\include\libc ..\include

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/Makefile.am
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/Makefile.am	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/Makefile.am	2005-10-20 12:42:06 UTC (rev 10202)
@@ -5,3 +5,4 @@
 
 SUBDIRS = libspeex speexenc speexdec
 
+EXTRA_DIST = speex.iss config.h

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/Makefile.in
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/Makefile.in	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/Makefile.in	2005-10-20 12:42:06 UTC (rev 10202)
@@ -1,6 +1,8 @@
-# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
+# Makefile.in generated by automake 1.8.5 from Makefile.am.
+# @configure_input@
 
-# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -10,114 +12,212 @@
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
+ at SET_MAKE@
+
 # Disable automatic dependency tracking if using other tools than gcc and gmake
 #AUTOMAKE_OPTIONS = no-dependencies
-
-
-SHELL = @SHELL@
-
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-
-bindir = @bindir@
-sbindir = @sbindir@
-libexecdir = @libexecdir@
-datadir = @datadir@
-sysconfdir = @sysconfdir@
-sharedstatedir = @sharedstatedir@
-localstatedir = @localstatedir@
-libdir = @libdir@
-infodir = @infodir@
-mandir = @mandir@
-includedir = @includedir@
-oldincludedir = /usr/include
-
-DESTDIR =
-
 pkgdatadir = $(datadir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
-
 top_builddir = ..
-
-ACLOCAL = @ACLOCAL@
-AUTOCONF = @AUTOCONF@
-AUTOMAKE = @AUTOMAKE@
-AUTOHEADER = @AUTOHEADER@
-
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-transform = @program_transform_name@
-
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
 NORMAL_INSTALL = :
 PRE_INSTALL = :
 POST_INSTALL = :
 NORMAL_UNINSTALL = :
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
-host_alias = @host_alias@
 host_triplet = @host@
-AS = @AS@
+subdir = win32
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+SOURCES =
+DIST_SOURCES =
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+	html-recursive info-recursive install-data-recursive \
+	install-exec-recursive install-info-recursive \
+	install-recursive installcheck-recursive installdirs-recursive \
+	pdf-recursive ps-recursive uninstall-info-recursive \
+	uninstall-recursive
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = $(SUBDIRS)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
 CC = @CC@
-DLLTOOL = @DLLTOOL@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
 ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
 EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
 LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
 MAINT = @MAINT@
+MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
+MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
-OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
-OGG_INCLUDES = @OGG_INCLUDES@
-OGG_LDFLAGS = @OGG_LDFLAGS@
+OGG_CFLAGS = @OGG_CFLAGS@
 OGG_LIBS = @OGG_LIBS@
 PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
 RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIZE16 = @SIZE16@
+SIZE32 = @SIZE32@
 SPEEX_LT_AGE = @SPEEX_LT_AGE@
 SPEEX_LT_CURRENT = @SPEEX_LT_CURRENT@
 SPEEX_LT_REVISION = @SPEEX_LT_REVISION@
+SPEEX_VERSION = @SPEEX_VERSION@
 STRIP = @STRIP@
 VERSION = @VERSION@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
+am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+datadir = @datadir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
 src = @src@
-
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
 SUBDIRS = libspeex speexenc speexdec
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-CONFIG_CLEAN_FILES = 
-DIST_COMMON =  Makefile.am Makefile.in
+EXTRA_DIST = speex.iss config.h
+all: all-recursive
 
+.SUFFIXES:
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  win32/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu  win32/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
 
-DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 
-TAR = gtar
-GZIP_ENV = --best
-all: all-redirect
-.SUFFIXES:
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
-	cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps win32/Makefile
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 
-Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
-	cd $(top_builddir) \
-	  && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+mostlyclean-libtool:
+	-rm -f *.lo
 
+clean-libtool:
+	-rm -rf .libs _libs
 
+distclean-libtool:
+	-rm -f libtool
+uninstall-info-am:
+
 # This directory's subdirectories are mostly independent; you can cd
 # into them and run `make' without going through this Makefile.
 # To change the values of `make' variables: instead of editing Makefiles,
 # (1) if the variable is set in `config.status', edit `config.status'
 #     (which will cause the Makefiles to be regenerated when you run `make');
 # (2) otherwise, pass the desired values on the `make' command line.
-
- at SET_MAKE@
-
-all-recursive install-data-recursive install-exec-recursive \
-installdirs-recursive install-recursive uninstall-recursive  \
-check-recursive installcheck-recursive info-recursive dvi-recursive:
-	@set fnord $(MAKEFLAGS); amf=$$2; \
+$(RECURSIVE_TARGETS):
+	@set fnord $$MAKEFLAGS; amf=$$2; \
 	dot_seen=no; \
 	target=`echo $@ | sed s/-recursive//`; \
 	list='$(SUBDIRS)'; for subdir in $$list; do \
@@ -137,13 +237,18 @@
 
 mostlyclean-recursive clean-recursive distclean-recursive \
 maintainer-clean-recursive:
-	@set fnord $(MAKEFLAGS); amf=$$2; \
+	@set fnord $$MAKEFLAGS; amf=$$2; \
 	dot_seen=no; \
-	rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \
-	  rev="$$subdir $$rev"; \
-	  test "$$subdir" != "." || dot_seen=yes; \
+	case "$@" in \
+	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+	  *) list='$(SUBDIRS)' ;; \
+	esac; \
+	rev=''; for subdir in $$list; do \
+	  if test "$$subdir" = "."; then :; else \
+	    rev="$$subdir $$rev"; \
+	  fi; \
 	done; \
-	test "$$dot_seen" = "no" && rev=". $$rev"; \
+	rev="$$rev ."; \
 	target=`echo $@ | sed s/-recursive//`; \
 	for subdir in $$rev; do \
 	  echo "Making $$target in $$subdir"; \
@@ -159,136 +264,203 @@
 	list='$(SUBDIRS)'; for subdir in $$list; do \
 	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
 	done
+ctags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+	done
 
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	mkid -fID $$unique
 tags: TAGS
 
-ID: $(HEADERS) $(SOURCES) $(LISP)
-	list='$(SOURCES) $(HEADERS)'; \
-	unique=`for i in $$list; do echo $$i; done | \
-	  awk '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
-	here=`pwd` && cd $(srcdir) \
-	  && mkid -f$$here/ID $$unique $(LISP)
-
-TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) $(LISP)
+TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
 	tags=; \
 	here=`pwd`; \
+	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+	  include_option=--etags-include; \
+	  empty_fix=.; \
+	else \
+	  include_option=--include; \
+	  empty_fix=; \
+	fi; \
 	list='$(SUBDIRS)'; for subdir in $$list; do \
-   if test "$$subdir" = .; then :; else \
-	    test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \
-   fi; \
+	  if test "$$subdir" = .; then :; else \
+	    test ! -f $$subdir/TAGS || \
+	      tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
+	  fi; \
 	done; \
-	list='$(SOURCES) $(HEADERS)'; \
-	unique=`for i in $$list; do echo $$i; done | \
-	  awk '    { files[$$0] = 1; } \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
 	       END { for (i in files) print i; }'`; \
-	test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
-	  || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags  $$unique $(LISP) -o $$here/TAGS)
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
 
-mostlyclean-tags:
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
 
-clean-tags:
-
 distclean-tags:
-	-rm -f TAGS ID
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
-maintainer-clean-tags:
-
-distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
-
-subdir = win32
-
 distdir: $(DISTFILES)
-	@for file in $(DISTFILES); do \
-	  d=$(srcdir); \
+	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+	list='$(DISTFILES)'; for file in $$list; do \
+	  case $$file in \
+	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+	  esac; \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+	    dir="/$$dir"; \
+	    $(mkdir_p) "$(distdir)$$dir"; \
+	  else \
+	    dir=''; \
+	  fi; \
 	  if test -d $$d/$$file; then \
-	    cp -pr $$d/$$file $(distdir)/$$file; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
 	  else \
 	    test -f $(distdir)/$$file \
-	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
-	    || cp -p $$d/$$file $(distdir)/$$file || :; \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
 	  fi; \
 	done
-	for subdir in $(SUBDIRS); do \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
 	  if test "$$subdir" = .; then :; else \
-	    test -d $(distdir)/$$subdir \
-	    || mkdir $(distdir)/$$subdir \
+	    test -d "$(distdir)/$$subdir" \
+	    || mkdir "$(distdir)/$$subdir" \
 	    || exit 1; \
-	    chmod 777 $(distdir)/$$subdir; \
-	    (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(top_distdir) distdir=../$(distdir)/$$subdir distdir) \
+	    (cd $$subdir && \
+	      $(MAKE) $(AM_MAKEFLAGS) \
+	        top_distdir="../$(top_distdir)" \
+	        distdir="../$(distdir)/$$subdir" \
+	        distdir) \
 	      || exit 1; \
 	  fi; \
 	done
-info-am:
-info: info-recursive
-dvi-am:
-dvi: dvi-recursive
 check-am: all-am
 check: check-recursive
-installcheck-am:
-installcheck: installcheck-recursive
-install-exec-am:
+all-am: Makefile
+installdirs: installdirs-recursive
+installdirs-am:
+install: install-recursive
 install-exec: install-exec-recursive
-
-install-data-am:
 install-data: install-data-recursive
+uninstall: uninstall-recursive
 
 install-am: all-am
 	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-install: install-recursive
-uninstall-am:
-uninstall: uninstall-recursive
-all-am: Makefile
-all-redirect: all-recursive
+
+installcheck: installcheck-recursive
 install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
-installdirs: installdirs-recursive
-installdirs-am:
-
-
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
 mostlyclean-generic:
 
 clean-generic:
 
 distclean-generic:
-	-rm -f Makefile $(CONFIG_CLEAN_FILES)
-	-rm -f config.cache config.log stamp-h stamp-h[0-9]*
+	-rm -f $(CONFIG_CLEAN_FILES)
 
 maintainer-clean-generic:
-mostlyclean-am:  mostlyclean-tags mostlyclean-generic
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
 
-mostlyclean: mostlyclean-recursive
+clean-am: clean-generic clean-libtool mostlyclean-am
 
-clean-am:  clean-tags clean-generic mostlyclean-am
+distclean: distclean-recursive
+	-rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-libtool \
+	distclean-tags
 
-clean: clean-recursive
+dvi: dvi-recursive
 
-distclean-am:  distclean-tags distclean-generic clean-am
-	-rm -f libtool
+dvi-am:
 
-distclean: distclean-recursive
+html: html-recursive
 
-maintainer-clean-am:  maintainer-clean-tags maintainer-clean-generic \
-		distclean-am
-	@echo "This command is intended for maintainers to use;"
-	@echo "it deletes files that may require special tools to rebuild."
+info: info-recursive
 
+info-am:
+
+install-data-am:
+
+install-exec-am:
+
+install-info: install-info-recursive
+
+install-man:
+
+installcheck-am:
+
 maintainer-clean: maintainer-clean-recursive
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
 
-.PHONY: install-data-recursive uninstall-data-recursive \
-install-exec-recursive uninstall-exec-recursive installdirs-recursive \
-uninstalldirs-recursive all-recursive check-recursive \
-installcheck-recursive info-recursive dvi-recursive \
-mostlyclean-recursive distclean-recursive clean-recursive \
-maintainer-clean-recursive tags tags-recursive mostlyclean-tags \
-distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
-dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
-install-exec install-data-am install-data install-am install \
-uninstall-am uninstall all-redirect all-am all installdirs-am \
-installdirs mostlyclean-generic distclean-generic clean-generic \
-maintainer-clean-generic clean mostlyclean distclean maintainer-clean
+mostlyclean: mostlyclean-recursive
 
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
 
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am: uninstall-info-am
+
+uninstall-info: uninstall-info-recursive
+
+.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \
+	clean clean-generic clean-libtool clean-recursive ctags \
+	ctags-recursive distclean distclean-generic distclean-libtool \
+	distclean-recursive distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-am install-data \
+	install-data-am install-exec install-exec-am install-info \
+	install-info-am install-man install-strip installcheck \
+	installcheck-am installdirs installdirs-am maintainer-clean \
+	maintainer-clean-generic maintainer-clean-recursive \
+	mostlyclean mostlyclean-generic mostlyclean-libtool \
+	mostlyclean-recursive pdf pdf-am ps ps-am tags tags-recursive \
+	uninstall uninstall-am uninstall-info-am
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/config.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/config.h	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/config.h	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,2 @@
+#define inline __inline
+#define restrict

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/libspeex/Makefile.am
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/libspeex/Makefile.am	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/libspeex/Makefile.am	2005-10-20 12:42:06 UTC (rev 10202)
@@ -3,4 +3,4 @@
 # Disable automatic dependency tracking if using other tools than gcc and gmake
 #AUTOMAKE_OPTIONS = no-dependencies
 
-EXTRA_DIST = libspeex.dsp  libspeex.dsw
+EXTRA_DIST = libspeex.dsp  libspeex.dsw libspeex_dynamic.dsp speex.def

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/libspeex/Makefile.in
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/libspeex/Makefile.in	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/libspeex/Makefile.in	2005-10-20 12:42:06 UTC (rev 10202)
@@ -1,6 +1,8 @@
-# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
+# Makefile.in generated by automake 1.8.5 from Makefile.am.
+# @configure_input@
 
-# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -10,181 +12,311 @@
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
+ at SET_MAKE@
+
 # Disable automatic dependency tracking if using other tools than gcc and gmake
 #AUTOMAKE_OPTIONS = no-dependencies
-
-
-SHELL = @SHELL@
-
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-
-bindir = @bindir@
-sbindir = @sbindir@
-libexecdir = @libexecdir@
-datadir = @datadir@
-sysconfdir = @sysconfdir@
-sharedstatedir = @sharedstatedir@
-localstatedir = @localstatedir@
-libdir = @libdir@
-infodir = @infodir@
-mandir = @mandir@
-includedir = @includedir@
-oldincludedir = /usr/include
-
-DESTDIR =
-
 pkgdatadir = $(datadir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
-
 top_builddir = ../..
-
-ACLOCAL = @ACLOCAL@
-AUTOCONF = @AUTOCONF@
-AUTOMAKE = @AUTOMAKE@
-AUTOHEADER = @AUTOHEADER@
-
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-transform = @program_transform_name@
-
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
 NORMAL_INSTALL = :
 PRE_INSTALL = :
 POST_INSTALL = :
 NORMAL_UNINSTALL = :
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
-host_alias = @host_alias@
 host_triplet = @host@
-AS = @AS@
+subdir = win32/libspeex
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+SOURCES =
+DIST_SOURCES =
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
 CC = @CC@
-DLLTOOL = @DLLTOOL@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
 ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
 EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
 LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
 MAINT = @MAINT@
+MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
+MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
-OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
-OGG_INCLUDES = @OGG_INCLUDES@
-OGG_LDFLAGS = @OGG_LDFLAGS@
+OGG_CFLAGS = @OGG_CFLAGS@
 OGG_LIBS = @OGG_LIBS@
 PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
 RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIZE16 = @SIZE16@
+SIZE32 = @SIZE32@
 SPEEX_LT_AGE = @SPEEX_LT_AGE@
 SPEEX_LT_CURRENT = @SPEEX_LT_CURRENT@
 SPEEX_LT_REVISION = @SPEEX_LT_REVISION@
+SPEEX_VERSION = @SPEEX_VERSION@
 STRIP = @STRIP@
 VERSION = @VERSION@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
+am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+datadir = @datadir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
 src = @src@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+EXTRA_DIST = libspeex.dsp  libspeex.dsw libspeex_dynamic.dsp speex.def
+all: all-am
 
-EXTRA_DIST = libspeex.dsp  libspeex.dsw
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-CONFIG_CLEAN_FILES = 
-DIST_COMMON =  Makefile.am Makefile.in
+.SUFFIXES:
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  win32/libspeex/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu  win32/libspeex/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
 
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 
-DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 
-TAR = gtar
-GZIP_ENV = --best
-all: all-redirect
-.SUFFIXES:
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
-	cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps win32/libspeex/Makefile
+mostlyclean-libtool:
+	-rm -f *.lo
 
-Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
-	cd $(top_builddir) \
-	  && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+clean-libtool:
+	-rm -rf .libs _libs
 
+distclean-libtool:
+	-rm -f libtool
+uninstall-info-am:
 tags: TAGS
 TAGS:
 
+ctags: CTAGS
+CTAGS:
 
-distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
 
-subdir = win32/libspeex
-
 distdir: $(DISTFILES)
-	@for file in $(DISTFILES); do \
-	  d=$(srcdir); \
+	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+	list='$(DISTFILES)'; for file in $$list; do \
+	  case $$file in \
+	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+	  esac; \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+	    dir="/$$dir"; \
+	    $(mkdir_p) "$(distdir)$$dir"; \
+	  else \
+	    dir=''; \
+	  fi; \
 	  if test -d $$d/$$file; then \
-	    cp -pr $$d/$$file $(distdir)/$$file; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
 	  else \
 	    test -f $(distdir)/$$file \
-	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
-	    || cp -p $$d/$$file $(distdir)/$$file || :; \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
 	  fi; \
 	done
-info-am:
-info: info-am
-dvi-am:
-dvi: dvi-am
 check-am: all-am
 check: check-am
-installcheck-am:
-installcheck: installcheck-am
-install-exec-am:
+all-am: Makefile
+installdirs:
+install: install-am
 install-exec: install-exec-am
-
-install-data-am:
 install-data: install-data-am
+uninstall: uninstall-am
 
 install-am: all-am
 	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-install: install-am
-uninstall-am:
-uninstall: uninstall-am
-all-am: Makefile
-all-redirect: all-am
+
+installcheck: installcheck-am
 install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
-installdirs:
-
-
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
 mostlyclean-generic:
 
 clean-generic:
 
 distclean-generic:
-	-rm -f Makefile $(CONFIG_CLEAN_FILES)
-	-rm -f config.cache config.log stamp-h stamp-h[0-9]*
+	-rm -f $(CONFIG_CLEAN_FILES)
 
 maintainer-clean-generic:
-mostlyclean-am:  mostlyclean-generic
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
 
-mostlyclean: mostlyclean-am
+clean-am: clean-generic clean-libtool mostlyclean-am
 
-clean-am:  clean-generic mostlyclean-am
+distclean: distclean-am
+	-rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-libtool
 
-clean: clean-am
+dvi: dvi-am
 
-distclean-am:  distclean-generic clean-am
-	-rm -f libtool
+dvi-am:
 
-distclean: distclean-am
+html: html-am
 
-maintainer-clean-am:  maintainer-clean-generic distclean-am
-	@echo "This command is intended for maintainers to use;"
-	@echo "it deletes files that may require special tools to rebuild."
+info: info-am
 
+info-am:
+
+install-data-am:
+
+install-exec-am:
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
 maintainer-clean: maintainer-clean-am
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
 
-.PHONY: tags distdir info-am info dvi-am dvi check check-am \
-installcheck-am installcheck install-exec-am install-exec \
-install-data-am install-data install-am install uninstall-am uninstall \
-all-redirect all-am all installdirs mostlyclean-generic \
-distclean-generic clean-generic maintainer-clean-generic clean \
-mostlyclean distclean maintainer-clean
+mostlyclean: mostlyclean-am
 
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
 
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-info-am
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+	distclean distclean-generic distclean-libtool distdir dvi \
+	dvi-am html html-am info info-am install install-am \
+	install-data install-data-am install-exec install-exec-am \
+	install-info install-info-am install-man install-strip \
+	installcheck installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-generic \
+	mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am \
+	uninstall-info-am
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/libspeex/libspeex.dsp
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/libspeex/libspeex.dsp	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/libspeex/libspeex.dsp	2005-10-20 12:42:06 UTC (rev 10202)
@@ -23,9 +23,9 @@
 
 # Begin Project
 # PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=xicl6.exe
+# PROP Scc_ProjName "Perforce Project"
+# PROP Scc_LocalPath "..\.."
+CPP=cl.exe
 RSC=rc.exe
 
 !IF  "$(CFG)" == "libspeex - Win32 Release"
@@ -42,13 +42,13 @@
 # PROP Target_Dir ""
 F90=df.exe
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /GX /Ox /Ot /Og /Oi /Ob2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /GX /Ox /Ot /Og /Oi /Ob2 /I "../../include" /I "../" /D inline=__inline /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "HAVE_CONFIG_H" /YX /FD /c
 # ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
 BSC32=bscmake.exe
 # ADD BASE BSC32 /nologo
 # ADD BSC32 /nologo
-LIB32=xilink6.exe -lib
+LIB32=link.exe -lib
 # ADD BASE LIB32 /nologo
 # ADD LIB32 /nologo
 
@@ -66,13 +66,13 @@
 # PROP Target_Dir ""
 F90=df.exe
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
+# ADD CPP /nologo /W3 /GX /Ox /Ot /Og /Oi /Ob2 /I "../../include" /I "../" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "HAVE_CONFIG_H" /YX /FD /c
 # ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
 BSC32=bscmake.exe
 # ADD BASE BSC32 /nologo
 # ADD BSC32 /nologo
-LIB32=xilink6.exe -lib
+LIB32=link.exe -lib
 # ADD BASE LIB32 /nologo
 # ADD LIB32 /nologo
 
@@ -175,6 +175,10 @@
 # End Source File
 # Begin Source File
 
+SOURCE=..\..\libspeex\preprocess.c
+# End Source File
+# Begin Source File
+
 SOURCE=..\..\libspeex\quant_lsp.c
 # End Source File
 # Begin Source File
@@ -183,6 +187,14 @@
 # End Source File
 # Begin Source File
 
+SOURCE=..\..\libspeex\smallft.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\speex.c
+# End Source File
+# Begin Source File
+
 SOURCE=..\..\libspeex\speex_callbacks.c
 # End Source File
 # Begin Source File
@@ -227,10 +239,6 @@
 # End Source File
 # Begin Source File
 
-SOURCE=..\..\libspeex\math_approx.h
-# End Source File
-# Begin Source File
-
 SOURCE=..\..\libspeex\misc.h
 # End Source File
 # Begin Source File
@@ -251,6 +259,10 @@
 # End Source File
 # Begin Source File
 
+SOURCE=..\..\libspeex\smallft.h
+# End Source File
+# Begin Source File
+
 SOURCE=..\..\libspeex\speex.h
 # End Source File
 # Begin Source File
@@ -263,6 +275,10 @@
 # End Source File
 # Begin Source File
 
+SOURCE=..\..\libspeex\speex_denoise.h
+# End Source File
+# Begin Source File
+
 SOURCE=..\..\libspeex\speex_header.h
 # End Source File
 # Begin Source File

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/libspeex/libspeex.dsw
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/libspeex/libspeex.dsw	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/libspeex/libspeex.dsw	2005-10-20 12:42:06 UTC (rev 10202)
@@ -15,6 +15,18 @@
 
 ###############################################################################
 
+Project: "libspeex_dynamic"=.\libspeex_dynamic.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
 Global:
 
 Package=<5>

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/libspeex/libspeex.vcproj
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/libspeex/libspeex.vcproj	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/libspeex/libspeex.vcproj	2005-10-20 12:42:06 UTC (rev 10202)
@@ -21,8 +21,8 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="..\..\include"
-				PreprocessorDefinitions="WIN32,_DEBUG,_WINDOWS"
+				AdditionalIncludeDirectories="..\..\include;.."
+				PreprocessorDefinitions="WIN32,_DEBUG,_WINDOWS,HAVE_CONFIG_H"
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="3"
 				UsePrecompiledHeader="2"
@@ -80,8 +80,8 @@
 				FavorSizeOrSpeed="1"
 				OmitFramePointers="TRUE"
 				OptimizeForProcessor="3"
-				AdditionalIncludeDirectories="..\..\include"
-				PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS"
+				AdditionalIncludeDirectories="..\..\include;.."
+				PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS,HAVE_CONFIG_H"
 				RuntimeLibrary="2"
 				BufferSecurityCheck="FALSE"
 				UsePrecompiledHeader="0"
@@ -137,8 +137,8 @@
 				FavorSizeOrSpeed="1"
 				OmitFramePointers="TRUE"
 				OptimizeForProcessor="3"
-				AdditionalIncludeDirectories="..\..\include"
-				PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS"
+				AdditionalIncludeDirectories="..\..\include;.."
+				PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS,HAVE_CONFIG_H"
 				RuntimeLibrary="2"
 				BufferSecurityCheck="FALSE"
 				EnableEnhancedInstructionSet="2"
@@ -195,8 +195,8 @@
 				FavorSizeOrSpeed="1"
 				OmitFramePointers="TRUE"
 				OptimizeForProcessor="3"
-				AdditionalIncludeDirectories="..\..\include"
-				PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS"
+				AdditionalIncludeDirectories="..\..\include;.."
+				PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS,HAVE_CONFIG_H"
 				RuntimeLibrary="2"
 				BufferSecurityCheck="FALSE"
 				EnableEnhancedInstructionSet="1"
@@ -286,6 +286,12 @@
 				RelativePath="..\..\libspeex\high_lsp_tables.c">
 			</File>
 			<File
+				RelativePath="..\..\libspeex\jitter.c">
+			</File>
+			<File
+				RelativePath="..\..\libspeex\lbr_48k_tables.c">
+			</File>
+			<File
 				RelativePath="..\..\libspeex\lpc.c">
 			</File>
 			<File
@@ -301,6 +307,9 @@
 				RelativePath="..\..\libspeex\math_approx.c">
 			</File>
 			<File
+				RelativePath="..\..\libspeex\mdf.c">
+			</File>
+			<File
 				RelativePath="..\..\libspeex\misc.c">
 			</File>
 			<File
@@ -310,12 +319,21 @@
 				RelativePath="..\..\libspeex\nb_celp.c">
 			</File>
 			<File
+				RelativePath="..\..\libspeex\preprocess.c">
+			</File>
+			<File
 				RelativePath="..\..\libspeex\quant_lsp.c">
 			</File>
 			<File
 				RelativePath="..\..\libspeex\sb_celp.c">
 			</File>
 			<File
+				RelativePath="..\..\libspeex\smallft.c">
+			</File>
+			<File
+				RelativePath="..\..\libspeex\speex.c">
+			</File>
+			<File
 				RelativePath="..\..\libspeex\speex_callbacks.c">
 			</File>
 			<File
@@ -338,6 +356,9 @@
 				RelativePath="..\..\libspeex\cb_search.h">
 			</File>
 			<File
+				RelativePath="..\config.h">
+			</File>
+			<File
 				RelativePath="..\..\libspeex\filters.h">
 			</File>
 			<File

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/libspeex/libspeex_dynamic.dsp
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/libspeex/libspeex_dynamic.dsp	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/libspeex/libspeex_dynamic.dsp	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,311 @@
+# Microsoft Developer Studio Project File - Name="libspeex_dynamic" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=libspeex_dynamic - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "libspeex_dynamic.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "libspeex_dynamic.mak" CFG="libspeex_dynamic - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "libspeex_dynamic - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "libspeex_dynamic - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE 
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "libspeex_dynamic - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "libspeex_dynamic___Win32_Release"
+# PROP BASE Intermediate_Dir "libspeex_dynamic___Win32_Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Dynamic_Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBSPEEX_DYNAMIC_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../include" /I "../" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBSPEEX_DYNAMIC_EXPORTS" /D "HAVE_CONFIG_H" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"Release/libspeex.dll"
+
+!ELSEIF  "$(CFG)" == "libspeex_dynamic - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "libspeex_dynamic___Win32_Debug"
+# PROP BASE Intermediate_Dir "libspeex_dynamic___Win32_Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Dynamic_Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBSPEEX_DYNAMIC_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../include" /I "../" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBSPEEX_DYNAMIC_EXPORTS" /D "HAVE_CONFIG_H" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"Debug/libspeex.dll" /pdbtype:sept
+
+!ENDIF 
+
+# Begin Target
+
+# Name "libspeex_dynamic - Win32 Release"
+# Name "libspeex_dynamic - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\libspeex\bits.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\cb_search.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\exc_10_16_table.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\exc_10_32_table.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\exc_20_32_table.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\exc_5_256_table.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\exc_5_64_table.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\exc_8_128_table.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\filters.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\gain_table.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\gain_table_lbr.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\hexc_10_32_table.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\hexc_table.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\high_lsp_tables.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\lpc.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\lsp.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\lsp_tables_nb.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\ltp.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\math_approx.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\misc.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\modes.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\nb_celp.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\preprocess.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\quant_lsp.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\sb_celp.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\smallft.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\speex.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\speex.def
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\speex_callbacks.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\speex_header.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\stereo.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\vbr.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\vq.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\..\libspeex\cb_search.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\filters.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\lpc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\lsp.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\ltp.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\misc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\modes.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\nb_celp.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\quant_lsp.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\sb_celp.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\smallft.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\speex.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\speex_bits.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\speex_callbacks.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\speex_denoise.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\speex_header.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\speex_stereo.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\stack_alloc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\vbr.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\libspeex\vq.h
+# End Source File
+# End Group
+# End Target
+# End Project

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/libspeex/speex.def
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/libspeex/speex.def	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/libspeex/speex.def	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,49 @@
+;
+; speex.def
+;
+LIBRARY
+EXPORTS
+;
+speex_encoder_init
+speex_encoder_destroy
+speex_encode
+speex_encoder_ctl
+speex_decoder_init
+speex_decoder_destroy
+speex_decode
+speex_decoder_ctl
+speex_mode_query
+speex_lib_ctl
+speex_bits_init
+speex_bits_init_buffer
+speex_bits_destroy
+speex_bits_reset
+speex_bits_rewind
+speex_bits_read_from
+speex_bits_read_whole_bytes
+speex_bits_write
+speex_bits_write_whole_bytes
+speex_bits_pack
+speex_bits_unpack_signed
+speex_bits_unpack_unsigned
+speex_bits_nbytes
+speex_bits_peek_unsigned
+speex_bits_peek
+speex_bits_advance
+speex_bits_remaining
+speex_bits_insert_terminator
+speex_inband_handler
+speex_std_mode_request_handler
+speex_std_high_mode_request_handler
+speex_std_char_handler
+speex_default_user_handler
+speex_std_low_mode_request_handler
+speex_std_vbr_request_handler
+speex_std_enh_request_handler
+speex_std_vbr_quality_request_handler
+speex_init_header
+speex_header_to_packet
+speex_packet_to_header
+speex_encode_stereo
+speex_decode_stereo
+speex_std_stereo_request_handler

Added: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/speex.iss
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/speex.iss	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/speex.iss	2005-10-20 12:42:06 UTC (rev 10202)
@@ -0,0 +1,47 @@
+; Script generated by the Inno Setup Script Wizard.
+; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
+
+[Setup]
+AppName=Speex
+AppVerName=Speex V1.1.6
+AppPublisherURL=http://www.speex.org
+AppSupportURL=http://www.speex.org
+AppUpdatesURL=http://www.speex.org
+DefaultDirName={pf}\Speex
+DefaultGroupName=Speex
+AllowNoIcons=yes
+LicenseFile=..\COPYING
+InfoAfterFile=..\README
+OutputDir=.
+OutputBaseFilename=speex_win32_1.1.6_setup
+; uncomment the following line if you want your installation to run on NT 3.51 too.
+; MinVersion=4,3.51
+
+[Tasks]
+;Name: "desktopicon"; Description: "Create a &desktop icon"; GroupDescription: "Additional icons:"; MinVersion: 4,4
+
+[Dirs]
+Name: "{app}"
+Name: "{app}\doc"
+Name: "{app}\html"
+Name: "{app}\libspeex"
+Name: "{app}\libspeex\include"
+
+[Files]
+Source: "speexdec\Release\speexdec.exe"; DestDir: "{app}"; Flags: ignoreversion
+Source: "speexenc\Release\speexenc.exe"; DestDir: "{app}"; Flags: ignoreversion
+Source: "libspeex\Release\libspeex.lib"; DestDir: "{app}\libspeex"; Flags: ignoreversion
+Source: "libspeex\Release\libspeex.exp"; DestDir: "{app}\libspeex"; Flags: ignoreversion
+Source: "libspeex\Release\libspeex.dll"; DestDir: "{app}\libspeex"; Flags: ignoreversion
+Source: "..\include\speex\speex.h"; DestDir: "{app}\libspeex\include"; Flags: ignoreversion
+Source: "..\include\speex\speex_bits.h"; DestDir: "{app}\libspeex\include"; Flags: ignoreversion
+Source: "..\include\speex\speex_callbacks.h"; DestDir: "{app}\libspeex\include"; Flags: ignoreversion
+Source: "..\include\speex\speex_echo.h"; DestDir: "{app}\libspeex\include"; Flags: ignoreversion
+Source: "..\include\speex\speex_header.h"; DestDir: "{app}\libspeex\include"; Flags: ignoreversion
+Source: "..\include\speex\speex_jitter.h"; DestDir: "{app}\libspeex\include"; Flags: ignoreversion
+Source: "..\include\speex\speex_preprocess.h"; DestDir: "{app}\libspeex\include"; Flags: ignoreversion
+Source: "..\include\speex\speex_stereo.h"; DestDir: "{app}\libspeex\include"; Flags: ignoreversion
+Source: "..\doc\manual.pdf"; DestDir: "{app}\doc"; Flags: ignoreversion
+
+[Run]
+

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/speexdec/Makefile.in
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/speexdec/Makefile.in	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/speexdec/Makefile.in	2005-10-20 12:42:06 UTC (rev 10202)
@@ -1,6 +1,8 @@
-# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
+# Makefile.in generated by automake 1.8.5 from Makefile.am.
+# @configure_input@
 
-# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -10,181 +12,311 @@
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
+ at SET_MAKE@
+
 # Disable automatic dependency tracking if using other tools than gcc and gmake
 #AUTOMAKE_OPTIONS = no-dependencies
-
-
-SHELL = @SHELL@
-
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-
-bindir = @bindir@
-sbindir = @sbindir@
-libexecdir = @libexecdir@
-datadir = @datadir@
-sysconfdir = @sysconfdir@
-sharedstatedir = @sharedstatedir@
-localstatedir = @localstatedir@
-libdir = @libdir@
-infodir = @infodir@
-mandir = @mandir@
-includedir = @includedir@
-oldincludedir = /usr/include
-
-DESTDIR =
-
 pkgdatadir = $(datadir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
-
 top_builddir = ../..
-
-ACLOCAL = @ACLOCAL@
-AUTOCONF = @AUTOCONF@
-AUTOMAKE = @AUTOMAKE@
-AUTOHEADER = @AUTOHEADER@
-
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-transform = @program_transform_name@
-
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
 NORMAL_INSTALL = :
 PRE_INSTALL = :
 POST_INSTALL = :
 NORMAL_UNINSTALL = :
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
-host_alias = @host_alias@
 host_triplet = @host@
-AS = @AS@
+subdir = win32/speexdec
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+SOURCES =
+DIST_SOURCES =
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
 CC = @CC@
-DLLTOOL = @DLLTOOL@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
 ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
 EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
 LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
 MAINT = @MAINT@
+MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
+MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
-OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
-OGG_INCLUDES = @OGG_INCLUDES@
-OGG_LDFLAGS = @OGG_LDFLAGS@
+OGG_CFLAGS = @OGG_CFLAGS@
 OGG_LIBS = @OGG_LIBS@
 PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
 RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIZE16 = @SIZE16@
+SIZE32 = @SIZE32@
 SPEEX_LT_AGE = @SPEEX_LT_AGE@
 SPEEX_LT_CURRENT = @SPEEX_LT_CURRENT@
 SPEEX_LT_REVISION = @SPEEX_LT_REVISION@
+SPEEX_VERSION = @SPEEX_VERSION@
 STRIP = @STRIP@
 VERSION = @VERSION@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
+am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+datadir = @datadir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
 src = @src@
-
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
 EXTRA_DIST = speexdec.dsp  speexdec.dsw
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-CONFIG_CLEAN_FILES = 
-DIST_COMMON =  Makefile.am Makefile.in
+all: all-am
 
+.SUFFIXES:
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  win32/speexdec/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu  win32/speexdec/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
 
-DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 
-TAR = gtar
-GZIP_ENV = --best
-all: all-redirect
-.SUFFIXES:
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
-	cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps win32/speexdec/Makefile
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 
-Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
-	cd $(top_builddir) \
-	  && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+mostlyclean-libtool:
+	-rm -f *.lo
 
+clean-libtool:
+	-rm -rf .libs _libs
+
+distclean-libtool:
+	-rm -f libtool
+uninstall-info-am:
 tags: TAGS
 TAGS:
 
+ctags: CTAGS
+CTAGS:
 
-distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
 
-subdir = win32/speexdec
-
 distdir: $(DISTFILES)
-	@for file in $(DISTFILES); do \
-	  d=$(srcdir); \
+	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+	list='$(DISTFILES)'; for file in $$list; do \
+	  case $$file in \
+	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+	  esac; \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+	    dir="/$$dir"; \
+	    $(mkdir_p) "$(distdir)$$dir"; \
+	  else \
+	    dir=''; \
+	  fi; \
 	  if test -d $$d/$$file; then \
-	    cp -pr $$d/$$file $(distdir)/$$file; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
 	  else \
 	    test -f $(distdir)/$$file \
-	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
-	    || cp -p $$d/$$file $(distdir)/$$file || :; \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
 	  fi; \
 	done
-info-am:
-info: info-am
-dvi-am:
-dvi: dvi-am
 check-am: all-am
 check: check-am
-installcheck-am:
-installcheck: installcheck-am
-install-exec-am:
+all-am: Makefile
+installdirs:
+install: install-am
 install-exec: install-exec-am
-
-install-data-am:
 install-data: install-data-am
+uninstall: uninstall-am
 
 install-am: all-am
 	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-install: install-am
-uninstall-am:
-uninstall: uninstall-am
-all-am: Makefile
-all-redirect: all-am
+
+installcheck: installcheck-am
 install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
-installdirs:
-
-
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
 mostlyclean-generic:
 
 clean-generic:
 
 distclean-generic:
-	-rm -f Makefile $(CONFIG_CLEAN_FILES)
-	-rm -f config.cache config.log stamp-h stamp-h[0-9]*
+	-rm -f $(CONFIG_CLEAN_FILES)
 
 maintainer-clean-generic:
-mostlyclean-am:  mostlyclean-generic
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
 
-mostlyclean: mostlyclean-am
+clean-am: clean-generic clean-libtool mostlyclean-am
 
-clean-am:  clean-generic mostlyclean-am
+distclean: distclean-am
+	-rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-libtool
 
-clean: clean-am
+dvi: dvi-am
 
-distclean-am:  distclean-generic clean-am
-	-rm -f libtool
+dvi-am:
 
-distclean: distclean-am
+html: html-am
 
-maintainer-clean-am:  maintainer-clean-generic distclean-am
-	@echo "This command is intended for maintainers to use;"
-	@echo "it deletes files that may require special tools to rebuild."
+info: info-am
 
+info-am:
+
+install-data-am:
+
+install-exec-am:
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
 maintainer-clean: maintainer-clean-am
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
 
-.PHONY: tags distdir info-am info dvi-am dvi check check-am \
-installcheck-am installcheck install-exec-am install-exec \
-install-data-am install-data install-am install uninstall-am uninstall \
-all-redirect all-am all installdirs mostlyclean-generic \
-distclean-generic clean-generic maintainer-clean-generic clean \
-mostlyclean distclean maintainer-clean
+mostlyclean: mostlyclean-am
 
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
 
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-info-am
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+	distclean distclean-generic distclean-libtool distdir dvi \
+	dvi-am html html-am info info-am install install-am \
+	install-data install-data-am install-exec install-exec-am \
+	install-info install-info-am install-man install-strip \
+	installcheck installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-generic \
+	mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am \
+	uninstall-info-am
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/speexdec/speexdec.dsp
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/speexdec/speexdec.dsp	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/speexdec/speexdec.dsp	2005-10-20 12:42:06 UTC (rev 10202)
@@ -25,7 +25,7 @@
 # PROP AllowPerConfigDependencies 0
 # PROP Scc_ProjName ""
 # PROP Scc_LocalPath ""
-CPP=xicl6.exe
+CPP=cl.exe
 RSC=rc.exe
 
 !IF  "$(CFG)" == "speexdec - Win32 Release"
@@ -42,15 +42,15 @@
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /GX /O1 /I "../../libspeex" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /GX /O2 /I "../../libspeex" /I "../../../ogg/include" /I "../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
 # ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
 BSC32=bscmake.exe
 # ADD BASE BSC32 /nologo
 # ADD BSC32 /nologo
-LINK32=xilink6.exe
+LINK32=link.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:"LIBCMT.lib"
 
 !ELSEIF  "$(CFG)" == "speexdec - Win32 Debug"
 
@@ -66,13 +66,13 @@
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ "../../libspeex" /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../libspeex" /I "../../../ogg/include" /I "../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
 # ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
 BSC32=bscmake.exe
 # ADD BASE BSC32 /nologo
 # ADD BSC32 /nologo
-LINK32=xilink6.exe
+LINK32=link.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
 

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/speexenc/Makefile.in
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/speexenc/Makefile.in	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/speexenc/Makefile.in	2005-10-20 12:42:06 UTC (rev 10202)
@@ -1,6 +1,8 @@
-# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
+# Makefile.in generated by automake 1.8.5 from Makefile.am.
+# @configure_input@
 
-# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -10,181 +12,311 @@
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
+ at SET_MAKE@
+
 # Disable automatic dependency tracking if using other tools than gcc and gmake
 #AUTOMAKE_OPTIONS = no-dependencies
-
-
-SHELL = @SHELL@
-
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-
-bindir = @bindir@
-sbindir = @sbindir@
-libexecdir = @libexecdir@
-datadir = @datadir@
-sysconfdir = @sysconfdir@
-sharedstatedir = @sharedstatedir@
-localstatedir = @localstatedir@
-libdir = @libdir@
-infodir = @infodir@
-mandir = @mandir@
-includedir = @includedir@
-oldincludedir = /usr/include
-
-DESTDIR =
-
 pkgdatadir = $(datadir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
-
 top_builddir = ../..
-
-ACLOCAL = @ACLOCAL@
-AUTOCONF = @AUTOCONF@
-AUTOMAKE = @AUTOMAKE@
-AUTOHEADER = @AUTOHEADER@
-
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
 INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-transform = @program_transform_name@
-
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
 NORMAL_INSTALL = :
 PRE_INSTALL = :
 POST_INSTALL = :
 NORMAL_UNINSTALL = :
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
-host_alias = @host_alias@
 host_triplet = @host@
-AS = @AS@
+subdir = win32/speexenc
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+SOURCES =
+DIST_SOURCES =
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
 CC = @CC@
-DLLTOOL = @DLLTOOL@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
 ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
 EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
 LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
 MAINT = @MAINT@
+MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
+MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
-OBJDUMP = @OBJDUMP@
 OBJEXT = @OBJEXT@
-OGG_INCLUDES = @OGG_INCLUDES@
-OGG_LDFLAGS = @OGG_LDFLAGS@
+OGG_CFLAGS = @OGG_CFLAGS@
 OGG_LIBS = @OGG_LIBS@
 PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
 RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIZE16 = @SIZE16@
+SIZE32 = @SIZE32@
 SPEEX_LT_AGE = @SPEEX_LT_AGE@
 SPEEX_LT_CURRENT = @SPEEX_LT_CURRENT@
 SPEEX_LT_REVISION = @SPEEX_LT_REVISION@
+SPEEX_VERSION = @SPEEX_VERSION@
 STRIP = @STRIP@
 VERSION = @VERSION@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
+am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+datadir = @datadir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
 src = @src@
-
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
 EXTRA_DIST = speexenc.dsp  speexenc.dsw
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-CONFIG_CLEAN_FILES = 
-DIST_COMMON =  Makefile.am Makefile.in
+all: all-am
 
+.SUFFIXES:
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  win32/speexenc/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu  win32/speexenc/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
 
-DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 
-TAR = gtar
-GZIP_ENV = --best
-all: all-redirect
-.SUFFIXES:
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
-	cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps win32/speexenc/Makefile
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 
-Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
-	cd $(top_builddir) \
-	  && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+mostlyclean-libtool:
+	-rm -f *.lo
 
+clean-libtool:
+	-rm -rf .libs _libs
+
+distclean-libtool:
+	-rm -f libtool
+uninstall-info-am:
 tags: TAGS
 TAGS:
 
+ctags: CTAGS
+CTAGS:
 
-distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
 
-subdir = win32/speexenc
-
 distdir: $(DISTFILES)
-	@for file in $(DISTFILES); do \
-	  d=$(srcdir); \
+	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+	list='$(DISTFILES)'; for file in $$list; do \
+	  case $$file in \
+	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+	  esac; \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+	    dir="/$$dir"; \
+	    $(mkdir_p) "$(distdir)$$dir"; \
+	  else \
+	    dir=''; \
+	  fi; \
 	  if test -d $$d/$$file; then \
-	    cp -pr $$d/$$file $(distdir)/$$file; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
 	  else \
 	    test -f $(distdir)/$$file \
-	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
-	    || cp -p $$d/$$file $(distdir)/$$file || :; \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
 	  fi; \
 	done
-info-am:
-info: info-am
-dvi-am:
-dvi: dvi-am
 check-am: all-am
 check: check-am
-installcheck-am:
-installcheck: installcheck-am
-install-exec-am:
+all-am: Makefile
+installdirs:
+install: install-am
 install-exec: install-exec-am
-
-install-data-am:
 install-data: install-data-am
+uninstall: uninstall-am
 
 install-am: all-am
 	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-install: install-am
-uninstall-am:
-uninstall: uninstall-am
-all-am: Makefile
-all-redirect: all-am
+
+installcheck: installcheck-am
 install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
-installdirs:
-
-
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
 mostlyclean-generic:
 
 clean-generic:
 
 distclean-generic:
-	-rm -f Makefile $(CONFIG_CLEAN_FILES)
-	-rm -f config.cache config.log stamp-h stamp-h[0-9]*
+	-rm -f $(CONFIG_CLEAN_FILES)
 
 maintainer-clean-generic:
-mostlyclean-am:  mostlyclean-generic
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
 
-mostlyclean: mostlyclean-am
+clean-am: clean-generic clean-libtool mostlyclean-am
 
-clean-am:  clean-generic mostlyclean-am
+distclean: distclean-am
+	-rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-libtool
 
-clean: clean-am
+dvi: dvi-am
 
-distclean-am:  distclean-generic clean-am
-	-rm -f libtool
+dvi-am:
 
-distclean: distclean-am
+html: html-am
 
-maintainer-clean-am:  maintainer-clean-generic distclean-am
-	@echo "This command is intended for maintainers to use;"
-	@echo "it deletes files that may require special tools to rebuild."
+info: info-am
 
+info-am:
+
+install-data-am:
+
+install-exec-am:
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
 maintainer-clean: maintainer-clean-am
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
 
-.PHONY: tags distdir info-am info dvi-am dvi check check-am \
-installcheck-am installcheck install-exec-am install-exec \
-install-data-am install-data install-am install uninstall-am uninstall \
-all-redirect all-am all installdirs mostlyclean-generic \
-distclean-generic clean-generic maintainer-clean-generic clean \
-mostlyclean distclean maintainer-clean
+mostlyclean: mostlyclean-am
 
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
 
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-info-am
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+	distclean distclean-generic distclean-libtool distdir dvi \
+	dvi-am html html-am info info-am install install-am \
+	install-data install-data-am install-exec install-exec-am \
+	install-info install-info-am install-man install-strip \
+	installcheck installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-generic \
+	mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am \
+	uninstall-info-am
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:

Modified: trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/speexenc/speexenc.dsp
===================================================================
--- trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/speexenc/speexenc.dsp	2005-10-20 12:16:14 UTC (rev 10201)
+++ trunk/oggdsf/src/lib/codecs/speex/libs/libspeex/win32/speexenc/speexenc.dsp	2005-10-20 12:42:06 UTC (rev 10202)
@@ -25,7 +25,7 @@
 # PROP AllowPerConfigDependencies 0
 # PROP Scc_ProjName ""
 # PROP Scc_LocalPath ""
-CPP=xicl6.exe
+CPP=cl.exe
 RSC=rc.exe
 
 !IF  "$(CFG)" == "speexenc - Win32 Release"
@@ -42,15 +42,15 @@
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /GX /O1 /Ob2 /I "../../libspeex" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /GX /Ox /Ot /Og /Oi /Ob2 /I "../../libspeex" /I "../../../ogg/include" /I "../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
 # ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG"
 BSC32=bscmake.exe
 # ADD BASE BSC32 /nologo
 # ADD BSC32 /nologo
-LINK32=xilink6.exe
+LINK32=link.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:"LIBCMT.lib"
 
 !ELSEIF  "$(CFG)" == "speexenc - Win32 Debug"
 
@@ -66,13 +66,13 @@
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../libspeex" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../libspeex" /I "../../../ogg/include" /I "../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
 # ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG"
 BSC32=bscmake.exe
 # ADD BASE BSC32 /nologo
 # ADD BSC32 /nologo
-LINK32=xilink6.exe
+LINK32=link.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
 



More information about the commits mailing list