lavc/gif: mark one colour as transparent

If the input palette contains at least one colour that is more than 50%
transparent.
lavc/gif: support resolutions up to 65535x65535

Maybe someone can add a check in the second gif encoder (rgb24), because I'm not
sure where it should be added.
lavc/gif: remove some obsolete/irrelevant chunks

Some code was copy pasted from muxer, which still have same comments but unlike
encoder they are still relevant to muxer.
lavc/gifdec: move some definitions to header file.

Share them with upcoming demuxer module.
gif: cleanse GIF muxer and encoder

This commit removes the badly duplicated code between the encoder and
the muxer. That may sound surprising, but the encoder is now responsible
from the encoding of the picture when muxing to a .gif file. It also
does not require anymore a manual user intervention such as a -pix_fmt
rgb24 to work properly. To summarize, output gif are now easier to
generate, code is saner and simpler, and files are smaller (thanks to
the lzw encoding which was unused so far with the default .gif output).
We can certainly make things even better, but this is the first step.
lavc/gif: crop image when possible.

Increase compression when pictures are similar.

-f lavfi testsrc=300: 61M -> 21M
lavf/gif: simplify palette writing.
lavc/gif: merge two allocation checks.
gif: remove outdated comments.
lavf/gif: remove unused fields.
lavf/gif: trim unnecessarily long netscape ext code.

Extension description comments are now placed along the avio calls, the
always defined macro removed, and the always true loop_count check as
well (loop option is bound to 0-65535).
lavf/gif: merge gif_write_{packet,video}.

Avoid a pointless split.
lavf/gif: support only GIF codec.
lavf/gif: improve error message in case of unsupported codec
lavc/gif: avoid encoding 0x0 images.

It seems browsers don't like it very much.
gif: use only one graphic control extension block per image.

The encoder now doesn't produce any extra graphic control extension
block anymore. Only the image is encoded, and the muxer writing
its own GCE containing notably the timing information now includes the
optional palette transmitted through packet side data.

This commit avoid setting clashes between the two GCE, and reduce the
size of the generated file with pal8 output.
lavf/gif: fix timing

pkt->duration can not be used since the values are only based on frame rate.
lavf/gif: correct the delay after the first frame.

To define accurately the delay between two frames, it is necessary to
have both available. Before this commit, the first frame had a delay of
0; while in practice the problem is not visible in most situation, it is
problematic with low frame rate and large scene change.

This commit notably fixes output generated with commands such as:

  ffmpeg -i big_buck_bunny_1080p_h264.mov
     -vf "select='gt(scene,0.4)',scale=320:-1,setpts=N/TB"
     -frames:v 5 -y out.gif

Also, to avoid odd loop delays, the N-1 delay is duplicated for the last
frame.
lavc/gif: make possible to disable offsetting.
lavc/gif: add flag to enable transparency detection between frames.

While this is not always optimal, in practice most of the common cases are.

  ffmpeg -i big_buck_bunny_1080p_h264.mov -ss 45 -vf scale=320:160 -gifflags -transdiff -frames:v 50 -y bbb-notrans.gif
  ffmpeg -i big_buck_bunny_1080p_h264.mov -ss 45 -vf scale=320:160 -gifflags +transdiff -frames:v 50 -y bbb-trans.gif

  -rw-r--r-- 1 ubitux ubitux 1.1M Apr 19 19:00 bbb-notrans.gif
  -rw-r--r-- 1 ubitux ubitux 378K Apr 19 19:00 bbb-trans.gif