Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "arm_math.h"
00025
00064 void arm_shift_q31(
00065 q31_t * pSrc,
00066 int8_t shiftBits,
00067 q31_t * pDst,
00068 uint32_t blockSize)
00069 {
00070 uint32_t blkCnt;
00071 uint8_t sign;
00072 q31_t in1, in2, in3, in4;
00073 q31_t out1, out2, out3, out4;
00074
00075
00076 blkCnt = blockSize >> 3u;
00077
00078
00079 sign = (shiftBits & 0x80);
00080
00081 if(sign == 0u)
00082 {
00083
00084
00085 while(blkCnt > 0u)
00086 {
00087
00088
00089 in1 = *pSrc;
00090 in2 = *(pSrc + 1);
00091 out1 = in1 << shiftBits;
00092 in3 = *(pSrc + 2);
00093 out2 = in2 << shiftBits;
00094 in4 = *(pSrc + 3);
00095 if(in1 != (out1 >> shiftBits))
00096 out1 = 0x7FFFFFFF ^(in1 >> 31);
00097
00098 if(in2 != (out2 >> shiftBits))
00099 out2 = 0x7FFFFFFF ^(in2 >> 31);
00100
00101 *pDst = out1;
00102 out3 = in3 << shiftBits;
00103 *(pDst + 1) = out2;
00104 out4 = in4 << shiftBits;
00105
00106 if(in3 != (out3 >> shiftBits))
00107 out3 = 0x7FFFFFFF ^(in3 >> 31);
00108
00109 if(in4 != (out4 >> shiftBits))
00110 out4 = 0x7FFFFFFF ^(in4 >> 31);
00111
00112 *(pDst + 2) = out3;
00113 *(pDst + 3) = out4;
00114
00115 in1 = *(pSrc + 4);
00116 in2 = *(pSrc + 5);
00117 out1 = in1 << shiftBits;
00118 in3 = *(pSrc + 6);
00119 out2 = in2 << shiftBits;
00120 in4 = *(pSrc + 7);
00121 if(in1 != (out1 >> shiftBits))
00122 out1 = 0x7FFFFFFF ^(in1 >> 31);
00123
00124 if(in2 != (out2 >> shiftBits))
00125 out2 = 0x7FFFFFFF ^(in2 >> 31);
00126
00127 *(pDst + 4) = out1;
00128 out3 = in3 << shiftBits;
00129 *(pDst + 5) = out2;
00130 out4 = in4 << shiftBits;
00131
00132 if(in3 != (out3 >> shiftBits))
00133 out3 = 0x7FFFFFFF ^(in3 >> 31);
00134
00135 if(in4 != (out4 >> shiftBits))
00136 out4 = 0x7FFFFFFF ^(in4 >> 31);
00137
00138 *(pDst + 6) = out3;
00139
00140 pSrc += 8u;
00141 *(pDst + 7) = out4;
00142
00143
00144 pDst += 8u;
00145
00146
00147 blkCnt--;
00148 }
00149
00150
00151
00152 blkCnt = blockSize % 0x8u;
00153
00154 while(blkCnt > 0u)
00155 {
00156
00157
00158 in1 = *pSrc++;
00159 out1 = in1 << shiftBits;
00160 if(in1 != (out1 >> shiftBits))
00161 out1 = 0x7FFFFFFF ^(in1 >> 31);
00162
00163 *pDst++ = out1;
00164
00165
00166 blkCnt--;
00167 }
00168 }
00169 else
00170 {
00171 shiftBits = -shiftBits;
00172
00173
00174
00175 while(blkCnt > 0u)
00176 {
00177
00178
00179 in1 = *pSrc;
00180 in2 = *(pSrc + 1);
00181 in3 = *(pSrc + 2);
00182 in4 = *(pSrc + 3);
00183
00184 *pDst = (in1 >> shiftBits);
00185 *(pDst + 1) = (in2 >> shiftBits);
00186 *(pDst + 2) = (in3 >> shiftBits);
00187 *(pDst + 3) = (in4 >> shiftBits);
00188
00189 in1 = *(pSrc + 4);
00190 in2 = *(pSrc + 5);
00191 in3 = *(pSrc + 6);
00192 in4 = *(pSrc + 7);
00193
00194 *(pDst + 4) = (in1 >> shiftBits);
00195 *(pDst + 5) = (in2 >> shiftBits);
00196 *(pDst + 6) = (in3 >> shiftBits);
00197 *(pDst + 7) = (in4 >> shiftBits);
00198
00199 pSrc += 8u;
00200 pDst += 8u;
00201
00202 blkCnt--;
00203 }
00204
00205
00206
00207 blkCnt = blockSize % 0x8u;
00208
00209 while(blkCnt > 0u)
00210 {
00211
00212
00213 in1 = *pSrc++;
00214 *pDst++ = (in1 >> shiftBits);
00215
00216
00217 blkCnt--;
00218 }
00219 }
00220
00221 }
00222