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