nareshmlx/opencv-pr huggingface dataset:
**File:** modules/core/include/opencv2/core/opencl/opencl_info.hpp
**Change Type:** modified
**Context:** PR #15883: Refactor opencl_info - This pullrequest refactors parts of opencl information dumping: - Remove code duplication - Clarify functionality of...
**Review Line:** 66

**Code Changes:**
```diff
+            return "dGPU";
+        }
+    }
+
+    return "unkown";
+}
 } // namespace
 
 static void dumpOpenCLInformation()
@@ -80,12 +97,11 @@ static void dumpOpenCLInformation()
             for (int j = 0; j < platform->deviceNumber(); j++)
```

Review comment:
Bad indentation
**File:** modules/core/include/opencv2/core/opencl/opencl_info.hpp
**Change Type:** modified
**Context:** PR #15883: Refactor opencl_info - This pullrequest refactors parts of opencl information dumping: - Remove code duplication - Clarify functionality of...

**Code Changes:**
```diff
@@ -47,6 +47,23 @@ static std::string bytesToStringRepr(size_t value)
         s = s.substr(0, s.size() - 1);
     return s;
 }
+
+static String getDeviceTypeString(const cv::ocl::Device& device)
+{
+    if (device.type() == cv::ocl::Device::TYPE_CPU) {
+        return "CPU";
+    }
```

Review comment:
I would prefer passing a device reference, because: * it's less error prone. You won't get a type of one device and memory type from another one. * it's possible to avoid unnecessarily calling of device.hostUnifiedMemory() when device type != GPU
**File:** modules/core/include/opencv2/core/opencl/opencl_info.hpp
**Change Type:** modified
**Context:** PR #15883: Refactor opencl_info - This pullrequest refactors parts of opencl information dumping: - Remove code duplication - Clarify functionality of...

**Code Changes:**
```diff
@@ -47,6 +47,23 @@ static std::string bytesToStringRepr(size_t value)
         s = s.substr(0, s.size() - 1);
     return s;
 }
+
+static String getDeviceTypeString(const cv::ocl::Device& device)
+{
+    if (device.type() == cv::ocl::Device::TYPE_CPU) {
+        return "CPU";
+    }
```

Review comment:
unnecessary change
**File:** modules/core/include/opencv2/core/opencl/opencl_info.hpp
**Change Type:** modified
**Context:** PR #15883: Refactor opencl_info - This pullrequest refactors parts of opencl information dumping: - Remove code duplication - Clarify functionality of...

**Code Changes:**
```diff
@@ -47,6 +47,23 @@ static std::string bytesToStringRepr(size_t value)
         s = s.substr(0, s.size() - 1);
     return s;
 }
+
+static String getDeviceTypeString(const cv::ocl::Device& device)
+{
+    if (device.type() == cv::ocl::Device::TYPE_CPU) {
+        return "CPU";
+    }
```

Review comment:
excessive line splitting
**File:** modules/core/include/opencv2/core/opencl/opencl_info.hpp
**Change Type:** modified
**Context:** PR #15883: Refactor opencl_info - This pullrequest refactors parts of opencl information dumping: - Remove code duplication - Clarify functionality of...

**Code Changes:**
```diff
@@ -47,6 +47,23 @@ static std::string bytesToStringRepr(size_t value)
         s = s.substr(0, s.size() - 1);
     return s;
 }
+
+static String getDeviceTypeString(const cv::ocl::Device& device)
+{
+    if (device.type() == cv::ocl::Device::TYPE_CPU) {
+        return "CPU";
+    }
```

Review comment:
Good points, I agree
**File:** modules/core/include/opencv2/core/opencl/opencl_info.hpp
**Change Type:** modified
**Context:** PR #15883: Refactor opencl_info - This pullrequest refactors parts of opencl information dumping: - Remove code duplication - Clarify functionality of...

