nareshmlx/opencv-pr huggingface dataset:
**File:** 3rdparty/hal_rvv/hal_rvv_1p0/dxt.hpp
**Change Type:** added
**Context:** PR #26865: Add RISC-V HAL implementation for cv::dft and cv::dct

**Code Changes:**
```diff
@@ -0,0 +1,569 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+#ifndef OPENCV_HAL_RVV_DXT_HPP_INCLUDED
+#define OPENCV_HAL_RVV_DXT_HPP_INCLUDED
+
+#include <riscv_vector.h>
+
+namespace cv { namespace cv_hal_rvv { namespace dxt {
```

Review comment:
Usually we do not indent code inside namespaced: ```.cpp namespace myns { void exampleFunction(); } ```
**File:** 3rdparty/hal_rvv/hal_rvv_1p0/dxt.hpp
**Change Type:** added
**Context:** PR #26865: Add RISC-V HAL implementation for cv::dft and cv::dct

**Code Changes:**
```diff
@@ -0,0 +1,569 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+#ifndef OPENCV_HAL_RVV_DXT_HPP_INCLUDED
+#define OPENCV_HAL_RVV_DXT_HPP_INCLUDED
+
+#include <riscv_vector.h>
+
+namespace cv { namespace cv_hal_rvv { namespace dxt {
```

Review comment:
Perhaps eventually it would make sense to unify this helper structure with others (minmax) and move it to separate header.
**File:** 3rdparty/hal_rvv/hal_rvv_1p0/dxt.hpp
**Change Type:** added
**Context:** PR #26865: Add RISC-V HAL implementation for cv::dft and cv::dct

**Code Changes:**
```diff
@@ -0,0 +1,569 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+#ifndef OPENCV_HAL_RVV_DXT_HPP_INCLUDED
+#define OPENCV_HAL_RVV_DXT_HPP_INCLUDED
+
+#include <riscv_vector.h>
+
+namespace cv { namespace cv_hal_rvv { namespace dxt {
```

Review comment:
Technically this macro is not available for HAL implementations - only things from `*/hal/interface.h` should be used. It works because this HAL is header-only and is included after cvdef.h.
**File:** 3rdparty/hal_rvv/hal_rvv_1p0/dxt.hpp
**Change Type:** added
**Context:** PR #26865: Add RISC-V HAL implementation for cv::dft and cv::dct

**Code Changes:**
```diff
@@ -0,0 +1,569 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+#ifndef OPENCV_HAL_RVV_DXT_HPP_INCLUDED
+#define OPENCV_HAL_RVV_DXT_HPP_INCLUDED
+
+#include <riscv_vector.h>
+
+namespace cv { namespace cv_hal_rvv { namespace dxt {
```

Review comment:
It would be hard to unify because different algorithms need different EMUL to achieve best performance.
**File:** 3rdparty/hal_rvv/hal_rvv_1p0/minmax.hpp
**Change Type:** modified
**Context:** PR #26865: Add RISC-V HAL implementation for cv::dft and cv::dct
**Review Line:** 9

**Code Changes:**
```diff
+#define OPENCV_HAL_RVV_MINMAX_HPP_INCLUDED
 
 #include <riscv_vector.h>
 
-namespace cv { namespace cv_hal_rvv {
+namespace cv { namespace cv_hal_rvv { namespace minmax {
 
 #undef cv_hal_minMaxIdx
-#define cv_hal_minMaxIdx cv::cv_hal_rvv::minMaxIdx
+#define cv_hal_minMaxIdx cv::cv_hal_rvv::minmax::minMaxIdx
 #undef cv_hal_minMaxIdxMaskStep
```

Review comment:
Reasons to add yet another layer of namespace? It breaks all the current code. Revert this and other changes on adding namespaces if possible.
**File:** 3rdparty/hal_rvv/hal_rvv_1p0/minmax.hpp
**Change Type:** modified
**Context:** PR #26865: Add RISC-V HAL implementation for cv::dft and cv::dct
**Review Line:** 9

