mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-19 16:47:28 +01:00
Have lzw rewind in and flush out on a bad code
name old speed new speed delta wuffs_lzw_decode_20k/clang 214MB/s ± 0% 204MB/s ± 2% -4.62% (p=0.008 n=5+5) wuffs_lzw_decode_100k/clang 369MB/s ± 0% 337MB/s ± 2% -8.72% (p=0.008 n=5+5) wuffs_lzw_decode_20k/gcc 232MB/s ± 1% 236MB/s ± 0% +1.99% (p=0.008 n=5+5) wuffs_lzw_decode_100k/gcc 384MB/s ± 1% 396MB/s ± 1% +3.00% (p=0.008 n=5+5) wuffs_gif_decode_1k_bw/clang 236MB/s ± 0% 230MB/s ± 0% -2.67% (p=0.008 n=5+5) wuffs_gif_decode_1k_color/clang 118MB/s ± 1% 120MB/s ± 0% +1.10% (p=0.008 n=5+5) wuffs_gif_decode_10k_bgra/clang 562MB/s ± 0% 562MB/s ± 0% ~ (p=0.690 n=5+5) wuffs_gif_decode_10k_indexed/clang 149MB/s ± 0% 149MB/s ± 0% ~ (p=0.421 n=5+5) wuffs_gif_decode_100k_artificial/clang 487MB/s ± 0% 459MB/s ± 1% -5.63% (p=0.008 n=5+5) wuffs_gif_decode_100k_realistic/clang 183MB/s ± 0% 174MB/s ± 0% -4.52% (p=0.008 n=5+5) wuffs_gif_decode_1000k/clang 185MB/s ± 0% 177MB/s ± 1% -4.61% (p=0.008 n=5+5) wuffs_gif_decode_anim_screencap/clang 1.02GB/s ± 0% 0.97GB/s ± 0% -5.30% (p=0.008 n=5+5) wuffs_gif_decode_1k_bw/gcc 250MB/s ± 0% 249MB/s ± 0% -0.63% (p=0.016 n=5+5) wuffs_gif_decode_1k_color/gcc 133MB/s ± 0% 133MB/s ± 1% ~ (p=0.151 n=5+5) wuffs_gif_decode_10k_bgra/gcc 543MB/s ± 1% 543MB/s ± 0% ~ (p=0.548 n=5+5) wuffs_gif_decode_10k_indexed/gcc 167MB/s ± 1% 166MB/s ± 1% -0.83% (p=0.032 n=5+5) wuffs_gif_decode_100k_artificial/gcc 465MB/s ± 1% 465MB/s ± 1% ~ (p=0.841 n=5+5) wuffs_gif_decode_100k_realistic/gcc 190MB/s ± 0% 190MB/s ± 1% ~ (p=0.222 n=5+5) wuffs_gif_decode_1000k/gcc 192MB/s ± 1% 193MB/s ± 0% ~ (p=0.421 n=5+5) wuffs_gif_decode_anim_screencap/gcc 1.00GB/s ± 1% 1.00GB/s ± 1% ~ (p=0.841 n=5+5)
This commit is contained in:
1 parent
010df42d75
commit
179f7afb9b
3 files changed
+68
-4
No files matched your search
+48
-1
@@ -197,6 +197,52 @@ const char* test_wuffs_lzw_decode_pi() {
|
||||
"test/data/pi.txt", 100003, 0, 0);
|
||||
}
|
||||
|
||||
const char* test_wuffs_lzw_decode_output_bad() {
|
||||
CHECK_FOCUS(__func__);
|
||||
|
||||
wuffs_base__io_buffer got = ((wuffs_base__io_buffer){
|
||||
.data = global_got_slice,
|
||||
});
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = global_src_slice,
|
||||
});
|
||||
|
||||
// Set up src to be 20 bytes long, starting with three 8-bit literal codes
|
||||
// (0x41, 0x42, 0x43) then a bad 8-bit code 0xFF. Decoding should produce 3
|
||||
// bytes and consume 4 bytes.
|
||||
src.meta.wi = 20;
|
||||
int i;
|
||||
for (i = 0; i < src.meta.wi; i++) {
|
||||
src.data.ptr[i] = 0;
|
||||
}
|
||||
src.data.ptr[0] = 0x41;
|
||||
src.data.ptr[1] = 0x42;
|
||||
src.data.ptr[2] = 0x43;
|
||||
src.data.ptr[3] = 0xFF;
|
||||
|
||||
wuffs_lzw__decoder dec = ((wuffs_lzw__decoder){});
|
||||
const char* z =
|
||||
wuffs_lzw__decoder__check_wuffs_version(&dec, sizeof dec, WUFFS_VERSION);
|
||||
if (z) {
|
||||
RETURN_FAIL("check_wuffs_version: \"%s\"", z);
|
||||
}
|
||||
wuffs_lzw__decoder__set_literal_width(&dec, 7);
|
||||
|
||||
z = wuffs_lzw__decoder__decode(&dec, wuffs_base__io_buffer__writer(&got),
|
||||
wuffs_base__io_buffer__reader(&src));
|
||||
if (z != wuffs_lzw__error__bad_code) {
|
||||
RETURN_FAIL("decode: \"%s\"", z);
|
||||
}
|
||||
|
||||
if (got.meta.wi != 3) {
|
||||
RETURN_FAIL("got.meta.wi: got %d, want 3", (int)(got.meta.wi));
|
||||
}
|
||||
if (src.meta.ri != 4) {
|
||||
RETURN_FAIL("src.meta.ri: got %d, want 4", (int)(src.meta.ri));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* test_wuffs_lzw_decode_output_empty() {
|
||||
CHECK_FOCUS(__func__);
|
||||
|
||||
@@ -208,7 +254,7 @@ const char* test_wuffs_lzw_decode_output_empty() {
|
||||
});
|
||||
|
||||
// Set up src to be 20 bytes long, starting with the 9-bit end code 0x101.
|
||||
// Decoding should consume only 2 of those bytes.
|
||||
// Decoding should produce 0 bytes and consume 2 bytes.
|
||||
src.meta.wi = 20;
|
||||
int i;
|
||||
for (i = 0; i < src.meta.wi; i++) {
|
||||
@@ -308,6 +354,7 @@ proc tests[] = {
|
||||
test_wuffs_lzw_decode_bricks_nodither, //
|
||||
test_wuffs_lzw_decode_many_big_reads, //
|
||||
test_wuffs_lzw_decode_many_small_writes_reads, //
|
||||
test_wuffs_lzw_decode_output_bad, //
|
||||
test_wuffs_lzw_decode_output_empty, //
|
||||
test_wuffs_lzw_decode_pi, //
|
||||
|
||||
|
||||
Reference in new issue
Block a user