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_cfft_radix2_q31.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_cfft_radix2_q31.c |
emh203 | 0:3d9c67d97d6f | 9 | * |
emh203 | 0:3d9c67d97d6f | 10 | * Description: Radix-2 Decimation in Frequency CFFT & CIFFT Fixed point processing function |
emh203 | 0:3d9c67d97d6f | 11 | * |
emh203 | 0:3d9c67d97d6f | 12 | * |
emh203 | 0:3d9c67d97d6f | 13 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 |
emh203 | 0:3d9c67d97d6f | 14 | * |
emh203 | 0:3d9c67d97d6f | 15 | * Redistribution and use in source and binary forms, with or without |
emh203 | 0:3d9c67d97d6f | 16 | * modification, are permitted provided that the following conditions |
emh203 | 0:3d9c67d97d6f | 17 | * are met: |
emh203 | 0:3d9c67d97d6f | 18 | * - Redistributions of source code must retain the above copyright |
emh203 | 0:3d9c67d97d6f | 19 | * notice, this list of conditions and the following disclaimer. |
emh203 | 0:3d9c67d97d6f | 20 | * - Redistributions in binary form must reproduce the above copyright |
emh203 | 0:3d9c67d97d6f | 21 | * notice, this list of conditions and the following disclaimer in |
emh203 | 0:3d9c67d97d6f | 22 | * the documentation and/or other materials provided with the |
emh203 | 0:3d9c67d97d6f | 23 | * distribution. |
emh203 | 0:3d9c67d97d6f | 24 | * - Neither the name of ARM LIMITED nor the names of its contributors |
emh203 | 0:3d9c67d97d6f | 25 | * may be used to endorse or promote products derived from this |
emh203 | 0:3d9c67d97d6f | 26 | * software without specific prior written permission. |
emh203 | 0:3d9c67d97d6f | 27 | * |
emh203 | 0:3d9c67d97d6f | 28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
emh203 | 0:3d9c67d97d6f | 29 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
emh203 | 0:3d9c67d97d6f | 30 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
emh203 | 0:3d9c67d97d6f | 31 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
emh203 | 0:3d9c67d97d6f | 32 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
emh203 | 0:3d9c67d97d6f | 33 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
emh203 | 0:3d9c67d97d6f | 34 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
emh203 | 0:3d9c67d97d6f | 35 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
emh203 | 0:3d9c67d97d6f | 36 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
emh203 | 0:3d9c67d97d6f | 37 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
emh203 | 0:3d9c67d97d6f | 38 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
emh203 | 0:3d9c67d97d6f | 39 | * POSSIBILITY OF SUCH DAMAGE. |
emh203 | 0:3d9c67d97d6f | 40 | * -------------------------------------------------------------------- */ |
emh203 | 0:3d9c67d97d6f | 41 | |
emh203 | 0:3d9c67d97d6f | 42 | #include "arm_math.h" |
emh203 | 0:3d9c67d97d6f | 43 | |
emh203 | 0:3d9c67d97d6f | 44 | void arm_radix2_butterfly_q31( |
emh203 | 0:3d9c67d97d6f | 45 | q31_t * pSrc, |
emh203 | 0:3d9c67d97d6f | 46 | uint32_t fftLen, |
emh203 | 0:3d9c67d97d6f | 47 | q31_t * pCoef, |
emh203 | 0:3d9c67d97d6f | 48 | uint16_t twidCoefModifier); |
emh203 | 0:3d9c67d97d6f | 49 | |
emh203 | 0:3d9c67d97d6f | 50 | void arm_radix2_butterfly_inverse_q31( |
emh203 | 0:3d9c67d97d6f | 51 | q31_t * pSrc, |
emh203 | 0:3d9c67d97d6f | 52 | uint32_t fftLen, |
emh203 | 0:3d9c67d97d6f | 53 | q31_t * pCoef, |
emh203 | 0:3d9c67d97d6f | 54 | uint16_t twidCoefModifier); |
emh203 | 0:3d9c67d97d6f | 55 | |
emh203 | 0:3d9c67d97d6f | 56 | void arm_bitreversal_q31( |
emh203 | 0:3d9c67d97d6f | 57 | q31_t * pSrc, |
emh203 | 0:3d9c67d97d6f | 58 | uint32_t fftLen, |
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 | * @addtogroup ComplexFFT |
emh203 | 0:3d9c67d97d6f | 68 | * @{ |
emh203 | 0:3d9c67d97d6f | 69 | */ |
emh203 | 0:3d9c67d97d6f | 70 | |
emh203 | 0:3d9c67d97d6f | 71 | /** |
emh203 | 0:3d9c67d97d6f | 72 | * @details |
emh203 | 0:3d9c67d97d6f | 73 | * @brief Processing function for the fixed-point CFFT/CIFFT. |
emh203 | 0:3d9c67d97d6f | 74 | * @param[in] *S points to an instance of the fixed-point CFFT/CIFFT structure. |
emh203 | 0:3d9c67d97d6f | 75 | * @param[in, out] *pSrc points to the complex data buffer of size <code>2*fftLen</code>. Processing occurs in-place. |
emh203 | 0:3d9c67d97d6f | 76 | * @return none. |
emh203 | 0:3d9c67d97d6f | 77 | */ |
emh203 | 0:3d9c67d97d6f | 78 | |
emh203 | 0:3d9c67d97d6f | 79 | void arm_cfft_radix2_q31( |
emh203 | 0:3d9c67d97d6f | 80 | const arm_cfft_radix2_instance_q31 * S, |
emh203 | 0:3d9c67d97d6f | 81 | q31_t * pSrc) |
emh203 | 0:3d9c67d97d6f | 82 | { |
emh203 | 0:3d9c67d97d6f | 83 | |
emh203 | 0:3d9c67d97d6f | 84 | if(S->ifftFlag == 1u) |
emh203 | 0:3d9c67d97d6f | 85 | { |
emh203 | 0:3d9c67d97d6f | 86 | arm_radix2_butterfly_inverse_q31(pSrc, S->fftLen, |
emh203 | 0:3d9c67d97d6f | 87 | S->pTwiddle, S->twidCoefModifier); |
emh203 | 0:3d9c67d97d6f | 88 | } |
emh203 | 0:3d9c67d97d6f | 89 | else |
emh203 | 0:3d9c67d97d6f | 90 | { |
emh203 | 0:3d9c67d97d6f | 91 | arm_radix2_butterfly_q31(pSrc, S->fftLen, |
emh203 | 0:3d9c67d97d6f | 92 | S->pTwiddle, S->twidCoefModifier); |
emh203 | 0:3d9c67d97d6f | 93 | } |
emh203 | 0:3d9c67d97d6f | 94 | |
emh203 | 0:3d9c67d97d6f | 95 | arm_bitreversal_q31(pSrc, S->fftLen, S->bitRevFactor, S->pBitRevTable); |
emh203 | 0:3d9c67d97d6f | 96 | } |
emh203 | 0:3d9c67d97d6f | 97 | |
emh203 | 0:3d9c67d97d6f | 98 | /** |
emh203 | 0:3d9c67d97d6f | 99 | * @} end of ComplexFFT group |
emh203 | 0:3d9c67d97d6f | 100 | */ |
emh203 | 0:3d9c67d97d6f | 101 | |
emh203 | 0:3d9c67d97d6f | 102 | void arm_radix2_butterfly_q31( |
emh203 | 0:3d9c67d97d6f | 103 | q31_t * pSrc, |
emh203 | 0:3d9c67d97d6f | 104 | uint32_t fftLen, |
emh203 | 0:3d9c67d97d6f | 105 | q31_t * pCoef, |
emh203 | 0:3d9c67d97d6f | 106 | uint16_t twidCoefModifier) |
emh203 | 0:3d9c67d97d6f | 107 | { |
emh203 | 0:3d9c67d97d6f | 108 | |
emh203 | 0:3d9c67d97d6f | 109 | unsigned i, j, k, l, m; |
emh203 | 0:3d9c67d97d6f | 110 | unsigned n1, n2, ia; |
emh203 | 0:3d9c67d97d6f | 111 | q31_t xt, yt, cosVal, sinVal; |
emh203 | 0:3d9c67d97d6f | 112 | q31_t p0, p1; |
emh203 | 0:3d9c67d97d6f | 113 | |
emh203 | 0:3d9c67d97d6f | 114 | //N = fftLen; |
emh203 | 0:3d9c67d97d6f | 115 | n2 = fftLen; |
emh203 | 0:3d9c67d97d6f | 116 | |
emh203 | 0:3d9c67d97d6f | 117 | n1 = n2; |
emh203 | 0:3d9c67d97d6f | 118 | n2 = n2 >> 1; |
emh203 | 0:3d9c67d97d6f | 119 | ia = 0; |
emh203 | 0:3d9c67d97d6f | 120 | |
emh203 | 0:3d9c67d97d6f | 121 | // loop for groups |
emh203 | 0:3d9c67d97d6f | 122 | for (i = 0; i < n2; i++) |
emh203 | 0:3d9c67d97d6f | 123 | { |
emh203 | 0:3d9c67d97d6f | 124 | cosVal = pCoef[ia * 2]; |
emh203 | 0:3d9c67d97d6f | 125 | sinVal = pCoef[(ia * 2) + 1]; |
emh203 | 0:3d9c67d97d6f | 126 | ia = ia + twidCoefModifier; |
emh203 | 0:3d9c67d97d6f | 127 | |
emh203 | 0:3d9c67d97d6f | 128 | l = i + n2; |
emh203 | 0:3d9c67d97d6f | 129 | xt = (pSrc[2 * i] >> 1u) - (pSrc[2 * l] >> 1u); |
emh203 | 0:3d9c67d97d6f | 130 | pSrc[2 * i] = ((pSrc[2 * i] >> 1u) + (pSrc[2 * l] >> 1u)) >> 1u; |
emh203 | 0:3d9c67d97d6f | 131 | |
emh203 | 0:3d9c67d97d6f | 132 | yt = (pSrc[2 * i + 1] >> 1u) - (pSrc[2 * l + 1] >> 1u); |
emh203 | 0:3d9c67d97d6f | 133 | pSrc[2 * i + 1] = |
emh203 | 0:3d9c67d97d6f | 134 | ((pSrc[2 * l + 1] >> 1u) + (pSrc[2 * i + 1] >> 1u)) >> 1u; |
emh203 | 0:3d9c67d97d6f | 135 | |
emh203 | 0:3d9c67d97d6f | 136 | mult_32x32_keep32_R(p0, xt, cosVal); |
emh203 | 0:3d9c67d97d6f | 137 | mult_32x32_keep32_R(p1, yt, cosVal); |
emh203 | 0:3d9c67d97d6f | 138 | multAcc_32x32_keep32_R(p0, yt, sinVal); |
emh203 | 0:3d9c67d97d6f | 139 | multSub_32x32_keep32_R(p1, xt, sinVal); |
emh203 | 0:3d9c67d97d6f | 140 | |
emh203 | 0:3d9c67d97d6f | 141 | pSrc[2u * l] = p0; |
emh203 | 0:3d9c67d97d6f | 142 | pSrc[2u * l + 1u] = p1; |
emh203 | 0:3d9c67d97d6f | 143 | |
emh203 | 0:3d9c67d97d6f | 144 | } // groups loop end |
emh203 | 0:3d9c67d97d6f | 145 | |
emh203 | 0:3d9c67d97d6f | 146 | twidCoefModifier <<= 1u; |
emh203 | 0:3d9c67d97d6f | 147 | |
emh203 | 0:3d9c67d97d6f | 148 | // loop for stage |
emh203 | 0:3d9c67d97d6f | 149 | for (k = fftLen / 2; k > 2; k = k >> 1) |
emh203 | 0:3d9c67d97d6f | 150 | { |
emh203 | 0:3d9c67d97d6f | 151 | n1 = n2; |
emh203 | 0:3d9c67d97d6f | 152 | n2 = n2 >> 1; |
emh203 | 0:3d9c67d97d6f | 153 | ia = 0; |
emh203 | 0:3d9c67d97d6f | 154 | |
emh203 | 0:3d9c67d97d6f | 155 | // loop for groups |
emh203 | 0:3d9c67d97d6f | 156 | for (j = 0; j < n2; j++) |
emh203 | 0:3d9c67d97d6f | 157 | { |
emh203 | 0:3d9c67d97d6f | 158 | cosVal = pCoef[ia * 2]; |
emh203 | 0:3d9c67d97d6f | 159 | sinVal = pCoef[(ia * 2) + 1]; |
emh203 | 0:3d9c67d97d6f | 160 | ia = ia + twidCoefModifier; |
emh203 | 0:3d9c67d97d6f | 161 | |
emh203 | 0:3d9c67d97d6f | 162 | // loop for butterfly |
emh203 | 0:3d9c67d97d6f | 163 | i = j; |
emh203 | 0:3d9c67d97d6f | 164 | m = fftLen / n1; |
emh203 | 0:3d9c67d97d6f | 165 | do |
emh203 | 0:3d9c67d97d6f | 166 | { |
emh203 | 0:3d9c67d97d6f | 167 | l = i + n2; |
emh203 | 0:3d9c67d97d6f | 168 | xt = pSrc[2 * i] - pSrc[2 * l]; |
emh203 | 0:3d9c67d97d6f | 169 | pSrc[2 * i] = (pSrc[2 * i] + pSrc[2 * l]) >> 1u; |
emh203 | 0:3d9c67d97d6f | 170 | |
emh203 | 0:3d9c67d97d6f | 171 | yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; |
emh203 | 0:3d9c67d97d6f | 172 | pSrc[2 * i + 1] = (pSrc[2 * l + 1] + pSrc[2 * i + 1]) >> 1u; |
emh203 | 0:3d9c67d97d6f | 173 | |
emh203 | 0:3d9c67d97d6f | 174 | mult_32x32_keep32_R(p0, xt, cosVal); |
emh203 | 0:3d9c67d97d6f | 175 | mult_32x32_keep32_R(p1, yt, cosVal); |
emh203 | 0:3d9c67d97d6f | 176 | multAcc_32x32_keep32_R(p0, yt, sinVal); |
emh203 | 0:3d9c67d97d6f | 177 | multSub_32x32_keep32_R(p1, xt, sinVal); |
emh203 | 0:3d9c67d97d6f | 178 | |
emh203 | 0:3d9c67d97d6f | 179 | pSrc[2u * l] = p0; |
emh203 | 0:3d9c67d97d6f | 180 | pSrc[2u * l + 1u] = p1; |
emh203 | 0:3d9c67d97d6f | 181 | i += n1; |
emh203 | 0:3d9c67d97d6f | 182 | m--; |
emh203 | 0:3d9c67d97d6f | 183 | } while( m > 0); // butterfly loop end |
emh203 | 0:3d9c67d97d6f | 184 | |
emh203 | 0:3d9c67d97d6f | 185 | } // groups loop end |
emh203 | 0:3d9c67d97d6f | 186 | |
emh203 | 0:3d9c67d97d6f | 187 | twidCoefModifier <<= 1u; |
emh203 | 0:3d9c67d97d6f | 188 | } // stages loop end |
emh203 | 0:3d9c67d97d6f | 189 | |
emh203 | 0:3d9c67d97d6f | 190 | n1 = n2; |
emh203 | 0:3d9c67d97d6f | 191 | n2 = n2 >> 1; |
emh203 | 0:3d9c67d97d6f | 192 | ia = 0; |
emh203 | 0:3d9c67d97d6f | 193 | |
emh203 | 0:3d9c67d97d6f | 194 | cosVal = pCoef[ia * 2]; |
emh203 | 0:3d9c67d97d6f | 195 | sinVal = pCoef[(ia * 2) + 1]; |
emh203 | 0:3d9c67d97d6f | 196 | ia = ia + twidCoefModifier; |
emh203 | 0:3d9c67d97d6f | 197 | |
emh203 | 0:3d9c67d97d6f | 198 | // loop for butterfly |
emh203 | 0:3d9c67d97d6f | 199 | for (i = 0; i < fftLen; i += n1) |
emh203 | 0:3d9c67d97d6f | 200 | { |
emh203 | 0:3d9c67d97d6f | 201 | l = i + n2; |
emh203 | 0:3d9c67d97d6f | 202 | xt = pSrc[2 * i] - pSrc[2 * l]; |
emh203 | 0:3d9c67d97d6f | 203 | pSrc[2 * i] = (pSrc[2 * i] + pSrc[2 * l]); |
emh203 | 0:3d9c67d97d6f | 204 | |
emh203 | 0:3d9c67d97d6f | 205 | yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; |
emh203 | 0:3d9c67d97d6f | 206 | pSrc[2 * i + 1] = (pSrc[2 * l + 1] + pSrc[2 * i + 1]); |
emh203 | 0:3d9c67d97d6f | 207 | |
emh203 | 0:3d9c67d97d6f | 208 | pSrc[2u * l] = xt; |
emh203 | 0:3d9c67d97d6f | 209 | |
emh203 | 0:3d9c67d97d6f | 210 | pSrc[2u * l + 1u] = yt; |
emh203 | 0:3d9c67d97d6f | 211 | |
emh203 | 0:3d9c67d97d6f | 212 | i += n1; |
emh203 | 0:3d9c67d97d6f | 213 | l = i + n2; |
emh203 | 0:3d9c67d97d6f | 214 | |
emh203 | 0:3d9c67d97d6f | 215 | xt = pSrc[2 * i] - pSrc[2 * l]; |
emh203 | 0:3d9c67d97d6f | 216 | pSrc[2 * i] = (pSrc[2 * i] + pSrc[2 * l]); |
emh203 | 0:3d9c67d97d6f | 217 | |
emh203 | 0:3d9c67d97d6f | 218 | yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; |
emh203 | 0:3d9c67d97d6f | 219 | pSrc[2 * i + 1] = (pSrc[2 * l + 1] + pSrc[2 * i + 1]); |
emh203 | 0:3d9c67d97d6f | 220 | |
emh203 | 0:3d9c67d97d6f | 221 | pSrc[2u * l] = xt; |
emh203 | 0:3d9c67d97d6f | 222 | |
emh203 | 0:3d9c67d97d6f | 223 | pSrc[2u * l + 1u] = yt; |
emh203 | 0:3d9c67d97d6f | 224 | |
emh203 | 0:3d9c67d97d6f | 225 | } // butterfly loop end |
emh203 | 0:3d9c67d97d6f | 226 | |
emh203 | 0:3d9c67d97d6f | 227 | } |
emh203 | 0:3d9c67d97d6f | 228 | |
emh203 | 0:3d9c67d97d6f | 229 | |
emh203 | 0:3d9c67d97d6f | 230 | void arm_radix2_butterfly_inverse_q31( |
emh203 | 0:3d9c67d97d6f | 231 | q31_t * pSrc, |
emh203 | 0:3d9c67d97d6f | 232 | uint32_t fftLen, |
emh203 | 0:3d9c67d97d6f | 233 | q31_t * pCoef, |
emh203 | 0:3d9c67d97d6f | 234 | uint16_t twidCoefModifier) |
emh203 | 0:3d9c67d97d6f | 235 | { |
emh203 | 0:3d9c67d97d6f | 236 | |
emh203 | 0:3d9c67d97d6f | 237 | unsigned i, j, k, l; |
emh203 | 0:3d9c67d97d6f | 238 | unsigned n1, n2, ia; |
emh203 | 0:3d9c67d97d6f | 239 | q31_t xt, yt, cosVal, sinVal; |
emh203 | 0:3d9c67d97d6f | 240 | q31_t p0, p1; |
emh203 | 0:3d9c67d97d6f | 241 | |
emh203 | 0:3d9c67d97d6f | 242 | //N = fftLen; |
emh203 | 0:3d9c67d97d6f | 243 | n2 = fftLen; |
emh203 | 0:3d9c67d97d6f | 244 | |
emh203 | 0:3d9c67d97d6f | 245 | n1 = n2; |
emh203 | 0:3d9c67d97d6f | 246 | n2 = n2 >> 1; |
emh203 | 0:3d9c67d97d6f | 247 | ia = 0; |
emh203 | 0:3d9c67d97d6f | 248 | |
emh203 | 0:3d9c67d97d6f | 249 | // loop for groups |
emh203 | 0:3d9c67d97d6f | 250 | for (i = 0; i < n2; i++) |
emh203 | 0:3d9c67d97d6f | 251 | { |
emh203 | 0:3d9c67d97d6f | 252 | cosVal = pCoef[ia * 2]; |
emh203 | 0:3d9c67d97d6f | 253 | sinVal = pCoef[(ia * 2) + 1]; |
emh203 | 0:3d9c67d97d6f | 254 | ia = ia + twidCoefModifier; |
emh203 | 0:3d9c67d97d6f | 255 | |
emh203 | 0:3d9c67d97d6f | 256 | l = i + n2; |
emh203 | 0:3d9c67d97d6f | 257 | xt = (pSrc[2 * i] >> 1u) - (pSrc[2 * l] >> 1u); |
emh203 | 0:3d9c67d97d6f | 258 | pSrc[2 * i] = ((pSrc[2 * i] >> 1u) + (pSrc[2 * l] >> 1u)) >> 1u; |
emh203 | 0:3d9c67d97d6f | 259 | |
emh203 | 0:3d9c67d97d6f | 260 | yt = (pSrc[2 * i + 1] >> 1u) - (pSrc[2 * l + 1] >> 1u); |
emh203 | 0:3d9c67d97d6f | 261 | pSrc[2 * i + 1] = |
emh203 | 0:3d9c67d97d6f | 262 | ((pSrc[2 * l + 1] >> 1u) + (pSrc[2 * i + 1] >> 1u)) >> 1u; |
emh203 | 0:3d9c67d97d6f | 263 | |
emh203 | 0:3d9c67d97d6f | 264 | mult_32x32_keep32_R(p0, xt, cosVal); |
emh203 | 0:3d9c67d97d6f | 265 | mult_32x32_keep32_R(p1, yt, cosVal); |
emh203 | 0:3d9c67d97d6f | 266 | multSub_32x32_keep32_R(p0, yt, sinVal); |
emh203 | 0:3d9c67d97d6f | 267 | multAcc_32x32_keep32_R(p1, xt, sinVal); |
emh203 | 0:3d9c67d97d6f | 268 | |
emh203 | 0:3d9c67d97d6f | 269 | pSrc[2u * l] = p0; |
emh203 | 0:3d9c67d97d6f | 270 | pSrc[2u * l + 1u] = p1; |
emh203 | 0:3d9c67d97d6f | 271 | } // groups loop end |
emh203 | 0:3d9c67d97d6f | 272 | |
emh203 | 0:3d9c67d97d6f | 273 | twidCoefModifier = twidCoefModifier << 1u; |
emh203 | 0:3d9c67d97d6f | 274 | |
emh203 | 0:3d9c67d97d6f | 275 | // loop for stage |
emh203 | 0:3d9c67d97d6f | 276 | for (k = fftLen / 2; k > 2; k = k >> 1) |
emh203 | 0:3d9c67d97d6f | 277 | { |
emh203 | 0:3d9c67d97d6f | 278 | n1 = n2; |
emh203 | 0:3d9c67d97d6f | 279 | n2 = n2 >> 1; |
emh203 | 0:3d9c67d97d6f | 280 | ia = 0; |
emh203 | 0:3d9c67d97d6f | 281 | |
emh203 | 0:3d9c67d97d6f | 282 | // loop for groups |
emh203 | 0:3d9c67d97d6f | 283 | for (j = 0; j < n2; j++) |
emh203 | 0:3d9c67d97d6f | 284 | { |
emh203 | 0:3d9c67d97d6f | 285 | cosVal = pCoef[ia * 2]; |
emh203 | 0:3d9c67d97d6f | 286 | sinVal = pCoef[(ia * 2) + 1]; |
emh203 | 0:3d9c67d97d6f | 287 | ia = ia + twidCoefModifier; |
emh203 | 0:3d9c67d97d6f | 288 | |
emh203 | 0:3d9c67d97d6f | 289 | // loop for butterfly |
emh203 | 0:3d9c67d97d6f | 290 | for (i = j; i < fftLen; i += n1) |
emh203 | 0:3d9c67d97d6f | 291 | { |
emh203 | 0:3d9c67d97d6f | 292 | l = i + n2; |
emh203 | 0:3d9c67d97d6f | 293 | xt = pSrc[2 * i] - pSrc[2 * l]; |
emh203 | 0:3d9c67d97d6f | 294 | pSrc[2 * i] = (pSrc[2 * i] + pSrc[2 * l]) >> 1u; |
emh203 | 0:3d9c67d97d6f | 295 | |
emh203 | 0:3d9c67d97d6f | 296 | yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; |
emh203 | 0:3d9c67d97d6f | 297 | pSrc[2 * i + 1] = (pSrc[2 * l + 1] + pSrc[2 * i + 1]) >> 1u; |
emh203 | 0:3d9c67d97d6f | 298 | |
emh203 | 0:3d9c67d97d6f | 299 | mult_32x32_keep32_R(p0, xt, cosVal); |
emh203 | 0:3d9c67d97d6f | 300 | mult_32x32_keep32_R(p1, yt, cosVal); |
emh203 | 0:3d9c67d97d6f | 301 | multSub_32x32_keep32_R(p0, yt, sinVal); |
emh203 | 0:3d9c67d97d6f | 302 | multAcc_32x32_keep32_R(p1, xt, sinVal); |
emh203 | 0:3d9c67d97d6f | 303 | |
emh203 | 0:3d9c67d97d6f | 304 | pSrc[2u * l] = p0; |
emh203 | 0:3d9c67d97d6f | 305 | pSrc[2u * l + 1u] = p1; |
emh203 | 0:3d9c67d97d6f | 306 | } // butterfly loop end |
emh203 | 0:3d9c67d97d6f | 307 | |
emh203 | 0:3d9c67d97d6f | 308 | } // groups loop end |
emh203 | 0:3d9c67d97d6f | 309 | |
emh203 | 0:3d9c67d97d6f | 310 | twidCoefModifier = twidCoefModifier << 1u; |
emh203 | 0:3d9c67d97d6f | 311 | } // stages loop end |
emh203 | 0:3d9c67d97d6f | 312 | |
emh203 | 0:3d9c67d97d6f | 313 | n1 = n2; |
emh203 | 0:3d9c67d97d6f | 314 | n2 = n2 >> 1; |
emh203 | 0:3d9c67d97d6f | 315 | ia = 0; |
emh203 | 0:3d9c67d97d6f | 316 | |
emh203 | 0:3d9c67d97d6f | 317 | cosVal = pCoef[ia * 2]; |
emh203 | 0:3d9c67d97d6f | 318 | sinVal = pCoef[(ia * 2) + 1]; |
emh203 | 0:3d9c67d97d6f | 319 | ia = ia + twidCoefModifier; |
emh203 | 0:3d9c67d97d6f | 320 | |
emh203 | 0:3d9c67d97d6f | 321 | // loop for butterfly |
emh203 | 0:3d9c67d97d6f | 322 | for (i = 0; i < fftLen; i += n1) |
emh203 | 0:3d9c67d97d6f | 323 | { |
emh203 | 0:3d9c67d97d6f | 324 | l = i + n2; |
emh203 | 0:3d9c67d97d6f | 325 | xt = pSrc[2 * i] - pSrc[2 * l]; |
emh203 | 0:3d9c67d97d6f | 326 | pSrc[2 * i] = (pSrc[2 * i] + pSrc[2 * l]); |
emh203 | 0:3d9c67d97d6f | 327 | |
emh203 | 0:3d9c67d97d6f | 328 | yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; |
emh203 | 0:3d9c67d97d6f | 329 | pSrc[2 * i + 1] = (pSrc[2 * l + 1] + pSrc[2 * i + 1]); |
emh203 | 0:3d9c67d97d6f | 330 | |
emh203 | 0:3d9c67d97d6f | 331 | pSrc[2u * l] = xt; |
emh203 | 0:3d9c67d97d6f | 332 | |
emh203 | 0:3d9c67d97d6f | 333 | pSrc[2u * l + 1u] = yt; |
emh203 | 0:3d9c67d97d6f | 334 | |
emh203 | 0:3d9c67d97d6f | 335 | i += n1; |
emh203 | 0:3d9c67d97d6f | 336 | l = i + n2; |
emh203 | 0:3d9c67d97d6f | 337 | |
emh203 | 0:3d9c67d97d6f | 338 | xt = pSrc[2 * i] - pSrc[2 * l]; |
emh203 | 0:3d9c67d97d6f | 339 | pSrc[2 * i] = (pSrc[2 * i] + pSrc[2 * l]); |
emh203 | 0:3d9c67d97d6f | 340 | |
emh203 | 0:3d9c67d97d6f | 341 | yt = pSrc[2 * i + 1] - pSrc[2 * l + 1]; |
emh203 | 0:3d9c67d97d6f | 342 | pSrc[2 * i + 1] = (pSrc[2 * l + 1] + pSrc[2 * i + 1]); |
emh203 | 0:3d9c67d97d6f | 343 | |
emh203 | 0:3d9c67d97d6f | 344 | pSrc[2u * l] = xt; |
emh203 | 0:3d9c67d97d6f | 345 | |
emh203 | 0:3d9c67d97d6f | 346 | pSrc[2u * l + 1u] = yt; |
emh203 | 0:3d9c67d97d6f | 347 | |
emh203 | 0:3d9c67d97d6f | 348 | } // butterfly loop end |
emh203 | 0:3d9c67d97d6f | 349 | |
emh203 | 0:3d9c67d97d6f | 350 | } |