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
00109
00110
00111
00112
00113 void arm_split_rfft_f32(
00114 float32_t * pSrc,
00115 uint32_t fftLen,
00116 float32_t * pATable,
00117 float32_t * pBTable,
00118 float32_t * pDst,
00119 uint32_t modifier);
00120 void arm_split_rifft_f32(
00121 float32_t * pSrc,
00122 uint32_t fftLen,
00123 float32_t * pATable,
00124 float32_t * pBTable,
00125 float32_t * pDst,
00126 uint32_t modifier);
00127
00141 void arm_rfft_f32(
00142 const arm_rfft_instance_f32 * S,
00143 float32_t * pSrc,
00144 float32_t * pDst)
00145 {
00146 const arm_cfft_radix4_instance_f32 *S_CFFT = S->pCfft;
00147
00148
00149
00150 if(S->ifftFlagR == 1u)
00151 {
00152
00153 arm_split_rifft_f32(pSrc, S->fftLenBy2, S->pTwiddleAReal,
00154 S->pTwiddleBReal, pDst, S->twidCoefRModifier);
00155
00156
00157
00158 arm_radix4_butterfly_inverse_f32(pDst, S_CFFT->fftLen,
00159 S_CFFT->pTwiddle,
00160 S_CFFT->twidCoefModifier,
00161 S_CFFT->onebyfftLen);
00162
00163
00164 if(S->bitReverseFlagR == 1u)
00165 {
00166 arm_bitreversal_f32(pDst, S_CFFT->fftLen,
00167 S_CFFT->bitRevFactor, S_CFFT->pBitRevTable);
00168 }
00169 }
00170 else
00171 {
00172
00173
00174
00175
00176 arm_radix4_butterfly_f32(pSrc, S_CFFT->fftLen,
00177 S_CFFT->pTwiddle, S_CFFT->twidCoefModifier);
00178
00179
00180 if(S->bitReverseFlagR == 1u)
00181 {
00182 arm_bitreversal_f32(pSrc, S_CFFT->fftLen,
00183 S_CFFT->bitRevFactor, S_CFFT->pBitRevTable);
00184 }
00185
00186
00187
00188 arm_split_rfft_f32(pSrc, S->fftLenBy2, S->pTwiddleAReal,
00189 S->pTwiddleBReal, pDst, S->twidCoefRModifier);
00190 }
00191
00192 }
00193
00209 void arm_split_rfft_f32(
00210 float32_t * pSrc,
00211 uint32_t fftLen,
00212 float32_t * pATable,
00213 float32_t * pBTable,
00214 float32_t * pDst,
00215 uint32_t modifier)
00216 {
00217 uint32_t i, blkCnt;
00218 float32_t *pCoefA, *pCoefB;
00219 float32_t *pDst1 = &pDst[2], *pDst2 = &pDst[(4u * fftLen) - 1u];
00220 float32_t *pSrc1 = &pSrc[2], *pSrc2 = &pSrc[(2u * fftLen) - 1u];
00221 float32_t inR1, inR2, inR4, inI1, inI2, inI4;
00222 float32_t CoefA1, CoefA2, CoefA3, CoefA4, CoefB1, CoefB2;
00223 float32_t outR1, outR2, outI1, outI2;
00224
00225
00226 pCoefA = &pATable[modifier * 2u];
00227 pCoefB = &pBTable[modifier * 2u];
00228
00229 blkCnt = fftLen - 1u;
00230
00231
00232 i = blkCnt >> 1u;
00233
00234 while(i > 0u)
00235 {
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255 inR1 = *pSrc1;
00256 inI1 = pSrc1[1];
00257
00258
00259 CoefA1 = pCoefA[0];
00260
00261 CoefA2 = pCoefA[1];
00262
00263
00264 CoefB1 = *pCoefB;
00265
00266
00267 pCoefA = pCoefA + (modifier * 2u);
00268 pCoefB = pCoefB + (modifier * 2u);
00269
00270 pSrc2 -= 4u;
00271
00272
00273 CoefA3 = pCoefA[0];
00274
00275 CoefA4 = pCoefA[1];
00276
00277 CoefB2 = *pCoefB;
00278
00279
00280 pCoefA = pCoefA + (modifier * 2u);
00281 pCoefB = pCoefB + (modifier * 2u);
00282
00283
00284 outR1 = inR1 * CoefA1;
00285
00286 inR2 = pSrc2[4];
00287 inI2 = pSrc2[3];
00288
00289
00290 outI1 = inR1 * CoefA2;
00291
00292
00293 outR1 -= (inI1 + inR2) * CoefA2;
00294
00295
00296 outI1 += inI1 * CoefA1;
00297
00298
00299 outI1 -= inR2 * CoefB1;
00300
00301
00302 outI1 -= inI2 * CoefA2;
00303
00304
00305 outR1 += inI2 * CoefB1;
00306
00307 pDst2 -= 4u;
00308
00309 inR1 = pSrc1[2];
00310 inI1 = pSrc1[3];
00311
00312 pSrc1 += 4u;
00313
00314
00315 outR2 = inR1 * CoefA3;
00316
00317 inR4 = pSrc2[2];
00318
00319
00320 outI2 = inR1 * CoefA4;
00321
00322
00323 outR2 -= (inI1 + inR4) * CoefA4;
00324
00325
00326 outI2 += inI1 * CoefA3;
00327
00328 inI4 = pSrc2[1];
00329
00330
00331 outI2 -= inR4 * CoefB2;
00332
00333
00334 outI2 -= inI4 * CoefA4;
00335
00336
00337 outR2 += inI4 * CoefB2;
00338
00339
00340 pDst1[0] = outR1;
00341 pDst1[1] = outI1;
00342 pDst1[2] = outR2;
00343 pDst1[3] = outI2;
00344
00345
00346 pDst2[1] = outR2;
00347 pDst2[2] = -outI2;
00348 pDst2[3] = outR1;
00349 pDst2[4] = -outI1;
00350
00351
00352 pDst1 += 4u;
00353
00354
00355 i--;
00356
00357 }
00358
00359 i = blkCnt & 1u;
00360
00361 while(i > 0u)
00362 {
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373 inR1 = *pSrc1;
00374
00375
00376 CoefA1 = *pCoefA++;
00377
00378 CoefA2 = *pCoefA;
00379
00380 pSrc2 -= 2u;
00381
00382
00383 outR1 = inR1 * CoefA1;
00384
00385 inI1 = pSrc1[1];
00386
00387 inR2 = pSrc2[2];
00388
00389
00390 outI1 = inR1 * CoefA2;
00391
00392 pSrc1 += 2u;
00393
00394
00395 outR1 -= (inI1 + inR2) * CoefA2;
00396
00397
00398 outI1 += inI1 * CoefA1;
00399
00400 CoefB1 = *pCoefB;
00401
00402 inI2 = pSrc2[1];
00403
00404
00405 outI1 -= inR2 * CoefB1;
00406
00407
00408 outI1 -= inI2 * CoefA2;
00409
00410
00411 outR1 += inI2 * CoefB1;
00412
00413 pDst2 -= 2u;
00414
00415
00416 pDst1[0] = outR1;
00417 pDst1[1] = outI1;
00418
00419
00420 pDst2[2] = -outI1;
00421 pDst2[1] = outR1;
00422
00423 pDst1 += 2u;
00424
00425
00426 pCoefB = pCoefB + (modifier * 2u);
00427 pCoefA = pCoefA + ((modifier * 2u) - 1u);
00428
00429
00430 i--;
00431
00432 }
00433
00434 pDst[2u * fftLen] = pSrc[0] - pSrc[1];
00435 pDst[(2u * fftLen) + 1u] = 0.0f;
00436
00437 pDst[0] = pSrc[0] + pSrc[1];
00438 pDst[1] = 0.0f;
00439
00440 }
00441
00442
00454 void arm_split_rifft_f32(
00455 float32_t * pSrc,
00456 uint32_t fftLen,
00457 float32_t * pATable,
00458 float32_t * pBTable,
00459 float32_t * pDst,
00460 uint32_t modifier)
00461 {
00462 uint32_t i, blkCnt;
00463 float32_t inVal1, inVal2, inVal3;
00464 float32_t outR, outI;
00465 float32_t *pCoefA, *pCoefB;
00466 float32_t *pSrc1 = &pSrc[0], *pSrc2 = &pSrc[(2u * fftLen) + 1u];
00467 float32_t CoefA1, CoefA2, CoefB1;
00468
00469 pCoefA = &pATable[0];
00470 pCoefB = &pBTable[0];
00471
00472 blkCnt = fftLen - 1u;
00473
00474
00475 i = blkCnt >> 1u;
00476
00477 while(i > 0u)
00478 {
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500 inVal1 = pSrc1[0];
00501
00502 CoefA1 = pCoefA[0];
00503 CoefA2 = pCoefA[1];
00504
00505 CoefB1 = *pCoefB;
00506
00507
00508 pCoefB = pCoefB + (modifier * 2u);
00509 pCoefA = pCoefA + (modifier * 2u);
00510
00511 pSrc2 -= 2u;
00512
00513 outR = inVal1 * CoefA1;
00514
00515 inVal2 = pSrc1[1];
00516
00517 inVal3 = pSrc2[2];
00518
00519
00520 outI = -(inVal1) * CoefA2;
00521
00522
00523 outR += (inVal2 + inVal3) * CoefA2;
00524
00525 pSrc1 += 2u;
00526
00527
00528 outI += (inVal2) * CoefA1;
00529
00530 inVal1 = pSrc2[1];
00531
00532
00533 outI -= inVal3 * CoefB1;
00534
00535
00536 outR += inVal1 * CoefB1;
00537
00538
00539 outI += inVal1 * CoefA2;
00540
00541
00542 pDst[0] = outR;
00543 pDst[1] = outI;
00544
00545 inVal1 = pSrc1[0];
00546
00547 CoefA1 = pCoefA[0];
00548 CoefA2 = pCoefA[1];
00549
00550 CoefB1 = *pCoefB;
00551
00552
00553 pCoefB = pCoefB + (modifier * 2u);
00554 pCoefA = pCoefA + (modifier * 2u);
00555
00556 pSrc2 -= 2u;
00557
00558 outR = inVal1 * CoefA1;
00559
00560 inVal2 = pSrc1[1];
00561
00562 inVal3 = pSrc2[2];
00563
00564
00565 outI = -(inVal1) * CoefA2;
00566
00567
00568 outR += (inVal2 + inVal3) * CoefA2;
00569
00570 pSrc1 += 2u;
00571
00572
00573 outI += (inVal2) * CoefA1;
00574
00575 inVal1 = pSrc2[1];
00576
00577
00578 outI -= inVal3 * CoefB1;
00579
00580
00581 outR += inVal1 * CoefB1;
00582
00583
00584 outI += inVal1 * CoefA2;
00585
00586
00587 pDst[2] = outR;
00588 pDst[3] = outI;
00589
00590 pDst += 4u;
00591
00592
00593 i--;
00594
00595 }
00596
00597 i = blkCnt & 1u;
00598
00599 while(i > 0u)
00600 {
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612 inVal1 = pSrc1[0];
00613
00614 CoefA1 = *pCoefA++;
00615 CoefA2 = *pCoefA;
00616
00617 pSrc2 -= 2u;
00618
00619 outR = inVal1 * CoefA1;
00620
00621 inVal2 = pSrc1[1];
00622
00623 inVal3 = pSrc2[2];
00624
00625
00626 outI = -(inVal1) * CoefA2;
00627
00628
00629 outR += (inVal2 + inVal3) * CoefA2;
00630
00631 pSrc1 += 2u;
00632
00633
00634 outI += (inVal2) * CoefA1;
00635
00636
00637 CoefB1 = *pCoefB;
00638
00639 inVal1 = pSrc2[1];
00640
00641
00642 outI -= inVal3 * CoefB1;
00643
00644
00645 outR += inVal1 * CoefB1;
00646
00647
00648 outI += inVal1 * CoefA2;
00649
00650
00651 pDst[0] = outR;
00652 pDst[1] = outI;
00653
00654 pDst += 2u;
00655
00656
00657 pCoefB = pCoefB + (modifier * 2u);
00658 pCoefA = pCoefA + ((modifier * 2u) - 1u);
00659
00660
00661 i--;
00662 }
00663
00664 }
00665