MCPcopy Create free account
hub / github.com/FastLED/FastLED / compareBuffers

Function compareBuffers

tests/fl/fx/2d/animartrix_fp.hpp:114–133  ·  view source on GitHub ↗

Compare two LED buffers and return max/avg error.

Source from the content-addressed store, hash-verified

112
113// Compare two LED buffers and return max/avg error.
114CompareResult compareBuffers(fl::span<const CRGB> a, fl::span<const CRGB> b) {
115 CompareResult r = {0, 0.0};
116 int count = static_cast<int>(a.size());
117 int error_pixels = 0;
118 for (int i = 0; i < count; i++) {
119 int re = abs(static_cast<int>(a[i].r) - static_cast<int>(b[i].r));
120 int ge = abs(static_cast<int>(a[i].g) - static_cast<int>(b[i].g));
121 int be = abs(static_cast<int>(a[i].b) - static_cast<int>(b[i].b));
122 int mx = re;
123 if (ge > mx) mx = ge;
124 if (be > mx) mx = be;
125 if (mx > r.max_error) r.max_error = mx;
126 if (mx > 0) {
127 r.avg_error += mx;
128 error_pixels++;
129 }
130 }
131 if (error_pixels > 0) r.avg_error /= error_pixels;
132 return r;
133}
134
135} // namespace
136

Callers 1

animartrix_fp.hppFile · 0.85

Calls 2

absFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected