Skip to content

Decode RunLength images, and scope the remaining image codecs - #20

Merged
MPCoreDeveloper merged 1 commit into
mainfrom
feat/runlength-image-decoders
Nov 14, 2026
Merged

MPCoreDeveloper merged 1 commit into
mainfrom
feat/runlength-image-decoders

Conversation

@MPCoreDeveloper

Copy link
Copy Markdown
Owner

Summary

First slice of 4a-volledig (the image filters the reader passes through), plus the ADR that scopes the rest.

RunLengthDecode

  • Pdf/PdfFilters.RunLength.cs — literal runs (control + 1 bytes) and repeat runs (257 - control), the end-of-data byte optional, and a truncated stream decoded as far as it goes.
  • PdfImageFilters dispatches it, so an image that declares it now reports IsDecodable true and yields samples; ImagePixels exposes them as Gray8, Rgb24 or Cmyk32.
  • The FilterChains fixture now actually run-length-encodes its samples (it was storing them raw), and Decodes_a_run_length_image replaces the theory that pinned the old “cannot decode” behaviour.

ADR-005 — the remaining four

docs/adr/0005-image-filter-decoders.md accepts CCITTFaxDecode, DCTDecode, JPXDecode and JBIG2Decode in that order, hand-written with no package reference (ADR-001), each with the independent decoder its acceptance needs:

Filter Acceptance
CCITTFaxDecode bit-equal to Pillow's CCITT reader
DCTDecode geometry exact, every sample within 2 levels of Pillow
JPXDecode reversible path bit-exact, irreversible within 2 levels of opj_decompress
JBIG2Decode bit-exact to jbig2dec

A test the harness exposed

Writes_the_font_fixture_the_external_validator_reads wrote a fixed temp path. Stryker runs the suite once per project in parallel, so four copies raced on the same file and the initial run failed. The name is now unique (Guid), which is the correct behaviour whether or not the harness is watching.

Evidence

  • dotnet build -c Release → 0 warnings, 0 errors; dotnet test → 1234 passed, 0 failed on net10.0 and net11.0.
  • Scoped Stryker on PdfFilters.RunLength.cs → 96.00% (22 killed, 1 survivor, 31 mutants). The survivor is control < 128 → <=, shadowed by the == 128 check above it; two other survivors were redundant statements and were removed. Recorded in docs/mutation-testing.md.

Not in this PR

CCITTFaxDecode, DCTDecode, JPXDecode and JBIG2Decode are the next slices, in the order ADR-005 records; each is a decoder of its own and lands with its own evidence and mutation record.

RunLengthDecode joins Flate, LZW and the two ASCII filters: PdfFilters.RunLength decodes the literal
and repeat runs (a truncated stream yields what it stated), PdfImageFilters dispatches it, and an image
that declares it now yields samples and Gray8/Rgb24/Cmyk32 pixels instead of ImageFilterUnsupported.

ADR-005 accepts the remaining four filters - CCITTFaxDecode, DCTDecode, JPXDecode, JBIG2Decode - in that
order, hand-written with no package reference, each with the independent decoder its acceptance needs.
The status table records RunLength as done and the rest as planned.

The scoped Stryker run over PdfFilters.RunLength.cs is 96.00% (22 killed, 1 survivor, 31 mutants); the
survivor is the < that the end-of-data check above it shadows. Two statements were removed because a
survivor said so: the Math.Max capacity hint and the count <= 0 guard.

The font-fixture test now writes a unique temp file: the mutation harness runs the suite once per project
in parallel, and a fixed name let one copy read a file another was still writing.
@MPCoreDeveloper
MPCoreDeveloper merged commit abd2c3f into main Nov 14, 2026
8 checks passed
@MPCoreDeveloper
MPCoreDeveloper deleted the feat/runlength-image-decoders branch November 14, 2026 21:56
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