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

◆ applyFluxScalar()

void fl::applyFluxScalar ( FluxScalar scalar,
span< i32 > drives )

Scale every drive by one scalar, in place.

Definition at line 40 of file flux_scalar.cpp.hpp.

40 {
41 const i64 raw = static_cast<i64>(scalar.rawQ16());
42 if (raw == kUnityQ16) {
43 // Pure short-circuit: the general path below is already bit-exact at
44 // unity, since drive * 65536 + 32768 >> 16 == drive. This only avoids
45 // walking the buffer on the default full-brightness path. Exactness is
46 // pinned by a test, not by this branch -- verified by removing it.
47 return;
48 }
49 for (size i = 0; i < drives.size(); ++i) {
50 const i64 scaled = static_cast<i64>(drives[i]) * raw;
51 // Round half away from zero so negative signed-wide intermediates
52 // are treated symmetrically.
53 drives[i] = static_cast<i32>(scaled >= 0 ? (scaled + 32768) >> 16
54 : -((-scaled + 32768) >> 16));
55 }
56}
i32 rawQ16() const FL_NO_EXCEPT
constexpr fl::size size() const FL_NO_EXCEPT
Definition span.h:483
fl::i64 i64
Definition stdint.h:221

References FL_NO_EXCEPT.

Referenced by encodeLinearEmitterQ16(), processPixelQ16(), and processPixelWideQ16().

+ Here is the caller graph for this function: