Files
wuffs/std/gif/decode_lzw.puffs
T

38 lines
764 B
Plaintext

pub struct lzw_decoder?(
literal_width u32[2..8] = 8,
stack[4096] u8,
suffixes[4096] u8,
prefixes[4096] u16,
)
pub func lzw_decoder.decode?(dst ptr buf1, src ptr buf1, src_final bool)() {
var bits u32
var n_bits u32
// TODO: set clear_code, end_code, etc.
var width u32[..12] = this.literal_width + 1
// TODO: implement.
while true,
pre n_bits < 8,
{
assert n_bits < (width + 8) via "a < (b + c): a < c; 0 <= b"()
while n_bits < width,
inv n_bits < (width + 8),
post n_bits >= width,
{
assert n_bits < 12 via "a < b: a < c; c <= b"(c:width)
bits |= in.src.read_u8?() as u32 // TODO
n_bits += 8
}
// TODO: var code u32[..4095] = bits.low_bits(width)
bits >>= width
n_bits -= width
// TODO: implement.
break
}
}