FastLED 3.10.8
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 934 of file channel.cpp.hpp.

934 {
935 // Build pixel iterator with optional addressing transformation
936 // (#2558) Pass both Rgbw and Rgbww from the current rendering settings; the iterator
937 // carries both, and the encoder dispatch below picks the right path based
938 // on which white-channel variant the controller currently holds.
939#if FL_COLOR_PROFILE_RUNTIME
940 // Brightness reaches the pipeline as C4's flux scalar and nowhere else.
941 // `premixed` is the brightness on this path: binding a profile sets
942 // correction and temperature to identity, so nothing else is folded into
943 // it -- and reading it rather than `ColorAdjustment::brightness` keeps
944 // this working when FASTLED_HD_COLOR_MIXING is off, where that field
945 // does not exist.
946 //
947 // The shared pipeline is never written after it is built (#4440): this
948 // managed iterator takes a reference, copies it, and sets flux on the copy, so a
949 // concurrent reader -- the power estimate copies the same pipeline --
950 // never sees a half-written flux, and a reconfiguration replaces
951 // `mPipeline` without touching what this frame encodes through. Small
952 // tiers encode synchronously and keep single ownership, mutated in place.
953#if FL_COLOR_PIPELINE_SHARED
954 const ColorPipelineStorage pipeline_ref = mPipeline;
955 const StreamingPipelineQ16* pipeline = pipeline_ref.get();
956#else
957 StreamingPipelineQ16* pipeline = mPipeline.get();
958#endif
959#else
960 StreamingPipelineQ16* pipeline = nullptr;
961#endif
962 // Dither advances on presentation, not on attempt (#4347, R8): this
963 // channel's phase moves only when its driver accepts a frame (submitFrame()), so
964 // a dropped submission -- no driver, a disabled one, a busy buffer --
965 // does not consume a phase and the cycle's average stays unbiased. Both
966 // the legacy offsets and the colour-managed temporal dither read it.
967 if (pixels.ditherActive()) {
969 }
970#ifdef FL_IS_AVR
971 // AVR omits base settings notifications, so base setters are authoritative.
972 const auto& whiteSettings = mLegacySettings;
973#else
974 const auto& whiteSettings = mSettings;
975#endif
976 ReorderingPixelIteratorAny iterator(pixels, mScreenMap.getXYMap(), mRgbOrder,
977 whiteSettings.rgbw(), whiteSettings.rgbww(),
978 mName, pipeline, mDitherPhase,
979 pixels.mColorAdjustment.premixed.r);
980 PixelIterator& pixelIterator = iterator.get();
981
982 // Encode pixels with the writer selected once from the immutable chipset.
983 auto& data = mChannelData->getData();
984 data.clear();
985 const auto* rgbww = whiteSettings.mWhiteCfg.ptr<Rgbww>();
986 const auto* rgbw = whiteSettings.mWhiteCfg.ptr<Rgbw>();
987 if (rgbww != nullptr && rgbww->active()) {
989 } else if (rgbw != nullptr && rgbw->active()) {
990 mChannelData->setPixelFormat(ChannelPixelFormat::RGBW);
991 } else {
992 mChannelData->setPixelFormat(ChannelPixelFormat::RGB);
993 }
994
995 if (mPixelEncoder != nullptr) {
996 mPixelEncoder(*this, pixelIterator, iterator.isManaged(), data);
997 }
998
999 // Fire event after encoding completes
1000 {
1001 auto& events = ChannelEvents::instance();
1002 events.onChannelDataEncoded(*this, *mChannelData);
1003 }
1004}
Rgbw rgbw
LegacySettings mLegacySettings
EOrder mRgbOrder
Definition channel.h:415
PixelEncoder mPixelEncoder
Definition channel.h:414
u8 mDitherPhase
This channel's temporal-dither phase.
Definition channel.h:448
fl::ScreenMap mScreenMap
Definition channel.h:458
ChannelDataPtr mChannelData
Definition channel.h:457
fl::string mName
Definition channel.h:456
ChannelOptions mSettings
Definition channel.h:459
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: