LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
Clamp negative signals to zero in hlg_decode
NetterSilver89e08db8b84a
diff --git a/crates/color/src/transfer.rs b/crates/color/src/transfer.rsindex 8a7e4fdbf..72ff76fc7 100644--- a/crates/color/src/transfer.rs+++ b/crates/color/src/transfer.rs@@ -49,6 +49,7 @@ pub fn hlg_encode(e: f64) -> f64 {}pub fn hlg_decode(s: f64) -> f64 {+ let s = s.max(0.0);if s <= 0.5 { s * s / 3.0 } else { (((s - HLG_C) / HLG_A).exp() + HLG_B) / 12.0 }}@@ -112,6 +113,11 @@ mod tests {}}+ #[test]+ fn hlg_decode_clamps_negative() {+ assert_eq!(hlg_decode(-0.5), 0.0);+ }+#[test]fn pq_hlg_roundtrip() {for i in 0..=50 {