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
00105 void arm_fir_sparse_f32(
00106 arm_fir_sparse_instance_f32 * S,
00107 float32_t * pSrc,
00108 float32_t * pDst,
00109 float32_t * pScratchIn,
00110 uint32_t blockSize)
00111 {
00112
00113 float32_t *pState = S->pState;
00114 float32_t *pCoeffs = S->pCoeffs;
00115 float32_t *px;
00116 float32_t *py = pState;
00117 float32_t *pb = pScratchIn;
00118 float32_t *pOut;
00119 int32_t *pTapDelay = S->pTapDelay;
00120 uint32_t delaySize = S->maxDelay + blockSize;
00121 uint16_t numTaps = S->numTaps;
00122 int32_t readIndex;
00123 uint32_t tapCnt, blkCnt;
00124 float32_t coeff = *pCoeffs++;
00125 float32_t x0, x1;
00126 float32_t y0, y1;
00127
00128
00129
00130
00131 arm_circularWrite_f32((int32_t *) py, delaySize, &S->stateIndex, 1,
00132 (int32_t *) pSrc, 1, blockSize);
00133
00134
00135
00136 readIndex = ((int32_t) S->stateIndex - (int32_t) blockSize) - *pTapDelay++;
00137
00138
00139 if(readIndex < 0)
00140 {
00141 readIndex += (int32_t) delaySize;
00142 }
00143
00144
00145 py = pState;
00146
00147
00148 arm_circularRead_f32((int32_t *) py, delaySize, &readIndex, 1,
00149 (int32_t *) pb, (int32_t *) pb, blockSize, 1,
00150 blockSize);
00151
00152
00153 px = pb;
00154
00155
00156 pOut = pDst;
00157
00158
00159
00160 blkCnt = blockSize >> 2u;
00161
00162 while(blkCnt > 0u)
00163 {
00164
00165
00166
00167 x0 = *px++;
00168 x1 = *px++;
00169
00170
00171 y0 = x0 * coeff;
00172 y1 = x1 * coeff;
00173
00174
00175 *pOut++ = y0;
00176 *pOut++ = y1;
00177
00178
00179 x0 = *px++;
00180 x1 = *px++;
00181
00182
00183 y0 = x0 * coeff;
00184 y1 = x1 * coeff;
00185
00186
00187 *pOut++ = y0;
00188 *pOut++ = y1;
00189
00190
00191 blkCnt--;
00192 }
00193
00194
00195
00196 blkCnt = blockSize % 0x4u;
00197
00198 while(blkCnt > 0u)
00199 {
00200
00201 *pOut++ = *px++ * coeff;
00202
00203
00204 blkCnt--;
00205 }
00206
00207
00208
00209 coeff = *pCoeffs++;
00210
00211
00212 readIndex = ((int32_t) S->stateIndex - (int32_t) blockSize) - *pTapDelay++;
00213
00214
00215 if(readIndex < 0)
00216 {
00217 readIndex += (int32_t) delaySize;
00218 }
00219
00220
00221 tapCnt = (uint32_t) numTaps - 1u;
00222
00223 while(tapCnt > 0u)
00224 {
00225
00226
00227 py = pState;
00228
00229
00230 arm_circularRead_f32((int32_t *) py, delaySize, &readIndex, 1,
00231 (int32_t *) pb, (int32_t *) pb, blockSize, 1,
00232 blockSize);
00233
00234
00235 px = pb;
00236
00237
00238 pOut = pDst;
00239
00240
00241
00242 blkCnt = blockSize >> 2u;
00243
00244 while(blkCnt > 0u)
00245 {
00246
00247 x0 = *px;
00248 x1 = *(px + 1u);
00249
00250
00251 y0 = *pOut;
00252 y1 = *(pOut + 1u);
00253
00254
00255 y0 = y0 + x0 * coeff;
00256 y1 = y1 + x1 * coeff;
00257
00258
00259 x0 = *(px + 2u);
00260 x1 = *(px + 3u);
00261
00262
00263 *pOut = y0;
00264 *(pOut + 1u) = y1;
00265
00266
00267 y0 = *(pOut + 2u);
00268 y1 = *(pOut + 3u);
00269
00270
00271 y0 = y0 + x0 * coeff;
00272 y1 = y1 + x1 * coeff;
00273
00274
00275 *(pOut + 2u) = y0;
00276 *(pOut + 3u) = y1;
00277
00278
00279 px += 4u;
00280 pOut += 4u;
00281
00282
00283 blkCnt--;
00284
00285 }
00286
00287
00288
00289 blkCnt = blockSize % 0x4u;
00290
00291 while(blkCnt > 0u)
00292 {
00293
00294 x0 = *px;
00295
00296
00297 y0 = *pOut;
00298
00299
00300 y0 = y0 + x0 * coeff;
00301
00302
00303 px += 1u;
00304
00305
00306 *pOut++ = y0;
00307
00308
00309 blkCnt--;
00310 }
00311
00312
00313
00314 coeff = *pCoeffs++;
00315
00316
00317 readIndex = ((int32_t) S->stateIndex -
00318 (int32_t) blockSize) - *pTapDelay++;
00319
00320
00321 if(readIndex < 0)
00322 {
00323 readIndex += (int32_t) delaySize;
00324 }
00325
00326
00327 tapCnt--;
00328 }
00329
00330 }
00331