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

◆ nsgif__parse_frame_extensions()

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

Parse the frame's extensions.

Parameters
[in]gifThe gif object we're decoding.
[in]frameThe frame to parse extensions for.
[in]posCurrent position in data, updated on exit.
[in]decodeWhether to decode or skip over the extension.
Returns
NSGIF_ERR_END_OF_DATA if more data is needed, NSGIF_OK for success.

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

901{
902 enum {
903 GIF_EXT_INTRODUCER = 0x21,
904 GIF_EXT_GRAPHIC_CONTROL = 0xf9,
905 GIF_EXT_COMMENT = 0xfe,
906 GIF_EXT_PLAIN_TEXT = 0x01,
907 GIF_EXT_APPLICATION = 0xff,
908 };
909 const fl::u8 *nsgif_data = *pos;
910 const fl::u8 *nsgif_end = gif->buf + gif->buf_len;
911 int nsgif_bytes = nsgif_end - nsgif_data;
912
913 /* Initialise the extensions */
914 while (nsgif_bytes > 0 && nsgif_data[0] == GIF_EXT_INTRODUCER) {
915 bool block_step = true;
916 nsgif_error ret;
917
918 nsgif_data++;
919 nsgif_bytes--;
920
921 if (nsgif_bytes == 0) {
923 }
924
925 /* Switch on extension label */
926 switch (nsgif_data[0]) {
927 case GIF_EXT_GRAPHIC_CONTROL:
928 if (decode) {
930 frame,
931 nsgif_data,
932 nsgif_bytes);
933 if (ret != NSGIF_OK) {
934 return ret;
935 }
936 }
937 break;
938
939 case GIF_EXT_APPLICATION:
940 if (decode) {
942 gif, nsgif_data, nsgif_bytes);
943 if (ret != NSGIF_OK) {
944 return ret;
945 }
946 }
947 break;
948
949 case GIF_EXT_COMMENT:
950 /* Move the pointer to the first data sub-block Skip 1
951 * byte for the extension label. */
952 ++nsgif_data;
953 block_step = false;
954 break;
955
956 default:
957 break;
958 }
959
960 if (block_step) {
961 /* Move the pointer to the first data sub-block Skip 2
962 * bytes for the extension label and size fields Skip
963 * the extension size itself
964 */
965 if (nsgif_bytes < 2) {
967 }
968 nsgif_data += 2 + nsgif_data[1];
969 }
970
971 /* Repeatedly skip blocks until we get a zero block or run out
972 * of data. This data is ignored by this gif decoder. */
973 while (nsgif_data < nsgif_end && nsgif_data[0] != NSGIF_BLOCK_TERMINATOR) {
974 nsgif_data += nsgif_data[0] + 1;
975 if (nsgif_data >= nsgif_end) {
977 }
978 }
979 nsgif_data++;
980 nsgif_bytes = nsgif_end - nsgif_data;
981 }
982
983 if (nsgif_data > nsgif_end) {
984 nsgif_data = nsgif_end;
985 }
986
987 /* Set buffer position and return */
988 *pos = nsgif_data;
989 return NSGIF_OK;
990}
uint8_t pos
Definition Blur.ino:11
unsigned char u8
Definition s16x16x4.h:132
nsgif_error
LibNSGIF return codes.
Definition nsgif.hpp:58
@ 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_extension_graphic_control(struct nsgif_frame *frame, const fl::u8 *data, fl::size len) FL_NOEXCEPT
Parse the graphic control extension.
Definition gif.cpp.hpp:756
static nsgif_error nsgif__parse_extension_application(struct nsgif *gif, const fl::u8 *data, fl::size len) FL_NOEXCEPT
Parse the application extension.
Definition gif.cpp.hpp:846
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
#define NSGIF_BLOCK_TERMINATOR
Definition gif.cpp.hpp:173

References FL_NOEXCEPT, nsgif__parse_extension_application(), nsgif__parse_extension_graphic_control(), NSGIF_BLOCK_TERMINATOR, NSGIF_ERR_END_OF_DATA, 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: