TransformF32.cpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. #include "TransformF32.h"
  2. #include "Error.h"
  3. #include "arm_math.h"
  4. #include "arm_const_structs.h"
  5. const arm_cfft_instance_f32 *arm_cfft_get_instance_f32(uint16_t fftLen)
  6. {
  7. switch (fftLen) {
  8. case 16:
  9. return(&arm_cfft_sR_f32_len16);
  10. case 32:
  11. return(&arm_cfft_sR_f32_len32);
  12. case 64:
  13. return(&arm_cfft_sR_f32_len64);
  14. case 128:
  15. return(&arm_cfft_sR_f32_len128);
  16. case 256:
  17. return(&arm_cfft_sR_f32_len256);
  18. case 512:
  19. return(&arm_cfft_sR_f32_len512);
  20. case 1024:
  21. return(&arm_cfft_sR_f32_len1024);
  22. case 2048:
  23. return(&arm_cfft_sR_f32_len2048);
  24. case 4096:
  25. return(&arm_cfft_sR_f32_len4096);
  26. }
  27. return(NULL);
  28. }
  29. void TransformF32::test_cfft_f32()
  30. {
  31. arm_cfft_f32(this->cfftInstance, this->pDst, this->ifft,this->bitRev);
  32. }
  33. void TransformF32::test_rfft_f32()
  34. {
  35. arm_rfft_fast_f32(&this->rfftFastInstance, this->pSrc, this->pDst, this->ifft);
  36. }
  37. void TransformF32::test_dct4_f32()
  38. {
  39. arm_dct4_f32(
  40. &this->dct4Instance,
  41. this->pState,
  42. this->pDst);
  43. }
  44. void TransformF32::test_cfft_radix4_f32()
  45. {
  46. arm_cfft_radix4_f32(&this->cfftRadix4Instance,this->pDst);
  47. }
  48. void TransformF32::test_cfft_radix2_f32()
  49. {
  50. arm_cfft_radix2_f32(&this->cfftRadix2Instance,this->pDst);
  51. }
  52. void TransformF32::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr)
  53. {
  54. float32_t normalize;
  55. std::vector<Testing::param_t>::iterator it = params.begin();
  56. this->nbSamples = *it++;
  57. this->ifft = *it++;
  58. this->bitRev = *it;
  59. switch(id)
  60. {
  61. case TEST_CFFT_F32_1:
  62. samples.reload(TransformF32::INPUTC_F32_ID,mgr,2*this->nbSamples);
  63. output.create(2*this->nbSamples,TransformF32::OUT_F32_ID,mgr);
  64. this->pSrc=samples.ptr();
  65. this->pDst=output.ptr();
  66. this->cfftInstance=arm_cfft_get_instance_f32(this->nbSamples);
  67. memcpy(this->pDst,this->pSrc,2*sizeof(float32_t)*this->nbSamples);
  68. break;
  69. case TEST_RFFT_F32_2:
  70. samples.reload(TransformF32::INPUTR_F32_ID,mgr,this->nbSamples);
  71. output.create(this->nbSamples,TransformF32::OUT_F32_ID,mgr);
  72. this->pSrc=samples.ptr();
  73. this->pDst=output.ptr();
  74. arm_rfft_fast_init_f32(&this->rfftFastInstance, this->nbSamples);
  75. break;
  76. case TEST_DCT4_F32_3:
  77. samples.reload(TransformF32::INPUTR_F32_ID,mgr,this->nbSamples);
  78. output.create(this->nbSamples,TransformF32::OUT_F32_ID,mgr);
  79. state.create(2*this->nbSamples,TransformF32::STATE_F32_ID,mgr);
  80. this->pSrc=samples.ptr();
  81. this->pDst=output.ptr();
  82. this->pState=state.ptr();
  83. normalize = sqrt((2.0f/(float32_t)this->nbSamples));
  84. memcpy(this->pDst,this->pSrc,sizeof(float32_t)*this->nbSamples);
  85. arm_dct4_init_f32(
  86. &this->dct4Instance,
  87. &this->rfftInstance,
  88. &this->cfftRadix4Instance,
  89. this->nbSamples,
  90. this->nbSamples/2,
  91. normalize);
  92. break;
  93. case TEST_CFFT_RADIX4_F32_4:
  94. samples.reload(TransformF32::INPUTC_F32_ID,mgr,2*this->nbSamples);
  95. output.create(2*this->nbSamples,TransformF32::OUT_F32_ID,mgr);
  96. this->pSrc=samples.ptr();
  97. this->pDst=output.ptr();
  98. memcpy(this->pDst,this->pSrc,2*sizeof(float32_t)*this->nbSamples);
  99. arm_cfft_radix4_init_f32(&this->cfftRadix4Instance,
  100. this->nbSamples,
  101. this->ifft,
  102. this->bitRev);
  103. break;
  104. case TEST_CFFT_RADIX2_F32_5:
  105. samples.reload(TransformF32::INPUTC_F32_ID,mgr,2*this->nbSamples);
  106. output.create(2*this->nbSamples,TransformF32::OUT_F32_ID,mgr);
  107. this->pSrc=samples.ptr();
  108. this->pDst=output.ptr();
  109. memcpy(this->pDst,this->pSrc,2*sizeof(float32_t)*this->nbSamples);
  110. arm_cfft_radix2_init_f32(&this->cfftRadix2Instance,
  111. this->nbSamples,
  112. this->ifft,
  113. this->bitRev);
  114. break;
  115. }
  116. }
  117. void TransformF32::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
  118. {
  119. }