FastLED 3.9.15
Loading...
Searching...
No Matches
gif.cpp.hpp File Reference

Detailed Description

GIF image decoder.

The GIF format is thoroughly documented; a full description can be found at http://www.w3.org/Graphics/GIF/spec-gif89a.txt

Todo
Plain text and comment extensions should be implemented.

Definition in file gif.cpp.hpp.

#include "fl/stl/cstddef.h"
#include "fl/stl/assert.h"
#include "fl/stl/int.h"
#include "fl/stl/limits.h"
#include "fl/stl/allocator.h"
#include "fl/stl/cstring.h"
#include "fl/stl/string.h"
#include "fl/stl/noexcept.h"
#include "lzw.h"
#include "third_party/libnsgif/include/nsgif.hpp"
+ Include dependency graph for gif.cpp.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  fl::third_party::nsgif
 GIF animation data. More...
 
struct  fl::third_party::nsgif_colour_layout
 Pixel format: colour component order. More...
 
struct  fl::third_party::nsgif_frame
 GIF frame data. More...
 

Namespaces

namespace  fl
 Base definition for an LED controller.
 
namespace  fl::third_party
 

Macros

#define NSGIF_ARRAY_LEN(_a)
 Helper macro to get number of elements in an array.
 
#define NSGIF_BLOCK_TERMINATOR   0x00
 
#define NSGIF_COLOUR_TABLE_MASK   0x80
 
#define NSGIF_COLOUR_TABLE_SIZE_MASK   0x07
 
#define NSGIF_FRAME_DELAY_DEFAULT   10
 Default frame delay to apply.
 
#define NSGIF_FRAME_DELAY_MIN   2
 Default minimum allowable frame delay in cs.
 
#define NSGIF_FRAME_INVALID   (fl::numeric_limits<fl::u32>::max)()
 Internal flag that a frame is invalid/unprocessed.
 
#define NSGIF_NO_TRANSPARENCY   (0xFFFFFFFFu)
 No transparency.
 
#define NSGIF_PROCESS_COLOURS   0xaa000000
 Internal flag that the colour table needs to be processed.
 
#define NSGIF_TRAILER   0x3b
 
#define NSGIF_TRANSPARENT_COLOUR   0x00
 Transparent colour.
 

Typedefs

typedef struct fl::third_party::nsgif_frame fl::third_party::nsgif_frame
 GIF frame data.
 

Functions

static fl::u32 fl::third_party::gif__clip (fl::u32 frame_off, fl::u32 frame_dim, fl::u32 image_ext) FL_NOEXCEPT
 Get any frame clip adjustment for the image extent.
 
static void fl::third_party::gif__jump_data (fl::u32 *skip, fl::u32 *available, const fl::u8 **pos) FL_NOEXCEPT
 Perform any jump over decoded data, to accommodate clipped portion of frame.
 
static bool fl::third_party::nsgif__animation_complete (int count, int max) FL_NOEXCEPT
 
static bool fl::third_party::nsgif__app_ext_is_loop_count (const fl::u8 *data, fl::size len) FL_NOEXCEPT
 Check an app ext identifier and authentication code for loop count extension.
 
static struct nsgif_colour_layout fl::third_party::nsgif__bitmap_fmt_to_colour_layout (nsgif_bitmap_fmt_t bitmap_fmt) FL_NOEXCEPT
 
static fl::u32 * fl::third_party::nsgif__bitmap_get (struct nsgif *gif) FL_NOEXCEPT
 Helper to get the rendering bitmap for a gif.
 
static bool fl::third_party::nsgif__bitmap_get_opaque (const struct nsgif *gif) FL_NOEXCEPT
 Helper to get the client to determine if the bitmap is opaque.
 
static void fl::third_party::nsgif__bitmap_modified (const struct nsgif *gif) FL_NOEXCEPT
 Helper to tell the client that their bitmap was modified.
 
static void fl::third_party::nsgif__bitmap_set_opaque (const struct nsgif *gif, const struct nsgif_frame *frame) FL_NOEXCEPT
 Helper to tell the client that whether the bitmap is opaque.
 
static void fl::third_party::nsgif__colour_table_decode (fl::u32 colour_table[NSGIF_MAX_COLOURS], const struct nsgif_colour_layout *layout, fl::size colour_table_entries, const fl::u8 *data) FL_NOEXCEPT
 Extract a GIF colour table into a LibNSGIF colour table buffer.
 
static nsgif_error fl::third_party::nsgif__colour_table_extract (fl::u32 colour_table[NSGIF_MAX_COLOURS], const struct nsgif_colour_layout *layout, fl::size colour_table_entries, const fl::u8 *data, fl::size data_len, fl::size *used, bool decode) FL_NOEXCEPT
 Extract a GIF colour table into a LibNSGIF colour table buffer.
 
static nsgif_error fl::third_party::nsgif__decode (struct nsgif *gif, struct nsgif_frame *frame, const fl::u8 *data, fl::u32 *frame_data) FL_NOEXCEPT
 
static nsgif_error fl::third_party::nsgif__decode_complex (struct nsgif *gif, fl::u32 width, fl::u32 height, fl::u32 offset_x, fl::u32 offset_y, fl::u32 interlace, const fl::u8 *data, fl::u32 transparency_index, fl::u32 *frame_data, fl::u32 *colour_table) FL_NOEXCEPT
 
static nsgif_error fl::third_party::nsgif__decode_simple (struct nsgif *gif, fl::u32 height, fl::u32 offset_y, const fl::u8 *data, fl::u32 transparency_index, fl::u32 *frame_data, fl::u32 *colour_table) FL_NOEXCEPT
 
static bool fl::third_party::nsgif__deinterlace (fl::u32 height, fl::u32 *y, fl::u8 *step) FL_NOEXCEPT
 Get the next line for GIF decode.
 
static nsgif_error fl::third_party::nsgif__error_from_lzw (lzw_result l_res) FL_NOEXCEPT
 Convert an LZW result code to equivalent GIF result code.
 
static fl::u32 fl::third_party::nsgif__frame_next (const nsgif_t *gif, bool partial, fl::u32 frame) FL_NOEXCEPT
 
static struct nsgif_framefl::third_party::nsgif__get_frame (struct nsgif *gif, fl::u32 frame_idx) FL_NOEXCEPT
 
static bool fl::third_party::nsgif__host_is_little_endian (void) FL_NOEXCEPT
 Check whether the host is little endian.
 
static nsgif_error fl::third_party::nsgif__initialise_sprite (struct nsgif *gif, fl::u32 width, fl::u32 height) FL_NOEXCEPT
 Updates the sprite memory size.
 
static nsgif_error fl::third_party::nsgif__next_displayable_frame (const nsgif_t *gif, fl::u32 *frame, fl::u32 *delay) FL_NOEXCEPT
 
static bool fl::third_party::nsgif__next_row (fl::u32 interlace, fl::u32 height, fl::u32 *y, fl::u8 *step) FL_NOEXCEPT
 Get the next line for GIF decode.
 
static nsgif_error fl::third_party::nsgif__parse_colour_table (struct nsgif *gif, struct nsgif_frame *frame, const fl::u8 **pos, bool decode) FL_NOEXCEPT
 Get a frame's colour table.
 
static nsgif_error fl::third_party::nsgif__parse_extension_application (struct nsgif *gif, const fl::u8 *data, fl::size len) FL_NOEXCEPT
 Parse the application extension.
 
static nsgif_error fl::third_party::nsgif__parse_extension_graphic_control (struct nsgif_frame *frame, const fl::u8 *data, fl::size len) FL_NOEXCEPT
 Parse the graphic control extension.
 
static nsgif_error fl::third_party::nsgif__parse_frame_extensions (struct nsgif *gif, struct nsgif_frame *frame, const fl::u8 **pos, bool decode) FL_NOEXCEPT
 Parse the frame's extensions.
 
static nsgif_error fl::third_party::nsgif__parse_header (struct nsgif *gif, const fl::u8 **pos, bool strict) FL_NOEXCEPT
 Read GIF header.
 
static nsgif_error fl::third_party::nsgif__parse_image_data (struct nsgif *gif, struct nsgif_frame *frame, const fl::u8 **pos, bool decode) FL_NOEXCEPT
 Parse the image data for a gif frame.
 
static nsgif_error fl::third_party::nsgif__parse_image_descriptor (struct nsgif *gif, struct nsgif_frame *frame, const fl::u8 **pos, bool decode) FL_NOEXCEPT
 Parse a GIF Image Descriptor.
 
static nsgif_error fl::third_party::nsgif__parse_logical_screen_descriptor (struct nsgif *gif, const fl::u8 **pos) FL_NOEXCEPT
 Read Logical Screen Descriptor.
 
static nsgif_error fl::third_party::nsgif__process_frame (struct nsgif *gif, fl::u32 frame_idx, bool decode) FL_NOEXCEPT
 Attempts to initialise the next frame.
 
static void fl::third_party::nsgif__record_frame (struct nsgif *gif, const fl::u32 *bitmap) FL_NOEXCEPT
 
static nsgif_error fl::third_party::nsgif__recover_frame (const struct nsgif *gif, fl::u32 *bitmap) FL_NOEXCEPT
 
static void fl::third_party::nsgif__redraw_rect_extend (const nsgif_rect_t *frame, nsgif_rect_t *redraw) FL_NOEXCEPT
 
static void fl::third_party::nsgif__restore_bg (struct nsgif *gif, struct nsgif_frame *frame, fl::u32 *bitmap) FL_NOEXCEPT
 Restore a GIF to the background colour.
 
static nsgif_error fl::third_party::nsgif__update_bitmap (struct nsgif *gif, struct nsgif_frame *frame, const fl::u8 *data, fl::u32 frame_idx) FL_NOEXCEPT
 
