[FFmpeg-devel] [PATCH] fix for transparencies in animated gifs

Paul B Mahol onemda at gmail.com
Mon Dec 10 19:18:50 EET 2018


On 11/21/17, Bjorn Roche <bjorn at giphy.com> wrote:
> Support for transparencies in animated gifs requires modifying both
> libavcodec/gif.c and libavformat/gif.c because both the graphics
> control extension (handled by libavformat/gif.c) and the raw frame data
> (handled by libavcodec/gif.c) must be changed. This is because
> transparencies in GIF can be used both to create a transparent image,
> and to provide optimization.
> How transparencies are interpreted in a given frame is controlled by
> the “disposal method”, which must be set appropriately in the graphics
> control extension.
>  The “in place” disposal method is used when transparency indicates
> optimization, and the “background” disposal method is used when
> transparency is intended to be preserved. In order to support both
> disposal methods, libavcodec/gif.c must signal to libavformat/gif.c
> which disposal method is required for every frame. This is done with a
> new side data type: AV_PKT_DATA_GIF_FRAME_DISPOSAL. This requires a
> change to avcodec.h
> Unfortunately, the addition of a new side data type causes some of the
> FATE tests to fail, so the fate tests are updated here as well.

What about rewritting code instead so it behaves correctly?

For example muxing gif and encoding gif should work with codec copy.
To get that working one needs to change muxer and encoder so muxer does not
write extensions but encoder does.
Adding side data is not going to make codec copy work.

I'm planning to do this.

More information about the ffmpeg-devel mailing list