prenticedavid / AnimatedGIFs_SD

Display GIFs from Flash, SD or SPIFFS
64 stars 14 forks source link

Possible wrong buffer overrun detection during lzw_decode #6

Open alimbourg opened 3 years ago

alimbourg commented 3 years ago

... Causing last pixel of every lines of non interlaced gifs to be glitchy.

When activating LZWDEBUG (=1) , serial monitor is reporting a lot of buffer overruns on very small gifs (8x8) (LzwDecoder_Impl.h/line 121)

It seems that decompressAndDisplayFrame() is subtracting one byte for the buffend parameters ( GifDecoder_Impl.h/line 869) while calling lzw_decode (although the inner code code seems not require that unless I'm missing something).

Changing the call into int len = lzw_decode(imageBuf + tbiImageX, tbiWidth, imageBuf + maxGifWidth, align); suppress the warning and decode the last pixel. Regards

prenticedavid commented 3 years ago

Sorry, I have not really done anything with this project recently.

The master Branch is out of date. I had been using adafruit_opt Branch.

I should tidy up the comments in the code and put it into the master Branch.

Please can you quote which Branch and which GIF is exhibiting the problem.

David.

alimbourg commented 3 years ago

Sorry about that: so, previously tested on master, but the call to lzw_decode and the dubious bufend computation is similar in the adafruit_opt branch (GifDecoder_Impl.h/line 873)

Here is the tiny GIF showing a bizarre last pixel on each row when lzw_decode is leaving too early: ghosts_8x8

Regards

prenticedavid commented 3 years ago

Your Tiny gif is difficult to see on a PC screen. I copied it to the data directory of the AnimatedGIFS_SD sketch. Uploaded to SPIFFS

It was pretty small to see on a 135x240 ST7789 screen So I tried a 128x160 ST7735 screen where iit was still small.

Each frame on ESP32 seems to match the frame on my PC running EZGif

Ah-ha. I loaded the tiny.GIF into IrfanViiew. Frame #2 is 8x8 Blue. WxH Frame #3, 4, 5 seem to lose the last row i.e. 8x7 Red/Orange

I will investigate. Do you have a better example GIF ?

David.

pmerlin commented 11 months ago

thank you @alimbourg, I had the same issue : last pixel of each line was background. This is solving my issue (on 16x16 gif)