void CShortBlock_FrequencyToTime(CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo, CAacDecoderChannelInfo *pAacDecoderChannelInfo, float outSamples[], const int stride) { int i; COverlapAddData *pOverlapAddData = &pAacDecoderStaticChannelInfo->OverlapAddData; const float *shortWindow = pAacDecoderStaticChannelInfo->pShortWindow[GetWindowShape(&pAacDecoderChannelInfo->IcsInfo)]; const float *shortWindowPrev = pAacDecoderStaticChannelInfo->pShortWindow[pOverlapAddData->WindowShape]; const float *longWindowPrev = pAacDecoderStaticChannelInfo->pLongWindow[pOverlapAddData->WindowShape]; float *pSpectralCoefficient = pAacDecoderChannelInfo->pSpectralCoefficient; COUNT_sub_start("CShortBlock_FrequencyToTime"); INDIRECT(5); PTR_INIT(5); /* counting previous operations */ /* Inverse MDCT */ PTR_INIT(1); /* pSpectralCoefficient[i*Size02] */ LOOP(1); for (i=0; i<MaximumWindows; i++) { FUNC(1); CShortBlock_InverseTransform(&pSpectralCoefficient[i*Size02]); } /* Overlap & Add */ INDIRECT(1); BRANCH(2); switch(pOverlapAddData->WindowSequence) { case EightShortSequence: case LongStartSequence: PTR_INIT(2); /* outSamples[stride*i] pOverlapAddData->pOverlapBuffer[i] */ LOOP(1); for (i=0; i<Size07; i++) { MOVE(1); outSamples[stride*i] = pOverlapAddData->pOverlapBuffer[i]; } INDIRECT(2); PTR_INIT(3); FUNC(6); Lap1(&pSpectralCoefficient[0],&pOverlapAddData->pOverlapBuffer[Size07], &outSamples[stride*Size07],shortWindowPrev,Size01,stride); INDIRECT(1); PTR_INIT(3); FUNC(6); Lap1(&pSpectralCoefficient[Size02],&pSpectralCoefficient[0], &outSamples[stride*Size09],shortWindow,Size01,stride); INDIRECT(1); PTR_INIT(3); FUNC(6); Lap1(&pSpectralCoefficient[Size04],&pSpectralCoefficient[Size02], &outSamples[stride*Size11],shortWindow,Size01,stride); INDIRECT(1); PTR_INIT(3); FUNC(6); Lap1(&pSpectralCoefficient[Size06],&pSpectralCoefficient[Size04], &outSamples[stride*Size13],shortWindow,Size01,stride); PTR_INIT(3); FUNC(6); Lap2(&pSpectralCoefficient[Size08],&pSpectralCoefficient[Size06], pOverlapAddData->pOverlapBuffer,shortWindow,Size01,1); PTR_INIT(3); /* outSamples[stride*(Size15+i)] pOverlapAddData->pOverlapBuffer[i] pOverlapAddData->pOverlapBuffer[i+Size01] */ LOOP(1); for (i=0; i<Size01; i++) { MOVE(2); outSamples[stride*(Size15+i)] = pOverlapAddData->pOverlapBuffer[i]; pOverlapAddData->pOverlapBuffer[i] = pOverlapAddData->pOverlapBuffer[i+Size01]; } break; case OnlyLongSequence: case LongStopSequence: INDIRECT(1); FUNC(6); LongShortLapIllegal(pSpectralCoefficient,pOverlapAddData->pOverlapBuffer,outSamples, shortWindow,shortWindowPrev,longWindowPrev,stride); break; } PTR_INIT(3); FUNC(6); Lap2(&pSpectralCoefficient[Size10],&pSpectralCoefficient[Size08], &pOverlapAddData->pOverlapBuffer[Size01],shortWindow,Size01,1); PTR_INIT(3); FUNC(6); Lap2(&pSpectralCoefficient[Size12],&pSpectralCoefficient[Size10], &pOverlapAddData->pOverlapBuffer[Size03],shortWindow,Size01,1); PTR_INIT(3); FUNC(6); Lap2(&pSpectralCoefficient[Size14],&pSpectralCoefficient[Size12], &pOverlapAddData->pOverlapBuffer[Size05],shortWindow,Size01,1); PTR_INIT(2); /* pOverlapAddData->pOverlapBuffer[i+Size07] pSpectralCoefficient[Size14+i] */ LOOP(1); for (i=0; i<Size01; i++) { MOVE(1); pOverlapAddData->pOverlapBuffer[i+Size07] = pSpectralCoefficient[Size14+i]; } INDIRECT(1); PTR_INIT(1); FUNC(1); FUNC(1); STORE(2); pOverlapAddData->WindowShape = GetWindowShape(&pAacDecoderChannelInfo->IcsInfo); pOverlapAddData->WindowSequence = GetWindowSequence(&pAacDecoderChannelInfo->IcsInfo); COUNT_sub_end(); }
void CJointStereo_ApplyMS( CAacDecoderChannelInfo *pAacDecoderChannelInfo[2], const SHORT *pScaleFactorBandOffsets, const UCHAR *pWindowGroupLength, const int windowGroups, const int scaleFactorBandsTransmittedL, const int scaleFactorBandsTransmittedR ) { CJointStereoData *pJointStereoData = &pAacDecoderChannelInfo[L]->pComData->jointStereoData; int window, group, scaleFactorBandsTransmitted; FDK_ASSERT(scaleFactorBandsTransmittedL == scaleFactorBandsTransmittedR); scaleFactorBandsTransmitted = scaleFactorBandsTransmittedL; for (window = 0, group = 0; group < windowGroups; group++) { UCHAR groupMask = 1 << group; for (int groupwin=0; groupwin<pWindowGroupLength[group]; groupwin++, window++) { int band; FIXP_DBL *leftSpectrum, *rightSpectrum; SHORT *leftScale = &pAacDecoderChannelInfo[L]->pDynData->aSfbScale[window*16]; SHORT *rightScale = &pAacDecoderChannelInfo[R]->pDynData->aSfbScale[window*16]; leftSpectrum = SPEC(pAacDecoderChannelInfo[L]->pSpectralCoefficient, window, pAacDecoderChannelInfo[L]->granuleLength); rightSpectrum = SPEC(pAacDecoderChannelInfo[R]->pSpectralCoefficient, window, pAacDecoderChannelInfo[R]->granuleLength); for (band=0; band<scaleFactorBandsTransmitted; band++) { if (pJointStereoData->MsUsed[band] & groupMask) { int lScale=leftScale[band]; int rScale=rightScale[band]; int commonScale=lScale > rScale ? lScale:rScale; /* ISO/IEC 14496-3 Chapter 4.6.8.1.1 : M/S joint channel coding can only be used if common_window is ‘1’. */ FDK_ASSERT(GetWindowSequence(&pAacDecoderChannelInfo[L]->icsInfo) == GetWindowSequence(&pAacDecoderChannelInfo[R]->icsInfo)); FDK_ASSERT(GetWindowShape(&pAacDecoderChannelInfo[L]->icsInfo) == GetWindowShape(&pAacDecoderChannelInfo[R]->icsInfo)); commonScale++; leftScale[band]=commonScale; rightScale[band]=commonScale; lScale = fMin(DFRACT_BITS-1, commonScale - lScale); rScale = fMin(DFRACT_BITS-1, commonScale - rScale); FDK_ASSERT(lScale >= 0 && rScale >= 0); for (int index=pScaleFactorBandOffsets[band]; index<pScaleFactorBandOffsets[band+1]; index++) { FIXP_DBL leftCoefficient = leftSpectrum [index] ; FIXP_DBL rightCoefficient = rightSpectrum [index] ; leftCoefficient >>= lScale ; rightCoefficient >>= rScale ; leftSpectrum [index] = leftCoefficient + rightCoefficient ; rightSpectrum [index] = leftCoefficient - rightCoefficient ; } } } } }