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

◆ nsgif__process_frame()

static nsgif_error fl::third_party::nsgif__process_frame ( struct nsgif * gif,
fl::u32 frame_idx,
bool decode )
static

Attempts to initialise the next frame.

Parameters
[in]gifThe animation context
[in]frame_idxThe frame number to decode.
[in]decodeWhether to decode the graphical image data.
Returns
NSGIF_OK on success, appropriate error otherwise.

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

1327{
1328 nsgif_error ret;
1329 const fl::u8 *pos;
1330 const fl::u8 *end;
1331 struct nsgif_frame *frame;
1332
1333 frame = nsgif__get_frame(gif, frame_idx);
1334 if (frame == nullptr) {
1335 return NSGIF_ERR_OOM;
1336 }
1337
1338 end = gif->buf + gif->buf_len;
1339
1340 if (decode) {
1341 pos = gif->buf + frame->frame_offset;
1342
1343 /* Ensure this frame is supposed to be decoded */
1344 if (frame->info.display == false) {
1345 return NSGIF_OK;
1346 }
1347
1348 /* Ensure the frame is in range to decode */
1349 if (frame_idx > gif->frame_count_partial) {
1350 return NSGIF_ERR_END_OF_DATA;
1351 }
1352
1353 /* Done if frame is already decoded */
1354 if (frame_idx == gif->decoded_frame) {
1355 return NSGIF_OK;
1356 }
1357 } else {
1358 pos = gif->buf + gif->buf_pos;
1359
1360 /* Check if we've finished */
1361 if (pos < end && pos[0] == NSGIF_TRAILER) {
1362 return NSGIF_OK;
1363 }
1364 }
1365
1366 ret = nsgif__parse_frame_extensions(gif, frame, &pos, !decode);
1367 if (ret != NSGIF_OK) {
1368 goto cleanup;
1369 }
1370
1371 ret = nsgif__parse_image_descriptor(gif, frame, &pos, !decode);
1372 if (ret != NSGIF_OK) {
1373 goto cleanup;
1374 }
1375
1376 ret = nsgif__parse_colour_table(gif, frame, &pos, decode);
1377 if (ret != NSGIF_OK) {
1378 goto cleanup;
1379 }
1380
1381 ret = nsgif__parse_image_data(gif, frame, &pos, decode);
1382 if (ret != NSGIF_OK) {
1383 goto cleanup;
1384 }
1385
1386cleanup:
1387 if (!decode) {
1388 gif->buf_pos = pos - gif->buf;
1389 }
1390
1391 return ret;
1392}
uint8_t pos
Definition Blur.ino:11
unsigned char u8
Definition coder.h:132
static nsgif_error nsgif__parse_image_descriptor(struct nsgif *gif, struct nsgif_frame *frame, const fl::u8 **pos, bool decode) FL_NOEXCEPT
Parse a GIF Image Descriptor.
Definition gif.cpp.hpp:1015
nsgif_error
LibNSGIF return codes.
Definition nsgif.hpp:58
@ NSGIF_ERR_OOM
Out of memory error.
Definition nsgif.hpp:67
@ NSGIF_ERR_END_OF_DATA
Unexpected end of GIF source data.
Definition nsgif.hpp:87
@ NSGIF_OK
Success.
Definition nsgif.hpp:62
static nsgif_error nsgif__parse_frame_extensions(struct nsgif *gif, struct nsgif_frame *frame, const fl::u8 **pos, bool decode) FL_NOEXCEPT
Parse the frame's extensions.
Definition gif.cpp.hpp:896
static nsgif_error 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.
Definition gif.cpp.hpp:1200
static struct nsgif_frame * nsgif__get_frame(struct nsgif *gif, fl::u32 frame_idx) FL_NOEXCEPT
Definition gif.cpp.hpp:1273
static nsgif_error 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.
Definition gif.cpp.hpp:1148
fl::size frame_offset
offset (in bytes) to the GIF frame data
Definition gif.cpp.hpp:41
fl::u32 decoded_frame
current frame decoded to bitmap
Definition gif.cpp.hpp:83
bool display
whether the frame should be displayed/animated
Definition nsgif.hpp:424
fl::size buf_pos
current index into GIF data
Definition gif.cpp.hpp:111
fl::size buf_len
total number of bytes of GIF data available
Definition gif.cpp.hpp:113
fl::u32 frame_count_partial
number of frames partially decoded
Definition gif.cpp.hpp:100
struct nsgif_frame_info info
Definition gif.cpp.hpp:38
const fl::u8 * buf
pointer to GIF data
Definition gif.cpp.hpp:109
constexpr T * end(T(&array)[N]) FL_NOEXCEPT
#define NSGIF_TRAILER
Definition gif.cpp.hpp:174

References fl::third_party::nsgif_frame_info::display, fl::end(), FL_NOEXCEPT, fl::third_party::nsgif_frame::frame_offset, fl::third_party::nsgif_frame::info, nsgif__get_frame(), nsgif__parse_colour_table(), nsgif__parse_frame_extensions(), nsgif__parse_image_data(), nsgif__parse_image_descriptor(), NSGIF_ERR_END_OF_DATA, NSGIF_ERR_OOM, NSGIF_OK, NSGIF_TRAILER, and pos.

Referenced by nsgif_data_scan(), and nsgif_frame_decode().

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