FastLED 3.9.15
Loading...
Searching...
No Matches
software_decoder.h
Go to the documentation of this file.
1#pragma once
2
3#include "fl/codec/idecoder.h"
4#include "fl/stl/noexcept.h"
5#include "fl/codec/common.h"
6#include "fl/stl/shared_ptr.h"
7#include "fl/stl/string.h"
8#include "fl/stl/stdint.h"
9#include "fl/stl/unique_ptr.h"
10#include "fl/stl/vector.h"
11#include "fl/fx/frame.h"
12
13// Include the actual nsgif header
14
16
17namespace fl {
18namespace third_party {
19
20 // Simple bitmap wrapper for libnsgif integration with FastLED Frame
21 struct GifBitmap {
23 fl::u16 width;
24 fl::u16 height;
26
27 GifBitmap(fl::u16 w, fl::u16 h, fl::u8 bpp) FL_NOEXCEPT
28 : pixels(fl::make_unique<fl::u8[]>(w * h * bpp))
29 , width(w)
30 , height(h)
31 , bytesPerPixel(bpp) {
32 }
33 };
34
43 private:
48 bool ready_;
51
52 // Data buffer - libnsgif requires all data to be contiguous
54
55 // Animation state
58
59 // Bitmap callbacks for libnsgif
61
62 // Internal helper methods
65 void setError(const fl::string& message) FL_NOEXCEPT;
68
69 // Static callbacks for libnsgif
71 static void bitmapDestroy(nsgif_bitmap_t* bitmap) FL_NOEXCEPT;
73
74 public:
77
78 // IDecoder interface implementation
79 bool begin(fl::filebuf_ptr stream) FL_NOEXCEPT override;
80 void end() FL_NOEXCEPT override;
81 bool isReady() const FL_NOEXCEPT override { return ready_; }
82 bool hasError(fl::string* msg = nullptr) const FL_NOEXCEPT override;
83
86 bool hasMoreFrames() const FL_NOEXCEPT override;
87
88 // Animation support methods
89 fl::u32 getFrameCount() const FL_NOEXCEPT override;
90 fl::u32 getCurrentFrameIndex() const FL_NOEXCEPT override { return currentFrameIndex_; }
91 bool seek(fl::u32 frameIndex) FL_NOEXCEPT override;
92
93 // Get GIF properties
94 fl::u16 getWidth() const FL_NOEXCEPT;
95 fl::u16 getHeight() const FL_NOEXCEPT;
96 bool isAnimated() const FL_NOEXCEPT;
97 fl::u32 getLoopCount() const FL_NOEXCEPT;
98 };
99
100} // namespace third_party
101} // namespace fl
fl::u32 getFrameCount() const FL_NOEXCEPT override
fl::Frame getCurrentFrame() FL_NOEXCEPT override
static fl::u8 * bitmapGetBuffer(nsgif_bitmap_t *bitmap) FL_NOEXCEPT
void setError(const fl::string &message) FL_NOEXCEPT
fl::DecodeResult decode() FL_NOEXCEPT override
bool hasMoreFrames() const FL_NOEXCEPT override
fl::u32 getCurrentFrameIndex() const FL_NOEXCEPT override
bool seek(fl::u32 frameIndex) FL_NOEXCEPT override
static nsgif_bitmap_t * bitmapCreate(int width, int height) FL_NOEXCEPT
fl::shared_ptr< fl::Frame > currentFrame_
static void bitmapDestroy(nsgif_bitmap_t *bitmap) FL_NOEXCEPT
bool hasError(fl::string *msg=nullptr) const FL_NOEXCEPT override
bool isReady() const FL_NOEXCEPT override
static nsgif_bitmap_cb_vt bitmapCallbacks_
fl::shared_ptr< fl::Frame > convertBitmapToFrame(nsgif_bitmap_t *bitmap) FL_NOEXCEPT
SoftwareGifDecoder(fl::PixelFormat format=fl::PixelFormat::RGB888) FL_NOEXCEPT
bool begin(fl::filebuf_ptr stream) FL_NOEXCEPT override
unsigned char u8
Definition coder.h:132
void nsgif_bitmap_t
Client bitmap type.
Definition nsgif.hpp:175
struct nsgif nsgif_t
Opaque type used by LibNSGIF to represent a GIF object in memory.
Definition nsgif.hpp:34
Bitmap callbacks function table.
Definition nsgif.hpp:178
unsigned char u8
Definition stdint.h:131
u8 u8 height
Definition blur.h:186
fl::enable_if<!fl::is_array< T >::value, unique_ptr< T > >::type make_unique(Args &&... args) FL_NOEXCEPT
Definition unique_ptr.h:261
u8 width
Definition blur.h:186
fl::shared_ptr< filebuf > filebuf_ptr
Definition idecoder.h:15
DecodeResult
Definition idecoder.h:18
fl::string format(const char *fmt)
Format with no arguments.
Definition format.h:439
PixelFormat
Definition pixel.h:7
Base definition for an LED controller.
Definition crgb.hpp:179
Interface to progressive animated GIF file decoding - FastLED namespace wrapped version.
#define FL_NOEXCEPT
GifBitmap(fl::u16 w, fl::u16 h, fl::u8 bpp) FL_NOEXCEPT
fl::unique_ptr< fl::u8[]> pixels