InterpolationTestsQ15.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #include "InterpolationTestsQ15.h"
  2. #include <stdio.h>
  3. #include "Error.h"
  4. #define SNR_THRESHOLD 70
  5. /*
  6. Reference patterns are generated with
  7. a double precision computation.
  8. */
  9. #define ABS_ERROR_Q15 ((q15_t)2)
  10. void InterpolationTestsQ15::test_linear_interp_q15()
  11. {
  12. const q31_t *inp = input.ptr();
  13. q15_t *outp = output.ptr();
  14. unsigned long nb;
  15. for(nb = 0; nb < input.nbSamples(); nb++)
  16. {
  17. outp[nb] = arm_linear_interp_q15(y.ptr(),inp[nb],y.nbSamples());
  18. }
  19. ASSERT_EMPTY_TAIL(output);
  20. ASSERT_SNR(output,ref,(float32_t)SNR_THRESHOLD);
  21. ASSERT_NEAR_EQ(output,ref,ABS_ERROR_Q15);
  22. }
  23. void InterpolationTestsQ15::test_bilinear_interp_q15()
  24. {
  25. const q31_t *inp = input.ptr();
  26. q15_t *outp = output.ptr();
  27. q31_t x,y;
  28. unsigned long nb;
  29. for(nb = 0; nb < input.nbSamples(); nb += 2)
  30. {
  31. x = inp[nb];
  32. y = inp[nb+1];
  33. *outp++=arm_bilinear_interp_q15(&SBI,x,y);
  34. }
  35. ASSERT_EMPTY_TAIL(output);
  36. ASSERT_SNR(output,ref,(float32_t)SNR_THRESHOLD);
  37. ASSERT_NEAR_EQ(output,ref,ABS_ERROR_Q15);
  38. }
  39. void InterpolationTestsQ15::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr)
  40. {
  41. Testing::nbSamples_t nb=MAX_NB_SAMPLES;
  42. const int16_t *pConfig;
  43. (void)params;
  44. switch(id)
  45. {
  46. case InterpolationTestsQ15::TEST_LINEAR_INTERP_Q15_1:
  47. input.reload(InterpolationTestsQ15::INPUT_Q31_ID,mgr,nb);
  48. y.reload(InterpolationTestsQ15::YVAL_Q15_ID,mgr,nb);
  49. ref.reload(InterpolationTestsQ15::REF_LINEAR_Q15_ID,mgr,nb);
  50. break;
  51. case InterpolationTestsQ15::TEST_BILINEAR_INTERP_Q15_2:
  52. input.reload(InterpolationTestsQ15::INPUTBI_Q31_ID,mgr,nb);
  53. config.reload(InterpolationTestsQ15::CONFIGBI_S16_ID,mgr,nb);
  54. y.reload(InterpolationTestsQ15::YVALBI_Q15_ID,mgr,nb);
  55. ref.reload(InterpolationTestsQ15::REF_BILINEAR_Q15_ID,mgr,nb);
  56. pConfig = config.ptr();
  57. SBI.numRows = pConfig[1];
  58. SBI.numCols = pConfig[0];
  59. SBI.pData = y.ptr();
  60. break;
  61. }
  62. output.create(ref.nbSamples(),InterpolationTestsQ15::OUT_SAMPLES_Q15_ID,mgr);
  63. }
  64. void InterpolationTestsQ15::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
  65. {
  66. (void)id;
  67. output.dump(mgr);
  68. }