Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision 14950)
+++ src/Makefile.am	(working copy)
@@ -18,8 +18,8 @@
 
 speexenc_SOURCES = speexenc.c wav_io.c skeleton.c
 speexenc_LDADD = $(top_builddir)/libspeex/libspeex.la $(top_builddir)/libspeex/libspeexdsp.la \
-	$(OGG_LIBS)
+	$(OGG_LIBS)  @FFTW3_LIBS@	
 
 speexdec_SOURCES = speexdec.c wav_io.c
 speexdec_LDADD = $(top_builddir)/libspeex/libspeex.la \
-	$(OGG_LIBS)
+	$(OGG_LIBS)  @FFTW3_LIBS@
Index: speexdsp.pc.in
===================================================================
--- speexdsp.pc.in	(revision 14950)
+++ speexdsp.pc.in	(working copy)
@@ -8,7 +8,7 @@
 Name: speexdsp
 Description: Speexdsp is a speech processing library that goes along with the Speex codec
 Version: @SPEEX_VERSION@
-Requires:
+Requires: @FFTW3_PKGCONFIG@
 Conflicts:
 Libs: -L${libdir} -lspeexdsp
 Libs.private: -lm
Index: configure.ac
===================================================================
--- configure.ac	(revision 14950)
+++ configure.ac	(working copy)
@@ -110,7 +110,15 @@
 )
 AC_MSG_RESULT($has_visibility)
 
+AC_ARG_WITH([gpl-fftw3], [AS_HELP_STRING([--with-gpl-fftw3],[enable experimental support for FFTW3 library for FFT])],[],[with_fftw3=no])
 
+AS_IF([test "x$with_fftw3" != "xno"],
+  [PKG_CHECK_MODULES(FFTW3, fftw3f, [
+   AC_DEFINE([USE_GPL_FFTW3], [], [Use FFTW3 for FFT])
+   AC_SUBST([FFTW3_PKGCONFIG], [fftw3f])
+  ]])
+)
+   
 AC_CHECK_HEADERS(sys/soundcard.h sys/audioio.h)
 
 XIPH_PATH_OGG([src="src"], [src=""])
Index: libspeex/fftwrap.c
===================================================================
--- libspeex/fftwrap.c	(revision 14950)
+++ libspeex/fftwrap.c	(working copy)
@@ -36,8 +36,13 @@
 #include "config.h"
 #endif
 
-/*#define USE_SMALLFT*/
+#ifdef FIXED_POINT
 #define USE_KISS_FFT
+#else
+#ifndef USE_GPL_FFTW3
+#define USE_SMALLFT
+#endif
+#endif
 
 
 #include "arch.h"
@@ -130,6 +135,79 @@
    spx_drft_backward((struct drft_lookup *)table, out);
 }
 
+#elif defined(USE_GPL_FFTW3)
+
+#include <fftw3.h>
+
+struct fftw_config {
+  float *in;
+  float *out;
+  fftwf_plan fft;
+  fftwf_plan ifft;
+  int N;
+};
+
+void *spx_fft_init(int size)
+{
+  struct fftw_config *table = (struct fftw_config *) speex_alloc(sizeof(struct fftw_config));
+  table->in = fftwf_malloc(sizeof(float) * (size+2));
+  table->out = fftwf_malloc(sizeof(float) * (size+2));
+
+  table->fft = fftwf_plan_dft_r2c_1d(size, table->in, (fftwf_complex *) table->out, FFTW_PATIENT);
+  table->ifft = fftwf_plan_dft_c2r_1d(size, (fftwf_complex *) table->in, table->out, FFTW_PATIENT);
+
+  table->N = size;
+  return table;
+}
+
+void spx_fft_destroy(void *table)
+{
+  struct fftw_config *t = (struct fftw_config *) table;
+  fftwf_destroy_plan(t->fft);
+  fftwf_destroy_plan(t->ifft);
+  fftwf_free(t->in);
+  fftwf_free(t->out);
+  speex_free(table);
+}
+
+
+void spx_fft(void *table, spx_word16_t *in, spx_word16_t *out)
+{
+  int i;
+  struct fftw_config *t = (struct fftw_config *) table;
+  const int N = t->N;
+  float *iptr = t->in;
+  float *optr = t->out;
+  const float m = 1.0 / N;
+  for(i=0;i<N;++i)
+    iptr[i]=in[i] * m;
+
+  fftwf_execute(t->fft);
+
+  out[0] = optr[0];
+  for(i=1;i<N;++i)
+    out[i] = optr[i+1];
+}
+
+void spx_ifft(void *table, spx_word16_t *in, spx_word16_t *out) 
+{
+  int i;
+  struct fftw_config *t = (struct fftw_config *) table;
+  const int N = t->N;
+  float *iptr = t->in;
+  float *optr = t->out;
+
+  iptr[0] = in[0];
+  iptr[1] = 0.0f;
+  for(i=1;i<N;++i)
+    iptr[i+1] = in[i];
+
+  fftwf_execute(t->ifft);
+  
+  for(i=0;i<N;++i)
+    out[i] = optr[i];
+}
+
 #elif defined(USE_KISS_FFT)
 
 #include "kiss_fftr.h"
Index: libspeex/Makefile.am
===================================================================
--- libspeex/Makefile.am	(revision 14950)
+++ libspeex/Makefile.am	(working copy)
@@ -4,7 +4,7 @@
 
 EXTRA_DIST=echo_diagnostic.m
 
-INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_builddir) @OGG_CFLAGS@
+INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_builddir) @OGG_CFLAGS@ @FFTW3_CFLAGS@
 
 lib_LTLIBRARIES = libspeex.la libspeexdsp.la
 
@@ -36,12 +36,12 @@
 testenc_SOURCES = testenc.c
 testenc_LDADD = libspeex.la
 testenc_wb_SOURCES = testenc_wb.c
-testenc_wb_LDADD = libspeex.la
+testenc_wb_LDADD = libspeex.la 
 testenc_uwb_SOURCES = testenc_uwb.c
 testenc_uwb_LDADD = libspeex.la
 testdenoise_SOURCES = testdenoise.c
-testdenoise_LDADD = libspeexdsp.la
+testdenoise_LDADD = libspeexdsp.la @FFTW3_LIBS@
 testecho_SOURCES = testecho.c
-testecho_LDADD = libspeexdsp.la
+testecho_LDADD = libspeexdsp.la @FFTW3_LIBS@
 testjitter_SOURCES = testjitter.c
-testjitter_LDADD = libspeexdsp.la
+testjitter_LDADD = libspeexdsp.la @FFTW3_LIBS@
