annotate src/rubberband-1.8.1/src/kissfft/kiss_fft.h @ 137:b38f6c5a0453

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