Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Many 32x32 index color animated gifs I created don't play (but some do). Here's one that doesn't (seems to crash teensy) #2

Closed
swb1701 opened this issue Sep 28, 2014 · 13 comments

Comments

@swb1701
Copy link

swb1701 commented Sep 28, 2014

totoro3

@pixelmatix
Copy link
Collaborator

I'll trace down what's causing this GIF to break the sketch. What tool did you use to create it?

@swb1701
Copy link
Author

swb1701 commented Sep 28, 2014

I used gimp to scale it down and save it.
Sent from my Verizon Wireless BlackBerry

-----Original Message-----
From: Pixelmatix [email protected]
Date: Sun, 28 Sep 2014 13:34:48
To: pixelmatix/[email protected]
Reply-To: pixelmatix/AnimatedGIFs [email protected]
Cc: [email protected]
Subject: Re: [AnimatedGIFs] Many 32x32 index color animated gifs I created
don't play (but some do). Here's one that doesn't (seems to crash teensy) (#2)

I'll trace down what's causing this GIF to break the sketch. What tool did you use to create it?


Reply to this email directly or view it on GitHub:
#2 (comment)

@pixelmatix
Copy link
Collaborator

This GIF can't play as the image data for the first frame is 1133 bytes long, and the GIF parser tries to write that into a 1024 byte buffer. I didn't write this code and I'm not sure the best way to fix, but I'm looking into it.

@pixelmatix
Copy link
Collaborator

If you just want to get your GIF playing without waiting for the real fix to be committed, change line 103 in GIFParseFunctions.cpp to:

byte lzwImageData[1280];

That gives the buffer enough room to decode the frames in this animation at least.

@swb1701
Copy link
Author

swb1701 commented Sep 28, 2014

Thanks, I'll give that a try tonight.
Sent from my Verizon Wireless BlackBerry

-----Original Message-----
From: Pixelmatix [email protected]
Date: Sun, 28 Sep 2014 14:52:47
To: pixelmatix/[email protected]
Reply-To: pixelmatix/AnimatedGIFs [email protected]
Cc: [email protected]
Subject: Re: [AnimatedGIFs] Many 32x32 index color animated gifs I created
don't play (but some do). Here's one that doesn't (seems to crash teensy) (#2)

If you just want to get your GIF playing without waiting for the real fix to be committed, change line 103 in GIFParseFunctions.cpp to:

byte lzwImageData[1280];

That gives the buffer enough room to decode the frames in this animation at least.


Reply to this email directly or view it on GitHub:
#2 (comment)

@swb1701
Copy link
Author

swb1701 commented Sep 28, 2014

