Project: Speex
Revision: 14966
Author: jm
Date: 27 May 2008 07:12:08
Changes:Patch by Thorvald Natvig to add FFTW3 support
Files:modified: /trunk/speex/doc/manual.lyx (
try)
modified: /trunk/speex/src/Makefile.am (
try)
modified: /trunk/speex/speexdsp.pc.in (
try)
modified: /trunk/speex/configure.ac (
try)
modified: /trunk/speex/libspeex/Makefile.am (
try)
modified: /trunk/speex/libspeex/fftwrap.c (
try)
Diff:
| ... | ...@@ -45,7 +45,7 @@ |
| 45 | 45 | \begin_body |
| 46 | 46 | |
| 47 | 47 | \begin_layout Title |
| 48 | | The Speex Codec Manual |
| 48 | The Speex Manual |
| 49 | 49 | \newline |
| 50 | 50 | Version 1.2 |
| 51 | 51 | \end_layout |
| ... | ...@@ -18,8 +18,8 @@ |
| 18 | 18 | |
| 19 | 19 | speexenc_SOURCES = speexenc.c wav_io.c skeleton.c |
| 20 | 20 | speexenc_LDADD = $(top_builddir)/libspeex/libspeex.la $(top_builddir)/libspeex/libspeexdsp.la \ |
| 21 | | $(OGG_LIBS) |
| 21 | $(OGG_LIBS) @FFTW3_LIBS@ |
| 22 | 22 | |
| 23 | 23 | speexdec_SOURCES = speexdec.c wav_io.c |
| 24 | 24 | speexdec_LDADD = $(top_builddir)/libspeex/libspeex.la \ |
| 25 | | $(OGG_LIBS) |
| 25 | $(OGG_LIBS) @FFTW3_LIBS@ |
| ... | ...@@ -8,7 +8,7 @@ |
| 8 | 8 | Name: speexdsp |
| 9 | 9 | Description: Speexdsp is a speech processing library that goes along with the Speex codec |
| 10 | 10 | Version: @SPEEX_VERSION@ |
| 11 | | Requires: |
| 11 | Requires: @FFTW3_PKGCONFIG@ |
| 12 | 12 | Conflicts: |
| 13 | 13 | Libs: -L${libdir} -lspeexdsp |
| 14 | 14 | Libs.private: -lm |
| ... | ...@@ -110,7 +110,15 @@ |
| 110 | 110 | ) |
| 111 | 111 | AC_MSG_RESULT($has_visibility) |
| 112 | 112 | |
| 113 | AC_ARG_WITH([gpl-fftw3], [AS_HELP_STRING([--with-gpl-fftw3],[enable experimental support for FFTW3 library for FFT])],[],[with_fftw3=no]) |
| 113 | 114 | |
| 115 | AS_IF([test "x$with_fftw3" != "xno"], |
| 116 | [PKG_CHECK_MODULES(FFTW3, fftw3f, [ |
| 117 | AC_DEFINE([USE_GPL_FFTW3], [], [Use FFTW3 for FFT]) |
| 118 | AC_SUBST([FFTW3_PKGCONFIG], [fftw3f]) |
| 119 | ]]) |
| 120 | ) |
| 121 | |
| 114 | 122 | AC_CHECK_HEADERS(sys/soundcard.h sys/audioio.h) |
| 115 | 123 | |
| 116 | 124 | XIPH_PATH_OGG([src="src"], [src=""]) |
| ... | ...@@ -4,7 +4,7 @@ |
| 4 | 4 | |
| 5 | 5 | EXTRA_DIST=echo_diagnostic.m |
| 6 | 6 | |
| 7 | | INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_builddir) @OGG_CFLAGS@ |
| 7 | INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_builddir) @OGG_CFLAGS@ @FFTW3_CFLAGS@ |
| 8 | 8 | |
| 9 | 9 | lib_LTLIBRARIES = libspeex.la libspeexdsp.la |
| 10 | 10 | |
| ... | ...@@ -36,12 +36,12 @@ |
| 36 | 36 | testenc_SOURCES = testenc.c |
| 37 | 37 | testenc_LDADD = libspeex.la |
| 38 | 38 | testenc_wb_SOURCES = testenc_wb.c |
| 39 | | testenc_wb_LDADD = libspeex.la |
| 39 | testenc_wb_LDADD = libspeex.la |
| 40 | 40 | testenc_uwb_SOURCES = testenc_uwb.c |
| 41 | 41 | testenc_uwb_LDADD = libspeex.la |
| 42 | 42 | testdenoise_SOURCES = testdenoise.c |
| 43 | | testdenoise_LDADD = libspeexdsp.la |
| 43 | testdenoise_LDADD = libspeexdsp.la @FFTW3_LIBS@ |
| 44 | 44 | testecho_SOURCES = testecho.c |
| 45 | | testecho_LDADD = libspeexdsp.la |
| 45 | testecho_LDADD = libspeexdsp.la @FFTW3_LIBS@ |
| 46 | 46 | testjitter_SOURCES = testjitter.c |
| 47 | | testjitter_LDADD = libspeexdsp.la |
| 47 | testjitter_LDADD = libspeexdsp.la @FFTW3_LIBS@ |
| ... | ...@@ -36,8 +36,13 @@ |
| 36 | 36 | #include "config.h" |
| 37 | 37 | #endif |
| 38 | 38 | |
| 39 | | /*#define USE_SMALLFT*/ |
| 39 | #ifdef FIXED_POINT |
| 40 | 40 | #define USE_KISS_FFT |
| 41 | #else |
| 42 | #ifndef USE_GPL_FFTW3 |
| 43 | #define USE_SMALLFT |
| 44 | #endif |
| 45 | #endif |
| 41 | 46 | |
| 42 | 47 | |
| 43 | 48 | #include "arch.h" |
| ... | ...@@ -130,6 +135,79 @@ |
| 130 | 135 | spx_drft_backward((struct drft_lookup *)table, out); |
| 131 | 136 | } |
| 132 | 137 | |
| 138 | #elif defined(USE_GPL_FFTW3) |
| 139 | |
| 140 | #include <fftw3.h> |
| 141 | |
| 142 | struct fftw_config { |
| 143 | float *in; |
| 144 | float *out; |
| 145 | fftwf_plan fft; |
| 146 | fftwf_plan ifft; |
| 147 | int N; |
| 148 | }; |
| 149 | |
| 150 | void *spx_fft_init(int size) |
| 151 | { |
| 152 | struct fftw_config *table = (struct fftw_config *) speex_alloc(sizeof(struct fftw_config)); |
| 153 | table->in = fftwf_malloc(sizeof(float) * (size+2)); |
| 154 | table->out = fftwf_malloc(sizeof(float) * (size+2)); |
| 155 | |
| 156 | table->fft = fftwf_plan_dft_r2c_1d(size, table->in, (fftwf_complex *) table->out, FFTW_PATIENT); |
| 157 | table->ifft = fftwf_plan_dft_c2r_1d(size, (fftwf_complex *) table->in, table->out, FFTW_PATIENT); |
| 158 | |
| 159 | table->N = size; |
| 160 | return table; |
| 161 | } |
| 162 | |
| 163 | void spx_fft_destroy(void *table) |
| 164 | { |
| 165 | struct fftw_config *t = (struct fftw_config *) table; |
| 166 | fftwf_destroy_plan(t->fft); |
| 167 | fftwf_destroy_plan(t->ifft); |
| 168 | fftwf_free(t->in); |
| 169 | fftwf_free(t->out); |
| 170 | speex_free(table); |
| 171 | } |
| 172 | |
| 173 | |
| 174 | void spx_fft(void *table, spx_word16_t *in, spx_word16_t *out) |
| 175 | { |
| 176 | int i; |
| 177 | struct fftw_config *t = (struct fftw_config *) table; |
| 178 | const int N = t->N; |
| 179 | float *iptr = t->in; |
| 180 | float *optr = t->out; |
| 181 | const float m = 1.0 / N; |
| 182 | for(i=0;i<N;++i) |
| 183 | iptr[i]=in[i] * m; |
| 184 | |
| 185 | fftwf_execute(t->fft); |
| 186 | |
| 187 | out[0] = optr[0]; |
| 188 | for(i=1;i<N;++i) |
| 189 | out[i] = optr[i+1]; |
| 190 | } |
| 191 | |
| 192 | void spx_ifft(void *table, spx_word16_t *in, spx_word16_t *out) |
| 193 | { |
| 194 | int i; |
| 195 | struct fftw_config *t = (struct fftw_config *) table; |
| 196 | const int N = t->N; |
| 197 | float *iptr = t->in; |
| 198 | float *optr = t->out; |
| 199 | |
| 200 | iptr[0] = in[0]; |
| 201 | iptr[1] = 0.0f; |
| 202 | for(i=1;i<N;++i) |
| 203 | iptr[i+1] = in[i]; |
| 204 | |
| 205 | fftwf_execute(t->ifft); |
| 206 | |
| 207 | for(i=0;i<N;++i) |
| 208 | out[i] = optr[i]; |
| 209 | } |
| 210 | |
| 133 | 211 | #elif defined(USE_KISS_FFT) |
| 134 | 212 | |
| 135 | 213 | #include "kiss_fftr.h" |
To list