Repository navigation
feat(raw): decode CR3, compressed RAF, CRW, NX1, IIQ S and Panasonic v8 natively - #98
Merged
Merged
Conversation
…v8 natively The six codecs the clean-room crate declined, implemented clean-room in the classic two-team form: separate agents read the LGPL reference and wrote functional specifications (prose, tables, worked intermediate values from an instrumented build) under /tmp; the implementers worked from those specifications, the sample files and LibRaw's oracle output only, and never opened the reference. Every one now matches LibRaw's unpacked frame sample for sample across the corpus: Canon CR3 (CRX lossless and lossy) 10/10 EOS R, 90D, R5, R8 Fujifilm compressed RAF (lossless, lossy) 4/4 X100F, X-Pro3, X-T5, GFX100S Canon CRW compressed 3/3 D60, 10D, G2 Samsung SRW compression 32773 2/2 NX1, NX500 Phase One IIQ S (formats 5 and 6) 6/6 P25+, P45, H25, iXU180, IQ140 Panasonic RW2 RawFormat 8 2/2 GH6, G9 II LibRaw 0.21.2 does not implement RawFormat 8 and lacks the Samsung output clamp, so those four oracle dumps were regenerated from 0.22.2. The implementers fed back a dozen corrections to the specifications (the Samsung length-0 dequantiser offset alone would have corrupted 15% of an NX500 frame followed literally), all recorded in module docs. Reviewed adversarially (80k mutated inputs, no blind panics): the five hand-targeted crashes it found — CRX allocating from an unbounded header, a zero bit depth, a quantiser-step overflow, the Panasonic curve underflowing on a forged threshold, the CRW predictor overflowing on a crafted stream — are fixed, along with a quadratic CRX frame assembly. Co-Authored-By: Claude Fable 5.1 <[email protected]>
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The six codecs
schist-codec-rawdeclined after #94 now decode natively, so LibRaw is only reached for Foveon, GoPro VC-5 and a few old odd formats. Based on main with #97 merged.Method. Classic two-team clean room: three separate agents read the LGPL reference (fetched under
/tmp, never into the repo), instrumented it, and wrote functional specifications in prose and tables with worked intermediate values (/tmp/raw-specs/*.md). Three implementers then worked from those specifications, the sample files and LibRaw's oracle output only, and never opened the reference. The specification writers reported only summaries to the coordinator, so no source entered the coordinating context either.Every allow-list in those modules is now empty. Against LibRaw's own development the new paths sit at 36–45 dB in the plugin's comparison harness (110 files compared, none below 20 dB).
Oracle note. LibRaw 0.21.2 (the box's package) does not implement RawFormat 8 and lacks the Samsung output clamp; the four affected oracle dumps were regenerated from LibRaw 0.22.2 (recorded in
/tmp/raw-specs/oracle-notes.md).Spec corrections found by the implementers (all in module docs): the Samsung length-0 dequantiser offset (would have corrupted 15% of an NX500 frame followed literally), Phase One row interleave and companding notes, a CRW record-field offset, a Fuji prose off-by-one, and CRX's predictor being numerically the LOCO-I median.
Review. 80,863 mutated inputs across all six codecs with overflow checks on: no blind panics. Five hand-targeted crashes were found and are fixed here: CRX allocating from an unbounded header (now through the crate's frame ceiling), a zero bit depth, a quantiser-step overflow, the Panasonic curve underflowing on a forged threshold, the CRW predictor overflowing on a crafted stream; plus a quadratic CRX frame assembly (24 MB → 9 s) rewritten to one pass. Latent items noted, not fixed: a compressed RAF whose strip header disagrees with the container is refused rather than trusting the header; a corrupt Samsung v3 row desyncs the rest of the frame into noise rather than black; Phase One's per-row/column black tables are not applied (LibRaw's dump doesn't either).
For a human to judge
Test plan
SCHIST_RAW_CORPUS=/tmp/rawsamples)cargo fmt --check, clippy-D warningson the crate🤖 Generated with Claude Code