void decodeSinusoidal(BitStream in, SBRHeader header, FrequencyTables tables) throws AACException { if (sinusoidalsPresent = in.readBool()) { for (int i = 0; i < tables.getN(HIGH); i++) { sinusoidals[i] = in.readBool(); } } else Arrays.fill(sinusoidals, false); }
void decodeNoise( BitStream in, SBRHeader header, FrequencyTables tables, boolean secCh, boolean coupling) throws AACException { // select huffman codebooks final int[][] tHuff, fHuff; final int tLav, fLav; final int delta; if (coupling && secCh) { delta = 1; tHuff = T_HUFFMAN_NOISE_BAL_3_0; tLav = T_HUFFMAN_NOISE_BAL_3_0_LAV; fHuff = F_HUFFMAN_NOISE_BAL_3_0; fLav = F_HUFFMAN_NOISE_BAL_3_0_LAV; } else { delta = 0; tHuff = T_HUFFMAN_NOISE_3_0; tLav = T_HUFFMAN_NOISE_3_0_LAV; fHuff = F_HUFFMAN_NOISE_3_0; fLav = F_HUFFMAN_NOISE_3_0_LAV; } // read huffman data: i=noise, j=band final int noiseBands = tables.getNq(); int j; float[] prev; for (int i = 0; i < noiseCount; i++) { if (dfNoise[i]) { prev = (i == 0) ? noiseFDPrevious : noiseFloorData[i - 1]; for (j = 0; j < noiseBands; j++) { noiseFloorData[i][j] = prev[j] + ((decodeHuffman(in, tHuff) - tLav) << delta); } } else { noiseFloorData[i][0] = in.readBits(5) << delta; for (j = 1; j < noiseBands; j++) { noiseFloorData[i][j] = noiseFloorData[i][j - 1] + ((decodeHuffman(in, fHuff) - fLav) << delta); } } } // save for next frame System.arraycopy(noiseFloorData[noiseCount - 1], 0, noiseFDPrevious, 0, MAX_BANDS); }
void decodeEnvelope( BitStream in, SBRHeader header, FrequencyTables tables, boolean secCh, boolean coupling) throws AACException { // select huffman codebooks final int[][] tHuff, fHuff; final int tLav, fLav; final int delta, bits; if (coupling && secCh) { delta = 1; if (ampRes) { bits = 5; tHuff = T_HUFFMAN_ENV_BAL_3_0; tLav = T_HUFFMAN_ENV_BAL_3_0_LAV; fHuff = F_HUFFMAN_ENV_BAL_3_0; fLav = F_HUFFMAN_ENV_BAL_3_0_LAV; } else { bits = 6; tHuff = T_HUFFMAN_ENV_BAL_1_5; tLav = T_HUFFMAN_ENV_BAL_1_5_LAV; fHuff = F_HUFFMAN_ENV_BAL_1_5; fLav = F_HUFFMAN_ENV_BAL_1_5_LAV; } } else { delta = 0; if (ampRes) { bits = 6; tHuff = T_HUFFMAN_ENV_3_0; tLav = T_HUFFMAN_ENV_3_0_LAV; fHuff = F_HUFFMAN_ENV_3_0; fLav = F_HUFFMAN_ENV_3_0_LAV; } else { bits = 7; tHuff = T_HUFFMAN_ENV_1_5; tLav = T_HUFFMAN_ENV_1_5_LAV; fHuff = F_HUFFMAN_ENV_1_5; fLav = F_HUFFMAN_ENV_1_5_LAV; } } // read delta coded huffman data final int[] envBands = tables.getN(); final int odd = envBands[1] & 1; int j, k, frPrev; float[] prev; for (int i = 0; i < envCount; i++) { prev = (i == 0) ? envelopeSFPrevious : envelopeSF[i - 1]; frPrev = (i == 0) ? freqResPrevious : freqRes[i - 1]; if (dfEnv[i]) { if (freqRes[i] == frPrev) { for (j = 0; j < envBands[freqRes[i]]; j++) { envelopeSF[i][j] = prev[j] + ((decodeHuffman(in, tHuff) - tLav) << delta); } } else if (freqRes[i] == 1) { for (j = 0; j < envBands[freqRes[i]]; j++) { k = (j + odd) >> 1; // fLow[k] <= fHigh[j] < fLow[k + 1] envelopeSF[i][j] = prev[k] + ((decodeHuffman(in, tHuff) - tLav) << delta); } } else { for (j = 0; j < envBands[freqRes[i]]; j++) { k = (j != 0) ? (2 * j - odd) : 0; // fHigh[k] == fLow[j] envelopeSF[i][j] = prev[k] + ((decodeHuffman(in, tHuff) - tLav) << delta); } } } else { envelopeSF[i][0] = in.readBits(bits) << delta; for (j = 1; j < envBands[freqRes[i]]; j++) { envelopeSF[i][j] = envelopeSF[i][j - 1] + ((decodeHuffman(in, fHuff) - fLav) << delta); } } } // save for next frame System.arraycopy(envelopeSF[envCount - 1], 0, envelopeSFPrevious, 0, MAX_BANDS); }
void decodeInvf(BitStream in, SBRHeader header, FrequencyTables tables) throws AACException { for (int i = 0; i < tables.getNq(); i++) { invfMode[i] = in.readBits(2); } }