FastLED 3.10.6
Loading...
Searching...
No Matches

◆ buildRgbSolveMatrixFromQ16()

bool fl::buildRgbSolveMatrixFromQ16 ( const EmitterChromaticitiesQ16 & profile,
EmitterSolveMatrixQ16 * out )

Build the inverse emitter matrix from a Q16 profile, without floats.

The float-free counterpart of buildRgbSolveMatrixQ16, and the second half of P9 item 2: that one converts float chromaticities through xyY_to_XYZ and invert3x3 before quantising, so a target that never wants a float symbol cannot use it.

ci/color_fixed_profile_study.py prices what this costs against the float derivation: worst 0.1085 dE2000 on BT.2020, against A1's 0.5 and the ~0.35 the derivation has once the gamut mapper's 0.15 is counted.

False on the same profiles buildRgbSolveMatrixQ16 refuses – a non-positive or degenerate chromaticity, a non-positive luminance, or a matrix the inverse cannot represent – with one addition the float path has no equivalent of: a y small enough to quantise to zero, which would otherwise be divided by.

Definition at line 265 of file device_solve.cpp.hpp.

266 {
267 if (out == nullptr) {
268 return false;
269 }
270 i64 red[3];
271 i64 green[3];
272 i64 blue[3];
273 if (!emitterColumnQ16(profile.xy_r, profile.lum_r, red) ||
274 !emitterColumnQ16(profile.xy_g, profile.lum_g, green) ||
275 !emitterColumnQ16(profile.xy_b, profile.lum_b, blue)) {
276 return false;
277 }
278
279 // Columns are the emitters' XYZ contributions at full drive, the same
280 // arrangement `buildRgbSolveMatrixQ16` builds in float.
281 const i32 emitter[3][3] = {
282 {static_cast<i32>(red[0]), static_cast<i32>(green[0]),
283 static_cast<i32>(blue[0])},
284 {static_cast<i32>(red[1]), static_cast<i32>(green[1]),
285 static_cast<i32>(blue[1])},
286 {static_cast<i32>(red[2]), static_cast<i32>(green[2]),
287 static_cast<i32>(blue[2])},
288 };
289 return invert3x3Q16(emitter, out->m);
290}
bool invert3x3Q16(const i32(&in)[3][3], i32(&out)[3][3]) FL_NO_EXCEPT
Inverse of an s16.16 3x3 matrix, in s16.16, computed without floats.
i32 lum_r
Peak luminance per emitter relative to source white, s16.16.
i32 xy_r[2]
CIE 1931 xy per emitter, s16.16, so 0.64 is 41943.
fl::i64 i64
Definition stdint.h:221

References FL_NO_EXCEPT, and invert3x3Q16().

Referenced by buildRgbSolveMatrixQ16().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: