Add gif.config_decoder (part 2 of 2)

This runs script/preprocess-wuffs.go as foreshadowed by the previous
commit 1aa50163 "Add gif.config_decoder (part 1 of 2)".

The new gif.config_decoder type is largely a copy/paste (with minor
edits) of the existing decoder type, but it can decode GIF animation
metadata (e.g. frame timings) without the memory requirements of a
complete GIF decoder (which can also decode pixels). As of this commit,
sizeof(config_decoder) and sizeof(decoder) is 1320 and 65024, a
difference of over 62 KiB.

The trade-off is that binary size increased by around 1.5x or 18K for
the GIF package. Future refactorings might be able to claw that back,
but it might not.

"wuffs genlib; ls -l gen/lib/c/*/*gif* | awk etc" output:

Before:
25904 gen/lib/c/clang-5.0-dynamic/wuffs-std-gif.lo
26424 gen/lib/c/clang-5.0-static/wuffs-std-gif.o
30480 gen/lib/c/gcc-dynamic/wuffs-std-gif.lo
30064 gen/lib/c/gcc-static/wuffs-std-gif.o

After:
41168 gen/lib/c/clang-5.0-dynamic/wuffs-std-gif.lo
42328 gen/lib/c/clang-5.0-static/wuffs-std-gif.o
49040 gen/lib/c/gcc-dynamic/wuffs-std-gif.lo
48304 gen/lib/c/gcc-static/wuffs-std-gif.o
This commit is contained in:
Nigel Tao committed 2020-02-05 17:25:39 +11:00
1 parent 1aa501632f
commit 555e8eaaa3
3 files changed
+3053 -3

No files matched your search

+18 -3
View File
@@ -165,13 +165,13 @@ const char* test_basic_sub_struct_initializer() {
const char* test_wuffs_gif_decode_interface_image_config_decoder() {
CHECK_FOCUS(__func__);
wuffs_gif__decoder dec;
wuffs_gif__config_decoder dec;
CHECK_STATUS("initialize",
wuffs_gif__decoder__initialize(
wuffs_gif__config_decoder__initialize(
&dec, sizeof dec, WUFFS_VERSION,
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
return do_test__wuffs_base__image_config_decoder(
wuffs_gif__decoder__upcast_as__wuffs_base__image_decoder(&dec),
wuffs_gif__config_decoder__upcast_as__wuffs_base__image_decoder(&dec),
"test/data/animated-red-blue.gif", 0, SIZE_MAX, 4);
}
@@ -1931,6 +1931,20 @@ const char* test_wuffs_gif_small_frame_interlaced() {
return NULL;
}
const char* test_wuffs_gif_sizeof() {
CHECK_FOCUS(__func__);
size_t n0 = sizeof(wuffs_gif__config_decoder);
size_t n1 = sizeof(wuffs_gif__decoder);
// As of 2020-02-05, the two sizeof's differ by over 60KiB. The exact
// difference doesn't really matter, just that it's non-trivial.
if ((n1 < n0) || ((n1 - n0) < 8192)) {
RETURN_FAIL(
"config_decoder (%zu) not substantially smaller than decoder (%zu)", n0,
n1);
}
return NULL;
}
// ---------------- Mimic Tests
#ifdef WUFFS_MIMIC
@@ -2310,6 +2324,7 @@ proc tests[] = {
test_wuffs_gif_io_position_one_chunk, //
test_wuffs_gif_io_position_two_chunks, //
test_wuffs_gif_small_frame_interlaced, //
test_wuffs_gif_sizeof, //
#ifdef WUFFS_MIMIC