Code Poetry
and Text Adventures

by catid posted (>30 days ago) 6:47pm Thu. May 16th 2013 PDT
Right now GCIF doesn't have good performance for small palettes.  So I'm going to do something like what WebP does in this case: Combine several pixels together into one byte and then do palette-mode compression with the result.

I'm going to need to add byte-wise modes to the preprocessing steps since currently they expect to work with RGBA data.  Preprocessing during encoding is currently incredibly fast so this won't hurt anything.  The decoder will only need minimal changes that should be done anyway.

Also I've seen that my palette-mode compression performance is about 9-11:1, and RGBA compression is about 2-4:1, so thresholds for enabling preprocessing steps should be multiplied by about 4 for paletted images.

The process will become:
(1) Check for small palette condition.  If so:
(2) Repack the small palette pixels into bytes, several pixels per byte.
(3) Perform LZ and masking with byte-mode and higher thresholds.
(4) Generate byte-wise palette (enabled with a new "small palette" bit) since it won't use all 256 numbers and perform palette-mode compression as normal.

...

(5) On the decoder, as palette-mode decompression occurs, generate a palette index matrix at the output.
(6) After the index matrix is recovered, instead of doing table lookups to recover the original RGBA color data, unpack the small palette pixels and use the small palette color table to decode the result.

After this is added, GCIF performance should be much better than PNG for small palettes like 1-bit monochrome images.