1 #include "InterpolationTestsQ31.h" 2 #include <stdio.h> 3 #include "Error.h" 4 5 #define SNR_THRESHOLD 100 6 7 /* 8 9 Reference patterns are generated with 10 a double precision computation. 11 12 */ 13 #define ABS_ERROR_Q31 ((q31_t)2000) 14 15 16 test_linear_interp_q31()17 void InterpolationTestsQ31::test_linear_interp_q31() 18 { 19 const q31_t *inp = input.ptr(); 20 q31_t *outp = output.ptr(); 21 22 unsigned long nb; 23 for(nb = 0; nb < input.nbSamples(); nb++) 24 { 25 outp[nb] = arm_linear_interp_q31(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_Q31); 33 34 } 35 36 test_bilinear_interp_q31()37 void InterpolationTestsQ31::test_bilinear_interp_q31() 38 { 39 const q31_t *inp = input.ptr(); 40 q31_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_q31(&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_Q31); 55 56 } 57 58 setUp(Testing::testID_t id,std::vector<Testing::param_t> & params,Client::PatternMgr * mgr)59 void InterpolationTestsQ31::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 InterpolationTestsQ31::TEST_LINEAR_INTERP_Q31_1: 69 input.reload(InterpolationTestsQ31::INPUT_Q31_ID,mgr,nb); 70 y.reload(InterpolationTestsQ31::YVAL_Q31_ID,mgr,nb); 71 ref.reload(InterpolationTestsQ31::REF_LINEAR_Q31_ID,mgr,nb); 72 73 break; 74 75 case InterpolationTestsQ31::TEST_BILINEAR_INTERP_Q31_2: 76 input.reload(InterpolationTestsQ31::INPUTBI_Q31_ID,mgr,nb); 77 config.reload(InterpolationTestsQ31::CONFIGBI_S16_ID,mgr,nb); 78 y.reload(InterpolationTestsQ31::YVALBI_Q31_ID,mgr,nb); 79 ref.reload(InterpolationTestsQ31::REF_BILINEAR_Q31_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(),InterpolationTestsQ31::OUT_SAMPLES_Q31_ID,mgr); 95 } 96 tearDown(Testing::testID_t id,Client::PatternMgr * mgr)97 void InterpolationTestsQ31::tearDown(Testing::testID_t id,Client::PatternMgr *mgr) 98 { 99 (void)id; 100 output.dump(mgr); 101 } 102