[xiph-commits] r14975 - in trunk/speex: . libspeex

jm at svn.xiph.org jm at svn.xiph.org
Wed May 28 05:43:16 PDT 2008


Author: jm
Date: 2008-05-28 05:43:15 -0700 (Wed, 28 May 2008)
New Revision: 14975

Modified:
   trunk/speex/configure.ac
   trunk/speex/libspeex/fftwrap.c
Log:
Patch by Thorvald Natvig to add Intel MKL support for the FFT


Modified: trunk/speex/configure.ac
===================================================================
--- trunk/speex/configure.ac	2008-05-27 21:39:21 UTC (rev 14974)
+++ trunk/speex/configure.ac	2008-05-28 12:43:15 UTC (rev 14975)
@@ -121,7 +121,28 @@
    AC_SUBST([FFTW3_PKGCONFIG], [fftw3f])
   ]])
 )
-   
+
+AC_ARG_WITH([intel-mkl], [AS_HELP_STRING([--with-intel-mkl],[enable experimental support for Intel Math Kernel Library for FFT])],[],[with_intel_mkl=no])
+AS_IF([test "x$with_intel_mkl" != "xno"],[
+ AC_MSG_CHECKING(for valid MKL)
+ AC_LINK_IFELSE([
+ AC_LANG_PROGRAM([[
+#include <mkl.h>
+void func() {
+  DFTI_DESCRIPTOR_HANDLE h;
+  MKL_LONG result=DftiCreateDescriptor(&h, DFTI_SINGLE, DFTI_REAL, 0);
+}
+ ]])],
+  [
+   AC_DEFINE([USE_INTEL_MKL], [], [Use Intel Math Kernel Library for FFT])
+   AC_MSG_RESULT(yes)
+  ],
+  [
+   AC_MSG_FAILURE([Failed to compile MKL test program. Make sure you set CFLAGS to include the include directory and set LDFLAGS to include the library directory and all necesarry libraries.])
+  ]
+ )
+])
+
 AC_CHECK_HEADERS(sys/soundcard.h sys/audioio.h)
 
 XIPH_PATH_OGG([src="src"], [src=""])

Modified: trunk/speex/libspeex/fftwrap.c
===================================================================
--- trunk/speex/libspeex/fftwrap.c	2008-05-27 21:39:21 UTC (rev 14974)
+++ trunk/speex/libspeex/fftwrap.c	2008-05-28 12:43:15 UTC (rev 14975)
@@ -40,9 +40,11 @@
 #define USE_KISS_FFT
 #else
 #ifndef USE_GPL_FFTW3
+#ifndef USE_INTEL_MKL
 #define USE_SMALLFT
 #endif
 #endif
+#endif
 
 
 #include "arch.h"
@@ -135,6 +137,45 @@
    spx_drft_backward((struct drft_lookup *)table, out);
 }
 
+#elif defined(USE_INTEL_MKL)
+#include <mkl.h>
+
+struct mkl_config {
+  DFTI_DESCRIPTOR_HANDLE desc;
+  int N;
+};
+
+void *spx_fft_init(int size)
+{
+  struct mkl_config *table = (struct mkl_config *) speex_alloc(sizeof(struct mkl_config));
+  table->N = size;
+  DftiCreateDescriptor(&table->desc, DFTI_SINGLE, DFTI_REAL, 1, size);
+  DftiSetValue(table->desc, DFTI_PACKED_FORMAT, DFTI_PACK_FORMAT);
+  DftiSetValue(table->desc, DFTI_PLACEMENT, DFTI_NOT_INPLACE);
+  DftiSetValue(table->desc, DFTI_FORWARD_SCALE, 1.0f / size);
+  DftiCommitDescriptor(table->desc);
+  return table;
+}
+
+void spx_fft_destroy(void *table)
+{
+  struct mkl_config *t = (struct mkl_config *) table;
+  DftiFreeDescriptor(t->desc);
+  speex_free(table);
+}
+
+void spx_fft(void *table, spx_word16_t *in, spx_word16_t *out)
+{
+  struct mkl_config *t = (struct mkl_config *) table;
+  DftiComputeForward(t->desc, in, out);
+}
+
+void spx_ifft(void *table, spx_word16_t *in, spx_word16_t *out)
+{
+  struct mkl_config *t = (struct mkl_config *) table;
+  DftiComputeBackward(t->desc, in, out);
+}
+
 #elif defined(USE_GPL_FFTW3)
 
 #include <fftw3.h>



More information about the commits mailing list