annotate src/opus-1.3/celt/kiss_fft.h @ 169:223a55898ab9 tip default

Add null config files
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 02 Mar 2020 14:03:47 +0000
parents 4664ac0c1032
children
rev   line source
cannam@154 1 /*Copyright (c) 2003-2004, Mark Borgerding
cannam@154 2 Lots of modifications by Jean-Marc Valin
cannam@154 3 Copyright (c) 2005-2007, Xiph.Org Foundation
cannam@154 4 Copyright (c) 2008, Xiph.Org Foundation, CSIRO
cannam@154 5
cannam@154 6 All rights reserved.
cannam@154 7
cannam@154 8 Redistribution and use in source and binary forms, with or without
cannam@154 9 modification, are permitted provided that the following conditions are met:
cannam@154 10
cannam@154 11 * Redistributions of source code must retain the above copyright notice,
cannam@154 12 this list of conditions and the following disclaimer.
cannam@154 13 * Redistributions in binary form must reproduce the above copyright notice,
cannam@154 14 this list of conditions and the following disclaimer in the
cannam@154 15 documentation and/or other materials provided with the distribution.
cannam@154 16
cannam@154 17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
cannam@154 18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
cannam@154 19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
cannam@154 20 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
cannam@154 21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
cannam@154 22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
cannam@154 23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
cannam@154 24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
cannam@154 25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
cannam@154 26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
cannam@154 27 POSSIBILITY OF SUCH DAMAGE.*/
cannam@154 28
cannam@154 29 #ifndef KISS_FFT_H
cannam@154 30 #define KISS_FFT_H
cannam@154 31
cannam@154 32 #include <stdlib.h>
cannam@154 33 #include <math.h>
cannam@154 34 #include "arch.h"
cannam@154 35 #include "cpu_support.h"
cannam@154 36
cannam@154 37 #ifdef __cplusplus
cannam@154 38 extern "C" {
cannam@154 39 #endif
cannam@154 40
cannam@154 41 #ifdef USE_SIMD
cannam@154 42 # include <xmmintrin.h>
cannam@154 43 # define kiss_fft_scalar __m128
cannam@154 44 #define KISS_FFT_MALLOC(nbytes) memalign(16,nbytes)
cannam@154 45 #else
cannam@154 46 #define KISS_FFT_MALLOC opus_alloc
cannam@154 47 #endif
cannam@154 48
cannam@154 49 #ifdef FIXED_POINT
cannam@154 50 #include "arch.h"
cannam@154 51
cannam@154 52 # define kiss_fft_scalar opus_int32
cannam@154 53 # define kiss_twiddle_scalar opus_int16
cannam@154 54
cannam@154 55
cannam@154 56 #else
cannam@154 57 # ifndef kiss_fft_scalar
cannam@154 58 /* default is float */
cannam@154 59 # define kiss_fft_scalar float
cannam@154 60 # define kiss_twiddle_scalar float
cannam@154 61 # define KF_SUFFIX _celt_single
cannam@154 62 # endif
cannam@154 63 #endif
cannam@154 64
cannam@154 65 typedef struct {
cannam@154 66 kiss_fft_scalar r;
cannam@154 67 kiss_fft_scalar i;
cannam@154 68 }kiss_fft_cpx;
cannam@154 69
cannam@154 70 typedef struct {
cannam@154 71 kiss_twiddle_scalar r;
cannam@154 72 kiss_twiddle_scalar i;
cannam@154 73 }kiss_twiddle_cpx;
cannam@154 74
cannam@154 75 #define MAXFACTORS 8
cannam@154 76 /* e.g. an fft of length 128 has 4 factors
cannam@154 77 as far as kissfft is concerned
cannam@154 78 4*4*4*2
cannam@154 79 */
cannam@154 80
cannam@154 81 typedef struct arch_fft_state{
cannam@154 82 int is_supported;
cannam@154 83 void *priv;
cannam@154 84 } arch_fft_state;
cannam@154 85
cannam@154 86 typedef struct kiss_fft_state{
cannam@154 87 int nfft;
cannam@154 88 opus_val16 scale;
cannam@154 89 #ifdef FIXED_POINT
cannam@154 90 int scale_shift;
cannam@154 91 #endif
cannam@154 92 int shift;
cannam@154 93 opus_int16 factors[2*MAXFACTORS];
cannam@154 94 const opus_int16 *bitrev;
cannam@154 95 const kiss_twiddle_cpx *twiddles;
cannam@154 96 arch_fft_state *arch_fft;
cannam@154 97 } kiss_fft_state;
cannam@154 98
cannam@154 99 #if defined(HAVE_ARM_NE10)
cannam@154 100 #include "arm/fft_arm.h"
cannam@154 101 #endif
cannam@154 102
cannam@154 103 /*typedef struct kiss_fft_state* kiss_fft_cfg;*/
cannam@154 104
cannam@154 105 /**
cannam@154 106 * opus_fft_alloc
cannam@154 107 *
cannam@154 108 * Initialize a FFT (or IFFT) algorithm's cfg/state buffer.
cannam@154 109 *
cannam@154 110 * typical usage: kiss_fft_cfg mycfg=opus_fft_alloc(1024,0,NULL,NULL);
cannam@154 111 *
cannam@154 112 * The return value from fft_alloc is a cfg buffer used internally
cannam@154 113 * by the fft routine or NULL.
cannam@154 114 *
cannam@154 115 * If lenmem is NULL, then opus_fft_alloc will allocate a cfg buffer using malloc.
cannam@154 116 * The returned value should be free()d when done to avoid memory leaks.
cannam@154 117 *
cannam@154 118 * The state can be placed in a user supplied buffer 'mem':
cannam@154 119 * If lenmem is not NULL and mem is not NULL and *lenmem is large enough,
cannam@154 120 * then the function places the cfg in mem and the size used in *lenmem
cannam@154 121 * and returns mem.
cannam@154 122 *
cannam@154 123 * If lenmem is not NULL and ( mem is NULL or *lenmem is not large enough),
cannam@154 124 * then the function returns NULL and places the minimum cfg
cannam@154 125 * buffer size in *lenmem.
cannam@154 126 * */
cannam@154 127
cannam@154 128 kiss_fft_state *opus_fft_alloc_twiddles(int nfft,void * mem,size_t * lenmem, const kiss_fft_state *base, int arch);
cannam@154 129
cannam@154 130 kiss_fft_state *opus_fft_alloc(int nfft,void * mem,size_t * lenmem, int arch);
cannam@154 131
cannam@154 132 /**
cannam@154 133 * opus_fft(cfg,in_out_buf)
cannam@154 134 *
cannam@154 135 * Perform an FFT on a complex input buffer.
cannam@154 136 * for a forward FFT,
cannam@154 137 * fin should be f[0] , f[1] , ... ,f[nfft-1]
cannam@154 138 * fout will be F[0] , F[1] , ... ,F[nfft-1]
cannam@154 139 * Note that each element is complex and can be accessed like
cannam@154 140 f[k].r and f[k].i
cannam@154 141 * */
cannam@154 142 void opus_fft_c(const kiss_fft_state *cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout);
cannam@154 143 void opus_ifft_c(const kiss_fft_state *cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout);
cannam@154 144
cannam@154 145 void opus_fft_impl(const kiss_fft_state *st,kiss_fft_cpx *fout);
cannam@154 146 void opus_ifft_impl(const kiss_fft_state *st,kiss_fft_cpx *fout);
cannam@154 147
cannam@154 148 void opus_fft_free(const kiss_fft_state *cfg, int arch);
cannam@154 149
cannam@154 150
cannam@154 151 void opus_fft_free_arch_c(kiss_fft_state *st);
cannam@154 152 int opus_fft_alloc_arch_c(kiss_fft_state *st);
cannam@154 153
cannam@154 154 #if !defined(OVERRIDE_OPUS_FFT)
cannam@154 155 /* Is run-time CPU detection enabled on this platform? */
cannam@154 156 #if defined(OPUS_HAVE_RTCD) && (defined(HAVE_ARM_NE10))
cannam@154 157
cannam@154 158 extern int (*const OPUS_FFT_ALLOC_ARCH_IMPL[OPUS_ARCHMASK+1])(
cannam@154 159 kiss_fft_state *st);
cannam@154 160
cannam@154 161 #define opus_fft_alloc_arch(_st, arch) \
cannam@154 162 ((*OPUS_FFT_ALLOC_ARCH_IMPL[(arch)&OPUS_ARCHMASK])(_st))
cannam@154 163
cannam@154 164 extern void (*const OPUS_FFT_FREE_ARCH_IMPL[OPUS_ARCHMASK+1])(
cannam@154 165 kiss_fft_state *st);
cannam@154 166 #define opus_fft_free_arch(_st, arch) \
cannam@154 167 ((*OPUS_FFT_FREE_ARCH_IMPL[(arch)&OPUS_ARCHMASK])(_st))
cannam@154 168
cannam@154 169 extern void (*const OPUS_FFT[OPUS_ARCHMASK+1])(const kiss_fft_state *cfg,
cannam@154 170 const kiss_fft_cpx *fin, kiss_fft_cpx *fout);
cannam@154 171 #define opus_fft(_cfg, _fin, _fout, arch) \
cannam@154 172 ((*OPUS_FFT[(arch)&OPUS_ARCHMASK])(_cfg, _fin, _fout))
cannam@154 173
cannam@154 174 extern void (*const OPUS_IFFT[OPUS_ARCHMASK+1])(const kiss_fft_state *cfg,
cannam@154 175 const kiss_fft_cpx *fin, kiss_fft_cpx *fout);
cannam@154 176 #define opus_ifft(_cfg, _fin, _fout, arch) \
cannam@154 177 ((*OPUS_IFFT[(arch)&OPUS_ARCHMASK])(_cfg, _fin, _fout))
cannam@154 178
cannam@154 179 #else /* else for if defined(OPUS_HAVE_RTCD) && (defined(HAVE_ARM_NE10)) */
cannam@154 180
cannam@154 181 #define opus_fft_alloc_arch(_st, arch) \
cannam@154 182 ((void)(arch), opus_fft_alloc_arch_c(_st))
cannam@154 183
cannam@154 184 #define opus_fft_free_arch(_st, arch) \
cannam@154 185 ((void)(arch), opus_fft_free_arch_c(_st))
cannam@154 186
cannam@154 187 #define opus_fft(_cfg, _fin, _fout, arch) \
cannam@154 188 ((void)(arch), opus_fft_c(_cfg, _fin, _fout))
cannam@154 189
cannam@154 190 #define opus_ifft(_cfg, _fin, _fout, arch) \
cannam@154 191 ((void)(arch), opus_ifft_c(_cfg, _fin, _fout))
cannam@154 192
cannam@154 193 #endif /* end if defined(OPUS_HAVE_RTCD) && (defined(HAVE_ARM_NE10)) */
cannam@154 194 #endif /* end if !defined(OVERRIDE_OPUS_FFT) */
cannam@154 195
cannam@154 196 #ifdef __cplusplus
cannam@154 197 }
cannam@154 198 #endif
cannam@154 199
cannam@154 200 #endif