From 6e3d68d3af68296a9ded7d2ea9a21c663a1d2b02 Mon Sep 17 00:00:00 2001 From: Thomas Churchman Date: Thu, 24 Apr 2025 16:47:07 +0200 Subject: [PATCH] Add absolute conversion matrices for ACES2065-1 Continuing the addition of absolute color conversion matrices. See also https://github.com/linebender/color/pull/156. --- color/src/colorspace.rs | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/color/src/colorspace.rs b/color/src/colorspace.rs index d2dd249..916c1bd 100644 --- a/color/src/colorspace.rs +++ b/color/src/colorspace.rs @@ -848,6 +848,50 @@ impl ColorSpace for Aces2065_1 { matvecmul(&LINEAR_SRGB_TO_ACES2065_1, src) } + fn to_linear_srgb_absolute(src: [f32; 3]) -> [f32; 3] { + // XYZ_to_lin_sRGB * ACES2065_1_to_XYZ + const ACES2065_1_TO_LINEAR_SRGB: [[f32; 3]; 3] = [ + [ + 54_120_196_967_290_615. / 21_154_043_450_084_358., + -320_017_885_460_000. / 285_865_452_028_167., + -564_067_687_050. / 1_439_638_182_257., + ], + [ + -65_267_199_138_999_760. / 234_786_371_866_236_861., + 320_721_924_808_012_000. / 234_786_371_866_236_861., + -2_987_552_619_450. / 31_956_767_642_063., + ], + [ + -581_359_048_862_990. / 33_857_690_407_037_013., + -457_168_407_800_000. / 3_077_971_855_185_183., + 4_981_730_664_150. / 4_608_369_457_879., + ], + ]; + matvecmul(&ACES2065_1_TO_LINEAR_SRGB, src) + } + + fn from_linear_srgb_absolute(src: [f32; 3]) -> [f32; 3] { + // XYZ_to_ACES2065_1 * lin_sRGB_to_XYZ + const LINEAR_SRGB_TO_ACES2065_1: [[f32; 3]; 3] = [ + [ + 26_324_697_889_654. / 60_805_826_029_215., + 95_867_335_448_462. / 255_384_469_322_703., + 34_545_867_731_048. / 182_417_478_087_645., + ], + [ + 1_068_725_544_495_979. / 11_952_668_021_931_000., + 9_008_998_273_654_297. / 11_033_232_020_244_000., + 2_110_950_307_239_113. / 20_490_288_037_596_000., + ], + [ + 267_367_106. / 13_953_194_325., + 2_967_477_727. / 25_115_749_785., + 33_806_406_089. / 35_879_642_550., + ], + ]; + matvecmul(&LINEAR_SRGB_TO_ACES2065_1, src) + } + fn clip([r, g, b]: [f32; 3]) -> [f32; 3] { [ r.clamp(-65504., 65504.),