/** * Layer III scalefactor and Huffman decoding. * * This is where a granule's 576 frequency lines come from. Three regions, coded * differently because their statistics differ: * * 1. **big_values** — the low and mid frequencies, where real energy lives. * Coded as (x, y) pairs from one of 32 Huffman tables, chosen per region. * 2. **count1** — the high-frequency tail, where almost everything has quantized * to -1, 0, or +1. Coded as quadruples, since a general table would waste bits * on values that never occur. * 3. **rzero** — everything above that is implicitly zero and costs nothing. * * The decoder does not know where count1 ends; it decodes until the granule's * declared `part2_3_length` bits are consumed. That is why {@link decodeHuffman} * takes a bit limit rather than a count. */ import { BitReader } from '../io/bits.js'; import type { GranuleInfo } from './sideinfo.js'; /** Decoded scalefactors for one granule and channel. */ export interface Scalefactors { /** Per scalefactor band, for long blocks. 22 entries. */ long: Int32Array; /** Per band per window, for short blocks. `short[window][band]`, 13 bands. */ short: Int32Array[]; } /** Allocates a reusable scalefactor structure. */ export declare function createScalefactors(): Scalefactors; /** * Decodes MPEG-1 scalefactors. * * `scfsi` lets granule 1 reuse granule 0's scalefactors for a band group rather * than retransmitting them — a meaningful saving, since scalefactors are sent * for every granule otherwise. */ export declare function decodeScalefactorsMpeg1(br: BitReader, granule: GranuleInfo, scfsi: number[], granuleIndex: number, previous: Scalefactors, out: Scalefactors): number; /** * Decodes MPEG-2 / 2.5 scalefactors. * * A different scheme entirely: `scalefac_compress` is 9 bits and encodes both the * band partitioning and the bit widths, rather than indexing a small table. */ export declare function decodeScalefactorsMpeg2(br: BitReader, granule: GranuleInfo, isIntensityRight: boolean, out: Scalefactors): number; export interface HuffmanResult { /** Quantized values, signed. Always 576 entries. */ values: Int32Array; /** Index one past the last non-zero value. */ nonZeroCount: number; /** Bits actually consumed. */ bitsUsed: number; } /** * Decodes one granule's quantized frequency lines. * * @param br Positioned at the start of this granule's Huffman data. * @param maxBits `part2_3_length` minus the scalefactor bits already read. */ export declare function decodeHuffman(br: BitReader, granule: GranuleInfo, sampleRate: number, maxBits: number, out: Int32Array): HuffmanResult; //# sourceMappingURL=huffman.d.ts.map