123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- #include "arm_math.h"
- void arm_shift_q7(
- q7_t * pSrc,
- int8_t shiftBits,
- q7_t * pDst,
- uint32_t blockSize)
- {
- uint32_t blkCnt;
- uint8_t sign;
- #if defined (ARM_MATH_DSP)
- q7_t in1;
- q7_t in2;
- q7_t in3;
- q7_t in4;
-
- blkCnt = blockSize >> 2U;
-
- sign = (shiftBits & 0x80);
-
- if (sign == 0U)
- {
-
- while (blkCnt > 0U)
- {
-
-
- in1 = *pSrc;
- in2 = *(pSrc + 1);
- in3 = *(pSrc + 2);
- in4 = *(pSrc + 3);
-
- *__SIMD32(pDst)++ = __PACKq7(__SSAT((in1 << shiftBits), 8),
- __SSAT((in2 << shiftBits), 8),
- __SSAT((in3 << shiftBits), 8),
- __SSAT((in4 << shiftBits), 8));
-
- pSrc += 4U;
-
- blkCnt--;
- }
-
- blkCnt = blockSize % 0x4U;
- while (blkCnt > 0U)
- {
-
-
- *pDst++ = (q7_t) __SSAT((*pSrc++ << shiftBits), 8);
-
- blkCnt--;
- }
- }
- else
- {
- shiftBits = -shiftBits;
-
- while (blkCnt > 0U)
- {
-
-
- in1 = *pSrc;
- in2 = *(pSrc + 1);
- in3 = *(pSrc + 2);
- in4 = *(pSrc + 3);
-
- *__SIMD32(pDst)++ = __PACKq7((in1 >> shiftBits), (in2 >> shiftBits),
- (in3 >> shiftBits), (in4 >> shiftBits));
- pSrc += 4U;
-
- blkCnt--;
- }
-
- blkCnt = blockSize % 0x4U;
- while (blkCnt > 0U)
- {
-
-
- in1 = *pSrc++;
- *pDst++ = (in1 >> shiftBits);
-
- blkCnt--;
- }
- }
- #else
-
-
- sign = (shiftBits & 0x80);
-
- if (sign == 0U)
- {
-
- blkCnt = blockSize;
- while (blkCnt > 0U)
- {
-
-
- *pDst++ = (q7_t) __SSAT(((q15_t) * pSrc++ << shiftBits), 8);
-
- blkCnt--;
- }
- }
- else
- {
-
- blkCnt = blockSize;
- while (blkCnt > 0U)
- {
-
-
- *pDst++ = (*pSrc++ >> -shiftBits);
-
- blkCnt--;
- }
- }
- #endif
- }
|