FastLED 3.10.6
Loading...
Searching...
No Matches

◆ encodeFrame()

void fl::Channel::encodeFrame ( PixelController< RGB, 1, 0xFFFFFFFF > & pixels)
private

Encode pixels into mChannelData and fire onChannelDataEncoded (#4566).

Definition at line 911 of file channel.cpp.hpp.

911 {
912 // Build pixel iterator with optional addressing transformation
913 // (#2558) Pass both Rgbw and Rgbww from the channel options; the iterator
914 // carries both, and the encoder dispatch below picks the right path based
915 // on which variant alternative ChannelOptions::mWhiteCfg holds.
916#if FL_COLOR_PROFILE_RUNTIME
917 // Brightness reaches the pipeline as C4's flux scalar and nowhere else.
918 // `premixed` is the brightness on this path: binding a profile sets
919 // correction and temperature to identity, so nothing else is folded into
920 // it -- and reading it rather than `ColorAdjustment::brightness` keeps
921 // this working when FASTLED_HD_COLOR_MIXING is off, where that field
922 // does not exist.
923 //
924 // The shared pipeline is never written after it is built (#4440): this
925 // managed iterator takes a reference, copies it, and sets flux on the copy, so a
926 // concurrent reader -- the power estimate copies the same pipeline --
927 // never sees a half-written flux, and a reconfiguration replaces
928 // `mPipeline` without touching what this frame encodes through. Small
929 // tiers encode synchronously and keep single ownership, mutated in place.
930#if FL_COLOR_PIPELINE_SHARED
931 const ColorPipelineStorage pipeline_ref = mPipeline;
932 const StreamingPipelineQ16* pipeline = pipeline_ref.get();
933#else
934 StreamingPipelineQ16* pipeline = mPipeline.get();
935#endif
936#else
937 StreamingPipelineQ16* pipeline = nullptr;
938#endif
939 // Dither advances on presentation, not on attempt (#4347, R8): this
940 // channel's phase moves only when its driver accepts a frame (submitFrame()), so
941 // a dropped submission -- no driver, a disabled one, a busy buffer --
942 // does not consume a phase and the cycle's average stays unbiased. Both
943 // the legacy offsets and the colour-managed temporal dither read it.
944 if (pixels.ditherActive()) {
946 }
947 ReorderingPixelIteratorAny iterator(pixels, mScreenMap.getXYMap(), mRgbOrder,
949 mName, pipeline, mDitherPhase,
950 pixels.mColorAdjustment.premixed.r);
951 PixelIterator& pixelIterator = iterator.get();
952
953 // Encode pixels with the writer selected once from the immutable chipset.
954 auto& data = mChannelData->getData();
955 data.clear();
956 if (mSettings.isRgbww()) {
958 } else if (mSettings.isRgbw()) {
959 mChannelData->setPixelFormat(ChannelPixelFormat::RGBW);
960 } else {
961 mChannelData->setPixelFormat(ChannelPixelFormat::RGB);
962 }
963
964 if (mPixelEncoder != nullptr) {
965 mPixelEncoder(*this, pixelIterator, iterator.isManaged(), data);
966 }
967
968 // Fire event after encoding completes
969 {
970 auto& events = ChannelEvents::instance();
971 events.onChannelDataEncoded(*this, *mChannelData);
972 }
973}
ChannelOptions mSettings
Optional channel settings (correction, temperature, dither, rgbw, affinity)
EOrder mRgbOrder
Definition channel.h:393
PixelEncoder mPixelEncoder
Definition channel.h:392
u8 mDitherPhase
This channel's temporal-dither phase.
Definition channel.h:426
fl::ScreenMap mScreenMap
Definition channel.h:436
ChannelDataPtr mChannelData
Definition channel.h:435
fl::string mName
Definition channel.h:434
const XYMap * getXYMap() const FL_NO_EXCEPT
Get the source XYMap as a raw const pointer.
fl::PixelIterator PixelIterator
ColorAdjustment mColorAdjustment
void reseed_binary_dithering(fl::u8 R)
Re-point binary dithering at phase R after construction, leaving the per-channel ranges e[] as init_b...
FASTLED_FORCE_INLINE bool ditherActive() const
Is temporal dithering on for this frame? (any channel has a range)
static ChannelEvents & instance()
Rgbww rgbww() const FL_NO_EXCEPT
Definition options.h:325
bool isRgbw() const FL_NO_EXCEPT
True if this channel emits 4-channel RGBW.
Definition options.h:334
Rgbw rgbw() const FL_NO_EXCEPT
Definition options.h:319
bool isRgbww() const FL_NO_EXCEPT
True if this channel emits 5-channel RGBWW.
Definition options.h:340

References fl::FL_NO_EXCEPT, fl::ChannelEvents::instance(), mChannelData, mDitherPhase, mName, mPixelEncoder, mRgbOrder, mScreenMap, fl::CLEDController::mSettings, fl::RGB, fl::RGBW, and fl::RGBWW.

Referenced by showPixels().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: