mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-19 00:38:14 +01:00
std/jpeg: drain bitstream for truncated input
name old speed new speed delta wuffs_jpeg_decode_19k_8bpp/clang11 367MB/s ± 0% 378MB/s ± 0% +2.91% (p=0.008 n=5+5) wuffs_jpeg_decode_30k_24bpp_progressive/clang11 333MB/s ± 0% 325MB/s ± 0% -2.46% (p=0.008 n=5+5) wuffs_jpeg_decode_30k_24bpp_sequential/clang11 1.00GB/s ± 0% 1.02GB/s ± 0% +1.37% (p=0.008 n=5+5) wuffs_jpeg_decode_77k_24bpp/clang11 822MB/s ± 0% 842MB/s ± 0% +2.39% (p=0.008 n=5+5) wuffs_jpeg_decode_552k_24bpp_420/clang11 898MB/s ± 0% 916MB/s ± 0% +1.98% (p=0.008 n=5+5) wuffs_jpeg_decode_552k_24bpp_444/clang11 1.09GB/s ± 0% 1.10GB/s ± 0% +1.21% (p=0.008 n=5+5) wuffs_jpeg_decode_4002k_24bpp/clang11 898MB/s ± 0% 919MB/s ± 0% +2.29% (p=0.008 n=5+5) wuffs_jpeg_decode_19k_8bpp/gcc10 362MB/s ± 0% 360MB/s ± 0% -0.55% (p=0.008 n=5+5) wuffs_jpeg_decode_30k_24bpp_progressive/gcc10 292MB/s ± 0% 290MB/s ± 0% -0.57% (p=0.008 n=5+5) wuffs_jpeg_decode_30k_24bpp_sequential/gcc10 934MB/s ± 0% 925MB/s ± 0% -1.03% (p=0.008 n=5+5) wuffs_jpeg_decode_77k_24bpp/gcc10 759MB/s ± 0% 758MB/s ± 0% -0.25% (p=0.008 n=5+5) wuffs_jpeg_decode_552k_24bpp_420/gcc10 828MB/s ± 0% 829MB/s ± 0% ~ (p=0.222 n=5+5) wuffs_jpeg_decode_552k_24bpp_444/gcc10 1.00GB/s ± 0% 0.98GB/s ± 0% -1.44% (p=0.008 n=5+5) wuffs_jpeg_decode_4002k_24bpp/gcc10 837MB/s ± 0% 835MB/s ± 0% -0.29% (p=0.008 n=5+5)
This commit is contained in:
1 parent
813c054c18
commit
d89ec2d40b
4 files changed
+24
-4
No files matched your search
@@ -280,6 +280,8 @@ pub struct decoder? implements base.image_decoder(
|
||||
bitstream_ri : base.u32[..= 0x800],
|
||||
bitstream_wi : base.u32[..= 0x800],
|
||||
|
||||
bitstream_is_closed : base.bool,
|
||||
|
||||
// bitstream_padding is the number (per restart) of implicit zeroes
|
||||
// remaining at the end of the bitstream. Its initial 12345 value is
|
||||
// arbitrary.
|
||||
@@ -1311,6 +1313,14 @@ pri func decoder.decode_sos?(src: base.io_reader, workbuf: slice base.u8) {
|
||||
break.fill_bitstream
|
||||
} else if this.bitstream_padding == 0 {
|
||||
return "#bad SOS marker"
|
||||
} else if args.src.is_closed() and (not this.bitstream_is_closed) {
|
||||
if this.bitstream_wi < (0x800 / 2) {
|
||||
assert this.bitstream_wi <= (this.bitstream_wi + 264) via "a <= (a + b): 0 <= b"()
|
||||
this.bitstream_buffer[this.bitstream_wi .. (this.bitstream_wi + 264)].bulk_memset!(byte_value: 0)
|
||||
this.bitstream_wi += 264
|
||||
this.bitstream_is_closed = true
|
||||
}
|
||||
break.fill_bitstream
|
||||
}
|
||||
yield? base."$short read"
|
||||
} endwhile.fill_bitstream
|
||||
@@ -2051,6 +2061,7 @@ pub func decoder.restart_frame!(index: base.u64, io_position: base.u64) base.sta
|
||||
}
|
||||
|
||||
this.call_sequence = 0x28
|
||||
this.bitstream_is_closed = false
|
||||
this.frame_config_io_position = args.io_position
|
||||
this.scan_count = 0
|
||||
this.restart_interval = this.saved_restart_interval
|
||||
|
||||
Reference in new issue
Block a user