Files
wuffs/std/lzw
Nigel Tao 91bf555431 Optimize some std/gif if blocks
name                             old speed     new speed     delta

wuffs_lzw_decode_20k/clang       123MB/s ± 1%  124MB/s ± 0%   +0.91%  (p=0.000 n=46+9)
wuffs_lzw_decode_100k/clang      156MB/s ± 1%  164MB/s ± 1%   +5.07%  (p=0.000 n=46+10)

wuffs_lzw_decode_20k/gcc         167MB/s ± 2%  167MB/s ± 0%     ~     (p=0.933 n=46+8)
wuffs_lzw_decode_100k/gcc        243MB/s ± 3%  247MB/s ± 0%   +1.56%  (p=0.000 n=47+9)

wuffs_gif_decode_1k_bw/clang     263MB/s ± 1%  266MB/s ± 1%   +1.02%  (p=0.000 n=46+10)
wuffs_gif_decode_1k_color/clang  147MB/s ± 1%  122MB/s ± 0%  -16.63%  (p=0.000 n=46+10)
wuffs_gif_decode_10k/clang       134MB/s ± 2%  115MB/s ± 1%  -14.02%  (p=0.000 n=49+10)
wuffs_gif_decode_100k/clang      115MB/s ± 1%  113MB/s ± 0%   -1.73%  (p=0.000 n=44+9)
wuffs_gif_decode_1000k/clang     117MB/s ± 1%  115MB/s ± 1%   -2.10%  (p=0.000 n=46+9)

wuffs_gif_decode_1k_bw/gcc       291MB/s ± 1%  298MB/s ± 1%   +2.46%  (p=0.000 n=44+9)
wuffs_gif_decode_1k_color/gcc    138MB/s ± 1%  163MB/s ± 1%  +18.50%  (p=0.000 n=45+10)
wuffs_gif_decode_10k/gcc         134MB/s ± 2%  152MB/s ± 0%  +13.37%  (p=0.000 n=47+9)
wuffs_gif_decode_100k/gcc        121MB/s ± 1%  134MB/s ± 0%  +11.18%  (p=0.000 n=46+8)
wuffs_gif_decode_1000k/gcc       124MB/s ± 2%  138MB/s ± 1%  +11.07%  (p=0.000 n=47+9)
2018-06-30 08:33:23 +10:00
..
2018-06-02 14:15:09 +10:00

LZW (Lempel Ziv Welch) Compression

LZW is a general purpose compression algorithm, not specific to GIF, PDF, TIFF or even to graphics. In practice, there are two incompatible implementations, LSB (Least Significant Bits) and MSB (Most Significant Bits) first.

The GIF format uses LSB first. The literal width can vary between 2 and 8 bits, inclusive. There is no EarlyChange option.

The PDF and TIFF formats use MSB first. The literal width is fixed at 8 bits. There is an EarlyChange option that PDF sometimes uses (see Table 3.7 in the PDF 1.4 spec) and TIFF always uses.

TODO: refactor this README.md file and std/gif's one.