Comments (6)
The height doesn't affect the amount of memory used since each line is emitted one at a time. If you're running out of memory on the ESP32, then re-use the GIF structure for other purposes. It needs about 22.5K of RAM, but only while decoding. You can use that memory for something else when not using the GIF decoder. Another way of describing this is a "memory pool". For example:
static uint8_t my_memory_pool[24000];
AnimatedGIF *pGIF = static_cast<AnimatedGIF *>(my_memory_pool);
Then use the memory for something else that doesn't need to run at the same time as the GIF decoder.
Hope this helps.
L.B.
from animatedgif.
This is a very good idea, I will try this.
Thanks for your help.
from animatedgif.
@bitbank2 memory on ESP32 is complicated, but basically, memory available for global arrays, is only half the memory actually available.
Have a look at the slides on http://marc.merlins.org/perso/arduino/post_2020-01-14_LCA-2020-Talk_-ESP32-Memory-Management_-Neopixels-and-RGBPanels.html
This is what I did to my old fork of the library, I switched everything to malloc.
Sorry, this is not a single CL, I wrote it over time
- marcmerlin/AnimatedGIFs@0c61911#diff-1c6b5b8854f2713658794a513e0149a7861b1aae2755e52dbb1c78a1900b2f2b
- marcmerlin/AnimatedGIFs@2715fe2#diff-1c6b5b8854f2713658794a513e0149a7861b1aae2755e52dbb1c78a1900b2f2b
- marcmerlin/AnimatedGIFs@c2dc4c7#diff-cca9dc0aaf37dcf8e83c111f403400c9f29a228fbfad3c5f62eed507f8608664
- marcmerlin/AnimatedGIFs@1750be0#diff-cca9dc0aaf37dcf8e83c111f403400c9f29a228fbfad3c5f62eed507f8608664
- marcmerlin/AnimatedGIFs@ad21ba5#diff-cca9dc0aaf37dcf8e83c111f403400c9f29a228fbfad3c5f62eed507f8608664
I also later updated mallocordie to allow allocating in PSRAM to further save main memory
from animatedgif.
from animatedgif.
Instead of changing the library code, why not allocate the whole GIF structure with malloc? That's why I wrote it the way I did. You can define it as a static or allocate the whole structure in one shot.
from animatedgif.
note that those patches are to an old version of the library. With the current one, using one malloc makes sense.
however, because memory is fragmented on ESP32, it's better to malloc each structure you need than malloc a big contiguous pool (which might not exist as one contiguous block).
In case you're curious, I maintain an old fork along with SmartMatrix and memory is tight on ESP32 when you reach resolutions of 128x64
http://marc.merlins.org/perso/arduino/post_2018-07-13_AnimatedGIFs-for-SmartMatrix-or-NeoMatrix-_Neopixel-WS2812B_-from-SDcard-or-SPIFFS_-on-Teensy-3_x_-ESP8266_-or-ESP32.html
I am now running the same (old) gif decoding library code on rPi to decode just about any resolution since rPi has so much RAM (and can drive bigger rgbpanels). It's super cool that this library was written in a way (with callbacks) that porting it to ESP32 SPIFFS/FatFS, and then straight linux (rPI) was very little work. Here's the result:
https://youtu.be/bQc7sh-a6hQ?t=163
Ideally in my "copious spare time", I should sync up my old fork against this one, but given that the old one is working fine for me, it's not been pressing on my list of priorities ;)
https://github.com/marcmerlin/AnimatedGIFs
most of my relevant code is here
https://github.com/marcmerlin/AnimatedGIFs/blob/master/GifAnim_Impl.h
That said, I see that this lib has changed "a lot" since the fork I made, so it'll likely be a new port as opposed to a resync
from animatedgif.
Related Issues (20)
- FB datas in 1555 instead of 565 HOT 4
- In ESP32_LEDMatrix_I2S.ino iWidth is not intialized. HOT 1
- Issue using AnimatedGIFPanel HOT 2
- Sketch is too big HOT 1
- a example for tft_espi sd gif HOT 15
- Question, How better write text over the GIF animation ? HOT 4
- Stop a GIF mid playing HOT 1
- How to display text on GIF for every frame HOT 2
- GIF not rendering properly HOT 1
- GIF Encoder HOT 3
- Unable to loop: GIF_EMTY_FRAME after call to reset() HOT 1
- The ucLZW buffer access violaton HOT 6
- What happens when there is no palette at all? HOT 1
- Ways to improve speed on esp32-s3 HOT 38
- Suggestion: gain a little more performance by engaging the non-aligned memory access. HOT 3
- Playing a custom GIF from memory HOT 1
- GIFs look scrambled on 72x40 OLED Display HOT 4
- Memory pointer GIFFILE::pData not const HOT 4
- Problem with shifting the image output point with tft_eSPI library HOT 1
- Possibility of change GIF speed HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from animatedgif.