You may have also seen I had trouble building Aurora (somehow the CRGB's don't cast to rgb24's for the smart matrix library). If you have any ideas there that would be helpful too. For this, I was just running the AnimatedGif demo independently -- which does build. Thanks.
Sent from my Verizon Wireless BlackBerry

-----Original Message-----
From: [email protected]
Date: Sun, 28 Sep 2014 22:14:33
To: pixelmatix/[email protected]; pixelmatix/[email protected]
Reply-To: [email protected]
Subject: Re: [AnimatedGIFs] Many 32x32 index color animated gifs I created don't play (but some do). Here's one that doesn't (seems to crash teensy) (#2)

Thanks, I'll give that a try tonight.
Sent from my Verizon Wireless BlackBerry

-----Original Message-----
From: Pixelmatix [email protected]
Date: Sun, 28 Sep 2014 14:52:47
To: pixelmatix/[email protected]
Reply-To: pixelmatix/AnimatedGIFs [email protected]
Cc: [email protected]
Subject: Re: [AnimatedGIFs] Many 32x32 index color animated gifs I created
don't play (but some do). Here's one that doesn't (seems to crash teensy) (#2)

If you just want to get your GIF playing without waiting for the real fix to be committed, change line 103 in GIFParseFunctions.cpp to:

byte lzwImageData[1280];

That gives the buffer enough room to decode the frames in this animation at least.


Reply to this email directly or view it on GitHub:
#2 (comment)

@pixelmatix
Copy link
Collaborator

@craiglindley The AnimatedGIFs sketch can't play this file as is, the lzw compressed image data for the first frame at least won't fit into 1024 bytes. It seems that for some complex images, the LZW compressed data is larger than the raw bitmap source. I'm increasing the the lzwImageData buffer size in AnimatedGIFs, and will add bounds checking as well. Do you have a recommendation on what size to set it to? Is there a theoretical limit I could compute with a better understanding of LZW compression?

@ghost
Copy link

ghost commented Sep 29, 2014

This is interesting. I have never encountered this issue before and I have
been using this decoder code for over 15 years in various forms. The gimp
encoder isn't doing a very good job of compressing the image data if the
compressed data is bigger than the bitmap data. It seems the encoder must
be choosing a large code size to start with. Is the initial code size
specifiable in gimp? If so, set it smaller than 8 bits.

That being said I don't see an issue with increasing the size of the lzw
data buffer. But no I have no idea how to calculate an absolute maximum
size. The important thing is that the decoded data doesn't exceed 32x32.

On Sun, Sep 28, 2014 at 5:20 PM, Pixelmatix [email protected]
wrote:

@craiglindley https://github.com/CraigLindley The AnimatedGIFs sketch
can't play this file as is, the lzw compressed image data for the first
frame at least won't fit into 1024 bytes. It seems that for some complex
images, the LZW compressed data is larger than the raw bitmap source. I'm
increasing the the lzwImageData buffer size in AnimatedGIFs, and will add
bounds checking as well. Do you have a recommendation on what size to set
it to? Is there a theoretical limit I could compute with a better
understanding of LZW compression?


Reply to this email directly or view it on GitHub
#2 (comment)
.

Craig Lindley / Heather Hubbard

New Recordings: craigandheather.net/cnmpage.html
Latest CD: craigandheather.net/hellinahandbasket.html

Personal Website: craigandheather.net

Phone: (719) 495-1873
Cell: (719) 502-7925

If you’re one in a million, there are now seven thousand people exactly
like you.

This was referenced Oct 3, 2014
pixelmatix pushed a commit that referenced this issue Oct 3, 2014
…IF encoding, fixing #2

Added a few more pieces of debug information, and removed comment that DEBUG=1 causes parsing to fail, as it seemed stable
@pixelmatix
Copy link
Collaborator

Fixed for now by increasing the buffer size probably too much. I created a new Issue #3 to set the buffer to the proper size

@KevoHack
Copy link

KevoHack commented Oct 3, 2014

I found a quick work around: Just reduce the number of colors in the GIF. It reduced my photos-to-GIF from 5K to 2K. By default GIMP uses a 256 color pallet. Here's the tweak:
1. Open image (of course);
2. Click Image->Mode->RGB (it will show an "Indexed..." choice but clicking doesn't do anything, at least with GIMP 2.6.8 on Winderz 7 Pro);
3. Click Image->Mode->Indexed...;
4. Under "Colormap" change "Maximum number of colors" from 256 to something that won't wreck your 32x32 self-expression-masterpiece; in my case, I chose 16;
5. For nicer results, under "Dithering" select "Floyd-Steinberg (reduced color bleeding)"
6. Save as GIF, as animation, etc...
Hope this helps somebody!

~Kevo

jasoncoon added a commit to pixelmatix/aurora that referenced this issue Oct 3, 2014
Added bounds checking to prevent lzwImageData buffer overflow, part of pixelmatix/AnimatedGIFs#2
Increased lzwImageData to 1280 to 1024 to make room for inefficient GIF encoding, fixing #2
Added a few more pieces of debug information, and removed comment that DEBUG=1 causes parsing to fail, as it seemed stable
Converted Adafruit remote IR codes to hex, for consistency with Sparkfun IR codes.
Updated precomiled binary Aurora.hex file.
@pixelmatix
Copy link
Collaborator

@KevoHack Did you try changing the size of the buffer and found it didn't work for your GIF?

@swb1701
Copy link
Author

swb1701 commented Oct 3, 2014

Expanding the lzw buffer solves the problem. I just doubled it but that's overkill.
Sent from my Verizon Wireless BlackBerry

-----Original Message-----
From: Pixelmatix [email protected]
Date: Fri, 03 Oct 2014 15:43:24
To: pixelmatix/[email protected]
Reply-To: pixelmatix/AnimatedGIFs [email protected]
Cc: [email protected]
Subject: Re: [AnimatedGIFs] Many 32x32 index color animated gifs I created
don't play (but some do). Here's one that doesn't (seems to crash teensy) (#2)

@KevoHack Did you try changing the size of the buffer and found it didn't work for your GIF?


Reply to this email directly or view it on GitHub:
#2 (comment)

@KevoHack
Copy link

KevoHack commented Oct 3, 2014

Pixelmatix,

No, I did not try to change the buffer size, but I completely expect that would have worked and is obviously a much better solution than somehow forcing the image to a smaller size. However for persons not wanting to recompile code, tweaking the image is a quick solution.

My preference of an ultimate solution is the code allocates the necessary buffer!

~Kevo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants