summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2021-10-31 17:11:15 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2021-10-31 17:11:57 +0000
commit46d7a0bb13a36dabaa5ede2158d22e3e702f5ad2 (patch)
tree0e0e262f9afbb2c686871bb515270b9add5b1be6 /src
parent8eac839eed55432446077659c052b6459509af2a (diff)
downloadlibnsgif-46d7a0bb13a36dabaa5ede2158d22e3e702f5ad2.tar.gz
libnsgif-46d7a0bb13a36dabaa5ede2158d22e3e702f5ad2.tar.bz2
GIF: Use cached frame details for clear disposal handling.
Diffstat (limited to 'src')
-rw-r--r--src/libnsgif.c37
1 files changed, 5 insertions, 32 deletions
diff --git a/src/libnsgif.c b/src/libnsgif.c
index 3cb1135..e744bcf 100644
--- a/src/libnsgif.c
+++ b/src/libnsgif.c
@@ -832,37 +832,11 @@ gif_clear_frame(gif_animation *gif, unsigned int frame)
goto gif_decode_frame_exit;
}
- /* 10-byte Image Descriptor is:
- *
- * +0 CHAR Image Separator (0x2c)
- * +1 SHORT Image Left Position
- * +3 SHORT Image Top Position
- * +5 SHORT Width
- * +7 SHORT Height
- * +9 CHAR __Packed Fields__
- * 1BIT Local Colour Table Flag
- * 1BIT Interlace Flag
- * 1BIT Sort Flag
- * 2BITS Reserved
- * 3BITS Size of Local Colour Table
- */
- if (gif_data[0] != GIF_IMAGE_SEPARATOR) {
- return_value = GIF_DATA_ERROR;
- goto gif_decode_frame_exit;
- }
- offset_x = gif_data[1] | (gif_data[2] << 8);
- offset_y = gif_data[3] | (gif_data[4] << 8);
- width = gif_data[5] | (gif_data[6] << 8);
- height = gif_data[7] | (gif_data[8] << 8);
-
- /* Boundary checking - shouldn't ever happen except unless the data has
- * been modified since initialisation.
- */
- if ((offset_x + width > gif->width) ||
- (offset_y + height > gif->height)) {
- return_value = GIF_DATA_ERROR;
- goto gif_decode_frame_exit;
- }
+ offset_x = gif->frames[frame].redraw_x;
+ offset_y = gif->frames[frame].redraw_y;
+ width = gif->frames[frame].redraw_width;
+ height = gif->frames[frame].redraw_height;
+ flags = gif->frames[frame].flags;
/* Make sure we have a buffer to decode to.
*/
@@ -871,7 +845,6 @@ gif_clear_frame(gif_animation *gif, unsigned int frame)
}
/* Decode the flags */
- flags = gif_data[9];
colour_table_size = 2 << (flags & GIF_COLOUR_TABLE_SIZE_MASK);
/* Advance data pointer to next block either colour table or image