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

◆ foldAdaptationIntoSourceMatrix()

void fl::foldAdaptationIntoSourceMatrix ( const AdaptationMatrixQ16 & adaptation,
SourceMatrixQ16 * source )

Pre-multiply the adaptation into a source matrix, in place.

This is how the streaming path should use it: primaries and adaptation become one matrix at bind time, so the per-pixel cost of adaptation is zero rather than a second matrix multiply per channel.

Definition at line 151 of file chromatic_adaptation.cpp.hpp.

152 {
153 if (source == nullptr) {
154 return;
155 }
156 SourceMatrixQ16 result;
157 for (int row = 0; row < 3; ++row) {
158 for (int col = 0; col < 3; ++col) {
159 const i64 acc =
160 static_cast<i64>(adaptation.m[row][0]) * source->m[0][col]
161 + static_cast<i64>(adaptation.m[row][1]) * source->m[1][col]
162 + static_cast<i64>(adaptation.m[row][2]) * source->m[2][col];
163 result.m[row][col] = static_cast<i32>(
164 acc >= 0 ? (acc + 32768) >> 16 : -((-acc + 32768) >> 16));
165 }
166 }
167 *source = result;
168}
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31
fl::i64 i64
Definition stdint.h:221

References FL_NO_EXCEPT.

Referenced by buildStreamingPipelineQ16().

+ Here is the caller graph for this function: