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

◆ IMDCT() [2/2]

int32_t fl::third_party::IMDCT ( MP3DecInfo * mp3DecInfo,
int32_t gr,
int32_t ch )

Definition at line 736 of file imdct.hpp.

737{
738 int32_t nBfly, blockCutoff;
739 FrameHeader *fh;
740 SideInfo *si;
741 HuffmanInfo *hi;
742 IMDCTInfo *mi;
743 BlockCount bc;
744
745 /* validate pointers */
746 if (!mp3DecInfo || !mp3DecInfo->FrameHeaderPS || !mp3DecInfo->SideInfoPS ||
747 !mp3DecInfo->HuffmanInfoPS || !mp3DecInfo->IMDCTInfoPS)
748 return -1;
749
750 /* si is an array of up to 4 structs, stored as gr0ch0, gr0ch1, gr1ch0, gr1ch1 */
751 fh = (FrameHeader *)(mp3DecInfo->FrameHeaderPS);
752 si = (SideInfo *)(mp3DecInfo->SideInfoPS);
753 hi = (HuffmanInfo*)(mp3DecInfo->HuffmanInfoPS);
754 mi = (IMDCTInfo *)(mp3DecInfo->IMDCTInfoPS);
755
756 /* anti-aliasing done on whole long blocks only
757 * for mixed blocks, nBfly always 1, except 3 for 8 kHz MPEG 2.5 (see sfBandTab)
758 * nLongBlocks = number of blocks with (possibly) non-zero power
759 * nBfly = number of butterflies to do (nLongBlocks - 1, unless no long blocks)
760 */
761 blockCutoff = fh->sfBand->l[(fh->ver == MPEG1 ? 8 : 6)] / 18; /* same as 3* num short sfb's in spec */
762 if (si->sis[gr][ch].blockType != 2) {
763 /* all long transforms */
764 bc.nBlocksLong = MIN((hi->nonZeroBound[ch] + 7) / 18 + 1, 32);
765 nBfly = bc.nBlocksLong - 1;
766 } else if (si->sis[gr][ch].blockType == 2 && si->sis[gr][ch].mixedBlock) {
767 /* mixed block - long transforms until cutoff, then short transforms */
768 bc.nBlocksLong = blockCutoff;
769 nBfly = bc.nBlocksLong - 1;
770 } else {
771 /* all short transforms */
772 bc.nBlocksLong = 0;
773 nBfly = 0;
774 }
775
776 AntiAlias(hi->huffDecBuf[ch], nBfly);
777 hi->nonZeroBound[ch] = MAX(hi->nonZeroBound[ch], (nBfly * 18) + 8);
778
779 ASSERT(hi->nonZeroBound[ch] <= MAX_NSAMP);
780
781 /* for readability, use a struct instead of passing a million parameters to HybridTransform() */
782 bc.nBlocksTotal = (hi->nonZeroBound[ch] + 17) / 18;
783 bc.nBlocksPrev = mi->numPrevIMDCT[ch];
784 bc.prevType = mi->prevType[ch];
785 bc.prevWinSwitch = mi->prevWinSwitch[ch];
786 bc.currWinSwitch = (si->sis[gr][ch].mixedBlock ? blockCutoff : 0); /* where WINDOW switches (not nec. transform) */
787 bc.gbIn = hi->gb[ch];
788
789 mi->numPrevIMDCT[ch] = HybridTransform(hi->huffDecBuf[ch], mi->overBuf[ch], mi->outBuf[ch], &si->sis[gr][ch], &bc);
790 mi->prevType[ch] = si->sis[gr][ch].blockType;
791 mi->prevWinSwitch[ch] = bc.currWinSwitch; /* 0 means not a mixed block (either all short or all long) */
792 mi->gb[ch] = bc.gbOut;
793
794 ASSERT(mi->numPrevIMDCT[ch] <= NBANDS);
795
796 /* output has gained 2 int bits */
797 return 0;
798}
#define MIN(a, b)
Definition coder.h:64
#define NBANDS
Definition coder.h:107
#define ASSERT(x)
Definition coder.h:56
#define MAX(a, b)
Definition coder.h:60
void * IMDCTInfoPS
Definition mp3common.h:73
void * FrameHeaderPS
Definition mp3common.h:68
void * SideInfoPS
Definition mp3common.h:69
void * HuffmanInfoPS
Definition mp3common.h:71
@ MPEG1
Definition mp3dec.h:83
#define MAX_NSAMP
Definition mp3dec.h:79
struct fl::third_party::_IMDCTInfo IMDCTInfo
struct fl::third_party::_HuffmanInfo HuffmanInfo
struct fl::third_party::_FrameHeader FrameHeader
static int32_t HybridTransform(int32_t *xCurr, int32_t *xPrev, int32_t y[BLOCK_SIZE][NBANDS], SideInfoSub *sis, BlockCount *bc) FL_NOEXCEPT
Definition imdct.hpp:634
struct fl::third_party::_SideInfo SideInfo
struct fl::third_party::_BlockCount BlockCount
fl::i32 int32_t
Definition coder.h:220
static void AntiAlias(int32_t *x, int32_t nBfly) FL_NOEXCEPT
Definition imdct.hpp:80
int32_t overBuf[MAX_NCHAN][MAX_NSAMP/2]
Definition coder.h:238
int32_t outBuf[MAX_NCHAN][BLOCK_SIZE][NBANDS]
Definition coder.h:237
int32_t prevType[MAX_NCHAN]
Definition coder.h:240
int32_t prevWinSwitch[MAX_NCHAN]
Definition coder.h:241
int32_t nonZeroBound[MAX_NCHAN]
Definition coder.h:217
int32_t gb[MAX_NCHAN]
Definition coder.h:218
int32_t huffDecBuf[MAX_NCHAN][MAX_NSAMP]
Definition coder.h:216
int32_t numPrevIMDCT[MAX_NCHAN]
Definition coder.h:239
int32_t gb[MAX_NCHAN]
Definition coder.h:242
const SFBandTable * sfBand
Definition coder.h:175
SideInfoSub sis[MAX_NGRAN][MAX_NCHAN]
Definition coder.h:200

References AntiAlias(), ASSERT, fl::third_party::_SideInfoSub::blockType, fl::third_party::_BlockCount::currWinSwitch, FL_NOEXCEPT, fl::third_party::_HuffmanInfo::gb, fl::third_party::_IMDCTInfo::gb, fl::third_party::_BlockCount::gbIn, fl::third_party::_BlockCount::gbOut, fl::third_party::_HuffmanInfo::huffDecBuf, HybridTransform(), fl::third_party::_SFBandTable::l, MAX, MAX_NSAMP, MIN, fl::third_party::_SideInfoSub::mixedBlock, MPEG1, NBANDS, fl::third_party::_BlockCount::nBlocksLong, fl::third_party::_BlockCount::nBlocksPrev, fl::third_party::_BlockCount::nBlocksTotal, fl::third_party::_HuffmanInfo::nonZeroBound, fl::third_party::_IMDCTInfo::numPrevIMDCT, fl::third_party::_IMDCTInfo::outBuf, fl::third_party::_IMDCTInfo::overBuf, fl::third_party::_BlockCount::prevType, fl::third_party::_IMDCTInfo::prevType, fl::third_party::_BlockCount::prevWinSwitch, fl::third_party::_IMDCTInfo::prevWinSwitch, fl::third_party::_FrameHeader::sfBand, fl::third_party::_SideInfo::sis, and fl::third_party::_FrameHeader::ver.

+ Here is the call graph for this function: