Repository navigation
feat(color): let HD108 consume the device drive too (P8, #4042/#4326) - #4387
Merged
Merged
Conversation
The other native 16-bit chipset, and #4326 called it "the same shape and worse". `hd108GammaCorrect` is a hardcoded 2.8 inside the encoder, so unlike UCS7604's `mGamma.value_or(2.8f)` no caller could ever have chosen otherwise, and `writeHD108` took no settings at all -- the information needed to suppress it was not in scope. Measured on a managed channel it put 849 on the wire where the device solve asked for 13933, the identical number the UCS7604 path produced before #4368. It now puts 13935. Confirmed causally: disabling the wide branch returns the case to 849. `writeHD108` takes the iterator's own `isManaged()` -- not `settings.hasColorProfile()`, for the reason established in #4368: a rejected binding leaves the legacy controller in place while the options still report a profile, and taking the no-gamma path over 8-bit pixels would drop a stage that path still needs. The wide loop is inline in `writeHD108` rather than an `encodeHD108_wide` in hd108.h. That header is included *by* pixel_iterator.h, before the class exists, and a concrete `PixelIterator&` parameter is not a dependent type, so the body would be checked there and fail -- the same property that made the UCS7604 wide encoder a hard error on TINY until it was guarded. +240 B on an ESP32-S3 Blink build, baseline moved with the symbol diff recorded: +255 B for the inlined loop, +72 B for `loadAndScaleRGB16` which now has two callers and is emitted once rather than inlined into one. A tiny-memory target pays 0 B, verified by compiling the header with FL_PLATFORM_HAS_TINY_MEMORY=1. Two tests: the managed path emits the drive and the unbound path still saturates at 65535 through the legacy curve, and black stays black on both so a difference can only be shaping rather than an offset. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughHD108 encoding now receives color-management state. Managed sources use direct 16-bit RGB encoding with brightness scaling, while unmanaged sources retain legacy gamma encoding. Tests compare both paths and validate black output. The ESP32-S3 size baseline records the measured increase. ChangesHD108 encoding
Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant Channel
participant PixelIterator
participant MockEngine
Channel->>PixelIterator: Pass iterator.isManaged()
PixelIterator->>PixelIterator: Encode managed RGB16 or legacy gamma path
PixelIterator->>MockEngine: Emit HD108 frames
MockEngine-->>Channel: Capture encoded bytes
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
zackees
added a commit
that referenced
this pull request
Sep 12, 2026
…ution (#4042) (#4388) P8 owns "native 16-bit encoders consume wide output; monotonic; low-light resolution". #4368 and #4387 did the first clause for UCS7604-16 and HD108; nothing measured the other two. Swept all 256 source codes through the UCS7604-16 path, managed and unbound side by side. Both are monotonic -- a rising source code never lowers the emitted value, zero violations either way -- so the wide path did not buy that at the cost of ordering. Where they part company is resolution. In the bottom 32 codes the managed path keeps all 32 distinguishable; the gamma LUT collapses four pairs, so 28. Across the full range, 256 against 252. Worth stating plainly in the test, because the number invites a wrong reading: this is not more *reachable* levels. An 8-bit CRGB can only ask for 256 things, and it still can. It is that none of them are discarded on the way out. Turning the 16-bit wire into more than 256 levels needs a wide source -- .fled rgb16_linear -- and this is the half that stops throwing them away first. The counts are measured, not assumed. Narrowing the managed drive to 8 bits and widening it again fails these, as does disabling the wide branch. Claude-Session: https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9 Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
This was referenced Sep 12, 2026
Merged
Closed
zackees
added a commit
that referenced
this pull request
Sep 12, 2026
…tial #4402) (#4403) * perf(hd108): stop computing a constant brightness header per LED (#4402) `hd108BrightnessHeader` discards its argument -- `(void)brightness_8bit`, then three `constexpr` gains of 31 -- and returns 0xFF 0xFF for every input. Both HD108 encode paths were doing work to feed it anyway. `encodeHD108_HD` carried a per-LED cache (`lastBrightness8`, `lastF0`, `lastF1`, plus a compare/branch) guarding against recomputing a value that cannot change, and dereferenced `brightness_first` once per LED to feed it. That read was the expensive half: the sole in-tree caller passes `ScaledPixelIteratorBrightness`, whose `load()` is out of line, so it was a function call per LED to fetch a number that reached nothing. `writeHD108`'s managed path built that whole adapter -- `makeScaledBrightness` plus a `load()` -- for the single purpose of passing a value into the same discarding function. Both are gone. The header is computed once per strip. Output is unchanged by construction, not by measurement: every removed value fed only an argument that is cast to void. Why now: the esp32dev size gate has been red on master since #4387 at 340235 B against a frozen 340000 B ceiling. `ci/lint/check_size_thresholds.py` exists because "CI agents have repeatedly tried to fix red size-check workflows by raising the thresholds instead of fixing the underlying regression", so the ceiling stays and the bytes come out of the code. #4402 has the full diagnosis. A new test pins the premise: HD108 output is byte-identical across brightness 0, 255 and a 0->255 ramp, and the header really is the pinned maximum rather than merely constant. Verified load-bearing -- making `hd108BrightnessHeader` honour its argument fails it by name, along with ten siblings that assert the pinned header. The stale "brightness caching optimization" case is renamed to what it actually checks, since the cache it was named for no longer exists. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9 * perf(hd108): call one encoder, not two copies of the same one (#4402) With the per-LED brightness read and its cache gone, `encodeHD108_HD` is `encodeHD108` with an extra argument. Both walk `makeScaledPixelRangeRGB`, both widen through `hd108GammaCorrect`, both frame with the same start and latch, and both headers come from `hd108BrightnessHeader`, which pins every gain at 31 whatever it is handed. So a build with FASTLED_HD_COLOR_MIXING was carrying a second copy of one function. `writeHD108` now calls `encodeHD108` on either branch and the `#if` around the call site goes away. `encodeHD108_HD` stays in hd108.h for source compatibility. A new test asserts the two agree byte for byte across five pixels and five brightness values, so the collapse cannot quietly stop being true -- if a real per-LED brightness ever lands, that test fails and says so. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9 * chore(bloat): lock in the 66 B the HD108 cleanup recovered (#4402) The gate fails on an unexplained *drop* past its 64 B tolerance, which is the ratchet asking for the win to be recorded rather than left as headroom. 342957 -> 342891. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9 --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
This was referenced Sep 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Completes the wide-output work #4368 started, for the other native 16-bit chipset. Part of #4034 P8 (#4042), "encoders consume wide output directly".
#4326 called HD108 "the same shape and worse".
hd108GammaCorrectis a hardcoded 2.8 inside the encoder, so unlike UCS7604'smGamma.value_or(2.8f)no caller could ever have chosen otherwise — andwriteHD108took no settings at all, so the information needed to suppress it was not in scope.Measured
On a managed channel HD108 put 849 on the wire where the device solve asked for 13933 — the identical number the UCS7604 path produced before #4368. It now puts 13935.
Confirmed causally rather than by inspection: disabling the wide branch returns the case to
849 > 13900failing.Notes
isManaged(), nothasColorProfile()— the distinction established in feat(color): let the 16-bit encoder consume the device drive (P8, #4042/#4326) #4368's review. A rejected binding leaves the legacy controller in place while the options still report a profile; taking the no-gamma path over its 8-bit pixels would drop a stage that path still needs.writeHD108rather than anencodeHD108_wideinhd108.h. That header is included bypixel_iterator.h, before the class exists, and a concretePixelIterator¶meter is not a dependent type — so the body would be checked there and fail. That is the same property that made the UCS7604 wide encoder a hard compile error on TINY until it was guarded, so it is worth stating rather than rediscovering.FL_PLATFORM_HAS_TINY_MEMORY=1.Flash
+240 B, baseline moved to 342954 with the symbol diff recorded in the file:
loadAndScaleRGB16was inlined into its single caller; with a second one it is emitted once and called twice, which is the cheaper arrangement. Measured withfbuild symbolson the ELF the build produced —bash bloat --buildused to analyse a different one, fixed in #4386.Tests
Two cases: the managed path emits the drive while the unbound path still saturates at 65535 through the legacy curve, and black stays black on both — so a difference above can only be shaping, not an offset.
bash lintclean; 305/305 unit, 84/84 examples.🤖 Generated with Claude Code
https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9
Summary by CodeRabbit
Bug Fixes
Tests