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