mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-19 16:47:28 +01:00
Restore deflate.decoder.n_huffs_bits's refinement
This commit is contained in:
1 parent
b075fcbed9
commit
5aeb98c701
5 files changed
+20
-28
No files matched your search
@@ -69,6 +69,9 @@ pub struct decoder?(
|
||||
// history_index indexes the history array, defined below.
|
||||
history_index base.u32,
|
||||
|
||||
// n_huffs_bits is discussed in the huffs field comment.
|
||||
n_huffs_bits array[2] base.u32[..9],
|
||||
|
||||
// end_of_block is whether decode_huffman_xxx saw an end-of-block code.
|
||||
//
|
||||
// TODO: can decode_huffman_xxx signal this in band instead of out of band?
|
||||
@@ -106,8 +109,7 @@ pub struct decoder?(
|
||||
// - bits 3 .. 0 are the number of decoder.bits to consume.
|
||||
//
|
||||
// Exactly one of the eight bits 31-24 should be set.
|
||||
huffs array[2] array[huffs_table_size] base.u32,
|
||||
n_huffs_bits array[2] base.u32,
|
||||
huffs array[2] array[huffs_table_size] base.u32,
|
||||
|
||||
// history holds up to the last 32KiB of decoded output, if the decoding
|
||||
// was incomplete (e.g. due to a short read or write). RFC 1951 (DEFLATE)
|
||||
@@ -389,7 +391,7 @@ pri func decoder.init_dynamic_huffman?(src base.io_reader) {
|
||||
}
|
||||
|
||||
// Decode the code lengths for the next two Huffman tables.
|
||||
mask = ((1 as base.u32) << (this.n_huffs_bits[0].min(x:9))) - 1
|
||||
mask = ((1 as base.u32) << (this.n_huffs_bits[0])) - 1
|
||||
i = 0
|
||||
while i < (n_lit + n_dist) {
|
||||
assert i < (288 + 32) via "a < (b + c): a < (b0 + c0); b0 <= b; c0 <= c"(b0:n_lit, c0:n_dist)
|
||||
|
||||
@@ -41,8 +41,8 @@ pri func decoder.decode_huffman_fast!(dst base.io_writer, src base.io_reader) ba
|
||||
bits = this.bits
|
||||
n_bits = this.n_bits
|
||||
|
||||
lmask = ((1 as base.u32) << this.n_huffs_bits[0].min(x:9)) - 1
|
||||
dmask = ((1 as base.u32) << this.n_huffs_bits[1].min(x:9)) - 1
|
||||
lmask = ((1 as base.u32) << this.n_huffs_bits[0]) - 1
|
||||
dmask = ((1 as base.u32) << this.n_huffs_bits[1]) - 1
|
||||
|
||||
// Check up front, on each iteration, that we have enough buffer space to
|
||||
// both read (12 bytes) and write (258 bytes) as much as we need to. Doing
|
||||
|
||||
@@ -45,8 +45,8 @@ pri func decoder.decode_huffman_slow?(dst base.io_writer, src base.io_reader) {
|
||||
bits = this.bits
|
||||
n_bits = this.n_bits
|
||||
|
||||
lmask = ((1 as base.u32) << this.n_huffs_bits[0].min(x:9)) - 1
|
||||
dmask = ((1 as base.u32) << this.n_huffs_bits[1].min(x:9)) - 1
|
||||
lmask = ((1 as base.u32) << this.n_huffs_bits[0]) - 1
|
||||
dmask = ((1 as base.u32) << this.n_huffs_bits[1]) - 1
|
||||
|
||||
while:loop not coroutine_resumed {
|
||||
// Decode an lcode symbol from H-L.
|
||||
|
||||
Reference in new issue
Block a user