nsgif_error fl::third_party::nsgif_create (const nsgif_bitmap_cb_vt *bitmap_vt, nsgif_bitmap_fmt_t bitmap_fmt, nsgif_t **gif_out) FL_NOEXCEPT
 Create the NSGIF object.
 
void fl::third_party::nsgif_data_complete (nsgif_t *gif) FL_NOEXCEPT
 Tell libnsgif that all the gif data has been provided.
 
nsgif_error fl::third_party::nsgif_data_scan (nsgif_t *gif, fl::size size, const fl::u8 *data) FL_NOEXCEPT
 Scan the source image data.
 
void fl::third_party::nsgif_destroy (nsgif_t *gif) FL_NOEXCEPT
 Free a NSGIF object.
 
nsgif_error fl::third_party::nsgif_frame_decode (nsgif_t *gif, fl::u32 frame, nsgif_bitmap_t **bitmap) FL_NOEXCEPT
 Decodes a GIF frame.
 
nsgif_error fl::third_party::nsgif_frame_prepare (nsgif_t *gif, nsgif_rect_t *area, fl::u32 *delay_cs, fl::u32 *frame_new) FL_NOEXCEPT
 Prepare to show a frame.
 
const nsgif_frame_info_tfl::third_party::nsgif_get_frame_info (const nsgif_t *gif, fl::u32 frame) FL_NOEXCEPT
 Get information about a GIF from an nsgif_t object.
 
const nsgif_info_tfl::third_party::nsgif_get_info (const nsgif_t *gif) FL_NOEXCEPT
 Get information about a GIF from an nsgif_t object.
 
void fl::third_party::nsgif_global_palette (const nsgif_t *gif, fl::u32 table[NSGIF_MAX_COLOURS], fl::size *entries) FL_NOEXCEPT
 Get the global colour palette.
 
bool fl::third_party::nsgif_local_palette (const nsgif_t *gif, fl::u32 frame, fl::u32 table[NSGIF_MAX_COLOURS], fl::size *entries) FL_NOEXCEPT
 Get the local colour palette for a frame.
 
nsgif_error fl::third_party::nsgif_reset (nsgif_t *gif) FL_NOEXCEPT
 Reset a GIF animation.
 
void fl::third_party::nsgif_set_frame_delay_behaviour (nsgif_t *gif, fl::u16 delay_min, fl::u16 delay_default) FL_NOEXCEPT
 Configure handling of small frame delays.
 
const char * fl::third_party::nsgif_str_disposal (enum nsgif_disposal disposal) FL_NOEXCEPT
 Convert a disposal method to a string.
 
const char * fl::third_party::nsgif_strerror (nsgif_error err) FL_NOEXCEPT
 Convert an error code to a string.
 

Class Documentation

◆ fl::third_party::nsgif

struct fl::third_party::nsgif
+ Collaboration diagram for fl::third_party::nsgif:
Class Members
u32 aspect_ratio image aspect ratio (ignored)
u32 bg_index background index
nsgif_bitmap_cb_vt bitmap callbacks for bitmap functions
const u8 * buf pointer to GIF data
size buf_len total number of bytes of GIF data available
size buf_pos current index into GIF data
struct nsgif_colour_layout colour_layout Client's colour component order.
u32 * colour_table current colour table
u32 colour_table_size size of global colour table (in entries)
bool data_complete Whether all the GIF data has been supplied, or if there may be more to come.
u32 decoded_frame current frame decoded to bitmap
u16 delay_default Frame delay to apply when delay is less than delay_min.
u16 delay_min Minimum allowable frame delay.
u32 frame current frame
u32 frame_count_partial number of frames partially decoded
u32 frame_holders current number of frame holders
nsgif_bitmap_t * frame_image currently decoded image; stored as bitmap from bitmap_create callback
nsgif_frame * frames decoded frames
u32 global_colour_table[NSGIF_MAX_COLOURS] global colour table
struct nsgif_info info
u32 local_colour_table[NSGIF_MAX_COLOURS] local colour table
int loop_count number of animation loops so far
void * lzw_ctx LZW decode context.
void * prev_frame previous frame for NSGIF_FRAME_RESTORE
u32 prev_index previous frame index
u32 rowspan Row span of frame_image in pixels.

◆ fl::third_party::nsgif_colour_layout

struct fl::third_party::nsgif_colour_layout
Class Members
u8 a Byte offset within pixel to alpha component.
u8 b Byte offset within pixel to blue component.
u8 g Byte offset within pixel to green component.
u8 r Byte offset within pixel to red component.

◆ fl::third_party::nsgif_frame

struct fl::third_party::nsgif_frame
+ Collaboration diagram for fl::third_party::nsgif_frame:
Class Members
u32 colour_table_offset offset to frame colour table
bool decoded whether the frame has previously been decoded.
u32 flags
size frame_offset offset (in bytes) to the GIF frame data
struct nsgif_frame_info info
u32 lzw_data_length Amount of LZW data found in scan.
bool opaque whether the frame is totally opaque
bool redraw_required whether a full image redraw is required
u32 transparency_index the index designating a transparent pixel