mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 16:32:11 +01:00
Prepare decode_huffman_fast to rewind in.src.
This commit is contained in:
1 parent
3099991d7f
commit
325c36314a
3 files changed
+22
-1
No files matched your search
@@ -2328,6 +2328,9 @@ static puffs_flate__status puffs_flate__flate_decoder__decode_huffman_fast(
|
||||
label_6_break:;
|
||||
}
|
||||
label_0_break:;
|
||||
while (v_n_bits >= 8) {
|
||||
v_n_bits -= 8;
|
||||
}
|
||||
self->private_impl.f_bits = v_bits;
|
||||
self->private_impl.f_n_bits = v_n_bits;
|
||||
if (self->private_impl.f_n_bits >= 8) {
|
||||
|
||||
@@ -291,7 +291,23 @@ pri func flate_decoder.decode_huffman_fast?(dst writer1, src reader1)() {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: unread some in.src bytes if n_bits >= 8?
|
||||
// Ensure n_bits < 8 by rewindng in.src, if we loaded too many of its bytes
|
||||
// into the bits variable.
|
||||
//
|
||||
// Note that we can unconditionally call unread_u8 (without resulting in an
|
||||
// "invalid I/O operation" error code) only because this whole function can
|
||||
// never suspend, as all of its I/O operations were checked beforehand for
|
||||
// sufficient buffer space. Otherwise, resuming from the suspension could
|
||||
// mean that the (possibly different) in.src is no longer rewindable, even
|
||||
// if conceptually, this function was responsible for reading the bytes we
|
||||
// want to rewind.
|
||||
//
|
||||
// TODO: have the compiler enforce (via some explicit syntax) that this
|
||||
// function is ProvenNotToSuspend?
|
||||
while n_bits >= 8 {
|
||||
n_bits -= 8
|
||||
// TODO: in.src.unread_u8?()
|
||||
}
|
||||
|
||||
this.bits = bits
|
||||
this.n_bits = n_bits
|
||||
|
||||
@@ -252,6 +252,8 @@ pri func flate_decoder.decode_huffman_slow?(dst writer1, src reader1)() {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: "assert n_bits < 8"?
|
||||
|
||||
this.bits = bits
|
||||
this.n_bits = n_bits
|
||||
|
||||
|
||||
Reference in new issue
Block a user