[xiph-commits] r14966 - in trunk/speex: . doc libspeex src

jm at svn.xiph.org jm at svn.xiph.org
Tue May 27 04:12:09 PDT 2008


Author: jm
Date: 2008-05-27 04:12:08 -0700 (Tue, 27 May 2008)
New Revision: 14966

Modified:
   trunk/speex/configure.ac
   trunk/speex/doc/manual.lyx
   trunk/speex/libspeex/Makefile.am
   trunk/speex/libspeex/fftwrap.c
   trunk/speex/speexdsp.pc.in
   trunk/speex/src/Makefile.am
Log:
Patch by Thorvald Natvig to add FFTW3 support


Modified: trunk/speex/configure.ac
===================================================================
--- trunk/speex/configure.ac	2008-05-27 10:25:03 UTC (rev 14965)
+++ trunk/speex/configure.ac	2008-05-27 11:12:08 UTC (rev 14966)
@@ -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=""])

Modified: trunk/speex/doc/manual.lyx
===================================================================
--- trunk/speex/doc/manual.lyx	2008-05-27 10:25:03 UTC (rev 14965)
+++ trunk/speex/doc/manual.lyx	2008-05-27 11:12:08 UTC (rev 14966)
@@ -45,7 +45,7 @@
 \begin_body
 
 \begin_layout Title
-The Speex Codec Manual
+The Speex Manual
 \newline
 Version 1.2
 \end_layout

Modified: trunk/speex/libspeex/Makefile.am
===================================================================
--- trunk/speex/libspeex/Makefile.am	2008-05-27 10:25:03 UTC (rev 14965)
+++ trunk/speex/libspeex/Makefile.am	2008-05-27 11:12:08 UTC (rev 14966)
@@ -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@

Modified: trunk/speex/libspeex/fftwrap.c
===================================================================
--- trunk/speex/libspeex/fftwrap.c	2008-05-27 10:25:03 UTC (rev 14965)
+++ trunk/speex/libspeex/fftwrap.c	2008-05-27 11:12:08 UTC (rev 14966)
@@ -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"

Modified: trunk/speex/speexdsp.pc.in
===================================================================
--- trunk/speex/speexdsp.pc.in	2008-05-27 10:25:03 UTC (rev 14965)
+++ trunk/speex/speexdsp.pc.in	2008-05-27 11:12:08 UTC (rev 14966)
@@ -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

Modified: trunk/speex/src/Makefile.am
===================================================================
--- trunk/speex/src/Makefile.am	2008-05-27 10:25:03 UTC (rev 14965)
+++ trunk/speex/src/Makefile.am	2008-05-27 11:12:08 UTC (rev 14966)
@@ -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@



More information about the commits mailing list