Repository navigation
feat(fled): let the builder emit video.color - #4164
Conversation
#4160 landed the parser half of #4038: `.fled` files carry `video.color` and the parser validates it. The producer half was missing. `FledBuilder` had `setScreenMapJson()` and `setChannelsJson()` but no way to declare a source color tuple, so the only way to emit one was to hand-write the envelope JSON -- which is exactly the drift the spec exists to prevent. #4038 lists the producer in both its scope ("bring mirror, builder, parser, and video consumer to the same contract") and its acceptance criterion (".fled spec/producer/mirror/parser/playback carry and honor video.color"). `setVideoColor(const VideoColor&)` writes the tuple under `video.color` with the spelling FLED_FORMAT.md defines. Three choices worth stating: - The wire spellings are literals in the serializer, not derived from the enumerators, so renaming a C++ enum cannot silently change the format. - All four keys are always written. Partial-tuple inheritance applies only to pixel formats that define a default tuple, and a producer should not have to know which those are. - `matrix` and `range` are emitted literally as the single value v1 allows for each, so producer and parser cannot drift. Custom primaries serialize as CIE xy pairs at four decimals, enough for the D65 white point (0.3127, 0.3290) to survive the round trip exactly. Tests build through the canonical Fled::loadFromVector() path and read back with Fled::videoColor(), covering each named primaries value, custom primaries, absent metadata resolving to the undeclared default, and a tuple the producer can emit but the parser must reject (rgb8 + linear transfer). Confirmed by mutation: spelling DisplayP3 as "bt709" fails the round-trip. Verified: `bash test --cpp` 287/287 unit + 84/84 examples, `bash lint` clean. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 8 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthrough
ChangesVideo color metadata
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to Fled producers can now declare video color metadata, including named and custom primaries, while existing undeclared-color behavior remains unchanged. No concrete merge-blocking risk remains. Sequence Diagram(s)sequenceDiagram
participant Caller
participant FledBuilder
participant JSONEnvelope
Caller->>FledBuilder: setVideoColor(VideoColor)
FledBuilder->>FledBuilder: serializeVideoColor()
Caller->>FledBuilder: build()
FledBuilder->>JSONEnvelope: buildEnvelope(videoColorJson)
JSONEnvelope-->>Caller: JSON with video.color
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 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 |
Completes the producer half of #4038 (Color pipeline P4), under #4034.
The gap
#4160 landed the parser half:
.fledfiles carryvideo.colorand the parser validates it against the header's pixel format. ButFledBuilderhad onlysetScreenMapJson()andsetChannelsJson()— no way to declare a source color tuple. The only way to emit one was to hand-write the envelope JSON, which is precisely the producer/parser drift the spec exists to prevent.#4038 names the producer in both halves of its definition:
What this adds
FledBuilder::setVideoColor(const VideoColor&), writing the tuple undervideo.colorwith the spellingFLED_FORMAT.mddefines.Three choices worth calling out, because each is a place this could rot:
matrixandrangeare emitted literally as the single value v1 permits for each, so producer and parser cannot drift apart.Custom primaries serialize as CIE xy pairs at four decimals — enough for the D65 white point (0.3127, 0.3290) to round-trip exactly.
Tests
All build through the canonical
Fled::loadFromVector()path and read back viaFled::videoColor(), so they exercise the real parse, not a private hook:bt709/display-p3/bt2020survive with their transfersetVideoColor()calldeclared == falselineartransferTransferConflictsWithFormatThat last one matters: a producer must not be able to emit a tuple its own parser rejects, and this proves the rejection is reachable from the builder.
Confirmed by mutation — spelling
DisplayP3as"bt709"in the serializer fails the round-trip test atfled_builder.cpp:81, so the tests genuinely exercise the serializer rather than passing vacuously.Verification
bash test --cpp— 287/287 unit, 84/84 examplesbash lint— cleanNot in this PR
The canonical ledmapper v1 spec lives in another repo; this changes FastLED's mirror and producer only.
🤖 Generated with Claude Code
https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9
Summary by CodeRabbit
New Features
Bug Fixes