gif: Minimize memory usage for gif animation

Update the logic to create the next frame.
When the new frame uses a buffer from the previous frame, in retain,
revert or dispose mode, try to reuse the allocated buffer from the
previous frame.

This reduces allocated memory by an order of magnitude.

For other cases when we can't use the old buffer, clean up the previous
buffers after the new frame has been handled.

https://bugzilla.gnome.org/show_bug.cgi?id=585425
lib: Add more g-i metadata for gdk_pixbuf_get_options