AAC_DECODER_ERROR CBlock_ReadScaleFactorData( CAacDecoderChannelInfo *pAacDecoderChannelInfo, HANDLE_FDK_BITSTREAM bs, UINT flags ) { int temp; int band; int group; int position = 0; /* accu for intensity delta coding */ int factor = pAacDecoderChannelInfo->pDynData->RawDataInfo.GlobalGain; /* accu for scale factor delta coding */ UCHAR *pCodeBook = pAacDecoderChannelInfo->pDynData->aCodeBook; SHORT *pScaleFactor = pAacDecoderChannelInfo->pDynData->aScaleFactor; const CodeBookDescription *hcb =&AACcodeBookDescriptionTable[BOOKSCL]; int ScaleFactorBandsTransmitted = GetScaleFactorBandsTransmitted(&pAacDecoderChannelInfo->icsInfo); for (group=0; group < GetWindowGroups(&pAacDecoderChannelInfo->icsInfo); group++) { for (band=0; band < ScaleFactorBandsTransmitted; band++) { switch (pCodeBook[group*16+band]) { case ZERO_HCB: /* zero book */ pScaleFactor[group*16+band] = 0; break; default: /* decode scale factor */ { temp = CBlock_DecodeHuffmanWord(bs,hcb); factor += temp - 60; /* MIDFAC 1.5 dB */ } pScaleFactor[group*16+band] = factor - 100; break; case INTENSITY_HCB: /* intensity steering */ case INTENSITY_HCB2: temp = CBlock_DecodeHuffmanWord(bs,hcb); position += temp - 60; pScaleFactor[group*16+band] = position - 100; break; case NOISE_HCB: /* PNS */ if (flags & (AC_MPS_RES|AC_USAC|AC_RSVD50)) { return AAC_DEC_PARSE_ERROR; } CPns_Read( &pAacDecoderChannelInfo->data.aac.PnsData, bs, hcb, pAacDecoderChannelInfo->pDynData->aScaleFactor, pAacDecoderChannelInfo->pDynData->RawDataInfo.GlobalGain, band, group); break; } } } return AAC_DEC_OK; }
void CShortBlock_ReadScaleFactorData(HANDLE_BIT_BUF bs, CAacDecoderChannelInfo *pAacDecoderChannelInfo, unsigned char global_gain) { int temp; int band; int group; int position = 0; int factor = global_gain; char *pCodeBook = pAacDecoderChannelInfo->pCodeBook; short *pScaleFactor = pAacDecoderChannelInfo->pScaleFactor; const CodeBookDescription *hcb = &HuffmanCodeBooks[BOOKSCL]; COUNT_sub_start("CShortBlock_ReadScaleFactorData"); INDIRECT(3); PTR_INIT(3); MOVE(2); /* counting previous operations */ INDIRECT(1); PTR_INIT(1); FUNC(1); LOOP(1); for (group=0; group < GetWindowGroups(&pAacDecoderChannelInfo->IcsInfo); group++) { PTR_INIT(2); /* pCodeBook[] pScaleFactor[] */ for (band=0; band < GetScaleFactorBandsTransmitted(&pAacDecoderChannelInfo->IcsInfo); band++) { BRANCH(2); switch (pCodeBook[group*MaximumScaleFactorBandsShort+band]) { case ZERO_HCB: /* zero book */ MOVE(1); pScaleFactor[group*MaximumScaleFactorBandsShort+band] = 0; break; default: /* decode scale factor */ INDIRECT(1); FUNC(2); temp = CBlock_DecodeHuffmanWord(bs,hcb->CodeBook); ADD(2); factor += temp - 60; /* MIDFAC 1.5 dB */ ADD(1); STORE(1); pScaleFactor[group*MaximumScaleFactorBandsShort+band] = factor - 100; break; case INTENSITY_HCB: /* intensity steering */ case INTENSITY_HCB2: INDIRECT(1); FUNC(2); temp = CBlock_DecodeHuffmanWord(bs,hcb->CodeBook); ADD(2); position += temp - 60; ADD(1); STORE(1); pScaleFactor[group*MaximumScaleFactorBandsShort+band] = position - 100; break; case NOISE_HCB: /* PNS */ FUNC(5); CPns_Read(pAacDecoderChannelInfo, bs, hcb, global_gain, band, group); break; } } } COUNT_sub_end(); }