From 607a6921687fd12e119eeaed93d9f7bc0b0e1a14 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sat, 22 Apr 2017 18:20:31 -0700 Subject: [PATCH] Feature: Fix resizing GIF buffer (fixes #695) --- CHANGES | 1 + src/feature/imagemagick/imagemagick-gif-encoder.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/CHANGES b/CHANGES index b292bde0d..c1b5a8ce2 100644 --- a/CHANGES +++ b/CHANGES @@ -23,6 +23,7 @@ Bugfixes: - DS Slot-1: Emulate initial SPI command delay - DS: Fix exposed CPU frequencies and audio timing - DS Audio: Fix audio sampling slightly too quickly + - Feature: Fix resizing GIF buffer (fixes mgba.io/i/695) Misc: - DS: Set boot complete bit in RAM on boot (fixes mgba.io/i/576, mgba.io/i/580, mgba.io/i/586) - DS Memory: Ensure DS9 I/O is 8-byte aligned diff --git a/src/feature/imagemagick/imagemagick-gif-encoder.c b/src/feature/imagemagick/imagemagick-gif-encoder.c index f42f09f83..73bf7b582 100644 --- a/src/feature/imagemagick/imagemagick-gif-encoder.c +++ b/src/feature/imagemagick/imagemagick-gif-encoder.c @@ -102,8 +102,13 @@ static void _magickPostVideoFrame(struct mAVStream* stream, const color_t* pixel static void _magickVideoDimensionsChanged(struct mAVStream* stream, unsigned width, unsigned height) { struct ImageMagickGIFEncoder* encoder = (struct ImageMagickGIFEncoder*) stream; + if (encoder->iwidth == width && encoder->iheight == height) { + return; + } + free(encoder->frame); encoder->iwidth = width; encoder->iheight = height; + encoder->frame = malloc(encoder->iwidth * encoder->iheight * 4); } static void _magickVideoFrameRateChanged(struct mAVStream* stream, unsigned numerator, unsigned denominator) {