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

Thilo Borgmann thilo.borgmann at mail.de
Fri Jul 21 02:07:27 EEST 2023


Am 12.07.23 um 02:20 schrieb James Zern:
> On Thu, Jul 6, 2023 at 4:28 AM Thilo Borgmann <thilo.borgmann at mail.de> wrote:
>>
>> 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       | 714 ++++++++++++++++++++++++++++++++++++----
>>   4 files changed, 658 insertions(+), 62 deletions(-)
>>
>> diff --git a/Changelog b/Changelog
>> index 3876082844..271926ed8f 100644
>> --- a/Changelog
>> +++ b/Changelog
>> @@ -25,6 +25,7 @@ version <next>:
>>   - Raw VVC bitstream parser, muxer and demuxer
>>   - Bitstream filter for editing metadata in VVC streams
>>   - Bitstream filter for converting VVC from MP4 to Annex B
>> +- animated WebP parser/decoder
>>
>>   version 6.0:
>>   - Radiance HDR image support
>> diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
>> index 4406dd8318..47a38a4036 100644
>> --- a/libavcodec/codec_desc.c
>> +++ b/libavcodec/codec_desc.c
>> @@ -1259,8 +1259,7 @@ static const AVCodecDescriptor codec_descriptors[] = {
>>           .type      = AVMEDIA_TYPE_VIDEO,
>>           .name      = "webp",
>>           .long_name = NULL_IF_CONFIG_SMALL("WebP"),
>> -        .props     = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY |
>> -                     AV_CODEC_PROP_LOSSLESS,
>> +        .props     = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_LOSSLESS,
> 
> The frames are all intra, though with animation they may be smaller
> than the canvas and combined with the previous frame.

Well, which makes them in fact P-Frames.
Also leaving _INTRA_ONLY induces rendering issues for animated images.

Everything else in v3.

Thanks,
Thilo




More information about the ffmpeg-devel mailing list