public void decode(BitStream inStream, ICSInfo info, Profile profile) { lag = 0; if (profile.type == Profile.ProfileType.AAC_LD) { lagUpdate = inStream.readBool(); if (lagUpdate) { lag = inStream.readBits(10); } } else { lag = inStream.readBits(11); } if (lag > (frameLength << 1)) { throw new AACException("LTP lag too large: " + lag); } coef = inStream.readBits(3); int windowCount = info.getWindowCount(); if (info.isEightShortFrame()) { shortUsed = new bool[windowCount]; shortLagPresent = new bool[windowCount]; shortLag = new int[windowCount]; for (int w = 0; w < windowCount; w++) { if (shortUsed[w] = inStream.readBool()) { shortLagPresent[w] = inStream.readBool(); if (shortLagPresent[w]) { shortLag[w] = inStream.readBits(4); } } } } else { lastBand = Math.Min(info.getMaxSFB(), MAX_LTP_SFB); longUsed = new bool[lastBand]; for (int i = 0; i < lastBand; i++) { longUsed[i] = inStream.readBool(); } } }
// /* ========= decoding ========== */ public void decode(BitStream inStream, bool commonWindow, DecoderConfig conf) { if (conf.isScalefactorResilienceUsed() && rvlc == null) { rvlc = new RVLC(); } bool er = conf.getProfile().isErrorResilientProfile(); globalGain = inStream.readBits(8); if (!commonWindow) { info.decode(inStream, conf, commonWindow); } decodeSectionData(inStream, conf.isSectionDataResilienceUsed()); //if(conf.isScalefactorResilienceUsed()) rvlc.decode(in, this, scaleFactors); /*else*/ decodeScaleFactors(inStream); pulseDataPresent = inStream.readBool(); if (pulseDataPresent) { if (info.isEightShortFrame()) { throw new AACException("pulse data not allowed for short frames"); } Logger.LogInfo("PULSE"); throw new NotImplementedException(); //decodePulseData(inStream); } tnsDataPresent = inStream.readBool(); if (tnsDataPresent && !er) { if (tns == null) { tns = new TNS(); } tns.decode(inStream, info); } gainControlPresent = inStream.readBool(); if (gainControlPresent) { if (gainControl == null) { gainControl = new GainControl(frameLength); } Logger.LogInfo("GAIN"); throw new NotImplementedException(); // gainControl.decode(inStream, info.getWindowSequence()); } //RVLC spectral data //if(conf.isScalefactorResilienceUsed()) rvlc.decodeScalefactors(this, in, scaleFactors); if (conf.isSpectralDataResilienceUsed()) { int max = (conf.getChannelConfiguration() == ChannelConfiguration.CHANNEL_CONFIG_STEREO) ? 6144 : 12288; reorderedSpectralDataLen = Math.Max(inStream.readBits(14), max); longestCodewordLen = Math.Max(inStream.readBits(6), 49); //HCR.decodeReorderedSpectralData(this, in, data, conf.isSectionDataResilienceUsed()); } else { decodeSpectralData(inStream); } }