mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-19 08:38:14 +01:00
Remove use of struct field initial values
This commit is contained in:
1 parent
7a4f6e9e1f
commit
0e498cb86d
10 files changed
+53
-26
No files matched your search
@@ -16,13 +16,19 @@ packageid "adl3"
|
||||
|
||||
// TODO: drop the '?' but still generate wuffs_adler32__hasher__initialize?
|
||||
pub struct hasher?(
|
||||
state base.u32 = 1,
|
||||
state base.u32,
|
||||
started base.bool,
|
||||
)
|
||||
|
||||
pub func hasher.update!(x slice base.u8)(checksum base.u32) {
|
||||
// The Adler-32 checksum's magic 65521 and 5552 numbers are discussed in
|
||||
// RFC 1950.
|
||||
|
||||
if not this.started {
|
||||
this.started = true
|
||||
this.state = 1
|
||||
}
|
||||
|
||||
var s1 base.u32 = this.state.low_bits(n:16)
|
||||
var s2 base.u32 = this.state.high_bits(n:16)
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ pub struct decoder?(
|
||||
// Absent an ANIMEXTS1.0 or NETSCAPE2.0 extension, the implicit number of
|
||||
// animation loops is 1.
|
||||
seen_num_loops base.bool,
|
||||
num_loops base.u32 = 1,
|
||||
num_loops base.u32,
|
||||
|
||||
seen_graphic_control base.bool,
|
||||
gc_has_transparent_index base.bool,
|
||||
@@ -92,12 +92,17 @@ pub func decoder.decode_config?(dst ptr base.image_config, src base.io_reader)()
|
||||
|
||||
// TODO: if this.end_of_data, return an error and/or set dst to zero?
|
||||
|
||||
var num_loops base.u32 = 1
|
||||
if this.seen_num_loops {
|
||||
num_loops = this.num_loops
|
||||
}
|
||||
|
||||
// TODO: rename initialize to set?
|
||||
//
|
||||
// TODO: a Wuffs (not just C) name for the
|
||||
// WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL_INDEXED magic pixfmt constant.
|
||||
in.dst.initialize!(pixfmt:0x22088888, pixsub:0,
|
||||
width:this.width, height:this.height, num_loops:this.num_loops)
|
||||
width:this.width, height:this.height, num_loops:num_loops)
|
||||
|
||||
this.call_sequence = 1
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ pub error "LZW code is out of range"
|
||||
pub error "LZW prefix chain is cyclical"
|
||||
|
||||
pri struct lzw_decoder?(
|
||||
literal_width base.u32[2..8] = 8,
|
||||
literal_width base.u32[..8],
|
||||
stack array[4096] base.u8,
|
||||
suffixes array[4096] base.u8,
|
||||
prefixes array[4096] base.u16[..4095],
|
||||
@@ -30,7 +30,11 @@ pri func lzw_decoder.set_literal_width!(lw base.u32[2..8] = 8)() {
|
||||
|
||||
pri func lzw_decoder.decode?(dst base.io_writer, src base.io_reader)() {
|
||||
// These variables don't change over the lifetime of this func.
|
||||
var clear_code base.u32[4..256] = (1 as base.u32) << this.literal_width
|
||||
var literal_width base.u32[2..8] = 8
|
||||
if this.literal_width >= 2 {
|
||||
literal_width = this.literal_width
|
||||
}
|
||||
var clear_code base.u32[4..256] = (1 as base.u32) << literal_width
|
||||
var end_code base.u32[5..257] = clear_code + 1
|
||||
|
||||
// These variables do change.
|
||||
@@ -40,8 +44,7 @@ pri func lzw_decoder.decode?(dst base.io_writer, src base.io_reader)() {
|
||||
// `max`. 4096 means do not save.
|
||||
var save_code base.u32[..4096] = end_code
|
||||
var prev_code base.u32[..4095]
|
||||
var initial_width base.u32[..12] = this.literal_width + 1
|
||||
var width base.u32[..12] = initial_width
|
||||
var width base.u32[..12] = literal_width + 1
|
||||
|
||||
// These variables yield src's bits in Least Significant Bits order.
|
||||
var bits base.u32
|
||||
@@ -74,7 +77,7 @@ pri func lzw_decoder.decode?(dst base.io_writer, src base.io_reader)() {
|
||||
} else if code == clear_code {
|
||||
save_code = end_code
|
||||
prev_code = 0
|
||||
width = initial_width
|
||||
width = literal_width + 1
|
||||
continue
|
||||
|
||||
} else if code == end_code {
|
||||
|
||||
Reference in new issue
Block a user