**Code Changes:**
```diff
+#define OPENCV_HAL_RVV_MINMAX_HPP_INCLUDED
 
 #include <riscv_vector.h>
 
-namespace cv { namespace cv_hal_rvv {
+namespace cv { namespace cv_hal_rvv { namespace minmax {
 
 #undef cv_hal_minMaxIdx
-#define cv_hal_minMaxIdx cv::cv_hal_rvv::minMaxIdx
+#define cv_hal_minMaxIdx cv::cv_hal_rvv::minmax::minMaxIdx
 #undef cv_hal_minMaxIdxMaskStep
```

Review comment:
There will be naming conflicts about `template rvv<T>`. If there is no namespace (using anonymous space cannot solve the problem), there will be names such as `rvv_dxt` and `rvv_minmax`. In addition, some HAL implementations have some singleton classes, and I think it is inappropriate to expose these classes in `cv_hal_rvv`.
**File:** 3rdparty/hal_rvv/hal_rvv_1p0/minmax.hpp
**Change Type:** modified
**Context:** PR #26865: Add RISC-V HAL implementation for cv::dft and cv::dct
**Review Line:** 9

**Code Changes:**
```diff
+#define OPENCV_HAL_RVV_MINMAX_HPP_INCLUDED
 
 #include <riscv_vector.h>
 
-namespace cv { namespace cv_hal_rvv {
+namespace cv { namespace cv_hal_rvv { namespace minmax {
 
 #undef cv_hal_minMaxIdx
-#define cv_hal_minMaxIdx cv::cv_hal_rvv::minMaxIdx
+#define cv_hal_minMaxIdx cv::cv_hal_rvv::minmax::minMaxIdx
 #undef cv_hal_minMaxIdxMaskStep
```

Review comment:
There are already several interfaces added. Your change is not complete and I propose to do it in a separate PR if you want to. This PR seems to be fine without this namespace change.
**File:** 3rdparty/hal_rvv/hal_rvv_1p0/minmax.hpp
**Change Type:** modified
**Context:** PR #26865: Add RISC-V HAL implementation for cv::dft and cv::dct
**Review Line:** 9

**Code Changes:**
```diff
+#define OPENCV_HAL_RVV_MINMAX_HPP_INCLUDED
 
 #include <riscv_vector.h>
 
-namespace cv { namespace cv_hal_rvv {
+namespace cv { namespace cv_hal_rvv { namespace minmax {
 
 #undef cv_hal_minMaxIdx
-#define cv_hal_minMaxIdx cv::cv_hal_rvv::minMaxIdx
+#define cv_hal_minMaxIdx cv::cv_hal_rvv::minmax::minMaxIdx
 #undef cv_hal_minMaxIdxMaskStep
```

Review comment:
Do you think I should use `rvv_dxt` and `rvv_minmax`? Or should I keep the `namespace dxt` in this PR and keep `minmax.hpp` without namespace?
**File:** 3rdparty/hal_rvv/hal_rvv_1p0/minmax.hpp
**Change Type:** modified
**Context:** PR #26865: Add RISC-V HAL implementation for cv::dft and cv::dct
**Review Line:** 9

**Code Changes:**
```diff
+#define OPENCV_HAL_RVV_MINMAX_HPP_INCLUDED
 
 #include <riscv_vector.h>
 
-namespace cv { namespace cv_hal_rvv {
+namespace cv { namespace cv_hal_rvv { namespace minmax {
 
 #undef cv_hal_minMaxIdx
-#define cv_hal_minMaxIdx cv::cv_hal_rvv::minMaxIdx
+#define cv_hal_minMaxIdx cv::cv_hal_rvv::minmax::minMaxIdx
 #undef cv_hal_minMaxIdxMaskStep
```

Review comment:
> There will be naming conflicts about template rvv<T> Could you give me an example to demonstrate the problem? --- > Or should I keep the namespace dxt in this PR and keep minmax.hpp without namespace? I don't see problem with this solution for now.
**File:** 3rdparty/hal_rvv/hal_rvv_1p0/minmax.hpp
**Change Type:** modified
**Context:** PR #26865: Add RISC-V HAL implementation for cv::dft and cv::dct
**Review Line:** 9

