annotate ext/kissfft/kiss_fft.h @ 515:08bcc06c38ec tip master

Remove fast-math
author Chris Cannam <cannam@all-day-breakfast.com>
date Tue, 28 Jan 2020 15:27:37 +0000
parents 1f1999b0f577
children
rev   line source
c@409 1 #ifndef KISS_FFT_H
c@409 2 #define KISS_FFT_H
c@409 3
c@409 4 #include <stdlib.h>
c@409 5 #include <stdio.h>
c@409 6 #include <math.h>
c@409 7 #include <string.h>
c@409 8
c@409 9 #ifdef __cplusplus
c@409 10 extern "C" {
c@409 11 #endif
c@409 12
c@409 13 /*
c@409 14 ATTENTION!
c@409 15 If you would like a :
c@409 16 -- a utility that will handle the caching of fft objects
c@409 17 -- real-only (no imaginary time component ) FFT
c@409 18 -- a multi-dimensional FFT
c@409 19 -- a command-line utility to perform ffts
c@409 20 -- a command-line utility to perform fast-convolution filtering
c@409 21
c@409 22 Then see kfc.h kiss_fftr.h kiss_fftnd.h fftutil.c kiss_fastfir.c
c@409 23 in the tools/ directory.
c@409 24 */
c@409 25
c@409 26 #ifdef USE_SIMD
c@409 27 # include <xmmintrin.h>
c@409 28 # define kiss_fft_scalar __m128
c@409 29 #define KISS_FFT_MALLOC(nbytes) _mm_malloc(nbytes,16)
c@409 30 #define KISS_FFT_FREE _mm_free
c@409 31 #else
c@409 32 #define KISS_FFT_MALLOC malloc
c@409 33 #define KISS_FFT_FREE free
c@409 34 #endif
c@409 35
c@409 36
c@409 37 #ifdef FIXED_POINT
c@409 38 #include <sys/types.h>
c@409 39 # if (FIXED_POINT == 32)
c@409 40 # define kiss_fft_scalar int32_t
c@409 41 # else
c@409 42 # define kiss_fft_scalar int16_t
c@409 43 # endif
c@409 44 #else
c@409 45 # ifndef kiss_fft_scalar
c@409 46 /* default is float */
c@409 47 # define kiss_fft_scalar float
c@409 48 # endif
c@409 49 #endif
c@409 50
c@409 51 typedef struct {
c@409 52 kiss_fft_scalar r;
c@409 53 kiss_fft_scalar i;
c@409 54 }kiss_fft_cpx;
c@409 55
c@409 56 typedef struct kiss_fft_state* kiss_fft_cfg;
c@409 57
c@409 58 /*
c@409 59 * kiss_fft_alloc
c@409 60 *
c@409 61 * Initialize a FFT (or IFFT) algorithm's cfg/state buffer.
c@409 62 *
c@409 63 * typical usage: kiss_fft_cfg mycfg=kiss_fft_alloc(1024,0,NULL,NULL);
c@409 64 *
c@409 65 * The return value from fft_alloc is a cfg buffer used internally
c@409 66 * by the fft routine or NULL.
c@409 67 *
c@409 68 * If lenmem is NULL, then kiss_fft_alloc will allocate a cfg buffer using malloc.
c@409 69 * The returned value should be free()d when done to avoid memory leaks.
c@409 70 *
c@409 71 * The state can be placed in a user supplied buffer 'mem':
c@409 72 * If lenmem is not NULL and mem is not NULL and *lenmem is large enough,
c@409 73 * then the function places the cfg in mem and the size used in *lenmem
c@409 74 * and returns mem.
c@409 75 *
c@409 76 * If lenmem is not NULL and ( mem is NULL or *lenmem is not large enough),
c@409 77 * then the function returns NULL and places the minimum cfg
c@409 78 * buffer size in *lenmem.
c@409 79 * */
c@409 80
c@409 81 kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem);
c@409 82
c@409 83 /*
c@409 84 * kiss_fft(cfg,in_out_buf)
c@409 85 *
c@409 86 * Perform an FFT on a complex input buffer.
c@409 87 * for a forward FFT,
c@409 88 * fin should be f[0] , f[1] , ... ,f[nfft-1]
c@409 89 * fout will be F[0] , F[1] , ... ,F[nfft-1]
c@409 90 * Note that each element is complex and can be accessed like
c@409 91 f[k].r and f[k].i
c@409 92 * */
c@409 93 void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout);
c@409 94
c@409 95 /*
c@409 96 A more generic version of the above function. It reads its input from every Nth sample.
c@409 97 * */
c@409 98 void kiss_fft_stride(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int fin_stride);
c@409 99
c@409 100 /* If kiss_fft_alloc allocated a buffer, it is one contiguous
c@409 101 buffer and can be simply free()d when no longer needed*/
c@409 102 #define kiss_fft_free free
c@409 103
c@409 104 /*
c@409 105 Cleans up some memory that gets managed internally. Not necessary to call, but it might clean up
c@409 106 your compiler output to call this before you exit.
c@409 107 */
c@409 108 void kiss_fft_cleanup(void);
c@409 109
c@409 110
c@409 111 /*
c@409 112 * Returns the smallest integer k, such that k>=n and k has only "fast" factors (2,3,5)
c@409 113 */
c@409 114 int kiss_fft_next_fast_size(int n);
c@409 115
c@409 116 /* for real ffts, we need an even size */
c@409 117 #define kiss_fftr_next_fast_size_real(n) \
c@409 118 (kiss_fft_next_fast_size( ((n)+1)>>1)<<1)
c@409 119
c@409 120 #ifdef __cplusplus
c@409 121 }
c@409 122 #endif
c@409 123
c@409 124 #endif