prenticedavid / AnimatedGIFs_SD

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

How to convert Gif to ESP32 arrays? #1

Open sirias52 opened 5 years ago

sirias52 commented 5 years ago

Its not Issues, but I want to Know how to convert Gif to Arrays. :)

prenticedavid commented 5 years ago

It is more convenient to just copy the regular .GIF file to SPIFFS or an SD card. Yes, you can embed the data in a C array e.g. with a utility like bin2C I think that you must be the first person who has ever looked at my private project.

What do you actually want to do?

David.

sirias52 commented 5 years ago

It is more convenient to just copy the regular .GIF file to SPIFFS or an SD card. Yes, you can embed the data in a C array e.g. with a utility like bin2C I think that you must be the first person who has ever looked at my private project.

What do you actually want to do?

David.

Thanks.

prenticedavid commented 5 years ago

I have not touch this project for a long time. It looks as if my local version has not been "synced" to the Public Repository on GitHub.

Explain what you want to do. e.g. post a link to the GIF you want to display. If it is interesting, I will see how well it works. There are several optimisations that I could investigate.

David.

Uup115 commented 5 years ago

Hello David,

Today, I began tinkering with your library (using Arduino Due). Does your local version sport any improvements, since the last public repository sync?

Best Regards

prenticedavid commented 5 years ago

No, I don't think that I have done anything recently.

Do you have a specific GIF that you want to display? What size? What display? Which library?

A Due should be practical. ESP32 or STM32 might be more powerful.

David.

Uup115 commented 5 years ago

Hello David,

Size: 320x240 (gif is attached)
Display: EastRising 3.2" ILI9341 Serial (buydisplay.com) Library: ILI9341_due

This time, It needs to be DUE, because of other requirements (CAN interface). Not sure if DUE + ILI9341_due can play this gif smoothly. If not, I'll need to simplify it a bit.

Thanks for your assistance!

Best Regards.

kaleidoscope

prenticedavid commented 5 years ago

Your GIF changes almost every pixel with each frame. Most of my examples only update small areas from one frame to the next.

I will have a look at my old code. I am sure that I can optimise some GIFs. I doubt if your GIF is possible. For a start, your GIF is 3.30MB. So it will not even fit in ESP32 flash. It can only be rendered from SD card.

I have added some extra debug info to the main sketch. I have added some comments to the readme_kbv.h

It looks as if I had already done the drawLine/skip optimisation. From memory, the LZW works quite well on an ARM M0, M3, M4. You might try improving LZW. You can speed up SPI in SD library. Or use a 128Mb Flash chip for RAW uncompressed pixel data.

Looking at LLAMA animation:

Pathname: /gifsdbg/LLAMA_~1.GIF
Logical Screen [LZW=8 355x200 P:0xF7 B:0 A:0 F:40ms] frames:0 pass=1
[108 frames = 4320ms] actual: 18547ms speed: 23% plot: 5928702 [30%] w=316

To my untrained eye I would expect higher than 30% transparent pixels. I am sure that GIF animations could be improved. But you have to render unknown GIFs that could have been designed for other targets.

David.

Uup115 commented 5 years ago

Hello David,

Yeah, I was thinking the GIF was a little over the top. Perhaps, I should fall back to something a little more reasonable on resources.

Thanks for your insight. I'll let you know how it goes.

Best Regards

prenticedavid commented 5 years ago

You can calculate the time for a full 240x320 frame to be written via ILI9341_due i.e. 24032016/42000000 = 29.258ms

Typical Animated GIFs draw a Frame every 40ms. This means you have to fetch data from SD card and LZW decode into SRAM in less than 10ms.

An animation that alters small areas could reduce the SPI traffic i.e. only update a minimal rectangle. and skip any unchanged pixels (transparent)

I suggest that you create a simpler animation. And use good PC tools to optimise the GIF sensibly. Or just draw pretty graphics in real time. Or a steady graphic but alter the colours via GAMMA settings.

David.