diff options
author | jm <jm@0101bb08-14d6-0310-b084-bc0e0c8e3800> | 2008-05-27 15:12:08 +0400 |
---|---|---|
committer | jm <jm@0101bb08-14d6-0310-b084-bc0e0c8e3800> | 2008-05-27 15:12:08 +0400 |
commit | 3ea24daa971f5aa64f522c4d5a30988e35cf55bc (patch) | |
tree | c0b6fd61ed3525aaa0cdeb190adee5177537b158 | |
parent | 6a8a2d36ad8663087409f1f83792569f7ab4d8ae (diff) |
Patch by Thorvald Natvig to add FFTW3 support
git-svn-id: http://svn.xiph.org/trunk/speex@14966 0101bb08-14d6-0310-b084-bc0e0c8e3800
-rw-r--r-- | configure.ac | 8 | ||||
-rw-r--r-- | doc/manual.lyx | 2 | ||||
-rw-r--r-- | libspeex/Makefile.am | 10 | ||||
-rw-r--r-- | libspeex/fftwrap.c | 80 | ||||
-rw-r--r-- | speexdsp.pc.in | 2 | ||||
-rw-r--r-- | src/Makefile.am | 4 |
6 files changed, 96 insertions, 10 deletions
diff --git a/configure.ac b/configure.ac index 0252620..0134c67 100644 --- a/configure.ac +++ b/configure.ac @@ -110,7 +110,15 @@ CFLAGS="$SAVE_CFLAGS" ) 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=""]) diff --git a/doc/manual.lyx b/doc/manual.lyx index b801cbd..f41feba 100644 --- a/doc/manual.lyx +++ b/doc/manual.lyx @@ -45,7 +45,7 @@ \begin_body \begin_layout Title -The Speex Codec Manual +The Speex Manual \newline Version 1.2 \end_layout diff --git a/libspeex/Makefile.am b/libspeex/Makefile.am index b0c5bef..5271839 100644 --- a/libspeex/Makefile.am +++ b/libspeex/Makefile.am @@ -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 @@ noinst_PROGRAMS = testenc testenc_wb testenc_uwb testdenoise testecho testjitter 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@ diff --git a/libspeex/fftwrap.c b/libspeex/fftwrap.c index 0b462c2..37d8fae 100644 --- a/libspeex/fftwrap.c +++ b/libspeex/fftwrap.c @@ -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 @@ void spx_ifft(void *table, float *in, float *out) 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" diff --git a/speexdsp.pc.in b/speexdsp.pc.in index d9f75b7..2fa5ee1 100644 --- a/speexdsp.pc.in +++ b/speexdsp.pc.in @@ -8,7 +8,7 @@ includedir=@includedir@ 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 diff --git a/src/Makefile.am b/src/Makefile.am index 9997271..87a03f3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,8 +18,8 @@ bin_PROGRAMS = speexenc speexdec 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@ |