**Code Changes:**
```diff
+#define OPENCV_HAL_RVV_MINMAX_HPP_INCLUDED
 
 #include <riscv_vector.h>
 
-namespace cv { namespace cv_hal_rvv {
+namespace cv { namespace cv_hal_rvv { namespace minmax {
 
 #undef cv_hal_minMaxIdx
-#define cv_hal_minMaxIdx cv::cv_hal_rvv::minMaxIdx
+#define cv_hal_minMaxIdx cv::cv_hal_rvv::minmax::minMaxIdx
 #undef cv_hal_minMaxIdxMaskStep
```

Review comment:
```cpp mimmax.hpp: #pragma once namespace cv { namespace cv_hal_rvv { template<typename T> rvv; template<> rvv<int> { ... }; }} dxt.hpp: #pragma once namespace cv { namespace cv_hal_rvv { template<typename T> rvv; template<> rvv<int> { ... }; }} hal_rvv.hpp: #include "hal_rvv_1p0/minmax.hpp" #include "hal_rvv_1p0/dxt.hpp" xxxx.cpp: #include "hal_rvv.hpp" // error ```
**File:** 3rdparty/hal_rvv/hal_rvv_1p0/minmax.hpp
**Change Type:** modified
**Context:** PR #26865: Add RISC-V HAL implementation for cv::dft and cv::dct
**Review Line:** 9

**Code Changes:**
```diff
+#define OPENCV_HAL_RVV_MINMAX_HPP_INCLUDED
 
 #include <riscv_vector.h>
 
-namespace cv { namespace cv_hal_rvv {
+namespace cv { namespace cv_hal_rvv { namespace minmax {
 
 #undef cv_hal_minMaxIdx
-#define cv_hal_minMaxIdx cv::cv_hal_rvv::minMaxIdx
+#define cv_hal_minMaxIdx cv::cv_hal_rvv::minmax::minMaxIdx
 #undef cv_hal_minMaxIdxMaskStep
```

Review comment:
> There are already several interfaces added. Interfaces that don't have `rvv` structures don't have to make this change. The only thing that really needs to be changed right now is `minmax`.
**File:** modules/core/include/opencv2/core/hal/intrin_rvv_scalable.hpp
**Change Type:** modified
**Context:** PR #27006: Fix issues in RISC-V Vector (RVV) Universal Intrinsic

**Code Changes:**
```diff
@@ -8,6 +8,7 @@
 #ifndef OPENCV_HAL_INTRIN_RVV_SCALABLE_HPP
 #define OPENCV_HAL_INTRIN_RVV_SCALABLE_HPP
 
+#include <array>
 #include <opencv2/core/check.hpp>
 
 #if defined(__GNUC__) && !defined(__clang__)
@@ -62,8 +63,9 @@ struct VTraits<REG> \
 { \
```

Review comment:
What about using std::array to store `idx_interleave_quads` so that we can get array length instead of a fixed number here to avoid mistakes.
**File:** modules/core/test/test_intrin_utils.hpp
**Change Type:** modified
**Context:** PR #27006: Fix issues in RISC-V Vector (RVV) Universal Intrinsic
**Review Line:** 993

**Code Changes:**
```diff
-        dataC *= (LaneType)-1;
+        for (int i = 0; i < VTraits<R>::vlanes(); i++)
+        {
+            auto c_signed = dataC.as_int(i);
+            dataC[i] = (LaneType)(c_signed == 0 ? -1 : -std::abs(c_signed));
+        }
         R a = dataA, b = dataB, c = dataC, d = dataD, e = dataE;
         dataC[VTraits<R>::vlanes() - 1] = 0;
         R nl = dataC;
@@ -1905,7 +1917,7 @@ template<typename R> struct TheTest
                     EXPECT_TRUE(std::isnan(outputs[j]));
```

Review comment:
Why do we need to change that? ~~It is code for testing, all checks are below.~~ Code of input preparation - so it is OK.
**File:** modules/core/test/test_intrin_utils.hpp
**Change Type:** modified
**Context:** PR #27006: Fix issues in RISC-V Vector (RVV) Universal Intrinsic
**Review Line:** 993

