summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2021-12-01 16:47:49 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2021-12-01 16:47:49 +0000
commit5c673578e310de6e254c27da735195285073483d (patch)
treee5729c94e3490b8bd4f636c0e25d0b73de706681
parentde0f5828f63d0db82c4157701a763796420eaa80 (diff)
downloadlibnsgif-5c673578e310de6e254c27da735195285073483d.tar.gz
libnsgif-5c673578e310de6e254c27da735195285073483d.tar.bz2
GIF: Scope reduce gif extension identifier magic values.
-rw-r--r--src/gif.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/gif.c b/src/gif.c
index 9d77894..dce2bb1 100644
--- a/src/gif.c
+++ b/src/gif.c
@@ -55,13 +55,8 @@ enum nsgif_disposal {
#define NSGIF_INTERLACE_MASK 0x40
#define NSGIF_COLOUR_TABLE_MASK 0x80
#define NSGIF_COLOUR_TABLE_SIZE_MASK 0x07
-#define NSGIF_EXTENSION_INTRODUCER 0x21
-#define NSGIF_EXTENSION_GRAPHIC_CONTROL 0xf9
#define NSGIF_DISPOSAL_MASK 0x1c
#define NSGIF_TRANSPARENCY_MASK 0x01
-#define NSGIF_EXTENSION_COMMENT 0xfe
-#define NSGIF_EXTENSION_PLAIN_TEXT 0x01
-#define NSGIF_EXTENSION_APPLICATION 0xff
#define NSGIF_BLOCK_TERMINATOR 0x00
#define NSGIF_TRAILER 0x3b
@@ -660,12 +655,19 @@ static nsgif_result nsgif__parse_frame_extensions(
const uint8_t **pos,
bool decode)
{
+ enum {
+ GIF_EXT_INTRODUCER = 0x21,
+ GIF_EXT_GRAPHIC_CONTROL = 0xf9,
+ GIF_EXT_COMMENT = 0xfe,
+ GIF_EXT_PLAIN_TEXT = 0x01,
+ GIF_EXT_APPLICATION = 0xff,
+ };
const uint8_t *nsgif_data = *pos;
const uint8_t *nsgif_end = gif->nsgif_data + gif->buffer_size;
int nsgif_bytes = nsgif_end - nsgif_data;
/* Initialise the extensions */
- while (nsgif_bytes > 0 && nsgif_data[0] == NSGIF_EXTENSION_INTRODUCER) {
+ while (nsgif_bytes > 0 && nsgif_data[0] == GIF_EXT_INTRODUCER) {
bool block_step = true;
nsgif_result ret;
@@ -678,7 +680,7 @@ static nsgif_result nsgif__parse_frame_extensions(
/* Switch on extension label */
switch (nsgif_data[0]) {
- case NSGIF_EXTENSION_GRAPHIC_CONTROL:
+ case GIF_EXT_GRAPHIC_CONTROL:
if (decode) {
ret = nsgif__parse_extension_graphic_control(
frame, nsgif_data, nsgif_bytes);
@@ -688,7 +690,7 @@ static nsgif_result nsgif__parse_frame_extensions(
}
break;
- case NSGIF_EXTENSION_APPLICATION:
+ case GIF_EXT_APPLICATION:
if (decode) {
ret = nsgif__parse_extension_application(
gif, nsgif_data, nsgif_bytes);
@@ -698,7 +700,7 @@ static nsgif_result nsgif__parse_frame_extensions(
}
break;
- case NSGIF_EXTENSION_COMMENT:
+ case GIF_EXT_COMMENT:
/* Move the pointer to the first data sub-block Skip 1
* byte for the extension label. */
++nsgif_data;