mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 16:32:11 +01:00
Add save_code to std/gif/decode_lzw.puffs.
This commit is contained in:
1 parent
3863427127
commit
0b034d7f6e
2 files changed
+20
-7
No files matched your search
@@ -13,13 +13,17 @@ pub struct lzw_decoder?(
|
||||
)
|
||||
|
||||
pub func lzw_decoder.decode?(dst ptr buf1, src ptr buf1, src_final bool)() {
|
||||
var bits u32
|
||||
var n_bits u32
|
||||
// These variables don't change over the lifetime of this func.
|
||||
var clear_code u32[4..256] = (1 as u32) << this.literal_width
|
||||
var end_code u32[5..257] = clear_code + 1
|
||||
|
||||
// These variables do change.
|
||||
var save_code u32[..4095] = end_code
|
||||
var width u32[..12] = this.literal_width + 1
|
||||
|
||||
// TODO: implement.
|
||||
// These variables yield src's bits in Least Significant Bits order.
|
||||
var bits u32
|
||||
var n_bits u32
|
||||
|
||||
while true,
|
||||
pre n_bits < 8,
|
||||
@@ -40,10 +44,13 @@ pub func lzw_decoder.decode?(dst ptr buf1, src ptr buf1, src_final bool)() {
|
||||
if code < clear_code {
|
||||
break
|
||||
} else if code == clear_code {
|
||||
save_code = end_code
|
||||
width = this.literal_width + 1
|
||||
continue
|
||||
} else if code == end_code {
|
||||
return
|
||||
} else if code <= save_code {
|
||||
return
|
||||
} else {
|
||||
return error "bad GIF image"
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user