[FFmpeg-devel] [PATCH] Animated GIF Support
Paul B Mahol
onemda at gmail.com
Fri Oct 12 10:26:27 CEST 2012
On 10/11/12, Vitaliy Sugrobov <vsugrob at hotmail.com> wrote:
>>Is transparency still working if you remove this?
> Thank you for feedback, Carl. Yes, transparency still working but now it
> is handled by other pieces of code.
> In contrast to previous version of libavformat/gifdec.c which was
> written for single-frame gif images, now we need to handle transparency
> with bit more complicated approach: transparent pixels of subsequent
> frames must leave underlying pixels of previous frames unaffected.
> Following piece of code provides this behavior by iterating through
> every pixel of scanline:
> for (px = ptr, idx = s->idx_line; px < pr; px++, idx++) {
> if (*idx != s->transparent_color_index)
> *px = pal[*idx];
> }
> As you can see, there is explicit check of whether each scanline color
> index is not equal to transparent color index prior to writing color
> value to the canvas.
> The other piece of code handles whether given gif image has transparent
> background or must be filled with some color. Before decoding first
> frame we check:
> if (s->transparent_color_index == -1 && s->has_global_palette) {
> /* transparency wasn't set before the first frame, fill with background
> color */
> gif_fill(&s->picture, s->bg_color);
> } else {
> /* otherwise fill with transparent color.
> * this is necessary since by default picture filled with 0x80808080.
> */
> gif_fill(&s->picture, GIF_TRANSPARENT_COLOR);
> }
> Together these two pieces of code forms full support of transparency for
> multiframe gif images.
How will this work with seeking?
This means that first frame is keyframe and any other frame with
transparency is not.
I think that right place to handle this is not in decoder but from user.
AFAIK mplayer should handle it and ffplay not.
More information about the ffmpeg-devel
mailing list