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

◆ loadMoreData()

bool fl::third_party::SoftwareGifDecoder::loadMoreData ( )
private

Definition at line 235 of file software_decoder.cpp.hpp.

235 {
236 if (!stream_ || !gif_) {
237 return false;
238 }
239
240 // Read available data from stream in chunks and accumulate
241 const fl::size bufferSize = 4096; // Read in chunks
242 fl::u8 buffer[bufferSize];
243 fl::size bytesRead = stream_->read(buffer, bufferSize);
244
245 if (bytesRead == 0) {
246 // No more data available, mark as complete
248 dataComplete_ = true;
249 return false;
250 }
251
252 // Append new data to accumulated buffer
253 // libnsgif requires ALL data to be provided in each call to nsgif_data_scan
254 fl::size oldSize = dataBuffer_.size();
255 dataBuffer_.resize(oldSize + bytesRead);
256 fl::memcpy(dataBuffer_.data() + oldSize, buffer, bytesRead);
257
258 // Feed ALL accumulated data to libnsgif
260
261 // Check if we've read less than requested (likely end of stream)
262 if (bytesRead < bufferSize) {
264 dataComplete_ = true;
265 }
266
268 setError(fl::string("GIF data scan error: ") + nsgif_strerror(result));
269 return false;
270 }
271
272 // Frame count is available via nsgif_get_info() if needed in the future
273
274 return true;
275}
void setError(const fl::string &message) FL_NOEXCEPT
unsigned char u8
Definition coder.h:132
nsgif_error
LibNSGIF return codes.
Definition nsgif.hpp:58
@ NSGIF_ERR_END_OF_DATA
Unexpected end of GIF source data.
Definition nsgif.hpp:87
@ NSGIF_OK
Success.
Definition nsgif.hpp:62
nsgif_error nsgif_data_scan(nsgif_t *gif, fl::size size, const fl::u8 *data) FL_NOEXCEPT
Scan the source image data.
Definition gif.cpp.hpp:1616
void nsgif_data_complete(nsgif_t *gif) FL_NOEXCEPT
Tell libnsgif that all the gif data has been provided.
Definition gif.cpp.hpp:1772
const char * nsgif_strerror(nsgif_error err) FL_NOEXCEPT
Convert an error code to a string.
Definition gif.cpp.hpp:2045
void * memcpy(void *dest, const void *src, size_t n) FL_NOEXCEPT
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31

References dataBuffer_, dataComplete_, FL_NOEXCEPT, gif_, fl::memcpy(), fl::third_party::nsgif_data_complete(), fl::third_party::nsgif_data_scan(), fl::third_party::NSGIF_ERR_END_OF_DATA, fl::third_party::NSGIF_OK, fl::third_party::nsgif_strerror(), setError(), and stream_.

Referenced by begin(), and decode().

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