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