Git Product home page Git Product logo

Comments (5)

deanm avatar deanm commented on July 22, 2024

Discussion at #27 (comment)

from omggif.

jtlapp avatar jtlapp commented on July 22, 2024

Yeah, my claim is a lie. Sorry about that, misremembered the problem. Looks like I'll be ripping this mod out of the PR.

For the record, I was doing buffer management improperly. The proper technique is here: #27 (comment)

Also for the record, @deanm has superhuman patience for devs who are lost in the woods and don't know it.

from omggif.

jtlapp avatar jtlapp commented on July 22, 2024

@deanm, I think there is a problem writing with a global color table using the new buffer/position setter/getters.

I modified gifwrap and ran my tests. I have tests for writing and reading both local and global color table versions of GIFs.

When I use your latest omggif.js and provide a huge buffer, all of my tests run fine. But when I provide a buffer that has to scale in size, only the local color table tests work, even though they both run the same frame-writing and buffer-scaling code.

When trying to scale the buffer using a global color table, the encoding completes without error. However, when I try to read it back, I get GifError: Unknown gif block: 0x0. Also, my Mac is unable to show it.

I don't have a stripped-down test of encoding/decoding to send you. I'm hoping you have a personal test for this. Mine is intimately tied to gifwrap. However, you can see the algorithm here in my revision of a _writeFrame() function that I use for writing all frames:

        let buffer = gifWriter.getOutputBuffer();
        let startOfFrame = gifWriter.getOutputBufferPosition();
        let endOfFrame;
        let tryAgain = true;

        while (tryAgain) {
            endOfFrame = gifWriter.addFrame(frame.xOffset, frame.yOffset,
                    frame.bitmap.width, frame.bitmap.height, frameInfo.buffer, options);
            tryAgain = false;
            if (endOfFrame >= buffer.length - 1) {
                const biggerBuffer = new Buffer(buffer.length * 1.5);
                buffer.copy(biggerBuffer);
                gifWriter.setOutputBuffer(biggerBuffer);
                gifWriter.setOutputBufferPosition(startOfFrame);
                buffer = biggerBuffer;
                tryAgain = true;
            }
        }

The two test cases that fail are this one and the next, which use this GIF and this GIF, respectively. Both of these GIFs are officially in the public domain.

I'm still keening for an omggif test suite. ;-)

from omggif.

jtlapp avatar jtlapp commented on July 22, 2024

Okay, figured it out. The initial buffer has to be large enough for the header, including a global color table. My test started at a buffer size of 500 bytes to make sure everything was forced to scale, but that broke the global lookup table tests.

from omggif.

jtlapp avatar jtlapp commented on July 22, 2024

Okay, I posted a new version of gifwrap that depends on an external omggif. Thank you for so quickly taking care of all of this.

Also, I included tests for scaling the buffer size, which exercises both my code and yours.

from omggif.

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.