Skip to content

Fix rawspeed-cli ARW/CR2/PEF decoding (missing metadata pass) - #3

Merged
Abas-Tim merged 3 commits into
developfrom
fix/v1.0.1-metadata-regression
Sep 6, 2026
Merged

Abas-Tim merged 3 commits into
developfrom
fix/v1.0.1-metadata-regression

Conversation

@Abas-Tim

@Abas-Tim Abas-Tim commented Sep 6, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes the v1.0.1 regression: ARW/CR2/PEF decoding failed with
rawspeed: unsupported CFA pattern (exit 1).

Root cause: main.cpp never called decoder->decodeMetaData();
those decoders set the CFA in their metadata pass
(ArwDecoder.cpp:501, same for Cr2/Pef), so render() saw a 0x0 CFA
and failed. The v1.0.0 CLI only worked because it unconditionally
forced an RGGB CFA in render() — a load-bearing call that the
clang-tidy cleanup removed as apparent dead code. Full details in
docs/rawspeed-cli-v1.0.1-regression-report.md.

Changes:

  • call decoder->decodeMetaData(&meta) after decodeRaw();
    cameras.xml is resolved like rawspeed-identify does
    (RS_CAMERAS_XML_PATH → <bindir>/../share/darktable/rawspeed/cameras.xml
    → RAWSPEED_SOURCE_DIR/data/cameras.xml), falling back to an empty
    CameraMetaData{} (the decoders set RGGB before consulting the DB,
    and unknown cameras only warn with failOnUnknown = false)
  • a failing metadata pass is logged and skipped instead of aborting
    the decode
  • render() hardening: CFA smaller than 2x2 now defaults to RGGB
    instead of failing; larger patterns (e.g. X-Trans) still fail as
    unsupported; the 4-Bayer pattern mapping is unchanged
  • publish smoke test now decodes a real image: a synthetic 8x8
    uncompressed RGGB CFA DNG generated in the runner, verifying the
    PPM header and size (the usage-only check cannot catch this class
    of regression)
  • regression report added under docs/

Verification

  • synthetic 8x8 CFA DNG: exit 0, P6 8 8 65535, 397 bytes (8-bit: 203)
  • usage path: exit 2 with usage text (unchanged)
  • clang-format 18.1.8 idempotent; clang -Weverything -Werror clean;
    clang-tidy (CI check set) clean; MSVC Release build green; exact CI
    smoke-test script executed locally against the fresh build

Notes

  • Prepared with AI assistance (opencode), per AGENTS.md disclosure rules
  • Fixes the release tracked in rawspeed-cli-v1.0.1; v1.0.2 will be
    tagged after merge

ARW/CR2/PEF decoders set the CFA pattern in their metadata pass
(ArwDecoder.cpp:501 and the Cr2/Pef equivalents), not in decodeRaw.
Without calling decoder->decodeMetaData() the CFA stays at its
default 0x0 size and render() fails with 'unsupported CFA pattern'.

- resolve cameras.xml like rawspeed-identify does (RS_CAMERAS_XML_PATH,
  <bindir>/../share/darktable/rawspeed/cameras.xml, then
  RAWSPEED_SOURCE_DIR/data/cameras.xml) and fall back to an empty
  CameraMetaData{}: the decoders set RGGB before consulting the
  database and unknown cameras only warn with failOnUnknown=false
- skip a failing metadata pass with a warning instead of aborting
- harden render(): default to RGGB when the reported CFA is smaller
  than 2x2; larger patterns still fail as unsupported

Found via real-world ARW/CR2/PEF failures of the v1.0.1 release;
the v1.0.0 CLI only worked because it unconditionally forced an RGGB
CFA in render(), a load-bearing call that was removed as apparent
dead code.

AI assistance disclosure: prepared with AI assistance (opencode), per
AGENTS.md disclosure rules.
The usage-only smoke test cannot catch decode-path regressions such
as the v1.0.1 metadata regression (every decode failed while the
usage check passed). Generate a synthetic 8x8 uncompressed RGGB CFA
DNG in the runner, decode it with the freshly built rawspeed-cli and
verify the PPM header and size. The usage check is kept as well.

AI assistance disclosure: prepared with AI assistance (opencode), per
AGENTS.md disclosure rules.
Documents the missing decodeMetaData() call that broke ARW/CR2/PEF
decoding in v1.0.1, why the v1.0.0 forced-CFA call was load-bearing,
and the fix shipped in v1.0.2.

AI assistance disclosure: prepared with AI assistance (opencode), per
AGENTS.md disclosure rules.
@Abas-Tim
Abas-Tim merged commit bf64aeb into develop Sep 6, 2026
53 checks passed
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