nareshmlx/opencv-pr huggingface dataset:
**File:** modules/imgcodecs/src/grfmt_png.cpp
**Change Type:** modified
**Context:** PR #25715: Animated PNG Support

**Code Changes:**
```diff
@@ -51,21 +51,66 @@
     and png2bmp sample from libpng distribution (Copyright (C) 1999-2001 MIYASAKA Masaru)
 \****************************************************************************************/
 
+/****************************************************************************\
+ *
+ *  this file includes some modified part of apngasm and APNG Optimizer 1.4
+ *  both have zlib license.
+ *
+ ****************************************************************************/
```

Review comment:
i think next line do the job ``` if (fread(sig, 1, 8, m_f)) id = read_chunk(m_chunkIHDR); if (!(id == id_IHDR && m_chunkIHDR.size == 25)) return false; ```
**File:** modules/imgcodecs/src/grfmt_webp.hpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support
**Review Line:** 52

**Code Changes:**
```diff
@@ -49,6 +49,8 @@
 
 #include <fstream>
 
+struct WebPAnimDecoder;
+
 namespace cv
 {
 
@@ -61,17 +63,24 @@ class WebPDecoder CV_FINAL : public BaseImageDecoder
```

Review comment:
If you forward declare the structs, no need to include the WebP headers.
**File:** modules/imgcodecs/src/grfmt_webp.cpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -44,17 +44,15 @@
 
 #include "precomp.hpp"
 
-#include <webp/decode.h>
-#include <webp/encode.h>
-
 #include <stdio.h>
 #include <limits.h>
-
```

Review comment:
No need to forward declare.
**File:** cmake/OpenCVFindWebP.cmake
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -10,8 +10,6 @@
 
 # Look for the header file.
 
-unset(WEBP_FOUND)
-
 FIND_PATH(WEBP_INCLUDE_DIR NAMES webp/decode.h)
 
 if(NOT WEBP_INCLUDE_DIR)
@@ -21,13 +19,14 @@ else()
```

Review comment:
You should only add webpmux and webpdemux if they are found. When building WebP from third_party, it is all bundled in one library. So: ```cmake if(WEBP_MUX_LIBRARY) SET(WEBP_LIBRARIES ${WEBP_LIBRARY} ${WEBP_MUX_LIBRARY}) endif() ```
**File:** cmake/OpenCVFindWebP.cmake
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -10,8 +10,6 @@
 
 # Look for the header file.
 
-unset(WEBP_FOUND)
-
 FIND_PATH(WEBP_INCLUDE_DIR NAMES webp/decode.h)
 
 if(NOT WEBP_INCLUDE_DIR)
@@ -21,13 +19,14 @@ else()
```

Review comment:
SET(WEBP_LIBRARIES ${WEBP_LIBRARY}) if(WEBP_MUX_LIBRARY) SET(WEBP_LIBRARIES ${WEBP_LIBRARIES} ${WEBP_MUX_LIBRARY} ${WEBP_DEMUX_LIBRARY}) endif()
**File:** modules/imgcodecs/src/grfmt_webp.hpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -49,6 +49,8 @@
 
 #include <fstream>
 
+struct WebPAnimDecoder;
+
 namespace cv
 {
 
@@ -61,17 +63,24 @@ class WebPDecoder CV_FINAL : public BaseImageDecoder
```

Review comment:
Do not include webp here, just forward declare `WebPAnimEncoder` and `WebPAnimDecoder` (`struct WebPAnimEncoder;`)
**File:** cmake/OpenCVFindWebP.cmake
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support
**Review Line:** 13

**Code Changes:**
```diff
 
 # Look for the header file.
 
-unset(WEBP_FOUND)
-
 FIND_PATH(WEBP_INCLUDE_DIR NAMES webp/decode.h)
 
 if(NOT WEBP_INCLUDE_DIR)
@@ -21,13 +19,14 @@ else()
 
     # Look for the library.
```

Review comment:
do not unset that if you want the CI to pass.
**File:** cmake/OpenCVFindWebP.cmake
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support
**Review Line:** 13

**Code Changes:**
```diff
 
 # Look for the header file.
 
-unset(WEBP_FOUND)
-
 FIND_PATH(WEBP_INCLUDE_DIR NAMES webp/decode.h)
 
 if(NOT WEBP_INCLUDE_DIR)
@@ -21,13 +19,14 @@ else()
 
     # Look for the library.
```

