Decodes the next Huffman code from bit-stream.
(int[] tableGroup, int tableIdx, State s)
| 411 | * Decodes the next Huffman code from bit-stream. |
| 412 | */ |
| 413 | private static int readSymbol(int[] tableGroup, int tableIdx, State s) { |
| 414 | int offset = tableGroup[tableIdx]; |
| 415 | final int v = BitReader.peekBits(s); |
| 416 | offset += v & HUFFMAN_TABLE_MASK; |
| 417 | final int bits = tableGroup[offset] >> 16; |
| 418 | final int sym = tableGroup[offset] & 0xFFFF; |
| 419 | if (bits <= HUFFMAN_TABLE_BITS) { |
| 420 | s.bitOffset += bits; |
| 421 | return sym; |
| 422 | } |
| 423 | offset += sym; |
| 424 | final int mask = (1 << bits) - 1; |
| 425 | offset += Utils.shr32(v & mask, HUFFMAN_TABLE_BITS); |
| 426 | s.bitOffset += ((tableGroup[offset] >> 16) + HUFFMAN_TABLE_BITS); |
| 427 | return tableGroup[offset] & 0xFFFF; |
| 428 | } |
| 429 | |
| 430 | private static int readBlockLength(int[] tableGroup, int tableIdx, State s) { |
| 431 | BitReader.fillBitWindow(s); |
no test coverage detected