**Code Changes:**
```diff
@@ -47,6 +47,23 @@ static std::string bytesToStringRepr(size_t value)
         s = s.substr(0, s.size() - 1);
     return s;
 }
+
+static String getDeviceTypeString(const cv::ocl::Device& device)
+{
+    if (device.type() == cv::ocl::Device::TYPE_CPU) {
+        return "CPU";
+    }
```

Review comment:
In this function, there is no cv::format as in line 103, right.
**File:** modules/core/include/opencv2/core/opencl/opencl_info.hpp
**Change Type:** modified
**Context:** PR #15883: Refactor opencl_info - This pullrequest refactors parts of opencl information dumping: - Remove code duplication - Clarify functionality of...

**Code Changes:**
```diff
@@ -47,6 +47,23 @@ static std::string bytesToStringRepr(size_t value)
         s = s.substr(0, s.size() - 1);
     return s;
 }
+
+static String getDeviceTypeString(const cv::ocl::Device& device)
+{
+    if (device.type() == cv::ocl::Device::TYPE_CPU) {
+        return "CPU";
+    }
```

Review comment:
Resolved by shorter function signature
**File:** modules/core/include/opencv2/core/opencl/opencl_info.hpp
**Change Type:** modified
**Context:** PR #15883: Refactor opencl_info - This pullrequest refactors parts of opencl information dumping: - Remove code duplication - Clarify functionality of...

**Code Changes:**
```diff
@@ -47,6 +47,23 @@ static std::string bytesToStringRepr(size_t value)
         s = s.substr(0, s.size() - 1);
     return s;
 }
+
+static String getDeviceTypeString(const cv::ocl::Device& device)
+{
+    if (device.type() == cv::ocl::Device::TYPE_CPU) {
+        return "CPU";
+    }
```

Review comment:
Braces should go on a new line. Or you can drop them entirely when they are unnecessary. Otherwise, the code looks good to me.
**File:** modules/core/include/opencv2/core/opencl/opencl_info.hpp
**Change Type:** modified
**Context:** PR #15883: Refactor opencl_info - This pullrequest refactors parts of opencl information dumping: - Remove code duplication - Clarify functionality of...

**Code Changes:**
```diff
@@ -47,6 +47,23 @@ static std::string bytesToStringRepr(size_t value)
         s = s.substr(0, s.size() - 1);
     return s;
 }
+
+static String getDeviceTypeString(const cv::ocl::Device& device)
+{
+    if (device.type() == cv::ocl::Device::TYPE_CPU) {
+        return "CPU";
+    }
```

Review comment:
Again, correct. Actually, does opencv have an autoformat file (clang-format) that I can apply?
**File:** modules/core/include/opencv2/core/opencl/opencl_info.hpp
**Change Type:** modified
**Context:** PR #15883: Refactor opencl_info - This pullrequest refactors parts of opencl information dumping: - Remove code duplication - Clarify functionality of...

**Code Changes:**
```diff
@@ -47,6 +47,23 @@ static std::string bytesToStringRepr(size_t value)
         s = s.substr(0, s.size() - 1);
     return s;
 }
+
+static String getDeviceTypeString(const cv::ocl::Device& device)
+{
+    if (device.type() == cv::ocl::Device::TYPE_CPU) {
+        return "CPU";
+    }
```

Review comment:
Some coding style information is available on Wiki: https://github.com/opencv/opencv/wiki/Coding_Style_Guide#code-layout `clang-format` looks weird (introduces too many unnecessary changes - there is no way to specify "keep"/"do not care" option for some rules) - you may find PR with these experiments.
**File:** cmake/OpenCVFindOpenEXR.cmake
**Change Type:** modified
**Context:** PR #15159: fix FindOpenEXR to respect OPENEXR_ROOT - resolves #13403 ### This pullrequest changes - if CMake variable `OPENEXR_ROOT` is set, it has th...
**Review Line:** 24

**Code Changes:**
```diff
         SET(OPENEXR_LIBSEARCH_SUFFIXES Win32/Release Win32 Win32/Debug)
     endif()
-else()
-    set(OPENEXR_ROOT "")
 endif()
 
-SET(LIBRARY_PATHS
-    /usr/lib
-    /usr/local/lib
-    /sw/lib
-    /opt/local/lib
```

