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

Thilo Borgmann thilo.borgmann at mail.de
Sun Dec 31 14:14:51 EET 2023


Am 21.12.23 um 23:18 schrieb Andreas Rheinhardt:
> 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.

Sending v9 with a separate commit for this.
actually_webp and pix_fmt need to be set since 9f00fa5, or we won't get the alpha channel allocated (and segfault on fate-webp-rgba-lossy-q80)
See https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/vp8.c#L2668-L2677

Thanks,
Thilo


More information about the ffmpeg-devel mailing list