mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 16:32:11 +01:00
name old speed new speed delta wuffs_adler32_10k/clang5 2.42GB/s ± 1% 2.43GB/s ± 1% +0.15% (p=0.014 n=46+45) wuffs_adler32_100k/clang5 2.43GB/s ± 1% 2.43GB/s ± 1% ~ (p=0.532 n=43+46) wuffs_adler32_10k/gcc7 3.22GB/s ± 0% 3.23GB/s ± 1% +0.17% (p=0.000 n=47+48) wuffs_adler32_100k/gcc7 3.23GB/s ± 0% 3.23GB/s ± 0% +0.20% (p=0.000 n=45+48) wuffs_crc32_ieee_10k/clang5 2.86GB/s ± 0% 2.86GB/s ± 0% +0.22% (p=0.000 n=47+46) wuffs_crc32_ieee_100k/clang5 2.88GB/s ± 0% 2.88GB/s ± 1% +0.11% (p=0.006 n=48+47) wuffs_crc32_ieee_10k/gcc7 3.37GB/s ± 1% 3.37GB/s ± 1% ~ (p=0.050 n=49+48) wuffs_crc32_ieee_100k/gcc7 3.40GB/s ± 0% 3.40GB/s ± 1% +0.15% (p=0.001 n=46+48) wuffs_deflate_decode_1k/clang5 139MB/s ± 0% 138MB/s ± 0% -0.44% (p=0.000 n=45+47) wuffs_deflate_decode_10k/clang5 222MB/s ± 0% 233MB/s ± 1% +4.81% (p=0.000 n=45+47) wuffs_deflate_decode_100k_just_one_read/clang5 260MB/s ± 1% 274MB/s ± 0% +5.34% (p=0.000 n=46+45) wuffs_deflate_decode_100k_many_big_reads/clang5 218MB/s ± 0% 224MB/s ± 1% +2.36% (p=0.000 n=44+46) wuffs_deflate_decode_1k/gcc7 158MB/s ± 1% 157MB/s ± 1% -0.23% (p=0.000 n=44+48) wuffs_deflate_decode_10k/gcc7 266MB/s ± 1% 265MB/s ± 1% -0.48% (p=0.000 n=45+47) wuffs_deflate_decode_100k_just_one_read/gcc7 323MB/s ± 1% 320MB/s ± 0% -0.87% (p=0.000 n=46+46) wuffs_deflate_decode_100k_many_big_reads/gcc7 255MB/s ± 0% 252MB/s ± 0% -1.04% (p=0.000 n=42+44) wuffs_gif_decode_1k_bw/clang5 243MB/s ± 1% 238MB/s ± 1% -1.74% (p=0.000 n=49+48) wuffs_gif_decode_1k_color/clang5 142MB/s ± 1% 140MB/s ± 1% -1.17% (p=0.000 n=45+49) wuffs_gif_decode_10k_bgra/clang5 723MB/s ± 1% 720MB/s ± 1% -0.37% (p=0.000 n=48+49) wuffs_gif_decode_10k_indexed/clang5 193MB/s ± 1% 194MB/s ± 1% +0.23% (p=0.002 n=49+48) wuffs_gif_decode_20k/clang5 245MB/s ± 1% 246MB/s ± 1% +0.20% (p=0.002 n=49+46) wuffs_gif_decode_100k_artificial/clang5 542MB/s ± 1% 543MB/s ± 1% +0.16% (p=0.012 n=48+47) wuffs_gif_decode_100k_realistic/clang5 227MB/s ± 1% 226MB/s ± 1% -0.31% (p=0.000 n=48+45) wuffs_gif_decode_1000k/clang5 232MB/s ± 0% 231MB/s ± 1% -0.40% (p=0.000 n=48+42) wuffs_gif_decode_anim_screencap/clang5 1.08GB/s ± 1% 1.07GB/s ± 1% -1.09% (p=0.000 n=46+46) wuffs_gif_decode_1k_bw/gcc7 264MB/s ± 1% 262MB/s ± 1% -0.81% (p=0.000 n=50+49) wuffs_gif_decode_1k_color/gcc7 148MB/s ± 0% 146MB/s ± 1% -1.60% (p=0.000 n=47+49) wuffs_gif_decode_10k_bgra/gcc7 621MB/s ± 1% 618MB/s ± 1% -0.47% (p=0.000 n=49+49) wuffs_gif_decode_10k_indexed/gcc7 194MB/s ± 1% 194MB/s ± 3% ~ (p=0.222 n=49+50) wuffs_gif_decode_20k/gcc7 236MB/s ± 1% 237MB/s ± 1% +0.52% (p=0.000 n=49+45) wuffs_gif_decode_100k_artificial/gcc7 505MB/s ± 1% 507MB/s ± 1% +0.36% (p=0.000 n=46+47) wuffs_gif_decode_100k_realistic/gcc7 210MB/s ± 1% 210MB/s ± 1% ~ (p=0.081 n=49+42) wuffs_gif_decode_1000k/gcc7 213MB/s ± 1% 213MB/s ± 1% -0.19% (p=0.001 n=49+47) wuffs_gif_decode_anim_screencap/gcc7 1.06GB/s ± 0% 1.05GB/s ± 1% -1.02% (p=0.000 n=48+47) wuffs_gzip_decode_10k/clang5 206MB/s ± 0% 215MB/s ± 0% +4.52% (p=0.000 n=49+44) wuffs_gzip_decode_100k/clang5 239MB/s ± 0% 250MB/s ± 0% +4.71% (p=0.000 n=47+46) wuffs_gzip_decode_10k/gcc7 250MB/s ± 1% 249MB/s ± 0% -0.38% (p=0.000 n=47+50) wuffs_gzip_decode_100k/gcc7 293MB/s ± 0% 289MB/s ± 0% -1.28% (p=0.000 n=45+44) wuffs_lzw_decode_20k/clang5 265MB/s ± 1% 265MB/s ± 0% ~ (p=0.331 n=47+44) wuffs_lzw_decode_100k/clang5 452MB/s ± 1% 450MB/s ± 1% -0.31% (p=0.001 n=48+46) wuffs_lzw_decode_20k/gcc7 264MB/s ± 1% 263MB/s ± 1% -0.49% (p=0.000 n=48+47) wuffs_lzw_decode_100k/gcc7 481MB/s ± 1% 475MB/s ± 1% -1.22% (p=0.000 n=48+50) wuffs_zlib_decode_10k/clang5 202MB/s ± 0% 212MB/s ± 0% +5.18% (p=0.000 n=46+46) wuffs_zlib_decode_100k/clang5 235MB/s ± 0% 247MB/s ± 0% +4.92% (p=0.000 n=46+45) wuffs_zlib_decode_10k/gcc7 246MB/s ± 0% 246MB/s ± 0% -0.13% (p=0.001 n=45+47) wuffs_zlib_decode_100k/gcc7 289MB/s ± 0% 291MB/s ± 0% +0.67% (p=0.000 n=47+46)
132 lines
3.3 KiB
Plaintext
132 lines
3.3 KiB
Plaintext
// Copyright 2018 The Wuffs Authors.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// https://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
use "std/crc32"
|
|
use "std/deflate"
|
|
|
|
pub status "?bad checksum"
|
|
pub status "?bad compression method"
|
|
pub status "?bad encoding flags"
|
|
pub status "?bad header"
|
|
|
|
// TODO: reference deflate.decoder_workbuf_len_max_incl_worst_case.
|
|
pub const decoder_workbuf_len_max_incl_worst_case base.u64 = 32768 + 512
|
|
|
|
pub struct decoder?(
|
|
ignore_checksum base.bool,
|
|
checksum crc32.ieee_hasher,
|
|
|
|
flate deflate.decoder,
|
|
|
|
util base.utility,
|
|
)
|
|
|
|
pub func decoder.set_ignore_checksum!(ic base.bool) {
|
|
this.ignore_checksum = args.ic
|
|
}
|
|
|
|
pub func decoder.workbuf_len() base.range_ii_u64 {
|
|
return this.util.make_range_ii_u64(
|
|
min_incl:decoder_workbuf_len_max_incl_worst_case,
|
|
max_incl:decoder_workbuf_len_max_incl_worst_case)
|
|
}
|
|
|
|
pub func decoder.decode_io_writer?(dst base.io_writer, src base.io_reader, workbuf slice base.u8) {
|
|
var c base.u8
|
|
var flags base.u8
|
|
var xlen base.u16
|
|
var checksum_got base.u32
|
|
var decoded_length_got base.u32
|
|
var status base.status
|
|
var checksum_want base.u32
|
|
var decoded_length_want base.u32
|
|
|
|
// Read the header.
|
|
c = args.src.read_u8?()
|
|
if c != 0x1F {
|
|
return "?bad header"
|
|
}
|
|
c = args.src.read_u8?()
|
|
if c != 0x8B {
|
|
return "?bad header"
|
|
}
|
|
c = args.src.read_u8?()
|
|
if c != 0x08 {
|
|
return "?bad compression method"
|
|
}
|
|
flags = args.src.read_u8?()
|
|
// TODO: API for returning the header's MTIME field.
|
|
args.src.skip?(n:6)
|
|
|
|
// Handle FEXTRA.
|
|
if (flags & 0x04) != 0 {
|
|
xlen = args.src.read_u16le?()
|
|
args.src.skip?(n:xlen as base.u32)
|
|
}
|
|
|
|
// Handle FNAME.
|
|
//
|
|
// TODO: API for returning the header's FNAME field. This might require
|
|
// converting ISO 8859-1 to UTF-8. We may also want to cap the UTF-8
|
|
// filename length to NAME_MAX, which is 255.
|
|
if (flags & 0x08) != 0 {
|
|
while true {
|
|
c = args.src.read_u8?()
|
|
if c == 0 {
|
|
break
|
|
}
|
|
}
|
|
}
|
|
|
|
// Handle FCOMMENT.
|
|
if (flags & 0x10) != 0 {
|
|
while true {
|
|
c = args.src.read_u8?()
|
|
if c == 0 {
|
|
break
|
|
}
|
|
}
|
|
}
|
|
|
|
// Handle FHCRC.
|
|
if (flags & 0x02) != 0 {
|
|
args.src.skip?(n:2)
|
|
}
|
|
|
|
// Reserved flags bits must be zero.
|
|
if (flags & 0xE0) != 0 {
|
|
return "?bad encoding flags"
|
|
}
|
|
|
|
// Decode and checksum the DEFLATE-encoded payload.
|
|
while true {
|
|
args.dst.set_mark!()
|
|
status =? this.flate.decode_io_writer?(dst:args.dst, src:args.src, workbuf:args.workbuf)
|
|
if not this.ignore_checksum {
|
|
checksum_got = this.checksum.update!(x:args.dst.since_mark())
|
|
decoded_length_got ~mod+= ((args.dst.since_mark().length() & 0xFFFFFFFF) as base.u32)
|
|
}
|
|
if status.is_ok() {
|
|
break
|
|
}
|
|
yield status
|
|
}
|
|
checksum_want = args.src.read_u32le?()
|
|
decoded_length_want = args.src.read_u32le?()
|
|
if (not this.ignore_checksum) and
|
|
((checksum_got != checksum_want) or (decoded_length_got != decoded_length_want)) {
|
|
return "?bad checksum"
|
|
}
|
|
}
|