One pixel: XYZ in s16.16 to in-gamut emitter drives in s16.16.
Drives always come back inside [0, 1]. A target already inside the hull is returned untouched, so an in-gamut image pays only the solve and the bounds check.
356 {
358 if (gamutDrivesAreInRange(drives, kGamutFeasibilitySlack)) {
359
360
361 clampGamutDrives(drives);
362 return;
363 }
364
365 i32 lab[3];
367
368 i32 lightness = lab[0];
369 if (lightness < 0) {
370 lightness = 0;
371 }
372
373
374
375
376
377
378 if (lightness >
map.max_neutral_lightness) {
379 i32 low_edge = 0;
380 i32 high_edge = 0;
382 &low_edge, &high_edge)) {
383 i32 candidate_xyz[3];
385 candidate_xyz);
386 i32 candidate[3];
389 for (int i = 0; i < 3; ++i) {
390 drives[i] = candidate[i];
391 }
393 return;
394 }
395 }
396
397
398
399
401 lab,
map.max_neutral_lightness, lightness, RgbFeasible{map.solve});
402 i32 edge_low = 0;
403 i32 edge_high = 0;
404 if (reachable >
map.max_neutral_lightness &&
406 &edge_low, &edge_high)) {
407 i32 candidate_xyz[3];
410 candidate_xyz);
411 i32 candidate[3];
414 for (int i = 0; i < 3; ++i) {
415 drives[i] = candidate[i];
416 }
418 return;
419 }
420 }
421
422
423 lightness =
map.max_neutral_lightness;
424 }
425
426
428 i32 mapped_xyz[3];
432}
bool gamutDrivesAreInRange(const i32(&drives)[3], i32 slack) FL_NO_EXCEPT
True when every drive is inside [0, 1], allowing slack ULP either side.
void clampGamutDrives(i32(&drives)[3]) FL_NO_EXCEPT
Clamp drives into [0, 1].
i32 clampChromaFactor(i32 low, i32 high) FL_NO_EXCEPT
The target's chroma clamped into [low, high], in factor space.
void chromaCandidateXyz(const i32(&lab)[3], i32 lightness, i32 factor, i32(&out_xyz)[3]) FL_NO_EXCEPT
XYZ of the candidate at factor of the target's chroma.
i32 largestFeasibleChroma(const i32(&lab)[3], i32 lightness, Feasible feasible) FL_NO_EXCEPT
Largest chroma factor the hull accepts, by a fixed count of halvings.
i32 highestReachableLightness(const i32(&lab)[3], i32 cap, i32 requested, Feasible feasible) FL_NO_EXCEPT
The highest lightness at or below requested whose feasible chroma interval the probe scan can still f...
bool feasibleChromaInterval(const i32(&lab)[3], i32 lightness, Feasible feasible, i32 *out_low, i32 *out_high) FL_NO_EXCEPT
The feasible chroma interval at the target's own lightness, as factors of the target's chroma.
MapRedBlackTree< Key, T, Compare, fl::allocator_slab< char > > map
void xyzToOklabQ16(const i32(&xyz)[3], i32(&out_lab)[3]) FL_NO_EXCEPT
XYZ (s16.16, D65-relative) -> OKLab (s16.16), L then a then b.
void solveRgbDrivesQ16(const EmitterSolveMatrixQ16 &matrix, const i32(&xyz)[3], i32(&drives)[3]) FL_NO_EXCEPT
One pixel: XYZ in s16.16 to three emitter drives in s16.16.