summaryrefslogtreecommitdiff
path: root/kiss_fft.h
diff options
context:
space:
mode:
Diffstat (limited to 'kiss_fft.h')
-rw-r--r--kiss_fft.h60
1 files changed, 31 insertions, 29 deletions
diff --git a/kiss_fft.h b/kiss_fft.h
index c01722c..ea1349e 100644
--- a/kiss_fft.h
+++ b/kiss_fft.h
@@ -1,9 +1,9 @@
1#ifndef KISS_FFT_H 1#ifndef KISS_FFT_H
2#define KISS_FFT_H 2#define KISS_FFT_H
3 3
4#include <stdlib.h>
5#include <stdio.h>
6#include <math.h> 4#include <math.h>
5#include <stdio.h>
6#include <stdlib.h>
7#include <string.h> 7#include <string.h>
8 8
9#ifdef __cplusplus 9#ifdef __cplusplus
@@ -24,36 +24,35 @@ extern "C" {
24*/ 24*/
25 25
26#ifdef USE_SIMD 26#ifdef USE_SIMD
27# include <xmmintrin.h> 27#include <xmmintrin.h>
28# define kiss_fft_scalar __m128 28#define kiss_fft_scalar __m128
29#define KISS_FFT_MALLOC(nbytes) _mm_malloc(nbytes,16) 29#define KISS_FFT_MALLOC(nbytes) _mm_malloc(nbytes, 16)
30#define KISS_FFT_FREE _mm_free 30#define KISS_FFT_FREE _mm_free
31#else 31#else
32#define KISS_FFT_MALLOC malloc 32#define KISS_FFT_MALLOC malloc
33#define KISS_FFT_FREE free 33#define KISS_FFT_FREE free
34#endif 34#endif
35 35
36
37#ifdef FIXED_POINT 36#ifdef FIXED_POINT
38#include <sys/types.h> 37#include <sys/types.h>
39# if (FIXED_POINT == 32) 38#if (FIXED_POINT == 32)
40# define kiss_fft_scalar int32_t 39#define kiss_fft_scalar int32_t
41# else
42# define kiss_fft_scalar int16_t
43# endif
44#else 40#else
45# ifndef kiss_fft_scalar 41#define kiss_fft_scalar int16_t
42#endif
43#else
44#ifndef kiss_fft_scalar
46/* default is float */ 45/* default is float */
47# define kiss_fft_scalar float 46#define kiss_fft_scalar float
48# endif 47#endif
49#endif 48#endif
50 49
51typedef struct { 50typedef struct {
52 kiss_fft_scalar r; 51 kiss_fft_scalar r;
53 kiss_fft_scalar i; 52 kiss_fft_scalar i;
54}kiss_fft_cpx; 53} kiss_fft_cpx;
55 54
56typedef struct kiss_fft_state* kiss_fft_cfg; 55typedef struct kiss_fft_state *kiss_fft_cfg;
57 56
58/* 57/*
59 * kiss_fft_alloc 58 * kiss_fft_alloc
@@ -65,8 +64,8 @@ typedef struct kiss_fft_state* kiss_fft_cfg;
65 * The return value from fft_alloc is a cfg buffer used internally 64 * The return value from fft_alloc is a cfg buffer used internally
66 * by the fft routine or NULL. 65 * by the fft routine or NULL.
67 * 66 *
68 * If lenmem is NULL, then kiss_fft_alloc will allocate a cfg buffer using malloc. 67 * If lenmem is NULL, then kiss_fft_alloc will allocate a cfg buffer using
69 * The returned value should be free()d when done to avoid memory leaks. 68 * malloc. The returned value should be free()d when done to avoid memory leaks.
70 * 69 *
71 * The state can be placed in a user supplied buffer 'mem': 70 * The state can be placed in a user supplied buffer 'mem':
72 * If lenmem is not NULL and mem is not NULL and *lenmem is large enough, 71 * If lenmem is not NULL and mem is not NULL and *lenmem is large enough,
@@ -78,7 +77,8 @@ typedef struct kiss_fft_state* kiss_fft_cfg;
78 * buffer size in *lenmem. 77 * buffer size in *lenmem.
79 * */ 78 * */
80 79
81kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem); 80kiss_fft_cfg kiss_fft_alloc(int nfft, int inverse_fft, void *mem,
81 size_t *lenmem);
82 82
83/* 83/*
84 * kiss_fft(cfg,in_out_buf) 84 * kiss_fft(cfg,in_out_buf)
@@ -90,32 +90,34 @@ kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem)
90 * Note that each element is complex and can be accessed like 90 * Note that each element is complex and can be accessed like
91 f[k].r and f[k].i 91 f[k].r and f[k].i
92 * */ 92 * */
93void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout); 93void kiss_fft(kiss_fft_cfg cfg, const kiss_fft_cpx *fin, kiss_fft_cpx *fout);
94 94
95/* 95/*
96 A more generic version of the above function. It reads its input from every Nth sample. 96 A more generic version of the above function. It reads its input from every Nth
97 sample.
97 * */ 98 * */
98void kiss_fft_stride(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int fin_stride); 99void kiss_fft_stride(kiss_fft_cfg cfg, const kiss_fft_cpx *fin,
100 kiss_fft_cpx *fout, int fin_stride);
99 101
100/* If kiss_fft_alloc allocated a buffer, it is one contiguous 102/* If kiss_fft_alloc allocated a buffer, it is one contiguous
101 buffer and can be simply free()d when no longer needed*/ 103 buffer and can be simply free()d when no longer needed*/
102#define kiss_fft_free free 104#define kiss_fft_free free
103 105
104/* 106/*
105 Cleans up some memory that gets managed internally. Not necessary to call, but it might clean up 107 Cleans up some memory that gets managed internally. Not necessary to call, but
106 your compiler output to call this before you exit. 108 it might clean up your compiler output to call this before you exit.
107*/ 109*/
108void kiss_fft_cleanup(void); 110void kiss_fft_cleanup(void);
109 111
110
111/* 112/*
112 * Returns the smallest integer k, such that k>=n and k has only "fast" factors (2,3,5) 113 * Returns the smallest integer k, such that k>=n and k has only "fast" factors
114 * (2,3,5)
113 */ 115 */
114int kiss_fft_next_fast_size(int n); 116int kiss_fft_next_fast_size(int n);
115 117
116/* for real ffts, we need an even size */ 118/* for real ffts, we need an even size */
117#define kiss_fftr_next_fast_size_real(n) \ 119#define kiss_fftr_next_fast_size_real(n) \
118 (kiss_fft_next_fast_size( ((n)+1)>>1)<<1) 120 (kiss_fft_next_fast_size(((n) + 1) >> 1) << 1)
119 121
120#ifdef __cplusplus 122#ifdef __cplusplus
121} 123}