From 18488a3bd0f0fef741218104e55bca451e061edd Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sun, 14 Jun 2026 20:12:21 +1000 Subject: [PATCH] std: rename some CLAMP and CLIP tables --- release/c/wuffs-unsupported-snapshot.c | 14 +++++++------- std/bzip2/decode_bzip2.wuffs | 6 ++++-- std/bzip2/decode_huffman_fast.wuffs | 2 +- std/bzip2/decode_huffman_slow.wuffs | 2 +- std/vp8/common_consts.wuffs | 2 +- std/vp8/decode_macroblocks.wuffs | 4 ++-- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index 67193e5c..2c5d5335 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c @@ -37938,7 +37938,7 @@ const char wuffs_bzip2__error__internal_error_inconsistent_huffman_decoder_state // ---------------- Private Consts static const uint8_t -WUFFS_BZIP2__CLAMP_TO_5[8] WUFFS_BASE__POTENTIALLY_UNUSED = { +WUFFS_BZIP2__CLAMP_NO_MORE_THAN_5[8] WUFFS_BASE__POTENTIALLY_UNUSED = { 0u, 1u, 2u, 3u, 4u, 5u, 5u, 5u, }; @@ -38410,7 +38410,7 @@ wuffs_bzip2__decoder__do_transform_io( } self->private_impl.f_block_size = 0u; self->private_impl.f_decode_huffman_finished = false; - self->private_impl.f_decode_huffman_which = WUFFS_BZIP2__CLAMP_TO_5[((uint8_t)(self->private_data.f_huffman_selectors[0u] & 7u))]; + self->private_impl.f_decode_huffman_which = WUFFS_BZIP2__CLAMP_NO_MORE_THAN_5[((uint8_t)(self->private_data.f_huffman_selectors[0u] & 7u))]; self->private_impl.f_decode_huffman_ticks = 50u; self->private_impl.f_decode_huffman_section = 0u; self->private_impl.f_decode_huffman_run_shift = 0u; @@ -39364,7 +39364,7 @@ wuffs_bzip2__decoder__decode_huffman_fast( status = wuffs_base__make_status(wuffs_bzip2__error__bad_number_of_sections); goto exit; } - v_which = WUFFS_BZIP2__CLAMP_TO_5[((uint8_t)(self->private_data.f_huffman_selectors[(v_section & 32767u)] & 7u))]; + v_which = WUFFS_BZIP2__CLAMP_NO_MORE_THAN_5[((uint8_t)(self->private_data.f_huffman_selectors[(v_section & 32767u)] & 7u))]; } v_bits |= (wuffs_base__peek_u32be__no_bounds_check(iop_a_src) >> v_n_bits); iop_a_src += ((31u - v_n_bits) >> 3u); @@ -39487,7 +39487,7 @@ wuffs_bzip2__decoder__decode_huffman_slow( status = wuffs_base__make_status(wuffs_bzip2__error__bad_number_of_sections); goto exit; } - self->private_impl.f_decode_huffman_which = WUFFS_BZIP2__CLAMP_TO_5[((uint8_t)(self->private_data.f_huffman_selectors[(self->private_impl.f_decode_huffman_section & 32767u)] & 7u))]; + self->private_impl.f_decode_huffman_which = WUFFS_BZIP2__CLAMP_NO_MORE_THAN_5[((uint8_t)(self->private_data.f_huffman_selectors[(self->private_impl.f_decode_huffman_section & 32767u)] & 7u))]; } v_node_index = 0u; while (true) { @@ -80970,7 +80970,7 @@ WUFFS_VP8__RENORM_RANGE_M1[256] WUFFS_BASE__POTENTIALLY_UNUSED = { }; static const uint8_t -WUFFS_VP8__CLIP_9[16] WUFFS_BASE__POTENTIALLY_UNUSED = { +WUFFS_VP8__CLAMP_NO_MORE_THAN_9[16] WUFFS_BASE__POTENTIALLY_UNUSED = { 0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 9u, 9u, 9u, 9u, 9u, 9u, }; @@ -82511,12 +82511,12 @@ wuffs_vp8__decoder__decode_subblock_modes( v_i = 0u; while (v_i < 16u) { if (v_i < 4u) { - v_top_mode = WUFFS_VP8__CLIP_9[(15u & (self->private_data.f_mb_states_top[a_mbx] >> (v_i * 4u)))]; + v_top_mode = WUFFS_VP8__CLAMP_NO_MORE_THAN_9[(15u & (self->private_data.f_mb_states_top[a_mbx] >> (v_i * 4u)))]; } else { v_top_mode = self->private_impl.f_mb_subblock_modes[(v_i - 4u)]; } if ((v_i & 3u) == 0u) { - v_left_mode = WUFFS_VP8__CLIP_9[(15u & (self->private_data.f_mb_states_left >> (v_i & 12u)))]; + v_left_mode = WUFFS_VP8__CLAMP_NO_MORE_THAN_9[(15u & (self->private_data.f_mb_states_left >> (v_i & 12u)))]; } else { v_left_mode = self->private_impl.f_mb_subblock_modes[(((uint32_t)(v_i + 15u)) & 15u)]; } diff --git a/std/bzip2/decode_bzip2.wuffs b/std/bzip2/decode_bzip2.wuffs index f6d2e8da..c477f5bc 100644 --- a/std/bzip2/decode_bzip2.wuffs +++ b/std/bzip2/decode_bzip2.wuffs @@ -23,7 +23,9 @@ pri status "#internal error: inconsistent Huffman decoder state" pub const DECODER_DST_HISTORY_RETAIN_LENGTH_MAX_INCL_WORST_CASE : base.u64 = 0 pub const DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE : base.u64 = 0 -pri const CLAMP_TO_5 : roarray[8] base.u8[..= 5] = [0, 1, 2, 3, 4, 5, 5, 5] +pri const CLAMP_NO_MORE_THAN_5 : roarray[8] base.u8[..= 5] = [ + 0, 1, 2, 3, 4, 5, 5, 5, +] pub struct decoder? implements base.io_transformer( bits : base.u32, @@ -197,7 +199,7 @@ pri func decoder.do_transform_io?(dst: base.io_writer, src: base.io_reader, work this.block_size = 0 this.decode_huffman_finished = false - this.decode_huffman_which = CLAMP_TO_5[this.huffman_selectors[0] & 7] + this.decode_huffman_which = CLAMP_NO_MORE_THAN_5[this.huffman_selectors[0] & 7] this.decode_huffman_ticks = 50 this.decode_huffman_section = 0 this.decode_huffman_run_shift = 0 diff --git a/std/bzip2/decode_huffman_fast.wuffs b/std/bzip2/decode_huffman_fast.wuffs index 47bb72c8..61f93fae 100644 --- a/std/bzip2/decode_huffman_fast.wuffs +++ b/std/bzip2/decode_huffman_fast.wuffs @@ -44,7 +44,7 @@ pri func decoder.decode_huffman_fast!(src: base.io_reader) base.status { if section >= this.num_sections { return "#bad number of sections" } - which = CLAMP_TO_5[this.huffman_selectors[section & 32767] & 7] + which = CLAMP_NO_MORE_THAN_5[this.huffman_selectors[section & 32767] & 7] } bits |= args.src.peek_u32be() >> n_bits diff --git a/std/bzip2/decode_huffman_slow.wuffs b/std/bzip2/decode_huffman_slow.wuffs index 3f324139..aff92efe 100644 --- a/std/bzip2/decode_huffman_slow.wuffs +++ b/std/bzip2/decode_huffman_slow.wuffs @@ -30,7 +30,7 @@ pri func decoder.decode_huffman_slow?(src: base.io_reader) { if this.decode_huffman_section >= this.num_sections { return "#bad number of sections" } - this.decode_huffman_which = CLAMP_TO_5[this.huffman_selectors[this.decode_huffman_section & 32767] & 7] + this.decode_huffman_which = CLAMP_NO_MORE_THAN_5[this.huffman_selectors[this.decode_huffman_section & 32767] & 7] } node_index = 0 diff --git a/std/vp8/common_consts.wuffs b/std/vp8/common_consts.wuffs index 87873293..a849d60b 100644 --- a/std/vp8/common_consts.wuffs +++ b/std/vp8/common_consts.wuffs @@ -107,7 +107,7 @@ pri const RENORM_RANGE_M1 : roarray[256] base.u8[127 ..= 254] = [ 254, ] -pri const CLIP_9 : roarray[16] base.u8[..= 9] = [ +pri const CLAMP_NO_MORE_THAN_9 : roarray[16] base.u8[..= 9] = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 9, 9, 9, 9, ] diff --git a/std/vp8/decode_macroblocks.wuffs b/std/vp8/decode_macroblocks.wuffs index f56f454a..258afb15 100644 --- a/std/vp8/decode_macroblocks.wuffs +++ b/std/vp8/decode_macroblocks.wuffs @@ -165,13 +165,13 @@ pri func decoder.decode_subblock_modes!( i = 0 while i < 16 { if i < 4 { - top_mode = CLIP_9[15 & (this.mb_states_top[args.mbx] >> (i * 4))] + top_mode = CLAMP_NO_MORE_THAN_9[15 & (this.mb_states_top[args.mbx] >> (i * 4))] } else { top_mode = this.mb_subblock_modes[i - 4] } if (i & 3) == 0 { - left_mode = CLIP_9[15 & (this.mb_states_left >> (i & 12))] + left_mode = CLAMP_NO_MORE_THAN_9[15 & (this.mb_states_left >> (i & 12))] } else { left_mode = this.mb_subblock_modes[(i ~mod+ 15) & 15] }