summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2021-12-01 16:57:16 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2022-02-23 11:32:42 +0000
commit958ea3a13e8d5ffd23f2540d7a0eb2926667a206 (patch)
treed576a88fa07e48579095f4cf61bbb0b439309f98
parent1e3f649e2b78bf936ac3ca83c0992b0cb9add327 (diff)
downloadlibnsgif-958ea3a13e8d5ffd23f2540d7a0eb2926667a206.tar.gz
GIF: Scope reduce graphic control extension masks.
-rw-r--r--src/gif.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/gif.c b/src/gif.c
index 28a5b2d..74fe4f4 100644
--- a/src/gif.c
+++ b/src/gif.c
@@ -55,8 +55,6 @@ enum nsgif_disposal {
#define NSGIF_INTERLACE_MASK 0x40
#define NSGIF_COLOUR_TABLE_MASK 0x80
#define NSGIF_COLOUR_TABLE_SIZE_MASK 0x07
-#define NSGIF_DISPOSAL_MASK 0x1c
-#define NSGIF_TRANSPARENCY_MASK 0x01
#define NSGIF_BLOCK_TERMINATOR 0x00
#define NSGIF_TRAILER 0x3b
@@ -636,6 +634,11 @@ static nsgif_result nsgif__parse_extension_graphic_control(
const uint8_t *data,
size_t len)
{
+ enum {
+ GIF_MASK_TRANSPARENCY = 0x01,
+ GIF_MASK_DISPOSAL = 0x1c,
+ };
+
/* 6-byte Graphic Control Extension is:
*
* +0 CHAR Graphic Control Label
@@ -653,12 +656,12 @@ static nsgif_result nsgif__parse_extension_graphic_control(
}
frame->frame_delay = data[3] | (data[4] << 8);
- if (data[2] & NSGIF_TRANSPARENCY_MASK) {
+ if (data[2] & GIF_MASK_TRANSPARENCY) {
frame->transparency = true;
frame->transparency_index = data[5];
}
- frame->disposal_method = ((data[2] & NSGIF_DISPOSAL_MASK) >> 2);
+ frame->disposal_method = ((data[2] & GIF_MASK_DISPOSAL) >> 2);
/* I have encountered documentation and GIFs in the
* wild that use 0x04 to restore the previous frame,
* rather than the officially documented 0x03. I