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