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_q31.c 00009 * 00010 * Description: Q31 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 00049 void arm_offset_q31( 00050 q31_t * pSrc, 00051 q31_t offset, 00052 q31_t * pDst, 00053 uint32_t blockSize) 00054 { 00055 uint32_t blkCnt; /* loop counter */ 00056 q31_t in1, in2, in3, in4; /* temporary variables */ 00057 00058 00059 /*loop Unrolling */ 00060 blkCnt = blockSize >> 3u; 00061 00062 /* First part of the processing with loop unrolling. Compute 8 outputs at a time. 00063 ** a second loop below computes the remaining 1 to 7 samples. */ 00064 while(blkCnt > 0u) 00065 { 00066 /* C = A + offset */ 00067 /* Add offset and then store the results in the destination buffer. */ 00068 /* read samples from the source */ 00069 in1 = *pSrc; 00070 in2 = *(pSrc + 1); 00071 00072 /* add offset to the input */ 00073 in1 = __QADD(in1, offset); 00074 00075 /* read sample from the source */ 00076 in3 = *(pSrc + 2); 00077 00078 /* add offset to the input */ 00079 in2 = __QADD(in2, offset); 00080 00081 /* read sample from the source */ 00082 in4 = *(pSrc + 3); 00083 00084 /* add offset to the input */ 00085 in3 = __QADD(in3, offset); 00086 00087 /* store result to destination buffer */ 00088 *pDst = in1; 00089 00090 /* add offset to the input */ 00091 in4 = __QADD(in4, offset); 00092 00093 /* store result to destination buffer */ 00094 *(pDst + 1) = in2; 00095 *(pDst + 2) = in3; 00096 *(pDst + 3) = in4; 00097 00098 /* read samples from the source */ 00099 in1 = *(pSrc + 4); 00100 in2 = *(pSrc + 5); 00101 00102 /* add offset to the input */ 00103 in1 = __QADD(in1, offset); 00104 00105 /* read sample from the source */ 00106 in3 = *(pSrc + 6); 00107 00108 /* add offset to the input */ 00109 in2 = __QADD(in2, offset); 00110 00111 /* read sample from the source */ 00112 in4 = *(pSrc + 7); 00113 00114 /* store result to destination buffer */ 00115 *(pDst + 4) = in1; 00116 00117 /* add offset to the input */ 00118 in3 = __QADD(in3, offset); 00119 00120 /* store result to destination buffer */ 00121 *(pDst + 5) = in2; 00122 00123 /* add offset to the input */ 00124 in4 = __QADD(in4, offset); 00125 00126 /* store result to destination buffer */ 00127 *(pDst + 6) = in3; 00128 00129 /* increment source pointer by 8 to process next samples */ 00130 pSrc += 8u; 00131 00132 /* store result to destination buffer */ 00133 *(pDst + 7) = in4; 00134 00135 /* increment destination pointer by 8 */ 00136 pDst += 8u; 00137 00138 /* Decrement the loop counter */ 00139 blkCnt--; 00140 } 00141 00142 /* If the blockSize is not a multiple of 8, compute any remaining output samples here. 00143 ** No loop unrolling is used. */ 00144 blkCnt = blockSize % 0x8u; 00145 00146 while(blkCnt > 0u) 00147 { 00148 /* C = A + offset */ 00149 /* Add offset and then store the result in the destination buffer. */ 00150 in1 = *pSrc++; 00151 *pDst++ = __QADD(in1, offset); 00152 00153 /* Decrement the loop counter */ 00154 blkCnt--; 00155 } 00156 } 00157