nareshmlx/opencv-pr huggingface dataset:
**File:** modules/calib3d/src/stereobm.cpp
**Change Type:** modified
**Context:** PR #11610: StereoBM: fixed SIMD processing for fixed-type output arrays - A check is not done before `findStereoCorrespondenceBM_SIMD` call whether ou...

**Code Changes:**
```diff
@@ -284,7 +284,39 @@ prefilterXSobel( const Mat& src, Mat& dst, int ftzero )
 static const int DISPARITY_SHIFT_16S = 4;
 static const int DISPARITY_SHIFT_32S = 8;
 
+template <typename T>
+struct dispShiftTemplate
+{ };
+
+template<>
+struct dispShiftTemplate<short>
```

Review comment:
In fact, the type check is done in `FindStereoCorrespInvoker` constructor, no need to do it again
**File:** modules/calib3d/src/stereobm.cpp
**Change Type:** modified
**Context:** PR #11610: StereoBM: fixed SIMD processing for fixed-type output arrays - A check is not done before `findStereoCorrespondenceBM_SIMD` call whether ou...

**Code Changes:**
```diff
@@ -284,7 +284,39 @@ prefilterXSobel( const Mat& src, Mat& dst, int ftzero )
 static const int DISPARITY_SHIFT_16S = 4;
 static const int DISPARITY_SHIFT_32S = 8;
 
+template <typename T>
+struct dispShiftTemplate
+{ };
+
+template<>
+struct dispShiftTemplate<short>
```

Review comment:
Purpose of assertion here (and in general of assertions) is to avoid errors in the future during code refactoring. This "if" not complete, it assumes two values only. For example, you want to add CV_32F type, adapt check somewhere (~50 lines from here), update other places, but don't change this block. How many time would you waste for debugging, because program will not crash (sizeof(int) == sizeof(float)), just produce many NaNs?
**File:** modules/videoio/src/videoio_c.cpp
**Change Type:** added
**Context:** PR #11596: videoio: backends priority list - Current fixed priority is not good, especially in case of existence of two separate lists (legacy and new...
**Review Line:** 13

**Code Changes:**
```diff
+
+using namespace cv;
+
+// Legacy C-like API
+
+CV_IMPL CvCapture* cvCreateCameraCapture(int index)
+{
+    // interpret preferred interface (0 = autodetect)
+    int apiPreference = (index / 100) * 100;
+    if (apiPreference)
+    {
```

Review comment:
Previous version of `cvCreateCameraCapture` allows to specify preferred backend as `backend*100+cameraID`. It looks like updated version ignore provided backend.
**File:** modules/videoio/src/videoio_registry.cpp
**Change Type:** added
**Context:** PR #11596: videoio: backends priority list - Current fixed priority is not good, especially in case of existence of two separate lists (legacy and new...
**Review Line:** 323

**Code Changes:**
```diff
+    } catch (const std::exception& e) { \
+        CV_LOG_ERROR(NULL, cv::format("VIDEOIO(%s): raised C++ exception:\n\n%s\n", #backend_func, e.what())); \
+    } catch(...) { \
+        CV_LOG_ERROR(NULL, cv::format("VIDEOIO(%s): raised unknown C++ exception!\n\n", #backend_func)); \
+    } \
+    break; \
+}
+
+#define TRY_OPEN_LEGACY(backend_func) \
+{ \
+    try { \
```

Review comment:
IMHO it would be better to remove unconditional brake here and add it explicitly after every macro call. Explicit brake is already added after almost every `TRY_OPEN`, `TRY_OPEN_LEGACY`. So for a few places without explicit brake it could be unclear that processing will be stopped on first TRY.
**File:** modules/videoio/src/videoio_registry.cpp
**Change Type:** added
**Context:** PR #11596: videoio: backends priority list - Current fixed priority is not good, especially in case of existence of two separate lists (legacy and new...
**Review Line:** 323

