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

◆ decode()

fl::DecodeResult fl::third_party::SoftwareGifDecoder::decode ( )
overridevirtual

Implements fl::IDecoder.

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

72 {
73 if (hasError_) {
75 }
76
77 if (!ready_) {
78 setError("Decoder not ready");
80 }
81
82 if (endOfStream_) {
84 }
85
86 // Try to decode current frame
87 nsgif_bitmap_t* bitmap = nullptr;
89
90 switch (result) {
91 case NSGIF_OK:
93 if (!currentFrame_) {
94 setError("Failed to convert bitmap to frame");
96 }
99
101 if (!dataComplete_) {
102 // Try to load more data
103 if (loadMoreData()) {
104 return decode(); // Retry
105 }
106 }
107 endOfStream_ = true;
109
111 endOfStream_ = true;
113
114 case NSGIF_ERR_OOM:
115 case NSGIF_ERR_DATA:
120 default:
121 setError(fl::string("GIF decode error: ") + nsgif_strerror(result));
123 }
124}
void setError(const fl::string &message) FL_NOEXCEPT
fl::DecodeResult decode() FL_NOEXCEPT override
fl::shared_ptr< fl::Frame > currentFrame_
fl::shared_ptr< fl::Frame > convertBitmapToFrame(nsgif_bitmap_t *bitmap) FL_NOEXCEPT
nsgif_error
LibNSGIF return codes.
Definition nsgif.hpp:58
@ NSGIF_ERR_DATA_COMPLETE
Can't supply more data after calling nsgif_data_complete.
Definition nsgif.hpp:92
@ NSGIF_ERR_OOM
Out of memory error.
Definition nsgif.hpp:67
@ NSGIF_ERR_BAD_FRAME
Frame number is not valid.
Definition nsgif.hpp:77
@ NSGIF_ERR_END_OF_DATA
Unexpected end of GIF source data.
Definition nsgif.hpp:87
@ NSGIF_ERR_ANIMATION_END
Indicates an animation is complete, and nsgif_reset must be called to restart the animation from the ...
Definition nsgif.hpp:103
@ NSGIF_ERR_DATA_FRAME
GIF source data contained an error in a frame.
Definition nsgif.hpp:82
@ NSGIF_ERR_DATA
GIF source data is invalid, and no frames are recoverable.
Definition nsgif.hpp:72
@ NSGIF_ERR_FRAME_DISPLAY
The current frame cannot be displayed.
Definition nsgif.hpp:97
@ NSGIF_OK
Success.
Definition nsgif.hpp:62
nsgif_error nsgif_frame_decode(nsgif_t *gif, fl::u32 frame, nsgif_bitmap_t **bitmap) FL_NOEXCEPT
Decodes a GIF frame.
Definition gif.cpp.hpp:1953
const char * nsgif_strerror(nsgif_error err) FL_NOEXCEPT
Convert an error code to a string.
Definition gif.cpp.hpp:2045
void nsgif_bitmap_t
Client bitmap type.
Definition nsgif.hpp:175
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31

References convertBitmapToFrame(), currentFrame_, currentFrameIndex_, dataComplete_, decode(), fl::EndOfStream, endOfStream_, fl::Error, FL_NOEXCEPT, gif_, hasError_, loadMoreData(), fl::third_party::NSGIF_ERR_ANIMATION_END, fl::third_party::NSGIF_ERR_BAD_FRAME, fl::third_party::NSGIF_ERR_DATA, fl::third_party::NSGIF_ERR_DATA_COMPLETE, fl::third_party::NSGIF_ERR_DATA_FRAME, fl::third_party::NSGIF_ERR_END_OF_DATA, fl::third_party::NSGIF_ERR_FRAME_DISPLAY, fl::third_party::NSGIF_ERR_OOM, fl::third_party::nsgif_frame_decode(), fl::third_party::NSGIF_OK, fl::third_party::nsgif_strerror(), ready_, setError(), and fl::Success.

Referenced by decode().

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