TransformQ15.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #include "TransformQ15.h"
  2. #include "Error.h"
  3. void TransformQ15::test_cfft_q15()
  4. {
  5. arm_cfft_q15(&this->cfftInstance, this->pDst, this->ifft,this->bitRev);
  6. }
  7. void TransformQ15::test_rfft_q15()
  8. {
  9. arm_rfft_q15(&this->rfftInstance, this->pSrc, this->pDst);
  10. }
  11. void TransformQ15::test_dct4_q15()
  12. {
  13. arm_dct4_q15(
  14. &this->dct4Instance,
  15. this->pState,
  16. this->pDst);
  17. }
  18. void TransformQ15::test_cfft_radix4_q15()
  19. {
  20. arm_cfft_radix4_q15(&this->cfftRadix4Instance,this->pDst);
  21. }
  22. void TransformQ15::test_cfft_radix2_q15()
  23. {
  24. arm_cfft_radix2_q15(&this->cfftRadix2Instance,this->pDst);
  25. }
  26. void TransformQ15::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_Q15_1:
  36. samples.reload(TransformQ15::INPUTC_Q15_ID,mgr,2*this->nbSamples);
  37. output.create(2*this->nbSamples,TransformQ15::OUT_Q15_ID,mgr);
  38. this->pSrc=samples.ptr();
  39. this->pDst=output.ptr();
  40. arm_cfft_init_q15(&this->cfftInstance,this->nbSamples);
  41. memcpy(this->pDst,this->pSrc,2*sizeof(q15_t)*this->nbSamples);
  42. break;
  43. case TEST_RFFT_Q15_2:
  44. samples.reload(TransformQ15::INPUTR_Q15_ID,mgr,this->nbSamples);
  45. output.create(this->nbSamples,TransformQ15::OUT_Q15_ID,mgr);
  46. this->pSrc=samples.ptr();
  47. this->pDst=output.ptr();
  48. arm_rfft_init_q15(&this->rfftInstance, this->nbSamples, this->ifft, this->bitRev);
  49. break;
  50. case TEST_DCT4_Q15_3:
  51. samples.reload(TransformQ15::INPUTR_Q15_ID,mgr,this->nbSamples);
  52. output.create(this->nbSamples,TransformQ15::OUT_Q15_ID,mgr);
  53. state.create(2*this->nbSamples,TransformQ15::STATE_Q15_ID,mgr);
  54. this->pSrc=samples.ptr();
  55. this->pDst=output.ptr();
  56. this->pState=state.ptr();
  57. normalize = sqrt((2.0f/(float32_t)this->nbSamples));
  58. memcpy(this->pDst,this->pSrc,sizeof(q15_t)*this->nbSamples);
  59. arm_dct4_init_q15(
  60. &this->dct4Instance,
  61. &this->rfftInstance,
  62. &this->cfftRadix4Instance,
  63. this->nbSamples,
  64. this->nbSamples/2,
  65. normalize);
  66. break;
  67. case TEST_CFFT_RADIX4_Q15_4:
  68. samples.reload(TransformQ15::INPUTC_Q15_ID,mgr,2*this->nbSamples);
  69. output.create(2*this->nbSamples,TransformQ15::OUT_Q15_ID,mgr);
  70. this->pSrc=samples.ptr();
  71. this->pDst=output.ptr();
  72. memcpy(this->pDst,this->pSrc,2*sizeof(q15_t)*this->nbSamples);
  73. arm_cfft_radix4_init_q15(&this->cfftRadix4Instance,
  74. this->nbSamples,
  75. this->ifft,
  76. this->bitRev);
  77. break;
  78. case TEST_CFFT_RADIX2_Q15_5:
  79. samples.reload(TransformQ15::INPUTC_Q15_ID,mgr,2*this->nbSamples);
  80. output.create(2*this->nbSamples,TransformQ15::OUT_Q15_ID,mgr);
  81. this->pSrc=samples.ptr();
  82. this->pDst=output.ptr();
  83. memcpy(this->pDst,this->pSrc,2*sizeof(q15_t)*this->nbSamples);
  84. arm_cfft_radix2_init_q15(&this->cfftRadix2Instance,
  85. this->nbSamples,
  86. this->ifft,
  87. this->bitRev);
  88. break;
  89. }
  90. }
  91. void TransformQ15::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
  92. {
  93. }