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

◆ nsgif__decode_simple()

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 )
static

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

554{
555 fl::u32 pixels;
556 fl::u32 written = 0;
557 nsgif_error ret = NSGIF_OK;
558 lzw_result res;
559
560 if (offset_y >= gif->info.height) {
561 return NSGIF_OK;
562 }
563
564 height -= gif__clip(offset_y, height, gif->info.height);
565
566 if (height == 0) {
567 return NSGIF_OK;
568 }
569
570 /* Initialise the LZW decoding */
571 res = lzw_decode_init_map(static_cast<struct lzw_ctx*>(gif->lzw_ctx), data[0],
572 transparency_index, colour_table,
573 gif->buf, gif->buf_len,
574 data + 1 - gif->buf);
575 if (res != LZW_OK) {
576 return nsgif__error_from_lzw(res);
577 }
578
579 frame_data += (offset_y * gif->info.width);
580 pixels = gif->info.width * height;
581
582 while (pixels > 0) {
583 res = lzw_decode_map(static_cast<struct lzw_ctx*>(gif->lzw_ctx),
584 frame_data, pixels, &written);
585 pixels -= written;
586 frame_data += written;
587 if (res != LZW_OK) {
588 /* Unexpected end of frame, try to recover */
589 if (res == LZW_OK_EOD || res == LZW_EOI_CODE) {
590 ret = NSGIF_OK;
591 } else {
592 ret = nsgif__error_from_lzw(res);
593 }
594 break;
595 }
596 }
597
598 if (pixels == 0) {
599 ret = NSGIF_OK;
600 }
601
602 return ret;
603}
nsgif_error
LibNSGIF return codes.
Definition nsgif.hpp:58
@ NSGIF_OK
Success.
Definition nsgif.hpp:62
static fl::u32 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.
Definition gif.cpp.hpp:413
lzw_result
LZW decoding response codes.
Definition lzw.h:33
@ LZW_EOI_CODE
Error: End of Information code.
Definition lzw.h:38
@ LZW_OK
Success.
Definition lzw.h:34
@ LZW_OK_EOD
Success; reached zero-length sub-block.
Definition lzw.h:35
static nsgif_error nsgif__error_from_lzw(lzw_result l_res) FL_NOEXCEPT
Convert an LZW result code to equivalent GIF result code.
Definition gif.cpp.hpp:182
lzw_result lzw_decode_init_map(struct lzw_ctx *ctx, fl::u8 minimum_code_size, fl::u32 transparency_idx, const fl::u32 *colour_table, const fl::u8 *input_data, fl::size input_length, fl::size input_pos) FL_NOEXCEPT
Initialise an LZW decompression context for decoding to colour map values.
Definition lzw.cpp.hpp:323
lzw_result lzw_decode_map(struct lzw_ctx *ctx, fl::u32 *output_data, fl::u32 output_length, fl::u32 *output_written) FL_NOEXCEPT
Read LZW codes into client buffer, mapping output to colours.
Definition lzw.cpp.hpp:591
fl::u32 width
width of GIF (may increase during decoding)
Definition nsgif.hpp:384
fl::u32 height
height of GIF (may increase during decoding)
Definition nsgif.hpp:386
fl::size buf_len
total number of bytes of GIF data available
Definition gif.cpp.hpp:113
void * lzw_ctx
LZW decode context.
Definition gif.cpp.hpp:75
struct nsgif_info info
Definition gif.cpp.hpp:72
const fl::u8 * buf
pointer to GIF data
Definition gif.cpp.hpp:109
LZW decompression context.
Definition lzw.cpp.hpp:72
u8 u8 height
Definition blur.h:186

References FL_NOEXCEPT, gif__clip(), fl::height, lzw_decode_init_map(), lzw_decode_map(), LZW_EOI_CODE, LZW_OK, LZW_OK_EOD, nsgif__error_from_lzw(), and NSGIF_OK.

Referenced by nsgif__decode().

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