00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "arm_math.h"
00025
00026
00027
00028
00029
00030 void arm_split_rfft_q31(
00031 q31_t * pSrc,
00032 uint32_t fftLen,
00033 q31_t * pATable,
00034 q31_t * pBTable,
00035 q31_t * pDst,
00036 uint32_t modifier);
00037
00038 void arm_split_rifft_q31(
00039 q31_t * pSrc,
00040 uint32_t fftLen,
00041 q31_t * pATable,
00042 q31_t * pBTable,
00043 q31_t * pDst,
00044 uint32_t modifier);
00045
00070 void arm_rfft_q31(
00071 const arm_rfft_instance_q31 * S,
00072 q31_t * pSrc,
00073 q31_t * pDst)
00074 {
00075 const arm_cfft_radix4_instance_q31 *S_CFFT = S->pCfft;
00076
00077
00078 if(S->ifftFlagR == 1u)
00079 {
00080
00081 arm_split_rifft_q31(pSrc, S->fftLenBy2, S->pTwiddleAReal,
00082 S->pTwiddleBReal, pDst, S->twidCoefRModifier);
00083
00084
00085 arm_radix4_butterfly_inverse_q31(pDst, S_CFFT->fftLen,
00086 S_CFFT->pTwiddle,
00087 S_CFFT->twidCoefModifier);
00088
00089 if(S->bitReverseFlagR == 1u)
00090 {
00091 arm_bitreversal_q31(pDst, S_CFFT->fftLen,
00092 S_CFFT->bitRevFactor, S_CFFT->pBitRevTable);
00093 }
00094 }
00095 else
00096 {
00097
00098
00099
00100 arm_radix4_butterfly_q31(pSrc, S_CFFT->fftLen,
00101 S_CFFT->pTwiddle, S_CFFT->twidCoefModifier);
00102
00103
00104 if(S->bitReverseFlagR == 1u)
00105 {
00106 arm_bitreversal_q31(pSrc, S_CFFT->fftLen,
00107 S_CFFT->bitRevFactor, S_CFFT->pBitRevTable);
00108 }
00109
00110
00111 arm_split_rfft_q31(pSrc, S->fftLenBy2, S->pTwiddleAReal,
00112 S->pTwiddleBReal, pDst, S->twidCoefRModifier);
00113 }
00114
00115 }
00116
00117
00133 void arm_split_rfft_q31(
00134 q31_t * pSrc,
00135 uint32_t fftLen,
00136 q31_t * pATable,
00137 q31_t * pBTable,
00138 q31_t * pDst,
00139 uint32_t modifier)
00140 {
00141 uint32_t i;
00142 q31_t inVal1, inVal2;
00143 q31_t outR, outI;
00144 q31_t *pCoefA, *pCoefB;
00145 q31_t CoefA1, CoefA2, CoefB1;
00146 q31_t *pOut1 = &pDst[2], *pOut2 = &pDst[(4u * fftLen) - 1u];
00147 q31_t *pIn1 = &pSrc[2], *pIn2 = &pSrc[(2u * fftLen) - 1u];
00148
00149
00150 pCoefA = &pATable[modifier * 2u];
00151 pCoefB = &pBTable[modifier * 2u];
00152
00153 i = fftLen - 1u;
00154
00155 while(i > 0u)
00156 {
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167 CoefA1 = pCoefA[0];
00168
00169 inVal1 = pIn1[0];
00170 pIn2 -= 2u;
00171
00172 CoefA2 = pCoefA[1];
00173
00174
00175 outR = ((int32_t) (((q63_t) inVal1 * CoefA1) >> 32));
00176
00177 inVal2 = pIn1[1];
00178
00179
00180 outI = ((int32_t) (((q63_t) inVal1 * CoefA2) >> 32));
00181
00182
00183 outR =
00184 (q31_t) ((((q63_t) outR << 32) + ((q63_t) inVal2 * (-CoefA2))) >> 32);
00185
00186 inVal1 = pIn2[2];
00187 pIn1 += 2u;
00188
00189
00190 outI =
00191 (q31_t) ((((q63_t) outI << 32) + ((q63_t) inVal2 * (CoefA1))) >> 32);
00192
00193
00194 outR =
00195 (q31_t) ((((q63_t) outR << 32) + ((q63_t) inVal1 * (-CoefA2))) >> 32);
00196
00197 CoefB1 = *pCoefB;
00198
00199 inVal2 = pIn2[1];
00200
00201
00202 outI =
00203 (q31_t) ((((q63_t) outI << 32) - ((q63_t) inVal1 * (CoefB1))) >> 32);
00204
00205
00206
00207 outR =
00208 (q31_t) ((((q63_t) outR << 32) + ((q63_t) inVal2 * (CoefB1))) >> 32);
00209
00210
00211 outI =
00212 (q31_t) ((((q63_t) outI << 32) - ((q63_t) inVal2 * (CoefA2))) >> 32);
00213
00214 pOut2 -= 2u;
00215
00216
00217 *pOut1++ = (outR << 1u);
00218 *pOut1++ = (outI << 1u);
00219
00220
00221 pOut2[2] = -(outI << 1u);
00222 pOut2[1] = (outR << 1u);
00223
00224
00225 pCoefB = pCoefB + (modifier * 2u);
00226 pCoefA = pCoefA + (modifier * 2u);
00227
00228 i--;
00229
00230 }
00231
00232 pDst[2u * fftLen] = pSrc[0] - pSrc[1];
00233 pDst[(2u * fftLen) + 1u] = 0;
00234
00235 pDst[0] = pSrc[0] + pSrc[1];
00236 pDst[1] = 0;
00237
00238 }
00239
00240
00252 void arm_split_rifft_q31(
00253 q31_t * pSrc,
00254 uint32_t fftLen,
00255 q31_t * pATable,
00256 q31_t * pBTable,
00257 q31_t * pDst,
00258 uint32_t modifier)
00259 {
00260 q31_t inVal1, inVal2;
00261 q31_t outR, outI;
00262 q31_t *pCoefA, *pCoefB;
00263 q31_t CoefA1, CoefA2, CoefB1;
00264 q31_t *pIn1 = &pSrc[0], *pIn2 = &pSrc[(2u * fftLen) + 1u];
00265
00266 pCoefA = &pATable[0];
00267 pCoefB = &pBTable[0];
00268
00269 while(fftLen > 0u)
00270 {
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281 inVal1 = *pIn1;
00282 pIn2 -= 2u;
00283
00284 CoefA1 = *pCoefA++;
00285 CoefA2 = *pCoefA;
00286
00287
00288 outR = ((int32_t) (((q63_t) inVal1 * CoefA1) >> 32));
00289
00290 inVal2 = pIn1[1];
00291
00292 pIn1 += 2u;
00293
00294
00295 outI = -((int32_t) (((q63_t) inVal1 * CoefA2) >> 32));
00296
00297 inVal1 = pIn2[2];
00298
00299
00300 outR =
00301 (q31_t) ((((q63_t) outR << 32) + ((q63_t) inVal2 * (CoefA2))) >> 32);
00302
00303
00304
00305 outI =
00306 (q31_t) ((((q63_t) outI << 32) + ((q63_t) inVal2* (CoefA1))) >> 32);
00307
00308
00309
00310 outR =
00311 (q31_t) ((((q63_t) outR << 32) + ((q63_t) inVal1 * (CoefA2))) >> 32);
00312
00313 CoefB1 = *pCoefB;
00314
00315
00316 inVal2 = pIn2[1];
00317
00318
00319 outI =
00320 (q31_t) ((((q63_t) outI << 32) - ((q63_t) inVal1 * (CoefB1))) >> 32);
00321
00322
00323 outR =
00324 (q31_t) ((((q63_t) outR << 32) + ((q63_t) inVal2 * (CoefB1))) >> 32);
00325
00326
00327
00328 outI =
00329 (q31_t) ((((q63_t) outI << 32) + ((q63_t) inVal2 * (CoefA2))) >> 32);
00330
00331
00332 *pDst++ = (outR << 1u);
00333 *pDst++ = (outI << 1u);
00334
00335
00336 pCoefB = pCoefB + (modifier * 2u);
00337 pCoefA = pCoefA + ((modifier * 2u) - 1u);
00338
00339
00340 fftLen--;
00341
00342 }
00343
00344
00345 }