00001 /* ---------------------------------------------------------------------- 00002 * Copyright (C) 2011 ARM Limited. All rights reserved. 00003 * 00004 * $Date: 15. December 2011 00005 * $Revision: V2.0.0 00006 * 00007 * Project: Cortex-R DSP Library 00008 * Title: arm_offset_q15.c 00009 * 00010 * Description: Q15 vector offset. 00011 * 00012 * Target Processor: Cortex-R4/R5 00013 * 00014 * Version 1.0.0 2011/03/08 00015 * Alpha release. 00016 * 00017 * Version 1.0.1 2011/09/30 00018 * Beta release. 00019 * 00020 * Version 2.0.0 2011/12/15 00021 * Final release. 00022 * 00023 * -------------------------------------------------------------------- */ 00024 #include "arm_math.h" 00025 00053 void arm_offset_q15( 00054 q15_t * pSrc, 00055 q15_t offset, 00056 q15_t * pDst, 00057 uint32_t blockSize) 00058 { 00059 uint32_t blkCnt; /* loop counter */ 00060 q31_t offset_packed; /* Offset packed to 32 bit */ 00061 q31_t in1, in2; /* temporary variables */ 00062 q15_t in; /* temporary variables */ 00063 00064 00065 /*loop Unrolling */ 00066 blkCnt = blockSize >> 3u; 00067 00068 /* Offset is packed to 32 bit in order to use SIMD32 for addition */ 00069 offset_packed = __PKHBT(offset, offset, 16); 00070 00071 /* First part of the processing with loop unrolling. Compute 8 outputs at a time. 00072 ** a second loop below computes the remaining 1 to 7 samples. */ 00073 while(blkCnt > 0u) 00074 { 00075 /* C = A + offset */ 00076 /* Add offset and then store the results in the destination buffer, 2 samples at a time. */ 00077 /* read two samples at a time from source */ 00078 in1 = *__SIMD32(pSrc)++; 00079 in2 = *__SIMD32(pSrc)++; 00080 00081 /* add offset to two samples at a time */ 00082 in1 = __QADD16(in1, offset_packed); 00083 in2 = __QADD16(in2, offset_packed); 00084 00085 /* store result to the destination two samples at a time */ 00086 *__SIMD32(pDst)++ = in1; 00087 *__SIMD32(pDst)++ = in2; 00088 00089 /* read two samples at a time from source */ 00090 in1 = *__SIMD32(pSrc)++; 00091 in2 = *__SIMD32(pSrc)++; 00092 00093 /* add offset to two samples at a time */ 00094 in1 = __QADD16(in1, offset_packed); 00095 in2 = __QADD16(in2, offset_packed); 00096 00097 /* store result to the destination two samples at a time */ 00098 *__SIMD32(pDst)++ = in1; 00099 *__SIMD32(pDst)++ = in2; 00100 00101 /* Decrement the loop counter */ 00102 blkCnt--; 00103 } 00104 00105 /* If the blockSize is not a multiple of 8, compute any remaining output samples here. 00106 ** No loop unrolling is used. */ 00107 blkCnt = blockSize % 0x8u; 00108 00109 while(blkCnt > 0u) 00110 { 00111 /* C = A + offset */ 00112 /* Add offset and then store the results in the destination buffer. */ 00113 in = *pSrc++; 00114 *pDst++ = (q15_t) __QADD16(in, offset); 00115 00116 /* Decrement the loop counter */ 00117 blkCnt--; 00118 } 00119 } 00120