This patch series adds animated WebP decoding support to FFmpeg via
libwebp's WebPAnimDecoder API (libwebpdemux >= 0.5.0), along with
several fixes and FATE regression tests.
The decoder is registered with higher priority than the native
ff_webp_decoder and covers both static and animated WebP images.
Changelog entries, docs, version bumps, and FATE tests are included.
Key changes:
- Patch 1: New libwebpdec.c decoder using WebPAnimDecoder API
- Patch 2: Fix return values and empty packet (flush) handling
- Patch 3: Fix loop count, timestamp accumulation, framerate,
decoder reset logic; add AV_CODEC_CAP_DELAY
- Patch 4: Remove dead code, narrow variable scope, cosmetic cleanup
- Patch 5: Lower libwebpdemux requirement to 0.5.0 (use public API);
add priority comment in allcodecs.c
- Patch 6: Register 10 FATE tests for static lossless/lossy and
animated WebP decoding
Usage Notes
-----------
Since there is currently no dedicated demuxer for the WebP format,
the raw video demuxer reads the entire WebP file as a single data
packet. When decoding animated WebP images, the -fps_mode passthrough
option **must** be added to the FFmpeg command line in order to
preserve the original per-frame durations:
ffmpeg -fps_mode passthrough -c:v libwebp -i anim.webp out.mp4
Without this option, the default filter chain will insert or drop
frames to force the output to 25 fps, resulting in incorrect
animation speed.
Acknowledgments
---------------
This work is based on an original patch by Peter Xia <[email protected]>:
https://patchwork.ffmpeg.org/project/ffmpeg/patch/[email protected]/
That patch has been substantially reworked: fixes for loop count,
timestamp tracking, frame rate handling, decoder reset logic,
flush packet handling, return value corrections, memory layout
optimization, version requirement adjustment, and FATE test coverage
were all added on top of the original decoder skeleton.
FATE Samples
------------
All sample files required by the FATE tests already exist in the
fate-suite repository under the webp/ directory:
webp/anim.webp
webp/anim_rgb_yuv.webp
webp/anim_yuv_rgb.webp
webp/dual_transform.webp
webp/rgb_lena_lossless.webp
webp/rgb_lossless.webp
webp/rgb_q80.webp
webp/rgba_lossless.webp
webp/rgba_q80.webp
Test Environment
----------------
Tested on the following configuration:
- FFmpeg master: 1356714d11b2885edfe7cdc26cb7cb256ea2c485
("avcodec/nvenc: force frameIntervalP=1 for H.264 Baseline profile")
- OS: Ubuntu 24.04 (WSL2)
- Compiler: gcc 14.2.0
- libwebp: 1.6.0 / libwebpdemux 1.6.0
- NASM: 2.16.01
- FATE samples: fate-suite
- All 10 libwebp FATE tests pass (make fate-libwebp)
Note on Language
----------------
English is not my native language. Both the commit messages and this
cover letter were drafted with the assistance of an AI writing tool.
heipa (6):
avcodec/libwebpdec: add animated WebP decoding support
avcodec/libwebpdec: fix decode return value and empty packet handling
avcodec/libwebpdec: fix loop count, timestamp, framerate and decoder
reset logic
avcodec/libwebpdec: optimize memory layout and remove dead code
avcodec/libwebp_decoder: lower version requirement and use public API
tests/fate: add FATE tests for the libwebp decoder
Changelog | 1 +
configure | 4 +-
doc/general_contents.texi | 2 +-
libavcodec/Makefile | 1 +
libavcodec/allcodecs.c | 2 +
libavcodec/libwebpdec.c | 317 ++++++++++++++++++
libavcodec/version.h | 2 +-
tests/Makefile | 1 +
tests/fate/libwebp.mak | 40 +++
tests/ref/fate/libwebp-anim | 22 ++
tests/ref/fate/libwebp-anim-ignore-loop | 22 ++
tests/ref/fate/libwebp-anim-rgb-yuv | 23 ++
tests/ref/fate/libwebp-anim-yuv-rgb | 82 +++++
tests/ref/fate/libwebp-rgb-lena-lossless | 6 +
tests/ref/fate/libwebp-rgb-lossless | 6 +
.../libwebp-rgb-lossless-palette-predictor | 6 +
tests/ref/fate/libwebp-rgb-lossy-q80 | 6 +
tests/ref/fate/libwebp-rgba-lossless | 6 +
tests/ref/fate/libwebp-rgba-lossy-q80 | 6 +
19 files changed, 552 insertions(+), 3 deletions(-)
create mode 100644 libavcodec/libwebpdec.c
create mode 100644 tests/fate/libwebp.mak
create mode 100644 tests/ref/fate/libwebp-anim
create mode 100644 tests/ref/fate/libwebp-anim-ignore-loop
create mode 100644 tests/ref/fate/libwebp-anim-rgb-yuv
create mode 100644 tests/ref/fate/libwebp-anim-yuv-rgb
create mode 100644 tests/ref/fate/libwebp-rgb-lena-lossless
create mode 100644 tests/ref/fate/libwebp-rgb-lossless
create mode 100644 tests/ref/fate/libwebp-rgb-lossless-palette-predictor
create mode 100644 tests/ref/fate/libwebp-rgb-lossy-q80
create mode 100644 tests/ref/fate/libwebp-rgba-lossless
create mode 100644 tests/ref/fate/libwebp-rgba-lossy-q80
--
2.43.0
_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]