mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-19 16:47:28 +01:00
std/jpeg: allow fewer-components sequential scans
name old speed new speed delta wuffs_jpeg_decode_19k_8bpp/clang11 366MB/s ± 0% 369MB/s ± 0% +0.81% (p=0.008 n=5+5) wuffs_jpeg_decode_30k_24bpp_progressive/clang11 302MB/s ± 0% 309MB/s ± 0% +2.28% (p=0.008 n=5+5) wuffs_jpeg_decode_30k_24bpp_sequential/clang11 1.00GB/s ± 0% 1.00GB/s ± 0% -0.58% (p=0.008 n=5+5) wuffs_jpeg_decode_77k_24bpp/clang11 820MB/s ± 0% 827MB/s ± 0% +0.80% (p=0.008 n=5+5) wuffs_jpeg_decode_552k_24bpp_420/clang11 895MB/s ± 0% 897MB/s ± 0% +0.24% (p=0.008 n=5+5) wuffs_jpeg_decode_552k_24bpp_444/clang11 1.11GB/s ± 0% 1.10GB/s ± 0% -0.30% (p=0.008 n=5+5) wuffs_jpeg_decode_4002k_24bpp/clang11 897MB/s ± 0% 900MB/s ± 0% +0.30% (p=0.008 n=5+5) wuffs_jpeg_decode_19k_8bpp/gcc10 370MB/s ± 0% 369MB/s ± 0% -0.26% (p=0.008 n=5+5) wuffs_jpeg_decode_30k_24bpp_progressive/gcc10 309MB/s ± 0% 283MB/s ± 0% -8.35% (p=0.008 n=5+5) wuffs_jpeg_decode_30k_24bpp_sequential/gcc10 948MB/s ± 0% 945MB/s ± 0% -0.27% (p=0.008 n=5+5) wuffs_jpeg_decode_77k_24bpp/gcc10 769MB/s ± 0% 769MB/s ± 0% ~ (p=0.310 n=5+5) wuffs_jpeg_decode_552k_24bpp_420/gcc10 841MB/s ± 0% 842MB/s ± 0% +0.13% (p=0.016 n=4+5) wuffs_jpeg_decode_552k_24bpp_444/gcc10 1.00GB/s ± 0% 1.01GB/s ± 0% +0.75% (p=0.016 n=4+5) wuffs_jpeg_decode_4002k_24bpp/gcc10 846MB/s ± 0% 848MB/s ± 0% +0.22% (p=0.008 n=5+5)
This commit is contained in:
1 parent
2f5f203d1b
commit
14a8bd0feb
3 files changed
+46
-28
No files matched your search
+26
-12
@@ -862,6 +862,14 @@ pri func decoder.do_decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reade
|
||||
} else if this.components_workbuf_offsets[4] < this.components_workbuf_offsets[8] {
|
||||
args.workbuf[this.components_workbuf_offsets[4] .. this.components_workbuf_offsets[8]].bulk_memset!(byte_value: 0)
|
||||
}
|
||||
// For both sequential and progressive JPEGs, biased-zero-initialize the
|
||||
// samples, in case the scans are incomplete (in terms of covering all
|
||||
// components) or the input is truncated. 0x80 is the same post-IDCT bias
|
||||
// as per BIAS_AND_CLAMP. For YCbCr, (0x80, 0x80, 0x80) is a medium gray
|
||||
// but (0x00, 0x00, 0x00) is a dark green.
|
||||
if this.components_workbuf_offsets[4] <= args.workbuf.length() {
|
||||
args.workbuf[.. this.components_workbuf_offsets[4]].bulk_memset!(byte_value: 0x80)
|
||||
}
|
||||
|
||||
// Process chunks (markers and their payloads).
|
||||
while true {
|
||||
@@ -1284,7 +1292,6 @@ pri func decoder.prepare_scan?(src: base.io_reader) {
|
||||
}
|
||||
this.scan_num_components = c as base.u32
|
||||
if (this.scan_num_components > this.num_components) or
|
||||
((this.scan_num_components < this.num_components) and (this.sof_marker < 0xC2)) or
|
||||
(this.payload_length <> (4 + (2 * this.scan_num_components))) {
|
||||
return "#bad SOS marker"
|
||||
}
|
||||
@@ -1303,20 +1310,27 @@ pri func decoder.prepare_scan?(src: base.io_reader) {
|
||||
return "#bad SOS marker"
|
||||
}
|
||||
assert j < 4 via "a < b: a < c; c <= b"(c: this.num_components)
|
||||
if c <> this.components_c[j] {
|
||||
j += 1
|
||||
continue
|
||||
}
|
||||
if i > 0 {
|
||||
if j <= (this.scan_comps_cselector[i - 1] as base.u32) {
|
||||
return "#bad SOS marker"
|
||||
if c == this.components_c[j] {
|
||||
if not this.seen_dqt[this.components_tq[j]] {
|
||||
return "#missing Quantization table"
|
||||
}
|
||||
this.scan_comps_cselector[i] = j as base.u8
|
||||
break
|
||||
}
|
||||
if not this.seen_dqt[this.components_tq[j]] {
|
||||
return "#missing Quantization table"
|
||||
j += 1
|
||||
} endwhile
|
||||
|
||||
// Section B.2.3: "the value of C_sj shall be different from the values
|
||||
// of C_s1 to C_sj–1".
|
||||
j = 0
|
||||
while j < i,
|
||||
inv i < 4,
|
||||
{
|
||||
assert j < 4 via "a < b: a < c; c < b"(c: i)
|
||||
if this.scan_comps_cselector[i] == this.scan_comps_cselector[j] {
|
||||
return "#bad SOS marker"
|
||||
}
|
||||
this.scan_comps_cselector[i] = j as base.u8
|
||||
break
|
||||
j += 1
|
||||
} endwhile
|
||||
|
||||
c = args.src.read_u8?()
|
||||
|
||||
Reference in new issue
Block a user