diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index 238c02bb..2815e7dc 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c @@ -41585,6 +41585,7 @@ wuffs_jpeg__decoder__decode_mcu__choosy_default( uint32_t v_dc_blm1 = 0; uint32_t v_dc_ht_slow = 0; uint32_t v_dc_value = 0; + const uint16_t(* v_ac_huff_table_fast) = NULL; uint8_t v_ac_h = 0; uint32_t v_ac_symbol = 0; uint32_t v_ac_ht_fast = 0; @@ -41674,6 +41675,8 @@ wuffs_jpeg__decoder__decode_mcu__choosy_default( goto label__dc_component__break; } label__dc_component__break:; + v_ac_h = self->private_impl.f_mcu_blocks_ac_hselector[self->private_impl.f_mcu_current_block]; + v_ac_huff_table_fast = &self->private_impl.f_huff_tables_fast[v_ac_h][0u]; while (true) { if (((uint64_t)(io2_v_r - iop_v_r)) < 8u) { v_ret = 1u; @@ -41682,8 +41685,7 @@ wuffs_jpeg__decoder__decode_mcu__choosy_default( v_bits |= (wuffs_base__peek_u64be__no_bounds_check(iop_v_r) >> (v_n_bits & 63u)); iop_v_r += ((63u - (v_n_bits & 63u)) >> 3u); v_n_bits |= 56u; - v_ac_h = self->private_impl.f_mcu_blocks_ac_hselector[self->private_impl.f_mcu_current_block]; - v_ac_ht_fast = ((uint32_t)(self->private_impl.f_huff_tables_fast[v_ac_h][(v_bits >> 56u)])); + v_ac_ht_fast = ((uint32_t)(v_ac_huff_table_fast[(v_bits >> 56u)])); v_ac_bl = (v_ac_ht_fast >> 8u); if (v_n_bits >= v_ac_bl) { v_ac_symbol = (255u & v_ac_ht_fast); @@ -41787,6 +41789,7 @@ wuffs_jpeg__decoder__decode_mcu_progressive_ac_high_bits( const uint8_t* io1_v_r WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io2_v_r WUFFS_BASE__POTENTIALLY_UNUSED = NULL; uint32_t v_pos = 0; + const uint16_t(* v_ac_huff_table_fast) = NULL; uint8_t v_ac_h = 0; uint32_t v_ac_symbol = 0; uint32_t v_ac_ht_fast = 0; @@ -41833,6 +41836,8 @@ wuffs_jpeg__decoder__decode_mcu_progressive_ac_high_bits( ((uint64_t)(self->private_impl.f_bitstream_ri))); while (true) { while (true) { + v_ac_h = self->private_impl.f_mcu_blocks_ac_hselector[0u]; + v_ac_huff_table_fast = &self->private_impl.f_huff_tables_fast[v_ac_h][0u]; while (true) { if (((uint64_t)(io2_v_r - iop_v_r)) < 8u) { v_ret = 1u; @@ -41841,8 +41846,7 @@ wuffs_jpeg__decoder__decode_mcu_progressive_ac_high_bits( v_bits |= (wuffs_base__peek_u64be__no_bounds_check(iop_v_r) >> (v_n_bits & 63u)); iop_v_r += ((63u - (v_n_bits & 63u)) >> 3u); v_n_bits |= 56u; - v_ac_h = self->private_impl.f_mcu_blocks_ac_hselector[0u]; - v_ac_ht_fast = ((uint32_t)(self->private_impl.f_huff_tables_fast[v_ac_h][(v_bits >> 56u)])); + v_ac_ht_fast = ((uint32_t)(v_ac_huff_table_fast[(v_bits >> 56u)])); v_ac_bl = (v_ac_ht_fast >> 8u); if (v_n_bits >= v_ac_bl) { v_ac_symbol = (255u & v_ac_ht_fast); @@ -41943,6 +41947,7 @@ wuffs_jpeg__decoder__decode_mcu_progressive_ac_low_bit( const uint8_t* io1_v_r WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io2_v_r WUFFS_BASE__POTENTIALLY_UNUSED = NULL; uint32_t v_pos = 0; + const uint16_t(* v_ac_huff_table_fast) = NULL; uint8_t v_ac_h = 0; uint32_t v_ac_symbol = 0; uint32_t v_ac_ht_fast = 0; @@ -41984,6 +41989,8 @@ wuffs_jpeg__decoder__decode_mcu_progressive_ac_low_bit( if (self->private_impl.f_eob_run > 0u) { goto label__goto_do_eob__break; } + v_ac_h = self->private_impl.f_mcu_blocks_ac_hselector[0u]; + v_ac_huff_table_fast = &self->private_impl.f_huff_tables_fast[v_ac_h][0u]; while (true) { if (((uint64_t)(io2_v_r - iop_v_r)) < 24u) { v_ret = 1u; @@ -41992,8 +41999,7 @@ wuffs_jpeg__decoder__decode_mcu_progressive_ac_low_bit( v_bits |= (wuffs_base__peek_u64be__no_bounds_check(iop_v_r) >> (v_n_bits & 63u)); iop_v_r += ((63u - (v_n_bits & 63u)) >> 3u); v_n_bits |= 56u; - v_ac_h = self->private_impl.f_mcu_blocks_ac_hselector[0u]; - v_ac_ht_fast = ((uint32_t)(self->private_impl.f_huff_tables_fast[v_ac_h][(v_bits >> 56u)])); + v_ac_ht_fast = ((uint32_t)(v_ac_huff_table_fast[(v_bits >> 56u)])); v_ac_bl = (v_ac_ht_fast >> 8u); if (v_n_bits >= v_ac_bl) { v_ac_symbol = (255u & v_ac_ht_fast); diff --git a/std/jpeg/decode_mcu_default.wuffs b/std/jpeg/decode_mcu_default.wuffs index bceaae89..9c45fba6 100644 --- a/std/jpeg/decode_mcu_default.wuffs +++ b/std/jpeg/decode_mcu_default.wuffs @@ -37,6 +37,8 @@ pri func decoder.decode_mcu!(workbuf: slice base.u8, mx: base.u32[..= 0x1FFF], m var dc_ht_slow : base.u32 var dc_value : base.u32 + var ac_huff_table_fast : nptr roarray[256] base.u16 + var ac_h : base.u8[..= 7] var ac_symbol : base.u32[..= 0xFF] var ac_ht_fast : base.u32 @@ -131,8 +133,11 @@ pri func decoder.decode_mcu!(workbuf: slice base.u8, mx: base.u32[..= 0x1FFF], m break.dc_component } endwhile.dc_component + ac_h = this.mcu_blocks_ac_hselector[this.mcu_current_block] + ac_huff_table_fast = this.huff_tables_fast[ac_h][..] as ptr array[256] base.u16 while.ac_components true, inv this.mcu_current_block < 10, + inv ac_huff_table_fast <> nullptr, { // Load at least 31 bits, by keeping 56 .. 64 loaded. if r.length() < 8 { @@ -144,8 +149,7 @@ pri func decoder.decode_mcu!(workbuf: slice base.u8, mx: base.u32[..= 0x1FFF], m n_bits |= 56 // Read the Huffman-encoded ac_symbol, up to 16 bits long. - ac_h = this.mcu_blocks_ac_hselector[this.mcu_current_block] - ac_ht_fast = this.huff_tables_fast[ac_h][bits >> 56] as base.u32 + ac_ht_fast = ac_huff_table_fast[bits >> 56] as base.u32 ac_bl = ac_ht_fast >> 8 if n_bits >= ac_bl { ac_symbol = 0xFF & ac_ht_fast @@ -158,6 +162,7 @@ pri func decoder.decode_mcu!(workbuf: slice base.u8, mx: base.u32[..= 0x1FFF], m n_bits ~mod-= 9 while true, inv this.mcu_current_block < 10, + inv ac_huff_table_fast <> nullptr, { ac_ht_slow = this.huff_tables_slow[ac_h][ac_blm1] if ac_code < (ac_ht_slow >> 8) { diff --git a/std/jpeg/decode_mcu_progressive_ac_high_bits.wuffs b/std/jpeg/decode_mcu_progressive_ac_high_bits.wuffs index 8abc51c3..2510c70e 100644 --- a/std/jpeg/decode_mcu_progressive_ac_high_bits.wuffs +++ b/std/jpeg/decode_mcu_progressive_ac_high_bits.wuffs @@ -21,6 +21,8 @@ pri func decoder.decode_mcu_progressive_ac_high_bits!(workbuf: slice base.u8, mx var r : base.io_reader var pos : base.u32 + var ac_huff_table_fast : nptr roarray[256] base.u16 + var ac_h : base.u8[..= 7] var ac_symbol : base.u32[..= 0xFF] var ac_ht_fast : base.u32 @@ -50,7 +52,11 @@ pri func decoder.decode_mcu_progressive_ac_high_bits!(workbuf: slice base.u8, mx while.goto_done true {{ while.block true { - while.ac_components true { + ac_h = this.mcu_blocks_ac_hselector[0] + ac_huff_table_fast = this.huff_tables_fast[ac_h][..] as ptr array[256] base.u16 + while.ac_components true, + inv ac_huff_table_fast <> nullptr, + { // Load at least 31 bits, by keeping 56 .. 64 loaded. if r.length() < 8 { ret = 1 // Request another fill_bitstream call. @@ -61,8 +67,7 @@ pri func decoder.decode_mcu_progressive_ac_high_bits!(workbuf: slice base.u8, mx n_bits |= 56 // Read the Huffman-encoded ac_symbol, up to 16 bits long. - ac_h = this.mcu_blocks_ac_hselector[0] - ac_ht_fast = this.huff_tables_fast[ac_h][bits >> 56] as base.u32 + ac_ht_fast = ac_huff_table_fast[bits >> 56] as base.u32 ac_bl = ac_ht_fast >> 8 if n_bits >= ac_bl { ac_symbol = 0xFF & ac_ht_fast @@ -73,7 +78,9 @@ pri func decoder.decode_mcu_progressive_ac_high_bits!(workbuf: slice base.u8, mx ac_blm1 = 8 bits ~mod<<= 9 n_bits ~mod-= 9 - while true { + while true, + inv ac_huff_table_fast <> nullptr, + { ac_ht_slow = this.huff_tables_slow[ac_h][ac_blm1] if ac_code < (ac_ht_slow >> 8) { ac_symbol = this.huff_tables_symbols[ac_h][0xFF & (ac_code ~mod+ ac_ht_slow)] as base.u32 diff --git a/std/jpeg/decode_mcu_progressive_ac_low_bit.wuffs b/std/jpeg/decode_mcu_progressive_ac_low_bit.wuffs index d4622d58..2f030222 100644 --- a/std/jpeg/decode_mcu_progressive_ac_low_bit.wuffs +++ b/std/jpeg/decode_mcu_progressive_ac_low_bit.wuffs @@ -23,6 +23,8 @@ pri func decoder.decode_mcu_progressive_ac_low_bit!(workbuf: slice base.u8, mx: var r : base.io_reader var pos : base.u32 + var ac_huff_table_fast : nptr roarray[256] base.u16 + var ac_h : base.u8[..= 7] var ac_symbol : base.u32[..= 0xFF] var ac_ht_fast : base.u32 @@ -55,7 +57,11 @@ pri func decoder.decode_mcu_progressive_ac_low_bit!(workbuf: slice base.u8, mx: break.goto_do_eob } - while.ac_components true { + ac_h = this.mcu_blocks_ac_hselector[0] + ac_huff_table_fast = this.huff_tables_fast[ac_h][..] as ptr array[256] base.u16 + while.ac_components true, + inv ac_huff_table_fast <> nullptr, + { // Load at least 31 bits, by keeping 56 .. 64 loaded (call it 8 // bytes). Just like the other decode_mcu_etc functions, this // is enough for the Huffman-encoded ac_symbol (up to 16 bits) @@ -77,8 +83,7 @@ pri func decoder.decode_mcu_progressive_ac_low_bit!(workbuf: slice base.u8, mx: n_bits |= 56 // Read the Huffman-encoded ac_symbol, up to 16 bits long. - ac_h = this.mcu_blocks_ac_hselector[0] - ac_ht_fast = this.huff_tables_fast[ac_h][bits >> 56] as base.u32 + ac_ht_fast = ac_huff_table_fast[bits >> 56] as base.u32 ac_bl = ac_ht_fast >> 8 if n_bits >= ac_bl { ac_symbol = 0xFF & ac_ht_fast @@ -89,7 +94,9 @@ pri func decoder.decode_mcu_progressive_ac_low_bit!(workbuf: slice base.u8, mx: ac_blm1 = 8 bits ~mod<<= 9 n_bits ~mod-= 9 - while true { + while true, + inv ac_huff_table_fast <> nullptr, + { ac_ht_slow = this.huff_tables_slow[ac_h][ac_blm1] if ac_code < (ac_ht_slow >> 8) { ac_symbol = this.huff_tables_symbols[ac_h][0xFF & (ac_code ~mod+ ac_ht_slow)] as base.u32 @@ -132,7 +139,9 @@ pri func decoder.decode_mcu_progressive_ac_low_bit!(workbuf: slice base.u8, mx: } // Consume 1 bit per non-zero AC coefficient, up to 63 bits. - while.refine_non_zeroes true { + while.refine_non_zeroes true, + inv ac_huff_table_fast <> nullptr, + { unzig = UNZIG[this.mcu_zig_index] if this.mcu_blocks[0][unzig] <> 0 { if n_bits == 0 {