Review comment:
`SET(OPENEXR_ROOT ... CACHE ...)` is enough. Cache values specified by users are not overwritten by these statements. Just remove "else()" branch.
**File:** cmake/OpenCVFindOpenEXR.cmake
**Change Type:** modified
**Context:** PR #15159: fix FindOpenEXR to respect OPENEXR_ROOT - resolves #13403 ### This pullrequest changes - if CMake variable `OPENEXR_ROOT` is set, it has th...
**Review Line:** 24

**Code Changes:**
```diff
         SET(OPENEXR_LIBSEARCH_SUFFIXES Win32/Release Win32 Win32/Debug)
     endif()
-else()
-    set(OPENEXR_ROOT "")
 endif()
 
-SET(LIBRARY_PATHS
-    /usr/lib
-    /usr/local/lib
-    /sw/lib
-    /opt/local/lib
```

Review comment:
removed else branch
**File:** cmake/OpenCVFindOpenEXR.cmake
**Change Type:** modified
**Context:** PR #15159: fix FindOpenEXR to respect OPENEXR_ROOT - resolves #13403 ### This pullrequest changes - if CMake variable `OPENEXR_ROOT` is set, it has th...

**Code Changes:**
```diff
@@ -20,55 +20,89 @@ if(WIN32)
     elseif(MSVC)
         SET(OPENEXR_LIBSEARCH_SUFFIXES Win32/Release Win32 Win32/Debug)
     endif()
-else()
-    set(OPENEXR_ROOT "")
 endif()
 
-SET(LIBRARY_PATHS
-    /usr/lib
```

Review comment:
This condition is not needed - `set(... CACHE)` doesn't override variables by default.
**File:** cmake/OpenCVFindOpenEXR.cmake
**Change Type:** modified
**Context:** PR #15159: fix FindOpenEXR to respect OPENEXR_ROOT - resolves #13403 ### This pullrequest changes - if CMake variable `OPENEXR_ROOT` is set, it has th...

**Code Changes:**
```diff
@@ -20,55 +20,89 @@ if(WIN32)
     elseif(MSVC)
         SET(OPENEXR_LIBSEARCH_SUFFIXES Win32/Release Win32 Win32/Debug)
     endif()
-else()
-    set(OPENEXR_ROOT "")
 endif()
 
-SET(LIBRARY_PATHS
-    /usr/lib
```

Review comment:
condition was removed
**File:** doc/py_tutorials/py_core/py_basic_ops/py_basic_ops.markdown
**Change Type:** modified
**Context:** PR #15832: Grammar fixes for python core operations docs - ### This pullrequest improves the grammar in the following sections: - Basic Operations on ...

**Code Changes:**
```diff
@@ -8,13 +8,13 @@ Learn to:
 
 -   Access pixel values and modify them
 -   Access image properties
--   Setting Region of Interest (ROI)
--   Splitting and Merging images
+-   Set a Region of Interest (ROI)
+-   Split and merge images
 
-Almost all the operations in this section is mainly related to Numpy rather than OpenCV. A good
```

Review comment:
Please revert this change.
**File:** doc/py_tutorials/py_core/py_basic_ops/py_basic_ops.markdown
**Change Type:** modified
**Context:** PR #15832: Grammar fixes for python core operations docs - ### This pullrequest improves the grammar in the following sections: - Basic Operations on ...

**Code Changes:**
```diff
@@ -8,13 +8,13 @@ Learn to:
 
 -   Access pixel values and modify them
 -   Access image properties
--   Setting Region of Interest (ROI)
--   Splitting and Merging images
+-   Set a Region of Interest (ROI)
+-   Split and merge images
 
-Almost all the operations in this section is mainly related to Numpy rather than OpenCV. A good
```

Review comment:
IMHO, this line changed its meaning.
**File:** modules/core/src/opengl.cpp
**Change Type:** modified
**Context:** PR #15658: Cuda + OpenGL on ARM - ### This pull request changes There might be multiple ways of getting OpenCV compile on Tegra (NVIDIA Jetson) platfo...

