Giter Site home page Giter Site logo

Comments (6)

bitbank2 avatar bitbank2 commented on September 12, 2024

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.

FrenchLab47 avatar FrenchLab47 commented on September 12, 2024

This is a very good idea, I will try this.
Thanks for your help.

from animatedgif.

marcmerlin avatar marcmerlin commented on September 12, 2024

@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

I also later updated mallocordie to allow allocating in PSRAM to further save main memory

from animatedgif.

marcmerlin avatar marcmerlin commented on September 12, 2024

mallocordie: https://github.com/marcmerlin/FastLED_NeoMatrix_SmartMatrix_LEDMatrix_GFX_Demos/blob/38a137e3ac54d4f0b8d7a11ca99d2061cbbf86b1/neomatrix_config.h#L885

from animatedgif.

bitbank2 avatar bitbank2 commented on September 12, 2024

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.

marcmerlin avatar marcmerlin commented on September 12, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.