nareshmlx/opencv-pr huggingface dataset:
**File:** 3rdparty/hal_rvv/hal_rvv_1p0/atan.hpp
**Change Type:** added
**Context:** PR #26853: Add RISC-V HAL implementation for fastAtan32f/fastAtan64f
**Review Line:** 19

**Code Changes:**
```diff
+#include <cfloat>
+
+namespace cv::cv_hal_rvv {
+
+namespace detail {
+// ref: mathfuncs_core.simd.hpp
+static constexpr float pi = CV_PI;
+static constexpr float atan2_p1 = 0.9997878412794807F * (180 / pi);
+static constexpr float atan2_p3 = -0.3258083974640975F * (180 / pi);
+static constexpr float atan2_p5 = 0.1555786518463281F * (180 / pi);
+static constexpr float atan2_p7 = -0.04432655554792128F * (180 / pi);
```

Review comment:
This implementation didn't introduce any new math approach, the constants were simply polynomial coefficients copied from https://github.com/opencv/opencv/blob/08a24ba2cf5007a2639035cc9661e18f3637223e/modules/core/src/mathfuncs_core.simd.hpp#L36-L39 Presumably it's a 7th degree polynomial approximation for Arctan(x) where x in [0, 1], the optimal coefficients can be evaluated using [Remez algorithm](https://en.wikipedia.org/wiki/Remez_algorithm) I guess? Should I add this in my code comment, or add them to `mathfuncs_core.simd.hpp` ```suggestion // ref: mathfuncs_core.simd.hpp, 7th degree polynomial form Remez algorithm? ```
**File:** samples/dnn/inpainting.cpp
**Change Type:** added
**Context:** PR #26736: Added lama inpainting onnx model sample
**Review Line:** 17

**Code Changes:**
```diff
+
+        ./example_dnn_inpainting
+    The system will ask you to draw the mask on area to be inpainted
+
+    You can download lama inpainting model using:
+       `python download_models.py lama`
+
+    References:
+      Github: https://github.com/advimman/lama
+      ONNX model: https://huggingface.co/Carve/LaMa-ONNX/blob/main/lama_fp32.onnx
+
```

Review comment:
I propose to add reference to the original model and how it was converted, if it's not onnx or simplification was applied.
**File:** samples/dnn/inpainting.cpp
**Change Type:** added
**Context:** PR #26736: Added lama inpainting onnx model sample

**Code Changes:**
```diff
@@ -0,0 +1,230 @@
+/*
+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.
+
+This sample inpaints the masked area in the given image.
+
+Copyright (C) 2025, Bigvision LLC.
+
```

Review comment:
{ formatting is different.
**File:** samples/dnn/inpainting.cpp
**Change Type:** added
**Context:** PR #26736: Added lama inpainting onnx model sample

**Code Changes:**
```diff
@@ -0,0 +1,230 @@
+/*
+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.
+
+This sample inpaints the masked area in the given image.
+
+Copyright (C) 2025, Bigvision LLC.
+
```

Review comment:
I propose to print hot keys at the very beginning to make them more obvious.
**File:** samples/dnn/inpainting.cpp
**Change Type:** added
**Context:** PR #26736: Added lama inpainting onnx model sample
**Review Line:** 13

**Code Changes:**
```diff
+Copyright (C) 2025, Bigvision LLC.
+
+How to use:
+    Sample command to run:
+
+        ./example_dnn_inpainting
+    The system will ask you to draw the mask on area to be inpainted
+
+    You can download lama inpainting model using:
+       `python download_models.py lama`
+
```

Review comment:
the comment should describe how to provide custom input, e.g. `./example_dnn_inpainting [--input=<image_name>]`
**File:** samples/dnn/inpainting.cpp
**Change Type:** added
**Context:** PR #26736: Added lama inpainting onnx model sample

**Code Changes:**
```diff
@@ -0,0 +1,230 @@
+/*
+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.
+
+This sample inpaints the masked area in the given image.
+
+Copyright (C) 2025, Bigvision LLC.
+
```

Review comment:
there should be a loop: until user presses 'escape', he/she should be able to draw another mask on the same original image.
**File:** samples/dnn/inpainting.cpp
**Change Type:** added
**Context:** PR #26736: Added lama inpainting onnx model sample
**Review Line:** 1

**Code Changes:**
```diff
@@ -0,0 +1,230 @@
+/*
+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.
+
+This sample inpaints the masked area in the given image.
```

Review comment:
OpenCV license should be inserted before BigVision copyright in order to avoid any confusion
**File:** modules/core/test/test_io.cpp
**Change Type:** modified
**Context:** PR #26846: Fix bug with int64 support for FileStorage

**Code Changes:**
```diff
@@ -2003,6 +2003,64 @@ TEST(Core_InputOutput, FileStorage_invalid_attribute_value_regression_25946)
     ASSERT_EQ(0, std::remove(fileName.c_str()));
 }
 
+// see https://github.com/opencv/opencv/issues/26829
+TEST(Core_InputOutput, FileStorage_int64_26829)
+{
+    String content =
+        "%YAML:1.0\n"
+        "String1: string1\n"
```

Review comment:
pleas use `tempfile()` call for file name. Not all platforms allow file i/o in current directory.
**File:** modules/core/test/test_io.cpp
**Change Type:** modified
**Context:** PR #26846: Fix bug with int64 support for FileStorage
**Review Line:** 2061

**Code Changes:**
```diff
+        fs["Int64Min"] >> value;
+        EXPECT_EQ(value, INT64_MIN);
+
+        fs["Int64Max"] >> value;
+        EXPECT_EQ(value, INT64_MAX);
+    }
+}
+
 template <typename T>
 T fsWriteRead(const T& expectedValue, const char* ext)
 {
```

Review comment:
The file is not removed. Actually you can use in-memory representation of FileStorage to exclude file io from pipeline. See https://docs.opencv.org/4.x/da/d56/classcv_1_1FileStorage.html#a973e41cb75ef6230412a567723b7482dabdde7670c9c7e472f8445932ea7cbbf7
**File:** modules/imgcodecs/src/grfmt_gif.cpp
**Change Type:** modified
**Context:** PR #26859: imgcodecs:gif: support IMREAD_UNCHANGED and IMREAD_GRAYSCALE

**Code Changes:**
```diff
@@ -14,7 +14,7 @@ namespace cv
 //////////////////////////////////////////////////////////////////////
 GifDecoder::GifDecoder() {
     m_signature = R"(GIF)";
-    m_type = CV_8UC4;
+    m_type = CV_8UC3;
     bgColor = -1;
     m_buf_supported = true;
     globalColorTableSize = 0;
@@ -172,12 +172,17 @@ bool GifDecoder::readData(Mat &img) {
```

Review comment:
It's error. I propose to include amount of channels to error message in printf style like https://github.com/opencv/opencv/blob/c21d0ad9d08d364542bb4a6eb971ee3051ccba63/modules/imgcodecs/src/grfmt_jpeg.cpp#L771
**File:** modules/imgcodecs/test/test_gif.cpp
**Change Type:** modified
**Context:** PR #26859: imgcodecs:gif: support IMREAD_UNCHANGED and IMREAD_GRAYSCALE

**Code Changes:**
```diff
@@ -241,17 +241,17 @@ TEST(Imgcodecs_Gif, read_gif_special){
     const string gif_filename2 = root + "gifsuite/special2.gif";
     const string png_filename2 = root + "gifsuite/special2.png";
     cv::Mat gif_img1;
-    ASSERT_NO_THROW(gif_img1 = cv::imread(gif_filename1,IMREAD_UNCHANGED));
+    ASSERT_NO_THROW(gif_img1 = cv::imread(gif_filename1,IMREAD_COLOR));
     ASSERT_FALSE(gif_img1.empty());
     cv::Mat png_img1;
-    ASSERT_NO_THROW(png_img1 = cv::imread(png_filename1,IMREAD_UNCHANGED));
+    ASSERT_NO_THROW(png_img1 = cv::imread(png_filename1,IMREAD_COLOR));
```

Review comment:
the color conversion is not needed, if you use imread without flags.
**File:** modules/imgcodecs/test/test_gif.cpp
**Change Type:** modified
**Context:** PR #26859: imgcodecs:gif: support IMREAD_UNCHANGED and IMREAD_GRAYSCALE

**Code Changes:**
```diff
@@ -241,17 +241,17 @@ TEST(Imgcodecs_Gif, read_gif_special){
     const string gif_filename2 = root + "gifsuite/special2.gif";
     const string png_filename2 = root + "gifsuite/special2.png";
     cv::Mat gif_img1;
-    ASSERT_NO_THROW(gif_img1 = cv::imread(gif_filename1,IMREAD_UNCHANGED));
+    ASSERT_NO_THROW(gif_img1 = cv::imread(gif_filename1,IMREAD_COLOR));
     ASSERT_FALSE(gif_img1.empty());
     cv::Mat png_img1;
-    ASSERT_NO_THROW(png_img1 = cv::imread(png_filename1,IMREAD_UNCHANGED));
+    ASSERT_NO_THROW(png_img1 = cv::imread(png_filename1,IMREAD_COLOR));
```

Review comment:
'special1.png' and `special2.png` have alpha channel, but ‘special1.gif' and `special2.png` do not. Having different arguments to imread() for each image type would have obscured the purpose of the test, so I modified it so that all imread()s use the same arguments `cv::IMREAD_COLOR`.
**File:** modules/imgcodecs/include/opencv2/imgcodecs.hpp
**Change Type:** modified
**Context:** PR #26859: imgcodecs:gif: support IMREAD_UNCHANGED and IMREAD_GRAYSCALE

**Code Changes:**
```diff
@@ -413,13 +413,13 @@ can be saved using this function, with these exceptions:
 - With JPEG 2000 encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
 - With JPEG XL encoder, 8-bit unsigned (CV_8U), 16-bit unsigned (CV_16U) and 32-bit float(CV_32F) images can be saved.
   - JPEG XL images with an alpha channel can be saved using this function.
-    To do this, create 8-bit (or 16-bit, 32-bit float) 4-channel image BGRA, where the alpha channel goes last.
-    Fully transparent pixels should have alpha set to 0, fully opaque pixels should have alpha set to 255/65535/1.0.
+    To achieve this, create an 8-bit 4-channel (CV_8UC4) / 16-bit 4-channel (CV_16UC4) / 32-bit float 4-channel (CV_32FC4) BGRA image, ensuring the alpha channel is the last component.
+    Fully transparent pixels should have an alpha value of 0, while fully opaque pixels should have an alpha value of 255/65535/1.0.
 - With PAM encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
 - With PNG encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
```

Review comment:
8-bit single-channel images (CV_8UC1) are not supported by the GIF specification due to its limitation to indexed color formats.
**File:** modules/imgcodecs/include/opencv2/imgcodecs.hpp
**Change Type:** modified
**Context:** PR #26859: imgcodecs:gif: support IMREAD_UNCHANGED and IMREAD_GRAYSCALE

**Code Changes:**
```diff
@@ -413,13 +413,13 @@ can be saved using this function, with these exceptions:
 - With JPEG 2000 encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
 - With JPEG XL encoder, 8-bit unsigned (CV_8U), 16-bit unsigned (CV_16U) and 32-bit float(CV_32F) images can be saved.
   - JPEG XL images with an alpha channel can be saved using this function.
-    To do this, create 8-bit (or 16-bit, 32-bit float) 4-channel image BGRA, where the alpha channel goes last.
-    Fully transparent pixels should have alpha set to 0, fully opaque pixels should have alpha set to 255/65535/1.0.
+    To achieve this, create an 8-bit 4-channel (CV_8UC4) / 16-bit 4-channel (CV_16UC4) / 32-bit float 4-channel (CV_32FC4) BGRA image, ensuring the alpha channel is the last component.
+    Fully transparent pixels should have an alpha value of 0, while fully opaque pixels should have an alpha value of 255/65535/1.0.
 - With PAM encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
 - With PNG encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
```

Review comment:
note : i support the idea of getting help from AI about documentation improvements. The GIF encoder supports saving 8-bit unsigned (CV_8U) images. GIF images with an alpha channel can be saved using this function. To achieve this, create an 8-bit 4-channel (CV_8UC4) BGRA image, ensuring the alpha channel is the last component. Fully transparent pixels should have an alpha value of 0, while fully opaque pixels should have an alpha value of 255. 8-bit single-channel images (CV_8UC1) are not supported due to GIF's limitation to indexed color formats.
**File:** modules/imgcodecs/include/opencv2/imgcodecs.hpp
**Change Type:** modified
**Context:** PR #26859: imgcodecs:gif: support IMREAD_UNCHANGED and IMREAD_GRAYSCALE

**Code Changes:**
```diff
@@ -413,13 +413,13 @@ can be saved using this function, with these exceptions:
 - With JPEG 2000 encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
 - With JPEG XL encoder, 8-bit unsigned (CV_8U), 16-bit unsigned (CV_16U) and 32-bit float(CV_32F) images can be saved.
   - JPEG XL images with an alpha channel can be saved using this function.
-    To do this, create 8-bit (or 16-bit, 32-bit float) 4-channel image BGRA, where the alpha channel goes last.
-    Fully transparent pixels should have alpha set to 0, fully opaque pixels should have alpha set to 255/65535/1.0.
+    To achieve this, create an 8-bit 4-channel (CV_8UC4) / 16-bit 4-channel (CV_16UC4) / 32-bit float 4-channel (CV_32FC4) BGRA image, ensuring the alpha channel is the last component.
+    Fully transparent pixels should have an alpha value of 0, while fully opaque pixels should have an alpha value of 255/65535/1.0.
 - With PAM encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
 - With PNG encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
```

Review comment:
updated document preview is here. https://pullrequest.opencv.org/buildbot/export/pr/26859/docs/d4/da8/group__imgcodecs.html#ga8ac397bd09e48851665edbe12aa28f25
**File:** modules/imgcodecs/src/grfmt_png.cpp
**Change Type:** modified
**Context:** PR #26854: Fix oss-fuzz bugs 391934081 and 392318892

**Code Changes:**
```diff
@@ -325,15 +325,6 @@ bool  PngDecoder::readHeader()
             bop = chunk.p[33];
         }
 
-        if (id == id_bKGD)
-        {
-            // The spec is actually more complex: http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html#C.bKGD
-            m_animation.bgcolor[0] = png_get_uint_16(&chunk.p[8]);
-            m_animation.bgcolor[1] = png_get_uint_16(&chunk.p[10]);
-            m_animation.bgcolor[2] = png_get_uint_16(&chunk.p[12]);
```

Review comment:
It should be BGR by default, right?
**File:** modules/imgcodecs/src/grfmt_png.cpp
**Change Type:** modified
**Context:** PR #26854: Fix oss-fuzz bugs 391934081 and 392318892

**Code Changes:**
```diff
@@ -325,15 +325,6 @@ bool  PngDecoder::readHeader()
             bop = chunk.p[33];
         }
 
-        if (id == id_bKGD)
-        {
-            // The spec is actually more complex: http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html#C.bKGD
-            m_animation.bgcolor[0] = png_get_uint_16(&chunk.p[8]);
-            m_animation.bgcolor[1] = png_get_uint_16(&chunk.p[10]);
-            m_animation.bgcolor[2] = png_get_uint_16(&chunk.p[12]);
```

Review comment:
> It should be BGR by default, right? i think RGB is OK as far as i test before. to other applications opens the file.
**File:** modules/imgcodecs/src/grfmt_png.cpp
**Change Type:** modified
**Context:** PR #26854: Fix oss-fuzz bugs 391934081 and 392318892

**Code Changes:**
```diff
@@ -325,15 +325,6 @@ bool  PngDecoder::readHeader()
             bop = chunk.p[33];
         }
 
-        if (id == id_bKGD)
-        {
-            // The spec is actually more complex: http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html#C.bKGD
-            m_animation.bgcolor[0] = png_get_uint_16(&chunk.p[8]);
-            m_animation.bgcolor[1] = png_get_uint_16(&chunk.p[10]);
-            m_animation.bgcolor[2] = png_get_uint_16(&chunk.p[12]);
```

Review comment:
related test is also expect RGB
**File:** modules/imgcodecs/src/grfmt_png.cpp
**Change Type:** modified
**Context:** PR #26854: Fix oss-fuzz bugs 391934081 and 392318892

**Code Changes:**
```diff
@@ -325,15 +325,6 @@ bool  PngDecoder::readHeader()
             bop = chunk.p[33];
         }
 
-        if (id == id_bKGD)
-        {
-            // The spec is actually more complex: http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html#C.bKGD
-            m_animation.bgcolor[0] = png_get_uint_16(&chunk.p[8]);
-            m_animation.bgcolor[1] = png_get_uint_16(&chunk.p[10]);
-            m_animation.bgcolor[2] = png_get_uint_16(&chunk.p[12]);
```

Review comment:
OpenCV uses BGR everywhere by default, including colors on drawing. We should align the implementation then.
**File:** modules/imgcodecs/src/grfmt_png.cpp
**Change Type:** modified
**Context:** PR #26854: Fix oss-fuzz bugs 391934081 and 392318892

**Code Changes:**
```diff
@@ -325,15 +325,6 @@ bool  PngDecoder::readHeader()
             bop = chunk.p[33];
         }
 
-        if (id == id_bKGD)
-        {
-            // The spec is actually more complex: http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html#C.bKGD
-            m_animation.bgcolor[0] = png_get_uint_16(&chunk.p[8]);
-            m_animation.bgcolor[1] = png_get_uint_16(&chunk.p[10]);
-            m_animation.bgcolor[2] = png_get_uint_16(&chunk.p[12]);
```

Review comment:
Right, that is what the doc says anyway
**File:** modules/photo/test/test_denoising.cpp
**Change Type:** modified
**Context:** PR #26831: added 16-bit support to fastNlMeansDenoising and updated tests

**Code Changes:**
```diff
@@ -165,4 +165,33 @@ TEST(Photo_Denoising, speed)
     printf("execution time: %gms\n", t*1000./getTickFrequency());
 }
 
+// Related issue : https://github.com/opencv/opencv/issues/26582
+TEST(Photo_DenoisingGrayscaleMulti16bitL1, regression)
+{
+    const int imgs_count = 3;
+    string folder = string(cvtest::TS::ptr()->get_data_path()) + "denoising/";
+
```

Review comment:
Please use cv::PSNR instead: https://docs.opencv.org/4.x/d2/de8/group__core__array.html#ga3119e3ea73010a6f810bb05aa36ac8d6
**File:** cmake/OpenCVFindAVIF.cmake
**Change Type:** modified
**Context:** PR #26762: Fixed AVIF linkage on Windows

**Code Changes:**
```diff
@@ -19,7 +19,7 @@ if(TARGET avif)
     MARK_AS_ADVANCED(AVIF_LIBRARY)
 
     SET(AVIF_FOUND TRUE)
-    GET_TARGET_PROPERTY(AVIF_LIBRARY avif LOCATION)
+    SET(AVIF_LIBRARY avif)
     GET_TARGET_PROPERTY(AVIF_INCLUDE_DIR1 avif INCLUDE_DIRECTORIES)
     GET_TARGET_PROPERTY(AVIF_INCLUDE_DIR2 avif INTERFACE_INCLUDE_DIRECTORIES)
     set(AVIF_INCLUDE_DIR)
```

Review comment:
Is this variable really necessary? I suppose all `INTERFACE_LINK_LIBRARIES` from `avif` target would be automatically linked by cmake. Perhaps we don't need to read target properties at all.
**File:** cmake/OpenCVFindAVIF.cmake
**Change Type:** modified
**Context:** PR #26762: Fixed AVIF linkage on Windows

**Code Changes:**
```diff
@@ -19,7 +19,7 @@ if(TARGET avif)
     MARK_AS_ADVANCED(AVIF_LIBRARY)
 
     SET(AVIF_FOUND TRUE)
-    GET_TARGET_PROPERTY(AVIF_LIBRARY avif LOCATION)
+    SET(AVIF_LIBRARY avif)
     GET_TARGET_PROPERTY(AVIF_INCLUDE_DIR1 avif INCLUDE_DIRECTORIES)
     GET_TARGET_PROPERTY(AVIF_INCLUDE_DIR2 avif INTERFACE_INCLUDE_DIRECTORIES)
     set(AVIF_INCLUDE_DIR)
```

Review comment:
the difference was only in cmake output. now for shared and static lib output is like `AVIF: avif (ver 1.1.1)`
**File:** modules/imgcodecs/src/grfmt_png.cpp
**Change Type:** modified
**Context:** PR #26851: fix related the issue 22551

**Code Changes:**
```diff
@@ -126,9 +126,10 @@ const uint32_t id_acTL = 0x4C546361; // Animation control chunk
 const uint32_t id_fcTL = 0x4C546366; // Frame control chunk
 const uint32_t id_IDAT = 0x54414449; // first frame and/or default image
 const uint32_t id_fdAT = 0x54416466; // Frame data chunk
-const uint32_t id_PLTE = 0x45544C50;
-const uint32_t id_bKGD = 0x44474B62;
-const uint32_t id_tRNS = 0x534E5274;
+const uint32_t id_PLTE = 0x45544C50; // The PLTE chunk contains a color palette for indexed-color images
+const uint32_t id_bKGD = 0x44474B62; // The bKGD chunk specifies a default background color for the image
+const uint32_t id_tRNS = 0x534E5274; // The tRNS chunk provides transparency information
```

Review comment:
Please just move id_tExt to the line above and respect the alphabetical order. Thx. This PNG_USER_CHUNK_MALLOC_MAX could also be an env variable that the user can change.
**File:** modules/imgcodecs/src/grfmt_png.cpp
**Change Type:** modified
**Context:** PR #26851: fix related the issue 22551

**Code Changes:**
```diff
@@ -126,9 +126,10 @@ const uint32_t id_acTL = 0x4C546361; // Animation control chunk
 const uint32_t id_fcTL = 0x4C546366; // Frame control chunk
 const uint32_t id_IDAT = 0x54414449; // first frame and/or default image
 const uint32_t id_fdAT = 0x54416466; // Frame data chunk
-const uint32_t id_PLTE = 0x45544C50;
-const uint32_t id_bKGD = 0x44474B62;
-const uint32_t id_tRNS = 0x534E5274;
+const uint32_t id_PLTE = 0x45544C50; // The PLTE chunk contains a color palette for indexed-color images
+const uint32_t id_bKGD = 0x44474B62; // The bKGD chunk specifies a default background color for the image
+const uint32_t id_tRNS = 0x534E5274; // The tRNS chunk provides transparency information
```

Review comment:
> Please just move id_tExt to the line above and respect the alphabetical order. Thx. This PNG_USER_CHUNK_MALLOC_MAX could also be an env variable that the user can change. done.
**File:** modules/imgcodecs/src/grfmt_jpegxl.cpp
**Change Type:** modified
**Context:** PR #26844: imgcodecs: jpegxl: imdecode() directly read from memory

**Code Changes:**
```diff
@@ -28,13 +28,15 @@ static void cbRGBAtoGRAY_32F(void *opaque, size_t x, size_t y, size_t num_pixels
 
 /////////////////////// JpegXLDecoder ///////////////////
 
-JpegXLDecoder::JpegXLDecoder() : m_f(nullptr, &fclose)
+JpegXLDecoder::JpegXLDecoder() : m_f(nullptr, &fclose),
+                                 m_read_buffer(16384,0) // 16KB chunks
 {
     m_signature = "\xFF\x0A";
     m_decoder = nullptr;
```

Review comment:
If I understood correctly, The m_read_buffer is resized only once here ant it's size is always 16k. The `m_read_buffer` is used in ::read() only. M.b. it's better to make it local variable there. If you need the buffer shared between readHeader and readData then it makes sense to initialize the buffer in decoder constructor.
**File:** modules/imgcodecs/src/grfmt_png.cpp
**Change Type:** modified
**Context:** PR #26835: Corrections on bKGD chunk writing and reading in PNG

**Code Changes:**
```diff
@@ -327,11 +327,10 @@ bool  PngDecoder::readHeader()
         if (id == id_bKGD)
         {
             // The spec is actually more complex: http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html#C.bKGD
-            int bgcolor = png_get_uint_32(&chunk.p[8]);
-            m_animation.bgcolor[3] = (bgcolor >> 24) & 0xFF;
-            m_animation.bgcolor[2] = (bgcolor >> 16) & 0xFF;
-            m_animation.bgcolor[1] = (bgcolor >> 8) & 0xFF;
-            m_animation.bgcolor[0] = bgcolor & 0xFF;
+            m_animation.bgcolor[0] = png_get_uint_16(&chunk.p[8]);
```

Review comment:
You should use png_get_uint_16
**File:** modules/imgcodecs/src/grfmt_png.cpp
**Change Type:** modified
**Context:** PR #26835: Corrections on bKGD chunk writing and reading in PNG

**Code Changes:**
```diff
@@ -327,11 +327,10 @@ bool  PngDecoder::readHeader()
         if (id == id_bKGD)
         {
             // The spec is actually more complex: http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html#C.bKGD
-            int bgcolor = png_get_uint_32(&chunk.p[8]);
-            m_animation.bgcolor[3] = (bgcolor >> 24) & 0xFF;
-            m_animation.bgcolor[2] = (bgcolor >> 16) & 0xFF;
-            m_animation.bgcolor[1] = (bgcolor >> 8) & 0xFF;
-            m_animation.bgcolor[0] = bgcolor & 0xFF;
+            m_animation.bgcolor[0] = png_get_uint_16(&chunk.p[8]);
```

Review comment:
Actually, let's follow the spec: `size != 8 + 1 && size != 8 + 2 && size != 8 + 6`