mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-23 08:47:56 +01:00
lang: remove endwhile keyword
This commit is contained in:
1 parent
6c8a43390b
commit
aae5997e12
56 files changed
+578
-590
No files matched your search
@@ -21,9 +21,9 @@ pri func decoder.decode_huffman_groups?(src: base.io_reader, n_huffman_groups: b
|
||||
{
|
||||
this.decode_huffman_tree?(src: args.src, hg: hg, ht: ht)
|
||||
ht += 1
|
||||
} endwhile
|
||||
}
|
||||
hg += 1
|
||||
} endwhile
|
||||
}
|
||||
}
|
||||
|
||||
pri func decoder.decode_huffman_tree?(src: base.io_reader, hg: base.u32[..= 255], ht: base.u32[..= 4]) {
|
||||
@@ -170,11 +170,11 @@ pri func decoder.decode_code_length_code_lengths?(src: base.io_reader) {
|
||||
this.n_bits -= 3
|
||||
|
||||
i += 1
|
||||
} endwhile
|
||||
}
|
||||
while i < 19 {
|
||||
this.code_length_code_lengths[CODE_LENGTH_CODE_ORDER[i]] = 0
|
||||
i += 1
|
||||
} endwhile
|
||||
}
|
||||
}
|
||||
|
||||
pri func decoder.build_code_lengths_huffman_nodes!() base.status {
|
||||
@@ -205,7 +205,7 @@ pri func decoder.build_code_lengths_huffman_nodes!() base.status {
|
||||
last_used_symbol = symbol
|
||||
}
|
||||
symbol += 1
|
||||
} endwhile
|
||||
}
|
||||
|
||||
if n_used_symbols < 1 {
|
||||
return "#bad Huffman code"
|
||||
@@ -225,7 +225,7 @@ pri func decoder.build_code_lengths_huffman_nodes!() base.status {
|
||||
break
|
||||
}
|
||||
code_len += 1
|
||||
} endwhile
|
||||
}
|
||||
|
||||
if subscription_total > (1 << 15) {
|
||||
return "#bad Huffman code (over-subscribed)"
|
||||
@@ -262,11 +262,11 @@ pri func decoder.build_code_lengths_huffman_nodes!() base.status {
|
||||
}
|
||||
code_bits ~mod<<= 1
|
||||
code_len -= 1
|
||||
} endwhile
|
||||
}
|
||||
this.code_lengths_huffman_nodes[h] = (symbol | 0x8000) as base.u16
|
||||
}
|
||||
symbol += 1
|
||||
} endwhile
|
||||
}
|
||||
return ok
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ pri func decoder.build_huffman_nodes!(hg: base.u32[..= 255], ht: base.u32[..= 4]
|
||||
last_used_symbol = symbol
|
||||
}
|
||||
symbol += 1
|
||||
} endwhile
|
||||
}
|
||||
|
||||
if n_used_symbols < 1 {
|
||||
return "#bad Huffman code"
|
||||
@@ -323,7 +323,7 @@ pri func decoder.build_huffman_nodes!(hg: base.u32[..= 255], ht: base.u32[..= 4]
|
||||
break
|
||||
}
|
||||
code_len += 1
|
||||
} endwhile
|
||||
}
|
||||
|
||||
if subscription_total > (1 << 15) {
|
||||
return "#bad Huffman code (over-subscribed)"
|
||||
@@ -361,11 +361,11 @@ pri func decoder.build_huffman_nodes!(hg: base.u32[..= 255], ht: base.u32[..= 4]
|
||||
}
|
||||
code_bits ~mod<<= 1
|
||||
code_len -= 1
|
||||
} endwhile
|
||||
}
|
||||
this.huffman_nodes[args.hg][h] = (symbol | 0x8000) as base.u16
|
||||
}
|
||||
symbol += 1
|
||||
} endwhile
|
||||
}
|
||||
return ok
|
||||
}
|
||||
|
||||
@@ -418,7 +418,7 @@ pri func decoder.build_code_lengths?(src: base.io_reader) {
|
||||
assert this.n_bits < 16 via "a < b: a < c; c <= b"(c: length_n_bits)
|
||||
this.bits |= (c8 as base.u32) << this.n_bits
|
||||
this.n_bits += 8
|
||||
} endwhile
|
||||
}
|
||||
length = (this.bits & (((1 as base.u32) << length_n_bits) - 1)) + 2
|
||||
this.bits >>= length_n_bits
|
||||
this.n_bits -= length_n_bits
|
||||
@@ -438,7 +438,7 @@ pri func decoder.build_code_lengths?(src: base.io_reader) {
|
||||
assert s < 2328 via "a < b: a < c; c <= b"(c: this.ht_n_symbols)
|
||||
this.code_lengths[s] = 0
|
||||
s += 1
|
||||
} endwhile
|
||||
}
|
||||
break
|
||||
}
|
||||
this.ht_code_lengths_remaining -= 1
|
||||
@@ -462,7 +462,7 @@ pri func decoder.build_code_lengths?(src: base.io_reader) {
|
||||
h = (node as base.u32) + (this.bits & 1)
|
||||
this.bits >>= 1
|
||||
this.n_bits -= 1
|
||||
} endwhile
|
||||
}
|
||||
|
||||
symbol = (node & 0x7FFF) as base.u32
|
||||
if symbol == 0 {
|
||||
@@ -509,8 +509,8 @@ pri func decoder.build_code_lengths?(src: base.io_reader) {
|
||||
assert s < 2328 via "a < b: a < c; c <= b"(c: s_max)
|
||||
this.code_lengths[s] = repeat_value
|
||||
s += 1
|
||||
} endwhile
|
||||
} endwhile
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pri const CODE_LENGTH_CODE_ORDER : roarray[19] base.u8[..= 18] = [
|
||||
|
||||
@@ -88,7 +88,7 @@ pri func decoder.decode_pixels_slow?(dst: slice base.u8, src: base.io_reader, wi
|
||||
h = (node as base.u32) + (this.bits & 1)
|
||||
this.bits >>= 1
|
||||
this.n_bits -= 1
|
||||
} endwhile
|
||||
}
|
||||
pixel_g = (node & 0x7FFF) as base.u32
|
||||
|
||||
if pixel_g < 0x100 { // Literal pixel.
|
||||
@@ -112,7 +112,7 @@ pri func decoder.decode_pixels_slow?(dst: slice base.u8, src: base.io_reader, wi
|
||||
h = ((node as base.u32) & 0xFFF) + (this.bits & 1)
|
||||
this.bits >>= 1
|
||||
this.n_bits -= 1
|
||||
} endwhile
|
||||
}
|
||||
color |= ((node & 0xFF) as base.u32) << 16
|
||||
|
||||
// Decode the Blue symbol.
|
||||
@@ -133,7 +133,7 @@ pri func decoder.decode_pixels_slow?(dst: slice base.u8, src: base.io_reader, wi
|
||||
h = ((node as base.u32) & 0xFFF) + (this.bits & 1)
|
||||
this.bits >>= 1
|
||||
this.n_bits -= 1
|
||||
} endwhile
|
||||
}
|
||||
color |= ((node & 0xFF) as base.u32) << 0
|
||||
|
||||
// Decode the Alpha symbol.
|
||||
@@ -154,7 +154,7 @@ pri func decoder.decode_pixels_slow?(dst: slice base.u8, src: base.io_reader, wi
|
||||
h = ((node as base.u32) & 0xFFF) + (this.bits & 1)
|
||||
this.bits >>= 1
|
||||
this.n_bits -= 1
|
||||
} endwhile
|
||||
}
|
||||
color |= ((node & 0xFF) as base.u32) << 24
|
||||
|
||||
} else if pixel_g < 0x118 { // Back-ref pixel.
|
||||
@@ -177,7 +177,7 @@ pri func decoder.decode_pixels_slow?(dst: slice base.u8, src: base.io_reader, wi
|
||||
assert this.n_bits < 12 via "a < b: a < c; c <= b"(c: back_ref_len_n_bits)
|
||||
this.bits |= (c8 as base.u32) << this.n_bits
|
||||
this.n_bits += 8
|
||||
} endwhile
|
||||
}
|
||||
back_ref_len_minus_1 += this.bits & (((1 as base.u32) << back_ref_len_n_bits) - 1)
|
||||
this.bits >>= back_ref_len_n_bits
|
||||
this.n_bits -= back_ref_len_n_bits
|
||||
@@ -202,7 +202,7 @@ pri func decoder.decode_pixels_slow?(dst: slice base.u8, src: base.io_reader, wi
|
||||
h = ((node as base.u32) & 0xFFF) + (this.bits & 1)
|
||||
this.bits >>= 1
|
||||
this.n_bits -= 1
|
||||
} endwhile
|
||||
}
|
||||
back_ref_dist_sym = (node & 0x7FFF) as base.u32
|
||||
|
||||
if back_ref_dist_sym < 4 {
|
||||
@@ -223,7 +223,7 @@ pri func decoder.decode_pixels_slow?(dst: slice base.u8, src: base.io_reader, wi
|
||||
assert this.n_bits < 24 via "a < b: a < c; c <= b"(c: back_ref_dist_n_bits)
|
||||
this.bits |= (c8 as base.u32) << this.n_bits
|
||||
this.n_bits += 8
|
||||
} endwhile
|
||||
}
|
||||
back_ref_dist_premap_minus_1 += this.bits & (((1 as base.u32) << back_ref_dist_n_bits) - 1)
|
||||
this.bits >>= back_ref_dist_n_bits
|
||||
this.n_bits -= back_ref_dist_n_bits
|
||||
@@ -257,14 +257,14 @@ pri func decoder.decode_pixels_slow?(dst: slice base.u8, src: base.io_reader, wi
|
||||
args.dst[p] = args.dst[q]
|
||||
p += 1
|
||||
q += 1
|
||||
} endwhile
|
||||
}
|
||||
|
||||
// Update (x, y).
|
||||
x ~mod+= back_ref_len_minus_1 + 1
|
||||
while x >= args.width {
|
||||
x -= args.width
|
||||
y ~mod+= 1
|
||||
} endwhile
|
||||
}
|
||||
continue
|
||||
|
||||
} else { // Color cache pixel.
|
||||
@@ -281,7 +281,7 @@ pri func decoder.decode_pixels_slow?(dst: slice base.u8, src: base.io_reader, wi
|
||||
color = color_cache_pixels.peek_u32le()
|
||||
this.color_cache[((color ~mod* 0x1E35_A7BD) >> color_cache_shift) & 2047] = color
|
||||
color_cache_pixels = color_cache_pixels[4 ..]
|
||||
} endwhile
|
||||
}
|
||||
|
||||
// Look up this.color_cache.
|
||||
color = this.color_cache[(pixel_g - 0x118) & 2047]
|
||||
@@ -304,5 +304,5 @@ pri func decoder.decode_pixels_slow?(dst: slice base.u8, src: base.io_reader, wi
|
||||
x = 0
|
||||
y ~mod+= 1
|
||||
}
|
||||
} endwhile
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,7 @@ pri func decoder.apply_transform_predictor!(pix: slice base.u8, tile_data: rosli
|
||||
curr_row[6] ~mod+= curr_row[2]
|
||||
curr_row[7] ~mod+= curr_row[3]
|
||||
curr_row = curr_row[4 ..]
|
||||
} endwhile
|
||||
}
|
||||
|
||||
tile_size_log2 = this.transform_tile_size_log2[0] as base.u32
|
||||
tiles_per_row = (this.width + (((1 as base.u32) << tile_size_log2) - 1)) >> tile_size_log2
|
||||
@@ -232,10 +232,10 @@ pri func decoder.apply_transform_predictor!(pix: slice base.u8, tile_data: rosli
|
||||
curr_row = curr_row[4 ..]
|
||||
prev_row = prev_row[4 ..]
|
||||
x += 1
|
||||
} endwhile
|
||||
}
|
||||
|
||||
y += 1
|
||||
} endwhile
|
||||
}
|
||||
}
|
||||
|
||||
pri func decoder.absolute_difference(a: base.u32[..= 0xFF], b: base.u32[..= 0xFF]) base.u32[..= 0xFF] {
|
||||
@@ -340,10 +340,10 @@ pri func decoder.apply_transform_cross_color!(pix: slice base.u8, tile_data: ros
|
||||
}
|
||||
|
||||
x += 1
|
||||
} endwhile
|
||||
}
|
||||
|
||||
y += 1
|
||||
} endwhile
|
||||
}
|
||||
}
|
||||
|
||||
pri func decoder.apply_transform_subtract_green!(pix: slice base.u8) {
|
||||
@@ -421,10 +421,10 @@ pri func decoder.apply_transform_color_indexing!(pix: slice base.u8) {
|
||||
dst[3] = p3
|
||||
dst = dst[4 ..]
|
||||
x ~mod+= 1
|
||||
} endwhile
|
||||
}
|
||||
|
||||
y += 1
|
||||
} endwhile
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: we shouldn't need a lookup table for converting i8 to i32.
|
||||
|
||||
+13
-13
@@ -154,7 +154,7 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
}
|
||||
|
||||
pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.io_reader) {
|
||||
@@ -191,7 +191,7 @@ pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.
|
||||
return "#short chunk"
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
|
||||
this.frame_config_io_position = args.src.position()
|
||||
|
||||
@@ -245,7 +245,7 @@ pri func decoder.do_decode_image_config_limited?(src: base.io_reader) {
|
||||
return "#short chunk"
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
|
||||
} else if c32 == 'VP8X'le {
|
||||
return "#unsupported WebP file"
|
||||
@@ -293,7 +293,7 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
}
|
||||
|
||||
pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) {
|
||||
@@ -339,7 +339,7 @@ pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader,
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
}
|
||||
|
||||
pri func decoder.do_decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
|
||||
@@ -384,7 +384,7 @@ pri func decoder.do_decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reade
|
||||
break
|
||||
}
|
||||
this.decode_transform?(src: args.src, workbuf: args.workbuf)
|
||||
} endwhile
|
||||
}
|
||||
|
||||
width = this.width
|
||||
if this.seen_transform[3] {
|
||||
@@ -421,7 +421,7 @@ pri func decoder.do_decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reade
|
||||
break
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
|
||||
if (this.workbuf_offset_for_transform[0] as base.u64) > args.workbuf.length() {
|
||||
return base."#bad workbuf length"
|
||||
@@ -452,7 +452,7 @@ pri func decoder.do_decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reade
|
||||
this.apply_transform_color_indexing!(pix: pix)
|
||||
width = this.width
|
||||
}
|
||||
} endwhile
|
||||
}
|
||||
|
||||
status = this.swizzle!(
|
||||
dst: args.dst,
|
||||
@@ -578,7 +578,7 @@ pri func decoder.decode_transform?(src: base.io_reader, workbuf: slice base.u8)
|
||||
p[6] ~mod+= p[2]
|
||||
p[7] ~mod+= p[3]
|
||||
p = p[4 ..]
|
||||
} endwhile
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -712,7 +712,7 @@ pri func decoder.decode_hg_table?(src: base.io_reader, width: base.u32[..= 0x400
|
||||
this.overall_n_huffman_groups = hg_plus_1
|
||||
}
|
||||
p = p[4 ..]
|
||||
} endwhile
|
||||
}
|
||||
}
|
||||
|
||||
pri func decoder.decode_pixels?(dst: slice base.u8, src: base.io_reader, width: base.u32[..= 0x4000], height: base.u32[..= 0x4000], tile_data: roslice base.u8, tile_size_log2: base.u32[..= 9]) {
|
||||
@@ -725,7 +725,7 @@ pri func decoder.decode_pixels?(dst: slice base.u8, src: base.io_reader, width:
|
||||
assert i < 2048 via "a < b: a < c; c <= b"(c: n)
|
||||
this.color_cache[i] = 0
|
||||
i += 1
|
||||
} endwhile
|
||||
}
|
||||
|
||||
this.decode_pixels_slow?(
|
||||
dst: args.dst,
|
||||
@@ -771,7 +771,7 @@ pri func decoder.swizzle!(dst: ptr base.pixel_buffer, src: roslice base.u8, blen
|
||||
tab = args.dst.plane(p: 0)
|
||||
src_bytes_per_row = (this.width * 4) as base.u64
|
||||
|
||||
while.outer src_bytes_per_row <= args.src.length() {
|
||||
while src_bytes_per_row <= args.src.length() {
|
||||
dst = tab.row_u32(y: y)
|
||||
if dst_bytes_per_row < dst.length() {
|
||||
dst = dst[.. dst_bytes_per_row]
|
||||
@@ -784,7 +784,7 @@ pri func decoder.swizzle!(dst: ptr base.pixel_buffer, src: roslice base.u8, blen
|
||||
|
||||
args.src = args.src[src_bytes_per_row ..]
|
||||
y ~mod+= 1
|
||||
} endwhile.outer
|
||||
}
|
||||
|
||||
return ok
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user