Skip to content

JPEG lab, slice 3: Quantize, Zigzag, Run-length, Huffman and Decode - #40

Merged
benjamin-small merged 10 commits into
mainfrom
jpeg-lab-pipeline
Oct 16, 2026
Merged

benjamin-small merged 10 commits into
mainfrom
jpeg-lab-pipeline

Conversation

@benjamin-small

Copy link
Copy Markdown
Owner

Stages 5–9 of the JPEG lab: Quantize, Zigzag, Run-length, Huffman and Decode. Plan: docs/superpowers/plans/2026-10-16-jpeg-lab-3-pipeline.md. The spec carries the Plan 3 amendment.

What's in it

  • Quantize:
    • An editable Q table, applied through the rule config (tables). A "Custom Q tables · Standard" chip shows on every stage while custom tables are in use.
    • Coefficients before and after rounding, and the block the decoder rebuilds.
    • The R–D curve: q = 1…100 through the kit, within an ~8 ms frame budget, cached per picture and settings.
  • Zigzag:
    • The viz animates the scan path and reports its progress through viz_readout().
    • The sequence strip marks the zero tail.
  • Run-length: token chips that show each Huffman code and its amplitude bits. Together they spell out the block's bits exactly.
  • Huffman:
    • Four tables from rule_inspect("huffman"), each with a histogram, a code tree and its cost against the entropy bound. The bound now compares code bits only; amplitude bits are shown separately.
    • The block's bits, coloured by part.
    • The file's segments, from rule_inspect("segments").
    • The size with the other Huffman mode.
  • Decode:
    • A wipe between the decoded image and the original, and a brightened error map.
    • Artifact hints computed in Rust: blocking, ringing (none on pictures without hard edges) and colour bleed.
    • Re-save ×20 generation loss, disabled while custom tables are in use.

Tests

  • cargo test --all-features: 85 + 311
  • wasm-pack in headless Chrome: 47
  • vitest: 526 in 37 files
  • svelte-check: 0 errors
  • fmt and clippy: clean (only the existing sierpinski warnings)
  • A headless Playwright pass against the real engine on every new stage

Review

  • Per-task reviews: two tasks needed one fix round each.
  • Opus final review: "with fixes". One fix wave closed all 12 items, and the re-review found no new issues.
  • Deferred minors are parked for Plan 4: mobile polish, the tab pattern, small test gaps.

@benjamin-small
benjamin-small merged commit 07ff9f3 into main Oct 16, 2026
6 checks passed
@benjamin-small
benjamin-small deleted the jpeg-lab-pipeline branch October 16, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant