TransformF32.cpp 4.4 KB

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