* CRW-LIB: decode Canon CRW through the shared craft-crw crate
LightCraft decodes Canon CRW (the CIFF raws of the EOS D30, D60, 10D, 300D and the
PowerShot G1/G6) through craft-libs' `craft-crw`, the clean-room decoder derived and
verified on the `clean-room-crw-format-decode` branch and moved there with its frozen
tables and derivation record. `crates/raw/src/vendor/crw.rs` is now the adapter: it maps
the crate's header and samples onto `RawImage` (CFA, levels, active area, orientation,
as-shot white balance, the make/model/time records a CRW keeps instead of Exif) and
converts the capture time through chrono. The dependency is a local path
(`../craft-libs/crates/crw`) until the craft-libs branch merges; then it becomes a git
revision.
Everything LightCraft-side from that branch comes along unchanged: `probe_bytes` fills
metadata gaps from the decoder's records so CRW imports name their camera; the EOS D60
bundled camera profile and its chart-measured dual-illuminant matrices (`chart_table.rs`,
`spectral::Camera` carries its illuminant pair) give the D60 a Kelvin white-balance scale;
CRW joins the JPEG-fitted starting look, the catalog's raw formats and `lightcraft-cli
calibrate`; `RENDER_CACHE_VERSION` 71; the CC0 CRW corpus entries for `cargo xtask corpus`;
coverage, parity, gaps, raw-parity, target-app-parity and ROADMAP updates. The G5 stays
preview-only (the crate refuses it with the reason) and the robustness test keeps its CRW
sample.
What does not come along: the decoder, its tables and `crw_oracle.rs` (now craft-crw's
digest-pinned sample test) and the derivation record, which lives in craft-libs
`crates/crw/clean-room/`. `clean-room/crw/` here keeps only the EOS D60 chart-calibration
document and its capture list, with a README pointing at the record.
Gates: fmt, clippy -D warnings (raw all targets; engine, catalog, cli), lightcraft-raw tests
(475 + 134, the corpus files decoding through the adapter), catalog tests, engine lib tests
(1,300 pass; the two failures, `tests_import::recursive_discovery_…` and
`originals::tests::write_targets_pin_absent_paths_…`, are in files unchanged from main),
`cargo xtask parity`, `assets`, `layers`, `coverage.py --check`.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* no message
* no message
* Update documentation after moving code to craft-libs
* Review coment fixes
* CRW: pin craft-crw f3b62ec, a truncated entropy stream is Corrupt
craft-libs #472 makes craft_crw::decode refuse a stream that ends more than
Limits::max_stream_end_fill (64 samples, one block) before the frame does,
instead of filling the rest with predictor values and returning success.
The adapter already maps craft_crw::Error::Corrupt to RawError::Corrupt;
a regression test proves a truncated CRW now fails at this boundary (it
decoded as a flat frame on the old pin) while its header still reads.
Only craft-crw moves; craft-ui/docpath/update/window stay on c5a1cbf.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Code review comment fix
* Add some tests
---------
Co-authored-by: Robert Woldberg <314159+rwoldberg@users.noreply.github.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Conflicts: crates/engine/src/camera_preview.rs: LOOK_VERSION stays 13, all three version notes kept; docs/raw-parity.md header merged (newer date, both changes)
Review follow-up to the vignetting fit fix:
- `proxies` applies the embedded vignetting gain before it moves the sensor
into the camera JPEG's lens geometry, so a warped proxy pixel gets the gain
of the position it samples, as the render applies it.
- `alignment` reads NaN pixels (outside a lens-warped proxy) as missing. The
`max(1e-4)` turned them into black, a false edge along the border, and the
warped candidate lost on wide-angle RAFs with barrel distortion.
- Tests: the colour fit gets the embedded lens, the vignetting is applied
before the warp, and alignment ignores missing pixels.
27 + 60 X-S10 RAFs: mean ΔE00 unchanged (3.06, 2.55 -> 2.54), none worse by
more than 0.02.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The RAF look fit compared the uncorrected sensor proxy with the camera
JPEG, which is already corrected for vignetting, so the tone curve learned
the brightening and the render then applied the embedded vignetting
correction a second time. Shadows and midtones came out up to 0.6 / 0.3 EV
too light on X-S10 files.
`look_proxies` applies the embedded correction to the sensor proxy of
every per-file fit (colour, monochrome, near-black fallback), as
`fit_dng_tone` already did. LOOK_VERSION 13, RENDER_CACHE_VERSION 71.
60 held-out X-S10 RAFs: mean ΔE00 2.71 -> 2.55, 32 better, none worse by
more than 0.05.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- X-S20 lens distortion and vignetting scale fixes
- X-S20 / X-S10 / X-M5 spectral sensor mappings
- Add Samuel Li to contributors/people.toml
Co-Authored-By: Antigravity <noreply@google.com>
- address review concerns
- update RENDER_CACHE_VERSION value in docs/camera-preview-colour.md
- made sure diagonal scales are exact match
X-T20, X-T2, X-Pro2, X-E3, X-H1 and X100F have no measured colour matrix, so
As Shot showed on the relative scale. Their RAFs store the camera's own
neutral multipliers for Illuminant A and D65 (tag 0xf00c). Two points
give a line in (ln R/G, ln B/G); mired is linear along it, isotherms are
perpendicular, tint is scaled by the CIE locus spacing. Only the file's pair
and CIE colorimetry are used. Bodies with matrices are unchanged. The look
stays the per-file JPEG fit.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014ti8KemZbjE2ZgHgV1q1BM
docs/parity-checklist.md: header keeps the newer date; LR-IMP-FORMATS row keeps both sides' changes.
docs/raw-parity.md: header change note names both sides' changes.
docs/raw/coverage.tsv: merged cleanly; same rows as both sides, no duplicates (regenerated on the combined branch).
crates/engine/src/camera_preview.rs: LOOK_VERSION keeps both history lines and the higher value.
crates/engine/src/media.rs: RENDER_CACHE_VERSION keeps the higher value.
crates/engine/src/camera_preview.rs: LOOK_VERSION keeps the higher value; fit_tone_only_pairs (from #1616) takes the HighlightCheck of #699 from fit_tone_only_on, and fit_dark_tone passes its frame's (empty, as no JPEG pixel reaches 0.85) check.
crates/engine/src/media.rs: RENDER_CACHE_VERSION keeps the higher value.
docs/parity-checklist.md: LR-PROF-CAMERACOLOR row keeps both sides' changes.
crates/engine/src/camera_preview.rs: LOOK_VERSION keeps both history lines and the higher value.
crates/engine/src/media.rs: RENDER_CACHE_VERSION keeps the higher value.
To make room for the pooled extension in the curve's 32 knots, extend_tone kept every
n-th knot of the photo's own curve, which could move the curve inside the range its JPEG
showed (a sharp toe most). It now drops the knots the curve needs least, one at a time,
within one 8-bit code (thinned_knots); with fewer extension knots if needed, or the
photo's curve as fitted when even two don't fit. On a D750 bracket renders move by at
most dE 0.09. LOOK_VERSION 13. Found by CodeRabbit on #2093.
profile_samples returned nothing when collect_pairs found no colour pairs, so the darkest
photos, the ones that show the camera's toe, never reached the pooled tone curve. Their
tone samples are now kept; Pool counts them apart from the colour fit's photos and
calibrate reports them as tone only. A black-and-white camera JPEG (a monochrome picture
style's own mix and curve) gives nothing, as before. Found by CodeRabbit on #2093.
The pooled curve maps luminance through the profile's matrix. A photo whose own fit
rejected the profile's colour renders through its own matrix, so continuing its curve
along the pooled one gave it a highlight mapping fitted to other colours. Such a look now
keeps its curve as fitted (with_pooled_tone). LOOK_VERSION 12. Found by CodeRabbit on #2093.
lightcraft-cli calibrate also pools tone samples (camera RGB -> camera JPEG
luminance, dark pixels included) and fits one curve per camera by quantile
matching; profiles store it as an optional `tone` field (older profiles and
builds still load). A photo keeps its own curve as far as its JPEG showed it and
follows the pooled curve past that, faded over 1 EV (extend_tone), instead of
the bounded shoulder that rendered underexposed photos pushed back up 4-7 L*
too dark; a photo no look fits takes the pooled curve whole.
On NIKON D780 brackets, pushed frames now match the properly exposed frame
within 0.5 L*; on 120 held-out D780/D750/D90 photos rendered as shot the curve
changes mean dE against the camera JPEG by at most 0.03.
LOOK_VERSION 11.
A photo whose camera JPEG is too dark (or too colourless) for any look to fit
dropped its camera profile's colour for the neutral fallback. It now keeps the
profile's colour, with the JPEG's tone curve when one fits, else the default raw
tone curve (CameraTone::default_raw). On NIKON D780 frames 3.7 EV under, pushed
back up, colourfulness goes from 37% of the properly exposed frame's to 88-99%.
LOOK_VERSION 10, RENDER_CACHE_VERSION 65.
An X-T30 RAF shot in Acros embeds a black-and-white camera JPEG, so the
per-file look fits only the tone curve, and the colour came from the
neutral "camera RGB ~ sRGB" fallback: a grey sky and muted colours. The
raw decode (lossless compressed) was correct.
Add a hand-kept SAME_SENSOR alias list next to the generated
rawtoaces-data table: the 26.1 MP X-Trans CMOS 4 bodies (X-T30, X-T30 II,
X-Pro3, X100V, X-S10, X-E4) use the X-T3's measured matrices, and their
white balance reads in Kelvin through them.
Canon's maker-note ColorData lists the levels of each white-balance preset
with Canon's colour temperature for it. For versions -4 and 13-15 the
Daylight, Shade, Cloudy, Tungsten and Flash rows now give a Kelvin curve
(kelvin_presets, generalised from five fixed points to any number, with a
from_unordered constructor that sorts and drops points that would turn the
curve back). Fluorescent (off the locus) and the Kelvin row (the dial's last
setting) are left out. Enabled for the PowerShot G1 X Mark III, which has no
colour matrices: its nine as-shot white balances read within 4 % of the
camera's own ColorTempAsShot.
Sources: own design on the existing kelvin_presets model; ColorData row
positions from the ExifTool Canon tag-name documentation, confirmed with
ExifTool run as a black-box tool on sample files.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Use luminance pairs after the existing camera looks fail their colour-pair
minimum. Keep the source colour, exclude clipped pixels from training, and
check held-out luminance and each clipped pixel before accepting the curve.
The darkest supplied D610 sample changes from +2.81 to -0.09 stops at the
median. The other 15 renders are byte-identical. Add synthetic coverage for
source-colour precedence, independent holdout and invalid or clipped input.
Bump LOOK_VERSION to 10 and RENDER_CACHE_VERSION to 67 after checking open PRs.
Engine tests pass. Workspace tests pass with only the known #1457 overlay
test excluded. Formatting, Clippy, HEIC, parity, layers, assets and WASM pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both tone fits refused a curve when the brightest 1/32 of the training
pairs was less than 1.5x the darkest 1/32, a hard cliff before any
acceptance gate: a hazy ILCE-7RM4 burst (issue #631) opened with the
neutral fallback on frames just under it (DSC01630: range 1.489, dE76 vs
the camera JPEG 23.8) and with a camera look on the frame just over it.
MIN_TONE_RANGE = 1.2 still refuses nearly uniform pairs.
A curve under the old 1.5 must also keep the bright areas (camera JPEG
luminance 0.85 and up), which the fit and the held-out gates leave out, no
further from the camera JPEG than the neutral fallback (highlights_hold,
full and partial looks): fitted to a narrow range it extrapolates them, and
reviews found synthetic frames whose accepted curve rendered a 0.93 sky at
0.28 to 0.61. The bright pixels come from the proxies before any training
filter, and for DRO photos the curve is checked lowered as it will be
used, inside the search. The tone curve of a black-and-white camera JPEG
(#577) comes from the same fit, so it gets the same check, by luminance as
its own gates compare: a synthetic frame's 0.93 sky rendered at 0.28
without it. DSC01630 (DRO Auto): look accepted, dE76 1.94. Every other
file of a 309-file sweep (135 public Sony) renders pixel-identical, also
with the camera JPEGs made grey. RENDER_CACHE_VERSION 63, LOOK_VERSION 6
(smart previews refit).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Stacked on rb/1592: LOOK_VERSION 8 -> 9; the PR's corpus-profile helper is the base's corpus_uses_the_bundled_profile.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolved against rb-base-36: LOOK_VERSION 6 -> 7; starting_colour_tags passes no lens (merge frames arrive without it).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Docs conflicts resolved on upstream's text; MRW edits reapplied with
coverage re-measured by docs/raw/coverage.py (243 verified, 946
unverified, 221 preview). Drops stale duplicate rows upstream's docs
carried in raw-parity.md and gaps.md.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>