**Code Changes:**
```diff
-        dataC *= (LaneType)-1;
+        for (int i = 0; i < VTraits<R>::vlanes(); i++)
+        {
+            auto c_signed = dataC.as_int(i);
+            dataC[i] = (LaneType)(c_signed == 0 ? -1 : -std::abs(c_signed));
+        }
         R a = dataA, b = dataB, c = dataC, d = dataD, e = dataE;
         dataC[VTraits<R>::vlanes() - 1] = 0;
         R nl = dataC;
@@ -1905,7 +1917,7 @@ template<typename R> struct TheTest
                     EXPECT_TRUE(std::isnan(outputs[j]));
```

Review comment:
Because we need `dataC` to be all negative numbers, then `v_check_all(c)` will be `true`. ``` R c = dataC; EXPECT_EQ(true, v_check_all(c)); ``` The previous `dataC *= (LaneType)-1;` cannot handle the case where the length of `dataC` greater than `128` for `int_8`
**File:** modules/imgcodecs/src/grfmt_png.cpp
**Change Type:** modified
**Context:** PR #26849: APNG encoding optimization

**Code Changes:**
```diff
@@ -814,6 +814,10 @@ PngEncoder::PngEncoder()
     next_seq_num = 0;
     trnssize = 0;
     palsize = 0;
+    m_compression_level = Z_BEST_SPEED;
+    m_compression_strategy = IMWRITE_PNG_STRATEGY_RLE; // Default strategy
+    m_filter = IMWRITE_PNG_FILTER_SUB; // Default filter
+    m_isBilevel = false;
     memset(palette, 0, sizeof(palette));
     memset(trns, 0, sizeof(trns));
```

Review comment:
for better readibility, should i replace with ``` if (animation.frames.size() == 1) return write(animation.frames[0], params); ```
**File:** modules/imgcodecs/src/grfmt_png.cpp
**Change Type:** modified
**Context:** PR #26849: APNG encoding optimization

**Code Changes:**
```diff
@@ -814,6 +814,10 @@ PngEncoder::PngEncoder()
     next_seq_num = 0;
     trnssize = 0;
     palsize = 0;
+    m_compression_level = Z_BEST_SPEED;
+    m_compression_strategy = IMWRITE_PNG_STRATEGY_RLE; // Default strategy
+    m_filter = IMWRITE_PNG_FILTER_SUB; // Default filter
+    m_isBilevel = false;
     memset(palette, 0, sizeof(palette));
     memset(trns, 0, sizeof(trns));
```

Review comment:
I still think this is an error: a 1-frame APNG is not the same as a PNG. The spec allows for 1 frame APNG: "1 is a valid value for a single-frame APNG.", cf https://wiki.mozilla.org/APNG_Specification
**File:** modules/imgcodecs/src/grfmt_png.cpp
**Change Type:** modified
**Context:** PR #26849: APNG encoding optimization

**Code Changes:**
```diff
@@ -814,6 +814,10 @@ PngEncoder::PngEncoder()
     next_seq_num = 0;
     trnssize = 0;
     palsize = 0;
+    m_compression_level = Z_BEST_SPEED;
+    m_compression_strategy = IMWRITE_PNG_STRATEGY_RLE; // Default strategy
+    m_filter = IMWRITE_PNG_FILTER_SUB; // Default filter
+    m_isBilevel = false;
     memset(palette, 0, sizeof(palette));
     memset(trns, 0, sizeof(trns));
```

Review comment:
Well, that is a bug in itself. Sure, usually, when you ask for a 1-frame APNG, the user probably wants a PNG but OpenCV should not be the one to decide.
**File:** modules/imgcodecs/src/grfmt_png.cpp
**Change Type:** modified
**Context:** PR #26849: APNG encoding optimization

**Code Changes:**
```diff
@@ -814,6 +814,10 @@ PngEncoder::PngEncoder()
     next_seq_num = 0;
     trnssize = 0;
     palsize = 0;
+    m_compression_level = Z_BEST_SPEED;
+    m_compression_strategy = IMWRITE_PNG_STRATEGY_RLE; // Default strategy
+    m_filter = IMWRITE_PNG_FILTER_SUB; // Default filter
+    m_isBilevel = false;
     memset(palette, 0, sizeof(palette));
     memset(trns, 0, sizeof(trns));
```

