V4.0.1 of the ARM CMSIS DSP libraries. Note that arm_bitreversal2.s, arm_cfft_f32.c and arm_rfft_fast_f32.c had to be removed. arm_bitreversal2.s will not assemble with the online tools. So, the fast f32 FFT functions are not yet available. All the other FFT functions are available.
Dependents: MPU9150_Example fir_f32 fir_f32 MPU9150_nucleo_noni2cdev ... more
TransformFunctions/arm_rfft_f32.c@0:3d9c67d97d6f, 2014-07-28 (annotated)
- Committer:
- emh203
- Date:
- Mon Jul 28 15:03:15 2014 +0000
- Revision:
- 0:3d9c67d97d6f
1st working commit. Had to remove arm_bitreversal2.s arm_cfft_f32.c and arm_rfft_fast_f32.c. The .s will not assemble. For now I removed these functions so we could at least have a library for the other functions.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emh203 | 0:3d9c67d97d6f | 1 | /* ---------------------------------------------------------------------- |
emh203 | 0:3d9c67d97d6f | 2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved. |
emh203 | 0:3d9c67d97d6f | 3 | * |
emh203 | 0:3d9c67d97d6f | 4 | * $Date: 12. March 2014 |
emh203 | 0:3d9c67d97d6f | 5 | * $Revision: V1.4.3 |
emh203 | 0:3d9c67d97d6f | 6 | * |
emh203 | 0:3d9c67d97d6f | 7 | * Project: CMSIS DSP Library |
emh203 | 0:3d9c67d97d6f | 8 | * Title: arm_rfft_f32.c |
emh203 | 0:3d9c67d97d6f | 9 | * |
emh203 | 0:3d9c67d97d6f | 10 | * Description: RFFT & RIFFT Floating point process function |
emh203 | 0:3d9c67d97d6f | 11 | * |
emh203 | 0:3d9c67d97d6f | 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 |
emh203 | 0:3d9c67d97d6f | 13 | * |
emh203 | 0:3d9c67d97d6f | 14 | * Redistribution and use in source and binary forms, with or without |
emh203 | 0:3d9c67d97d6f | 15 | * modification, are permitted provided that the following conditions |
emh203 | 0:3d9c67d97d6f | 16 | * are met: |
emh203 | 0:3d9c67d97d6f | 17 | * - Redistributions of source code must retain the above copyright |
emh203 | 0:3d9c67d97d6f | 18 | * notice, this list of conditions and the following disclaimer. |
emh203 | 0:3d9c67d97d6f | 19 | * - Redistributions in binary form must reproduce the above copyright |
emh203 | 0:3d9c67d97d6f | 20 | * notice, this list of conditions and the following disclaimer in |
emh203 | 0:3d9c67d97d6f | 21 | * the documentation and/or other materials provided with the |
emh203 | 0:3d9c67d97d6f | 22 | * distribution. |
emh203 | 0:3d9c67d97d6f | 23 | * - Neither the name of ARM LIMITED nor the names of its contributors |
emh203 | 0:3d9c67d97d6f | 24 | * may be used to endorse or promote products derived from this |
emh203 | 0:3d9c67d97d6f | 25 | * software without specific prior written permission. |
emh203 | 0:3d9c67d97d6f | 26 | * |
emh203 | 0:3d9c67d97d6f | 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
emh203 | 0:3d9c67d97d6f | 28 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
emh203 | 0:3d9c67d97d6f | 29 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
emh203 | 0:3d9c67d97d6f | 30 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
emh203 | 0:3d9c67d97d6f | 31 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
emh203 | 0:3d9c67d97d6f | 32 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
emh203 | 0:3d9c67d97d6f | 33 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
emh203 | 0:3d9c67d97d6f | 34 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
emh203 | 0:3d9c67d97d6f | 35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
emh203 | 0:3d9c67d97d6f | 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
emh203 | 0:3d9c67d97d6f | 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
emh203 | 0:3d9c67d97d6f | 38 | * POSSIBILITY OF SUCH DAMAGE. |
emh203 | 0:3d9c67d97d6f | 39 | * -------------------------------------------------------------------- */ |
emh203 | 0:3d9c67d97d6f | 40 | |
emh203 | 0:3d9c67d97d6f | 41 | #include "arm_math.h" |
emh203 | 0:3d9c67d97d6f | 42 | |
emh203 | 0:3d9c67d97d6f | 43 | extern void arm_radix4_butterfly_f32( |
emh203 | 0:3d9c67d97d6f | 44 | float32_t * pSrc, |
emh203 | 0:3d9c67d97d6f | 45 | uint16_t fftLen, |
emh203 | 0:3d9c67d97d6f | 46 | float32_t * pCoef, |
emh203 | 0:3d9c67d97d6f | 47 | uint16_t twidCoefModifier); |
emh203 | 0:3d9c67d97d6f | 48 | |
emh203 | 0:3d9c67d97d6f | 49 | extern void arm_radix4_butterfly_inverse_f32( |
emh203 | 0:3d9c67d97d6f | 50 | float32_t * pSrc, |
emh203 | 0:3d9c67d97d6f | 51 | uint16_t fftLen, |
emh203 | 0:3d9c67d97d6f | 52 | float32_t * pCoef, |
emh203 | 0:3d9c67d97d6f | 53 | uint16_t twidCoefModifier, |
emh203 | 0:3d9c67d97d6f | 54 | float32_t onebyfftLen); |
emh203 | 0:3d9c67d97d6f | 55 | |
emh203 | 0:3d9c67d97d6f | 56 | extern void arm_bitreversal_f32( |
emh203 | 0:3d9c67d97d6f | 57 | float32_t * pSrc, |
emh203 | 0:3d9c67d97d6f | 58 | uint16_t fftSize, |
emh203 | 0:3d9c67d97d6f | 59 | uint16_t bitRevFactor, |
emh203 | 0:3d9c67d97d6f | 60 | uint16_t * pBitRevTab); |
emh203 | 0:3d9c67d97d6f | 61 | |
emh203 | 0:3d9c67d97d6f | 62 | /** |
emh203 | 0:3d9c67d97d6f | 63 | * @ingroup groupTransforms |
emh203 | 0:3d9c67d97d6f | 64 | */ |
emh203 | 0:3d9c67d97d6f | 65 | |
emh203 | 0:3d9c67d97d6f | 66 | /*-------------------------------------------------------------------- |
emh203 | 0:3d9c67d97d6f | 67 | * Internal functions prototypes |
emh203 | 0:3d9c67d97d6f | 68 | *--------------------------------------------------------------------*/ |
emh203 | 0:3d9c67d97d6f | 69 | |
emh203 | 0:3d9c67d97d6f | 70 | void arm_split_rfft_f32( |
emh203 | 0:3d9c67d97d6f | 71 | float32_t * pSrc, |
emh203 | 0:3d9c67d97d6f | 72 | uint32_t fftLen, |
emh203 | 0:3d9c67d97d6f | 73 | float32_t * pATable, |
emh203 | 0:3d9c67d97d6f | 74 | float32_t * pBTable, |
emh203 | 0:3d9c67d97d6f | 75 | float32_t * pDst, |
emh203 | 0:3d9c67d97d6f | 76 | uint32_t modifier); |
emh203 | 0:3d9c67d97d6f | 77 | void arm_split_rifft_f32( |
emh203 | 0:3d9c67d97d6f | 78 | float32_t * pSrc, |
emh203 | 0:3d9c67d97d6f | 79 | uint32_t fftLen, |
emh203 | 0:3d9c67d97d6f | 80 | float32_t * pATable, |
emh203 | 0:3d9c67d97d6f | 81 | float32_t * pBTable, |
emh203 | 0:3d9c67d97d6f | 82 | float32_t * pDst, |
emh203 | 0:3d9c67d97d6f | 83 | uint32_t modifier); |
emh203 | 0:3d9c67d97d6f | 84 | |
emh203 | 0:3d9c67d97d6f | 85 | /** |
emh203 | 0:3d9c67d97d6f | 86 | * @addtogroup RealFFT |
emh203 | 0:3d9c67d97d6f | 87 | * @{ |
emh203 | 0:3d9c67d97d6f | 88 | */ |
emh203 | 0:3d9c67d97d6f | 89 | |
emh203 | 0:3d9c67d97d6f | 90 | /** |
emh203 | 0:3d9c67d97d6f | 91 | * @brief Processing function for the floating-point RFFT/RIFFT. |
emh203 | 0:3d9c67d97d6f | 92 | * @deprecated Do not use this function. It has been superceded by \ref arm_rfft_fast_f32 and will be removed |
emh203 | 0:3d9c67d97d6f | 93 | * in the future. |
emh203 | 0:3d9c67d97d6f | 94 | * @param[in] *S points to an instance of the floating-point RFFT/RIFFT structure. |
emh203 | 0:3d9c67d97d6f | 95 | * @param[in] *pSrc points to the input buffer. |
emh203 | 0:3d9c67d97d6f | 96 | * @param[out] *pDst points to the output buffer. |
emh203 | 0:3d9c67d97d6f | 97 | * @return none. |
emh203 | 0:3d9c67d97d6f | 98 | */ |
emh203 | 0:3d9c67d97d6f | 99 | |
emh203 | 0:3d9c67d97d6f | 100 | void arm_rfft_f32( |
emh203 | 0:3d9c67d97d6f | 101 | const arm_rfft_instance_f32 * S, |
emh203 | 0:3d9c67d97d6f | 102 | float32_t * pSrc, |
emh203 | 0:3d9c67d97d6f | 103 | float32_t * pDst) |
emh203 | 0:3d9c67d97d6f | 104 | { |
emh203 | 0:3d9c67d97d6f | 105 | const arm_cfft_radix4_instance_f32 *S_CFFT = S->pCfft; |
emh203 | 0:3d9c67d97d6f | 106 | |
emh203 | 0:3d9c67d97d6f | 107 | |
emh203 | 0:3d9c67d97d6f | 108 | /* Calculation of Real IFFT of input */ |
emh203 | 0:3d9c67d97d6f | 109 | if(S->ifftFlagR == 1u) |
emh203 | 0:3d9c67d97d6f | 110 | { |
emh203 | 0:3d9c67d97d6f | 111 | /* Real IFFT core process */ |
emh203 | 0:3d9c67d97d6f | 112 | arm_split_rifft_f32(pSrc, S->fftLenBy2, S->pTwiddleAReal, |
emh203 | 0:3d9c67d97d6f | 113 | S->pTwiddleBReal, pDst, S->twidCoefRModifier); |
emh203 | 0:3d9c67d97d6f | 114 | |
emh203 | 0:3d9c67d97d6f | 115 | |
emh203 | 0:3d9c67d97d6f | 116 | /* Complex radix-4 IFFT process */ |
emh203 | 0:3d9c67d97d6f | 117 | arm_radix4_butterfly_inverse_f32(pDst, S_CFFT->fftLen, |
emh203 | 0:3d9c67d97d6f | 118 | S_CFFT->pTwiddle, |
emh203 | 0:3d9c67d97d6f | 119 | S_CFFT->twidCoefModifier, |
emh203 | 0:3d9c67d97d6f | 120 | S_CFFT->onebyfftLen); |
emh203 | 0:3d9c67d97d6f | 121 | |
emh203 | 0:3d9c67d97d6f | 122 | /* Bit reversal process */ |
emh203 | 0:3d9c67d97d6f | 123 | if(S->bitReverseFlagR == 1u) |
emh203 | 0:3d9c67d97d6f | 124 | { |
emh203 | 0:3d9c67d97d6f | 125 | arm_bitreversal_f32(pDst, S_CFFT->fftLen, |
emh203 | 0:3d9c67d97d6f | 126 | S_CFFT->bitRevFactor, S_CFFT->pBitRevTable); |
emh203 | 0:3d9c67d97d6f | 127 | } |
emh203 | 0:3d9c67d97d6f | 128 | } |
emh203 | 0:3d9c67d97d6f | 129 | else |
emh203 | 0:3d9c67d97d6f | 130 | { |
emh203 | 0:3d9c67d97d6f | 131 | |
emh203 | 0:3d9c67d97d6f | 132 | /* Calculation of RFFT of input */ |
emh203 | 0:3d9c67d97d6f | 133 | |
emh203 | 0:3d9c67d97d6f | 134 | /* Complex radix-4 FFT process */ |
emh203 | 0:3d9c67d97d6f | 135 | arm_radix4_butterfly_f32(pSrc, S_CFFT->fftLen, |
emh203 | 0:3d9c67d97d6f | 136 | S_CFFT->pTwiddle, S_CFFT->twidCoefModifier); |
emh203 | 0:3d9c67d97d6f | 137 | |
emh203 | 0:3d9c67d97d6f | 138 | /* Bit reversal process */ |
emh203 | 0:3d9c67d97d6f | 139 | if(S->bitReverseFlagR == 1u) |
emh203 | 0:3d9c67d97d6f | 140 | { |
emh203 | 0:3d9c67d97d6f | 141 | arm_bitreversal_f32(pSrc, S_CFFT->fftLen, |
emh203 | 0:3d9c67d97d6f | 142 | S_CFFT->bitRevFactor, S_CFFT->pBitRevTable); |
emh203 | 0:3d9c67d97d6f | 143 | } |
emh203 | 0:3d9c67d97d6f | 144 | |
emh203 | 0:3d9c67d97d6f | 145 | |
emh203 | 0:3d9c67d97d6f | 146 | /* Real FFT core process */ |
emh203 | 0:3d9c67d97d6f | 147 | arm_split_rfft_f32(pSrc, S->fftLenBy2, S->pTwiddleAReal, |
emh203 | 0:3d9c67d97d6f | 148 | S->pTwiddleBReal, pDst, S->twidCoefRModifier); |
emh203 | 0:3d9c67d97d6f | 149 | } |
emh203 | 0:3d9c67d97d6f | 150 | |
emh203 | 0:3d9c67d97d6f | 151 | } |
emh203 | 0:3d9c67d97d6f | 152 | |
emh203 | 0:3d9c67d97d6f | 153 | /** |
emh203 | 0:3d9c67d97d6f | 154 | * @} end of RealFFT group |
emh203 | 0:3d9c67d97d6f | 155 | */ |
emh203 | 0:3d9c67d97d6f | 156 | |
emh203 | 0:3d9c67d97d6f | 157 | /** |
emh203 | 0:3d9c67d97d6f | 158 | * @brief Core Real FFT process |
emh203 | 0:3d9c67d97d6f | 159 | * @param[in] *pSrc points to the input buffer. |
emh203 | 0:3d9c67d97d6f | 160 | * @param[in] fftLen length of FFT. |
emh203 | 0:3d9c67d97d6f | 161 | * @param[in] *pATable points to the twiddle Coef A buffer. |
emh203 | 0:3d9c67d97d6f | 162 | * @param[in] *pBTable points to the twiddle Coef B buffer. |
emh203 | 0:3d9c67d97d6f | 163 | * @param[out] *pDst points to the output buffer. |
emh203 | 0:3d9c67d97d6f | 164 | * @param[in] modifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. |
emh203 | 0:3d9c67d97d6f | 165 | * @return none. |
emh203 | 0:3d9c67d97d6f | 166 | */ |
emh203 | 0:3d9c67d97d6f | 167 | |
emh203 | 0:3d9c67d97d6f | 168 | void arm_split_rfft_f32( |
emh203 | 0:3d9c67d97d6f | 169 | float32_t * pSrc, |
emh203 | 0:3d9c67d97d6f | 170 | uint32_t fftLen, |
emh203 | 0:3d9c67d97d6f | 171 | float32_t * pATable, |
emh203 | 0:3d9c67d97d6f | 172 | float32_t * pBTable, |
emh203 | 0:3d9c67d97d6f | 173 | float32_t * pDst, |
emh203 | 0:3d9c67d97d6f | 174 | uint32_t modifier) |
emh203 | 0:3d9c67d97d6f | 175 | { |
emh203 | 0:3d9c67d97d6f | 176 | uint32_t i; /* Loop Counter */ |
emh203 | 0:3d9c67d97d6f | 177 | float32_t outR, outI; /* Temporary variables for output */ |
emh203 | 0:3d9c67d97d6f | 178 | float32_t *pCoefA, *pCoefB; /* Temporary pointers for twiddle factors */ |
emh203 | 0:3d9c67d97d6f | 179 | float32_t CoefA1, CoefA2, CoefB1; /* Temporary variables for twiddle coefficients */ |
emh203 | 0:3d9c67d97d6f | 180 | float32_t *pDst1 = &pDst[2], *pDst2 = &pDst[(4u * fftLen) - 1u]; /* temp pointers for output buffer */ |
emh203 | 0:3d9c67d97d6f | 181 | float32_t *pSrc1 = &pSrc[2], *pSrc2 = &pSrc[(2u * fftLen) - 1u]; /* temp pointers for input buffer */ |
emh203 | 0:3d9c67d97d6f | 182 | |
emh203 | 0:3d9c67d97d6f | 183 | /* Init coefficient pointers */ |
emh203 | 0:3d9c67d97d6f | 184 | pCoefA = &pATable[modifier * 2u]; |
emh203 | 0:3d9c67d97d6f | 185 | pCoefB = &pBTable[modifier * 2u]; |
emh203 | 0:3d9c67d97d6f | 186 | |
emh203 | 0:3d9c67d97d6f | 187 | i = fftLen - 1u; |
emh203 | 0:3d9c67d97d6f | 188 | |
emh203 | 0:3d9c67d97d6f | 189 | while(i > 0u) |
emh203 | 0:3d9c67d97d6f | 190 | { |
emh203 | 0:3d9c67d97d6f | 191 | /* |
emh203 | 0:3d9c67d97d6f | 192 | outR = (pSrc[2 * i] * pATable[2 * i] - pSrc[2 * i + 1] * pATable[2 * i + 1] |
emh203 | 0:3d9c67d97d6f | 193 | + pSrc[2 * n - 2 * i] * pBTable[2 * i] + |
emh203 | 0:3d9c67d97d6f | 194 | pSrc[2 * n - 2 * i + 1] * pBTable[2 * i + 1]); |
emh203 | 0:3d9c67d97d6f | 195 | */ |
emh203 | 0:3d9c67d97d6f | 196 | |
emh203 | 0:3d9c67d97d6f | 197 | /* outI = (pIn[2 * i + 1] * pATable[2 * i] + pIn[2 * i] * pATable[2 * i + 1] + |
emh203 | 0:3d9c67d97d6f | 198 | pIn[2 * n - 2 * i] * pBTable[2 * i + 1] - |
emh203 | 0:3d9c67d97d6f | 199 | pIn[2 * n - 2 * i + 1] * pBTable[2 * i]); */ |
emh203 | 0:3d9c67d97d6f | 200 | |
emh203 | 0:3d9c67d97d6f | 201 | /* read pATable[2 * i] */ |
emh203 | 0:3d9c67d97d6f | 202 | CoefA1 = *pCoefA++; |
emh203 | 0:3d9c67d97d6f | 203 | /* pATable[2 * i + 1] */ |
emh203 | 0:3d9c67d97d6f | 204 | CoefA2 = *pCoefA; |
emh203 | 0:3d9c67d97d6f | 205 | |
emh203 | 0:3d9c67d97d6f | 206 | /* pSrc[2 * i] * pATable[2 * i] */ |
emh203 | 0:3d9c67d97d6f | 207 | outR = *pSrc1 * CoefA1; |
emh203 | 0:3d9c67d97d6f | 208 | /* pSrc[2 * i] * CoefA2 */ |
emh203 | 0:3d9c67d97d6f | 209 | outI = *pSrc1++ * CoefA2; |
emh203 | 0:3d9c67d97d6f | 210 | |
emh203 | 0:3d9c67d97d6f | 211 | /* (pSrc[2 * i + 1] + pSrc[2 * fftLen - 2 * i + 1]) * CoefA2 */ |
emh203 | 0:3d9c67d97d6f | 212 | outR -= (*pSrc1 + *pSrc2) * CoefA2; |
emh203 | 0:3d9c67d97d6f | 213 | /* pSrc[2 * i + 1] * CoefA1 */ |
emh203 | 0:3d9c67d97d6f | 214 | outI += *pSrc1++ * CoefA1; |
emh203 | 0:3d9c67d97d6f | 215 | |
emh203 | 0:3d9c67d97d6f | 216 | CoefB1 = *pCoefB; |
emh203 | 0:3d9c67d97d6f | 217 | |
emh203 | 0:3d9c67d97d6f | 218 | /* pSrc[2 * fftLen - 2 * i + 1] * CoefB1 */ |
emh203 | 0:3d9c67d97d6f | 219 | outI -= *pSrc2-- * CoefB1; |
emh203 | 0:3d9c67d97d6f | 220 | /* pSrc[2 * fftLen - 2 * i] * CoefA2 */ |
emh203 | 0:3d9c67d97d6f | 221 | outI -= *pSrc2 * CoefA2; |
emh203 | 0:3d9c67d97d6f | 222 | |
emh203 | 0:3d9c67d97d6f | 223 | /* pSrc[2 * fftLen - 2 * i] * CoefB1 */ |
emh203 | 0:3d9c67d97d6f | 224 | outR += *pSrc2-- * CoefB1; |
emh203 | 0:3d9c67d97d6f | 225 | |
emh203 | 0:3d9c67d97d6f | 226 | /* write output */ |
emh203 | 0:3d9c67d97d6f | 227 | *pDst1++ = outR; |
emh203 | 0:3d9c67d97d6f | 228 | *pDst1++ = outI; |
emh203 | 0:3d9c67d97d6f | 229 | |
emh203 | 0:3d9c67d97d6f | 230 | /* write complex conjugate output */ |
emh203 | 0:3d9c67d97d6f | 231 | *pDst2-- = -outI; |
emh203 | 0:3d9c67d97d6f | 232 | *pDst2-- = outR; |
emh203 | 0:3d9c67d97d6f | 233 | |
emh203 | 0:3d9c67d97d6f | 234 | /* update coefficient pointer */ |
emh203 | 0:3d9c67d97d6f | 235 | pCoefB = pCoefB + (modifier * 2u); |
emh203 | 0:3d9c67d97d6f | 236 | pCoefA = pCoefA + ((modifier * 2u) - 1u); |
emh203 | 0:3d9c67d97d6f | 237 | |
emh203 | 0:3d9c67d97d6f | 238 | i--; |
emh203 | 0:3d9c67d97d6f | 239 | |
emh203 | 0:3d9c67d97d6f | 240 | } |
emh203 | 0:3d9c67d97d6f | 241 | |
emh203 | 0:3d9c67d97d6f | 242 | pDst[2u * fftLen] = pSrc[0] - pSrc[1]; |
emh203 | 0:3d9c67d97d6f | 243 | pDst[(2u * fftLen) + 1u] = 0.0f; |
emh203 | 0:3d9c67d97d6f | 244 | |
emh203 | 0:3d9c67d97d6f | 245 | pDst[0] = pSrc[0] + pSrc[1]; |
emh203 | 0:3d9c67d97d6f | 246 | pDst[1] = 0.0f; |
emh203 | 0:3d9c67d97d6f | 247 | |
emh203 | 0:3d9c67d97d6f | 248 | } |
emh203 | 0:3d9c67d97d6f | 249 | |
emh203 | 0:3d9c67d97d6f | 250 | |
emh203 | 0:3d9c67d97d6f | 251 | /** |
emh203 | 0:3d9c67d97d6f | 252 | * @brief Core Real IFFT process |
emh203 | 0:3d9c67d97d6f | 253 | * @param[in] *pSrc points to the input buffer. |
emh203 | 0:3d9c67d97d6f | 254 | * @param[in] fftLen length of FFT. |
emh203 | 0:3d9c67d97d6f | 255 | * @param[in] *pATable points to the twiddle Coef A buffer. |
emh203 | 0:3d9c67d97d6f | 256 | * @param[in] *pBTable points to the twiddle Coef B buffer. |
emh203 | 0:3d9c67d97d6f | 257 | * @param[out] *pDst points to the output buffer. |
emh203 | 0:3d9c67d97d6f | 258 | * @param[in] modifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. |
emh203 | 0:3d9c67d97d6f | 259 | * @return none. |
emh203 | 0:3d9c67d97d6f | 260 | */ |
emh203 | 0:3d9c67d97d6f | 261 | |
emh203 | 0:3d9c67d97d6f | 262 | void arm_split_rifft_f32( |
emh203 | 0:3d9c67d97d6f | 263 | float32_t * pSrc, |
emh203 | 0:3d9c67d97d6f | 264 | uint32_t fftLen, |
emh203 | 0:3d9c67d97d6f | 265 | float32_t * pATable, |
emh203 | 0:3d9c67d97d6f | 266 | float32_t * pBTable, |
emh203 | 0:3d9c67d97d6f | 267 | float32_t * pDst, |
emh203 | 0:3d9c67d97d6f | 268 | uint32_t modifier) |
emh203 | 0:3d9c67d97d6f | 269 | { |
emh203 | 0:3d9c67d97d6f | 270 | float32_t outR, outI; /* Temporary variables for output */ |
emh203 | 0:3d9c67d97d6f | 271 | float32_t *pCoefA, *pCoefB; /* Temporary pointers for twiddle factors */ |
emh203 | 0:3d9c67d97d6f | 272 | float32_t CoefA1, CoefA2, CoefB1; /* Temporary variables for twiddle coefficients */ |
emh203 | 0:3d9c67d97d6f | 273 | float32_t *pSrc1 = &pSrc[0], *pSrc2 = &pSrc[(2u * fftLen) + 1u]; |
emh203 | 0:3d9c67d97d6f | 274 | |
emh203 | 0:3d9c67d97d6f | 275 | pCoefA = &pATable[0]; |
emh203 | 0:3d9c67d97d6f | 276 | pCoefB = &pBTable[0]; |
emh203 | 0:3d9c67d97d6f | 277 | |
emh203 | 0:3d9c67d97d6f | 278 | while(fftLen > 0u) |
emh203 | 0:3d9c67d97d6f | 279 | { |
emh203 | 0:3d9c67d97d6f | 280 | /* |
emh203 | 0:3d9c67d97d6f | 281 | outR = (pIn[2 * i] * pATable[2 * i] + pIn[2 * i + 1] * pATable[2 * i + 1] + |
emh203 | 0:3d9c67d97d6f | 282 | pIn[2 * n - 2 * i] * pBTable[2 * i] - |
emh203 | 0:3d9c67d97d6f | 283 | pIn[2 * n - 2 * i + 1] * pBTable[2 * i + 1]); |
emh203 | 0:3d9c67d97d6f | 284 | |
emh203 | 0:3d9c67d97d6f | 285 | outI = (pIn[2 * i + 1] * pATable[2 * i] - pIn[2 * i] * pATable[2 * i + 1] - |
emh203 | 0:3d9c67d97d6f | 286 | pIn[2 * n - 2 * i] * pBTable[2 * i + 1] - |
emh203 | 0:3d9c67d97d6f | 287 | pIn[2 * n - 2 * i + 1] * pBTable[2 * i]); |
emh203 | 0:3d9c67d97d6f | 288 | |
emh203 | 0:3d9c67d97d6f | 289 | */ |
emh203 | 0:3d9c67d97d6f | 290 | |
emh203 | 0:3d9c67d97d6f | 291 | CoefA1 = *pCoefA++; |
emh203 | 0:3d9c67d97d6f | 292 | CoefA2 = *pCoefA; |
emh203 | 0:3d9c67d97d6f | 293 | |
emh203 | 0:3d9c67d97d6f | 294 | /* outR = (pSrc[2 * i] * CoefA1 */ |
emh203 | 0:3d9c67d97d6f | 295 | outR = *pSrc1 * CoefA1; |
emh203 | 0:3d9c67d97d6f | 296 | |
emh203 | 0:3d9c67d97d6f | 297 | /* - pSrc[2 * i] * CoefA2 */ |
emh203 | 0:3d9c67d97d6f | 298 | outI = -(*pSrc1++) * CoefA2; |
emh203 | 0:3d9c67d97d6f | 299 | |
emh203 | 0:3d9c67d97d6f | 300 | /* (pSrc[2 * i + 1] + pSrc[2 * fftLen - 2 * i + 1]) * CoefA2 */ |
emh203 | 0:3d9c67d97d6f | 301 | outR += (*pSrc1 + *pSrc2) * CoefA2; |
emh203 | 0:3d9c67d97d6f | 302 | |
emh203 | 0:3d9c67d97d6f | 303 | /* pSrc[2 * i + 1] * CoefA1 */ |
emh203 | 0:3d9c67d97d6f | 304 | outI += (*pSrc1++) * CoefA1; |
emh203 | 0:3d9c67d97d6f | 305 | |
emh203 | 0:3d9c67d97d6f | 306 | CoefB1 = *pCoefB; |
emh203 | 0:3d9c67d97d6f | 307 | |
emh203 | 0:3d9c67d97d6f | 308 | /* - pSrc[2 * fftLen - 2 * i + 1] * CoefB1 */ |
emh203 | 0:3d9c67d97d6f | 309 | outI -= *pSrc2-- * CoefB1; |
emh203 | 0:3d9c67d97d6f | 310 | |
emh203 | 0:3d9c67d97d6f | 311 | /* pSrc[2 * fftLen - 2 * i] * CoefB1 */ |
emh203 | 0:3d9c67d97d6f | 312 | outR += *pSrc2 * CoefB1; |
emh203 | 0:3d9c67d97d6f | 313 | |
emh203 | 0:3d9c67d97d6f | 314 | /* pSrc[2 * fftLen - 2 * i] * CoefA2 */ |
emh203 | 0:3d9c67d97d6f | 315 | outI += *pSrc2-- * CoefA2; |
emh203 | 0:3d9c67d97d6f | 316 | |
emh203 | 0:3d9c67d97d6f | 317 | /* write output */ |
emh203 | 0:3d9c67d97d6f | 318 | *pDst++ = outR; |
emh203 | 0:3d9c67d97d6f | 319 | *pDst++ = outI; |
emh203 | 0:3d9c67d97d6f | 320 | |
emh203 | 0:3d9c67d97d6f | 321 | /* update coefficient pointer */ |
emh203 | 0:3d9c67d97d6f | 322 | pCoefB = pCoefB + (modifier * 2u); |
emh203 | 0:3d9c67d97d6f | 323 | pCoefA = pCoefA + ((modifier * 2u) - 1u); |
emh203 | 0:3d9c67d97d6f | 324 | |
emh203 | 0:3d9c67d97d6f | 325 | /* Decrement loop count */ |
emh203 | 0:3d9c67d97d6f | 326 | fftLen--; |
emh203 | 0:3d9c67d97d6f | 327 | } |
emh203 | 0:3d9c67d97d6f | 328 | |
emh203 | 0:3d9c67d97d6f | 329 | } |