Review comment:
i think Webp version of buildbot should be updated.
**File:** cmake/OpenCVFindLibsGrfmt.cmake
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support
**Review Line:** 200

**Code Changes:**
```diff
-  if(EXISTS "${WEBP_INCLUDE_DIR}/enc/vp8enci.h")
-    ocv_parse_header("${WEBP_INCLUDE_DIR}/enc/vp8enci.h" WEBP_VERSION_LINES ENC_MAJ_VERSION ENC_MIN_VERSION ENC_REV_VERSION)
-    set(WEBP_VERSION "${ENC_MAJ_VERSION}.${ENC_MIN_VERSION}.${ENC_REV_VERSION}")
-  elseif(EXISTS "${WEBP_INCLUDE_DIR}/webp/encode.h")
+  if(EXISTS "${WEBP_INCLUDE_DIR}/webp/encode.h")
     file(STRINGS "${WEBP_INCLUDE_DIR}/webp/encode.h" WEBP_ENCODER_ABI_VERSION REGEX "#define[ \t]+WEBP_ENCODER_ABI_VERSION[ \t]+([x0-9a-f]+)" )
     if(WEBP_ENCODER_ABI_VERSION MATCHES "#define[ \t]+WEBP_ENCODER_ABI_VERSION[ \t]+([x0-9a-f]+)")
         set(WEBP_ENCODER_ABI_VERSION "${CMAKE_MATCH_1}")
-        set(WEBP_VERSION "encoder: ${WEBP_ENCODER_ABI_VERSION}")
     else()
       unset(WEBP_ENCODER_ABI_VERSION)
```

Review comment:
Indeed, that check should go, this is from WebP 0.5.2 (2017).... https://chromium.googlesource.com/webm/libwebp/+/668e1dd44f7594610b805f8ef8b7d7964777d3e2 It is rather harmless though, did you have a problem with it?
**File:** modules/imgcodecs/src/grfmt_webp.cpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -44,17 +44,15 @@
 
 #include "precomp.hpp"
 
-#include <webp/decode.h>
-#include <webp/encode.h>
-
 #include <stdio.h>
 #include <limits.h>
-
```

Review comment:
You are missing a WebPAnimDecoderDelete. Either you create a destructor for WebPDecoder, either you wrap the pointer in a unique_ptr. E.g., create in the header, a private struct: ```cpp struct UniquePtrDeleter { void operator()(WebPAnimDecoder * decoder) const { WebPAnimDecoderDelete(decoder); } void operator()(WebpData * dara) const { WebPDataClear(decoder); } }; // Use these unique_ptr to ensure the structs are automatically destroyed. std::unique_ptr<WebPAnimDecoder, UniquePtrDeleter> anim_decoder; // or create a type: using DataPtr = std::unique_ptr<WebPData, UniquePtrDeleter>; ``` I'd go with this, so that you do not have to remember to call a destructor.
**File:** modules/imgcodecs/src/grfmt_webp.cpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -44,17 +44,15 @@
 
 #include "precomp.hpp"
 
-#include <webp/decode.h>
-#include <webp/encode.h>
-
 #include <stdio.h>
 #include <limits.h>
-
```

Review comment:
When calling the WebP API you need to get a pointer so if you have a `std::unique_ptr<WebPAnimDecoder, UniquePtrDeleter> anim_decoder;`, just call `anim_decoder.get()`
**File:** cmake/OpenCVFindWebP.cmake
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -10,8 +10,6 @@
 
 # Look for the header file.
 
-unset(WEBP_FOUND)
-
 FIND_PATH(WEBP_INCLUDE_DIR NAMES webp/decode.h)
 
 if(NOT WEBP_INCLUDE_DIR)
@@ -21,13 +19,14 @@ else()
```

