diff --git a/crates/raw/src/develop.rs b/crates/raw/src/develop.rs index a51287ee38..580460c764 100644 --- a/crates/raw/src/develop.rs +++ b/crates/raw/src/develop.rs @@ -316,7 +316,10 @@ fn develop(s: &Sensor, opts: &DevelopOptions, allow_fused: bool) -> Result Result craft_develop::sensor::Method::Bilinear, Demosaic::Ahd | Demosaic::Mhc => craft_develop::sensor::Method::Ahd, }; - let shared = matches!(opts.demosaic, Demosaic::Bilinear | Demosaic::Ahd); // Whether the sensor clipped is told from the measured sample, before lens shading lifts or lowers it. let clipped = shared && sensor_clipped(w, h, band, &|iy, row| fill_raw(iy, row, [1.0; 3], f32::INFINITY)); let rebuild = if clipped { @@ -576,7 +578,8 @@ fn develop(s: &Sensor, opts: &DevelopOptions, allow_fused: bool) -> Result 0, + b'G' => 1, + _ => 2, + }) + }) + .collect(); + let mut s = test_sensor(600, 350, Some(crate::Cfa { width: 6, height: 6, colors, origin_x: 0, origin_y: 0 }), 1); + s.crop = crate::Rect::new(3, 5, 592, 339); + s.orientation = 6; + for v in &mut s.data { + *v = 64 + (*v - 64) * 3 / 4; + } + for method in [Demosaic::Bilinear, Demosaic::Ahd] { + let mut opts = DevelopOptions { demosaic: method, ..Default::default() }; + let reference = develop_sensor(&s, &opts).unwrap(); + opts.limits.max_alloc = 8 * 1024 * 1024; + let bounded = with_threads(3, || develop_sensor(&s, &opts).unwrap()); + assert_eq!((bounded.width, bounded.height), (reference.width, reference.height)); + assert_eq!(bounded.rgb, reference.rgb, "{method:?}: budget must not change pixels"); + // Both settings dispatch the same whole-frame shared method, so their + // admission decisions must agree under an ordinary limited workspace. + opts.limits.max_alloc = 3_900_000; + let automatic = with_threads(1, || develop(&s, &opts, true)); + let full = with_threads(1, || develop(&s, &opts, false)); + assert!(matches!(full, Err(RawError::LimitExceeded(_)))); + assert!(matches!(automatic, Err(RawError::LimitExceeded(_))), "{method:?}: equivalent route must use the same budget"); + } + } + #[test] fn fused_only_where_no_whole_frame_statistic_is_needed() { use crate::Cfa;