Refresh Smart Previews and cached renders after the CR3 look changes

This commit is contained in:
r3d42-git committed 2026-11-28 08:36:03 +01:00
1 parent b7c38772c1
commit 3295921b86
4 files changed
+22 -5

No files matched your search

+2 -1
View File
@@ -95,7 +95,8 @@ use tone::{HighlightCheck, ToneFit, fit_tone, fit_tone_conditional, highlights};
/// (`camera_vignetting_amount`, ranked within chromaticity classes), not whole: JPEGs that show less of it fitted looks too
/// dark, with skewed colour. The same for a DNG's tone fit; a CR3 proxy gets the gain where its framed pixels come from.
/// 27: geometry-gated external lens and camera framing for JPEG calibration correspondences.
pub const LOOK_VERSION: u32 = 27;
/// 28: resolved lens geometry can align CR3 camera-JPEG colour and tone samples against the existing framing fallback.
pub const LOOK_VERSION: u32 = 28;
#[derive(Clone, Debug)]
pub(crate) struct CameraLook {
+2 -1
View File
@@ -1,13 +1,14 @@
use super::{Arc, DcpProfile, Deserialize, DevelopSettings, MediaKind, Photo, Rgb32f, Rgba8, Serialize, SourceInfo};
/// Bump when the pipeline's output changes, to invalidate cached thumbnails.
/// 89: use accepted lens geometry when fitting a CR3 camera look against the embedded JPEG (#3138).
/// 88: use eligible external lens profiles for camera-preview colour alignment (#2675).
/// 87: a lens database's vignetting correction reaches the look fit only in the share the camera JPEG shows
/// (#3943, which had reserved 83: taken after 86, so a later bump counting up from here can't meet an older cache).
/// 86: pushed shadows keep the camera profile's colour and tone (#2092).
/// 85: raw decoding keeps negative channels (#2278).
/// 84: full-size raw demosaic runs on the white-balanced mosaic with a clip mask (#1328).
pub const RENDER_CACHE_VERSION: u64 = 88;
pub const RENDER_CACHE_VERSION: u64 = 89;
/// 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];
+16 -3
View File
@@ -344,9 +344,9 @@ fn a_proxy_from_the_previous_look_version_is_stale() {
let path = dir.join("p.lcsp");
std::fs::write(&path, &bytes).unwrap();
assert!(!is_stale(&path), "this build's own proxy is up to date");
// Both the pre-Nikon look and the previous integration's look remain readable offline
// and are rebuilt when the original is available. Keep the lens provenance current.
for version in [13, 14] {
// Look 27 already recorded the lens identity, but did not align CR3 fits with lens geometry.
// Like the earlier proxies, it remains readable offline and is rebuilt from the online original.
for version in [13, 14, 27] {
let mut older = head.clone();
older[LOOK_FIELD] = serde_json::json!(version);
let mut old = MAGIC.to_vec();
@@ -463,6 +463,19 @@ fn explicit_lens_identity_is_kept_by_encoder_and_scan_marker() {
std::fs::remove_dir_all(dir).unwrap();
}
#[test]
fn folder_marker_replaces_lens_fingerprints_in_either_direction_and_preserves_newer_provenance() {
let dir = temp("lens-marker-upgrade");
let fit = u64::from(crate::camera_preview::LOOK_VERSION);
let enc = ENCODE_VERSION;
for (look, encoding, old_key, expected_key) in [(fit, enc, 2, 5), (fit, enc, 99, 5), (fit, enc + 1, 99, 99)] {
std::fs::write(dir.join(LOOK_MARKER), format!("{look} {encoding} {old_key} 71")).unwrap();
mark_look_checked_with_lens_key(&dir, 5).unwrap();
assert_eq!(marker(&dir, LOOK_MARKER), [look, encoding, expected_key, 71]);
}
std::fs::remove_dir_all(dir).unwrap();
}
#[test]
fn a_scan_cannot_clear_pending_behind_a_newer_marker_for_another_database() {
let dir = temp("lens-marker-pending");
+2
View File
@@ -289,6 +289,8 @@ is recorded here yet. Whether they should come before the file-local fit for the
A smart preview keeps the result of the fit twice: the colour matrix is baked into its pixels and the tone and chroma curves are stored in its header. When the fit changes, a preview built earlier keeps the old look until it is rebuilt, and the render cache version does not reach it (renders are keyed on the library's files, proxies are files of their own).
Version 27 introduced resolved-profile geometry for non-CR3 files. Version 28 extends it to eligible CR3s for file-local fits, pooled calibration and merge/DNG colour tags. Render cache version 89 invalidates thumbnails fitted with the earlier geometry. Existing Smart Previews keep the lens database identity recorded when their originals were decoded.
The fit therefore has a version, `LOOK_VERSION` in `crates/engine/src/camera_preview.rs`, and every smart preview records the version that wrote it in its header line (`look_version`). **Bump the constant in any change that makes the fit give a different result for the same file**: the matrix, hue/saturation, tone or chroma fit, their gates and fallbacks, or how a camera profile feeds them. Changes that leave the fitted look alone don't need it. A header without the field (everything built before it existed) counts as version 0, and so does a value that is not a non-negative integer; a value from a newer build is left alone.
A proxy older than the constant is brought up to date by the existing Build Smart Previews path (`smart_run`), which also repairs damaged proxies: