we (web engine): Experimental web browser project to understand the limits of Claude

DEFLATE decompressor (RFC 1951) #64

open opened by pierrelf.com

Implement a pure Rust DEFLATE decompressor in the image crate (or a shared module within it) per RFC 1951.

Requirements#

  • Decode DEFLATE compressed data streams
  • Support all three block types:
    • Non-compressed blocks (BTYPE=00)
    • Fixed Huffman codes (BTYPE=01)
    • Dynamic Huffman codes (BTYPE=10)
  • Huffman tree construction from code lengths
  • LZ77 back-reference decoding (length/distance pairs)
  • Streaming-friendly API: fn inflate(input: &[u8]) -> Result<Vec<u8>, DeflateError>

Acceptance Criteria#

  • Passes round-trip tests with known compressed data
  • Handles edge cases: empty input, maximum back-reference distance (32KB window), all block types
  • Unit tests for Huffman tree construction, each block type, and error cases
  • No external dependencies
  • No unsafe

Context#

This is the foundation for zlib (used by PNG) and potentially gzip. Must be implemented before the PNG decoder.

Phase 7 — Image Decoders

sign up or login to add to the discussion
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:meotu43t6usg4qdwzenk4s2t/sh.tangled.repo.issue/3mgwaqipy4p25