FastLED 3.9.15
Loading...
Searching...
No Matches

◆ IMDCT36()

static int32_t fl::third_party::IMDCT36 ( int32_t * xCurr,
int32_t * xPrev,
int32_t * y,
int32_t btCurr,
int32_t btPrev,
int32_t blockIdx,
int32_t gb )
static

Definition at line 381 of file imdct.hpp.

382{
383 int32_t i, es;
384 int32_t xBuf[18], xPrevWin[18];
385 int32_t acc1, acc2, s, d, t, mOut;
386 int32_t xo, xe, c, *xp, yLo, yHi;
387 const int32_t *cp, *wp;
388
389 acc1 = acc2 = 0;
390 xCurr += 17;
391
392 /* 7 gb is always adequate for antialias + accumulator loop + idct9 */
393 if (gb < 7) {
394 /* rarely triggered - 5% to 10% of the time on normal clips (with Q25 input) */
395 es = 7 - gb;
396 for (i = 8; i >= 0; i--) {
397 acc1 = ((*xCurr--) >> es) - acc1;
398 acc2 = acc1 - acc2;
399 acc1 = ((*xCurr--) >> es) - acc1;
400 xBuf[i+9] = acc2; /* odd */
401 xBuf[i+0] = acc1; /* even */
402 xPrev[i] >>= es;
403 }
404 } else {
405 es = 0;
406 /* max gain = 18, assume adequate guard bits */
407 for (i = 8; i >= 0; i--) {
408 acc1 = (*xCurr--) - acc1;
409 acc2 = acc1 - acc2;
410 acc1 = (*xCurr--) - acc1;
411 xBuf[i+9] = acc2; /* odd */
412 xBuf[i+0] = acc1; /* even */
413 }
414 }
415 /* xEven[0] and xOdd[0] scaled by 0.5 */
416 xBuf[9] >>= 1;
417 xBuf[0] >>= 1;
418
419 /* do 9-point IDCT on even and odd */
420 idct9(xBuf+0); /* even */
421 idct9(xBuf+9); /* odd */
422
423 xp = xBuf + 8;
424 cp = c18 + 8;
425 mOut = 0;
426 if (btPrev == 0 && btCurr == 0) {
427 /* fast path - use symmetry of sin window to reduce windowing multiplies to 18 (N/2) */
428 wp = fastWin36;
429 for (i = 0; i < 9; i++) {
430 /* do ARM-style pointer arithmetic (i still needed for y[] indexing - compiler spills if 2 y pointers) */
431 c = *cp--; xo = *(xp + 9); xe = *xp--;
432 /* gain 2 int bits here */
433 xo = MULSHIFT32(c, xo); /* 2*c18*xOdd (mul by 2 implicit in scaling) */
434 xe >>= 2;
435
436 s = -(*xPrev); /* sum from last block (always at least 2 guard bits) */
437 d = -(xe - xo); /* gain 2 int bits, don't shift xo (effective << 1 to eat sign bit, << 1 for mul by 2) */
438 (*xPrev++) = xe + xo; /* symmetry - xPrev[i] = xPrev[17-i] for long blocks */
439 t = s - d;
440
441 yLo = (d + (MULSHIFT32(t, *wp++) * 4L));
442 yHi = (s + (MULSHIFT32(t, *wp++) * 4L));
443 y[(i)*NBANDS] = yLo;
444 y[(17-i)*NBANDS] = yHi;
445 mOut |= FASTABS(yLo);
446 mOut |= FASTABS(yHi);
447 }
448 } else {
449 /* slower method - either prev or curr is using window type != 0 so do full 36-point window
450 * output xPrevWin has at least 3 guard bits (xPrev has 2, gain 1 in WinPrevious)
451 */
452 WinPrevious(xPrev, xPrevWin, btPrev);
453
454 wp = imdctWin[btCurr];
455 for (i = 0; i < 9; i++) {
456 c = *cp--; xo = *(xp + 9); xe = *xp--;
457 /* gain 2 int bits here */
458 xo = MULSHIFT32(c, xo); /* 2*c18*xOdd (mul by 2 implicit in scaling) */
459 xe >>= 2;
460
461 d = xe - xo;
462 (*xPrev++) = xe + xo; /* symmetry - xPrev[i] = xPrev[17-i] for long blocks */
463
464 yLo = (xPrevWin[i] + MULSHIFT32(d, wp[i])) * 4L;
465 yHi = (xPrevWin[17-i] + MULSHIFT32(d, wp[17-i])) * 4L;
466 y[(i)*NBANDS] = yLo;
467 y[(17-i)*NBANDS] = yHi;
468 mOut |= FASTABS(yLo);
469 mOut |= FASTABS(yHi);
470 }
471 }
472
473 xPrev -= 9;
474 mOut |= FreqInvertRescale(y, xPrev, blockIdx, es);
475
476 return mOut;
477}
#define NBANDS
Definition coder.h:107
static int32_t FreqInvertRescale(int32_t *y, int32_t *xPrev, int32_t blockIdx, int32_t es) FL_NOEXCEPT
Definition imdct.hpp:195
__inline int32_t MULSHIFT32(int32_t x, int32_t y) FL_NOEXCEPT
Multiply together two 32-bit numbers and return the top 32-bits of the result.
Definition assembly.h:503
__inline int32_t FASTABS(int32_t x) FL_NOEXCEPT
Absolute value of x.
Definition assembly.h:513
static void WinPrevious(int32_t *xPrev, int32_t *xPrevWin, int32_t btPrev) FL_NOEXCEPT
Definition imdct.hpp:141
const int32_t imdctWin[4][36]
Definition trigtabs.hpp:107
static __inline void idct9(int32_t *x) FL_NOEXCEPT
Definition imdct.hpp:272
fl::i32 int32_t
Definition coder.h:220
static const int32_t c18[9]
Definition imdct.hpp:267
int32_t fastWin36[18]
Definition imdct.hpp:342

References c18, FASTABS(), fastWin36, FL_NOEXCEPT, FreqInvertRescale(), idct9(), imdctWin, MULSHIFT32(), NBANDS, fl::t, WinPrevious(), and fl::y.

Referenced by HybridTransform().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: