Menu

#6 File decode error

closed-fixed
5
2010-03-01
2010-01-27
Bill BOQUET
No

Hello,
i found a gif animation that produce an error in GifInspector / Gifdecoder.
It stop after the 7th frames, and there are 46 frames in that file.
Here is the error :

System.ArgumentOutOfRangeException: Colour table size: 2. Index: 2
Parameter name: index
at GifComponents.ColourTable.get_Item(Int32 index)
at GifComponents.GifFrame.FromStream(Stream inputStream, LogicalScreenDescriptor lsd, ColourTable gct, GraphicControlExtension gce, GifFrame previousFrame, GifFrame previousFrameBut1)
at GifComponents.GifDecoder.AddFrame(Stream inputStream, GraphicControlExtension lastGce)
at GifComponents.GifDecoder.ReadContents(Stream inputStream)
at GifComponents.GifDecoder.ReadStream(Stream inputStream)
at GifComponents.GifDecoder.Decode()
at GifInspector.MainForm.LoadGif()

Discussion

  • Bill BOQUET

    Bill BOQUET - 2010-01-27

    animation that

     
  • Simon Bridewell

    Simon Bridewell - 2010-01-27

    The stack trace indicates that you're using an out-of-date version of the code. The GifFrame.FromStream method has been replaced by a GifFrame constructor which accepts a stream as a parameter. However that image causes the same exception in the latest code too.

    This is where it's happening, this is a bit of code from the nGif library which I never really understood and I don't know whether it's right or not:

    // If this frame has a transparent colour then replace its entry in
    // the active colour table with black // TODO: (why?)
    Color savedTransparentColour = Color.FromArgb( 0 );
    if( gce.HasTransparentColour )
    {
    savedTransparentColour = activeColourTable[transparentColourIndex];
    activeColourTable[transparentColourIndex] = Color.FromArgb( 0 );
    }

    That image has a colour table with only 2 colours, and the graphic control extension for frame 8 appears to say that the frame has a (zero-based) transparent colour index of 2, which is out of the range of the colour table.

    It's a badly encoded file, but GifDecoder ought to handle it more gracefully than this, so thanks for pointing it out.

     
  • Simon Bridewell

    Simon Bridewell - 2010-01-27
    • assigned_to: nobody --> sbridewell
     
  • Simon Bridewell

    Simon Bridewell - 2010-01-27
    • status: open --> open-accepted
     
  • Simon Bridewell

    Simon Bridewell - 2010-02-20

    I've just committed revision 78 to the repository which includes a change to GifFrame to prevent this exception. Also includes a new test case in GifFrameTest using the image you supplied.

    I'd be grateful if you could check the image is being decoded as you'd expect.

     
  • Simon Bridewell

    Simon Bridewell - 2010-02-20
    • status: open-accepted --> open-fixed
     
  • Simon Bridewell

    Simon Bridewell - 2010-02-28
    • status: open-fixed --> closed-fixed
     
  • Simon Bridewell

    Simon Bridewell - 2010-02-28

    Fixed in version 0.1.3711.28220 of the MSI installer, uploaded today

     
  • Bill BOQUET

    Bill BOQUET - 2010-03-01

    This new release works great, and decode frame difference optimized gif with no problem.
    But i found another error, while loading a number of gifs, and browsing thrue frames :

    System.Xml.XmlException: The 'IndexedPixels' start tag on line 4020 does not match the end tag of 'BytesRead'. Line 10957, position 5.
    at System.Xml.XmlTextReaderImpl.Throw(Exception e)
    at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
    at System.Xml.XmlTextReaderImpl.ThrowTagMismatch(NodeData startTag)
    at System.Xml.XmlTextReaderImpl.ParseEndElement()
    at System.Xml.XmlTextReaderImpl.ParseElementContent()
    at System.Xml.XmlTextReaderImpl.Read()
    at System.Xml.XmlTextReader.Read()
    at System.Xml.XmlWriter.WriteNode(XmlReader reader, Boolean defattr)
    at GifComponents.Components.GifComponent.WriteDebugXmlNode(XmlReader reader)
    at GifComponents.GifDecoder.AddFrame(Stream inputStream, GraphicControlExtension lastGce)
    at GifComponents.GifDecoder.ReadContents(Stream inputStream)
    at GifComponents.GifDecoder.ReadStream(Stream inputStream)
    at GifComponents.GifDecoder.Decode()
    at GifInspector.MainForm.LoadGif()

    I think you can reproduce it easily this way :

    1) Load a gif (i use the ones in the WrongGifs archive)
    2) browse the frames
    3) reapeat those two steps 3 or 4 times

     
  • Bill BOQUET

    Bill BOQUET - 2010-03-01
    • status: closed-fixed --> open-fixed
     
  • Simon Bridewell

    Simon Bridewell - 2010-03-01
    • status: open-fixed --> closed-fixed
     
  • Simon Bridewell

    Simon Bridewell - 2010-03-04

    I've updated the new bug report 2961509 with my analysis of what's wrong and details of what I've changed to fix it. Could you try out the latest code and post any feedback on that bug report please?

     

Log in to post a comment.

MongoDB Logo MongoDB