[FFmpeg-devel] [PATCH v8 2/5] libavcodec/webp: add support for animated WebP decoding

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Fri Dec 22 00:18:40 EET 2023


Thilo Borgmann via ffmpeg-devel:
> From: Josef Zlomek <josef at pex.com>
> 
> Fixes: 4907
> 
> Adds support for decoding of animated WebP.
> 
> The WebP decoder adds the animation related features according to the specs:
> https://developers.google.com/speed/webp/docs/riff_container#animation
> The frames of the animation may be smaller than the image canvas.
> Therefore, the frame is decoded to a temporary frame,
> then it is blended into the canvas, the canvas is copied to the output frame,
> and finally the frame is disposed from the canvas.
> 
> The output to AV_PIX_FMT_YUVA420P/AV_PIX_FMT_YUV420P is still supported.
> The background color is specified only as BGRA in the WebP file
> so it is converted to YUVA if YUV formats are output.
> 
> Signed-off-by: Josef Zlomek <josef at pex.com>
> ---
>  Changelog               |   1 +
>  libavcodec/codec_desc.c |   3 +-
>  libavcodec/version.h    |   2 +-
>  libavcodec/webp.c       | 754 ++++++++++++++++++++++++++++++++++++----
>  4 files changed, 696 insertions(+), 64 deletions(-)
> 
> @@ -1298,12 +1326,12 @@ static int vp8_lossy_decode_frame(AVCodecContext *avctx, AVFrame *p,
>      int ret;
>  
>      if (!s->initialized) {
> -        ff_vp8_decode_init(avctx);
> +        VP8Context *s_vp8 = s->avctx_vp8->priv_data;
> +        s_vp8->actually_webp = 1;
>          s->initialized = 1;
> -        s->v.actually_webp = 1;
>      }
>      avctx->pix_fmt = s->has_alpha ? AV_PIX_FMT_YUVA420P : AV_PIX_FMT_YUV420P;
> -    s->lossless = 0;
> +    s->avctx_vp8->pix_fmt = avctx->pix_fmt;
>  

Separating webp.c from vp8.c should be done in commit of its own. And
you did not really separate them, because you are overwriting internals
of the VP8 decoder.

- Andreas



More information about the ffmpeg-devel mailing list