std/jpeg: tweak decode_mcu up-front r.length check

name                                             old speed     new speed     delta

wuffs_jpeg_decode_19k_8bpp/clang11               236MB/s ± 0%  237MB/s ± 0%  +0.11%  (p=0.032 n=4+5)
wuffs_jpeg_decode_30k_24bpp_progressive/clang11  210MB/s ± 0%  213MB/s ± 0%  +1.20%  (p=0.008 n=5+5)
wuffs_jpeg_decode_30k_24bpp_sequential/clang11   385MB/s ± 0%  384MB/s ± 0%    ~     (p=0.095 n=5+5)
wuffs_jpeg_decode_77k_24bpp/clang11              338MB/s ± 0%  338MB/s ± 0%    ~     (p=0.151 n=5+5)
wuffs_jpeg_decode_552k_24bpp_420/clang11         353MB/s ± 0%  353MB/s ± 0%    ~     (p=0.548 n=5+5)
wuffs_jpeg_decode_552k_24bpp_444/clang11         481MB/s ± 0%  481MB/s ± 0%    ~     (p=0.690 n=5+5)
wuffs_jpeg_decode_4002k_24bpp/clang11            360MB/s ± 0%  359MB/s ± 0%  -0.35%  (p=0.008 n=5+5)

wuffs_jpeg_decode_19k_8bpp/gcc10                 244MB/s ± 0%  245MB/s ± 0%  +0.44%  (p=0.008 n=5+5)
wuffs_jpeg_decode_30k_24bpp_progressive/gcc10    251MB/s ± 0%  247MB/s ± 0%  -1.46%  (p=0.008 n=5+5)
wuffs_jpeg_decode_30k_24bpp_sequential/gcc10     509MB/s ± 0%  510MB/s ± 0%  +0.13%  (p=0.008 n=5+5)
wuffs_jpeg_decode_77k_24bpp/gcc10                431MB/s ± 0%  432MB/s ± 0%  +0.24%  (p=0.008 n=5+5)
wuffs_jpeg_decode_552k_24bpp_420/gcc10           455MB/s ± 0%  456MB/s ± 0%  +0.26%  (p=0.008 n=5+5)
wuffs_jpeg_decode_552k_24bpp_444/gcc10           481MB/s ± 0%  484MB/s ± 0%  +0.56%  (p=0.016 n=4+5)
wuffs_jpeg_decode_4002k_24bpp/gcc10              463MB/s ± 0%  465MB/s ± 0%  +0.36%  (p=0.008 n=5+5)
This commit is contained in:
Nigel Tao committed 2023-06-22 11:37:40 +10:00
1 parent 255516bc21
commit a00150f62f
6 files changed
+85 -58

No files matched your search

@@ -44,12 +44,23 @@ pri func decoder.decode_mcu_progressive_dc_high_bits!(workbuf: slice base.u8, mx
while.block this.mcu_current_block < this.mcu_num_blocks {
assert this.mcu_current_block < 10 via "a < b: a < c; c <= b"(c: this.mcu_num_blocks)
// Ensure that we have enough bits for this iteration of the
// while.block loop body. Worst case, there are 64 components and
// each one needs (16 + 15) bits (round that up to 4 bytes), so we
// need (64 * 4) = 256 bytes available. 8 more bytes of slack means
// that we can always call peek_u64be.
if r.length() < 264 {
ret = 1 // Request another fill_bitstream call.
break.goto_done
}
while.dc_component true,
inv this.mcu_current_block < 10,
{
// Load at least 47 bits, by keeping 56 .. 64 loaded.
// Load at least 56 bits.
if r.length() < 8 {
ret = 1 // Request another fill_bitstream call.
ret = 2 // Internal error.
break.goto_done
}
bits |= r.peek_u64be() >> (n_bits & 63)