**Code Changes:**
```diff
@@ -45,6 +45,13 @@
 #ifdef HAVE_OPENGL
 #  include "gl_core_3_1.hpp"
 #  ifdef HAVE_CUDA
+#    if (defined(__arm__) || defined(__aarch64__)) \
+         && !defined(OPENCV_SKIP_CUDA_OPENGL_ARM_WORKAROUND)
+#      include <GL/gl.h>
+#      ifndef GL_VERSION
+#        define GL_VERSION 0x1F02
+#      endif
```

Review comment:
To make robust solution please add option to bypass this workaround: ``` if (defined(__arm__) || defined(__aarch64__)) \ && !defined(OPENCV_SKIP_CUDA_OPENGL_ARM_WORKAROUND) ``` which can be applied via C++ CMake flags.
**File:** modules/core/src/opengl.cpp
**Change Type:** modified
**Context:** PR #15658: Cuda + OpenGL on ARM - ### This pull request changes There might be multiple ways of getting OpenCV compile on Tegra (NVIDIA Jetson) platfo...

**Code Changes:**
```diff
@@ -45,6 +45,13 @@
 #ifdef HAVE_OPENGL
 #  include "gl_core_3_1.hpp"
 #  ifdef HAVE_CUDA
+#    if (defined(__arm__) || defined(__aarch64__)) \
+         && !defined(OPENCV_SKIP_CUDA_OPENGL_ARM_WORKAROUND)
+#      include <GL/gl.h>
+#      ifndef GL_VERSION
+#        define GL_VERSION 0x1F02
+#      endif
```

Review comment:
Should `OPENCV_SKIP_CUDA_OPENGL_ARM_WORKAROUND` workaround be enabled or disabled by default? (I will start with enabled). The current change is derived from the patch for CUDAs to make OpenCV compile with it, and covers exactly the cases which CUDA currently rejects: ```diff --git a/cuda_gl_interop.h b/cuda_gl_interop.h index 0f4aa17..e8c538c 100644 --- a/cuda_gl_interop.h +++ b/cuda_gl_interop.h @@ -59,13 +59,13 @@ #else /* __APPLE__ */ -#if defined(__arm__) || defined(__aarch64__) -#ifndef GL_VERSION -#error Please include the appropriate gl headers before including cuda_gl_interop.h -#endif -#else +//#if defined(__arm__) || defined(__aarch64__) +//#ifndef GL_VERSION +//#error Please include the appropriate gl headers before including cuda_gl_interop.h +//#endif +//#else #include <GL/gl.h> -#endif +//#endif #endif /* __APPLE__ */ ``` re: `patch-1` it is an artifact from github editor, will try to rename them before making PRs
**File:** modules/imgcodecs/src/grfmt_jpeg2000.cpp
**Change Type:** modified
**Context:** PR #13847: Add JPEG2000 compression flag. - I believe the title says it all. Since this is my first PR to the OpenCV repository, I might have missed s...
**Review Line:** 482

**Code Changes:**
```diff
     if( channels > 3 || channels < 1 )
         return false;
 
+    CV_Assert(params.size() % 2 == 0);
+    double target_compression_rate = 1.0;
+    for( size_t i = 0; i < params.size(); i += 2 )
+    {
+        switch(params[i])
+        {
+        case cv::IMWRITE_JPEG2000_COMPRESSION_X1000:
+            target_compression_rate = std::min(std::max(params[i+1], 0), 1000) / 1000.0;
```

Review comment:
there should be check that `params.size() % 2 == 0`
**File:** modules/imgcodecs/src/grfmt_jpeg2000.cpp
**Change Type:** modified
**Context:** PR #13847: Add JPEG2000 compression flag. - I believe the title says it all. Since this is my first PR to the OpenCV repository, I might have missed s...

