The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: localmotion34 on May 24, 2007, 09:10:32 PM

Title: GIF Decoder Crashes
Post by: localmotion34 on May 24, 2007, 09:10:32 PM
I have the source from Exagones' GIFLIB, and I compiled it to a static lib.  I linked it with a simple EXE to decode the GIF, and display it on the window.  It works with alot of GIFs, but i noticed it started crashing with a certain few, with no discernable pattern of what application encoded them.  i have included the GIFLIB source as written by Exagone, and the example EXE which crashes. 

Can anyone figure out why this LIB crashes with certain GIFs?  or does anyone have source for an actual GIF decoder, and not just OLE or GDI/Ipicture implementations?

QuoteGIFLIB is no longer available!

Due to the patents on the LZW compression that GIF uses, I can no longer supply GIFLIB or it's source. It might return in 2004 (when the patent expires) but I can't promise anything.

As an alternative, you can use Ernest Murphy's tutorial on pictures objects which shows you how to display GIF and JPG's using functionality built into Windows. For a completely patent-free and higher quality solution, try my PNGlib (see elsewhere on this download page). If you mirror a copy of GIFLIB, please remove it from your site as well.
Sorry for any inconvenience...


<Edit by P1>According to the instructions of the Author, this code is not to be mirrorred.
I have e-mail Thomas for him to post his code, seeing the copyright has expired.
Explicit Permission has been given by Thomas now.  See post below.</Edit>

[attachment deleted by admin]
Title: Re: GIF Decoder Crashes
Post by: P1 on May 24, 2007, 09:48:22 PM
Is KYKLOS.GIF a gif which will crash the library?

Regards,  P1   :8)
Title: Re: GIF Decoder Crashes
Post by: localmotion34 on May 24, 2007, 10:38:56 PM
yes, that GIF crashed the LIB. 

BTW, John Found translated this source to FASM for the FreshIDE, which is publically available on many sites.  I actually emailed Thomas a while ago, and he had said that the LIB was still available on a few sites and it was not an issue because all patents had expired. 
Title: Re: GIF Decoder Crashes
Post by: P1 on May 24, 2007, 11:48:20 PM
Back at the ranch ....

I am hoping Thomas would release current library code with permission.  And maybe fix your problem, without needing to debug this code.

Does this behavior demonstrate itself across different machines with different OSes?

Could you post your test.asm please?

Regards,  P1   :8)
Title: Re: GIF Decoder Crashes
Post by: raymond on May 25, 2007, 03:35:37 AM
Havew you tried the GIF decoder from the library in the following thread:

http://www.masm32.com/board/index.php?topic=4266.0

The link to download the library still works. It comes with a Help file.

Raymond
Title: Re: GIF Decoder Crashes
Post by: localmotion34 on May 25, 2007, 11:56:59 AM
Quote from: raymond on May 25, 2007, 03:35:37 AM
Havew you tried the GIF decoder from the library in the following thread:

http://www.masm32.com/board/index.php?topic=4266.0

The link to download the library still works. It comes with a Help file.

Raymond


That decoder does not work with hardly any GIFs i have.  The result from the return of LoadGIF is mostly 0.  It really only works with smaller optimized GIFs around 200x100. 
Title: Re: GIF Decoder Crashes
Post by: P1 on May 25, 2007, 07:02:33 PM
This library was written to handle flat ( non-animated ) gifs.

Here is some assembler code for GIF89a:
http://www.codeproject.com/useritems/anigif.asp

Regards,  P1   :8)
Title: Re: GIF Decoder Crashes
Post by: localmotion34 on May 25, 2007, 08:31:16 PM
Quote from: raymond on May 25, 2007, 03:35:37 AM
Havew you tried the GIF decoder from the library in the following thread:

http://www.masm32.com/board/index.php?topic=4266.0

The link to download the library still works. It comes with a Help file.

Raymond


@Raymond

Does your GIF decoder use the OLE or IPicture?  or did you code a native GIF decoder yourself?

@P1  Exagone's GIFLIB can decode animated GIFs, but it only renders the FIRST frame.  It is just hit or miss whether it will render a still or animated first frame.  i can't figure out WHY a random GIF crashes it.  It i could, then i could recompile the static lib and move on to working on an encoder. 
Title: Re: GIF Decoder Crashes
Post by: raymond on May 26, 2007, 02:53:49 AM
QuoteDoes your GIF decoder use the OLE or IPicture?  or did you code a native GIF decoder yourself?

I encoded myself that GIF decoder. However, it may decode only the first picture of animated GIFs. Could you provide some of those GIF files which are problematic so I may have a look at why they may not be rendered?

Raymond

Title: Re: GIF Decoder Crashes
Post by: localmotion34 on May 26, 2007, 03:08:47 AM
Here are the GIFs.  The one of me and my Doberman was saved in Photoshop, and the other was created i think in CorelPaint, which is Animated. 

