diff --git a/decode.go b/decode.go index 65198ca..a77a639 100644 --- a/decode.go +++ b/decode.go @@ -925,8 +925,8 @@ func readBlockLength(table []huffmanCode, br *bitReader) uint32 { var code uint32 var nbits uint32 code = readSymbol(table, br) - nbits = uint32(kBlockLengthPrefixCode1[code].nbits) /* nbits == 2..24 */ - return uint32(kBlockLengthPrefixCode1[code].offset) + readBits(br, nbits) + nbits = kBlockLengthPrefixCode[code].nbits /* nbits == 2..24 */ + return kBlockLengthPrefixCode[code].offset + readBits(br, nbits) } /* WARNING: if state is not BROTLI_STATE_READ_BLOCK_LENGTH_NONE, then @@ -942,14 +942,14 @@ func safeReadBlockLength(s *Reader, result *uint32, table []huffmanCode, br *bit } { var bits uint32 /* nbits == 2..24 */ - var nbits uint32 = uint32(kBlockLengthPrefixCode1[index].nbits) + var nbits uint32 = kBlockLengthPrefixCode[index].nbits if !safeReadBits(br, nbits, &bits) { s.block_length_index = index s.substate_read_block_length = BROTLI_STATE_READ_BLOCK_LENGTH_SUFFIX return false } - *result = uint32(kBlockLengthPrefixCode1[index].offset) + bits + *result = kBlockLengthPrefixCode[index].offset + bits s.substate_read_block_length = BROTLI_STATE_READ_BLOCK_LENGTH_NONE return true } diff --git a/prefix_dec.go b/prefix_dec.go index b24c8d0..1efe822 100644 --- a/prefix_dec.go +++ b/prefix_dec.go @@ -6,126 +6,6 @@ package brotli See file LICENSE for detail or copy at https://opensource.org/licenses/MIT */ -/* Lookup tables to map prefix codes to value ranges. This is used during - decoding of the block lengths, literal insertion lengths and copy lengths. */ - -/* Represents the range of values belonging to a prefix code: - [offset, offset + 2^nbits) */ -type prefixCodeRange1 struct { - offset uint16 - nbits byte -} - -var kBlockLengthPrefixCode1 = [numBlockLenSymbols]struct { - offset uint16 - nbits byte -}{ - struct { - offset uint16 - nbits byte - }{1, 2}, - struct { - offset uint16 - nbits byte - }{5, 2}, - struct { - offset uint16 - nbits byte - }{9, 2}, - struct { - offset uint16 - nbits byte - }{13, 2}, - struct { - offset uint16 - nbits byte - }{17, 3}, - struct { - offset uint16 - nbits byte - }{25, 3}, - struct { - offset uint16 - nbits byte - }{33, 3}, - struct { - offset uint16 - nbits byte - }{41, 3}, - struct { - offset uint16 - nbits byte - }{49, 4}, - struct { - offset uint16 - nbits byte - }{65, 4}, - struct { - offset uint16 - nbits byte - }{81, 4}, - struct { - offset uint16 - nbits byte - }{97, 4}, - struct { - offset uint16 - nbits byte - }{113, 5}, - struct { - offset uint16 - nbits byte - }{145, 5}, - struct { - offset uint16 - nbits byte - }{177, 5}, - struct { - offset uint16 - nbits byte - }{209, 5}, - struct { - offset uint16 - nbits byte - }{241, 6}, - struct { - offset uint16 - nbits byte - }{305, 6}, - struct { - offset uint16 - nbits byte - }{369, 7}, - struct { - offset uint16 - nbits byte - }{497, 8}, - struct { - offset uint16 - nbits byte - }{753, 9}, - struct { - offset uint16 - nbits byte - }{1265, 10}, - struct { - offset uint16 - nbits byte - }{2289, 11}, - struct { - offset uint16 - nbits byte - }{4337, 12}, - struct { - offset uint16 - nbits byte - }{8433, 13}, - struct { - offset uint16 - nbits byte - }{16625, 24}, -} - type CmdLutElement struct { insert_len_extra_bits byte copy_len_extra_bits byte