#include "ref.h" void ref_absmax_f32( const float32_t * pSrc, uint32_t blockSize, float32_t * pResult, uint32_t * pIndex) { float32_t maxVal, out; /* Temporary variables to store the output value. */ uint32_t blkCnt, outIndex; /* Loop counter */ /* Initialise index value to zero. */ outIndex = 0U; /* Load first input value that act as reference value for comparision */ out = fabsf(*pSrc++); /* Initialize blkCnt with number of samples */ blkCnt = (blockSize - 1U); while (blkCnt > 0U) { /* Initialize maxVal to the next consecutive values one by one */ maxVal = fabsf(*pSrc++); /* compare for the maximum value */ if (out < maxVal) { /* Update the maximum value and it's index */ out = maxVal; outIndex = blockSize - blkCnt; } /* Decrement loop counter */ blkCnt--; } /* Store the maximum value and it's index into destination pointers */ *pResult = out; *pIndex = outIndex; } void ref_absmax_q7( const q7_t * pSrc, uint32_t blockSize, q7_t * pResult, uint32_t * pIndex) { q7_t maxVal, out; /* Temporary variables to store the output value. */ uint32_t blkCnt, outIndex; /* Loop counter */ /* Initialise index value to zero. */ outIndex = 0U; /* Load first input value that act as reference value for comparision */ out = (*pSrc > 0) ? *pSrc : ((*pSrc == (q7_t) 0x80) ? (q7_t) 0x7f : -*pSrc); pSrc++; /* Initialize blkCnt with number of samples */ blkCnt = (blockSize - 1U); while (blkCnt > 0U) { /* Initialize maxVal to the next consecutive values one by one */ maxVal = (*pSrc > 0) ? *pSrc : ((*pSrc == (q7_t) 0x80) ? (q7_t) 0x7f : -*pSrc); pSrc++; /* compare for the maximum value */ if (out < maxVal) { /* Update the maximum value and it's index */ out = maxVal; outIndex = blockSize - blkCnt; } /* Decrement loop counter */ blkCnt--; } /* Store the maximum value and it's index into destination pointers */ *pResult = out; *pIndex = outIndex; } void ref_absmax_q15( const q15_t * pSrc, uint32_t blockSize, q15_t * pResult, uint32_t * pIndex) { q15_t maxVal, out; /* Temporary variables to store the output value. */ uint32_t blkCnt, outIndex; /* Loop counter */ /* Initialise index value to zero. */ outIndex = 0U; /* Load first input value that act as reference value for comparision */ out = (*pSrc > 0) ? *pSrc : ((*pSrc == (q15_t) 0x8000) ? 0x7fff : -*pSrc); pSrc++; /* Initialize blkCnt with number of samples */ blkCnt = (blockSize - 1U); while (blkCnt > 0U) { /* Initialize maxVal to the next consecutive values one by one */ maxVal = (*pSrc > 0) ? *pSrc : ((*pSrc == (q15_t) 0x8000) ? 0x7fff : -*pSrc); pSrc++; /* compare for the maximum value */ if (out < maxVal) { /* Update the maximum value and it's index */ out = maxVal; outIndex = blockSize - blkCnt; } /* Decrement loop counter */ blkCnt--; } /* Store the maximum value and it's index into destination pointers */ *pResult = out; *pIndex = outIndex; } void ref_absmax_q31( const q31_t * pSrc, uint32_t blockSize, q31_t * pResult, uint32_t * pIndex) { q31_t maxVal, out; /* Temporary variables to store the output value. */ uint32_t blkCnt, outIndex; /* Loop counter */ /* Initialise index value to zero. */ outIndex = 0U; /* Load first input value that act as reference value for comparision */ out = (*pSrc > 0) ? *pSrc : ((*pSrc == INT32_MIN) ? INT32_MAX : -*pSrc); pSrc++; /* Initialize blkCnt with number of samples */ blkCnt = (blockSize - 1U); while (blkCnt > 0U) { /* Initialize maxVal to the next consecutive values one by one */ maxVal = (*pSrc > 0) ? *pSrc : ((*pSrc == INT32_MIN) ? INT32_MAX : -*pSrc); pSrc++; /* compare for the maximum value */ if (out < maxVal) { /* Update the maximum value and it's index */ out = maxVal; outIndex = blockSize - blkCnt; } /* Decrement loop counter */ blkCnt--; } /* Store the maximum value and it's index into destination pointers */ *pResult = out; *pIndex = outIndex; }