**Code Changes:**
```diff
+    } catch (const std::exception& e) { \
+        CV_LOG_ERROR(NULL, cv::format("VIDEOIO(%s): raised C++ exception:\n\n%s\n", #backend_func, e.what())); \
+    } catch(...) { \
+        CV_LOG_ERROR(NULL, cv::format("VIDEOIO(%s): raised unknown C++ exception!\n\n", #backend_func)); \
+    } \
+    break; \
+}
+
+#define TRY_OPEN_LEGACY(backend_func) \
+{ \
+    try { \
```

Review comment:
"break" should be unconditional by design. I added "break"s to make happy IDE (Eclipse CDT). Missing breaks are errors - I will re-check that again.
**File:** modules/videoio/src/videoio_registry.cpp
**Change Type:** added
**Context:** PR #11596: videoio: backends priority list - Current fixed priority is not good, especially in case of existence of two separate lists (legacy and new...
**Review Line:** 323

**Code Changes:**
```diff
+    } catch (const std::exception& e) { \
+        CV_LOG_ERROR(NULL, cv::format("VIDEOIO(%s): raised C++ exception:\n\n%s\n", #backend_func, e.what())); \
+    } catch(...) { \
+        CV_LOG_ERROR(NULL, cv::format("VIDEOIO(%s): raised unknown C++ exception!\n\n", #backend_func)); \
+    } \
+    break; \
+}
+
+#define TRY_OPEN_LEGACY(backend_func) \
+{ \
+    try { \
```

Review comment:
I mean `CAP_VFW` and `CAP_FIREWIRE`. Even though the only define should be active for a given configuration it isn't obvious from the code. So e.g. for `CAP_FIREWIRE` the code looks like `cvCreateCameraCapture_CMU` should override `cvCreateCameraCapture_DC1394` result. Also there will be no log warning if user try to use `CAP_FIREWIRE` backend while it's not enabled.
**File:** modules/videoio/src/videoio_registry.cpp
**Change Type:** added
**Context:** PR #11596: videoio: backends priority list - Current fixed priority is not good, especially in case of existence of two separate lists (legacy and new...
**Review Line:** 323

**Code Changes:**
```diff
+    } catch (const std::exception& e) { \
+        CV_LOG_ERROR(NULL, cv::format("VIDEOIO(%s): raised C++ exception:\n\n%s\n", #backend_func, e.what())); \
+    } catch(...) { \
+        CV_LOG_ERROR(NULL, cv::format("VIDEOIO(%s): raised unknown C++ exception!\n\n", #backend_func)); \
+    } \
+    break; \
+}
+
+#define TRY_OPEN_LEGACY(backend_func) \
+{ \
+    try { \
```