Review comment:
It breaks `compression_level = Z_BEST_SPEED;` in constructor.
**File:** modules/imgcodecs/src/grfmt_png.cpp
**Change Type:** modified
**Context:** PR #26849: APNG encoding optimization

**Code Changes:**
```diff
@@ -814,6 +814,10 @@ PngEncoder::PngEncoder()
     next_seq_num = 0;
     trnssize = 0;
     palsize = 0;
+    m_compression_level = Z_BEST_SPEED;
+    m_compression_strategy = IMWRITE_PNG_STRATEGY_RLE; // Default strategy
+    m_filter = IMWRITE_PNG_FILTER_SUB; // Default filter
+    m_isBilevel = false;
     memset(palette, 0, sizeof(palette));
     memset(trns, 0, sizeof(trns));
```

Review comment:
Why not just set Z_BEST_SPEED in constructor and remove the line here?
**File:** modules/imgcodecs/src/grfmt_png.cpp
**Change Type:** modified
**Context:** PR #26849: APNG encoding optimization

**Code Changes:**
```diff
@@ -814,6 +814,10 @@ PngEncoder::PngEncoder()
     next_seq_num = 0;
     trnssize = 0;
     palsize = 0;
+    m_compression_level = Z_BEST_SPEED;
+    m_compression_strategy = IMWRITE_PNG_STRATEGY_RLE; // Default strategy
+    m_filter = IMWRITE_PNG_FILTER_SUB; // Default filter
+    m_isBilevel = false;
     memset(palette, 0, sizeof(palette));
     memset(trns, 0, sizeof(trns));
```

Review comment:
then https://github.com/opencv/opencv/blob/4.x/modules/imgcodecs/src/grfmt_png.cpp#L910-L920 will be meaningless without `compression_level = -1;` let me look later with a fresh mind
**File:** modules/imgcodecs/perf/perf_png.cpp
**Change Type:** modified
**Context:** PR #26849: APNG encoding optimization

**Code Changes:**
```diff
@@ -11,7 +11,10 @@ namespace opencv_test
 
 using namespace perf;
 
-typedef perf::TestBaseWithParam<std::string> PNG;
+CV_ENUM(PNGStrategy, IMWRITE_PNG_STRATEGY_DEFAULT, IMWRITE_PNG_STRATEGY_FILTERED, IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY, IMWRITE_PNG_STRATEGY_RLE, IMWRITE_PNG_STRATEGY_FIXED);
+CV_ENUM(PNGFilters, IMWRITE_PNG_FILTER_NONE, IMWRITE_PNG_FILTER_SUB, IMWRITE_PNG_FILTER_UP, IMWRITE_PNG_FILTER_AVG, IMWRITE_PNG_FILTER_PAETH, IMWRITE_PNG_FAST_FILTERS, IMWRITE_PNG_ALL_FILTERS);
+
+typedef perf::TestBaseWithParam<testing::tuple<PNGStrategy, PNGFilters, int>> PNG;
 
```

Review comment:
Please use CV_ENUM instead of int like here: https://github.com/opencv/opencv/blob/d32d4da9a39ce92bdc5603749ea6f2d90215f4ea/modules/imgproc/test/test_templmatch.cpp#L306 GTest prints enum names instead of magic integer values.
**File:** modules/imgcodecs/perf/perf_png.cpp
**Change Type:** modified
**Context:** PR #26849: APNG encoding optimization

**Code Changes:**
```diff
@@ -11,7 +11,10 @@ namespace opencv_test
 
 using namespace perf;
 
-typedef perf::TestBaseWithParam<std::string> PNG;
+CV_ENUM(PNGStrategy, IMWRITE_PNG_STRATEGY_DEFAULT, IMWRITE_PNG_STRATEGY_FILTERED, IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY, IMWRITE_PNG_STRATEGY_RLE, IMWRITE_PNG_STRATEGY_FIXED);
+CV_ENUM(PNGFilters, IMWRITE_PNG_FILTER_NONE, IMWRITE_PNG_FILTER_SUB, IMWRITE_PNG_FILTER_UP, IMWRITE_PNG_FILTER_AVG, IMWRITE_PNG_FILTER_PAETH, IMWRITE_PNG_FAST_FILTERS, IMWRITE_PNG_ALL_FILTERS);
+
+typedef perf::TestBaseWithParam<testing::tuple<PNGStrategy, PNGFilters, int>> PNG;
 
```

