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
00026 #include "arm_math.h"
00027
00159 void arm_biquad_cascade_df1_f32(
00160 const arm_biquad_casd_df1_inst_f32 * S,
00161 float32_t * pSrc,
00162 float32_t * pDst,
00163 uint32_t blockSize)
00164 {
00165 float32_t *pIn = pSrc;
00166 float32_t *pOut = pDst;
00167 float32_t *pState = S->pState;
00168 float32_t *pCoeffs = S->pCoeffs;
00169 float32_t acc;
00170 float32_t b0, b1, b2, a1, a2;
00171 float32_t Xn1, Xn2, Yn1, Yn2;
00172 float32_t Xn;
00173 uint32_t sample, stage = S->numStages;
00174 float32_t X0, X1, X2;
00175 float32_t Y0, Y1, Y2, Y3, Y4, Y5, Y6, Y7;
00176
00177 do
00178 {
00179
00180 b0 = *pCoeffs++;
00181 b1 = *pCoeffs++;
00182 b2 = *pCoeffs++;
00183 a1 = *pCoeffs++;
00184 a2 = *pCoeffs++;
00185
00186
00187 Xn2 = pState[0];
00188 Xn1 = pState[1];
00189 Yn2 = pState[2];
00190 Yn1 = pState[3];
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206 sample = blockSize >> 3u;
00207
00208 if(sample > 0)
00209 {
00210
00211 sample = sample - 1u;
00212
00213
00214
00215
00216
00217
00218
00219
00220 X2 = *pIn++;
00221
00222
00223
00224 Y0 = (Xn2 * b2);
00225
00226 Y1 = (Xn1 * b2);
00227
00228 Y2 = (X2 * b2);
00229
00230
00231 X0 = *pIn++;
00232
00233
00234
00235 Y3 = (X0 * b2);
00236
00237
00238 Y0 += (Xn1 * b1);
00239
00240 Y1 += (X2 * b1);
00241
00242 Y2 += (X0 * b1);
00243
00244
00245 X1 = *pIn++;
00246
00247
00248
00249 Y0 += (X2 * b0);
00250
00251 Y3 += (X1 * b1);
00252
00253 Y1 += (X0 * b0);
00254
00255 Y2 += (X1 * b0);
00256
00257
00258
00259 Y0 += (Yn2 * a2);
00260
00261
00262 X2 = *pIn++;
00263
00264
00265
00266 Y3 += (X2 * b0);
00267
00268 Y1 += (Yn1 * a2);
00269
00270 Y0 += (Yn1 * a1);
00271
00272 while(sample > 0u)
00273 {
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286 X0 = *pIn++;
00287
00288
00289
00290 Y4 = (X1 * b2);
00291
00292 Y5 = (X2 * b2);
00293
00294 Y6 = (X0 * b2);
00295
00296
00297 X1 = *pIn++;
00298
00299
00300 Y1 += (Y0 * a1);
00301 Y2 += (Y0 * a2);
00302
00303
00304 Y4 += (X2 * b1);
00305
00306 Y5 += (X0 * b1);
00307
00308 Y6 += (X1 * b1);
00309
00310 Y7 = (X1 * b2);
00311
00312
00313 X2 = *pIn++;
00314
00315
00316
00317 *pOut++ = Y0;
00318
00319
00320 Y3 += (Y1 * a2);
00321
00322 Y2 += (Y1 * a1);
00323
00324
00325 Y4 += (X0 * b0);
00326
00327 Y5 += (X1 * b0);
00328
00329 Y6 += (X2 * b0);
00330
00331
00332 Y3 += (Y2 * a1);
00333
00334 Y4 += (Y2 * a2);
00335
00336 Y7 += (X2 * b1);
00337
00338 X1 = X2;
00339
00340
00341 X2 = *pIn++;
00342
00343
00344
00345 *pOut++ = Y1;
00346
00347
00348 Y4 += (Y3 * a1);
00349
00350 Y5 += (Y3 * a2);
00351
00352 Y7 += (X2 * b0);
00353
00354
00355 *pOut++ = Y2;
00356
00357
00358
00359 *pOut++ = Y3;
00360
00361
00362 X0 = *pIn++;
00363
00364
00365
00366
00367
00368
00369
00370
00371 Y0 = (X1 * b2);
00372 Y1 = (X2 * b2);
00373 Y2 = (X0 * b2);
00374
00375 X1 = *pIn++;
00376
00377
00378 Y5 += (Y4 * a1);
00379 Y6 += (Y4 * a2);
00380
00381 Y0 += (X2 * b1);
00382 Y1 += (X0 * b1);
00383 Y2 += (X1 * b1);
00384
00385 Y3 = (X1 * b2);
00386
00387 X2 = *pIn++;
00388
00389
00390
00391 *pOut++ = Y4;
00392
00393
00394 Y7 += (Y5 * a2);
00395 Y6 += (Y5 * a1);
00396
00397 Y0 += (X0 * b0);
00398 Y1 += (X1 * b0);
00399 Y2 += (X2 * b0);
00400
00401 Y7 += (Y6 * a1);
00402 Y0 += (Y6 * a2);
00403 Y3 += (X2 * b1);
00404
00405 X1 = X2;
00406
00407 X2 = *pIn++;
00408
00409
00410
00411 *pOut++ = Y5;
00412
00413
00414 Y0 += (Y7 * a1);
00415 Y1 += (Y7 * a2);
00416 Y3 += (X2 * b0);
00417
00418
00419 *pOut++ = Y6;
00420
00421
00422
00423 *pOut++ = Y7;
00424
00425
00426
00427
00428 sample--;
00429
00430
00431 }
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443 X0 = *pIn++;
00444
00445
00446 Y4 = (X1 * b2);
00447 Y5 = (X2 * b2);
00448 Y6 = (X0 * b2);
00449
00450
00451 X1 = *pIn++;
00452
00453
00454 Y1 += (Y0 * a1);
00455 Y2 += (Y0 * a2);
00456
00457 Y4 += (X2 * b1);
00458 Y5 += (X0 * b1);
00459 Y6 += (X1 * b1);
00460
00461 Y7 = (X1 * b2);
00462
00463 X2 = *pIn++;
00464
00465
00466 *pOut++ = Y0;
00467
00468
00469 Y3 += (Y1 * a2);
00470 Y2 += (Y1 * a1);
00471
00472 Y4 += (X0 * b0);
00473 Y5 += (X1 * b0);
00474 Y6 += (X2 * b0);
00475
00476 Y3 += (Y2 * a1);
00477 Y4 += (Y2 * a2);
00478
00479 Y7 += (X2 * b1);
00480
00481 X1 = X2;
00482
00483 X2 = *pIn++;
00484
00485
00486 *pOut++ = Y1;
00487
00488
00489 Y4 += (Y3 * a1);
00490 Y5 += (Y3 * a2);
00491 Y7 += (X2 * b0);
00492
00493 *pOut++ = Y2;
00494
00495
00496 *pOut++ = Y3;
00497
00498
00499 Y5 += (Y4 * a1);
00500 Y6 += (Y4 * a2);
00501 Y6 += (Y5 * a1);
00502 Y7 += (Y5 * a2);
00503 Y7 += (Y6 * a1);
00504
00505 *pOut++ = Y4;
00506
00507
00508 *pOut++ = Y5;
00509
00510
00511 *pOut++ = Y6;
00512
00513
00514 *pOut++ = Y7;
00515
00516
00517
00518 Xn2 = X1;
00519 Xn1 = X2;
00520 Yn2 = Y6;
00521 Yn1 = Y7;
00522
00523 }
00524
00525
00526
00527 sample = (blockSize & 0x7u);
00528
00529 while(sample > 0u)
00530 {
00531
00532 Xn = *pIn++;
00533
00534
00535 acc = (b0 * Xn) + (b1 * Xn1) + (b2 * Xn2) + (a1 * Yn1) + (a2 * Yn2);
00536
00537
00538 *pOut++ = acc;
00539
00540
00541
00542
00543
00544
00545
00546 Xn2 = Xn1;
00547 Xn1 = Xn;
00548 Yn2 = Yn1;
00549 Yn1 = acc;
00550
00551
00552 sample--;
00553
00554 }
00555
00556
00557 *pState++ = Xn2;
00558 *pState++ = Xn1;
00559 *pState++ = Yn2;
00560 *pState++ = Yn1;
00561
00562
00563
00564 pIn = pDst;
00565
00566
00567 pOut = pDst;
00568
00569
00570 stage--;
00571
00572 } while(stage > 0u);
00573
00574
00575
00576 }
00577
00578