Skip to content

Decode baseline JPEG images - #27

Merged
MPCoreDeveloper merged 2 commits into
mainfrom
feat/jpeg-baseline-decoder
Nov 15, 2026
Merged

MPCoreDeveloper merged 2 commits into
mainfrom
feat/jpeg-baseline-decoder

Conversation

@MPCoreDeveloper

Copy link
Copy Markdown
Owner

Summary

The third slice of 4a-volledig (ADR-005): baseline DCTDecode.

  • Pdf/JpegDecoder.cs — marker parsing (DQT, DHT, SOF0/SOF1, SOS, DRI, APP14 Adobe), canonical Huffman decoding, MCU/block decode with an 8×8 inverse DCT, restart-interval handling, and the colour paths: Gray8 (1 component), Rgb24 (3, YCbCr converted or direct RGB when Adobe transform 0), Cmyk32 (4, CMYK as stored or YCCK with transform 2).
  • PdfPageContentReader fills DecodedPixels from it while Data keeps the stored JPEG — the contract ADR-005 settled.
  • PdfJpegFilterTests — 4 cases against Pillow-written 16×16 fixtures at 4:4:4 and one component, with Pillow's own decode as the reference and a ±2 levels tolerance; plus the budget and a non-JPEG stream.

What the fixtures do and do not cover

The 4:4:4 fixture is deliberate: no chroma upsampling, so a bug in the block/IDCT/Huffman path is not masked. The survivors of the mutation run name the missing fixtures — 4:2:0 (fancy upsampling), CMYK/YCCK, restart intervals, 16-bit quantisation, malformed streams — and they are the next tests.

Evidence

  • dotnet build -c Release → 0 warnings, 0 errors; dotnet test → 1246 passed, 0 failed on net10.0 and net11.0.
  • Scoped Stryker on JpegDecoder.cs → 61.65% (671 mutants: 351 killed, 114 survived, 105 no coverage). docs/mutation-testing.md reads the survivors.
  • The manual is rebuilt (check: ok); ADR-005, parity row 14, chapter 8 and the changelog record the slice.

Next

SOF2 (progressive), then the 4:2:0/CMYK/restart fixtures, then JPXDecode and JBIG2Decode per ADR-005.

JpegDecoder parses the marker segments, builds the canonical Huffman tables, decodes the MCUs with an
8 x 8 inverse DCT, and states the samples as Gray8, Rgb24 (YCbCr converted) or Cmyk32 (CMYK/YCCK with the
Adobe transform). PdfPageContentReader fills DecodedPixels from it while Data keeps the stored JPEG, so a
caller can have either.

The decoder is checked against 16 x 16 Pillow-written fixtures at 4:4:4 and one component, with Pillow own
decode as the reference and a two-level tolerance. Progressive (SOF2), the fancy chroma upsampling a 4:2:0
fixture needs, CMYK and restart-interval fixtures are the next tests; ADR-005 records them.

The scoped Stryker run over JpegDecoder.cs is 61.65% (671 mutants: 351 killed, 114 survived, 105 no
coverage); the survivors are the variants the two fixtures do not carry, and docs/mutation-testing.md
reads them.
@MPCoreDeveloper
MPCoreDeveloper merged commit 37d5b27 into main Nov 15, 2026
8 checks passed
@MPCoreDeveloper
MPCoreDeveloper deleted the feat/jpeg-baseline-decoder branch November 15, 2026 08:53
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