Review comment:
Why is it disabled?
**File:** modules/imgcodecs/include/opencv2/imgcodecs.hpp
**Change Type:** modified
**Context:** PR #26849: APNG encoding optimization

**Code Changes:**
```diff
@@ -96,6 +96,7 @@ enum ImwriteFlags {
        IMWRITE_PNG_COMPRESSION     = 16, //!< For PNG, it can be the compression level from 0 to 9. A higher value means a smaller size and longer compression time. If specified, strategy is changed to IMWRITE_PNG_STRATEGY_DEFAULT (Z_DEFAULT_STRATEGY). Default value is 1 (best speed setting).
        IMWRITE_PNG_STRATEGY        = 17, //!< One of cv::ImwritePNGFlags, default is IMWRITE_PNG_STRATEGY_RLE.
        IMWRITE_PNG_BILEVEL         = 18, //!< Binary level PNG, 0 or 1, default is 0.
+       IMWRITE_PNG_FILTER          = 19, //!< One of cv::ImwritePNGFilterFlags, default is IMWRITE_PNG_FILTER_SUB.
        IMWRITE_PXM_BINARY          = 32, //!< For PPM, PGM, or PBM, it can be a binary format flag, 0 or 1. Default value is 1.
        IMWRITE_EXR_TYPE            = (3 << 4) + 0 /* 48 */, //!< override EXR storage type (FLOAT (FP32) is default)
        IMWRITE_EXR_COMPRESSION     = (3 << 4) + 1 /* 49 */, //!< override EXR compression type (ZIP_COMPRESSION = 3 is default)
@@ -211,6 +212,17 @@ enum ImwritePNGFlags {
        IMWRITE_PNG_STRATEGY_FIXED        = 4  //!< Using this value prevents the use of dynamic Huffman codes, allowing for a simpler decoder for special applications.
```

Review comment:
What is difference between IMWRITE_PNG_NO_FILTERS and IMWRITE_PNG_FILTER_NONE? Why do we need both?
**File:** modules/imgcodecs/include/opencv2/imgcodecs.hpp
**Change Type:** modified
**Context:** PR #26849: APNG encoding optimization
**Review Line:** 99

**Code Changes:**
```diff
@@ -96,6 +96,7 @@ enum ImwriteFlags {
        IMWRITE_PNG_COMPRESSION     = 16, //!< For PNG, it can be the compression level from 0 to 9. A higher value means a smaller size and longer compression time. If specified, strategy is changed to IMWRITE_PNG_STRATEGY_DEFAULT (Z_DEFAULT_STRATEGY). Default value is 1 (best speed setting).
        IMWRITE_PNG_STRATEGY        = 17, //!< One of cv::ImwritePNGFlags, default is IMWRITE_PNG_STRATEGY_RLE.
        IMWRITE_PNG_BILEVEL         = 18, //!< Binary level PNG, 0 or 1, default is 0.
+       IMWRITE_PNG_FILTER          = 19, //!< One of cv::ImwritePNGFilterFlags, default is IMWRITE_PNG_FILTER_SUB.
        IMWRITE_PXM_BINARY          = 32, //!< For PPM, PGM, or PBM, it can be a binary format flag, 0 or 1. Default value is 1.
        IMWRITE_EXR_TYPE            = (3 << 4) + 0 /* 48 */, //!< override EXR storage type (FLOAT (FP32) is default)
        IMWRITE_EXR_COMPRESSION     = (3 << 4) + 1 /* 49 */, //!< override EXR compression type (ZIP_COMPRESSION = 3 is default)
@@ -211,6 +212,17 @@ enum ImwritePNGFlags {
        IMWRITE_PNG_STRATEGY_FIXED        = 4  //!< Using this value prevents the use of dynamic Huffman codes, allowing for a simpler decoder for special applications.
```

