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>2021-12-01 16:57:16 +0000
commit3efe269c0ea83df2b8fc5885d36e0074ff904527 (patch)
tree7466e692aa9486914056a440b6e63095638a79a6
parent5c673578e310de6e254c27da735195285073483d (diff)
downloadlibnsgif-3efe269c0ea83df2b8fc5885d36e0074ff904527.tar.gz
libnsgif-3efe269c0ea83df2b8fc5885d36e0074ff904527.tar.bz2
GIF: Scope reduce graphic control extension masks.
-rw-r--r--src/gif.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/gif.c b/src/gif.c
index dce2bb1..9244d01 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
@@ -549,7 +547,7 @@ static nsgif_result nsgif__update_bitmap(
}
/**
- * Parse the application extension
+ * Parse the graphic control extension
*
* \param[in] frame The gif object we're decoding.
* \param[in] data The data to decode.
@@ -562,6 +560,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
@@ -579,12 +582,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