Scan the source image data.
This is used to feed the source data into LibNSGIF. This must be called before calling nsgif_frame_decode.
It can be called multiple times with, with increasing sizes. If it is called several times, as more data is available (e.g. slow network fetch) the data already given to nsgif_data_scan must be provided each time.
If an error occurs, all previously scanned frames are retained.
Note that an error returned from this function is purely informational. So long as at least one frame is available, you can display frames.
1620{
1621 const fl::u8 *nsgif_data;
1623 fl::u32 frames;
1624
1627 }
1628
1629
1632
1633
1635
1636
1638
1639
1640
1644
1645
1650
1653 return ret;
1654 }
1655
1658 return ret;
1659 }
1660
1661
1663
1664
1665
1666
1667
1668
1679 }
1680
1681
1682
1683
1685
1686
1687
1688
1689
1693 }
1694 }
1695 }
1696
1697
1698
1699
1700
1702
1704 fl::size remaining = gif->
buf + gif->
buf_len - nsgif_data;
1705 fl::size used;
1706
1711 nsgif_data, remaining, &used, true);
1713 return ret;
1714 }
1715
1716 nsgif_data += used;
1718 } else {
1719
1720
1722
1723
1728
1729 entry += sizeof(fl::u32);
1730
1731
1736
1738 }
1739
1744 } else {
1746 }
1747 }
1748
1749 if (gif->
lzw_ctx ==
nullptr) {
1750 struct lzw_ctx *lzw_ctx_ptr =
nullptr;
1755 }
1756 }
1757
1758
1759 do {
1763
1766 }
1767
1768 return ret;
1769}
lzw_result lzw_context_create(struct lzw_ctx **ctx) FL_NOEXCEPT
Create an LZW decompression context.
static nsgif_error nsgif__parse_logical_screen_descriptor(struct nsgif *gif, const fl::u8 **pos) FL_NOEXCEPT
Read Logical Screen Descriptor.
nsgif_error
LibNSGIF return codes.
@ NSGIF_ERR_DATA_COMPLETE
Can't supply more data after calling nsgif_data_complete.
@ NSGIF_ERR_END_OF_DATA
Unexpected end of GIF source data.
static nsgif_error nsgif__parse_header(struct nsgif *gif, const fl::u8 **pos, bool strict) FL_NOEXCEPT
Read GIF header.
lzw_result
LZW decoding response codes.
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.
static nsgif_error nsgif__error_from_lzw(lzw_result l_res) FL_NOEXCEPT
Convert an LZW result code to equivalent GIF result code.
static nsgif_error nsgif__process_frame(struct nsgif *gif, fl::u32 frame_idx, bool decode) FL_NOEXCEPT
Attempts to initialise the next frame.
fl::u32 colour_table_size
size of global colour table (in entries)
nsgif_bitmap_t * frame_image
currently decoded image; stored as bitmap from bitmap_create callback
fl::u32 global_colour_table[NSGIF_MAX_COLOURS]
global colour table
fl::u8 b
Byte offset within pixel to blue component.
nsgif_frame * frames
decoded frames
fl::u8 g
Byte offset within pixel to green component.
fl::u32 decoded_frame
current frame decoded to bitmap
fl::size buf_pos
current index into GIF data
fl::u32 background
background colour in same pixel format as nsgif_bitmap_t.
fl::u32 frame_count
number of frames decoded
fl::u8 r
Byte offset within pixel to red component.
fl::u32 width
width of GIF (may increase during decoding)
fl::u32 height
height of GIF (may increase during decoding)
fl::size buf_len
total number of bytes of GIF data available
struct nsgif_colour_layout colour_layout
Client's colour component order.
void * lzw_ctx
LZW decode context.
bool global_palette
whether the GIF has a global colour table
fl::u32 frame
current frame
fl::u32 bg_index
background index
fl::u32 frame_count_partial
number of frames partially decoded
fl::u8 a
Byte offset within pixel to alpha component.
bool data_complete
Whether all the GIF data has been supplied, or if there may be more to come.
const fl::u8 * buf
pointer to GIF data
fl::u32 frame_holders
current number of frame holders
LZW decompression context.
#define NSGIF_FRAME_INVALID
Internal flag that a frame is invalid/unprocessed.
#define NSGIF_PROCESS_COLOURS
Internal flag that the colour table needs to be processed.