Review comment:
What are you trying to check here? How old is an invalid WebP version?
**File:** modules/imgcodecs/test/test_webp.cpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -7,23 +7,9 @@ namespace opencv_test { namespace {
 
 #ifdef HAVE_WEBP
 
-TEST(Imgcodecs_WebP, encode_decode_lossless_webp)
+static void readFileBytes(const std::string& fname, std::vector<unsigned char>& buf)
 {
-    const string root = cvtest::TS::ptr()->get_data_path();
-    string filename = root + "../cv/shared/lena.png";
-    cv::Mat img = cv::imread(filename);
```

Review comment:
Also compare the bgcolor and all the other members.
**File:** cmake/OpenCVFindWebP.cmake
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -10,8 +10,6 @@
 
 # Look for the header file.
 
-unset(WEBP_FOUND)
-
 FIND_PATH(WEBP_INCLUDE_DIR NAMES webp/decode.h)
 
 if(NOT WEBP_INCLUDE_DIR)
@@ -21,13 +19,14 @@ else()
```

Review comment:
It will be clearer to use https://cmake.org/cmake/help/latest/module/CheckCXXSourceCompiles.html here, instead of adding a new file to the source tree.
**File:** modules/imgcodecs/src/grfmt_webp.cpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -44,17 +44,15 @@
 
 #include "precomp.hpp"
 
-#include <webp/decode.h>
-#include <webp/encode.h>
-
 #include <stdio.h>
 #include <limits.h>
-
```

Review comment:
Just to reduce the imbricated `if` , write it as: ```cpp if (VP8_STATUS_OK == WebPGetFeatures(header, sizeof(header), &features)) return false; ``` And then you can remove the big `{}` below.
**File:** modules/imgcodecs/src/grfmt_webp.cpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support
**Review Line:** 188

**Code Changes:**
```diff
@@ -155,7 +185,7 @@ bool WebPDecoder::readData(Mat &img)
     CV_CheckEQ(img.cols, m_width, "");
     CV_CheckEQ(img.rows, m_height, "");
 
-    if (m_buf.empty())
+    if (data.empty())
     {
         fs.seekg(0, std::ios::beg); CV_Assert(fs && "File stream error");
         data.create(1, validateToInt(fs_size), CV_8UC1);
@@ -165,70 +195,96 @@ bool WebPDecoder::readData(Mat &img)
     }
```

Review comment:
That should still be m_buf no ?
**File:** modules/imgcodecs/src/grfmt_webp.cpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -44,17 +44,15 @@
 
 #include "precomp.hpp"
 
-#include <webp/decode.h>
-#include <webp/encode.h>
-
 #include <stdio.h>
 #include <limits.h>
-
```

Review comment:
That is only if there is alpha. Otherwise, it should be BGR
**File:** modules/imgcodecs/src/grfmt_webp.cpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -44,17 +44,15 @@
 
 #include "precomp.hpp"
 
-#include <webp/decode.h>
-#include <webp/encode.h>
-
 #include <stdio.h>
 #include <limits.h>
-
```

Review comment:
should i mark this as resolved?
**File:** modules/imgcodecs/src/grfmt_webp.cpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support
**Review Line:** 188

**Code Changes:**
```diff
@@ -155,7 +185,7 @@ bool WebPDecoder::readData(Mat &img)
     CV_CheckEQ(img.cols, m_width, "");
     CV_CheckEQ(img.rows, m_height, "");
 
-    if (m_buf.empty())
+    if (data.empty())
     {
         fs.seekg(0, std::ios::beg); CV_Assert(fs && "File stream error");
         data.create(1, validateToInt(fs_size), CV_8UC1);
@@ -165,70 +195,96 @@ bool WebPDecoder::readData(Mat &img)
     }
```

Review comment:
if (m_buf.empty()) don't pass tests.. m_buf is related with imdecode and imencode which i did not focused yet.
**File:** cmake/OpenCVFindWebP.cmake
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -10,8 +10,6 @@
 
 # Look for the header file.
 
-unset(WEBP_FOUND)
-
 FIND_PATH(WEBP_INCLUDE_DIR NAMES webp/decode.h)
 
 if(NOT WEBP_INCLUDE_DIR)
@@ -21,13 +19,14 @@ else()
```

Review comment:
Thx for checking ! Forget about that then.
**File:** modules/imgcodecs/src/grfmt_webp.hpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -49,6 +49,8 @@
 
 #include <fstream>
 
+struct WebPAnimDecoder;
+
 namespace cv
 {
 
@@ -61,17 +63,24 @@ class WebPDecoder CV_FINAL : public BaseImageDecoder
```

Review comment:
Please add the same thing for data and encoder: ``` void operator()(WebPData* data) const { WebPDataClear(data); } ``` And you can then use it internally when creating a unique_ptr (or use a typedef to that) ``` typedef std::unique_ptr<WebPAnimDecoder, UniquePtrDeleter> AnimDecoder; ``` If you only use those once, no need indeed to create the UniquePtrDeleter and just do what you already did for the encoder.
**File:** modules/imgcodecs/src/grfmt_webp.cpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -44,17 +44,15 @@
 
 #include "precomp.hpp"
 
-#include <webp/decode.h>
-#include <webp/encode.h>
-
 #include <stdio.h>
 #include <limits.h>
-
```

Review comment:
Just do the same thing for data and encoder (or maybe simply do what you did for the encoder, by using a full unique_ptr definition if you only use those once in the code.
**File:** modules/imgcodecs/src/grfmt_webp.cpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -44,17 +44,15 @@
 
 #include "precomp.hpp"
 
-#include <webp/decode.h>
-#include <webp/encode.h>
-
 #include <stdio.h>
 #include <limits.h>
-
```

Review comment:
I'd say the second one.
**File:** modules/imgcodecs/src/grfmt_webp.hpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -49,6 +49,8 @@
 
 #include <fstream>
 
+struct WebPAnimDecoder;
+
 namespace cv
 {
 
@@ -61,17 +63,24 @@ class WebPDecoder CV_FINAL : public BaseImageDecoder
```

Review comment:
animinfo -> anim
**File:** modules/imgcodecs/test/test_webp.cpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -7,23 +7,9 @@ namespace opencv_test { namespace {
 
 #ifdef HAVE_WEBP
 
-TEST(Imgcodecs_WebP, encode_decode_lossless_webp)
+static void readFileBytes(const std::string& fname, std::vector<unsigned char>& buf)
 {
-    const string root = cvtest::TS::ptr()->get_data_path();
-    string filename = root + "../cv/shared/lena.png";
-    cv::Mat img = cv::imread(filename);
```

Review comment:
Is that image standard ?
**File:** modules/imgcodecs/src/grfmt_webp.cpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -44,17 +44,15 @@
 
 #include "precomp.hpp"
 
-#include <webp/decode.h>
-#include <webp/encode.h>
-
 #include <stdio.h>
 #include <limits.h>
-
```

Review comment:
This is the reason why I think writemulti should not support AVIF and WebP. Those are not multi-page formats (and yes, I added it for AVIF but now think that it should be removed)
**File:** modules/imgcodecs/src/grfmt_webp.hpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -49,6 +49,8 @@
 
 #include <fstream>
 
+struct WebPAnimDecoder;
+
 namespace cv
 {
 
@@ -61,17 +63,24 @@ class WebPDecoder CV_FINAL : public BaseImageDecoder
```

Review comment:
Defining `operator()` forces you to include the WebP headers here. Can you instead define it in the `.cpp` file ? And therefore forward declare `WebPAnimDecoder` in the header
**File:** modules/imgcodecs/include/opencv2/imgcodecs.hpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -218,6 +218,36 @@ enum ImwriteHDRCompressionFlags {
 
 //! @} imgcodecs_flags
 
+/** @brief Represents an animation with multiple frames.
+The `Animation` struct is designed to store and manage data for animated sequences such as those from animated formats (e.g., GIF, AVIF, APNG, WebP).
+It provides support for looping, background color settings, frame timing, and frame storage.
+*/
+struct CV_EXPORTS_W_SIMPLE Animation
+{
```

Review comment:
Let's stick to struct, they are easier to bind. Animations do not have 100 frames.
**File:** modules/imgcodecs/test/test_webp.cpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -7,23 +7,9 @@ namespace opencv_test { namespace {
 
 #ifdef HAVE_WEBP
 
-TEST(Imgcodecs_WebP, encode_decode_lossless_webp)
+static void readFileBytes(const std::string& fname, std::vector<unsigned char>& buf)
 {
-    const string root = cvtest::TS::ptr()->get_data_path();
-    string filename = root + "../cv/shared/lena.png";
-    cv::Mat img = cv::imread(filename);
```

Review comment:
here is the link of image https://opencv.org/wp-content/uploads/2020/07/OpenCV_logo_white_.png i resized it to speed up tests
**File:** modules/imgcodecs/include/opencv2/imgcodecs.hpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -218,6 +218,36 @@ enum ImwriteHDRCompressionFlags {
 
 //! @} imgcodecs_flags
 
+/** @brief Represents an animation with multiple frames.
+The `Animation` struct is designed to store and manage data for animated sequences such as those from animated formats (e.g., GIF, AVIF, APNG, WebP).
+It provides support for looping, background color settings, frame timing, and frame storage.
+*/
+struct CV_EXPORTS_W_SIMPLE Animation
+{
```

Review comment:
M.b. `cv::Scalar`? We use it everywhere for the same purpose. There is no issue with big-little endianess.
**File:** modules/imgcodecs/include/opencv2/imgcodecs.hpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -218,6 +218,36 @@ enum ImwriteHDRCompressionFlags {
 
 //! @} imgcodecs_flags
 
+/** @brief Represents an animation with multiple frames.
+The `Animation` struct is designed to store and manage data for animated sequences such as those from animated formats (e.g., GIF, AVIF, APNG, WebP).
+It provides support for looping, background color settings, frame timing, and frame storage.
+*/
+struct CV_EXPORTS_W_SIMPLE Animation
+{
```

Review comment:
Does it affect decoding? Please add note to the description.
**File:** modules/imgcodecs/test/test_webp.cpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -7,23 +7,9 @@ namespace opencv_test { namespace {
 
 #ifdef HAVE_WEBP
 
-TEST(Imgcodecs_WebP, encode_decode_lossless_webp)
+static void readFileBytes(const std::string& fname, std::vector<unsigned char>& buf)
 {
-    const string root = cvtest::TS::ptr()->get_data_path();
-    string filename = root + "../cv/shared/lena.png";
-    cv::Mat img = cv::imread(filename);
```

Review comment:
use OpenCV theRNG.
**File:** modules/imgcodecs/include/opencv2/imgcodecs.hpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -218,6 +218,36 @@ enum ImwriteHDRCompressionFlags {
 
 //! @} imgcodecs_flags
 
+/** @brief Represents an animation with multiple frames.
+The `Animation` struct is designed to store and manage data for animated sequences such as those from animated formats (e.g., GIF, AVIF, APNG, WebP).
+It provides support for looping, background color settings, frame timing, and frame storage.
+*/
+struct CV_EXPORTS_W_SIMPLE Animation
+{
```

Review comment:
That should be an extra parameter in imwriteanimation because it is not filled by imreadanimation
**File:** modules/imgcodecs/include/opencv2/imgcodecs.hpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -218,6 +218,36 @@ enum ImwriteHDRCompressionFlags {
 
 //! @} imgcodecs_flags
 
+/** @brief Represents an animation with multiple frames.
+The `Animation` struct is designed to store and manage data for animated sequences such as those from animated formats (e.g., GIF, AVIF, APNG, WebP).
+It provides support for looping, background color settings, frame timing, and frame storage.
+*/
+struct CV_EXPORTS_W_SIMPLE Animation
+{
```

Review comment:
i will remove it. IMWRITE_WEBP_QUALITY parameter does the job.
**File:** modules/imgcodecs/test/test_webp.cpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -7,23 +7,9 @@ namespace opencv_test { namespace {
 
 #ifdef HAVE_WEBP
 
-TEST(Imgcodecs_WebP, encode_decode_lossless_webp)
+static void readFileBytes(const std::string& fname, std::vector<unsigned char>& buf)
 {
-    const string root = cvtest::TS::ptr()->get_data_path();
-    string filename = root + "../cv/shared/lena.png";
-    cv::Mat img = cv::imread(filename);
```

Review comment:
Please create PR in opencv_extra with the same branch name.
**File:** modules/imgcodecs/test/test_webp.cpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -7,23 +7,9 @@ namespace opencv_test { namespace {
 
 #ifdef HAVE_WEBP
 
-TEST(Imgcodecs_WebP, encode_decode_lossless_webp)
+static void readFileBytes(const std::string& fname, std::vector<unsigned char>& buf)
 {
-    const string root = cvtest::TS::ptr()->get_data_path();
-    string filename = root + "../cv/shared/lena.png";
-    cv::Mat img = cv::imread(filename);
```

Review comment:
I propose to switch to some existing file in opencv_extra. It grows too fast this days.
**File:** cmake/OpenCVFindWebP.cmake
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -10,8 +10,6 @@
 
 # Look for the header file.
 
-unset(WEBP_FOUND)
-
 FIND_PATH(WEBP_INCLUDE_DIR NAMES webp/decode.h)
 
 if(NOT WEBP_INCLUDE_DIR)
@@ -21,13 +19,14 @@ else()
```

Review comment:
The check is redundant.
**File:** modules/imgcodecs/src/grfmt_webp.cpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support
**Review Line:** 461

**Code Changes:**
```diff
+    std::unique_ptr<WebPAnimEncoder, void (*)(WebPAnimEncoder*)> anim_encoder(
+        WebPAnimEncoderNew(width, height, &anim_config), WebPAnimEncoderDelete);
+
+    pic.width = width;
+    pic.height = height;
+    pic.use_argb = 1;
+    pic.argb_stride = width;
+    WebPEncode(&config, &pic);
+
+    bool is_input_rgba = animation.frames[0].channels() == 4;
+    Size canvas_size = Size(animation.frames[0].cols,animation.frames[0].rows);
```

Review comment:
Looks like the sanitizer issue is related to the flag. The encoder always expects alpha channel, even, ig input matrices have CV_8UC3 type.
**File:** modules/imgcodecs/src/grfmt_webp.cpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support
**Review Line:** 461

**Code Changes:**
```diff
+    std::unique_ptr<WebPAnimEncoder, void (*)(WebPAnimEncoder*)> anim_encoder(
+        WebPAnimEncoderNew(width, height, &anim_config), WebPAnimEncoderDelete);
+
+    pic.width = width;
+    pic.height = height;
+    pic.use_argb = 1;
+    pic.argb_stride = width;
+    WebPEncode(&config, &pic);
+
+    bool is_input_rgba = animation.frames[0].channels() == 4;
+    Size canvas_size = Size(animation.frames[0].cols,animation.frames[0].rows);
```

Review comment:
> Looks like the sanitizer issue is related to the flag. The encoder always expects alpha channel, even, ig input matrices have CV_8UC3 type. There are two possible solutions: either assert if the input is 8UC3, or convert 8UC3 to 8UC4. I believe converting 8UC3 to 8UC4 is the better approach.
**File:** samples/python/tutorial_code/imgcodecs/animations.py
**Change Type:** added
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -0,0 +1,52 @@
+import cv2 as cv
+import numpy as np
+
+def main(filename):
+    ## [write_animation]
+    if filename == "animated_image.webp":
+        # Create an Animation instance to save
+        animation_to_save = cv.Animation()
+
```

Review comment:
timestamp is not incremented in the loop
**File:** samples/cpp/tutorial_code/imgcodecs/animations.cpp
**Change Type:** added
**Context:** PR #25608: Animated WebP and AVIF Support

**Code Changes:**
```diff
@@ -0,0 +1,51 @@
+#include <opencv2/highgui.hpp>
+#include <opencv2/imgcodecs.hpp>
+#include <opencv2/imgproc.hpp>
+#include <iostream>
+
+using namespace cv;
+
+int main( int argc, const char** argv )
+{
```

Review comment:
Timestamp is not incremented.
**File:** modules/imgcodecs/test/test_webp.cpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support
**Review Line:** 210

**Code Changes:**
```diff
+    EXPECT_EQ(0, cvtest::norm(l_animation.frames[5], l_animation.frames[14], NORM_INF));
+    EXPECT_EQ(0, cvtest::norm(l_animation.frames[6], l_animation.frames[15], NORM_INF));
+    EXPECT_EQ(0, cvtest::norm(l_animation.frames[7], l_animation.frames[16], NORM_INF));
+
+    // Verify whether the imread function successfully loads the first frame
+    Mat frame = imread(output, IMREAD_UNCHANGED);
+    EXPECT_EQ(0, cvtest::norm(l_animation.frames[0], frame, NORM_INF));
+
+    std::vector<uchar> buf;
+    readFileBytes(output, buf);
+    vector<Mat> webp_frames;
```

Review comment:
Let's extact it as another test case.