From 9f5c8eca79277ba96a6fb0f56ea036cb0fd7f8d7 Mon Sep 17 00:00:00 2001 From: Pascal Massimino Date: Wed, 12 Oct 2016 00:03:59 -0700 Subject: [PATCH] additional fix for stride type as size_t - remove the inclusion of format_constants.h - use incremental update of pointer, instead of arithmetic (follow-up to e2affacc35f1df6cc3b1a9fa0ceff5ce2d0cce83) Change-Id: I48420c8defc8d47339f54bc00e9da9617f08ab32 --- examples/gifdec.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/examples/gifdec.c b/examples/gifdec.c index 7df176fd..f921c0a4 100644 --- a/examples/gifdec.c +++ b/examples/gifdec.c @@ -20,7 +20,6 @@ #include "webp/encode.h" #include "webp/mux_types.h" -#include "webp/format_constants.h" #define GIF_TRANSPARENT_COLOR 0x00000000 #define GIF_WHITE_COLOR 0xffffffff @@ -111,8 +110,7 @@ int GIFReadFrame(GifFileType* const gif, int transparent_index, int ok = 0; *gif_rect = rect; - if (memory_needed != (size_t)memory_needed || - memory_needed > 4 * MAX_IMAGE_AREA) { + if (memory_needed != (size_t)memory_needed || memory_needed > (4ULL << 32)) { fprintf(stderr, "Image is too large (%d x %d).", rect.width, rect.height); return 0; } @@ -135,12 +133,13 @@ int GIFReadFrame(GifFileType* const gif, int transparent_index, const int interlace_jumps[] = { 8, 8, 4, 2 }; int pass; for (pass = 0; pass < 4; ++pass) { - int y; - for (y = interlace_offsets[pass]; y < rect.height; - y += interlace_jumps[pass]) { + const size_t stride = (size_t)sub_image.argb_stride; + int y = interlace_offsets[pass]; + uint32_t* row = dst + y * stride; + const size_t jump = interlace_jumps[pass] * stride; + for (; y < rect.height; y += interlace_jumps[pass], row += jump) { if (DGifGetLine(gif, tmp, rect.width) == GIF_ERROR) goto End; - Remap(gif, tmp, rect.width, transparent_index, - dst + y * (size_t)sub_image.argb_stride); + Remap(gif, tmp, rect.width, transparent_index, row); } } } else { // Non-interlaced image.