pipeline: share HDR preview histogram binning (#4644)

This commit is contained in:
Terra854 authored and GitHub committed 2026-11-23 04:29:25 +07:00
1 parent 71425df614
commit e92f4e52de
2 files changed
+13 -1

No files matched your search

+9 -1
View File
@@ -692,7 +692,15 @@ pub fn hdr_histogram(src: &Rgb32f, info: &SourceInfo, s: &DevelopSettings, req:
};
let deep = render(src, info, s, &hreq).deep?;
let DeepSamples::F32(v) = &deep.samples else { return None };
Some(Histogram::of_hdr(v.as_chunks::<3>().0, lightcraft_develop::Hdr::MAX_EV_LIMIT as f32))
let shared = craft_develop::raster::Histogram::of_hdr(v.as_chunks::<3>().0, lightcraft_develop::Hdr::MAX_EV_LIMIT as f32);
Some(Histogram {
r: shared.r,
g: shared.g,
b: shared.b,
luma: shared.luma,
total: shared.total,
hdr: shared.hdr.map(|bins| lightcraft_raster::HdrBins { from: bins.from, stops: bins.stops }),
})
}
/// Render `src` with settings `s`.
+4
View File
@@ -150,10 +150,14 @@ fn hdr_histogram_shows_the_range_above_sdr_white_on_a_fixed_scale() {
RenderRequest { depth: OutputDepth::U16, ..req },
RenderRequest { window: Some(crate::PixelWindow { x: 0, y: 0, w: 8, h: 8 }), ..req },
RenderRequest { proof: Some(crate::Proof::default()), ..req },
RenderRequest { quality: crate::Quality::Draft, ..req },
] {
assert!(crate::hdr_histogram(&src, &raw(), &s, &other).is_none());
}
let h = crate::hdr_histogram(&src, &raw(), &s, &req).expect("an HDR edit's histogram");
let samples = deep(&src, &s, OutputDepth::F32Hdr);
let legacy = lightcraft_raster::Histogram::of_hdr(samples.as_chunks::<3>().0, lightcraft_develop::Hdr::MAX_EV_LIMIT as f32);
assert_eq!(h, legacy);
let bins = h.hdr.expect("HDR bins");
assert_eq!(bins.stops, lightcraft_develop::Hdr::MAX_EV_LIMIT as f32, "the whole HDR range");
assert!(h.above_sdr() > 0.0, "highlights above SDR white: {}", h.above_sdr());