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

◆ highestReachableLightness()

template<typename Feasible>
i32 fl::anonymous_namespace{gamut_map.cpp.hpp}::highestReachableLightness ( const i32(&) lab[3],
i32 cap,
i32 requested,
Feasible feasible )

The highest lightness at or below requested whose feasible chroma interval the probe scan can still find.

Without this the mapper is discontinuous at the top of the reachable region, and badly: holding the requested lightness works until the probes stop landing inside the interval, and the fallback then drops all the way to the neutral cap. Swept along a fixed hue at chroma 0.10 that step measured 0.91 in summed drive – 234 eight-bit codes, against the ~1 code the rest of the mapper's paths stay inside.

Bisecting instead lands on the edge of the region rather than jumping past it, so the answer walks down continuously as the target rises. The neutral cap is the low end of the bracket because chroma zero is feasible there by construction, which is the invariant the search needs.

Costs kGamutMapHalvings * kGamutMapProbes feasibility tests, and only on an above-cap target whose interval was not found at its own lightness.

Definition at line 258 of file gamut_map.cpp.hpp.

259 {
260 i32 low = cap; // feasible: chroma zero is reachable at the cap
261 i32 high = requested; // not feasible, or the caller would not be here
262 for (int step = 0; step < kGamutMapHalvings; ++step) {
263 const i32 middle = low + ((high - low) >> 1);
264 i32 unused_low = 0;
265 i32 unused_high = 0;
266 if (feasibleChromaInterval(lab, middle, feasible, &unused_low,
267 &unused_high)) {
268 low = middle;
269 } else {
270 high = middle;
271 }
272 }
273 return low;
274}
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.
constexpr int kGamutMapHalvings
Number of chroma halvings the mapper runs, fixed at compile time.
Definition gamut_map.h:40
constexpr enable_if< is_fixed_point< T >::value, T >::type step(T edge, T x) FL_NO_EXCEPT

References feasibleChromaInterval(), fl::FL_NO_EXCEPT, highestReachableLightness(), fl::kGamutMapHalvings, and fl::step().

Referenced by highestReachableLightness().

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