lecram / gifdec

small C GIF decoder
236 stars 53 forks source link

Timing #6

Open zaun opened 5 years ago

zaun commented 5 years ago

When playing this animation back, using gif->gce.delay as the replay between frames, it doesn't work properly. Most frames only last for 1 render.

eyeroll

lecram commented 4 years ago

That's because most frames in this GIF have gif->gce.delay == 0, which strictly speaking means no delay, i.e., "don't wait before moving to the next frame". So, as far as I can tell, gifdec is behaving just as specified. To work around this kind of GIF, we can enforce a minimum value for gif->gce.delay after each call to gd_get_frame(), e.g.:

gd_get_frame(gif);
if (gif->gce.delay < 6)
    gif->gce.delay = 6;

If GIFs like this turn out to be common, I may add such code to example.c.