Skip to content

Commit 1873dfa

Browse files
author
Louis Beaudoin
committed
Fix error where empty frame was treated as a new frame with valid delay
- depends on fix in AnimatedGIF's next release (beyond 1.2.0)
1 parent 6daa47b commit 1873dfa

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

src/GifDecoder_Impl.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -401,20 +401,23 @@ int GifDecoder<maxGifWidth, maxGifHeight, lzwMaxBits, useMalloc>::decodeFrame(bo
401401

402402
frameStatus = gif->playFrame(delayAfterDecode, &frameDelay_ms);
403403

404-
if(updateScreenCallback)
405-
(*updateScreenCallback)();
406-
407404
if(frameStatus < 0) {
408405
Serial.print("playFrame failed: ");
409406
Serial.println(gif->getLastError());
410407

411408
return translateGifErrorCode(gif->getLastError());
412409
}
413410

414-
frameNumber++;
415-
// only track cycleTime on first frame
416-
if(!cycleNumber)
417-
cycleTime += frameDelay_ms;
411+
// only run this code if a new frame was processed, otherwise we got error GIF_EMPTY_FRAME
412+
if(gif->getLastError() == GIF_SUCCESS) {
413+
if(updateScreenCallback)
414+
(*updateScreenCallback)();
415+
416+
frameNumber++;
417+
// only track cycleTime on first frame
418+
if(!cycleNumber)
419+
cycleTime += frameDelay_ms;
420+
}
418421

419422
// if done parsing
420423
if (frameStatus == 0) {

0 commit comments

Comments
 (0)