Monday, 6 July 2020

Re: possible bug: libnsgif does not handle DISPOSE_PREVIOUS correctly

Thank you Michael! It now renders that test case correctly, and runs
cleanly with valgrind.

I had a couple of other small ideas for improvements to libnsgif, if
changes are being made. I'd be happy to have a go at a patch if they
sound useful.

First, line 438 modifies the input buffer:

http://source.netsurf-browser.org/libnsgif.git/tree/src/libnsgif.c?id=8442a27c2bb8df48029ceea6e64c4930106a57fc#n438

This feels a bit ugly to me, and it doesn't work for us, since the
input buffer can be a mmaped file. I patched this to just return
GIF_INSUFFICIENT_FRAME_DATA.

Second, gif_decode_frame(gif, frame_number) seems like the wrong API.
You can only call this function with frame_number ascending, and you
must always start from 0 and loop, but this restriction is not obvious
from the function.

How about having frame_number as a member, and renaming it to
gif_decode_next_frame(gif)? It could handle looping too.

gif_decode_frame() could be marked as deprecated, and just call
gif_decode_next_frame() without using the frame_number parameter. It
should be compatible and the API would be simpler and clearer. I may
well have misunderstood things, of course.

John

On Mon, 6 Jul 2020 at 17:03, Michael Drake
<michael.drake@codethink.co.uk> wrote:
>
> On 06/07/2020 10:07, Michael Drake wrote:
> > On 04/07/2020 15:25, jcupitt@gmail.com wrote:
> >> On Fri, 3 Jul 2020 at 12:16, <jcupitt@gmail.com> wrote:
>
> >>> https://user-images.githubusercontent.com/580843/86457777-18bd1400-bd1c-11ea-923a-adeed2eba031.gif
>
> >>> Frame 6 is DISPOSE_PREVIOUS and should unpaint the tips of the wings.
>
> > Thanks for this! I hope to have a fix for you to test later today.
>
> Please try with this:
>
> http://source.netsurf-browser.org/libnsgif.git/commit/?id=8442a27c2bb8df48029ceea6e64c4930106a57fc
>
> Cheers,
>
> --
> Michael Drake https://www.codethink.co.uk/
> _______________________________________________
> netsurf-dev mailing list -- netsurf-dev@netsurf-browser.org
> To unsubscribe send an email to netsurf-dev-leave@netsurf-browser.org
_______________________________________________
netsurf-dev mailing list -- netsurf-dev@netsurf-browser.org
To unsubscribe send an email to netsurf-dev-leave@netsurf-browser.org

No comments:

Post a Comment