The CMSIS DSP 5 library

Dependents:   Nucleo-Heart-Rate ejercicioVrms2 PROYECTOFINAL ejercicioVrms ... more

Committer:
xorjoep
Date:
Thu Jun 21 11:56:27 2018 +0000
Revision:
3:4098b9d3d571
Parent:
1:24714b45cd1b
headers is a folder not a library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
xorjoep 1:24714b45cd1b 1 /* ----------------------------------------------------------------------
xorjoep 1:24714b45cd1b 2 * Project: CMSIS DSP Library
xorjoep 1:24714b45cd1b 3 * Title: arm_cfft_radix2_f32.c
xorjoep 1:24714b45cd1b 4 * Description: Radix-2 Decimation in Frequency CFFT & CIFFT Floating point processing function
xorjoep 1:24714b45cd1b 5 *
xorjoep 1:24714b45cd1b 6 * $Date: 27. January 2017
xorjoep 1:24714b45cd1b 7 * $Revision: V.1.5.1
xorjoep 1:24714b45cd1b 8 *
xorjoep 1:24714b45cd1b 9 * Target Processor: Cortex-M cores
xorjoep 1:24714b45cd1b 10 * -------------------------------------------------------------------- */
xorjoep 1:24714b45cd1b 11 /*
xorjoep 1:24714b45cd1b 12 * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved.
xorjoep 1:24714b45cd1b 13 *
xorjoep 1:24714b45cd1b 14 * SPDX-License-Identifier: Apache-2.0
xorjoep 1:24714b45cd1b 15 *
xorjoep 1:24714b45cd1b 16 * Licensed under the Apache License, Version 2.0 (the License); you may
xorjoep 1:24714b45cd1b 17 * not use this file except in compliance with the License.
xorjoep 1:24714b45cd1b 18 * You may obtain a copy of the License at
xorjoep 1:24714b45cd1b 19 *
xorjoep 1:24714b45cd1b 20 * www.apache.org/licenses/LICENSE-2.0
xorjoep 1:24714b45cd1b 21 *
xorjoep 1:24714b45cd1b 22 * Unless required by applicable law or agreed to in writing, software
xorjoep 1:24714b45cd1b 23 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
xorjoep 1:24714b45cd1b 24 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
xorjoep 1:24714b45cd1b 25 * See the License for the specific language governing permissions and
xorjoep 1:24714b45cd1b 26 * limitations under the License.
xorjoep 1:24714b45cd1b 27 */
xorjoep 1:24714b45cd1b 28
xorjoep 1:24714b45cd1b 29 #include "arm_math.h"
xorjoep 1:24714b45cd1b 30
xorjoep 1:24714b45cd1b 31 void arm_radix2_butterfly_f32(
xorjoep 1:24714b45cd1b 32 float32_t * pSrc,
xorjoep 1:24714b45cd1b 33 uint32_t fftLen,
xorjoep 1:24714b45cd1b 34 float32_t * pCoef,
xorjoep 1:24714b45cd1b 35 uint16_t twidCoefModifier);
xorjoep 1:24714b45cd1b 36
xorjoep 1:24714b45cd1b 37 void arm_radix2_butterfly_inverse_f32(
xorjoep 1:24714b45cd1b 38 float32_t * pSrc,
xorjoep 1:24714b45cd1b 39 uint32_t fftLen,
xorjoep 1:24714b45cd1b 40 float32_t * pCoef,
xorjoep 1:24714b45cd1b 41 uint16_t twidCoefModifier,
xorjoep 1:24714b45cd1b 42 float32_t onebyfftLen);
xorjoep 1:24714b45cd1b 43
xorjoep 1:24714b45cd1b 44 extern void arm_bitreversal_f32(
xorjoep 1:24714b45cd1b 45 float32_t * pSrc,
xorjoep 1:24714b45cd1b 46 uint16_t fftSize,
xorjoep 1:24714b45cd1b 47 uint16_t bitRevFactor,
xorjoep 1:24714b45cd1b 48 uint16_t * pBitRevTab);
xorjoep 1:24714b45cd1b 49
xorjoep 1:24714b45cd1b 50 /**
xorjoep 1:24714b45cd1b 51 * @ingroup groupTransforms
xorjoep 1:24714b45cd1b 52 */
xorjoep 1:24714b45cd1b 53
xorjoep 1:24714b45cd1b 54 /**
xorjoep 1:24714b45cd1b 55 * @addtogroup ComplexFFT
xorjoep 1:24714b45cd1b 56 * @{
xorjoep 1:24714b45cd1b 57 */
xorjoep 1:24714b45cd1b 58
xorjoep 1:24714b45cd1b 59 /**
xorjoep 1:24714b45cd1b 60 * @details
xorjoep 1:24714b45cd1b 61 * @brief Radix-2 CFFT/CIFFT.
xorjoep 1:24714b45cd1b 62 * @deprecated Do not use this function. It has been superseded by \ref arm_cfft_f32 and will be removed
xorjoep 1:24714b45cd1b 63 * in the future.
xorjoep 1:24714b45cd1b 64 * @param[in] *S points to an instance of the floating-point Radix-2 CFFT/CIFFT structure.
xorjoep 1:24714b45cd1b 65 * @param[in, out] *pSrc points to the complex data buffer of size <code>2*fftLen</code>. Processing occurs in-place.
xorjoep 1:24714b45cd1b 66 * @return none.
xorjoep 1:24714b45cd1b 67 */
xorjoep 1:24714b45cd1b 68
xorjoep 1:24714b45cd1b 69 void arm_cfft_radix2_f32(
xorjoep 1:24714b45cd1b 70 const arm_cfft_radix2_instance_f32 * S,
xorjoep 1:24714b45cd1b 71 float32_t * pSrc)
xorjoep 1:24714b45cd1b 72 {
xorjoep 1:24714b45cd1b 73
xorjoep 1:24714b45cd1b 74 if (S->ifftFlag == 1U)
xorjoep 1:24714b45cd1b 75 {
xorjoep 1:24714b45cd1b 76 /* Complex IFFT radix-2 */
xorjoep 1:24714b45cd1b 77 arm_radix2_butterfly_inverse_f32(pSrc, S->fftLen, S->pTwiddle,
xorjoep 1:24714b45cd1b 78 S->twidCoefModifier, S->onebyfftLen);
xorjoep 1:24714b45cd1b 79 }
xorjoep 1:24714b45cd1b 80 else
xorjoep 1:24714b45cd1b 81 {
xorjoep 1:24714b45cd1b 82 /* Complex FFT radix-2 */
xorjoep 1:24714b45cd1b 83 arm_radix2_butterfly_f32(pSrc, S->fftLen, S->pTwiddle,
xorjoep 1:24714b45cd1b 84 S->twidCoefModifier);
xorjoep 1:24714b45cd1b 85 }
xorjoep 1:24714b45cd1b 86
xorjoep 1:24714b45cd1b 87 if (S->bitReverseFlag == 1U)
xorjoep 1:24714b45cd1b 88 {
xorjoep 1:24714b45cd1b 89 /* Bit Reversal */
xorjoep 1:24714b45cd1b 90 arm_bitreversal_f32(pSrc, S->fftLen, S->bitRevFactor, S->pBitRevTable);
xorjoep 1:24714b45cd1b 91 }
xorjoep 1:24714b45cd1b 92
xorjoep 1:24714b45cd1b 93 }
xorjoep 1:24714b45cd1b 94
xorjoep 1:24714b45cd1b 95
xorjoep 1:24714b45cd1b 96 /**
xorjoep 1:24714b45cd1b 97 * @} end of ComplexFFT group
xorjoep 1:24714b45cd1b 98 */
xorjoep 1:24714b45cd1b 99
xorjoep 1:24714b45cd1b 100
xorjoep 1:24714b45cd1b 101
xorjoep 1:24714b45cd1b 102 /* ----------------------------------------------------------------------
xorjoep 1:24714b45cd1b 103 ** Internal helper function used by the FFTs
xorjoep 1:24714b45cd1b 104 ** ------------------------------------------------------------------- */
xorjoep 1:24714b45cd1b 105
xorjoep 1:24714b45cd1b 106 /*
xorjoep 1:24714b45cd1b 107 * @brief Core function for the floating-point CFFT butterfly process.
xorjoep 1:24714b45cd1b 108 * @param[in, out] *pSrc points to the in-place buffer of floating-point data type.
xorjoep 1:24714b45cd1b 109 * @param[in] fftLen length of the FFT.
xorjoep 1:24714b45cd1b 110 * @param[in] *pCoef points to the twiddle coefficient buffer.
xorjoep 1:24714b45cd1b 111 * @param[in] twidCoefModifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table.
xorjoep 1:24714b45cd1b 112 * @return none.
xorjoep 1:24714b45cd1b 113 */
xorjoep 1:24714b45cd1b 114
xorjoep 1:24714b45cd1b 115 void arm_radix2_butterfly_f32(
xorjoep 1:24714b45cd1b 116 float32_t * pSrc,
xorjoep 1:24714b45cd1b 117 uint32_t fftLen,
xorjoep 1:24714b45cd1b 118 float32_t * pCoef,
xorjoep 1:24714b45cd1b 119 uint16_t twidCoefModifier)
xorjoep 1:24714b45cd1b 120 {
xorjoep 1:24714b45cd1b 121
xorjoep 1:24714b45cd1b 122 uint32_t i, j, k, l;
xorjoep 1:24714b45cd1b 123 uint32_t n1, n2, ia;
xorjoep 1:24714b45cd1b 124 float32_t xt, yt, cosVal, sinVal;
xorjoep 1:24714b45cd1b 125 float32_t p0, p1, p2, p3;
xorjoep 1:24714b45cd1b 126 float32_t a0, a1;
xorjoep 1:24714b45cd1b 127
xorjoep 1:24714b45cd1b 128 #if defined (ARM_MATH_DSP)
xorjoep 1:24714b45cd1b 129
xorjoep 1:24714b45cd1b 130 /* Initializations for the first stage */
xorjoep 1:24714b45cd1b 131 n2 = fftLen >> 1;
xorjoep 1:24714b45cd1b 132 ia = 0;
xorjoep 1:24714b45cd1b 133 i = 0;
xorjoep 1:24714b45cd1b 134
xorjoep 1:24714b45cd1b 135 // loop for groups
xorjoep 1:24714b45cd1b 136 for (k = n2; k > 0; k--)
xorjoep 1:24714b45cd1b 137 {
xorjoep 1:24714b45cd1b 138 cosVal = pCoef[ia * 2];
xorjoep 1:24714b45cd1b 139 sinVal = pCoef[(ia * 2) + 1];
xorjoep 1:24714b45cd1b 140
xorjoep 1:24714b45cd1b 141 /* Twiddle coefficients index modifier */
xorjoep 1:24714b45cd1b 142 ia += twidCoefModifier;
xorjoep 1:24714b45cd1b 143
xorjoep 1:24714b45cd1b 144 /* index calculation for the input as, */
xorjoep 1:24714b45cd1b 145 /* pSrc[i + 0], pSrc[i + fftLen/1] */
xorjoep 1:24714b45cd1b 146 l = i + n2;
xorjoep 1:24714b45cd1b 147
xorjoep 1:24714b45cd1b 148 /* Butterfly implementation */
xorjoep 1:24714b45cd1b 149 a0 = pSrc[2 * i] + pSrc[2 * l];
xorjoep 1:24714b45cd1b 150 xt = pSrc[2 * i] - pSrc[2 * l];
xorjoep 1:24714b45cd1b 151
xorjoep 1:24714b45cd1b 152 yt = pSrc[2 * i + 1] - pSrc[2 * l + 1];
xorjoep 1:24714b45cd1b 153 a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1];
xorjoep 1:24714b45cd1b 154
xorjoep 1:24714b45cd1b 155 p0 = xt * cosVal;
xorjoep 1:24714b45cd1b 156 p1 = yt * sinVal;
xorjoep 1:24714b45cd1b 157 p2 = yt * cosVal;
xorjoep 1:24714b45cd1b 158 p3 = xt * sinVal;
xorjoep 1:24714b45cd1b 159
xorjoep 1:24714b45cd1b 160 pSrc[2 * i] = a0;
xorjoep 1:24714b45cd1b 161 pSrc[2 * i + 1] = a1;
xorjoep 1:24714b45cd1b 162
xorjoep 1:24714b45cd1b 163 pSrc[2 * l] = p0 + p1;
xorjoep 1:24714b45cd1b 164 pSrc[2 * l + 1] = p2 - p3;
xorjoep 1:24714b45cd1b 165
xorjoep 1:24714b45cd1b 166 i++;
xorjoep 1:24714b45cd1b 167 } // groups loop end
xorjoep 1:24714b45cd1b 168
xorjoep 1:24714b45cd1b 169 twidCoefModifier <<= 1U;
xorjoep 1:24714b45cd1b 170
xorjoep 1:24714b45cd1b 171 // loop for stage
xorjoep 1:24714b45cd1b 172 for (k = n2; k > 2; k = k >> 1)
xorjoep 1:24714b45cd1b 173 {
xorjoep 1:24714b45cd1b 174 n1 = n2;
xorjoep 1:24714b45cd1b 175 n2 = n2 >> 1;
xorjoep 1:24714b45cd1b 176 ia = 0;
xorjoep 1:24714b45cd1b 177
xorjoep 1:24714b45cd1b 178 // loop for groups
xorjoep 1:24714b45cd1b 179 j = 0;
xorjoep 1:24714b45cd1b 180 do
xorjoep 1:24714b45cd1b 181 {
xorjoep 1:24714b45cd1b 182 cosVal = pCoef[ia * 2];
xorjoep 1:24714b45cd1b 183 sinVal = pCoef[(ia * 2) + 1];
xorjoep 1:24714b45cd1b 184 ia += twidCoefModifier;
xorjoep 1:24714b45cd1b 185
xorjoep 1:24714b45cd1b 186 // loop for butterfly
xorjoep 1:24714b45cd1b 187 i = j;
xorjoep 1:24714b45cd1b 188 do
xorjoep 1:24714b45cd1b 189 {
xorjoep 1:24714b45cd1b 190 l = i + n2;
xorjoep 1:24714b45cd1b 191 a0 = pSrc[2 * i] + pSrc[2 * l];
xorjoep 1:24714b45cd1b 192 xt = pSrc[2 * i] - pSrc[2 * l];
xorjoep 1:24714b45cd1b 193
xorjoep 1:24714b45cd1b 194 yt = pSrc[2 * i + 1] - pSrc[2 * l + 1];
xorjoep 1:24714b45cd1b 195 a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1];
xorjoep 1:24714b45cd1b 196
xorjoep 1:24714b45cd1b 197 p0 = xt * cosVal;
xorjoep 1:24714b45cd1b 198 p1 = yt * sinVal;
xorjoep 1:24714b45cd1b 199 p2 = yt * cosVal;
xorjoep 1:24714b45cd1b 200 p3 = xt * sinVal;
xorjoep 1:24714b45cd1b 201
xorjoep 1:24714b45cd1b 202 pSrc[2 * i] = a0;
xorjoep 1:24714b45cd1b 203 pSrc[2 * i + 1] = a1;
xorjoep 1:24714b45cd1b 204
xorjoep 1:24714b45cd1b 205 pSrc[2 * l] = p0 + p1;
xorjoep 1:24714b45cd1b 206 pSrc[2 * l + 1] = p2 - p3;
xorjoep 1:24714b45cd1b 207
xorjoep 1:24714b45cd1b 208 i += n1;
xorjoep 1:24714b45cd1b 209 } while ( i < fftLen ); // butterfly loop end
xorjoep 1:24714b45cd1b 210 j++;
xorjoep 1:24714b45cd1b 211 } while ( j < n2); // groups loop end
xorjoep 1:24714b45cd1b 212 twidCoefModifier <<= 1U;
xorjoep 1:24714b45cd1b 213 } // stages loop end
xorjoep 1:24714b45cd1b 214
xorjoep 1:24714b45cd1b 215 // loop for butterfly
xorjoep 1:24714b45cd1b 216 for (i = 0; i < fftLen; i += 2)
xorjoep 1:24714b45cd1b 217 {
xorjoep 1:24714b45cd1b 218 a0 = pSrc[2 * i] + pSrc[2 * i + 2];
xorjoep 1:24714b45cd1b 219 xt = pSrc[2 * i] - pSrc[2 * i + 2];
xorjoep 1:24714b45cd1b 220
xorjoep 1:24714b45cd1b 221 yt = pSrc[2 * i + 1] - pSrc[2 * i + 3];
xorjoep 1:24714b45cd1b 222 a1 = pSrc[2 * i + 3] + pSrc[2 * i + 1];
xorjoep 1:24714b45cd1b 223
xorjoep 1:24714b45cd1b 224 pSrc[2 * i] = a0;
xorjoep 1:24714b45cd1b 225 pSrc[2 * i + 1] = a1;
xorjoep 1:24714b45cd1b 226 pSrc[2 * i + 2] = xt;
xorjoep 1:24714b45cd1b 227 pSrc[2 * i + 3] = yt;
xorjoep 1:24714b45cd1b 228 } // groups loop end
xorjoep 1:24714b45cd1b 229
xorjoep 1:24714b45cd1b 230 #else
xorjoep 1:24714b45cd1b 231
xorjoep 1:24714b45cd1b 232 n2 = fftLen;
xorjoep 1:24714b45cd1b 233
xorjoep 1:24714b45cd1b 234 // loop for stage
xorjoep 1:24714b45cd1b 235 for (k = fftLen; k > 1; k = k >> 1)
xorjoep 1:24714b45cd1b 236 {
xorjoep 1:24714b45cd1b 237 n1 = n2;
xorjoep 1:24714b45cd1b 238 n2 = n2 >> 1;
xorjoep 1:24714b45cd1b 239 ia = 0;
xorjoep 1:24714b45cd1b 240
xorjoep 1:24714b45cd1b 241 // loop for groups
xorjoep 1:24714b45cd1b 242 j = 0;
xorjoep 1:24714b45cd1b 243 do
xorjoep 1:24714b45cd1b 244 {
xorjoep 1:24714b45cd1b 245 cosVal = pCoef[ia * 2];
xorjoep 1:24714b45cd1b 246 sinVal = pCoef[(ia * 2) + 1];
xorjoep 1:24714b45cd1b 247 ia += twidCoefModifier;
xorjoep 1:24714b45cd1b 248
xorjoep 1:24714b45cd1b 249 // loop for butterfly
xorjoep 1:24714b45cd1b 250 i = j;
xorjoep 1:24714b45cd1b 251 do
xorjoep 1:24714b45cd1b 252 {
xorjoep 1:24714b45cd1b 253 l = i + n2;
xorjoep 1:24714b45cd1b 254 a0 = pSrc[2 * i] + pSrc[2 * l];
xorjoep 1:24714b45cd1b 255 xt = pSrc[2 * i] - pSrc[2 * l];
xorjoep 1:24714b45cd1b 256
xorjoep 1:24714b45cd1b 257 yt = pSrc[2 * i + 1] - pSrc[2 * l + 1];
xorjoep 1:24714b45cd1b 258 a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1];
xorjoep 1:24714b45cd1b 259
xorjoep 1:24714b45cd1b 260 p0 = xt * cosVal;
xorjoep 1:24714b45cd1b 261 p1 = yt * sinVal;
xorjoep 1:24714b45cd1b 262 p2 = yt * cosVal;
xorjoep 1:24714b45cd1b 263 p3 = xt * sinVal;
xorjoep 1:24714b45cd1b 264
xorjoep 1:24714b45cd1b 265 pSrc[2 * i] = a0;
xorjoep 1:24714b45cd1b 266 pSrc[2 * i + 1] = a1;
xorjoep 1:24714b45cd1b 267
xorjoep 1:24714b45cd1b 268 pSrc[2 * l] = p0 + p1;
xorjoep 1:24714b45cd1b 269 pSrc[2 * l + 1] = p2 - p3;
xorjoep 1:24714b45cd1b 270
xorjoep 1:24714b45cd1b 271 i += n1;
xorjoep 1:24714b45cd1b 272 } while (i < fftLen);
xorjoep 1:24714b45cd1b 273 j++;
xorjoep 1:24714b45cd1b 274 } while (j < n2);
xorjoep 1:24714b45cd1b 275 twidCoefModifier <<= 1U;
xorjoep 1:24714b45cd1b 276 }
xorjoep 1:24714b45cd1b 277
xorjoep 1:24714b45cd1b 278 #endif // #if defined (ARM_MATH_DSP)
xorjoep 1:24714b45cd1b 279
xorjoep 1:24714b45cd1b 280 }
xorjoep 1:24714b45cd1b 281
xorjoep 1:24714b45cd1b 282
xorjoep 1:24714b45cd1b 283 void arm_radix2_butterfly_inverse_f32(
xorjoep 1:24714b45cd1b 284 float32_t * pSrc,
xorjoep 1:24714b45cd1b 285 uint32_t fftLen,
xorjoep 1:24714b45cd1b 286 float32_t * pCoef,
xorjoep 1:24714b45cd1b 287 uint16_t twidCoefModifier,
xorjoep 1:24714b45cd1b 288 float32_t onebyfftLen)
xorjoep 1:24714b45cd1b 289 {
xorjoep 1:24714b45cd1b 290
xorjoep 1:24714b45cd1b 291 uint32_t i, j, k, l;
xorjoep 1:24714b45cd1b 292 uint32_t n1, n2, ia;
xorjoep 1:24714b45cd1b 293 float32_t xt, yt, cosVal, sinVal;
xorjoep 1:24714b45cd1b 294 float32_t p0, p1, p2, p3;
xorjoep 1:24714b45cd1b 295 float32_t a0, a1;
xorjoep 1:24714b45cd1b 296
xorjoep 1:24714b45cd1b 297 #if defined (ARM_MATH_DSP)
xorjoep 1:24714b45cd1b 298
xorjoep 1:24714b45cd1b 299 n2 = fftLen >> 1;
xorjoep 1:24714b45cd1b 300 ia = 0;
xorjoep 1:24714b45cd1b 301
xorjoep 1:24714b45cd1b 302 // loop for groups
xorjoep 1:24714b45cd1b 303 for (i = 0; i < n2; i++)
xorjoep 1:24714b45cd1b 304 {
xorjoep 1:24714b45cd1b 305 cosVal = pCoef[ia * 2];
xorjoep 1:24714b45cd1b 306 sinVal = pCoef[(ia * 2) + 1];
xorjoep 1:24714b45cd1b 307 ia += twidCoefModifier;
xorjoep 1:24714b45cd1b 308
xorjoep 1:24714b45cd1b 309 l = i + n2;
xorjoep 1:24714b45cd1b 310 a0 = pSrc[2 * i] + pSrc[2 * l];
xorjoep 1:24714b45cd1b 311 xt = pSrc[2 * i] - pSrc[2 * l];
xorjoep 1:24714b45cd1b 312
xorjoep 1:24714b45cd1b 313 yt = pSrc[2 * i + 1] - pSrc[2 * l + 1];
xorjoep 1:24714b45cd1b 314 a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1];
xorjoep 1:24714b45cd1b 315
xorjoep 1:24714b45cd1b 316 p0 = xt * cosVal;
xorjoep 1:24714b45cd1b 317 p1 = yt * sinVal;
xorjoep 1:24714b45cd1b 318 p2 = yt * cosVal;
xorjoep 1:24714b45cd1b 319 p3 = xt * sinVal;
xorjoep 1:24714b45cd1b 320
xorjoep 1:24714b45cd1b 321 pSrc[2 * i] = a0;
xorjoep 1:24714b45cd1b 322 pSrc[2 * i + 1] = a1;
xorjoep 1:24714b45cd1b 323
xorjoep 1:24714b45cd1b 324 pSrc[2 * l] = p0 - p1;
xorjoep 1:24714b45cd1b 325 pSrc[2 * l + 1] = p2 + p3;
xorjoep 1:24714b45cd1b 326 } // groups loop end
xorjoep 1:24714b45cd1b 327
xorjoep 1:24714b45cd1b 328 twidCoefModifier <<= 1U;
xorjoep 1:24714b45cd1b 329
xorjoep 1:24714b45cd1b 330 // loop for stage
xorjoep 1:24714b45cd1b 331 for (k = fftLen / 2; k > 2; k = k >> 1)
xorjoep 1:24714b45cd1b 332 {
xorjoep 1:24714b45cd1b 333 n1 = n2;
xorjoep 1:24714b45cd1b 334 n2 = n2 >> 1;
xorjoep 1:24714b45cd1b 335 ia = 0;
xorjoep 1:24714b45cd1b 336
xorjoep 1:24714b45cd1b 337 // loop for groups
xorjoep 1:24714b45cd1b 338 j = 0;
xorjoep 1:24714b45cd1b 339 do
xorjoep 1:24714b45cd1b 340 {
xorjoep 1:24714b45cd1b 341 cosVal = pCoef[ia * 2];
xorjoep 1:24714b45cd1b 342 sinVal = pCoef[(ia * 2) + 1];
xorjoep 1:24714b45cd1b 343 ia += twidCoefModifier;
xorjoep 1:24714b45cd1b 344
xorjoep 1:24714b45cd1b 345 // loop for butterfly
xorjoep 1:24714b45cd1b 346 i = j;
xorjoep 1:24714b45cd1b 347 do
xorjoep 1:24714b45cd1b 348 {
xorjoep 1:24714b45cd1b 349 l = i + n2;
xorjoep 1:24714b45cd1b 350 a0 = pSrc[2 * i] + pSrc[2 * l];
xorjoep 1:24714b45cd1b 351 xt = pSrc[2 * i] - pSrc[2 * l];
xorjoep 1:24714b45cd1b 352
xorjoep 1:24714b45cd1b 353 yt = pSrc[2 * i + 1] - pSrc[2 * l + 1];
xorjoep 1:24714b45cd1b 354 a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1];
xorjoep 1:24714b45cd1b 355
xorjoep 1:24714b45cd1b 356 p0 = xt * cosVal;
xorjoep 1:24714b45cd1b 357 p1 = yt * sinVal;
xorjoep 1:24714b45cd1b 358 p2 = yt * cosVal;
xorjoep 1:24714b45cd1b 359 p3 = xt * sinVal;
xorjoep 1:24714b45cd1b 360
xorjoep 1:24714b45cd1b 361 pSrc[2 * i] = a0;
xorjoep 1:24714b45cd1b 362 pSrc[2 * i + 1] = a1;
xorjoep 1:24714b45cd1b 363
xorjoep 1:24714b45cd1b 364 pSrc[2 * l] = p0 - p1;
xorjoep 1:24714b45cd1b 365 pSrc[2 * l + 1] = p2 + p3;
xorjoep 1:24714b45cd1b 366
xorjoep 1:24714b45cd1b 367 i += n1;
xorjoep 1:24714b45cd1b 368 } while ( i < fftLen ); // butterfly loop end
xorjoep 1:24714b45cd1b 369 j++;
xorjoep 1:24714b45cd1b 370 } while (j < n2); // groups loop end
xorjoep 1:24714b45cd1b 371
xorjoep 1:24714b45cd1b 372 twidCoefModifier <<= 1U;
xorjoep 1:24714b45cd1b 373 } // stages loop end
xorjoep 1:24714b45cd1b 374
xorjoep 1:24714b45cd1b 375 // loop for butterfly
xorjoep 1:24714b45cd1b 376 for (i = 0; i < fftLen; i += 2)
xorjoep 1:24714b45cd1b 377 {
xorjoep 1:24714b45cd1b 378 a0 = pSrc[2 * i] + pSrc[2 * i + 2];
xorjoep 1:24714b45cd1b 379 xt = pSrc[2 * i] - pSrc[2 * i + 2];
xorjoep 1:24714b45cd1b 380
xorjoep 1:24714b45cd1b 381 a1 = pSrc[2 * i + 3] + pSrc[2 * i + 1];
xorjoep 1:24714b45cd1b 382 yt = pSrc[2 * i + 1] - pSrc[2 * i + 3];
xorjoep 1:24714b45cd1b 383
xorjoep 1:24714b45cd1b 384 p0 = a0 * onebyfftLen;
xorjoep 1:24714b45cd1b 385 p2 = xt * onebyfftLen;
xorjoep 1:24714b45cd1b 386 p1 = a1 * onebyfftLen;
xorjoep 1:24714b45cd1b 387 p3 = yt * onebyfftLen;
xorjoep 1:24714b45cd1b 388
xorjoep 1:24714b45cd1b 389 pSrc[2 * i] = p0;
xorjoep 1:24714b45cd1b 390 pSrc[2 * i + 1] = p1;
xorjoep 1:24714b45cd1b 391 pSrc[2 * i + 2] = p2;
xorjoep 1:24714b45cd1b 392 pSrc[2 * i + 3] = p3;
xorjoep 1:24714b45cd1b 393 } // butterfly loop end
xorjoep 1:24714b45cd1b 394
xorjoep 1:24714b45cd1b 395 #else
xorjoep 1:24714b45cd1b 396
xorjoep 1:24714b45cd1b 397 n2 = fftLen;
xorjoep 1:24714b45cd1b 398
xorjoep 1:24714b45cd1b 399 // loop for stage
xorjoep 1:24714b45cd1b 400 for (k = fftLen; k > 2; k = k >> 1)
xorjoep 1:24714b45cd1b 401 {
xorjoep 1:24714b45cd1b 402 n1 = n2;
xorjoep 1:24714b45cd1b 403 n2 = n2 >> 1;
xorjoep 1:24714b45cd1b 404 ia = 0;
xorjoep 1:24714b45cd1b 405
xorjoep 1:24714b45cd1b 406 // loop for groups
xorjoep 1:24714b45cd1b 407 j = 0;
xorjoep 1:24714b45cd1b 408 do
xorjoep 1:24714b45cd1b 409 {
xorjoep 1:24714b45cd1b 410 cosVal = pCoef[ia * 2];
xorjoep 1:24714b45cd1b 411 sinVal = pCoef[(ia * 2) + 1];
xorjoep 1:24714b45cd1b 412 ia = ia + twidCoefModifier;
xorjoep 1:24714b45cd1b 413
xorjoep 1:24714b45cd1b 414 // loop for butterfly
xorjoep 1:24714b45cd1b 415 i = j;
xorjoep 1:24714b45cd1b 416 do
xorjoep 1:24714b45cd1b 417 {
xorjoep 1:24714b45cd1b 418 l = i + n2;
xorjoep 1:24714b45cd1b 419 a0 = pSrc[2 * i] + pSrc[2 * l];
xorjoep 1:24714b45cd1b 420 xt = pSrc[2 * i] - pSrc[2 * l];
xorjoep 1:24714b45cd1b 421
xorjoep 1:24714b45cd1b 422 yt = pSrc[2 * i + 1] - pSrc[2 * l + 1];
xorjoep 1:24714b45cd1b 423 a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1];
xorjoep 1:24714b45cd1b 424
xorjoep 1:24714b45cd1b 425 p0 = xt * cosVal;
xorjoep 1:24714b45cd1b 426 p1 = yt * sinVal;
xorjoep 1:24714b45cd1b 427 p2 = yt * cosVal;
xorjoep 1:24714b45cd1b 428 p3 = xt * sinVal;
xorjoep 1:24714b45cd1b 429
xorjoep 1:24714b45cd1b 430 pSrc[2 * i] = a0;
xorjoep 1:24714b45cd1b 431 pSrc[2 * i + 1] = a1;
xorjoep 1:24714b45cd1b 432
xorjoep 1:24714b45cd1b 433 pSrc[2 * l] = p0 - p1;
xorjoep 1:24714b45cd1b 434 pSrc[2 * l + 1] = p2 + p3;
xorjoep 1:24714b45cd1b 435
xorjoep 1:24714b45cd1b 436 i += n1;
xorjoep 1:24714b45cd1b 437 } while ( i < fftLen ); // butterfly loop end
xorjoep 1:24714b45cd1b 438 j++;
xorjoep 1:24714b45cd1b 439 } while ( j < n2 ); // groups loop end
xorjoep 1:24714b45cd1b 440
xorjoep 1:24714b45cd1b 441 twidCoefModifier = twidCoefModifier << 1U;
xorjoep 1:24714b45cd1b 442 } // stages loop end
xorjoep 1:24714b45cd1b 443
xorjoep 1:24714b45cd1b 444 n1 = n2;
xorjoep 1:24714b45cd1b 445 n2 = n2 >> 1;
xorjoep 1:24714b45cd1b 446
xorjoep 1:24714b45cd1b 447 // loop for butterfly
xorjoep 1:24714b45cd1b 448 for (i = 0; i < fftLen; i += n1)
xorjoep 1:24714b45cd1b 449 {
xorjoep 1:24714b45cd1b 450 l = i + n2;
xorjoep 1:24714b45cd1b 451
xorjoep 1:24714b45cd1b 452 a0 = pSrc[2 * i] + pSrc[2 * l];
xorjoep 1:24714b45cd1b 453 xt = pSrc[2 * i] - pSrc[2 * l];
xorjoep 1:24714b45cd1b 454
xorjoep 1:24714b45cd1b 455 a1 = pSrc[2 * l + 1] + pSrc[2 * i + 1];
xorjoep 1:24714b45cd1b 456 yt = pSrc[2 * i + 1] - pSrc[2 * l + 1];
xorjoep 1:24714b45cd1b 457
xorjoep 1:24714b45cd1b 458 p0 = a0 * onebyfftLen;
xorjoep 1:24714b45cd1b 459 p2 = xt * onebyfftLen;
xorjoep 1:24714b45cd1b 460 p1 = a1 * onebyfftLen;
xorjoep 1:24714b45cd1b 461 p3 = yt * onebyfftLen;
xorjoep 1:24714b45cd1b 462
xorjoep 1:24714b45cd1b 463 pSrc[2 * i] = p0;
xorjoep 1:24714b45cd1b 464 pSrc[2U * l] = p2;
xorjoep 1:24714b45cd1b 465
xorjoep 1:24714b45cd1b 466 pSrc[2 * i + 1] = p1;
xorjoep 1:24714b45cd1b 467 pSrc[2U * l + 1U] = p3;
xorjoep 1:24714b45cd1b 468 } // butterfly loop end
xorjoep 1:24714b45cd1b 469
xorjoep 1:24714b45cd1b 470 #endif // #if defined (ARM_MATH_DSP)
xorjoep 1:24714b45cd1b 471
xorjoep 1:24714b45cd1b 472 }