annotate dsp/transforms/kissfft/kiss_fft.h @ 297:b74f91bd5c7d

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