Skip to content

test(color): pin C5's dither exclusion where it can actually be measured (#4042) - #4394

Merged
zackees merged 1 commit into
masterfrom
test/4042-c5-dither-exclusion
Sep 12, 2026
Merged

zackees merged 1 commit into
masterfrom
test/4042-c5-dither-exclusion

Conversation

@zackees

@zackees zackees commented Sep 12, 2026 •

Copy link
Copy Markdown
Member

Part of #4034 P8 (#4042). Pins C5: "Pipeline dithering and BINARY_DITHER are mutually exclusive per channel."

The gap this covers

ChannelOptions::setColorProfile enforces half of C5 by setting DISABLE_DITHER. But mDitherMode is a public field, not a setter — unlike setLegacyCorrection, which clears the profile and warns — so nothing stops:

options.setColorProfile(...);
options.mDitherMode = BINARY_DITHER;   // no guard, no warning

What makes that harmless is structural, and this file's own header already explains it: the managed source reads mController.mData rather than loadAndScale0/1/2, because those fold in mColorAdjustment whose premixed carries brightness the pipeline also carries. Legacy dithering lives inside those same calls, so bypassing them for the brightness reason excludes the dither as a consequence.

That is worth a test precisely because it is incidental — nothing declares it, so nothing would notice it changing.

Three attempts, and why two failed

Both failures passed cleanly and looked convincing, which is the point of recording them.

  1. Through Channel::showLeds, counting distinct emitted bytes over a cycle: managed held one value, unbound varied. Routing the managed source through the dithering path did not change it — at two source values and two brightnesses. So it could not distinguish "the managed path ignores dither" from "dither was never armed in this harness". I reverted that one and reported it on this issue rather than banking it.
  2. At unit level with the 8-bit entry point: same outcome, different cause. A dither-scale change in the pipeline's input is smaller than the output byte's quantum, so the result is identical whether the read is right or wrong.
  3. The 16-bit entry point has 256× the resolution and does move. Mutating loadAndScaleRGB16 to read the dithered value now fails this case — the first version that could.

Vacuity guard

A legacy PixelController with identical settings runs beside it and does vary across the cycle, so the assertion is about the managed path rather than about a harness that never dithers anything.

bash lint clean; 305/305 unit, 84/84 examples.

Test-only; no src/ change.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9

Summary by CodeRabbit

  • Tests
    • Added coverage verifying that legacy dithering does not affect color-managed pixel sources.
    • Confirmed expected output behavior across multiple dithering frames for both legacy and managed rendering paths.

…red (#4042)

C5 says pipeline dithering and BINARY_DITHER are mutually exclusive per
channel. `setColorProfile` enforces half of it by setting DISABLE_DITHER, but
`mDitherMode` is a public field rather than a setter -- unlike
`setLegacyCorrection`, which clears the profile and warns -- so a caller can
re-enable it after binding and reach the forbidden combination through the
type system.

What makes that harmless is structural, and this file's own header already
says why: the managed source reads `mController.mData` rather than
`loadAndScale0/1/2`, because those fold in `mColorAdjustment` whose `premixed`
carries brightness the pipeline also carries. Legacy dithering lives inside
those same calls, so bypassing them for the brightness reason excludes the
dither as a consequence.

Getting a test that can fail took three attempts, and the two that did not are
worth recording because each looked convincing.

Through `Channel::showLeds`, counting distinct emitted bytes over a cycle: the
managed channel held one value and the unbound one varied, which reads as the
exclusion working. Routing the managed source through the dithering path did
not change it, at two source values and two brightnesses -- so the measurement
could not tell "the managed path ignores dither" from "dither was never armed
here".

At this level with the 8-bit entry point: same problem for a different reason.
A dither-scale change in the pipeline's input is smaller than the output's
quantum, so the byte is identical whether the read is right or wrong.

The 16-bit entry point has 256x the resolution and does move. Mutating
`loadAndScaleRGB16` to read the dithered value now fails this case, which is
the first version of it that could.

The legacy controller beside it varies across the cycle, so the assertion is
about the managed path rather than about a harness that never dithers.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9
@zackees
zackees merged commit a8fb9e7 into master Sep 12, 2026
4 of 5 checks passed
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Sep 12, 2026
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Sep 12, 2026
@coderabbitai

coderabbitai Bot commented Sep 12, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 1b2c426a-f29d-401c-86cb-d27ee2ffbbdc

📥 Commits

Reviewing files that changed from the base of the PR and between eda0dc7 and 8637ae5.

📒 Files selected for processing (1)
  • tests/fl/channels/color_managed_source.cpp

📝 Walkthrough

Walkthrough

Adds a test for BINARY_DITHER behavior. The test compares a legacy PixelController with a ColorManagedPixelSource across eight dither frames and validates their output variation.

Changes

Dithering behavior validation

Layer / File(s) Summary
Dither comparison test
tests/fl/channels/color_managed_source.cpp
Adds dither-frame support and a test that verifies legacy output varies while managed-source output remains constant across eight frames.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/4042-c5-dither-exclusion

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant