Changeset 0ad2e17 for src


Ignore:
Timestamp:
Oct 1, 2017, 3:32:35 PM (2 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master
Children:
379ef6c
Parents:
4b943729
Message:

src/spectral/fft.c: define ipp aliases for single/double precision

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/spectral/fft.c

    r4b943729 r0ad2e17  
    114114#elif defined HAVE_INTEL_IPP // using INTEL IPP
    115115
    116 #include <ippcore.h>
    117 #include <ippvm.h>
    118 #include <ipps.h>
     116#if !HAVE_AUBIO_DOUBLE
     117#define aubio_IppFloat                 Ipp32f
     118#define aubio_IppComplex               Ipp32fc
     119#define aubio_FFTSpec                  FFTSpec_R_32f
     120#define aubio_ippsPhas                 ippsPhase_32fc
     121#define aubio_ippsMalloc_complex       ippsMalloc_32fc
     122#define aubio_ippsFFTInit_R            ippsFFTInit_R_32f
     123#define aubio_ippsFFTGetSize_R         ippsFFTGetSize_R_32f
     124#define aubio_ippsFFTInv_CCSToR        ippsFFTInv_CCSToR_32f
     125#define aubio_ippsFFTFwd_RToCCS        ippsFFTFwd_RToCCS_32f
     126#else /* HAVE_AUBIO_DOUBLE */
     127#define aubio_IppFloat                 Ipp64f
     128#define aubio_IppComplex               Ipp64fc
     129#define aubio_FFTSpec                  FFTSpec_R_64f
     130#define aubio_ippsPhas                 ippsPhase_64fc
     131#define aubio_ippsMalloc_complex       ippsMalloc_64fc
     132#define aubio_ippsFFTInit_R            ippsFFTInit_R_64f
     133#define aubio_ippsFFTGetSize_R         ippsFFTGetSize_R_64f
     134#define aubio_ippsFFTInv_CCSToR        ippsFFTInv_CCSToR_64f
     135#define aubio_ippsFFTFwd_RToCCS        ippsFFTFwd_RToCCS_64f
     136#endif
     137
    119138
    120139#else // using OOURA
     
    146165  Ipp8u* memInit;
    147166  Ipp8u* memBuffer;
    148   #if HAVE_AUBIO_DOUBLE
    149     struct FFTSpec_R_64f* fftSpec;
    150     Ipp64fc* complexOut;
    151   #else
    152     struct FFTSpec_R_32f* fftSpec;
    153     Ipp32fc* complexOut;
    154   #endif
     167  struct aubio_FFTSpec* fftSpec;
     168  aubio_IppComplex* complexOut;
    155169#else                         // using OOURA
    156170  smpl_t *in, *out;
     
    223237  }
    224238
    225 #if HAVE_AUBIO_DOUBLE
    226   status = ippsFFTGetSize_R_64f(order, flags, qualityHint,
     239  status = aubio_ippsFFTGetSize_R(order, flags, qualityHint,
    227240      &sizeSpec, &sizeInit, &sizeBuffer);
    228 #else
    229   status = ippsFFTGetSize_R_32f(order, flags, qualityHint,
    230     &sizeSpec, &sizeInit, &sizeBuffer);
    231 #endif
    232241  if (status != ippStsNoErr) {
    233242    AUBIO_ERR("fft: failed to initialize fft. IPP error: %d\n", status);
     
    243252    s->memInit = ippsMalloc_8u(sizeInit);
    244253  }
    245 #if HAVE_AUBIO_DOUBLE
    246   s->complexOut = ippsMalloc_64fc(s->fft_size / 2 + 1);
    247   status = ippsFFTInit_R_64f(
     254  s->complexOut = aubio_ippsMalloc_complex(s->fft_size / 2 + 1);
     255  status = aubio_ippsFFTInit_R(
    248256    &s->fftSpec, order, flags, qualityHint, s->memSpec, s->memInit);
    249 #else
    250   s->complexOut = ippsMalloc_32fc(s->fft_size / 2 + 1);
    251   status = ippsFFTInit_R_32f(
    252     &s->fftSpec, order, flags, qualityHint, s->memSpec, s->memInit);
    253 #endif
    254257  if (status != ippStsNoErr) {
    255258    AUBIO_ERR("fft: failed to initialize. IPP error: %d\n", status);
     
    365368
    366369  // apply fft
    367 #if HAVE_AUBIO_DOUBLE
    368   ippsFFTFwd_RToCCS_64f(s->in, (Ipp64f*)s->complexOut, s->fftSpec, s->memBuffer);
    369 #else
    370   ippsFFTFwd_RToCCS_32f(s->in, (Ipp32f*)s->complexOut, s->fftSpec, s->memBuffer);
    371 #endif
     370  aubio_ippsFFTFwd_RToCCS(s->in, (aubio_IppFloat*)s->complexOut, s->fftSpec, s->memBuffer);
    372371  // convert complex buffer to [ r0, r1, ..., rN, iN-1, .., i2, i1]
    373372  compspec->data[0] = s->complexOut[0].re;
     
    378377  }
    379378  // apply scaling
    380 #if HAVE_AUBIO_DOUBLE
    381   ippsMulC_64f(compspec->data, 1.0 / 2.0, compspec->data, s->fft_size);
    382 #else
    383   ippsMulC_32f(compspec->data, 1.0 / 2.0, compspec->data, s->fft_size);
    384 #endif
     379  aubio_ippsMulC(compspec->data, 1.0 / 2.0, compspec->data, s->fft_size);
    385380
    386381#else                         // using OOURA
     
    446441    s->complexOut[i].im = compspec->data[s->fft_size - i];
    447442  }
    448 #if HAVE_AUBIO_DOUBLE
    449443  // apply fft
    450   ippsFFTInv_CCSToR_64f((const Ipp64f *)s->complexOut, output->data, s->fftSpec, s->memBuffer);
     444  aubio_ippsFFTInv_CCSToR((const aubio_IppFloat *)s->complexOut, output->data, s->fftSpec, s->memBuffer);
    451445  // apply scaling
    452   ippsMulC_64f(output->data, 2.0 / s->winsize, output->data, s->fft_size);
    453 #else
    454   // apply fft
    455   ippsFFTInv_CCSToR_32f((const Ipp32f *)s->complexOut, output->data, s->fftSpec, s->memBuffer);
    456   // apply scaling
    457   ippsMulC_32f(output->data, 2.0f / s->winsize, output->data, s->fft_size);
    458 #endif /* HAVE_AUBIO_DOUBLE */
     446  aubio_ippsMulC(output->data, 1.0 / s->winsize, output->data, s->fft_size);
    459447
    460448#else                         // using OOURA
     
    497485    s->complexOut[i].im = compspec->data[compspec->length - i];
    498486  }
    499  
    500 #if HAVE_AUBIO_DOUBLE
    501   IppStatus status = ippsPhase_64fc(s->complexOut, spectrum->phas, spectrum->length);
    502 #else
    503   IppStatus status = ippsPhase_32fc(s->complexOut, spectrum->phas, spectrum->length);
    504 #endif
     487
     488  IppStatus status = aubio_ippsPhas(s->complexOut, spectrum->phas, spectrum->length);
    505489  if (status != ippStsNoErr) {
    506490    AUBIO_ERR("fft: failed to extract phase from fft. IPP error: %d\n", status);
Note: See TracChangeset for help on using the changeset viewer.