diff --git a/ROADMAP.md b/ROADMAP.md index f816f7d13..07900bf48 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -175,7 +175,7 @@ CR3 lossless Bayer and version 0x100/0x200 C-RAW sensor decoding is verified pix Decoded (CC0 corpus from raw.pixls.us, `cargo xtask corpus --download`, `crates/raw/tests/corpus.rs`): DNG (uncompressed, LJ92, lossy JPEG / Smart Previews, Deflate, float, linear, DNG 1.7 JPEG XL tiles: lossless ones bit-exact on synthetic files, -lossy ones decode but no real file has verified them), CR2, ARW (uncompressed, ARW2, LJ92; as-shot white balance and black level of pre-2017 bodies from the enciphered +lossy ones unclipped in the declared linear primaries, checked on one real file), CR2, ARW (uncompressed, ARW2, LJ92; as-shot white balance and black level of pre-2017 bodies from the enciphered maker-note `Tag2010` and the encrypted `SR2SubIFD`, both recovered by black-box analysis, `crates/raw/src/vendor/arw.rs`), NEF/NRW uncompressed and Huffman-compressed (lossless, lossy type 1/2, 12/14-bit), RAF uncompressed and lossless/lossy compressed (Bayer and X-Trans, 14/16-bit real-file verification), RW2 / Leica RWL / Panasonic RAW in every raw format (compressed formats 4 and 6, the prefix-coded strips of format 8, packed formats 2, 5 and 7, the 16-bit words of the 2005–2007 bodies; all recovered by black-box analysis of 178 CC0 files from diff --git a/crates/engine/src/media.rs b/crates/engine/src/media.rs index e3ed58155..ca2192035 100644 --- a/crates/engine/src/media.rs +++ b/crates/engine/src/media.rs @@ -62,7 +62,7 @@ impl SettingsHashes { } /// Bump when the pipeline's output changes, to invalidate cached thumbnails. -pub const RENDER_CACHE_VERSION: u64 = 16; +pub const RENDER_CACHE_VERSION: u64 = 17; /// Thumbnails render at one of these long edges (so window/cell size changes reuse the cache). pub const THUMB_SIZES: [usize; 4] = [128, 256, 384, 512]; diff --git a/crates/raw/src/jxl.rs b/crates/raw/src/jxl.rs index 9e5bfc5fe..5bfbb22de 100644 --- a/crates/raw/src/jxl.rs +++ b/crates/raw/src/jxl.rs @@ -9,17 +9,24 @@ //! tiles decode bit-exactly, whatever bit depth the encoder declared relative to the IFD's //! `BitsPerSample`. Float samples are returned as decoded. //! -//! We never request an output colour encoding, so jxl-oxide renders in the codestream's *original* -//! colour encoding: for lossless (non-XYB) data that is the identity, keeping the values in the raw IFD's -//! sample space. Lossy (XYB) tiles are converted from XYB back to that signalled encoding by jxl-oxide; -//! [INFERENCE] DNG writers signal a linear encoding matching the raw data there, so the result is the raw -//! sample space up to the codec's loss — not verified against a real lossy JXL DNG. +//! Lossless (non-XYB) tiles are rendered in the codestream's own colour encoding, which is the identity, +//! keeping the values in the raw IFD's sample space. Lossy (XYB) tiles are decoded by jxl-oxide to linear +//! sRGB primaries; the codestream's declared primaries are then restored with a plain 3×3 matrix. We +//! never let jxl-oxide convert to the declared encoding itself: that step gamut-maps and clips to +//! [0, 1], which destroys raw values above 1.0 (a `WhiteLevel` of 32768 puts them far above) and +//! desaturates. The result is the linear sample space the DNG's `WhiteLevel` refers to, up to the +//! codec's loss, and can exceed 1.0 or dip below 0. +//! +//! Every tile is decoded with wide (32-bit) modular buffers. A lossy tile whose header sets +//! `modular_16bit_buffers` can still carry values that need more than 16 bits; the narrow buffers then +//! fail with `InvalidAnsStream` or `UnexpectedEof`. use crate::tiffraw::ChunkPx; use crate::{RawError, Result}; +use jxl_oxide::color::{ColourEncoding, ColourSpace, Primaries, TransferFunction, WhitePoint}; use jxl_oxide::frame::Encoding; use jxl_oxide::image::BitDepth; -use jxl_oxide::{AllocTracker, JxlImage, JxlThreadPool}; +use jxl_oxide::{AllocTracker, EnumColourEncoding, JxlImage, JxlThreadPool, RenderingIntent}; /// Decoder memory (bytes) allowed per sample of a tile. jxl-oxide 0.12 peaks at about three 32-bit /// buffers per sample: measured ≤ 10.3 bytes for lossless (modular) tiles and ≤ 13.5 bytes per @@ -29,6 +36,99 @@ const BYTES_PER_SAMPLE: usize = 16; /// on a 16 × 16 tile. const MARGIN_BYTES: usize = 64 << 10; +/// Linear sRGB primaries with a D65 white point (the space jxl-oxide decodes XYB to) and the matrix that +/// takes a linear colour in it to the codestream's declared primaries (row-major, D65 white point). +type Matrix = [[f64; 3]; 3]; + +const D65: [f64; 2] = [0.3127, 0.3290]; +const SRGB: [[f64; 2]; 3] = [[0.640, 0.330], [0.300, 0.600], [0.150, 0.060]]; +const BT2100: [[f64; 2]; 3] = [[0.708, 0.292], [0.170, 0.797], [0.131, 0.046]]; +const P3: [[f64; 2]; 3] = [[0.680, 0.320], [0.265, 0.690], [0.150, 0.060]]; + +fn inverse(m: Matrix) -> Matrix { + let c = + |i: usize, j: usize| m[(i + 1) % 3][(j + 1) % 3] * m[(i + 2) % 3][(j + 2) % 3] - m[(i + 1) % 3][(j + 2) % 3] * m[(i + 2) % 3][(j + 1) % 3]; + let det = m[0][0] * c(0, 0) + m[0][1] * c(0, 1) + m[0][2] * c(0, 2); + let mut out = [[0.0; 3]; 3]; + for (i, row) in out.iter_mut().enumerate() { + for (j, v) in row.iter_mut().enumerate() { + *v = c(j, i) / det; + } + } + out +} + +fn mul(a: Matrix, b: Matrix) -> Matrix { + let mut out = [[0.0; 3]; 3]; + for (i, row) in out.iter_mut().enumerate() { + for (j, v) in row.iter_mut().enumerate() { + *v = (0..3).map(|k| a[i][k] * b[k][j]).sum(); + } + } + out +} + +/// Linear RGB → XYZ for primaries `p` (xy) and the D65 white point. +fn rgb_to_xyz(p: [[f64; 2]; 3]) -> Matrix { + let xyz = |[x, y]: [f64; 2]| [x / y, 1.0, (1.0 - x - y) / y]; + let cols = [xyz(p[0]), xyz(p[1]), xyz(p[2])]; + let prim = [[cols[0][0], cols[1][0], cols[2][0]], [1.0, 1.0, 1.0], [cols[0][2], cols[1][2], cols[2][2]]]; + let w = xyz(D65); + let inv = inverse(prim); + let s: [f64; 3] = std::array::from_fn(|i| (0..3).map(|k| inv[i][k] * w[k]).sum()); + std::array::from_fn(|i| std::array::from_fn(|j| prim[i][j] * s[j])) +} + +/// How a chunk is rendered by jxl-oxide. +#[derive(Debug, Clone, Copy, PartialEq)] +enum Output { + /// In the codestream's own colour encoding (non-XYB: the identity). + AsCoded, + /// XYB (lossy) data: linear sRGB primaries from the decoder, then `Some(matrix)` to the declared + /// primaries (`None` when those are sRGB's). + FromXyb(Option<[[f32; 3]; 3]>), +} + +/// Decide how to render a chunk from its header: whether it is XYB-coded, the declared colour +/// encoding and the intensity target. Lossy data is only accepted when the declared encoding is a +/// linear RGB one with a D65 white point (what a raw DNG writer signals) and no HDR tone mapping would +/// apply, otherwise the samples cannot be restored faithfully. +fn output_for(xyb: bool, encoding: &ColourEncoding, intensity_target: f32, planes: usize) -> Result { + if !xyb { + return Ok(Output::AsCoded); + } + let unsupported = |what: &str| RawError::Unsupported(format!("lossy JPEG XL tile with {what}")); + if planes != 3 { + return Err(unsupported("a single colour plane")); + } + let ColourEncoding::Enum(e) = encoding else { + return Err(unsupported("an ICC profile instead of a colour encoding")); + }; + if e.colour_space != ColourSpace::Rgb || e.tf != TransferFunction::Linear { + return Err(unsupported("a declared encoding that is not linear RGB")); + } + if e.white_point != WhitePoint::D65 { + return Err(unsupported("a white point other than D65")); + } + if intensity_target > 255.0 { + return Err(unsupported("an intensity target above 255 nits")); + } + let primaries = match e.primaries { + Primaries::Srgb => return Ok(Output::FromXyb(None)), + Primaries::Bt2100 => BT2100, + Primaries::P3 => P3, + Primaries::Custom { red, green, blue } => [red, green, blue].map(|c| c.as_float().map(f64::from)), + }; + if primaries.iter().any(|p| p[1] <= 0.0) { + return Err(unsupported("invalid primaries")); + } + let m = mul(inverse(rgb_to_xyz(primaries)), rgb_to_xyz(SRGB)); + if m.iter().flatten().any(|v| !v.is_finite()) { + return Err(unsupported("degenerate primaries")); + } + Ok(Output::FromXyb(Some(m.map(|r| r.map(|v| v as f32))))) +} + fn corrupt(e: impl std::fmt::Display) -> RawError { RawError::Corrupt(format!("JPEG XL tile: {e}")) } @@ -37,7 +137,7 @@ fn corrupt(e: impl std::fmt::Display) -> RawError { /// nominal `cw × ch`, or the part of it inside the image `vw × vh` (edge tiles), `cpp` colour planes, /// a sample type matching the IFD. Returns the decoder and the codestream's integer maximum (0 for float). #[allow(clippy::too_many_arguments)] -fn open(src: &[u8], cw: usize, ch: usize, vw: usize, vh: usize, cpp: usize, bits: u32, float: bool) -> Result<(JxlImage, f32)> { +fn open(src: &[u8], cw: usize, ch: usize, vw: usize, vh: usize, cpp: usize, bits: u32, float: bool) -> Result<(JxlImage, f32, Output)> { if !matches!(cpp, 1 | 3) { return Err(RawError::Unsupported(format!("JPEG XL with {cpp} samples per pixel"))); } @@ -49,8 +149,9 @@ fn open(src: &[u8], cw: usize, ch: usize, vw: usize, vh: usize, cpp: usize, bits let pixels = cw.saturating_mul(ch); let budget = |planes: usize| pixels.saturating_mul(planes).saturating_mul(BYTES_PER_SAMPLE); let tracker = AllocTracker::with_limit(budget(cpp).saturating_add(MARGIN_BYTES)); - let img = JxlImage::builder() + let mut img = JxlImage::builder() .pool(JxlThreadPool::none()) // chunks are already decoded in parallel + .force_wide_buffers(true) // see the module documentation .alloc_tracker(tracker.clone()) .read(std::io::Cursor::new(src)) .map_err(corrupt)?; @@ -75,7 +176,11 @@ fn open(src: &[u8], cw: usize, ch: usize, vw: usize, vh: usize, cpp: usize, bits BitDepth::FloatSample { .. } if float => 0.0, d => return Err(RawError::Corrupt(format!("JPEG XL tile sample type {d:?} does not match the IFD"))), }; - Ok((img, max)) + let output = output_for(header.metadata.xyb_encoded, &header.metadata.colour_encoding, header.metadata.tone_mapping.intensity_target, planes)?; + if matches!(output, Output::FromXyb(_)) { + img.request_color_encoding(EnumColourEncoding::srgb_linear(RenderingIntent::Relative)); + } + Ok((img, max, output)) } /// Check the first chunk's headers ([`open`]) without decoding pixels (header-only probing). @@ -88,7 +193,7 @@ pub(crate) fn check(src: &[u8], cw: usize, ch: usize, vw: usize, vh: usize, cpp: /// in-image size `vw × vh` fills the top-left of that, the rest stays 0. #[allow(clippy::too_many_arguments)] pub(crate) fn decode(src: &[u8], cw: usize, ch: usize, vw: usize, vh: usize, cpp: usize, bits: u32, float: bool) -> Result { - let (img, max) = open(src, cw, ch, vw, vh, cpp, bits, float)?; + let (img, max, output) = open(src, cw, ch, vw, vh, cpp, bits, float)?; if img.num_loaded_keyframes() == 0 { return Err(corrupt("no complete frame")); } @@ -100,22 +205,116 @@ pub(crate) fn decode(src: &[u8], cw: usize, ch: usize, vw: usize, vh: usize, cpp } let n = cw.saturating_mul(ch).saturating_mul(cpp); let rows = fb.buf().chunks_exact(jw * fc); + // lossy data: restore the declared primaries (see the module documentation) + let matrix = match output { + Output::FromXyb(m) => m, + Output::AsCoded => None, + }; + let restore = |s: &[f32], d: &mut [f32]| match matrix { + Some(m) => { + for (d, row) in d.iter_mut().zip(&m) { + *d = row[0] * s[0] + row[1] * s[1] + row[2] * s[2]; + } + } + None => d.copy_from_slice(&s[..cpp]), + }; Ok(if float { let mut out = vec![0f32; n]; for (dst, src) in out.chunks_exact_mut(cw * cpp).zip(rows) { for (d, s) in dst.chunks_exact_mut(cpp).zip(src.chunks_exact(fc)) { - d.iter_mut().zip(s).for_each(|(d, s)| *d = *s); + restore(s, d); } } ChunkPx::F32(out) } else { let mut out = vec![0u16; n]; + let mut px = [0f32; 3]; for (dst, src) in out.chunks_exact_mut(cw * cpp).zip(rows) { for (d, s) in dst.chunks_exact_mut(cpp).zip(src.chunks_exact(fc)) { + restore(s, &mut px[..cpp]); // `as` saturates (NaN → 0): lossy overshoot clips to the integer range - d.iter_mut().zip(s).for_each(|(d, s)| *d = (s * max).round() as u16); + d.iter_mut().zip(&px).for_each(|(d, s)| *d = (s * max).round() as u16); } } ChunkPx::U16(out) }) } + +#[cfg(test)] +mod tests { + use super::*; + use jxl_oxide::color::Customxy; + + fn linear(primaries: Primaries) -> ColourEncoding { + ColourEncoding::Enum(EnumColourEncoding { + colour_space: ColourSpace::Rgb, + white_point: WhitePoint::D65, + primaries, + tf: TransferFunction::Linear, + rendering_intent: RenderingIntent::Perceptual, + }) + } + + fn matrix(o: Output) -> [[f32; 3]; 3] { + match o { + Output::FromXyb(Some(m)) => m, + other => panic!("expected a matrix, got {other:?}"), + } + } + + #[test] + fn data_that_is_not_xyb_is_rendered_as_coded() { + // lossless tiles: whatever the header declares, the decoder must not convert anything + for e in + [linear(Primaries::Srgb), linear(Primaries::Bt2100), ColourEncoding::Enum(EnumColourEncoding::srgb_gamma22(RenderingIntent::Relative))] + { + assert_eq!(output_for(false, &e, 255.0, 3).unwrap(), Output::AsCoded); + assert_eq!(output_for(false, &e, 10_000.0, 1).unwrap(), Output::AsCoded); + } + } + + #[test] + fn lossy_data_with_srgb_primaries_needs_no_matrix() { + assert_eq!(output_for(true, &linear(Primaries::Srgb), 255.0, 3).unwrap(), Output::FromXyb(None)); + } + + #[test] + fn lossy_data_is_restored_to_the_declared_primaries() { + // linear sRGB to linear BT.2020/BT.2100 primaries (D65), as published in ITU-R BT.2087 + let expect = [[0.6274, 0.3293, 0.0433], [0.0691, 0.9195, 0.0114], [0.0164, 0.0880, 0.8956]]; + let m = matrix(output_for(true, &linear(Primaries::Bt2100), 255.0, 3).unwrap()); + for (r, e) in m.iter().zip(&expect) { + for (v, e) in r.iter().zip(e) { + assert!((v - e).abs() < 1e-3, "{m:?}"); + } + // the white point maps to itself: rows sum to one + assert!((r.iter().sum::() - 1.0).abs() < 1e-5, "{m:?}"); + } + // custom primaries equal to the named ones give the same matrix + let xy = |[x, y]: [f64; 2]| Customxy { x: (x * 1e6) as i32, y: (y * 1e6) as i32 }; + let custom = Primaries::Custom { red: xy(BT2100[0]), green: xy(BT2100[1]), blue: xy(BT2100[2]) }; + let c = matrix(output_for(true, &linear(custom), 255.0, 3).unwrap()); + assert!(c.iter().flatten().zip(m.iter().flatten()).all(|(a, b)| (a - b).abs() < 1e-5), "{c:?} {m:?}"); + // the sRGB primaries lie inside the wider P3 gamut: the full-saturation sRGB green is a valid P3 colour + let inv = matrix(output_for(true, &linear(Primaries::P3), 255.0, 3).unwrap()); + let srgb_green_in_p3 = [inv[0][1], inv[1][1], inv[2][1]]; + assert!(srgb_green_in_p3.iter().all(|v| (0.0..=1.0).contains(v)), "sRGB green lies inside P3"); + } + + #[test] + fn lossy_data_that_cannot_be_restored_is_unsupported() { + let bad = |xyb_planes: usize, e: ColourEncoding, it: f32| matches!(output_for(true, &e, it, xyb_planes), Err(RawError::Unsupported(_))); + assert!(bad(1, linear(Primaries::Srgb), 255.0), "grey"); + assert!(bad(3, linear(Primaries::Srgb), 10_000.0), "HDR intensity target would tone-map"); + assert!(bad(3, ColourEncoding::Enum(EnumColourEncoding::srgb_gamma22(RenderingIntent::Relative)), 255.0), "non-linear"); + let mut e = EnumColourEncoding::srgb_linear(RenderingIntent::Relative); + e.white_point = WhitePoint::Dci; + assert!(bad(3, ColourEncoding::Enum(e.clone()), 255.0), "white point"); + e.white_point = WhitePoint::D65; + e.primaries = + Primaries::Custom { red: Customxy { x: 0, y: 0 }, green: Customxy { x: 300_000, y: 600_000 }, blue: Customxy { x: 150_000, y: 60_000 } }; + assert!(bad(3, ColourEncoding::Enum(e.clone()), 255.0), "degenerate primaries"); + e.colour_space = ColourSpace::Grey; + assert!(bad(3, ColourEncoding::Enum(e.clone()), 255.0), "grey declared"); + } +} diff --git a/crates/raw/src/tiffraw.rs b/crates/raw/src/tiffraw.rs index c28b8b64f..676bb6197 100644 --- a/crates/raw/src/tiffraw.rs +++ b/crates/raw/src/tiffraw.rs @@ -108,6 +108,10 @@ pub fn read_image(data: &[u8], info: &ImageInfo, order: ByteOrder, packing: Pack let (c, px) = match r { Ok(v) => v, Err(e) => { + // a JPEG XL tile that cannot be decoded is not a partial image: the file stays preview-only + if info.compression == comp::JPEG_XL { + return Err(e); + } first_err.get_or_insert(e); continue; } diff --git a/crates/raw/tests/dng.rs b/crates/raw/tests/dng.rs index bba5ac81f..44527cf9c 100644 --- a/crates/raw/tests/dng.rs +++ b/crates/raw/tests/dng.rs @@ -669,6 +669,26 @@ fn malformed_jpeg_xl_tiles_are_errors() { assert!(matches!(lightcraft_raw::probe_info(&one(good, 3)), Err(RawError::Corrupt(_)))); } +/// One undecodable tile makes the whole image an error: it is never returned with a black tile. +#[test] +fn a_jpeg_xl_tile_that_fails_is_an_error_for_the_image() { + use lightcraft_raw::RawError; + let (w, h) = (32, 16); + let px = pattern(w, h, 1, 12); + let tile = |x0: usize| -> Vec { (0..16).flat_map(|y| px[y * w + x0..y * w + x0 + 16].to_vec()).collect() }; + let two = |second: Vec| { + let mut raw = base_ifd(w, h, 12, 1, true); + raw.set(t::COMPRESSION, Value::Short(vec![compression::JPEG_XL])); + raw.set_image(ImageData::Tiles { tile_width: 16, tile_height: 16, tiles: vec![jxl_encode(&tile(0), 16, 16, 1, false), second] }); + dng(raw, ByteOrder::Little) + }; + assert_eq!(decode(&two(jxl_encode(&tile(16), 16, 16, 1, false))).unwrap().data, RawData::U16(px.clone())); + // the second tile is cut short; the first one alone is not an image + let good = jxl_encode(&tile(16), 16, 16, 1, false); + assert!(matches!(decode(&two(good[..good.len() / 2].to_vec())), Err(RawError::Corrupt(_)))); + assert!(matches!(decode(&two(vec![0xff, 0x0a, 1, 2, 3])), Err(RawError::Corrupt(_)))); +} + /// The decoder's memory is bounded by the tile: a grey tile that also codes an alpha channel needs /// about twice what one plane may use, and is an error rather than an allocation the header asks /// for. The same samples without the alpha channel decode. diff --git a/docs/parity.md b/docs/parity.md index ed95faab9..d3e298f5b 100644 --- a/docs/parity.md +++ b/docs/parity.md @@ -142,7 +142,7 @@ under the UI command that wraps it (a no-op error); the UI command now wins. | LR-IMP-PROFILES | Import profiles & presets | P1 | ✅ | `cmd:file.importPresets`, `cmd:preset.import`, `cmd:profile.import`, `crates/engine/src/preset_import.rs`, `crates/engine/src/preset_luminar.rs` | presets: .lcpreset, XMP, classic .lrtemplate, photos carrying edits ("DNG presets"), Luminar looks (.lmp, .mplumpack collections; sliders with a counterpart), .zip bundles, folders (folder → group), drag & drop; masks carried over; unmapped settings reported (fields that only describe the preset or photo, e.g. `Cluster`, `SortName`, `SupportsAmount2`, the as-shot white, empty Point Color slots, are not); profiles: .cube 3D LUTs; Adobe profile formats deliberately unsupported | | LR-IMP-LOCAL | Work on files in place | P0 | ✅ | `cmd:library.browse`, `cmd:photo.addToLibrary`, `cmd:library.import` (mode add), `cmd:local.addRoot`, `cmd:local.hide`, `cmd:local.restoreHidden`, `crates/engine/src/cmd/browse.rs`, `crates/ui-egui/src/panels/left.rs` (`local_section`), `crates/ui-egui/src/panels/grid.rs` (`folder_header`) | Local: browse Pictures / Desktop / Downloads / Home or any folder without adding it (breadcrumb, Include subfolders, Add N to My Photos); browsed photos stay out of All Photos, albums and counts; folders picked with Browse Folder… (or Keep in Local / Add to Local on a folder row) stay listed across restarts, and browsing a folder inside a listed one highlights it inside that tree (opened down to it, siblings reachable) instead of adding a root; edits go to XMP sidecars; importing promotes them; right-click a top-level location → Remove from Local hides the shortcut only (nothing on disk or in the catalog changes), saved with the UI state, and “Show N hidden locations” (or Browse Folder… on it) brings it back; a folder is one location however its path is spelled (`/` or `\`, trailing separator, `.`/`..`, drive-letter case; `folder_key` in `crates/catalog/src/query.rs`); browsed photos nobody changed are forgotten once their folder has not been browsed for 30 days (Settings → Performance → Local folders, 0 = never; checked when the library opens, or `cmd:library.forgetLocal` with `dryRun`; files and sidecars stay, browsing again brings them back; see `crates/catalog/src/local.rs` for what counts as a change) | | LR-IMP-SIDECAR-SPLIT | Separate XMP sidecar variants | P2 | ⬜ | `cmd:library.xmpPreferences` | sidecar naming option exists (stem/full), no split sidecars | -| LR-IMP-FORMATS | Supported formats | P0 | 🟡 | `crates/codecs/src/lib.rs`, `crates/raw/src/lib.rs`, `crates/raw/src/jxl.rs` | JPEG, PNG, TIFF (1- to 64-bit integer, 16- to 64-bit float, incl. bilevel and CCITT fax), WebP, JXL, PSD, GIF, BMP; DNG (incl. lossy / Smart Preview DNG and DNG 1.7 JPEG XL tiles/strips: lossless ones decode bit-exactly on synthetic CFA and LinearRaw files, lossy ones decode but no real JPEG XL DNG has verified them yet; a single-chunk JPEG XL preview IFD is offered as the embedded preview), CR2 (colour-filter layout from the file's `CR2CFAPattern` tag, issue #85), ARW (pre-2017 bodies: white balance and black level from enciphered maker-note / `SR2SubIFD` data, issue #148; downsized Sony lossless YCbCr 4:2:0 / 4:2:2 tiles decoded to linear RGB, verified on private ILCE-7M4 3:2 & 4:3 examples including 16-bit full-resolution export), NEF (uncompressed, lossless and lossy compressed 12/14-bit, `crates/raw/src/vendor/nefc.rs`), RAF (uncompressed, lossless/lossy compressed Bayer and X-Trans; `crates/raw/src/vendor/rafc.rs`, full sensor verification on 13 bodies, `docs/raf-compression.md`), RW2 / Leica RWL / Panasonic RAW in every raw format (compressed 4 and 6, the prefix-coded strips of format 8 from the GH6 on, packed 2/5/7, the 16-bit words of the 2005–2007 bodies; black levels, in-camera aspect crops and mapped-out defect pixels; 178 CC0 files from 118 bodies checked, `crates/raw/src/vendor/rw2.rs`), PEF, ORF (uncompressed; colour-filter layout from the file's Exif `CFAPattern`). 12-bit NEF black level: maker note `0x003d` is in 14-bit units (D750, D780, D850, D7500, Z 50 checked). Lossy type 2 NEF curves of version `0x44 0x40` (D780, D6, Z 5, Z 6, Z 7, Z 7_2) span a quarter of the sample range, read from the table's own point spacing. CR3 lossless CRX Bayer and version 0x100/0x200 C-RAW decodes to sensor pixels with timed white balance, black/white levels and file crop; full sensor samples match the reference on M50/R100/R8 (`crates/raw/tests/cr3_corpus.rs`, `docs/cr3.md`). Unsupported coding variants retain metadata and use the embedded JPEG when available; HEVC preview decoding remains unsupported. Missing: CR3 unverified CRX variants, compressed ORF, NEFs labelled compressed (34713) but stored uncompressed without a `0x0096` table (Z 6 packed 14-bit, D850 12-bit uncompressed), NEF "lossy after split" (preview only: imported with `preview_only` = the decoder's reason, rendered as a rendered JPEG, flagged by a grid badge and loupe/Edit/Info notices, `previewOnly` in `catalog.query`; Reload clears it once the file decodes), TIFF-based raws whose raw data sits in a private block (Phase One / Leaf IIQ, Canon EOS-1D / 1Ds and Kodak DCS TIFFs: IFD0 is only a reduced RGB image next to a much larger declared picture) are recognised from that structure and import as `preview_only` with the reason, instead of opening as a thumbnail-sized ordinary image (`thumbnail_shell` in `crates/raw/src/lib.rs`), Recognised raws LightCraft cannot decode open as `preview_only` with any usable embedded JPEG, also Canon CRW, Minolta MRW and Sigma X3F (containers recognised by magic, preview found by a structural JPEG scan), Kodak KDC (IFD0 without `ImageWidth`), Leaf MOS and Epson ERF (scan), and any decode failure of a recognised raw, not only an unsupported variant; ones with no JPEG still fail with "without an embedded preview", AVIF decode (HEIC decodes only behind the non-default `heif` feature: `crates/heif`, heic-rs, same policy as PhotoCraft; 8/10-bit, alpha, irot/imir/clap, ICC/EXIF/XMP), palette (indexed-colour) TIFF (refused by the `tiff` crate) | +| LR-IMP-FORMATS | Supported formats | P0 | 🟡 | `crates/codecs/src/lib.rs`, `crates/raw/src/lib.rs`, `crates/raw/src/jxl.rs` | JPEG, PNG, TIFF (1- to 64-bit integer, 16- to 64-bit float, incl. bilevel and CCITT fax), WebP, JXL, PSD, GIF, BMP; DNG (incl. lossy / Smart Preview DNG and DNG 1.7 JPEG XL tiles/strips: lossless ones decode bit-exactly on synthetic CFA and LinearRaw files, lossy ones are restored to the declared linear primaries without clipping or gamut mapping, checked on one real file with 108 lossy tiles, and any tile that fails to decode makes the file preview-only; a single-chunk JPEG XL preview IFD is offered as the embedded preview), CR2 (colour-filter layout from the file's `CR2CFAPattern` tag, issue #85), ARW (pre-2017 bodies: white balance and black level from enciphered maker-note / `SR2SubIFD` data, issue #148; downsized Sony lossless YCbCr 4:2:0 / 4:2:2 tiles decoded to linear RGB, verified on private ILCE-7M4 3:2 & 4:3 examples including 16-bit full-resolution export), NEF (uncompressed, lossless and lossy compressed 12/14-bit, `crates/raw/src/vendor/nefc.rs`), RAF (uncompressed, lossless/lossy compressed Bayer and X-Trans; `crates/raw/src/vendor/rafc.rs`, full sensor verification on 13 bodies, `docs/raf-compression.md`), RW2 / Leica RWL / Panasonic RAW in every raw format (compressed 4 and 6, the prefix-coded strips of format 8 from the GH6 on, packed 2/5/7, the 16-bit words of the 2005–2007 bodies; black levels, in-camera aspect crops and mapped-out defect pixels; 178 CC0 files from 118 bodies checked, `crates/raw/src/vendor/rw2.rs`), PEF, ORF (uncompressed; colour-filter layout from the file's Exif `CFAPattern`). 12-bit NEF black level: maker note `0x003d` is in 14-bit units (D750, D780, D850, D7500, Z 50 checked). Lossy type 2 NEF curves of version `0x44 0x40` (D780, D6, Z 5, Z 6, Z 7, Z 7_2) span a quarter of the sample range, read from the table's own point spacing. CR3 lossless CRX Bayer and version 0x100/0x200 C-RAW decodes to sensor pixels with timed white balance, black/white levels and file crop; full sensor samples match the reference on M50/R100/R8 (`crates/raw/tests/cr3_corpus.rs`, `docs/cr3.md`). Unsupported coding variants retain metadata and use the embedded JPEG when available; HEVC preview decoding remains unsupported. Missing: CR3 unverified CRX variants, compressed ORF, NEFs labelled compressed (34713) but stored uncompressed without a `0x0096` table (Z 6 packed 14-bit, D850 12-bit uncompressed), NEF "lossy after split" (preview only: imported with `preview_only` = the decoder's reason, rendered as a rendered JPEG, flagged by a grid badge and loupe/Edit/Info notices, `previewOnly` in `catalog.query`; Reload clears it once the file decodes), TIFF-based raws whose raw data sits in a private block (Phase One / Leaf IIQ, Canon EOS-1D / 1Ds and Kodak DCS TIFFs: IFD0 is only a reduced RGB image next to a much larger declared picture) are recognised from that structure and import as `preview_only` with the reason, instead of opening as a thumbnail-sized ordinary image (`thumbnail_shell` in `crates/raw/src/lib.rs`), Recognised raws LightCraft cannot decode open as `preview_only` with any usable embedded JPEG, also Canon CRW, Minolta MRW and Sigma X3F (containers recognised by magic, preview found by a structural JPEG scan), Kodak KDC (IFD0 without `ImageWidth`), Leaf MOS and Epson ERF (scan), and any decode failure of a recognised raw, not only an unsupported variant; ones with no JPEG still fail with "without an embedded preview", AVIF decode (HEIC decodes only behind the non-default `heif` feature: `crates/heif`, heic-rs, same policy as PhotoCraft; 8/10-bit, alpha, irot/imir/clap, ICC/EXIF/XMP), palette (indexed-colour) TIFF (refused by the `tiff` crate) | | LR-IMP-CAMERA-COVERAGE | Camera coverage, verified per model | P0 | 🟡 | `crates/raw/tests/corpus.rs`, `xtask/src/main.rs` | a supported container is not the same as every camera that writes it decoding correctly: ~55 CC0 corpus files plus 6 exact-sensor CR3 cases (plus ~60 NEFs checked by hand and 178 Panasonic / Leica RW2, RWL and RAW files from 118 bodies, checked against each file's own JPEG) against the >1,000 models Lightroom lists; per-model differences still surface (e.g. the CR2 colour-filter layout differed by model until it was read from the file's own tag, issue #85, checked on 35 CR2 bodies; pre-2017 Sony ARWs opened green until their scrambled white balance / black level were read, issue #148, checked on 16 ARWs from 15 Sony bodies; Canon PowerShot and EOS M CR2s whose `ColorData` is stored as bytes opened green until the bytes were read as 16-bit words, 25 files from 25 bodies checked). Compressed RAF sensor arrays verified on 13 Fujifilm bodies (`docs/raf-compression.md`). Grow the CC0 corpus per model and test each sample decodes with plausible colour. Nikon CropArea and untagged-preview colour-space regression tests; private Z 8 crop verified. | | LR-IMP-CULL-AT-IMPORT | Culling analysis at import | P2 | 🟡 | `cmd:photo.analyze` | run Assisted Culling on the imported photos (they're selected after an import); not automatic | | LR-IMP-MOVE | Move on import [Classic] | P1 | ✅ | `cmd:library.import` (`mode` move), `crates/engine/src/import_move.rs`, `crates/engine/src/tests_import_move.rs`, `crates/ui-egui/src/import.rs` | Transfer ▸ Move with Copy's destination, folders (day / month / one folder / custom template), rename template and example destination; XMP sidecars (both namings) move along; each source is removed only after its destination is written (hard link on the same volume, else copied, synced and compared byte for byte) and its catalog record is saved; failed, duplicate, unchecked files keep their sources, taken names get -1, -2…, never overwritten; files already in the destination/library are added in place; sources that can't be removed (read-only card) are kept and reported (`kept`). Undo removes the photos from the library but leaves the moved files at the destination. No Copy as DNG while moving | diff --git a/docs/whats-new.md b/docs/whats-new.md index a22297501..138b2b799 100644 --- a/docs/whats-new.md +++ b/docs/whats-new.md @@ -18,7 +18,8 @@ - Canon CR2 and Pentax PEF raws get the same starting look fitted to the camera's own JPEG as ARW, NEF, RW2, RAF and CR3, instead of opening flat and desaturated (issue #310). Photos already imported pick it up when re-rendered. - JPEG XL compressed DNGs (DNG 1.7) now open: lossless tiles decode sample for sample (checked on synthetic files); - lossy tiles decode too, but no real file has checked them yet. A JPEG XL preview stored in the DNG is used like an + lossy tiles decode too, keeping the raw values above 1.0 instead of clipping them (checked on one real file). A tile that cannot be decoded makes the file open from its embedded + preview, with the reason, instead of showing a black tile. A JPEG XL preview stored in the DNG is used like an embedded JPEG. - Apple ProRAW's gain table map (its local tone mapping, `ProfileGainTableMap`) is now read and kept when a photo is exported or converted to DNG. It is not applied to the render: Lightroom Classic renders ProRAW without it.