Skip to content

feat(raw): decode Foveon, GoPro VC-5, Canon sRAW and Kodak RADC natively - #102

Merged
IAmJSD merged 1 commit into
mainfrom
raw-remaining-codecs
Sep 3, 2026
Merged

IAmJSD merged 1 commit into
mainfrom
raw-remaining-codecs

Conversation

@IAmJSD

@IAmJSD IAmJSD commented Sep 3, 2026

Copy link
Copy Markdown
Member

Summary

The last codecs the clean-room crate declined after #98, done the same two-team way (spec writers read the reference under /tmp and wrote prose specifications; implementers worked from the specs, the samples and oracle output only) with one addition: a triage step first — for each format, can any buildable reference produce a frame to verify against? Based on the squash-merged main.

codec result
Sigma Foveon X3F, Merrill and Quattro 6/6 exact, three sensor planes (colour from the camera table); SD9/SD10/SD14 declined, no sample
GoPro VC-5 (GPR) 4/4 exact, ~100 MP/s; oracle from GoPro's Apache-2.0 converter cross-checked against LibRaw
Canon sRAW/mRAW 50D and 7D exact (4/4, planar and full RGB stages); 5D Mark II/III declined by model until verified
Kodak DC40/DC50 RADC 1/1 exact

Two triage findings worth knowing: LibRaw 0.21.2 does read X3F (compiled out by default, USE_X3FTOOLS), contrary to what the first round concluded; and a reviewer fetched six more subsampled Canon bodies, which is how the 50D-fitted colour stage was caught and gated.

Deliberately still on the LibRaw fallback: Fuji SuperCCD (decode is trivial and oracle-verified, but its 45° sensor grid is not representable in RawImage/Cfa — needs a rotate stage), Nikon Z High Efficiency (licensed intoPIX TicoRAW; nothing reads it without the SDK), Sigma SD9/SD10/SD14 and CR3-container sRAW (no samples).

Review (two passes, ~13k mutated inputs, no blind panics): fixed Foveon Huffman bounds (two one-byte panics), an unvalidated Quattro plane table (a 1.8 GB allocation lever), missing Foveon levels/crop, a VC-5 precision assumption, sRAW's slice-count hang and forged-SOF allocation, and its 50D-only colour stage (gains now keyed by ColorData version; hue/matrix gated by model id). Reviewer-flagged for a human: the spec relays reference-derived colour constants for sRAW (the YCbCr matrix and hue rules) that no public document yields — a project-level call on what a spec may carry.

Plugin: a body with no colour matrix now develops in camera RGB when LibRaw cannot render it either (Foveon on a stock LibRaw), instead of failing; and a native "no embedded preview" is no longer overridden by a LibRaw open failure (GPR).

Test plan

  • Crate: 403 tests incl. every spec's worked values and per-format corpus comparison (SCHIST_RAW_CORPUS=/tmp/rawsamples)
  • Plugin sweep over the full corpus (256 files); native-vs-LibRaw comparison: 114 compared, none below 20 dB
  • The 1:1 lossless-JPEG path confirmed byte-identical across a 243-file A/B before/after the sRAW change
  • cargo fmt --check, clippy -D warnings on both crates

🤖 Generated with Claude Code

The last codecs the clean-room crate declined, done the same two-team
way as before — separate agents read the reference and wrote functional
specifications; the implementers worked from those, the samples and the
oracle output only — with a triage step first: for each format, can any
buildable reference produce a frame to verify against? Three could,
one could not, and two are declined on purpose:

  Sigma Foveon X3F, Merrill and Quattro    6/6 exact (three sensor planes;
                                           colour from the camera table)
  GoPro VC-5 (GPR)                         4/4 exact, ~100 MP/s
  Canon sRAW/mRAW                          50D and 7D exact (4/4); the
                                           5D Mark II/III are declined by
                                           model until verified
  Kodak DC40/DC50 RADC                     1/1 exact

Triage corrected an earlier belief: LibRaw 0.21.2 does read X3F, it is
merely compiled out by default; rebuilt with the flag it gave a proper
3-plane oracle. GoPro's own Apache-2.0 converter, cross-checked against
LibRaw on its output, gave the VC-5 oracle.

Still on the LibRaw fallback, deliberately: Fuji SuperCCD (a trivial
decode, but its 45° sensor grid has no representation in RawImage yet),
Nikon Z High Efficiency (licensed TicoRAW; nothing can read it without
the vendor SDK), Sigma SD9/SD10/SD14 and CR3-container sRAW (no sample).

Reviewed adversarially (~13k mutated inputs, no blind panics): the
findings — Foveon Huffman bounds, an unvalidated Quattro plane table,
missing Foveon levels and crop, a VC-5 precision assumption, sRAW's
50D-fitted colour stage and a slice-count hang — are fixed, with the
sRAW colour reconstruction now gated to the bodies it is verified on.

The plugin now develops a body with no colour matrix in camera RGB when
LibRaw cannot render it either, instead of failing, and a definitive
native "no embedded preview" is no longer overridden by a LibRaw open
failure.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@IAmJSD
IAmJSD merged commit aac982d into main Sep 3, 2026
4 checks passed
@IAmJSD
IAmJSD deleted the raw-remaining-codecs branch September 3, 2026 17:02
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