TransformF32.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #include "TransformF32.h"
  2. #include "Error.h"
  3. void TransformF32::test_cfft_f32()
  4. {
  5. arm_cfft_f32(&(this->cfftInstance), this->pDst, this->ifft,this->bitRev);
  6. }
  7. void TransformF32::test_rfft_f32()
  8. {
  9. arm_rfft_fast_f32(&this->rfftFastInstance, this->pTmp, this->pDst, this->ifft);
  10. }
  11. void TransformF32::test_dct4_f32()
  12. {
  13. arm_dct4_f32(
  14. &this->dct4Instance,
  15. this->pState,
  16. this->pDst);
  17. }
  18. void TransformF32::test_cfft_radix4_f32()
  19. {
  20. arm_cfft_radix4_f32(&this->cfftRadix4Instance,this->pDst);
  21. }
  22. void TransformF32::test_cfft_radix2_f32()
  23. {
  24. arm_cfft_radix2_f32(&this->cfftRadix2Instance,this->pDst);
  25. }
  26. void TransformF32::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr)
  27. {
  28. float32_t normalize;
  29. std::vector<Testing::param_t>::iterator it = params.begin();
  30. this->nbSamples = *it++;
  31. this->ifft = *it++;
  32. this->bitRev = *it;
  33. switch(id)
  34. {
  35. case TEST_CFFT_F32_1:
  36. samples.reload(TransformF32::INPUTC_F32_ID,mgr,2*this->nbSamples);
  37. output.create(2*this->nbSamples,TransformF32::OUT_F32_ID,mgr);
  38. this->pSrc=samples.ptr();
  39. this->pDst=output.ptr();
  40. status=arm_cfft_init_f32(&cfftInstance,this->nbSamples);
  41. memcpy(this->pDst,this->pSrc,2*sizeof(float32_t)*this->nbSamples);
  42. break;
  43. case TEST_RFFT_F32_2:
  44. // Factor 2 for rifft
  45. samples.reload(TransformF32::INPUTR_F32_ID,mgr,2*this->nbSamples);
  46. output.create(this->nbSamples,TransformF32::OUT_F32_ID,mgr);
  47. tmp.create(this->nbSamples,TransformF32::TMP_F32_ID,mgr);
  48. this->pSrc=samples.ptr();
  49. this->pDst=output.ptr();
  50. this->pTmp=tmp.ptr();
  51. memcpy(this->pTmp,this->pSrc,sizeof(float32_t)*this->nbSamples);
  52. arm_rfft_fast_init_f32(&this->rfftFastInstance, this->nbSamples);
  53. break;
  54. case TEST_DCT4_F32_3:
  55. samples.reload(TransformF32::INPUTR_F32_ID,mgr,this->nbSamples);
  56. output.create(this->nbSamples,TransformF32::OUT_F32_ID,mgr);
  57. state.create(2*this->nbSamples,TransformF32::STATE_F32_ID,mgr);
  58. this->pSrc=samples.ptr();
  59. this->pDst=output.ptr();
  60. this->pState=state.ptr();
  61. normalize = sqrt((2.0f/(float32_t)this->nbSamples));
  62. memcpy(this->pDst,this->pSrc,sizeof(float32_t)*this->nbSamples);
  63. arm_dct4_init_f32(
  64. &this->dct4Instance,
  65. &this->rfftInstance,
  66. &this->cfftRadix4Instance,
  67. this->nbSamples,
  68. this->nbSamples/2,
  69. normalize);
  70. break;
  71. case TEST_CFFT_RADIX4_F32_4:
  72. samples.reload(TransformF32::INPUTC_F32_ID,mgr,2*this->nbSamples);
  73. output.create(2*this->nbSamples,TransformF32::OUT_F32_ID,mgr);
  74. this->pSrc=samples.ptr();
  75. this->pDst=output.ptr();
  76. memcpy(this->pDst,this->pSrc,2*sizeof(float32_t)*this->nbSamples);
  77. arm_cfft_radix4_init_f32(&this->cfftRadix4Instance,
  78. this->nbSamples,
  79. this->ifft,
  80. this->bitRev);
  81. break;
  82. case TEST_CFFT_RADIX2_F32_5:
  83. samples.reload(TransformF32::INPUTC_F32_ID,mgr,2*this->nbSamples);
  84. output.create(2*this->nbSamples,TransformF32::OUT_F32_ID,mgr);
  85. this->pSrc=samples.ptr();
  86. this->pDst=output.ptr();
  87. memcpy(this->pDst,this->pSrc,2*sizeof(float32_t)*this->nbSamples);
  88. arm_cfft_radix2_init_f32(&this->cfftRadix2Instance,
  89. this->nbSamples,
  90. this->ifft,
  91. this->bitRev);
  92. break;
  93. }
  94. }
  95. void TransformF32::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
  96. {
  97. }