**Code Changes:**
```diff
@@ -43,6 +43,7 @@
 #include "precomp.hpp"
 
 #ifdef HAVE_JASPER
+#include <sstream>
 
 #include "grfmt_jpeg2000.hpp"
 #include "opencv2/imgproc.hpp"
@@ -467,7 +468,7 @@ bool  Jpeg2KEncoder::isFormatSupported( int depth ) const
 }
```

Review comment:
handle the case when `params[i+1] <= 0` or too big
**File:** modules/imgcodecs/include/opencv2/imgcodecs.hpp
**Change Type:** modified
**Context:** PR #13847: Add JPEG2000 compression flag. - I believe the title says it all. Since this is my first PR to the OpenCV repository, I might have missed s...

**Code Changes:**
```diff
@@ -94,7 +94,8 @@ enum ImwriteFlags {
        IMWRITE_PAM_TUPLETYPE       = 128,//!< For PAM, sets the TUPLETYPE field to the corresponding string value that is defined for the format
        IMWRITE_TIFF_RESUNIT = 256,//!< For TIFF, use to specify which DPI resolution unit to set; see libtiff documentation for valid values
        IMWRITE_TIFF_XDPI = 257,//!< For TIFF, use to specify the X direction DPI
-       IMWRITE_TIFF_YDPI = 258 //!< For TIFF, use to specify the Y direction DPI
+       IMWRITE_TIFF_YDPI = 258, //!< For TIFF, use to specify the Y direction DPI
+       IMWRITE_JPEG2000_COMPRESSION_X1000 = 272 //!< For JPEG2000, use to specify the target compression rate (multiplied by 1000). The value can be from 0 to 1000. Default is 1000.
      };
 
 enum ImwriteEXRTypeFlags {
```

Review comment:
Initial increment was "16" between codecs: "(codec_index << 4) + prop_index" Also we have plans to drop "Jasper" support completely (Jasper project is in abandoned state for several years) and replace it by OpenJPEG. So, how is this property can be mapped into OpenJPEG implementation?
**File:** modules/imgcodecs/src/grfmt_jpeg2000.cpp
**Change Type:** modified
**Context:** PR #13847: Add JPEG2000 compression flag. - I believe the title says it all. Since this is my first PR to the OpenCV repository, I might have missed s...

**Code Changes:**
```diff
@@ -43,6 +43,7 @@
 #include "precomp.hpp"
 
 #ifdef HAVE_JASPER
+#include <sstream>
 
 #include "grfmt_jpeg2000.hpp"
 #include "opencv2/imgproc.hpp"
@@ -467,7 +468,7 @@ bool  Jpeg2KEncoder::isFormatSupported( int depth ) const
 }
```

Review comment:
Very valid point! Concerning the definition of "too big". I guess if 1/compression is numerically 0 is likely a good boundary, right?
**File:** modules/imgcodecs/include/opencv2/imgcodecs.hpp
**Change Type:** modified
**Context:** PR #13847: Add JPEG2000 compression flag. - I believe the title says it all. Since this is my first PR to the OpenCV repository, I might have missed s...

**Code Changes:**
```diff
@@ -94,7 +94,8 @@ enum ImwriteFlags {
        IMWRITE_PAM_TUPLETYPE       = 128,//!< For PAM, sets the TUPLETYPE field to the corresponding string value that is defined for the format
        IMWRITE_TIFF_RESUNIT = 256,//!< For TIFF, use to specify which DPI resolution unit to set; see libtiff documentation for valid values
        IMWRITE_TIFF_XDPI = 257,//!< For TIFF, use to specify the X direction DPI
-       IMWRITE_TIFF_YDPI = 258 //!< For TIFF, use to specify the Y direction DPI
+       IMWRITE_TIFF_YDPI = 258, //!< For TIFF, use to specify the Y direction DPI
+       IMWRITE_JPEG2000_COMPRESSION_X1000 = 272 //!< For JPEG2000, use to specify the target compression rate (multiplied by 1000). The value can be from 0 to 1000. Default is 1000.
      };
 
 enum ImwriteEXRTypeFlags {
```

Review comment:
If it is Jasper specific behavior (without alternative in OpenJPEG) then it is better to avoid using such common name. What is about this name? `IMWRITE_JPEG2000_JASPER_COMPRESSION`
**File:** modules/imgcodecs/src/grfmt_jpeg2000.cpp
**Change Type:** modified
**Context:** PR #13847: Add JPEG2000 compression flag. - I believe the title says it all. Since this is my first PR to the OpenCV repository, I might have missed s...

**Code Changes:**
```diff
@@ -43,6 +43,7 @@
 #include "precomp.hpp"
 
 #ifdef HAVE_JASPER
+#include <sstream>
 
 #include "grfmt_jpeg2000.hpp"
 #include "opencv2/imgproc.hpp"
@@ -467,7 +468,7 @@ bool  Jpeg2KEncoder::isFormatSupported( int depth ) const
 }
```

Review comment:
well, maybe not. Maybe 100 (or even 10) will already be such a big number that the produced image will have very low quality. For example, Photoshop uses the compression quality in from 0 to 12, some other editors use percentage (100% is the best quality, %50 is so-so, closer to 0% the image degrades very much). I think, it would be useful to have some guidance - how this quality parameter maps to the percentage or to the Photoshop scale.
**File:** modules/imgcodecs/src/grfmt_jpeg2000.cpp
**Change Type:** modified
**Context:** PR #13847: Add JPEG2000 compression flag. - I believe the title says it all. Since this is my first PR to the OpenCV repository, I might have missed s...

**Code Changes:**
```diff
@@ -43,6 +43,7 @@
 #include "precomp.hpp"
 
 #ifdef HAVE_JASPER
+#include <sstream>
 
 #include "grfmt_jpeg2000.hpp"
 #include "opencv2/imgproc.hpp"
@@ -467,7 +468,7 @@ bool  Jpeg2KEncoder::isFormatSupported( int depth ) const
 }
```

Review comment:
Hm, a value of 100 would mean a target rate of 1%, i.e. depending on the image it might still be a possible value. I would actually refrain from imposing an artificial upper limit there is no generally applicable limit for this parameter. Maybe, one should point out in the documentation that it is a target, not a guaranteed value?
**File:** modules/imgcodecs/include/opencv2/imgcodecs.hpp
**Change Type:** modified
**Context:** PR #13847: Add JPEG2000 compression flag. - I believe the title says it all. Since this is my first PR to the OpenCV repository, I might have missed s...

**Code Changes:**
```diff
@@ -94,7 +94,8 @@ enum ImwriteFlags {
        IMWRITE_PAM_TUPLETYPE       = 128,//!< For PAM, sets the TUPLETYPE field to the corresponding string value that is defined for the format
        IMWRITE_TIFF_RESUNIT = 256,//!< For TIFF, use to specify which DPI resolution unit to set; see libtiff documentation for valid values
        IMWRITE_TIFF_XDPI = 257,//!< For TIFF, use to specify the X direction DPI
-       IMWRITE_TIFF_YDPI = 258 //!< For TIFF, use to specify the Y direction DPI
+       IMWRITE_TIFF_YDPI = 258, //!< For TIFF, use to specify the Y direction DPI
+       IMWRITE_JPEG2000_COMPRESSION_X1000 = 272 //!< For JPEG2000, use to specify the target compression rate (multiplied by 1000). The value can be from 0 to 1000. Default is 1000.
      };
 
 enum ImwriteEXRTypeFlags {
```

Review comment:
I think this name is fine. However, I am wondering if it makes sense to introduce this enum, if it will be deprecated soon. I will implement the changes later this week, if we agreed on the details.
**File:** modules/imgcodecs/src/grfmt_jpeg2000.cpp
**Change Type:** modified
**Context:** PR #13847: Add JPEG2000 compression flag. - I believe the title says it all. Since this is my first PR to the OpenCV repository, I might have missed s...

