FastLED 3.10.10
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 971 of file channel.cpp.hpp.

971 {
972 // Build pixel iterator with optional addressing transformation
973 // (#2558) Pass both Rgbw and Rgbww from the current rendering settings; the iterator
974 // carries both, and the encoder dispatch below picks the right path based
975 // on which white-channel variant the controller currently holds.
976#if FL_COLOR_PROFILE_RUNTIME
977 // Brightness reaches the pipeline as C4's flux scalar and nowhere else.
978 // `premixed` is the brightness on this path: binding a profile sets
979 // correction and temperature to identity, so nothing else is folded into
980 // it -- and reading it rather than `ColorAdjustment::brightness` keeps
981 // this working when FASTLED_HD_COLOR_MIXING is off, where that field
982 // does not exist.
983 //
984 // The shared pipeline is never written after it is built (#4440): this
985 // managed iterator takes a reference, copies it, and sets flux on the copy, so a
986 // concurrent reader -- the power estimate copies the same pipeline --
987 // never sees a half-written flux, and a reconfiguration replaces
988 // `mPipeline` without touching what this frame encodes through. Small
989 // tiers encode synchronously and keep single ownership, mutated in place.
990#if FL_COLOR_PIPELINE_SHARED
991 const ColorPipelineStorage pipeline_ref = mPipeline;
992 const StreamingPipelineQ16* pipeline = pipeline_ref.get();
993#else
994 StreamingPipelineQ16* pipeline = mPipeline.get();
995#endif
996#else
997 StreamingPipelineQ16* pipeline = nullptr;
998#endif
999 // Dither advances on presentation, not on attempt (#4347, R8): this
1000 // channel's phase moves only when its driver accepts a frame (submitFrame()), so
1001 // a dropped submission -- no driver, a disabled one, a busy buffer --
1002 // does not consume a phase and the cycle's average stays unbiased. Both
1003 // the legacy offsets and the colour-managed temporal dither read it.
1004 if (pixels.ditherActive()) {
1006 }
1007#ifdef FL_IS_AVR
1008 // AVR omits base settings notifications, so base setters are authoritative.
1009 const auto& whiteSettings = mLegacySettings;
1010#else
1011 const auto& whiteSettings = mSettings;
1012#endif
1013 ReorderingPixelIteratorAny iterator(pixels, mScreenMap.getXYMap(), mRgbOrder,
1014 whiteSettings.rgbw(), whiteSettings.rgbww(),
1015 mName, pipeline, mDitherPhase,
1016 pixels.mColorAdjustment.premixed.r);
1017 PixelIterator& pixelIterator = iterator.get();
1018
1019 // Encode pixels with the writer selected once from the immutable chipset.
1020 auto& data = mChannelData->getData();
1021 data.clear();
1022 const auto* rgbww = whiteSettings.mWhiteCfg.ptr<Rgbww>();
1023 const auto* rgbw = whiteSettings.mWhiteCfg.ptr<Rgbw>();
1024 if (rgbww != nullptr && rgbww->active()) {
1025 mChannelData->setPixelFormat(ChannelPixelFormat::RGBWW);
1026 } else if (rgbw != nullptr && rgbw->active()) {
1027 mChannelData->setPixelFormat(ChannelPixelFormat::RGBW);
1028 } else {
1029 mChannelData->setPixelFormat(ChannelPixelFormat::RGB);
1030 }
1031
1032 if (mPixelEncoder != nullptr) {
1033 mPixelEncoder(*this, pixelIterator, iterator.isManaged(), data);
1034 }
1035
1036 // Fire event after encoding completes
1037 {
1038 auto& events = ChannelEvents::instance();
1039 events.onChannelDataEncoded(*this, *mChannelData);
1040 }
1041}
Rgbw rgbw
LegacySettings mLegacySettings
EOrder mRgbOrder
Definition channel.h:417
PixelEncoder mPixelEncoder
Definition channel.h:416
u8 mDitherPhase
This channel's temporal-dither phase.
Definition channel.h:445
fl::ScreenMap mScreenMap
Definition channel.h:455
ChannelDataPtr mChannelData
Definition channel.h:454
fl::string mName
Definition channel.h:453
ChannelOptions mSettings
Definition channel.h:456
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) FL_NO_EXCEPT
Re-point binary dithering at phase R after construction, leaving the per-channel ranges e[] as init_b...
FASTLED_FORCE_INLINE bool ditherActive() const FL_NO_EXCEPT
Is temporal dithering on for this frame? (any channel has a range)
static ChannelEvents & instance() FL_NO_EXCEPT
FASTLED_FORCE_INLINE bool active() const FL_NO_EXCEPT
Definition rgbw.h:258

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

Referenced by showPixels().

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