diff options
| author | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2022-01-25 12:18:10 +0100 |
|---|---|---|
| committer | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2022-01-25 12:18:10 +0100 |
| commit | 65f8722afc0680b7b7fa47fd7060fd434243ae3c (patch) | |
| tree | b593906121d100d6f99c1ee0b154e11736d45960 | |
| parent | c0479f1564119603f022f5f3d22dd8dc3a1e5983 (diff) | |
zlib: update Huffman builder.
| -rw-r--r-- | core/compress/zlib/zlib.odin | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/core/compress/zlib/zlib.odin b/core/compress/zlib/zlib.odin index 9ae980042..4d575c7e6 100644 --- a/core/compress/zlib/zlib.odin +++ b/core/compress/zlib/zlib.odin @@ -111,9 +111,9 @@ ZFAST_MASK :: ((1 << ZFAST_BITS) - 1) */ Huffman_Table :: struct { fast: [1 << ZFAST_BITS]u16, - firstcode: [16]u16, + firstcode: [17]u16, maxcode: [17]int, - firstsymbol: [16]u16, + firstsymbol: [17]u16, size: [288]u8, value: [288]u16, } @@ -244,7 +244,7 @@ allocate_huffman_table :: proc(allocator := context.allocator) -> (z: ^Huffman_T @(optimization_mode="speed") build_huffman :: proc(z: ^Huffman_Table, code_lengths: []u8) -> (err: Error) { sizes: [HUFFMAN_MAX_BITS+1]int - next_code: [HUFFMAN_MAX_BITS]int + next_code: [HUFFMAN_MAX_BITS+1]int k := int(0) @@ -256,14 +256,14 @@ build_huffman :: proc(z: ^Huffman_Table, code_lengths: []u8) -> (err: Error) { } sizes[0] = 0 - for i in 1..<(HUFFMAN_MAX_BITS+1) { + for i in 1 ..< HUFFMAN_MAX_BITS { if sizes[i] > (1 << uint(i)) { return E_Deflate.Huffman_Bad_Sizes } } code := int(0) - for i in 1..<HUFFMAN_MAX_BITS { + for i in 1 ..= HUFFMAN_MAX_BITS { next_code[i] = code z.firstcode[i] = u16(code) z.firstsymbol[i] = u16(k) |