TransformF32.cpp 4.5 KB

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