Review comment:
Are there any changes against 4.11 (APNG support) and 4.10 (old style PNG)?
**File:** modules/imgcodecs/include/opencv2/imgcodecs.hpp
**Change Type:** modified
**Context:** PR #26849: APNG encoding optimization
**Review Line:** 99

**Code Changes:**
```diff
@@ -96,6 +96,7 @@ enum ImwriteFlags {
        IMWRITE_PNG_COMPRESSION     = 16, //!< For PNG, it can be the compression level from 0 to 9. A higher value means a smaller size and longer compression time. If specified, strategy is changed to IMWRITE_PNG_STRATEGY_DEFAULT (Z_DEFAULT_STRATEGY). Default value is 1 (best speed setting).
        IMWRITE_PNG_STRATEGY        = 17, //!< One of cv::ImwritePNGFlags, default is IMWRITE_PNG_STRATEGY_RLE.
        IMWRITE_PNG_BILEVEL         = 18, //!< Binary level PNG, 0 or 1, default is 0.
+       IMWRITE_PNG_FILTER          = 19, //!< One of cv::ImwritePNGFilterFlags, default is IMWRITE_PNG_FILTER_SUB.
        IMWRITE_PXM_BINARY          = 32, //!< For PPM, PGM, or PBM, it can be a binary format flag, 0 or 1. Default value is 1.
        IMWRITE_EXR_TYPE            = (3 << 4) + 0 /* 48 */, //!< override EXR storage type (FLOAT (FP32) is default)
        IMWRITE_EXR_COMPRESSION     = (3 << 4) + 1 /* 49 */, //!< override EXR compression type (ZIP_COMPRESSION = 3 is default)
@@ -211,6 +212,17 @@ enum ImwritePNGFlags {
        IMWRITE_PNG_STRATEGY_FIXED        = 4  //!< Using this value prevents the use of dynamic Huffman codes, allowing for a simpler decoder for special applications.
```

Review comment:
It'll be great to add some accuracy test for the new option. You can, for example, compare file sizes or byte array sizes to ensure the compression applied properly.
**File:** modules/imgcodecs/include/opencv2/imgcodecs.hpp
**Change Type:** modified
**Context:** PR #26849: APNG encoding optimization
**Review Line:** 99

**Code Changes:**
```diff
@@ -96,6 +96,7 @@ enum ImwriteFlags {
        IMWRITE_PNG_COMPRESSION     = 16, //!< For PNG, it can be the compression level from 0 to 9. A higher value means a smaller size and longer compression time. If specified, strategy is changed to IMWRITE_PNG_STRATEGY_DEFAULT (Z_DEFAULT_STRATEGY). Default value is 1 (best speed setting).
        IMWRITE_PNG_STRATEGY        = 17, //!< One of cv::ImwritePNGFlags, default is IMWRITE_PNG_STRATEGY_RLE.
        IMWRITE_PNG_BILEVEL         = 18, //!< Binary level PNG, 0 or 1, default is 0.
+       IMWRITE_PNG_FILTER          = 19, //!< One of cv::ImwritePNGFilterFlags, default is IMWRITE_PNG_FILTER_SUB.
        IMWRITE_PXM_BINARY          = 32, //!< For PPM, PGM, or PBM, it can be a binary format flag, 0 or 1. Default value is 1.
        IMWRITE_EXR_TYPE            = (3 << 4) + 0 /* 48 */, //!< override EXR storage type (FLOAT (FP32) is default)
        IMWRITE_EXR_COMPRESSION     = (3 << 4) + 1 /* 49 */, //!< override EXR compression type (ZIP_COMPRESSION = 3 is default)
@@ -211,6 +212,17 @@ enum ImwritePNGFlags {
        IMWRITE_PNG_STRATEGY_FIXED        = 4  //!< Using this value prevents the use of dynamic Huffman codes, allowing for a simpler decoder for special applications.
```

Review comment:
> It'll be great to add some accuracy test for the new option. You can, for example, compare file sizes or byte array sizes to ensure the compression applied properly. as far as i tested file sizes are various according used zlib or zlib-ng ( maybe also used versions creates different sizes)