Nibnib: Extreme Speed Image Format for Embedded Displays
Nibnib is an image format designed for extreme decompression speed on microcontrollers like the RP2350. Instead of storing absolute color values, it uses a palette of delta values, which improves quality in soft image regions. The decoder achieves 4bpp compression by processing two pixels from each input byte—a simple, deterministic operation that doubles the previous pixel value and adds a palette-looked-up result.
Decompression is simple, relying on basic bit operations, arithmetic, and memory lookups. Encoding works differently: it searches through possible encoded images to find high-quality matches to the original, using Floyd-Steinberg error diffusion to distribute quantization errors. The palette combines structured delta values with random entries selected through Gaussian processes. Current encoders run orders of magnitude slower than decoders because they must evaluate all palette options to minimize error across pixel pairs.
This asymmetrical design prioritizes decoding speed over encoding complexity. Greedy search produces artifacts trailing right of sharp edges, and the palette isn’t adaptively optimized for each image. However, improvements to the encoder don’t affect decompression performance, making the format practical for implementations tightly integrated with the decoder.
Read the full article
Continue reading at Hacker News →This is an AI-generated summary. Read the original for the full story.