FastLED 3.9.15
Loading...
Searching...
No Matches

◆ processGif()

void CodecProcessor::processGif ( )

Definition at line 87 of file codec_processor.cpp.

87 {
88 Serial.println("\n=== Processing GIF ===");
89
90 if (!fl::Gif::isSupported()) {
91 Serial.println("GIF decoding not supported on this platform");
92 return;
93 }
94
95 // Copy data from PROGMEM to RAM
98
99 // Configure GIF decoder
100 fl::GifConfig config;
103
104 // Create decoder
105 fl::string error_msg;
106 fl::shared_ptr<fl::IDecoder> decoder = fl::Gif::createDecoder(config, &error_msg);
107
108 if (!decoder) {
109 Serial.print("Failed to create GIF decoder: ");
110 Serial.println(error_msg.c_str());
111 return;
112 }
113
114 // Create byte stream from data
115 auto stream = fl::make_shared<fl::memorybuf>(gifData.size());
116 stream->write(gifData);
117
118 // Begin decoding
119 if (!decoder->begin(stream)) {
120 fl::string error;
121 decoder->hasError(&error);
122 Serial.print("Failed to begin GIF decoding: ");
123 Serial.println(error.c_str());
124 return;
125 }
126
127 // Decode first frame
128 fl::DecodeResult result = decoder->decode();
129
130 if (result == fl::DecodeResult::Success) {
131 fl::Frame frame = decoder->getCurrentFrame();
132 if (frame.isValid()) {
133 displayFrameOnLEDs(frame);
134 showDecodedMessage("GIF decoded successfully!");
135 } else {
136 Serial.println("Invalid GIF frame received");
137 }
138 } else {
139 fl::string error;
140 decoder->hasError(&error);
141 Serial.print("GIF frame decode error: ");
142 Serial.println(error.c_str());
143 }
144
145 decoder->end();
146}
bool isValid() const
static IDecoderPtr createDecoder(const GifConfig &config, fl::string *error_message=nullptr)
Definition gif.cpp.hpp:9
static bool isSupported()
Definition gif.cpp.hpp:23
const char * c_str() const FL_NOEXCEPT
const size_t sampleGifDataLength
const uint8_t sampleGifData[]
void displayFrameOnLEDs(const fl::Frame &frame)
void showDecodedMessage(const char *format)
void * memcopy(void *dest, const void *src, size_t n) FL_NOEXCEPT
Definition cstring.h:103
shared_ptr< T > make_shared(Args &&... args) FL_NOEXCEPT
Definition shared_ptr.h:414
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31
DecodeResult
Definition idecoder.h:18
@ SingleFrame
Definition gif.h:30
PixelFormat format
Definition gif.h:33
FrameMode mode
Definition gif.h:32
#define Serial
Definition serial.h:304

References fl::basic_string::c_str(), fl::Gif::createDecoder(), fl::vector< T >::data(), displayFrameOnLEDs(), fl::GifConfig::format, fl::Gif::isSupported(), fl::Frame::isValid(), fl::make_shared(), fl::memcopy(), fl::GifConfig::mode, fl::RGB888, CodecData::sampleGifData, CodecData::sampleGifDataLength, Serial, showDecodedMessage(), fl::GifConfig::SingleFrame, fl::vector_basic::size(), and fl::Success.

Referenced by loop().

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