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