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

◆ nsgif__parse_header()

static nsgif_error fl::third_party::nsgif__parse_header ( struct nsgif * gif,
const fl::u8 ** pos,
bool strict )
static

Read GIF header.

6-byte GIF file header is:

+0 3CHARS Signature ('GIF') +3 3CHARS Version ('87a' or '89a')

Parameters
[in]gifThe GIF object we're decoding.
[in,out]posThe current buffer position, updated on success.
[in]strictWhether to require a known GIF version.
Returns
NSGIF_OK on success, appropriate error otherwise.

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

1548{
1549 const fl::u8 *data = *pos;
1550 fl::size len = gif->buf + gif->buf_len - data;
1551
1552 if (len < 6) {
1553 return NSGIF_ERR_END_OF_DATA;
1554 }
1555
1556 if (strncmp((const char *) data, "GIF", 3) != 0) {
1557 return NSGIF_ERR_DATA;
1558 }
1559 data += 3;
1560
1561 if (strict == true) {
1562 if ((strncmp((const char *) data, "87a", 3) != 0) &&
1563 (strncmp((const char *) data, "89a", 3) != 0)) {
1564 return NSGIF_ERR_DATA;
1565 }
1566 }
1567 data += 3;
1568
1569 *pos = data;
1570 return NSGIF_OK;
1571}
uint8_t pos
Definition Blur.ino:11
unsigned char u8
Definition coder.h:132
@ NSGIF_ERR_END_OF_DATA
Unexpected end of GIF source data.
Definition nsgif.hpp:87
@ NSGIF_ERR_DATA
GIF source data is invalid, and no frames are recoverable.
Definition nsgif.hpp:72
@ NSGIF_OK
Success.
Definition nsgif.hpp:62
fl::size buf_len
total number of bytes of GIF data available
Definition gif.cpp.hpp:113
const fl::u8 * buf
pointer to GIF data
Definition gif.cpp.hpp:109
int strncmp(const char *s1, const char *s2, size_t n) FL_NOEXCEPT

References FL_NOEXCEPT, NSGIF_ERR_DATA, NSGIF_ERR_END_OF_DATA, NSGIF_OK, pos, and fl::strncmp().

Referenced by nsgif_data_scan().

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