CMSIS DSP Lib

Fork of mbed-dsp by mbed official

Committer:
mbed_official
Date:
Fri Nov 08 13:45:10 2013 +0000
Revision:
3:7a284390b0ce
Parent:
2:da51fb522205
Synchronized with git revision e69956aba2f68a2a26ac26b051f8d349deaa1ce8

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emilmont 1:fdd22bb7aa52 1 /* ----------------------------------------------------------------------
mbed_official 3:7a284390b0ce 2 * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
emilmont 1:fdd22bb7aa52 3 *
mbed_official 3:7a284390b0ce 4 * $Date: 17. January 2013
mbed_official 3:7a284390b0ce 5 * $Revision: V1.4.1
emilmont 1:fdd22bb7aa52 6 *
emilmont 2:da51fb522205 7 * Project: CMSIS DSP Library
emilmont 2:da51fb522205 8 * Title: arm_rfft_q31.c
emilmont 1:fdd22bb7aa52 9 *
emilmont 2:da51fb522205 10 * Description: RFFT & RIFFT Q31 process function
emilmont 1:fdd22bb7aa52 11 *
emilmont 1:fdd22bb7aa52 12 *
emilmont 1:fdd22bb7aa52 13 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
emilmont 1:fdd22bb7aa52 14 *
mbed_official 3:7a284390b0ce 15 * Redistribution and use in source and binary forms, with or without
mbed_official 3:7a284390b0ce 16 * modification, are permitted provided that the following conditions
mbed_official 3:7a284390b0ce 17 * are met:
mbed_official 3:7a284390b0ce 18 * - Redistributions of source code must retain the above copyright
mbed_official 3:7a284390b0ce 19 * notice, this list of conditions and the following disclaimer.
mbed_official 3:7a284390b0ce 20 * - Redistributions in binary form must reproduce the above copyright
mbed_official 3:7a284390b0ce 21 * notice, this list of conditions and the following disclaimer in
mbed_official 3:7a284390b0ce 22 * the documentation and/or other materials provided with the
mbed_official 3:7a284390b0ce 23 * distribution.
mbed_official 3:7a284390b0ce 24 * - Neither the name of ARM LIMITED nor the names of its contributors
mbed_official 3:7a284390b0ce 25 * may be used to endorse or promote products derived from this
mbed_official 3:7a284390b0ce 26 * software without specific prior written permission.
mbed_official 3:7a284390b0ce 27 *
mbed_official 3:7a284390b0ce 28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
mbed_official 3:7a284390b0ce 29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
mbed_official 3:7a284390b0ce 30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
mbed_official 3:7a284390b0ce 31 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
mbed_official 3:7a284390b0ce 32 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
mbed_official 3:7a284390b0ce 33 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
mbed_official 3:7a284390b0ce 34 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
mbed_official 3:7a284390b0ce 35 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 3:7a284390b0ce 36 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
mbed_official 3:7a284390b0ce 37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
mbed_official 3:7a284390b0ce 38 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
mbed_official 3:7a284390b0ce 39 * POSSIBILITY OF SUCH DAMAGE.
emilmont 1:fdd22bb7aa52 40 * -------------------------------------------------------------------- */
emilmont 1:fdd22bb7aa52 41
emilmont 1:fdd22bb7aa52 42 #include "arm_math.h"
emilmont 1:fdd22bb7aa52 43
mbed_official 3:7a284390b0ce 44 void arm_radix4_butterfly_inverse_q31(
mbed_official 3:7a284390b0ce 45 q31_t * pSrc,
mbed_official 3:7a284390b0ce 46 uint32_t fftLen,
mbed_official 3:7a284390b0ce 47 q31_t * pCoef,
mbed_official 3:7a284390b0ce 48 uint32_t twidCoefModifier);
mbed_official 3:7a284390b0ce 49
mbed_official 3:7a284390b0ce 50 void arm_radix4_butterfly_q31(
mbed_official 3:7a284390b0ce 51 q31_t * pSrc,
mbed_official 3:7a284390b0ce 52 uint32_t fftLen,
mbed_official 3:7a284390b0ce 53 q31_t * pCoef,
mbed_official 3:7a284390b0ce 54 uint32_t twidCoefModifier);
mbed_official 3:7a284390b0ce 55
mbed_official 3:7a284390b0ce 56 void arm_bitreversal_q31(
mbed_official 3:7a284390b0ce 57 q31_t * pSrc,
mbed_official 3:7a284390b0ce 58 uint32_t fftLen,
mbed_official 3:7a284390b0ce 59 uint16_t bitRevFactor,
mbed_official 3:7a284390b0ce 60 uint16_t * pBitRevTab);
mbed_official 3:7a284390b0ce 61
emilmont 1:fdd22bb7aa52 62 /*--------------------------------------------------------------------
emilmont 2:da51fb522205 63 * Internal functions prototypes
emilmont 1:fdd22bb7aa52 64 --------------------------------------------------------------------*/
emilmont 1:fdd22bb7aa52 65
emilmont 1:fdd22bb7aa52 66 void arm_split_rfft_q31(
emilmont 1:fdd22bb7aa52 67 q31_t * pSrc,
emilmont 1:fdd22bb7aa52 68 uint32_t fftLen,
emilmont 1:fdd22bb7aa52 69 q31_t * pATable,
emilmont 1:fdd22bb7aa52 70 q31_t * pBTable,
emilmont 1:fdd22bb7aa52 71 q31_t * pDst,
emilmont 1:fdd22bb7aa52 72 uint32_t modifier);
emilmont 1:fdd22bb7aa52 73
emilmont 1:fdd22bb7aa52 74 void arm_split_rifft_q31(
emilmont 1:fdd22bb7aa52 75 q31_t * pSrc,
emilmont 1:fdd22bb7aa52 76 uint32_t fftLen,
emilmont 1:fdd22bb7aa52 77 q31_t * pATable,
emilmont 1:fdd22bb7aa52 78 q31_t * pBTable,
emilmont 1:fdd22bb7aa52 79 q31_t * pDst,
emilmont 1:fdd22bb7aa52 80 uint32_t modifier);
emilmont 1:fdd22bb7aa52 81
emilmont 1:fdd22bb7aa52 82 /**
mbed_official 3:7a284390b0ce 83 * @addtogroup RealFFT
emilmont 1:fdd22bb7aa52 84 * @{
emilmont 1:fdd22bb7aa52 85 */
emilmont 1:fdd22bb7aa52 86
emilmont 1:fdd22bb7aa52 87 /**
emilmont 1:fdd22bb7aa52 88 * @brief Processing function for the Q31 RFFT/RIFFT.
emilmont 1:fdd22bb7aa52 89 * @param[in] *S points to an instance of the Q31 RFFT/RIFFT structure.
emilmont 1:fdd22bb7aa52 90 * @param[in] *pSrc points to the input buffer.
emilmont 1:fdd22bb7aa52 91 * @param[out] *pDst points to the output buffer.
emilmont 1:fdd22bb7aa52 92 * @return none.
emilmont 1:fdd22bb7aa52 93 *
emilmont 1:fdd22bb7aa52 94 * \par Input an output formats:
emilmont 1:fdd22bb7aa52 95 * \par
emilmont 1:fdd22bb7aa52 96 * Internally input is downscaled by 2 for every stage to avoid saturations inside CFFT/CIFFT process.
emilmont 1:fdd22bb7aa52 97 * Hence the output format is different for different RFFT sizes.
emilmont 1:fdd22bb7aa52 98 * The input and output formats for different RFFT sizes and number of bits to upscale are mentioned in the tables below for RFFT and RIFFT:
emilmont 1:fdd22bb7aa52 99 * \par
emilmont 1:fdd22bb7aa52 100 * \image html RFFTQ31.gif "Input and Output Formats for Q31 RFFT"
emilmont 1:fdd22bb7aa52 101 *
emilmont 1:fdd22bb7aa52 102 * \par
emilmont 1:fdd22bb7aa52 103 * \image html RIFFTQ31.gif "Input and Output Formats for Q31 RIFFT"
emilmont 1:fdd22bb7aa52 104 */
emilmont 1:fdd22bb7aa52 105
emilmont 1:fdd22bb7aa52 106 void arm_rfft_q31(
emilmont 1:fdd22bb7aa52 107 const arm_rfft_instance_q31 * S,
emilmont 1:fdd22bb7aa52 108 q31_t * pSrc,
emilmont 1:fdd22bb7aa52 109 q31_t * pDst)
emilmont 1:fdd22bb7aa52 110 {
emilmont 1:fdd22bb7aa52 111 const arm_cfft_radix4_instance_q31 *S_CFFT = S->pCfft;
emilmont 1:fdd22bb7aa52 112
emilmont 1:fdd22bb7aa52 113 /* Calculation of RIFFT of input */
emilmont 1:fdd22bb7aa52 114 if(S->ifftFlagR == 1u)
emilmont 1:fdd22bb7aa52 115 {
emilmont 1:fdd22bb7aa52 116 /* Real IFFT core process */
emilmont 1:fdd22bb7aa52 117 arm_split_rifft_q31(pSrc, S->fftLenBy2, S->pTwiddleAReal,
emilmont 1:fdd22bb7aa52 118 S->pTwiddleBReal, pDst, S->twidCoefRModifier);
emilmont 1:fdd22bb7aa52 119
emilmont 1:fdd22bb7aa52 120 /* Complex readix-4 IFFT process */
emilmont 1:fdd22bb7aa52 121 arm_radix4_butterfly_inverse_q31(pDst, S_CFFT->fftLen,
emilmont 1:fdd22bb7aa52 122 S_CFFT->pTwiddle,
emilmont 1:fdd22bb7aa52 123 S_CFFT->twidCoefModifier);
emilmont 1:fdd22bb7aa52 124 /* Bit reversal process */
emilmont 1:fdd22bb7aa52 125 if(S->bitReverseFlagR == 1u)
emilmont 1:fdd22bb7aa52 126 {
emilmont 1:fdd22bb7aa52 127 arm_bitreversal_q31(pDst, S_CFFT->fftLen,
emilmont 1:fdd22bb7aa52 128 S_CFFT->bitRevFactor, S_CFFT->pBitRevTable);
emilmont 1:fdd22bb7aa52 129 }
emilmont 1:fdd22bb7aa52 130 }
emilmont 1:fdd22bb7aa52 131 else
emilmont 1:fdd22bb7aa52 132 {
emilmont 1:fdd22bb7aa52 133 /* Calculation of RFFT of input */
emilmont 1:fdd22bb7aa52 134
emilmont 1:fdd22bb7aa52 135 /* Complex readix-4 FFT process */
emilmont 1:fdd22bb7aa52 136 arm_radix4_butterfly_q31(pSrc, S_CFFT->fftLen,
emilmont 1:fdd22bb7aa52 137 S_CFFT->pTwiddle, S_CFFT->twidCoefModifier);
emilmont 1:fdd22bb7aa52 138
emilmont 1:fdd22bb7aa52 139 /* Bit reversal process */
emilmont 1:fdd22bb7aa52 140 if(S->bitReverseFlagR == 1u)
emilmont 1:fdd22bb7aa52 141 {
emilmont 1:fdd22bb7aa52 142 arm_bitreversal_q31(pSrc, S_CFFT->fftLen,
emilmont 1:fdd22bb7aa52 143 S_CFFT->bitRevFactor, S_CFFT->pBitRevTable);
emilmont 1:fdd22bb7aa52 144 }
emilmont 1:fdd22bb7aa52 145
emilmont 1:fdd22bb7aa52 146 /* Real FFT core process */
emilmont 1:fdd22bb7aa52 147 arm_split_rfft_q31(pSrc, S->fftLenBy2, S->pTwiddleAReal,
emilmont 1:fdd22bb7aa52 148 S->pTwiddleBReal, pDst, S->twidCoefRModifier);
emilmont 1:fdd22bb7aa52 149 }
emilmont 1:fdd22bb7aa52 150
emilmont 1:fdd22bb7aa52 151 }
emilmont 1:fdd22bb7aa52 152
emilmont 1:fdd22bb7aa52 153
emilmont 1:fdd22bb7aa52 154 /**
mbed_official 3:7a284390b0ce 155 * @} end of RealFFT group
emilmont 1:fdd22bb7aa52 156 */
emilmont 1:fdd22bb7aa52 157
emilmont 1:fdd22bb7aa52 158 /**
emilmont 1:fdd22bb7aa52 159 * @brief Core Real FFT process
emilmont 2:da51fb522205 160 * @param[in] *pSrc points to the input buffer.
emilmont 2:da51fb522205 161 * @param[in] fftLen length of FFT.
emilmont 2:da51fb522205 162 * @param[in] *pATable points to the twiddle Coef A buffer.
emilmont 2:da51fb522205 163 * @param[in] *pBTable points to the twiddle Coef B buffer.
emilmont 2:da51fb522205 164 * @param[out] *pDst points to the output buffer.
emilmont 2:da51fb522205 165 * @param[in] modifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table.
emilmont 1:fdd22bb7aa52 166 * @return none.
emilmont 1:fdd22bb7aa52 167 */
emilmont 1:fdd22bb7aa52 168
emilmont 1:fdd22bb7aa52 169 void arm_split_rfft_q31(
emilmont 1:fdd22bb7aa52 170 q31_t * pSrc,
emilmont 1:fdd22bb7aa52 171 uint32_t fftLen,
emilmont 1:fdd22bb7aa52 172 q31_t * pATable,
emilmont 1:fdd22bb7aa52 173 q31_t * pBTable,
emilmont 1:fdd22bb7aa52 174 q31_t * pDst,
emilmont 1:fdd22bb7aa52 175 uint32_t modifier)
emilmont 1:fdd22bb7aa52 176 {
emilmont 1:fdd22bb7aa52 177 uint32_t i; /* Loop Counter */
emilmont 1:fdd22bb7aa52 178 q31_t outR, outI; /* Temporary variables for output */
emilmont 1:fdd22bb7aa52 179 q31_t *pCoefA, *pCoefB; /* Temporary pointers for twiddle factors */
emilmont 1:fdd22bb7aa52 180 q31_t CoefA1, CoefA2, CoefB1; /* Temporary variables for twiddle coefficients */
emilmont 1:fdd22bb7aa52 181 q31_t *pOut1 = &pDst[2], *pOut2 = &pDst[(4u * fftLen) - 1u];
emilmont 1:fdd22bb7aa52 182 q31_t *pIn1 = &pSrc[2], *pIn2 = &pSrc[(2u * fftLen) - 1u];
emilmont 1:fdd22bb7aa52 183
emilmont 1:fdd22bb7aa52 184 /* Init coefficient pointers */
emilmont 1:fdd22bb7aa52 185 pCoefA = &pATable[modifier * 2u];
emilmont 1:fdd22bb7aa52 186 pCoefB = &pBTable[modifier * 2u];
emilmont 1:fdd22bb7aa52 187
emilmont 1:fdd22bb7aa52 188 i = fftLen - 1u;
emilmont 1:fdd22bb7aa52 189
emilmont 1:fdd22bb7aa52 190 while(i > 0u)
emilmont 1:fdd22bb7aa52 191 {
emilmont 1:fdd22bb7aa52 192 /*
emilmont 1:fdd22bb7aa52 193 outR = (pSrc[2 * i] * pATable[2 * i] - pSrc[2 * i + 1] * pATable[2 * i + 1]
emilmont 1:fdd22bb7aa52 194 + pSrc[2 * n - 2 * i] * pBTable[2 * i] +
emilmont 1:fdd22bb7aa52 195 pSrc[2 * n - 2 * i + 1] * pBTable[2 * i + 1]);
emilmont 1:fdd22bb7aa52 196 */
emilmont 1:fdd22bb7aa52 197
emilmont 1:fdd22bb7aa52 198 /* outI = (pIn[2 * i + 1] * pATable[2 * i] + pIn[2 * i] * pATable[2 * i + 1] +
emilmont 1:fdd22bb7aa52 199 pIn[2 * n - 2 * i] * pBTable[2 * i + 1] -
emilmont 1:fdd22bb7aa52 200 pIn[2 * n - 2 * i + 1] * pBTable[2 * i]); */
emilmont 1:fdd22bb7aa52 201
emilmont 1:fdd22bb7aa52 202 CoefA1 = *pCoefA++;
emilmont 1:fdd22bb7aa52 203 CoefA2 = *pCoefA;
emilmont 1:fdd22bb7aa52 204
emilmont 1:fdd22bb7aa52 205 /* outR = (pSrc[2 * i] * pATable[2 * i] */
emilmont 1:fdd22bb7aa52 206 outR = ((int32_t) (((q63_t) * pIn1 * CoefA1) >> 32));
emilmont 1:fdd22bb7aa52 207
emilmont 1:fdd22bb7aa52 208 /* outI = pIn[2 * i] * pATable[2 * i + 1] */
emilmont 1:fdd22bb7aa52 209 outI = ((int32_t) (((q63_t) * pIn1++ * CoefA2) >> 32));
emilmont 1:fdd22bb7aa52 210
emilmont 1:fdd22bb7aa52 211 /* - pSrc[2 * i + 1] * pATable[2 * i + 1] */
emilmont 1:fdd22bb7aa52 212 outR =
emilmont 1:fdd22bb7aa52 213 (q31_t) ((((q63_t) outR << 32) + ((q63_t) * pIn1 * (-CoefA2))) >> 32);
emilmont 1:fdd22bb7aa52 214
emilmont 1:fdd22bb7aa52 215 /* (pIn[2 * i + 1] * pATable[2 * i] */
emilmont 1:fdd22bb7aa52 216 outI =
emilmont 1:fdd22bb7aa52 217 (q31_t) ((((q63_t) outI << 32) + ((q63_t) * pIn1++ * (CoefA1))) >> 32);
emilmont 1:fdd22bb7aa52 218
emilmont 1:fdd22bb7aa52 219 /* pSrc[2 * n - 2 * i] * pBTable[2 * i] */
emilmont 1:fdd22bb7aa52 220 outR =
emilmont 1:fdd22bb7aa52 221 (q31_t) ((((q63_t) outR << 32) + ((q63_t) * pIn2 * (-CoefA2))) >> 32);
emilmont 1:fdd22bb7aa52 222 CoefB1 = *pCoefB;
emilmont 1:fdd22bb7aa52 223
emilmont 1:fdd22bb7aa52 224 /* pIn[2 * n - 2 * i] * pBTable[2 * i + 1] */
emilmont 1:fdd22bb7aa52 225 outI =
emilmont 1:fdd22bb7aa52 226 (q31_t) ((((q63_t) outI << 32) + ((q63_t) * pIn2-- * (-CoefB1))) >> 32);
emilmont 1:fdd22bb7aa52 227
emilmont 1:fdd22bb7aa52 228 /* pSrc[2 * n - 2 * i + 1] * pBTable[2 * i + 1] */
emilmont 1:fdd22bb7aa52 229 outR =
emilmont 1:fdd22bb7aa52 230 (q31_t) ((((q63_t) outR << 32) + ((q63_t) * pIn2 * (CoefB1))) >> 32);
emilmont 1:fdd22bb7aa52 231
emilmont 1:fdd22bb7aa52 232 /* pIn[2 * n - 2 * i + 1] * pBTable[2 * i] */
emilmont 1:fdd22bb7aa52 233 outI =
emilmont 1:fdd22bb7aa52 234 (q31_t) ((((q63_t) outI << 32) + ((q63_t) * pIn2-- * (-CoefA2))) >> 32);
emilmont 1:fdd22bb7aa52 235
emilmont 1:fdd22bb7aa52 236 /* write output */
emilmont 1:fdd22bb7aa52 237 *pOut1++ = (outR << 1u);
emilmont 1:fdd22bb7aa52 238 *pOut1++ = (outI << 1u);
emilmont 1:fdd22bb7aa52 239
emilmont 1:fdd22bb7aa52 240 /* write complex conjugate output */
emilmont 1:fdd22bb7aa52 241 *pOut2-- = -(outI << 1u);
emilmont 1:fdd22bb7aa52 242 *pOut2-- = (outR << 1u);
emilmont 1:fdd22bb7aa52 243
emilmont 1:fdd22bb7aa52 244 /* update coefficient pointer */
emilmont 1:fdd22bb7aa52 245 pCoefB = pCoefB + (modifier * 2u);
emilmont 1:fdd22bb7aa52 246 pCoefA = pCoefA + ((modifier * 2u) - 1u);
emilmont 1:fdd22bb7aa52 247
emilmont 1:fdd22bb7aa52 248 i--;
emilmont 1:fdd22bb7aa52 249
emilmont 1:fdd22bb7aa52 250 }
emilmont 1:fdd22bb7aa52 251
emilmont 1:fdd22bb7aa52 252 pDst[2u * fftLen] = pSrc[0] - pSrc[1];
emilmont 1:fdd22bb7aa52 253 pDst[(2u * fftLen) + 1u] = 0;
emilmont 1:fdd22bb7aa52 254
emilmont 1:fdd22bb7aa52 255 pDst[0] = pSrc[0] + pSrc[1];
emilmont 1:fdd22bb7aa52 256 pDst[1] = 0;
emilmont 1:fdd22bb7aa52 257
emilmont 1:fdd22bb7aa52 258 }
emilmont 1:fdd22bb7aa52 259
emilmont 1:fdd22bb7aa52 260
emilmont 1:fdd22bb7aa52 261 /**
emilmont 1:fdd22bb7aa52 262 * @brief Core Real IFFT process
emilmont 2:da51fb522205 263 * @param[in] *pSrc points to the input buffer.
emilmont 2:da51fb522205 264 * @param[in] fftLen length of FFT.
emilmont 2:da51fb522205 265 * @param[in] *pATable points to the twiddle Coef A buffer.
emilmont 2:da51fb522205 266 * @param[in] *pBTable points to the twiddle Coef B buffer.
emilmont 2:da51fb522205 267 * @param[out] *pDst points to the output buffer.
emilmont 2:da51fb522205 268 * @param[in] modifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table.
emilmont 1:fdd22bb7aa52 269 * @return none.
emilmont 1:fdd22bb7aa52 270 */
emilmont 1:fdd22bb7aa52 271
emilmont 1:fdd22bb7aa52 272 void arm_split_rifft_q31(
emilmont 1:fdd22bb7aa52 273 q31_t * pSrc,
emilmont 1:fdd22bb7aa52 274 uint32_t fftLen,
emilmont 1:fdd22bb7aa52 275 q31_t * pATable,
emilmont 1:fdd22bb7aa52 276 q31_t * pBTable,
emilmont 1:fdd22bb7aa52 277 q31_t * pDst,
emilmont 1:fdd22bb7aa52 278 uint32_t modifier)
emilmont 1:fdd22bb7aa52 279 {
emilmont 1:fdd22bb7aa52 280 q31_t outR, outI; /* Temporary variables for output */
emilmont 1:fdd22bb7aa52 281 q31_t *pCoefA, *pCoefB; /* Temporary pointers for twiddle factors */
emilmont 1:fdd22bb7aa52 282 q31_t CoefA1, CoefA2, CoefB1; /* Temporary variables for twiddle coefficients */
emilmont 1:fdd22bb7aa52 283 q31_t *pIn1 = &pSrc[0], *pIn2 = &pSrc[(2u * fftLen) + 1u];
emilmont 1:fdd22bb7aa52 284
emilmont 1:fdd22bb7aa52 285 pCoefA = &pATable[0];
emilmont 1:fdd22bb7aa52 286 pCoefB = &pBTable[0];
emilmont 1:fdd22bb7aa52 287
emilmont 1:fdd22bb7aa52 288 while(fftLen > 0u)
emilmont 1:fdd22bb7aa52 289 {
emilmont 1:fdd22bb7aa52 290 /*
emilmont 1:fdd22bb7aa52 291 outR = (pIn[2 * i] * pATable[2 * i] + pIn[2 * i + 1] * pATable[2 * i + 1] +
emilmont 1:fdd22bb7aa52 292 pIn[2 * n - 2 * i] * pBTable[2 * i] -
emilmont 1:fdd22bb7aa52 293 pIn[2 * n - 2 * i + 1] * pBTable[2 * i + 1]);
emilmont 1:fdd22bb7aa52 294
emilmont 1:fdd22bb7aa52 295 outI = (pIn[2 * i + 1] * pATable[2 * i] - pIn[2 * i] * pATable[2 * i + 1] -
emilmont 1:fdd22bb7aa52 296 pIn[2 * n - 2 * i] * pBTable[2 * i + 1] -
emilmont 1:fdd22bb7aa52 297 pIn[2 * n - 2 * i + 1] * pBTable[2 * i]);
emilmont 1:fdd22bb7aa52 298
emilmont 1:fdd22bb7aa52 299 */
emilmont 1:fdd22bb7aa52 300 CoefA1 = *pCoefA++;
emilmont 1:fdd22bb7aa52 301 CoefA2 = *pCoefA;
emilmont 1:fdd22bb7aa52 302
emilmont 1:fdd22bb7aa52 303 /* outR = (pIn[2 * i] * pATable[2 * i] */
emilmont 1:fdd22bb7aa52 304 outR = ((int32_t) (((q63_t) * pIn1 * CoefA1) >> 32));
emilmont 1:fdd22bb7aa52 305
emilmont 1:fdd22bb7aa52 306 /* - pIn[2 * i] * pATable[2 * i + 1] */
emilmont 1:fdd22bb7aa52 307 outI = -((int32_t) (((q63_t) * pIn1++ * CoefA2) >> 32));
emilmont 1:fdd22bb7aa52 308
emilmont 1:fdd22bb7aa52 309 /* pIn[2 * i + 1] * pATable[2 * i + 1] */
emilmont 1:fdd22bb7aa52 310 outR =
emilmont 1:fdd22bb7aa52 311 (q31_t) ((((q63_t) outR << 32) + ((q63_t) * pIn1 * (CoefA2))) >> 32);
emilmont 1:fdd22bb7aa52 312
emilmont 1:fdd22bb7aa52 313 /* pIn[2 * i + 1] * pATable[2 * i] */
emilmont 1:fdd22bb7aa52 314 outI =
emilmont 1:fdd22bb7aa52 315 (q31_t) ((((q63_t) outI << 32) + ((q63_t) * pIn1++ * (CoefA1))) >> 32);
emilmont 1:fdd22bb7aa52 316
emilmont 1:fdd22bb7aa52 317 /* pIn[2 * n - 2 * i] * pBTable[2 * i] */
emilmont 1:fdd22bb7aa52 318 outR =
emilmont 1:fdd22bb7aa52 319 (q31_t) ((((q63_t) outR << 32) + ((q63_t) * pIn2 * (CoefA2))) >> 32);
emilmont 1:fdd22bb7aa52 320
emilmont 1:fdd22bb7aa52 321 CoefB1 = *pCoefB;
emilmont 1:fdd22bb7aa52 322
emilmont 1:fdd22bb7aa52 323 /* pIn[2 * n - 2 * i] * pBTable[2 * i + 1] */
emilmont 1:fdd22bb7aa52 324 outI =
emilmont 1:fdd22bb7aa52 325 (q31_t) ((((q63_t) outI << 32) - ((q63_t) * pIn2-- * (CoefB1))) >> 32);
emilmont 1:fdd22bb7aa52 326
emilmont 1:fdd22bb7aa52 327 /* pIn[2 * n - 2 * i + 1] * pBTable[2 * i + 1] */
emilmont 1:fdd22bb7aa52 328 outR =
emilmont 1:fdd22bb7aa52 329 (q31_t) ((((q63_t) outR << 32) + ((q63_t) * pIn2 * (CoefB1))) >> 32);
emilmont 1:fdd22bb7aa52 330
emilmont 1:fdd22bb7aa52 331 /* pIn[2 * n - 2 * i + 1] * pBTable[2 * i] */
emilmont 1:fdd22bb7aa52 332 outI =
emilmont 1:fdd22bb7aa52 333 (q31_t) ((((q63_t) outI << 32) + ((q63_t) * pIn2-- * (CoefA2))) >> 32);
emilmont 1:fdd22bb7aa52 334
emilmont 1:fdd22bb7aa52 335 /* write output */
emilmont 1:fdd22bb7aa52 336 *pDst++ = (outR << 1u);
emilmont 1:fdd22bb7aa52 337 *pDst++ = (outI << 1u);
emilmont 1:fdd22bb7aa52 338
emilmont 1:fdd22bb7aa52 339 /* update coefficient pointer */
emilmont 1:fdd22bb7aa52 340 pCoefB = pCoefB + (modifier * 2u);
emilmont 1:fdd22bb7aa52 341 pCoefA = pCoefA + ((modifier * 2u) - 1u);
emilmont 1:fdd22bb7aa52 342
emilmont 1:fdd22bb7aa52 343 /* Decrement loop count */
emilmont 1:fdd22bb7aa52 344 fftLen--;
emilmont 1:fdd22bb7aa52 345
emilmont 1:fdd22bb7aa52 346 }
emilmont 1:fdd22bb7aa52 347
emilmont 1:fdd22bb7aa52 348
emilmont 1:fdd22bb7aa52 349 }