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
00025 #include "arm_math.h"
00026
00123 void arm_fir_decimate_f32(
00124 const arm_fir_decimate_instance_f32 * S,
00125 float32_t * pSrc,
00126 float32_t * pDst,
00127 uint32_t blockSize)
00128 {
00129 float32_t *pState = S->pState;
00130 float32_t *pCoeffs = S->pCoeffs;
00131 float32_t *pStateCurnt;
00132 float32_t *px, *pb;
00133 float32_t sum0;
00134 float32_t x0, c0;
00135 uint32_t numTaps = S->numTaps;
00136 uint32_t i, tapCnt, blkCnt, outBlockSize = blockSize / S->M;
00137 uint32_t blkCntN4;
00138 float32_t *px0, *px1, *px2, *px3;
00139 float32_t acc0, acc1, acc2, acc3;
00140 float32_t x1, x2, x3;
00141
00142
00143
00144
00145 pStateCurnt = S->pState + (numTaps - 1u);
00146
00147
00148 blkCnt = outBlockSize / 4;
00149 blkCntN4 = outBlockSize - (4*blkCnt);
00150
00151 while(blkCnt > 0u)
00152 {
00153
00154 i = 4 * S->M;
00155
00156 do
00157 {
00158 *pStateCurnt++ = *pSrc++;
00159
00160 } while(--i);
00161
00162
00163 acc0 = 0.0f;
00164 acc1 = 0.0f;
00165 acc2 = 0.0f;
00166 acc3 = 0.0f;
00167
00168
00169 px0 = pState;
00170 px1 = pState + S->M;
00171 px2 = pState + 2 * S->M;
00172 px3 = pState + 3 * S->M;
00173
00174
00175 pb = pCoeffs;
00176
00177
00178 tapCnt = numTaps >> 2;
00179
00180
00181
00182
00183 while(tapCnt > 0u)
00184 {
00185
00186 c0 = *(pb++);
00187
00188
00189 x0 = *(px0++);
00190
00191 x1 = *(px1++);
00192
00193 x2 = *(px2++);
00194
00195 x3 = *(px3++);
00196
00197
00198 acc0 += x0 * c0;
00199 acc1 += x1 * c0;
00200 acc2 += x2 * c0;
00201 acc3 += x3 * c0;
00202
00203
00204 c0 = *(pb++);
00205
00206
00207 x0 = *(px0++);
00208 x1 = *(px1++);
00209 x2 = *(px2++);
00210 x3 = *(px3++);
00211
00212
00213 acc0 += x0 * c0;
00214 acc1 += x1 * c0;
00215 acc2 += x2 * c0;
00216 acc3 += x3 * c0;
00217
00218
00219 c0 = *(pb++);
00220
00221
00222 x0 = *(px0++);
00223 x1 = *(px1++);
00224 x2 = *(px2++);
00225 x3 = *(px3++);
00226
00227
00228 acc0 += x0 * c0;
00229 acc1 += x1 * c0;
00230 acc2 += x2 * c0;
00231 acc3 += x3 * c0;
00232
00233
00234 c0 = *(pb++);
00235
00236
00237 x0 = *(px0++);
00238 x1 = *(px1++);
00239 x2 = *(px2++);
00240 x3 = *(px3++);
00241
00242
00243 acc0 += x0 * c0;
00244 acc1 += x1 * c0;
00245 acc2 += x2 * c0;
00246 acc3 += x3 * c0;
00247
00248
00249 tapCnt--;
00250 }
00251
00252
00253 tapCnt = numTaps % 0x4u;
00254
00255 while(tapCnt > 0u)
00256 {
00257
00258 c0 = *(pb++);
00259
00260
00261 x0 = *(px0++);
00262 x1 = *(px1++);
00263 x2 = *(px2++);
00264 x3 = *(px3++);
00265
00266
00267 acc0 += x0 * c0;
00268 acc1 += x1 * c0;
00269 acc2 += x2 * c0;
00270 acc3 += x3 * c0;
00271
00272
00273 tapCnt--;
00274 }
00275
00276
00277
00278 pState = pState + 4 * S->M;
00279
00280
00281 *pDst++ = acc0;
00282 *pDst++ = acc1;
00283 *pDst++ = acc2;
00284 *pDst++ = acc3;
00285
00286
00287 blkCnt--;
00288 }
00289
00290 while(blkCntN4 > 0u)
00291 {
00292
00293 i = S->M;
00294
00295 do
00296 {
00297 *pStateCurnt++ = *pSrc++;
00298
00299 } while(--i);
00300
00301
00302 sum0 = 0.0f;
00303
00304
00305 px = pState;
00306
00307
00308 pb = pCoeffs;
00309
00310
00311 tapCnt = numTaps >> 2;
00312
00313
00314
00315 while(tapCnt > 0u)
00316 {
00317
00318 c0 = *(pb++);
00319
00320
00321 x0 = *(px++);
00322
00323
00324 sum0 += x0 * c0;
00325
00326
00327 c0 = *(pb++);
00328
00329
00330 x0 = *(px++);
00331
00332
00333 sum0 += x0 * c0;
00334
00335
00336 c0 = *(pb++);
00337
00338
00339 x0 = *(px++);
00340
00341
00342 sum0 += x0 * c0;
00343
00344
00345 c0 = *(pb++);
00346
00347
00348 x0 = *(px++);
00349
00350
00351 sum0 += x0 * c0;
00352
00353
00354 tapCnt--;
00355 }
00356
00357
00358 tapCnt = numTaps % 0x4u;
00359
00360 while(tapCnt > 0u)
00361 {
00362
00363 c0 = *(pb++);
00364
00365
00366 x0 = *(px++);
00367
00368
00369 sum0 += x0 * c0;
00370
00371
00372 tapCnt--;
00373 }
00374
00375
00376
00377 pState = pState + S->M;
00378
00379
00380 *pDst++ = sum0;
00381
00382
00383 blkCntN4--;
00384 }
00385
00386
00387
00388
00389
00390
00391 pStateCurnt = S->pState;
00392
00393 i = (numTaps - 1u) >> 2;
00394
00395
00396 while(i > 0u)
00397 {
00398 *pStateCurnt++ = *pState++;
00399 *pStateCurnt++ = *pState++;
00400 *pStateCurnt++ = *pState++;
00401 *pStateCurnt++ = *pState++;
00402
00403
00404 i--;
00405 }
00406
00407 i = (numTaps - 1u) % 0x04u;
00408
00409
00410 while(i > 0u)
00411 {
00412 *pStateCurnt++ = *pState++;
00413
00414
00415 i--;
00416 }
00417 }
00418