Review comment:
VFW shares **the same** api id with V4L/V4L2 (and can't be used simultaneously). Also there is no way to use multiple FIREWIRE backends - only one can be selected.
**File:** modules/calib3d/src/calibinit.cpp
**Change Type:** modified
**Context:** PR #6895: Improved method for chessboard detection - Ported from #4046 and #6851 by @HHI-VIT-IMC > Modified and improved the method for chessboard det...
**Review Line:** 235

**Code Changes:**
```diff
-            CV_MAT_ELEM( *uv, float, i*2, 0 ) = pts1[j].x;
-            CV_MAT_ELEM( *uv, float, i*2+1, 0 ) = pts1[j].y;
-            i++;
-        }
+      iIdx = i+ii;
+      if (iIdx > 0 && iIdx < 256)
+      {
+        iSmooth += piHist[iIdx];
+      }
+    }
+    piHistSmooth[i] = iSmooth/(2*iWidth+1);
```

Review comment:
```.diff -iIdx > 0 +iIdx >= 0 ``` #11591
**File:** modules/calib3d/src/calibinit.cpp
**Change Type:** modified
**Context:** PR #6895: Improved method for chessboard detection - Ported from #4046 and #6851 by @HHI-VIT-IMC > Modified and improved the method for chessboard det...
**Review Line:** 270

**Code Changes:**
```diff
+  int iMaxPix1 = iMaxPix/100;
+  const int iNumBins = 256;
+  std::vector<int> piHistIntensity(iNumBins, 0);
+  std::vector<int> piHistSmooth(iNumBins, 0);
+  std::vector<int> piHistGrad(iNumBins, 0);
+  std::vector<int> piAccumSum(iNumBins, 0);
+  std::vector<int> piMaxPos(20, 0);
+  int iThresh = 0;
+  int iIdx;
+  int iWidth = 1;
+
```

Review comment:
`piAccumSum` is calculated, but not used anywhere.
**File:** modules/calib3d/src/calibinit.cpp
**Change Type:** modified
**Context:** PR #6895: Improved method for chessboard detection - Ported from #4046 and #6851 by @HHI-VIT-IMC > Modified and improved the method for chessboard det...
**Review Line:** 326

**Code Changes:**
```diff
+  }
+  else if ( iCntMaxima == 2)
+  {
+    iThresh = (piMaxPos[0] + piMaxPos[1])/2;
+  }
+  else // iCntMaxima >= 3
+  {
+    // CHECKING THRESHOLD FOR WHITE
+    int iIdxAccSum = 0, iAccum = 0;
+    for (int i=iNumBins-1; i>0; i--)
+    {
```

Review comment:
Case `iCntMaxima == 0` is lost and incorrectly handled by "iCntMaxima >= 3" code. #11590
**File:** modules/calib3d/src/calibinit.cpp
**Change Type:** modified
**Context:** PR #6895: Improved method for chessboard detection - Ported from #4046 and #6851 by @HHI-VIT-IMC > Modified and improved the method for chessboard det...
**Review Line:** 361

**Code Changes:**
```diff
+
+    //IF TOO CLOSE TO 255, jump to next maximum
+    if ( piMaxPos[iIdxBGMax] >= 250 && iIdxBGMax < iCntMaxima )
+    {
+      iIdxBGMax++;
+      iMaxVal = piHistIntensity[piMaxPos[iIdxBGMax]];
+    }
+
+    for ( int n=iIdxBGMax + 1; n<iCntMaxima; n++)
+    {
+      if ( piHistIntensity[piMaxPos[n]] >= iMaxVal )
```

Review comment:
Pre-condition above should avoid `piMaxPos` buffer overrun on this line: ```.diff -iIdxBGMax < iCntMaxima +iIdxBGMax + 1 < iCntMaxima ``` #11590
**File:** modules/calib3d/src/calibinit.cpp
**Change Type:** modified
**Context:** PR #6895: Improved method for chessboard detection - Ported from #4046 and #6851 by @HHI-VIT-IMC > Modified and improved the method for chessboard det...
**Review Line:** 498

**Code Changes:**
```diff
-                    // empiric threshold level
-                    double mean = cvAvg( img ).val[0];
-                    int thresh_level = cvRound( mean - 10 );
-                    thresh_level = MAX( thresh_level, 10 );
+      //USE BINARY IMAGE COMPUTED USING icvBinarizationHistogramBased METHOD
+      cvDilate( thresh_img_new, thresh_img_new, 0, 1 );
 
-                    cvThreshold( img, thresh_img, thresh_level, 255, CV_THRESH_BINARY );
-                    cvDilate( thresh_img, thresh_img, 0, dilations );
-                }
+      // So we can find rectangles that go to the edge, we draw a white line around the image edge.
```

Review comment:
cvFindContours() (from icvGenerateQuads) modifies image, which becomes changed for next dilation iterations. #11589
**File:** cmake/OpenCVFindLibsGrfmt.cmake
**Change Type:** modified
**Context:** PR #11417: imgcodecs cmake: the option to customize supported formats list - (WITH_HDR, WITH_SUNRASTER, WITH_PXM) There were (and may be still exist) ...

**Code Changes:**
```diff
@@ -252,3 +252,19 @@ if (WITH_GDCM)
     set(GDCM_LIBRARIES gdcmMSFF) # GDCM does not set this variable for some reason
   endif()
 endif()
+
+if(WITH_IMGCODEC_HDR)
+  set(HAVE_IMGCODEC_HDR ON)
+elseif(DEFINED WITH_IMGCODEC_HDR)
+  set(HAVE_IMGCODEC_HDR OFF)
+endif()
```

Review comment:
This block is still required.
**File:** cmake/OpenCVFindLibsGrfmt.cmake
**Change Type:** modified
**Context:** PR #11417: imgcodecs cmake: the option to customize supported formats list - (WITH_HDR, WITH_SUNRASTER, WITH_PXM) There were (and may be still exist) ...

**Code Changes:**
```diff
@@ -252,3 +252,19 @@ if (WITH_GDCM)
     set(GDCM_LIBRARIES gdcmMSFF) # GDCM does not set this variable for some reason
   endif()
 endif()
+
+if(WITH_IMGCODEC_HDR)
+  set(HAVE_IMGCODEC_HDR ON)
+elseif(DEFINED WITH_IMGCODEC_HDR)
+  set(HAVE_IMGCODEC_HDR OFF)
+endif()
```

Review comment:
Modern (5+ years) CMake doesn't expand `WITH_` variables, so these `HAVE_` vars are always true.
**File:** modules/gpu/src/cuda/pyrlk.cu
**Change Type:** modified
**Context:** PR #11060: Thread-safe version of sparse function in cv::gpu::PyrLKOpticalFlow - Issue: The function sparse of cv::gpu::PyrLKOpticalFlow class isn't t...

**Code Changes:**
```diff
@@ -49,6 +49,8 @@
 #include "opencv2/gpu/device/vec_math.hpp"
 #include "opencv2/gpu/device/reduce.hpp"
 
+#include "opencv2/core/core.hpp"
+
 using namespace cv::gpu;
 using namespace cv::gpu::device;
 
@@ -60,12 +62,54 @@ namespace pyrlk
```

Review comment:
Such checks should have this form: `(fabs(D) < ...)`
**File:** modules/gpu/src/pyrlk.cpp
**Change Type:** modified
**Context:** PR #11060: Thread-safe version of sparse function in cv::gpu::PyrLKOpticalFlow - Issue: The function sparse of cv::gpu::PyrLKOpticalFlow class isn't t...

**Code Changes:**
```diff
@@ -42,6 +42,11 @@
 
 #include "precomp.hpp"
 
+#ifdef HAVE_TBB
+#include <tbb/compat/condition_variable>
+#include <tbb/mutex.h>
+#endif
+
 using namespace std;
```

Review comment:
"precomp.hpp" must be the first include in .cpp file.
**File:** modules/gpu/src/pyrlk.cpp
**Change Type:** modified
**Context:** PR #11060: Thread-safe version of sparse function in cv::gpu::PyrLKOpticalFlow - Issue: The function sparse of cv::gpu::PyrLKOpticalFlow class isn't t...

**Code Changes:**
```diff
@@ -42,6 +42,11 @@
 
 #include "precomp.hpp"
 
+#ifdef HAVE_TBB
+#include <tbb/compat/condition_variable>
+#include <tbb/mutex.h>
+#endif
+
 using namespace std;
```

Review comment:
Don't use "tabs"
**File:** modules/gpu/src/pyrlk.cpp
**Change Type:** modified
**Context:** PR #11060: Thread-safe version of sparse function in cv::gpu::PyrLKOpticalFlow - Issue: The function sparse of cv::gpu::PyrLKOpticalFlow class isn't t...

**Code Changes:**
```diff
@@ -42,6 +42,11 @@
 
 #include "precomp.hpp"
 
+#ifdef HAVE_TBB
+#include <tbb/compat/condition_variable>
+#include <tbb/mutex.h>
+#endif
+
 using namespace std;
```

Review comment:
Ok, I'm going to change pthreads by c++11 std::mutex and std::condition_variable and add accuracy tests and performance tests
**File:** modules/gpu/src/pyrlk.cpp
**Change Type:** modified
**Context:** PR #11060: Thread-safe version of sparse function in cv::gpu::PyrLKOpticalFlow - Issue: The function sparse of cv::gpu::PyrLKOpticalFlow class isn't t...

**Code Changes:**
```diff
@@ -42,6 +42,11 @@
 
 #include "precomp.hpp"
 
+#ifdef HAVE_TBB
+#include <tbb/compat/condition_variable>
+#include <tbb/mutex.h>
+#endif
+
 using namespace std;
```

Review comment:
C++11 is not allowed for OpenCV 2.4/3.x - C++98 is required.
**File:** samples/cpp/gstreamer_pipeline.cpp
**Change Type:** modified
**Context:** PR #11482: Remove command line argument related to container - ``` docker_image:Linux x64 Debug=gstreamer:16.04 buildworker:Win64 OpenCL=windows-2 doc...

**Code Changes:**
```diff
@@ -18,7 +18,6 @@ class GStreamerPipeline
               "{h help usage ? |           | print help messages   }"
               "{m mode         |           | coding mode (supported: encode, decode) }"
               "{p pipeline     |default    | pipeline name  (supported: 'default', 'gst-basic', 'gst-vaapi', 'gst-libav', 'ffmpeg') }"
-              "{ct container   |mp4        | container name (supported: 'mp4', 'mov', 'avi', 'mkv') }"
               "{cd codec       |h264       | codec name     (supported: 'h264', 'h265', 'mpeg2', 'mpeg4', 'mjpeg', 'vp8') }"
               "{f file path    |           | path to file }"
               "{vr resolution  |720p       | video resolution for encoding (supported: '720p', '1080p', '4k') }"
@@ -30,32 +29,36 @@ class GStreamerPipeline
         if (cmd_parser->has("help"))
```

Review comment:
1. `find()` => `rfind()` 2. add validation for files with missing dot '.'
**File:** samples/cpp/gstreamer_pipeline.cpp
**Change Type:** modified
**Context:** PR #11482: Remove command line argument related to container - ``` docker_image:Linux x64 Debug=gstreamer:16.04 buildworker:Win64 OpenCL=windows-2 doc...

**Code Changes:**
```diff
@@ -18,7 +18,6 @@ class GStreamerPipeline
               "{h help usage ? |           | print help messages   }"
               "{m mode         |           | coding mode (supported: encode, decode) }"
               "{p pipeline     |default    | pipeline name  (supported: 'default', 'gst-basic', 'gst-vaapi', 'gst-libav', 'ffmpeg') }"
-              "{ct container   |mp4        | container name (supported: 'mp4', 'mov', 'avi', 'mkv') }"
               "{cd codec       |h264       | codec name     (supported: 'h264', 'h265', 'mpeg2', 'mpeg4', 'mjpeg', 'vp8') }"
               "{f file path    |           | path to file }"
               "{vr resolution  |720p       | video resolution for encoding (supported: '720p', '1080p', '4k') }"
@@ -30,32 +29,36 @@ class GStreamerPipeline
         if (cmd_parser->has("help"))
```

Review comment:
`exit_code = -1` is useless here, because it is overrided on line 59. The same problem is with lines 32, 57. "exit_code" should be removed (anywhere) and replaced to `throw std::exception("message")` or early return.
**File:** samples/cpp/gstreamer_pipeline.cpp
**Change Type:** modified
**Context:** PR #11482: Remove command line argument related to container - ``` docker_image:Linux x64 Debug=gstreamer:16.04 buildworker:Win64 OpenCL=windows-2 doc...

**Code Changes:**
```diff
@@ -18,7 +18,6 @@ class GStreamerPipeline
               "{h help usage ? |           | print help messages   }"
               "{m mode         |           | coding mode (supported: encode, decode) }"
               "{p pipeline     |default    | pipeline name  (supported: 'default', 'gst-basic', 'gst-vaapi', 'gst-libav', 'ffmpeg') }"
-              "{ct container   |mp4        | container name (supported: 'mp4', 'mov', 'avi', 'mkv') }"
               "{cd codec       |h264       | codec name     (supported: 'h264', 'h265', 'mpeg2', 'mpeg4', 'mjpeg', 'vp8') }"
               "{f file path    |           | path to file }"
               "{vr resolution  |720p       | video resolution for encoding (supported: '720p', '1080p', '4k') }"
@@ -30,32 +29,36 @@ class GStreamerPipeline
         if (cmd_parser->has("help"))
```

Review comment:
In case of "-help" we can just call `exit(0);` after the message output. For other errors: `throw std::exception("Error message here");` Exception handling in main: ``` catch (const std::exception& e) { std::cerr << "Exception: " << e.what() << std::endl; return 1; } ```
**File:** samples/cpp/gstreamer_pipeline.cpp
**Change Type:** modified
**Context:** PR #11482: Remove command line argument related to container - ``` docker_image:Linux x64 Debug=gstreamer:16.04 buildworker:Win64 OpenCL=windows-2 doc...

**Code Changes:**
```diff
@@ -18,7 +18,6 @@ class GStreamerPipeline
               "{h help usage ? |           | print help messages   }"
               "{m mode         |           | coding mode (supported: encode, decode) }"
               "{p pipeline     |default    | pipeline name  (supported: 'default', 'gst-basic', 'gst-vaapi', 'gst-libav', 'ffmpeg') }"
-              "{ct container   |mp4        | container name (supported: 'mp4', 'mov', 'avi', 'mkv') }"
               "{cd codec       |h264       | codec name     (supported: 'h264', 'h265', 'mpeg2', 'mpeg4', 'mjpeg', 'vp8') }"
               "{f file path    |           | path to file }"
               "{vr resolution  |720p       | video resolution for encoding (supported: '720p', '1080p', '4k') }"
@@ -30,32 +29,36 @@ class GStreamerPipeline
         if (cmd_parser->has("help"))
```

Review comment:
`const` reference should be here - you are not going to modify exception object. http://en.cppreference.com/w/cpp/language/try_catch
**File:** modules/imgproc/src/smooth.cpp
**Change Type:** modified
**Context:** PR #10898: Bit-exact GaussianBlur performance update - ### This pullrequest changes Reworked evaluation of bit-exact GaussianBlur to improve performan...

**Code Changes:**
```diff
@@ -1826,15 +1826,15 @@ void hlineSmooth1N<uint8_t, ufixedpoint16>(const uint8_t* src, int cn, const ufi
     int lencn = len*cn;
     v_uint16x8 v_mul = v_setall_u16(*((uint16_t*)m));
     int i = 0;
-    for (; i < lencn - 15; i += 16)
+    for (; i <= lencn - 16; i += 16)
     {
         v_uint8x16 v_src = v_load(src + i);
         v_uint16x8 v_tmp0, v_tmp1;
         v_expand(v_src, v_tmp0, v_tmp1);
```

Review comment:
Current OpenCV pattern for such loops is: ``` for (; i <= len - <vec_width>; i += <vec_width>) { ... } ``` Using of different constants should be avoided (16/15)
**File:** modules/imgproc/src/smooth.cpp
**Change Type:** modified
**Context:** PR #10898: Bit-exact GaussianBlur performance update - ### This pullrequest changes Reworked evaluation of bit-exact GaussianBlur to improve performan...
**Review Line:** 3232

**Code Changes:**
```diff
+        v_src02 = v_load((int16_t*)(src[2]) + i + 16);
+        v_src03 = v_load((int16_t*)(src[2]) + i + 24);
+        v_src10 = v_load((int16_t*)(src[3]) + i);
+        v_src11 = v_load((int16_t*)(src[3]) + i + 8);
+        v_src12 = v_load((int16_t*)(src[3]) + i + 16);
+        v_src13 = v_load((int16_t*)(src[3]) + i + 24);
+        v_zip(v_add_wrap(v_src00, v_128), v_add_wrap(v_src10, v_128), v_tmp0, v_tmp1);
         v_res0 += v_dotprod(v_tmp0, v_mul23);
         v_res1 += v_dotprod(v_tmp1, v_mul23);
+        v_zip(v_add_wrap(v_src01, v_128), v_add_wrap(v_src11, v_128), v_tmp0, v_tmp1);
+        v_res2 += v_dotprod(v_tmp0, v_mul23);
```

Review comment:
SSE/AVX instruction set has 16 vector registers only. `v_res{0, 7}` (8) and `v_src*` (8) + external `v_mul*` + other exceeds registers pool. Are you sure that there is no register spilling into stack?
**File:** modules/imgproc/src/fixedpoint.inl.hpp
**Change Type:** modified
**Context:** PR #10898: Bit-exact GaussianBlur performance update - ### This pullrequest changes Reworked evaluation of bit-exact GaussianBlur to improve performan...
**Review Line:** 71

**Code Changes:**
```diff
@@ -61,23 +67,29 @@ class fixedpoint64
         uint64_t val0_h = (sh2   & 0xFFFFFFFF) + (sh1_0 >> 32) + (sh1_1 >> 32) + (val0_l >> 32);
         val0_l &= 0xFFFFFFFF;
 
+        if ( (sh2 >> 32) || (val0_h >> ressign ? 32 : 31) )
+            return (ressign ? ~(int64_t)0x7FFFFFFFFFFFFFFF : (int64_t)0x7FFFFFFFFFFFFFFF);
+
         if (ressign)
         {
             val0_l = (~val0_l + 1) & 0xFFFFFFFF;
             val0_h = val0_l ? ~val0_h : (~val0_h + 1);
```

Review comment:
Created issue #11330
**File:** modules/core/include/opencv2/core/hal/intrin_cpp.hpp
**Change Type:** modified
**Context:** PR #11332: core(hal): improve v_select() SSE4.1+ - Make `v_select()` eliment-wise (instead of bit-wise). `v_select()` `mask` is restricted to these va...

**Code Changes:**
```diff
@@ -1039,13 +1039,16 @@ template<typename _Tp, int n> inline bool v_check_any(const v_reg<_Tp, n>& a)
     return false;
 }
 
-/** @brief Bitwise select
+/** @brief Per-element select (blend operation)
 
-Return value will be built by combining values a and b using the following scheme:
-If the i-th bit in _mask_ is 1
-    select i-th bit from _a_
```

Review comment:
BTW, This semantic is compatible with OpenCL: https://www.khronos.org/registry/OpenCL/sdk/1.2/docs/man/xhtml/select.html
**File:** modules/ts/include/opencv2/ts/ocl_test.hpp
**Change Type:** modified
**Context:** PR #11315: ARM: add new comparison to tolerate with rounding error - * clean up the source code * remove unused variable (eps) * remove unused member ...

**Code Changes:**
```diff
@@ -122,6 +122,25 @@ do \
     << "Size: " << mat1.size() << std::endl; \
 } while ((void)0, 0)
 
+#define OCL_EXPECT_MAT_N_DIFF(name, eps) \
+do \
+{ \
+    ASSERT_EQ(name ## _roi.type(), u ## name ## _roi.type()); \
+    ASSERT_EQ(name ## _roi.size(), u ## name ## _roi.size()); \
+    Mat diff, binary, binary_8; \
```

Review comment:
Number of pixels on border (`O(rows+cols)`) is much less than total number of pixels (`rows*cols`). So this condition may not detect problems with incorrect processing of border pixels. BTW, What kind of source images for failed tests? If processed images are just "noise", then it is probably better to replace of these inputs (I can help to prepare some synthetic images).
**File:** modules/ts/include/opencv2/ts/ocl_test.hpp
**Change Type:** modified
**Context:** PR #11315: ARM: add new comparison to tolerate with rounding error - * clean up the source code * remove unused variable (eps) * remove unused member ...

**Code Changes:**
```diff
@@ -122,6 +122,25 @@ do \
     << "Size: " << mat1.size() << std::endl; \
 } while ((void)0, 0)
 
+#define OCL_EXPECT_MAT_N_DIFF(name, eps) \
+do \
+{ \
+    ASSERT_EQ(name ## _roi.type(), u ## name ## _roi.type()); \
+    ASSERT_EQ(name ## _roi.size(), u ## name ## _roi.size()); \
+    Mat diff, binary, binary_8; \
```

Review comment:
My point about the border is that if we processing border incorrectly, then this check may pass and the problem may not be detected. > `(int)(binary.cols*binary.rows*5/1000)`