From: heipa <[email protected]>

---
 Changelog                 |  2 +-
 configure                 |  2 +-
 doc/general_contents.texi |  2 +-
 libavcodec/allcodecs.c    |  1 +
 libavcodec/libwebpdec.c   | 11 ++++++++++-
 libavcodec/version.h      |  2 +-
 6 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/Changelog b/Changelog
index 63c00de..e0a4bb6 100644
--- a/Changelog
+++ b/Changelog
@@ -10,7 +10,7 @@ version <next>:
 - transpose_cuda filter
 - Add AMF Frame Rate Converter (vf_frc_amf) filter
 - SMPTE 2094-50 metadata support and passthrough
-- animated WebP decoding support via libwebpdemux
+- animated WebP decoding support via libwebp
 - ProRes RAW VideoToolbox hwaccel
 
 
diff --git a/configure b/configure
index 9ec9a37..d225fa5 100755
--- a/configure
+++ b/configure
@@ -7499,7 +7499,7 @@ enabled libvvenc          && require_pkg_config libvvenc 
"libvvenc >= 1.6.1" "vv
 enabled libwebp           && {
     enabled libwebp_encoder      && require_pkg_config libwebp "libwebp >= 
0.2.0" webp/encode.h WebPGetEncoderVersion
     enabled libwebp_anim_encoder && check_pkg_config libwebp_anim_encoder 
"libwebpmux >= 0.4.0" webp/mux.h WebPAnimEncoderOptionsInit
-    enabled libwebp_decoder      && check_pkg_config libwebp_decoder 
"libwebpdemux >= 1.5.0" webp/demux.h WebPAnimDecoderOptionsInitInternal; }
+    enabled libwebp_decoder      && check_pkg_config libwebp_decoder 
"libwebpdemux >= 0.5.0" webp/demux.h WebPAnimDecoderOptionsInit; }
 enabled libx264           && require_pkg_config libx264 x264 "stdint.h x264.h" 
x264_encoder_encode &&
                              require_cpp_condition libx264 x264.h "X264_BUILD 
>= 155" && {
                              [ "$toolchain" != "msvc" ] ||
diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index 83a41a5..899b4b6 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -878,7 +878,7 @@ following image formats are supported:
 @item WBMP         @tab X @tab X
     @tab Wireless Application Protocol Bitmap image format
 @item WebP         @tab E @tab X
-    @tab WebP image format, supported through external library libwebp
+    @tab WebP image format encoding and animated decoding supported through 
external library libwebp
 @item XBM  @tab X @tab X
     @tab X BitMap image format
 @item XFace @tab X @tab X
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 424e0f6..0b84d0e 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -396,6 +396,7 @@ extern const FFCodec ff_vqc_decoder;
 extern const FFCodec ff_vvc_decoder;
 extern const FFCodec ff_wbmp_decoder;
 extern const FFCodec ff_wbmp_encoder;
+/* preferred over native webp */
 extern const FFCodec ff_libwebp_decoder;
 extern const FFCodec ff_webp_decoder;
 extern const FFCodec ff_wcmv_decoder;
diff --git a/libavcodec/libwebpdec.c b/libavcodec/libwebpdec.c
index b19d5b0..00b603c 100644
--- a/libavcodec/libwebpdec.c
+++ b/libavcodec/libwebpdec.c
@@ -102,7 +102,8 @@ static av_cold int libwebp_decode_init(AVCodecContext 
*avctx)
  * @param p          output AVFrame to fill
  * @param got_frame  set to 1 if a frame was produced, 0 otherwise
  * @param avpkt      input packet (used on first call only)
- * @return 0 on success or when no more frames are available,
+ * @return positive number of bytes consumed from avpkt on the final frame,
+ *         0 when more frames can be decoded or no more frames are available,
  *         negative AVERROR on failure
  */
 static int libwebp_decode_frame(AVCodecContext *avctx, AVFrame *p,
@@ -159,6 +160,8 @@ static int libwebp_decode_frame(AVCodecContext *avctx, 
AVFrame *p,
         avctx->height = anim_info.canvas_height;
         avctx->coded_height = anim_info.canvas_height;
     } else if (!avpkt || avpkt->size <= 0) {
+        /* Flush packet: if the decoder has exhausted all frames,
+         * advance the loop and reset for the next iteration. */
         if (!WebPAnimDecoderHasMoreFrames(s->dec)) {
             s->timestamp_offset += s->prev_timestamp_ms;
             s->loop_sent++;
@@ -174,6 +177,8 @@ static int libwebp_decode_frame(AVCodecContext *avctx, 
AVFrame *p,
         }
     }
 
+    /* The previous GetNext call may have exhausted the last frame;
+     * if so, advance the loop and reset before fetching the next frame. */
     if (!WebPAnimDecoderHasMoreFrames(s->dec)) {
         s->timestamp_offset += s->prev_timestamp_ms;
         s->loop_sent++;
@@ -240,6 +245,10 @@ static int libwebp_decode_frame(AVCodecContext *avctx, 
AVFrame *p,
 /**
  * Close the libwebp decoder and release all resources.
  *
+ * Deletes the underlying WebPAnimDecoder instance and releases
+ * the reference to the input packet buffer, ensuring all memory
+ * allocated during decoding is freed.
+ *
  * @param avctx  codec context
  * @return 0 on success
  */
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 0ef6c99..1008fea 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #include "version_major.h"
 
-#define LIBAVCODEC_VERSION_MINOR  34
+#define LIBAVCODEC_VERSION_MINOR  35
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to