Debian Codegraph @

src/kiss_fft/kiss_fft.h

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