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

◆ nsgif__parse_colour_table()

static nsgif_error fl::third_party::nsgif__parse_colour_table ( struct nsgif * gif,
struct nsgif_frame * frame,
const fl::u8 ** pos,
bool decode )
static

Get a frame's colour table.

Sets up gif->colour_table for the frame.

Parameters
[in]gifThe gif object we're decoding.
[in]frameThe frame to get the colour table for.
[in]posCurrent position in data, updated on exit.
[in]decodeWhether to decode the colour table.
Returns
NSGIF_OK on success, appropriate error otherwise.

Definition at line 1148 of file gif.cpp.hpp.

1153{
1154 nsgif_error ret;
1155 const fl::u8 *data = *pos;
1156 fl::size len = gif->buf + gif->buf_len - data;
1157 fl::size used_bytes;
1158
1159 FL_ASSERT(gif != nullptr, "GIF object required");
1160 FL_ASSERT(frame != nullptr, "Frame object required");
1161
1162 if ((frame->flags & NSGIF_COLOUR_TABLE_MASK) == 0) {
1164 return NSGIF_OK;
1165 }
1166
1167 if (decode == false) {
1168 frame->colour_table_offset = *pos - gif->buf;
1169 }
1170
1173 2 << (frame->flags & NSGIF_COLOUR_TABLE_SIZE_MASK),
1174 data, len, &used_bytes, decode);
1175 if (ret != NSGIF_OK) {
1176 return ret;
1177 }
1178 *pos += used_bytes;
1179
1180 if (decode) {
1181 gif->colour_table = gif->local_colour_table;
1182 } else {
1183 frame->info.local_palette = true;
1184 }
1185
1186 return NSGIF_OK;
1187}
uint8_t pos
Definition Blur.ino:11
#define FL_ASSERT(x, MSG)
Definition assert.h:6
unsigned char u8
Definition coder.h:132
nsgif_error
LibNSGIF return codes.
Definition nsgif.hpp:58
@ NSGIF_OK
Success.
Definition nsgif.hpp:62
static nsgif_error 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.
Definition gif.cpp.hpp:1115
bool local_palette
whether the frame has a local colour table
Definition nsgif.hpp:428
fl::u32 global_colour_table[NSGIF_MAX_COLOURS]
global colour table
Definition gif.cpp.hpp:129
fl::u32 * colour_table
current colour table
Definition gif.cpp.hpp:125
fl::u32 colour_table_offset
offset to frame colour table
Definition gif.cpp.hpp:56
fl::size buf_len
total number of bytes of GIF data available
Definition gif.cpp.hpp:113
struct nsgif_colour_layout colour_layout
Client's colour component order.
Definition gif.cpp.hpp:127
struct nsgif_frame_info info
Definition gif.cpp.hpp:38
const fl::u8 * buf
pointer to GIF data
Definition gif.cpp.hpp:109
fl::u32 local_colour_table[NSGIF_MAX_COLOURS]
local colour table
Definition gif.cpp.hpp:131
#define NSGIF_COLOUR_TABLE_SIZE_MASK
Definition gif.cpp.hpp:172
#define NSGIF_COLOUR_TABLE_MASK
Definition gif.cpp.hpp:171

References FL_ASSERT, FL_NOEXCEPT, nsgif__colour_table_extract(), NSGIF_COLOUR_TABLE_MASK, NSGIF_COLOUR_TABLE_SIZE_MASK, NSGIF_OK, and pos.

Referenced by nsgif__process_frame().

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