std/jpeg: memoize ac_huff_table_fast

name                                             old speed     new speed     delta

wuffs_jpeg_decode_19k_8bpp/clang11               215MB/s ± 0%  226MB/s ± 0%  +5.17%  (p=0.008 n=5+5)
wuffs_jpeg_decode_30k_24bpp_progressive/clang11  209MB/s ± 0%  210MB/s ± 0%  +0.50%  (p=0.008 n=5+5)
wuffs_jpeg_decode_30k_24bpp_sequential/clang11   368MB/s ± 0%  380MB/s ± 1%  +3.11%  (p=0.008 n=5+5)
wuffs_jpeg_decode_77k_24bpp/clang11              313MB/s ± 0%  327MB/s ± 0%  +4.27%  (p=0.008 n=5+5)
wuffs_jpeg_decode_552k_24bpp_420/clang11         326MB/s ± 0%  338MB/s ± 0%  +3.50%  (p=0.008 n=5+5)
wuffs_jpeg_decode_552k_24bpp_444/clang11         462MB/s ± 0%  468MB/s ± 0%  +1.14%  (p=0.008 n=5+5)
wuffs_jpeg_decode_4002k_24bpp/clang11            329MB/s ± 1%  346MB/s ± 0%  +5.39%  (p=0.008 n=5+5)

wuffs_jpeg_decode_19k_8bpp/gcc10                 174MB/s ± 0%  175MB/s ± 0%  +0.55%  (p=0.008 n=5+5)
wuffs_jpeg_decode_30k_24bpp_progressive/gcc10    228MB/s ± 0%  248MB/s ± 0%  +8.49%  (p=0.008 n=5+5)
wuffs_jpeg_decode_30k_24bpp_sequential/gcc10     472MB/s ± 0%  478MB/s ± 0%  +1.20%  (p=0.008 n=5+5)
wuffs_jpeg_decode_77k_24bpp/gcc10                327MB/s ± 0%  328MB/s ± 0%  +0.47%  (p=0.008 n=5+5)
wuffs_jpeg_decode_552k_24bpp_420/gcc10           344MB/s ± 0%  346MB/s ± 0%  +0.46%  (p=0.016 n=4+5)
wuffs_jpeg_decode_552k_24bpp_444/gcc10           422MB/s ± 0%  424MB/s ± 0%  +0.49%  (p=0.008 n=5+5)
wuffs_jpeg_decode_4002k_24bpp/gcc10              349MB/s ± 0%  348MB/s ± 0%  -0.24%  (p=0.008 n=5+5)
This commit is contained in:
Nigel Tao committed 2023-06-13 22:38:29 +10:00
1 parent 19f56ebfd2
commit dd6a5d5435
4 files changed
+44 -17

No files matched your search

+12 -6
View File
@@ -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);