FastLED 3.10.6
Loading...
Searching...
No Matches

◆ mp3d_DCT_II()

static MP3D_KERNEL void mp3d_DCT_II ( int32_t * grbuf,
int n )
static

Definition at line 470 of file minimp3_synth_fixed.h.

471{
472 int i, k = 0;
473#if MP3D_HAVE_INT_SIMD
474 if (MP3D_SIMD_AVAILABLE())
475 {
476 for (; k + 4 <= n; k += 4)
477 {
478 mp3d_dct2_bands4(grbuf, k);
479 }
480 }
481#endif
482 for (; k < n; k++)
483 {
484 int32_t t[4][8], *x, *y = grbuf + k;
485
486 /* Pass 1, spelled out rather than written as a loop over i.
487
488 gcc unrolls it either way -- it was 443 riscv32 instructions inside
489 the k loop before this, with no backward branch -- so the unroll is
490 not what this buys. What it buys is `i` being a template argument,
491 which makes g_sec_q27[3*i + k] a constant expression and lets each
492 of the four multiplies use mp3d_mulshift_k. Written as a loop the
493 secant is an int32 the compiler happens to know the value of, which
494 is not the same thing: a template argument can pick the integer and
495 fractional parts apart at compile time, and a value cannot.
496
497 g_sec_q27 stays the single definition of these numbers -- the
498 coefficients are read from it here, not transcribed -- which is why
499 it is `constexpr`. The SIMD kernel still indexes it at run time. */
500#define MP3D_DCT_PASS1(I) \
501 do { \
502 const int32_t x0 = y[(I)*18]; \
503 const int32_t x1 = y[(15 - (I))*18]; \
504 const int32_t x2 = y[(16 + (I))*18]; \
505 const int32_t x3 = y[(31 - (I))*18]; \
506 const int32_t t0 = mp3d_add_sat(x0, x3); \
507 const int32_t t1 = mp3d_add_sat(x1, x2); \
508 const int32_t t2 = mp3d_mulshift_k<27, g_sec_q27[3*(I) + 0]>( \
509 mp3d_sub_sat(x1, x2)); \
510 const int32_t t3 = mp3d_mulshift_k<27, g_sec_q27[3*(I) + 1]>( \
511 mp3d_sub_sat(x0, x3)); \
512 t[0][I] = mp3d_add_sat(t0, t1); \
513 t[1][I] = mp3d_mulshift_k<27, g_sec_q27[3*(I) + 2]>( \
514 mp3d_sub_sat(t0, t1)); \
515 t[2][I] = mp3d_add_sat(t3, t2); \
516 t[3][I] = mp3d_mulshift_k<27, g_sec_q27[3*(I) + 2]>( \
517 mp3d_sub_sat(t3, t2)); \
518 } while (0)
527#undef MP3D_DCT_PASS1
528 for (x = t[0], i = 0; i < 4; i++, x += 8)
529 {
530 int32_t x0 = x[0], x1 = x[1], x2 = x[2], x3 = x[3];
531 int32_t x4 = x[4], x5 = x[5], x6 = x[6], x7 = x[7], xt;
532 xt = mp3d_sub_sat(x0, x7); x0 = mp3d_add_sat(x0, x7);
533 x7 = mp3d_sub_sat(x1, x6); x1 = mp3d_add_sat(x1, x6);
534 x6 = mp3d_sub_sat(x2, x5); x2 = mp3d_add_sat(x2, x5);
535 x5 = mp3d_sub_sat(x3, x4); x3 = mp3d_add_sat(x3, x4);
536 x4 = mp3d_sub_sat(x0, x3); x0 = mp3d_add_sat(x0, x3);
537 x3 = mp3d_sub_sat(x1, x2); x1 = mp3d_add_sat(x1, x2);
538 x[0] = mp3d_add_sat(x0, x1);
539 x[4] = mp3d_mulshift_k<31, MP3D_Q31_COS_PI_4>(mp3d_sub_sat(x0, x1));
540 x5 = mp3d_add_sat(x5, x6);
541 x6 = mp3d_mulshift_k<31, MP3D_Q31_COS_PI_4>(mp3d_add_sat(x6, x7));
542 x7 = mp3d_add_sat(x7, xt);
543 x3 = mp3d_mulshift_k<31, MP3D_Q31_COS_PI_4>(mp3d_add_sat(x3, x4));
544 /* rotate by PI/8 */
545 x5 = mp3d_sub_sat(x5, mp3d_mulshift_k<31, MP3D_Q31_TAN_PI_16>(x7));
546 x7 = mp3d_add_sat(x7, mp3d_mulshift_k<31, MP3D_Q31_SIN_PI_8>(x5));
547 x5 = mp3d_sub_sat(x5, mp3d_mulshift_k<31, MP3D_Q31_TAN_PI_16>(x7));
548 x0 = mp3d_sub_sat(xt, x6); xt = mp3d_add_sat(xt, x6);
549 x[1] = mp3d_mulshift_k<29, MP3D_Q29_SEC_PI_16>(mp3d_add_sat(xt, x7));
550 x[2] = mp3d_mulshift_k<29, MP3D_Q29_SEC_PI_8>(mp3d_add_sat(x4, x3));
551 x[3] = mp3d_mulshift_k<29, MP3D_Q29_SEC_3PI_16>(mp3d_sub_sat(x0, x5));
552 x[5] = mp3d_mulshift_k<29, MP3D_Q29_SEC_5PI_16>(mp3d_add_sat(x0, x5));
553 x[6] = mp3d_mulshift_k<29, MP3D_Q29_SEC_3PI_8>(mp3d_sub_sat(x4, x3));
554 x[7] = mp3d_mulshift_k<29, MP3D_Q29_SEC_7PI_16>(mp3d_sub_sat(xt, x7));
555 }
556 for (i = 0; i < 7; i++, y += 4*18)
557 {
558 y[0*18] = t[0][i];
559 y[1*18] = mp3d_add_sat(mp3d_add_sat(t[2][i], t[3][i]), t[3][i + 1]);
560 y[2*18] = mp3d_add_sat(t[1][i], t[1][i + 1]);
561 y[3*18] = mp3d_add_sat(mp3d_add_sat(t[2][i + 1], t[3][i]), t[3][i + 1]);
562 }
563 y[0*18] = t[0][7];
564 y[1*18] = mp3d_add_sat(t[2][7], t[3][7]);
565 y[2*18] = t[1][7];
566 y[3*18] = t[3][7];
567 }
568}
int y
Definition simple.h:93
int x
Definition simple.h:92
static uint32_t t
Definition Luminova.h:55
#define MP3D_DCT_PASS1(I)
fl::i32 int32_t
Definition stdint.h:219

References FL_NO_EXCEPT, MP3D_DCT_PASS1, t, x, and y.

Referenced by mp3d_synth_granule().

+ Here is the caller graph for this function: