FastLED 3.10.6
Loading...
Searching...
No Matches
pipeline.h
Go to the documentation of this file.
1#pragma once
2
3// The streaming pipeline core (P6, #4040).
4//
5// P6's stages have existed as separate modules for a while -- decode,
6// primaries->XYZ, chromatic adaptation, the device solve, the gamut mapper,
7// the flux scalar -- with nothing composing them. This is the composition:
8// one bind-time build, and one per-pixel call that runs the whole chain.
9//
10// The chain, and why it is in this order:
11//
12// 1. `decodeTransferU16` turns each RGB8 code into u16 linear light. One
13// semantic conversion, per B3: there is no intermediate RGB8 linear
14// buffer and no RGB8->RGB8 correction anywhere in it.
15// 2. `linearRgbToXyzQ16` takes those to s16.16 XYZ. Chromatic adaptation
16// is folded into that matrix at bind time, so it costs nothing here.
17// 3. The gamut mapper maps the target onto the device hull and solves for
18// drives -- clamping belongs to it, not to the stages before.
19// 4. `applyFluxScalar` scales linear emitter light. C4's single insertion point:
20// brightness and the power limiter compose into one scalar before they
21// get here. Inverse physical response then produces drive coordinates;
22// native encoding performs the final quantization.
23//
24// Streaming, per C2: the per-pixel call carries no state and allocates
25// nothing, so it runs inside `PixelController` iteration without an RGB16
26// framebuffer.
27
30#include "fl/gfx/flux_scalar.h"
31#include "fl/gfx/gamut_map.h"
32#include "fl/gfx/source_xyz.h"
33#include "fl/stl/int.h"
34#include "fl/stl/noexcept.h"
35#include "fl/stl/shared_ptr.h"
36#include "fl/stl/vector.h"
37
38namespace fl {
39
48
58
106
121 GamutPolicy policy,
123 const Chromaticity* target_white = nullptr) FL_NO_EXCEPT;
124
127
132void processPixelQ16(const StreamingPipelineQ16& pipeline, u8 r, u8 g, u8 b,
133 i32 (&drives)[3]) FL_NO_EXCEPT;
134
138void processPixelLinearQ16(const StreamingPipelineQ16& pipeline, u8 r, u8 g,
139 u8 b, i32 (&light)[3]) FL_NO_EXCEPT;
140
144void processPixelWideQ16(const StreamingPipelineQ16& pipeline, u8 r, u8 g,
145 u8 b, i32 (&drives)[5]) FL_NO_EXCEPT;
147 u8 g, u8 b, i32 (&light)[5]) FL_NO_EXCEPT;
148
151i32 encodeLinearEmitterQ16(const StreamingPipelineQ16& pipeline, u8 emitter,
152 i32 light, FluxScalar flux) FL_NO_EXCEPT;
153
154} // namespace fl
static FluxScalar unity() FL_NO_EXCEPT
Identity. Drives pass through unchanged.
A linear flux scalar in s16.16.
Definition flux_scalar.h:21
Shared colorimetric primitives reusable by the RGBW and (future) RGB colorimetric paths (issue #3255)...
unsigned char u8
Definition stdint.h:131
void setPipelineFluxQ16(StreamingPipelineQ16 *pipeline, FluxScalar flux) FL_NO_EXCEPT
Set the composed brightness-and-power scalar for the frames that follow.
GamutPolicy
void processPixelLinearQ16(const StreamingPipelineQ16 &pipeline, u8 r, u8 g, u8 b, i32(&drives)[3]) FL_NO_EXCEPT
Pre-response linear emitter light for a power prepass.
TransferFunction
void processPixelWideLinearQ16(const StreamingPipelineQ16 &pipeline, u8 r, u8 g, u8 b, i32(&drives)[5]) FL_NO_EXCEPT
InputGamut g FL_NO_EXCEPT
Definition rgbw.h:121
InputGamut g
Definition rgbw.h:124
bool buildStreamingPipelineQ16(const SourceProfile &source, const colorimetric_response::EmitterProfile &device, GamutPolicy policy, StreamingPipelineQ16 *out, const Chromaticity *target_white) FL_NO_EXCEPT
Bind a source declaration and a device profile into a pipeline.
void processPixelWideQ16(const StreamingPipelineQ16 &pipeline, u8 r, u8 g, u8 b, i32(&drives)[5]) FL_NO_EXCEPT
Like processPixelQ16, but solves the physical 4/5-emitter hull.
i32 encodeLinearEmitterQ16(const StreamingPipelineQ16 &pipeline, u8 emitter, i32 light, FluxScalar flux) FL_NO_EXCEPT
Scale one linear emitter and invert its physical response, using the identical final stage as process...
void processPixelQ16(const StreamingPipelineQ16 &pipeline, u8 r, u8 g, u8 b, i32(&drives)[3]) FL_NO_EXCEPT
One pixel: an RGB8 code triple to three physical emitter drives in s16.16.
Base definition for an LED controller.
Definition crgb.hpp:179
TransferFunction transfer
The source's transfer function, applied per code.
Definition pipeline.h:75
GamutPolicy gamut_policy
What to do with a target the device cannot reproduce.
Definition pipeline.h:91
shared_ptr< const ResponseLutsQ16 > response
Absent means linear code-to-light response.
Definition pipeline.h:102
GamutMapQ16 gamut
The device hull, its solve, and the lightness bound.
Definition pipeline.h:81
vector< u16 > white1_response
Definition pipeline.h:55
vector< u16 > green
Definition pipeline.h:45
vector< u16 > red
Definition pipeline.h:44
vector< u16 > blue
Definition pipeline.h:46
FluxScalar flux
Brightness times power limiting, as one scalar (C4).
Definition pipeline.h:98
colorimetric_response::EmitterTopology topology
Definition pipeline.h:52
vector< u16 > white2_response
Definition pipeline.h:56
shared_ptr< const WidePipelineQ16 > wide
Definition pipeline.h:104
GamutMapRgbwwQ16 rgbww
Definition pipeline.h:54
SourceMatrixQ16 source
Source primaries to XYZ, with adaptation to D65 already folded in.
Definition pipeline.h:78
GamutMapRgbwQ16 rgbw
Definition pipeline.h:53
The same mapper for a device with a white emitter.
Definition gamut_map.h:69
Everything the per-pixel mapper needs, derived once when a profile binds.
Definition gamut_map.h:43
The same mapper for a device with two white emitters.
Definition gamut_map.h:122
Source-primaries matrix in s16.16, rows ordered X, Y, Z.
Definition source_xyz.h:20
Owned code-to-light samples for the three physical emitters.
Definition pipeline.h:43
Everything the per-pixel path needs, derived once when a profile binds.
Definition pipeline.h:73
Allocated only for a bound four- or five-emitter profile.
Definition pipeline.h:51
CIE 1931 xy chromaticity, independent of encoded storage and chipset.
A source declaration, not a container or an output-device selection.