I have some C sourcecode that successfully loads both the animated and static ones here, but it then crashes due to an unknown memory error. 

I really cant find any code out there that doesnt crash at some point or another.  my own attemtps at a GIF decoder are feeble at best.  Im looking to study a decoder that is always successful, and then learn from that.  i did the same thing with the PCX format, and it worked very well.  Then i was able to write and encoder, with some additional help.  I want to repeat this again, and write a GIF encoder.  I think Zcoder posted here and in the ASM community he wrote a GIF encoder/decoder, but i cant find those sources anywhere. 

i have seen your RFimage linked from another forum, and it works so well with bitmaps and JPEGS.  i think GIF can be really nasty sometimes, like PCX can be with 6 different variaitons. 

but thanks for your help, very much!!

[attachment deleted by admin]
Title: Re: GIF Decoder Crashes
Post by: Grincheux on May 26, 2007, 09:35:46 AM
I took your Gifs and loaded them with I-View there is no problem.
http://i-view.idcat39.com/download.html

I use the GFL SDK version 2.54

I-View is a free software. You can download it source code with the GFL DSK for MASM.
Title: Re: GIF Decoder Crashes
Post by: P1 on May 28, 2007, 07:37:15 PM
QuoteMy site has not been updated for some years so there is some old stuff on there. GIFLIB can be used again, although I strongly recommend the much better PNG library on my website. But if you really need GIF I guess that's of no help. I've placed a note on the frontpage of my website with a link to the GIFLIB on Iczelion's site, which never removed it. However that site is down now too. A mirror is available
here: http://win32assembly.online.fr/source1.html

It's no problem to redistribute the library, post it wherever you like.
Also, ignore the GPL license attached with it. Just use it in any way you want. But again, if you can also use PNGs, try my PNG library.

Regards,
Thomas
Download will be restored.

Regards,  P1   :8)
Title: Re: GIF Decoder Crashes
Post by: localmotion34 on May 28, 2007, 07:52:47 PM
Ok, so now we know we can use the library. 

LMAO, he seems to not like GIF, eh? 

So the original question:

What the heck is causing the LIB to crash?  i have debugged an EXE linked with the LIB, and the GIFdecompress procedure is where it is dying, ALTHOUGH, it is variable WHERE in the procedure it is crashing. 

Depending on the GIF, it will crash in the LZW decompression, or in creating the color table.  Any ideas?
Title: Re: GIF Decoder Crashes
Post by: raymond on May 28, 2007, 11:55:57 PM
I've been away for a few days but I had a quick glance at your GIF files before I left home. It would seem that those GIF images may not fully respect the GIF encoding rules. But, some decoders may disregard some of the rules and thus succeed in rendering those images.

I'll have a more detailed look at it when I get back home tomorrow and then report my results.

Raymond
Title: Re: GIF Decoder Crashes
Post by: raymond on May 30, 2007, 12:50:09 AM
I may have jumped to conclusion too fast. Those GIF files you provided do not seem to stray from the encoding rules as far as my library goes. The image viewer which I wrote to use that library displays those two files correctly. And, just in case it may have been using a version of the library more recent than the one you downloaded, I recompiled my viewer with that specific library; and it still renders those images correctly.

I'm attaching that viewer. Let me know if it renders those two GIF files on your system. If it does, there may be some other reason(s) for the problem.

Raymond

P.S. Don't worry about the name of the app. This was (and still is) in the development stage. It is designed to render JPGs, BMPs and GIFs.


[attachment deleted by admin]
Title: Re: GIF Decoder Crashes
Post by: localmotion34 on May 30, 2007, 08:45:01 PM
Your app loads the files fine.  However, it cannot load other GIFs downloaded from the web, or seemingly larger in size than 600KB.  They show up as blank squares in the custom drawn listview. 

When i link the LIB to my app, i cannot return the DIBINFO structure on the GIFs i have uploaded here.  Only very small GIFs will return a valid DIBINFO pointer. 
Title: Re: GIF Decoder Crashes
Post by: raymond on May 31, 2007, 01:44:09 AM
Many of the larger image files uploaded to the web (whether JPG, GIF, PNG) may be interlaced to provide a quick idea of the image by displaying only a portion of the pixels during a download while the remainder of the image is being decoded. I have not yet included the necessary code in the lib to deal with that feature. If a GIF or JPG file is indicated as being interlaced, the lib simply returns 0.

This does not explain why your regular non-interlaced GIF images were crashing.

Raymond
Title: Re: GIF Decoder Crashes
Post by: raymond on May 31, 2007, 06:24:14 PM
Could you also provide a link to some of those 600+kb GIF files which are problematic.

Raymond