(br: BitReader, h: Huff)
| 145 | return { counts, symbols }; |
| 146 | } |
| 147 | function decodeSym(br: BitReader, h: Huff): number { |
| 148 | let code = 0, |
| 149 | first = 0, |
| 150 | index = 0; |
| 151 | for (let len = 1; len <= 15; len++) { |
| 152 | code |= br.bit(); |
| 153 | const count = h.counts[len]; |
| 154 | if (code - first < count) return h.symbols[index + (code - first)]; |
| 155 | index += count; |
| 156 | first += count; |
| 157 | first <<= 1; |
| 158 | code <<= 1; |
| 159 | } |
| 160 | throw new PackParseError("bad huffman code"); |
| 161 | } |
| 162 | const LEN_BASE = [ |
| 163 | 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, |
| 164 | 163, 195, 227, 258, |