| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- #include "DECIMF32.h"
- #include <stdio.h>
- #include "Error.h"
- #define SNR_THRESHOLD 120
- /*
- Reference patterns are generated with
- a double precision computation.
- */
- #define REL_ERROR (8.0e-4)
- void DECIMF32::test_fir_decimate_f32()
- {
- int nbTests;
- int nb;
- uint32_t *pConfig = config.ptr();
- const float32_t * pSrc = input.ptr();
- float32_t * pDst = output.ptr();
- float32_t * pCoefs = coefs.ptr();
- nbTests=config.nbSamples() / 4;
- for(nb=0;nb < nbTests; nb++)
- {
- this->q = pConfig[0];
- this->numTaps = pConfig[1];
- this->blocksize = pConfig[2];
- this->refsize = pConfig[3];
- pConfig += 4;
- this->status=arm_fir_decimate_init_f32(&(this->S),
- this->numTaps,
- this->q,
- pCoefs,
- state.ptr(),
- this->blocksize);
- ASSERT_TRUE(this->status == ARM_MATH_SUCCESS);
- arm_fir_decimate_f32(
- &(this->S),
- pSrc,
- pDst,
- this->blocksize);
- pSrc += this->blocksize;
- pDst += this->refsize;
- pCoefs += this->numTaps;
- }
- ASSERT_EMPTY_TAIL(output);
- ASSERT_SNR(output,ref,(float32_t)SNR_THRESHOLD);
- ASSERT_REL_ERROR(output,ref,REL_ERROR);
- }
- void DECIMF32::test_fir_interpolate_f32()
- {
- int nbTests;
- int nb;
- uint32_t *pConfig = config.ptr();
- const float32_t * pSrc = input.ptr();
- float32_t * pDst = output.ptr();
- float32_t * pCoefs = coefs.ptr();
- nbTests=config.nbSamples() / 4;
- for(nb=0;nb < nbTests; nb++)
- {
- this->q = pConfig[0];
- this->numTaps = pConfig[1];
- this->blocksize = pConfig[2];
- this->refsize = pConfig[3];
- pConfig += 4;
- this->status=arm_fir_interpolate_init_f32(&(this->SI),
- this->q,
- this->numTaps,
- pCoefs,
- state.ptr(),
- this->blocksize);
- ASSERT_TRUE(this->status == ARM_MATH_SUCCESS);
- arm_fir_interpolate_f32(
- &(this->SI),
- pSrc,
- pDst,
- this->blocksize);
- pSrc += this->blocksize;
- pDst += this->refsize;
- pCoefs += this->numTaps;
- }
- ASSERT_EMPTY_TAIL(output);
- ASSERT_SNR(output,ref,(float32_t)SNR_THRESHOLD);
- ASSERT_REL_ERROR(output,ref,REL_ERROR);
- }
-
- void DECIMF32::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr)
- {
-
- (void)params;
-
- switch(id)
- {
- case DECIMF32::TEST_FIR_DECIMATE_F32_1:
- config.reload(DECIMF32::CONFIGSDECIMF32_ID,mgr);
-
- input.reload(DECIMF32::INPUT1_F32_ID,mgr);
- coefs.reload(DECIMF32::COEFS1_F32_ID,mgr);
- ref.reload(DECIMF32::REF1_DECIM_F32_ID,mgr);
- state.create(16 + 768 - 1,DECIMF32::STATE_F32_ID,mgr);
- break;
- case DECIMF32::TEST_FIR_INTERPOLATE_F32_2:
- config.reload(DECIMF32::CONFIGSINTERPF32_ID,mgr);
-
- input.reload(DECIMF32::INPUT2_F32_ID,mgr);
- coefs.reload(DECIMF32::COEFS2_F32_ID,mgr);
- ref.reload(DECIMF32::REF2_INTERP_F32_ID,mgr);
- state.create(16 + 768 - 1,DECIMF32::STATE_F32_ID,mgr);
- break;
- }
-
-
- output.create(ref.nbSamples(),DECIMF32::OUT_F32_ID,mgr);
- }
- void DECIMF32::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
- {
- (void)id;
- output.dump(mgr);
- }
|