Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 7 of 7

Thread: (another) Animated GIF player

  1. #1
    Junior Member
    Join Date
    Jun 2020
    Location
    Rome, Italy
    Posts
    15

    (another) Animated GIF player

    Long ago, in a job far far way, I wrote optimized image codecs for all standard image types. I've been slowly porting them to be compatible with Arduinos and today I got my old GIF player to run on the Teensy4. It still needs some cleanup before it can be released as an Arduino library, but today I got it running reliably.

    https://youtu.be/Bmqrxzmw30s

    It currently uses a lot of RAM and doesn't optimize the display writes, but I will get there in stages. Hopefully this will make it easier to use animated images on the Teensy when I finish it.

  2. #2
    Senior Member
    Join Date
    Oct 2019
    Posts
    134
    That looks quick!

    So you’re going to build a new library to play back the GIFs, or will it be an extension library that utilizes the APIs from display driver libraries such as ILI9341_t3n?

  3. #3
    Junior Member
    Join Date
    Jun 2020
    Location
    Rome, Italy
    Posts
    15
    Quote Originally Posted by Rezo View Post
    That looks quick!

    So you’re going to build a new library to play back the GIFs, or will it be an extension library that utilizes the APIs from display driver libraries such as ILI9341_t3n?
    It's going to use my bb_spi_lcd library to draw on LCDs. It should be easy to modify it to use any other LCD library from there.

  4. #4
    I maintain this AnimatedGIFs "sketch", originally written for Teensy/SmartMatrix Library/SD card, but easily adaptable to other platforms: https://github.com/pixelmatix/AnimatedGIFs

    Adafruit adapted the sketch into an Adafruit Arcada specific library: https://github.com/adafruit/Adafruit_Arcada_GifDecoder

    I've forked their library to make it generic again, and it's now available here: https://github.com/pixelmatix/GifDecoder

    It sounds like you're coding your library from scratch, but I'm sharing anyway in case it helps. Looking forward to seeing your library!

  5. #5
    Junior Member
    Join Date
    Jun 2020
    Location
    Rome, Italy
    Posts
    15
    I've done some cleanup and testing. Here's the status so far:

    1) Written for any C compiler (no dependency on Arduino or anything else)
    2) Static GIF structure uses 22k of RAM; no other buffers needed and no use of malloc/free or any dynamic structures
    3) Can play files from memory (internal FLASH) or SD cards (seek and read callbacks)
    4) Uses a smart buffering system that de-chunks a few blocks of GIF data and doesn't have to constantly check for needing more data at each decode step
    5) Can display much quicker on systems with enough RAM to hold the destination image (transparent pixel rendering in memory versus moving the LCD write cursor)

    I'll share it soon; I'm still fleshing out the parts and I need to document it and provide examples.

  6. #6
    Junior Member
    Join Date
    Jun 2020
    Location
    Rome, Italy
    Posts
    15
    I finally got time today to work on this. I've been coding the SD card support and it basically works, but I've run into an odd problem. My code tries to read a fixed amount of data (2K) to parse the GIF header of each frame instead of calling read() tons of times with tiny buffers. The problem occurs when it reaches the end of the file. If the file position is at filesize-1k and I try to read 2K, it will correctly read 1k, but from that point on, seek() has no effect and the file is 'stuck' at the end. Has anyone seen this?

    Update:
    If found an ugly workaround - if I read up to, but not including the last byte of the file, seek() continues to work.

    https://youtu.be/8psIzfY2Ick
    Last edited by bitbank; 07-19-2020 at 10:01 PM.

  7. #7
    Junior Member
    Join Date
    Jun 2020
    Location
    Rome, Italy
    Posts
    15
    I finished the code - please have a look and let me know what you think:

    https://github.com/bitbank2/AnimatedGIF

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •