Skip to content

Raw decoder: dnglab (rawler) as a third per-camera decoder - #1836

Merged
emmertex merged 6 commits into
stagingfrom
claude/project-thread-shahjb
Dec 2, 2026
Merged

emmertex merged 6 commits into
stagingfrom
claude/project-thread-shahjb

Conversation

@emmertex

@emmertex emmertex commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Requested by Andrew · project thread

Problem

The per-camera raw decoder choice offered only the built-in decoder (lcc-raw) and LibRaw. dnglab's decoder library (rawler, pure Rust) is a third mature decoder worth having, for comparing decoders and as a fallback for files the others can't read.

Change

  • New crate crates/dnglab (lcc-dnglab, L0): wraps rawler 0.8 and turns its output into the app's terms. Everything rawler reports is checked as hostile input: sizes, CFA (RGB only; 4-colour sensors are refused), the black grid re-anchored from the data origin to the image area, the clip level, as-shot multipliers, the D65 matrix. Panics are caught. Its default crop is passed on (relative to the image area).
  • lcc_engine::raw_decoder: Decoder::Dnglab (id dnglab, also typed rawler), a dnglab backend slot built in with the engine's new dnglab feature (install_dnglab, dnglab_name, dnglab_built_in), Used::Dnglab, and the backends' names in the cache key. Frame gains an optional crop, used only when lcc-raw's header probe sees another image area.
    • dnglab: rawler first, lcc-raw when it fails or isn't built in.
    • Auto: unchanged for files lcc-raw reads; a file it refuses as unsupported now goes to LibRaw, then dnglab.
  • library.preferences accepts decoder: "dnglab" and reports dnglab (the built-in name, or null).
  • Settings ▸ Import ▸ Raw decoder lists dnglab, greyed out with a note where it isn't built in. New/changed text translated in all 17 fork catalogs.
  • Feature on by default in the desktop app and CLI. Not in the web build (panic = abort, so a decoder panic couldn't be caught) or Android (not built/tested here).

Not in this PR: Android enablement; rawler's own camera colour matrices are used only as a last resort (same rule as LibRaw's); rawler's lens/opcode data is not taken (lcc-raw's header probe supplies it when it agrees on the sensor area).

How it was checked

  • cargo xtask ci --quick --base origin/staging: fmt, brand, docs, notes, i18n, windows, clippy, heif, stamp pass; test step fails only on lcc-catalog tests_v4::an_older_store_that_cant_be_marked_is_refused_untouched, which relies on file permissions and can't pass when the container runs as root (unrelated). cargo xtask layers, assets, parity pass.
  • cargo test -p lcc-engine --features dnglab --lib raw_decoder (14 pass, incl. the real rawler reading the synthetic DNG to the same mosaic as lcc-raw) and cargo test -p lcc-dnglab (hostile bytes, black-grid shift, patterns, levels).
  • Ran the app UI (not done here; Settings change is a combo entry and a hint)

Real files (Andrew's own raws, compared rawler vs lcc-raw mosaic):

File Mosaic vs lcc-raw Notes
Canon 20D CR2 identical rawler's image area is wider, its default crop lands on lcc-raw's exactly
Canon 7D CR2 identical same; rawler's white 15094 vs 16383
Canon R6 CR3 identical final crop identical
Sony A7R III ARW (uncompressed) identical white 15360 vs 16383
Sony A7R III ARW (lossy) mean 0.75 DN 26% of samples identical
Sony RX100 VII ARW mean 0.75 DN 30% identical

Decode times were within 2x of lcc-raw either way (release build).

Merging

  • Overlap: none found.
  • Existing edits and libraries: unchanged unless a camera is set to dnglab. Auto now also tries dnglab for files that previously showed their embedded preview. The render/decode cache key now includes dnglab's name, so cached thumbnails are re-rendered once after updating.
  • Shared numbers taken: none.
  • Where it came from: Sources: rawler 0.8 (https://github.com/dnglab/dnglab), LGPL-2.1, a crates.io dependency used unmodified; NOTICE entry and licence text in crates/dnglab/; docs/license-status.md updated.
  • New dependencies: rawler (LGPL-2.1, in deny.toml's allow-list) and its new transitive crates (libflate, toml 0.8, winnow, adler32, dary_heap, enumn, rle-decode-fast; MIT/Apache/Zlib). No unsafe in our code; no build scripts, network or processes.

Checklist

  • No new panic path in non-test code
  • New text on screen goes through tr() and has its key in every fork catalog
  • Manual updated in the same commit (pages: reference/settings)
  • New code has a caller
  • No assets added

Manual: reference/settings (Raw decoder)


Generated by Claude Code

Adds lcc-dnglab, a small wrapper over dnglab's rawler crate (pure Rust,
LGPL-2.1, crates.io 0.8), and wires it into the per-camera raw decoder
choice beside Auto, lcc-raw and LibRaw. Choosing dnglab reads the mosaic
with rawler and falls back to lcc-raw when it fails; Auto now tries
LibRaw, then dnglab, for files lcc-raw refuses as unsupported. The app
still demosaics and develops the picture itself.

rawler's output is checked as hostile input (sizes, CFA, black grid
re-anchored at the image area, levels, matrix), panics are caught, and
its default crop is used when lcc-raw's header probe sees another image
area. On by default in the desktop app and CLI (`dnglab` feature); not in
the web build (panic = abort there).

Checked on six real raws (20D/7D CR2, R6 CR3, A7R III and RX100 VII ARW):
same mosaic as lcc-raw bit for bit on CR2/CR3 and uncompressed ARW, mean
difference 0.75 DN on lossy-compressed ARW; final crops match.

Sources: rawler 0.8 (https://github.com/dnglab/dnglab), used as a
dependency, unmodified; NOTICE and licence text in crates/dnglab.
Manual: reference/settings (Raw decoder)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011VFDreSrZaZSYHG2uVG77A
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011VFDreSrZaZSYHG2uVG77A
@emmertex emmertex self-assigned this Dec 2, 2026
rawler declares the deprecated SPDX id `LGPL-2.1` (= LGPL-2.1-only, already
allowed); cargo deny matches ids literally. `cargo deny check licenses
sources` was rejected, now ok.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011VFDreSrZaZSYHG2uVG77A
rawler doesn't build for wasm32 (its uuid needs a randomness source), and
the xtask wasm check builds every crate there. rawler is now a
non-wasm32 dependency; on the web decode() says dnglab isn't part of
that version (the web build never enables the feature anyway).
cargo clippy -p lcc-dnglab --target wasm32-unknown-unknown -D warnings: ok.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011VFDreSrZaZSYHG2uVG77A
@emmertex
emmertex enabled auto-merge December 2, 2026 12:02
@emmertex

emmertex commented Dec 2, 2026

Copy link
Copy Markdown
Owner Author

PR steward review at 6447c87: looks good — rawler output is checked as hostile input (sizes, CFA, black grid, levels, matrix) with a catch_unwind guard and hostile-bytes tests; licence/NOTICE/deny/license-status, layers, all fork locales, manual and whats-new/changelog entries are in place; new deps are all crates.io. Required check is green and auto-merge is on, but merge is blocked by the code-owner review rule, which the PR author can't satisfy; left for a maintainer to merge.

@emmertex
emmertex merged commit 1f95f54 into staging Dec 2, 2026
3 checks passed
@emmertex
emmertex deleted the claude/project-thread-shahjb branch December 2, 2026 17:23
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.

3 participants