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