**Code Changes:**
```diff
@@ -43,6 +43,7 @@
 #include "precomp.hpp"
 
 #ifdef HAVE_JASPER
+#include <sstream>
 
 #include "grfmt_jpeg2000.hpp"
 #include "opencv2/imgproc.hpp"
@@ -467,7 +468,7 @@ bool  Jpeg2KEncoder::isFormatSupported( int depth ) const
 }
```

Review comment:
It seems that this haven't to behave well: - OpenCV parameter value has "int" type - valid parameter values are 1,2,3,4,... - corresponding `target_compression_rate` are: 1.0, 0.5, 0.333, 0.25 As we can see target values set is very discreet. Do we really need it in this way? (for example, we don't need 66%, 80% compression)
**File:** modules/imgcodecs/src/grfmt_jpeg2000.cpp
**Change Type:** modified
**Context:** PR #13847: Add JPEG2000 compression flag. - I believe the title says it all. Since this is my first PR to the OpenCV repository, I might have missed s...

**Code Changes:**
```diff
@@ -43,6 +43,7 @@
 #include "precomp.hpp"
 
 #ifdef HAVE_JASPER
+#include <sstream>
 
 #include "grfmt_jpeg2000.hpp"
 #include "opencv2/imgproc.hpp"
@@ -467,7 +468,7 @@ bool  Jpeg2KEncoder::isFormatSupported( int depth ) const
 }
```

Review comment:
You are right that the values are discrete due to the `int` type. If you prefer the possible values to be equidistant, I could change the implementation to something similar to the JPEG quality parameter (0-100), where one integer means 1% and 0 corresponds to the smallest possible compression rate. In this case one could rename `COMPRESSION` to `QUALITY`. What do you think?
**File:** modules/imgcodecs/src/grfmt_jpeg2000.cpp
**Change Type:** modified
**Context:** PR #13847: Add JPEG2000 compression flag. - I believe the title says it all. Since this is my first PR to the OpenCV repository, I might have missed s...

**Code Changes:**
```diff
@@ -43,6 +43,7 @@
 #include "precomp.hpp"
 
 #ifdef HAVE_JASPER
+#include <sstream>
 
 #include "grfmt_jpeg2000.hpp"
 #include "opencv2/imgproc.hpp"
@@ -467,7 +468,7 @@ bool  Jpeg2KEncoder::isFormatSupported( int depth ) const
 }
```

Review comment:
Looks like JPEG2000 codecs may have both parameters "COMPRESSION" and "QUALITY": - OpenJPEG compression tool: https://github.com/uclouvain/openjpeg/wiki/DocJ2KCodec (`-r` and `-q`) - Jasper compression: https://www.ece.uvic.ca/~frodo/jasper/jasper.pdf (page 17 - example 3,4 for compression) - Jasper quality - ? and they are different (by behavior). What is about these names: - `IMWRITE_JPEG2000_QUALITY` - range 0-100 (if Jasper has this parameter) - `IMWRITE_JPEG2000_COMPRESSION_X1000`, parameter value is multiplied by 1e-3
**File:** modules/videoio/src/container_avi.cpp
**Change Type:** modified
**Context:** PR #11964: AVI container fixes - Resolves #11841 ### This pullrequest changes * use C++ streams for file I/O * added check for integer overflows in so...
**Review Line:** 22

**Code Changes:**
```diff
+    typedef std::numeric_limits<S> st;
+    typedef std::numeric_limits<D> dt;
+    CV_StaticAssert(st::is_integer && dt::is_integer, "Integer type is expected");
+    const bool in_range_r = (double)val <= (double)dt::max();
+    const bool in_range_l = (double)val >= (double)dt::min();
+    if (!in_range_r || !in_range_l)
+    {
+        CV_Error_(cv::Error::StsOutOfRange, ("Can not convert integer values (%s -> %s), value 0x%llx is out of range", typeid(S).name(), typeid(D).name(), val));
+    }
+    return static_cast<D>(val);
+}
```

Review comment:
since we know the exact context, can we have more specific error message, e.g. "Too long AVI video; it can hold no more than 4Gb of data. Consider another type of container"