nareshmlx/opencv-pr huggingface dataset:
**File:** modules/videoio/src/cap_ffmpeg_hw.hpp
**Change Type:** modified
**Context:** PR #19755: cv::UMat output/input in VideoCapture/VideoWriter (data stays in GPU memory)

**Code Changes:**
```diff
@@ -5,7 +5,10 @@
 // Copyright (C) 2020-2021 Intel Corporation
 
 #include "opencv2/videoio.hpp"
-#if defined(__OPENCV_BUILD) || defined(OPENCV_HAVE_CVCONFIG_H)  // TODO Properly detect and add D3D11 / LIBVA dependencies for standalone plugins
+#ifdef HAVE_OPENCL
+#include "opencv2/core/ocl.hpp"
+#endif
+#if defined(__OPENCV_BUILD) && !defined(BUILD_PLUGIN)  // TODO Properly detect and add D3D11 / LIBVA dependencies for standalone plugins
 #include "cvconfig.h"
```

Review comment:
There is an regression for case with disabled OpenCL subsystem in OpenCV through `OPENCV_OPENCL_RUNTIME=disabled`. Both Mat / UMat test cases don't work (skipped) with messages: ``` [OPENCV:FFMPEG:40] VAAPI driver: Intel iHD driver for Intel(R) Gen Graphics - 20.4.5 (74e2f111). [OPENCV:FFMPEG:40] Driver not found in known nonstandard list, using standard behaviour. [ INFO:0] global /home/alalek/projects/opencv/dev/modules/videoio/src/cap_ffmpeg_hw.hpp (268) hw_check_device FFMPEG: Using vaapi video acceleration on device: Intel iHD driver for Intel(R) Gen Graphics - 20.4.5 (74e2f111) [ INFO:0] global /home/alalek/projects/opencv/dev/modules/videoio/src/cap_ffmpeg_hw.hpp (559) hw_create_device FFMPEG: Created video acceleration context (av_hwdevice_ctx_create) for vaapi on device 'default' [ERROR:0] global /home/alalek/projects/opencv/dev/modules/videoio/src/cap.cpp (160) open VIDEOIO(FFMPEG): raised OpenCV exception: OpenCV(4.5.2-dev) /home/alalek/projects/opencv/dev/modules/core/src/opencl/runtime/opencl_core.cpp:378: error: (-220:Unknown error code -220) OpenCL function is not available: [clGetPlatformIDs] in function 'opencl_check_fn' [ SKIP ] FFMPEG VideoCapture on sample_322x242_15frames.yuv420p.libx264.mp4 not supported with HW acceleration, skipping ```
**File:** modules/core/include/opencv2/core/ocl.hpp
**Change Type:** modified
**Context:** PR #19755: cv::UMat output/input in VideoCapture/VideoWriter (data stays in GPU memory)

**Code Changes:**
```diff
@@ -43,6 +43,8 @@
 #define OPENCV_OPENCL_HPP
 
 #include "opencv2/core.hpp"
+#include <typeinfo>
+#include <typeindex>
 
 namespace cv { namespace ocl {
 
@@ -277,6 +279,12 @@ class CV_EXPORTS Context
```

Review comment:
As we want to work with OpenCL enums lets use more specific method name `getOpenCLContextProperty()` and add note to doc string about returned values and passed parameter (extract properties through `clGetContextInfo(CL_CONTEXT_PROPERTIES)` call)
**File:** modules/core/src/ocl.cpp
**Change Type:** modified
**Context:** PR #19755: cv::UMat output/input in VideoCapture/VideoWriter (data stays in GPU memory)

**Code Changes:**
```diff
@@ -113,10 +113,6 @@
 
 #include "opencv2/core/opencl/runtime/opencl_core.hpp"
 
-#ifdef HAVE_DIRECTX
-#include "directx.hpp"
-#endif
-
 #ifdef HAVE_OPENCL_SVM
 #include "opencv2/core/opencl/runtime/opencl_svm_20.hpp"
```

Review comment:
Just a question: can we cache this properties array? or its contents can be changed in runtime
**File:** modules/core/include/opencv2/core/ocl.hpp
**Change Type:** modified
**Context:** PR #19755: cv::UMat output/input in VideoCapture/VideoWriter (data stays in GPU memory)
**Review Line:** 307

**Code Changes:**
```diff
+    public:
+        virtual ~UserContext();
+    };
+    template <typename T>
+    inline void setUserContext(const std::shared_ptr<T>& userContext) {
+        setUserContext(typeid(T), userContext);
+    }
+    template <typename T>
+    inline std::shared_ptr<T> getUserContext() {
+        return std::dynamic_pointer_cast<T>(getUserContext(typeid(T)));
+    }
```

Review comment:
Great idea! > `std::shared_ptr<T>` const reference? inline?
**File:** modules/core/include/opencv2/core/ocl.hpp
**Change Type:** modified
**Context:** PR #19755: cv::UMat output/input in VideoCapture/VideoWriter (data stays in GPU memory)

**Code Changes:**
```diff
@@ -43,6 +43,8 @@
 #define OPENCV_OPENCL_HPP
 
 #include "opencv2/core.hpp"
+#include <typeinfo>
+#include <typeindex>
 
 namespace cv { namespace ocl {
 
@@ -277,6 +279,12 @@ class CV_EXPORTS Context
```

Review comment:
It makes sense to put destructor implementation in .cpp file. Otherwise "full header" classes may lead to RTTI issues (e.g. with clang - it creates independent clones in each module)
**File:** modules/videoio/src/cap_ffmpeg_impl.hpp
**Change Type:** modified
**Context:** PR #19755: cv::UMat output/input in VideoCapture/VideoWriter (data stays in GPU memory)

**Code Changes:**
```diff
@@ -476,6 +476,7 @@ struct CvCapture_FFMPEG
     bool setProperty(int, double);
     bool grabFrame();
     bool retrieveFrame(int, unsigned char** data, int* step, int* width, int* height, int* cn);
+    bool retrieveHWFrame(cv::OutputArray output);
     void rotateFrame(cv::Mat &mat) const;
 
     void init();
@@ -537,6 +538,7 @@ struct CvCapture_FFMPEG
 #endif
```

Review comment:
Perhaps robust check should check UMat's OpenCL context.
**File:** modules/core/src/ocl.cpp
**Change Type:** modified
**Context:** PR #19755: cv::UMat output/input in VideoCapture/VideoWriter (data stays in GPU memory)

**Code Changes:**
```diff
@@ -113,10 +113,6 @@
 
 #include "opencv2/core/opencl/runtime/opencl_core.hpp"
 
-#ifdef HAVE_DIRECTX
-#include "directx.hpp"
-#endif
-
 #ifdef HAVE_OPENCL_SVM
 #include "opencv2/core/opencl/runtime/opencl_svm_20.hpp"
```

Review comment:
OpenCL doesn't allow to change properties (I would really like to have such ability - change media context property after context creation;) But properties cached by OpenCL user-mode library, so these these two calls should work very fast. Is it ok, or better cache on OpenCV side?
**File:** modules/videoio/src/cap_ffmpeg_impl.hpp
**Change Type:** modified
**Context:** PR #19755: cv::UMat output/input in VideoCapture/VideoWriter (data stays in GPU memory)

**Code Changes:**
```diff
@@ -476,6 +476,7 @@ struct CvCapture_FFMPEG
     bool setProperty(int, double);
     bool grabFrame();
     bool retrieveFrame(int, unsigned char** data, int* step, int* width, int* height, int* cn);
+    bool retrieveHWFrame(cv::OutputArray output);
     void rotateFrame(cv::Mat &mat) const;
 
     void init();
@@ -537,6 +538,7 @@ struct CvCapture_FFMPEG
 #endif
```

Review comment:
It would require code like below? ``` CV_Assert(u.u && u.u->currAllocator == ocl::getOpenCLAllocator()); CV_Assert(std::static_pointer_cast<ocl::Context>(u.u->allocatorContext)->ptr() == ocl_context.getContext().ptr()); ``` I believe SetKernelArgument will throw exception if wrong context, and this code under try/catch - is it ok or better check context?
**File:** modules/videoio/src/cap_ffmpeg_impl.hpp
**Change Type:** modified
**Context:** PR #19755: cv::UMat output/input in VideoCapture/VideoWriter (data stays in GPU memory)

**Code Changes:**
```diff
@@ -476,6 +476,7 @@ struct CvCapture_FFMPEG
     bool setProperty(int, double);
     bool grabFrame();
     bool retrieveFrame(int, unsigned char** data, int* step, int* width, int* height, int* cn);
+    bool retrieveHWFrame(cv::OutputArray output);
     void rotateFrame(cv::Mat &mat) const;
 
     void init();
@@ -537,6 +538,7 @@ struct CvCapture_FFMPEG
 #endif
```

Review comment:
Not sure that OpenCL CTS has checks for "wrong context" cases. I would prefer to raise OpenCV exception instead of crash in OpenCL runtime internals.
**File:** modules/core/src/directx.cpp
**Change Type:** modified
**Context:** PR #19755: cv::UMat output/input in VideoCapture/VideoWriter (data stays in GPU memory)
**Review Line:** 260

**Code Changes:**
```diff
-            CV_Error(cv::Error::OpenCLInitError, "OpenCL: No supported extensions");
-#else
-        if (!is_support_cl_khr_d3d11_sharing)
-            CV_Error(cv::Error::OpenCLInitError, "OpenCL: No supported extensions");
+    ~OpenCL_D3D11_NV() {
+        device->Release();
+    }
+    ID3D11Device* device;
+    clCreateFromD3D11Texture2DNV_fn clCreateFromD3D11Texture2DNV;
+    clEnqueueAcquireD3D11ObjectsNV_fn clEnqueueAcquireD3D11ObjectsNV;
+    clEnqueueReleaseD3D11ObjectsNV_fn clEnqueueReleaseD3D11ObjectsNV;
```

Review comment:
Can't reproduce in my environment so far. Could be (at least) two potential reasons 1. Clean-up order - as it's after ExitProcess, is it possible that some global d3d11/dxgi resources already closed at time device Release called? 2. Incorrect manipulation (directly or indirectly) with d3d device reference counter, so that Release called on already destroyed object I tried to check that it's not 2 (which is bad) by inserting ``` ocl::OpenCLExecutionContext::getCurrent().release() ``` into sample `video_acceleration` right before exiting function main, works ok. For similar experiment in tests, is there easy way to close OpenCL context after all tests finished but before ExitProcess?
**File:** modules/core/src/directx.cpp
**Change Type:** modified
**Context:** PR #19755: cv::UMat output/input in VideoCapture/VideoWriter (data stays in GPU memory)
**Review Line:** 260

**Code Changes:**
```diff
-            CV_Error(cv::Error::OpenCLInitError, "OpenCL: No supported extensions");
-#else
-        if (!is_support_cl_khr_d3d11_sharing)
-            CV_Error(cv::Error::OpenCLInitError, "OpenCL: No supported extensions");
+    ~OpenCL_D3D11_NV() {
+        device->Release();
+    }
+    ID3D11Device* device;
+    clCreateFromD3D11Texture2DNV_fn clCreateFromD3D11Texture2DNV;
+    clEnqueueAcquireD3D11ObjectsNV_fn clEnqueueAcquireD3D11ObjectsNV;
+    clEnqueueReleaseD3D11ObjectsNV_fn clEnqueueReleaseD3D11ObjectsNV;
```

Review comment:
> is there easy way to close OpenCL context after all tests finished We can do that in our tests. But problem itself would migrate to OpenCV Users because we just "hides" that. --- We have similar issues with OpenCL, so there are several workarounds to avoid calling of any release functions after "ExitProcess" (see `__termination` flag).
**File:** modules/core/src/directx.cpp
**Change Type:** modified
**Context:** PR #19755: cv::UMat output/input in VideoCapture/VideoWriter (data stays in GPU memory)
**Review Line:** 260

**Code Changes:**
```diff
-            CV_Error(cv::Error::OpenCLInitError, "OpenCL: No supported extensions");
-#else
-        if (!is_support_cl_khr_d3d11_sharing)
-            CV_Error(cv::Error::OpenCLInitError, "OpenCL: No supported extensions");
+    ~OpenCL_D3D11_NV() {
+        device->Release();
+    }
+    ID3D11Device* device;
+    clCreateFromD3D11Texture2DNV_fn clCreateFromD3D11Texture2DNV;
+    clEnqueueAcquireD3D11ObjectsNV_fn clEnqueueAcquireD3D11ObjectsNV;
+    clEnqueueReleaseD3D11ObjectsNV_fn clEnqueueReleaseD3D11ObjectsNV;
```

Review comment:
I mean modify tests temporary for experimental purpose - if call to release OpenCL context before ExitProcess causes crash, it definitely requires investigation and fix; if no crash, should be ok to add workarounds targeted specifically for termination process?
**File:** modules/core/src/directx.cpp
**Change Type:** modified
**Context:** PR #19755: cv::UMat output/input in VideoCapture/VideoWriter (data stays in GPU memory)
**Review Line:** 260

**Code Changes:**
```diff
-            CV_Error(cv::Error::OpenCLInitError, "OpenCL: No supported extensions");
-#else
-        if (!is_support_cl_khr_d3d11_sharing)
-            CV_Error(cv::Error::OpenCLInitError, "OpenCL: No supported extensions");
+    ~OpenCL_D3D11_NV() {
+        device->Release();
+    }
+    ID3D11Device* device;
+    clCreateFromD3D11Texture2DNV_fn clCreateFromD3D11Texture2DNV;
+    clEnqueueAcquireD3D11ObjectsNV_fn clEnqueueAcquireD3D11ObjectsNV;
+    clEnqueueReleaseD3D11ObjectsNV_fn clEnqueueReleaseD3D11ObjectsNV;
```

Review comment:
> for experimental purpose Adding `ocl::OpenCLExecutionContext::getCurrent().release();` into the test's main() function eliminates crash. --- `__termination` flag is not enabled in this problematic code flow (`DllMain()` is not called, cleanup is performed through FLS): ``` ... 20 000000e6`622ff790 00007ff9`ddc6b690 opencv_core452!cv::TLSData<cv::CoreTLSData>::deleteDataInstance+0x47 [C:\build\precommit_custom_windows\opencv\modules\core\include\opencv2\core\utils\tls.hpp @ 82] 21 000000e6`622ff7c0 00007ffa`18eeddd5 opencv_core452!cv::details::TlsStorage::releaseThread+0x130 [C:\build\precommit_custom_windows\opencv\modules\core\src\system.cpp @ 1571] 22 000000e6`622ff800 00007ffa`18eedae8 ntdll!RtlpFlsDataCleanup+0x121 23 000000e6`622ff840 00007ffa`18eeda2d ntdll!LdrShutdownProcess+0x98 24 000000e6`622ff940 00007ffa`1731e0ab ntdll!RtlExitUserProcess+0xad 25 000000e6`622ff970 00007ffa`16a405bc KERNEL32!ExitProcessImplementation+0xb 26 000000e6`622ff9a0 00007ffa`16a4045f ucrtbase!exit_or_terminate_process+0x44 27 000000e6`622ff9d0 00007ff7`81b0718b ucrtbase!common_exit+0x6f 28 000000e6`622ffa20 00007ffa`17317034 opencv_test_videoio!__scrt_common_main_seh+0x173 [D:\agent\_work\9\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl @ 295] 29 000000e6`622ffa60 00007ffa`18ee2651 KERNEL32!BaseThreadInitThunk+0x14 2a 000000e6`622ffa90 00000000`00000000 ntdll!RtlUserThreadStart+0x21 ``` Will take a look how to deal this that case.
**File:** CMakeLists.txt
**Change Type:** modified
**Context:** PR #19755: cv::UMat output/input in VideoCapture/VideoWriter (data stays in GPU memory)

**Code Changes:**
```diff
@@ -1420,7 +1420,16 @@ if(WITH_LIBREALSENSE OR HAVE_LIBREALSENSE)
 endif()
 
 if(WITH_MFX OR HAVE_MFX)
-  status("    Intel Media SDK:" HAVE_MFX      THEN "YES (${MFX_LIBRARY})" ELSE NO)
+  if(HAVE_MFX)
+    if(MFX_LIBRARY)
+      set(__details " (${MFX_LIBRARY})")
+    elseif(MFX_LIBRARIES)
+      set(__details " (${MFX_LIBRARIES})")
```

Review comment:
```suggestion set(__details " (${MFX_LIBRARY})") ``` A curly brace is missing here.
**File:** modules/videoio/src/cap_ffmpeg_hw.hpp
**Change Type:** modified
**Context:** PR #19755: cv::UMat output/input in VideoCapture/VideoWriter (data stays in GPU memory)
**Review Line:** 116

**Code Changes:**
```diff
@@ -80,7 +113,7 @@ std::string getDecoderConfiguration(VideoAccelerationType va_type, AVDictionary
     case VIDEO_ACCELERATION_ANY: return "vaapi.iHD";
     case VIDEO_ACCELERATION_D3D11: return "";
     case VIDEO_ACCELERATION_VAAPI: return "vaapi.iHD";
-    case VIDEO_ACCELERATION_MFX: return "";
+    case VIDEO_ACCELERATION_MFX: return "qsv.iHD";
     }
     return "";
 #endif
@@ -125,7 +158,6 @@ std::string getEncoderConfiguration(VideoAccelerationType va_type, AVDictionary
 #endif
```

Review comment:
No easy workaround. ffmpeg-qsv decoder designed with delayed initialization, the `MFXVideoDECODE_Init` called on decoding first frame, it's too late for fallback to SW decoder in current implementation. No such problem in VAAPI and D3D11 decoders as they report all errors on opening stage (av_codec_open2 call). Disable MFX decode (revert "qsv.iHD" back to empty string "") or keep as known issue in case MFX acceleration explicitly requested?
**File:** modules/videoio/cmake/detect_ffmpeg.cmake
**Change Type:** modified
**Context:** PR #19755: cv::UMat output/input in VideoCapture/VideoWriter (data stays in GPU memory)
**Review Line:** 115

**Code Changes:**
```diff
+    if(OPENCL_INCLUDE_DIRS)
+      set(__opencl_dirs "${OPENCL_INCLUDE_DIRS}")
+    elseif(OPENCL_INCLUDE_DIR)
+      set(__opencl_dirs "${OPENCL_INCLUDE_DIR}")
+    else()
+      set(__opencl_dirs "${OpenCV_SOURCE_DIR}/3rdparty/include/opencl/1.2")
+    endif()
+    # extra dependencies for buildin code (OpenCL dir is required for extensions like cl_d3d11.h)
+    # buildin HAVE_OPENCL is already defined through cvconfig.h
+    list(APPEND __builtin_include_dirs "${__opencl_dirs}")
+
```

Review comment:
I observe cmake error in some configurations: ``` CMake Error in modules/CMakeLists.txt: Target "ocv.3rdparty.ffmpeg.builtin_deps" INTERFACE_INCLUDE_DIRECTORIES property contains path: "/opencv/3rdparty/include/opencl/1.2" which is prefixed in the source directory. ``` It seem to be related to installation process: https://stackoverflow.com/questions/25676277/cmake-target-include-directories-prints-an-error-when-i-try-to-add-the-source
**File:** samples/dnn/dnn_model_runner/dnn_conversion/paddlepaddle/paddle_resnet50.py
**Change Type:** added
**Context:** PR #19976: Added PaddlePaddle classification model conversion case

**Code Changes:**
```diff
@@ -0,0 +1,61 @@
+import paddle
+import paddlehub as hub
+import paddlehub.vision.transforms as T
+import cv2 as cv
+import numpy as np
+
+
+def preprocess(image_path):
+    ''' preprocess input image file to np.ndarray
```

Review comment:
please, replace it with `import cv2 as cv` and then replace `cv2.` below with `cv.`
**File:** modules/imgcodecs/src/grfmt_exr.cpp
**Change Type:** modified
**Context:** PR #19998: Fix OpenCV build with OpenEXR before 2.2.0

**Code Changes:**
```diff
@@ -64,6 +64,7 @@
 #include <ImfStandardAttributes.h>
 #include <half.h>
 #include "grfmt_exr.hpp"
+#include "OpenEXRConfig.h"
 
 #if defined _WIN32
 
@@ -649,12 +650,14 @@ bool  ExrEncoder::write( const Mat& img, const std::vector<int>& params )
             case IMWRITE_EXR_COMPRESSION_B44A:
```

Review comment:
I think this check would not work with `OPENEXR_VERSION_MAJOR=3` and `OPENEXR_VERSION_MINOR=0`.
**File:** modules/gapi/src/backends/fluid/gfluidcore.cpp
**Change Type:** modified
**Context:** PR #18466: GAPI: SIMD optimization for AddWeighted kernel. - SIMD optimization for AddWeighted kernel via universal intrinsics. <cut/> ``` force_build...

**Code Changes:**
```diff
@@ -97,6 +97,130 @@ static inline DST divr(SRC1 x, SRC2 y, float scale=1)
 // Fluid kernels: addWeighted
 //
 //---------------------------
+#if CV_SSE2
+CV_ALWAYS_INLINE v_float32 v_load_f32(const ushort* in)
+{
+    return v_cvt_f32(v_reinterpret_as_s32(vx_load_expand(in)));
+}
+
```

Review comment:
`v_fma` could be used here
**File:** modules/gapi/src/backends/fluid/gfluidcore.cpp
**Change Type:** modified
**Context:** PR #18466: GAPI: SIMD optimization for AddWeighted kernel. - SIMD optimization for AddWeighted kernel via universal intrinsics. <cut/> ``` force_build...

**Code Changes:**
```diff
@@ -97,6 +97,130 @@ static inline DST divr(SRC1 x, SRC2 y, float scale=1)
 // Fluid kernels: addWeighted
 //
 //---------------------------
+#if CV_SSE2
+CV_ALWAYS_INLINE v_float32 v_load_f32(const ushort* in)
+{
+    return v_cvt_f32(v_reinterpret_as_s32(vx_load_expand(in)));
+}
+
```

Review comment:
Looks like vectorized version handle data tails on the own so scalar version could be under `#else ... #endif`
**File:** modules/gapi/src/backends/fluid/gfluidcore.cpp
**Change Type:** modified
**Context:** PR #18466: GAPI: SIMD optimization for AddWeighted kernel. - SIMD optimization for AddWeighted kernel via universal intrinsics. <cut/> ``` force_build...

**Code Changes:**
```diff
@@ -97,6 +97,130 @@ static inline DST divr(SRC1 x, SRC2 y, float scale=1)
 // Fluid kernels: addWeighted
 //
 //---------------------------
+#if CV_SSE2
+CV_ALWAYS_INLINE v_float32 v_load_f32(const ushort* in)
+{
+    return v_cvt_f32(v_reinterpret_as_s32(vx_load_expand(in)));
+}
+
```

Review comment:
> Looks like vectorized version handle data tails on the own so scalar version But there is the case when `nlanes > length`. Am I right that then the scalar version should be used? If yes, there shouldn't be `#else`
**File:** modules/gapi/src/backends/fluid/gfluidcore.cpp
**Change Type:** modified
**Context:** PR #18466: GAPI: SIMD optimization for AddWeighted kernel. - SIMD optimization for AddWeighted kernel via universal intrinsics. <cut/> ``` force_build...

**Code Changes:**
```diff
@@ -97,6 +97,130 @@ static inline DST divr(SRC1 x, SRC2 y, float scale=1)
 // Fluid kernels: addWeighted
 //
 //---------------------------
+#if CV_SSE2
+CV_ALWAYS_INLINE v_float32 v_load_f32(const ushort* in)
+{
+    return v_cvt_f32(v_reinterpret_as_s32(vx_load_expand(in)));
+}
+
```

Review comment:
please move this into specialization of `add_simd_sametype` for `uchar` to call it here
**File:** modules/gapi/src/backends/fluid/gfluidcore.cpp
**Change Type:** modified
**Context:** PR #18466: GAPI: SIMD optimization for AddWeighted kernel. - SIMD optimization for AddWeighted kernel via universal intrinsics. <cut/> ``` force_build...

**Code Changes:**
```diff
@@ -97,6 +97,130 @@ static inline DST divr(SRC1 x, SRC2 y, float scale=1)
 // Fluid kernels: addWeighted
 //
 //---------------------------
+#if CV_SSE2
+CV_ALWAYS_INLINE v_float32 v_load_f32(const ushort* in)
+{
+    return v_cvt_f32(v_reinterpret_as_s32(vx_load_expand(in)));
+}
+
```

Review comment:
this applies to other cases in this and other functions as well
**File:** modules/gapi/src/backends/fluid/gfluidcore.cpp
**Change Type:** modified
**Context:** PR #18466: GAPI: SIMD optimization for AddWeighted kernel. - SIMD optimization for AddWeighted kernel via universal intrinsics. <cut/> ``` force_build...

**Code Changes:**
```diff
@@ -97,6 +97,130 @@ static inline DST divr(SRC1 x, SRC2 y, float scale=1)
 // Fluid kernels: addWeighted
 //
 //---------------------------
+#if CV_SSE2
+CV_ALWAYS_INLINE v_float32 v_load_f32(const ushort* in)
+{
+    return v_cvt_f32(v_reinterpret_as_s32(vx_load_expand(in)));
+}
+
```

Review comment:
please change this function to have same structure as other ones. I.e. to make this a pure dispatcher calling implementation fuction with proper casted arguments
**File:** modules/gapi/src/backends/fluid/gfluidcore.cpp
**Change Type:** modified
**Context:** PR #18466: GAPI: SIMD optimization for AddWeighted kernel. - SIMD optimization for AddWeighted kernel via universal intrinsics. <cut/> ``` force_build...

**Code Changes:**
```diff
@@ -97,6 +97,130 @@ static inline DST divr(SRC1 x, SRC2 y, float scale=1)
 // Fluid kernels: addWeighted
 //
 //---------------------------
+#if CV_SSE2
+CV_ALWAYS_INLINE v_float32 v_load_f32(const ushort* in)
+{
+    return v_cvt_f32(v_reinterpret_as_s32(vx_load_expand(in)));
+}
+
```

Review comment:
this applies to other functions as well
**File:** modules/gapi/src/backends/fluid/gfluidcore.cpp
**Change Type:** modified
**Context:** PR #18466: GAPI: SIMD optimization for AddWeighted kernel. - SIMD optimization for AddWeighted kernel via universal intrinsics. <cut/> ``` force_build...

**Code Changes:**
```diff
@@ -97,6 +97,130 @@ static inline DST divr(SRC1 x, SRC2 y, float scale=1)
 // Fluid kernels: addWeighted
 //
 //---------------------------
+#if CV_SSE2
+CV_ALWAYS_INLINE v_float32 v_load_f32(const ushort* in)
+{
+    return v_cvt_f32(v_reinterpret_as_s32(vx_load_expand(in)));
+}
+
```

Review comment:
Why it was moved here ? - it seems that it's usage is not changed
**File:** modules/gapi/src/backends/fluid/gfluidcore.cpp
**Change Type:** modified
**Context:** PR #18466: GAPI: SIMD optimization for AddWeighted kernel. - SIMD optimization for AddWeighted kernel via universal intrinsics. <cut/> ``` force_build...

**Code Changes:**
```diff
@@ -97,6 +97,130 @@ static inline DST divr(SRC1 x, SRC2 y, float scale=1)
 // Fluid kernels: addWeighted
 //
 //---------------------------
+#if CV_SSE2
+CV_ALWAYS_INLINE v_float32 v_load_f32(const ushort* in)
+{
+    return v_cvt_f32(v_reinterpret_as_s32(vx_load_expand(in)));
+}
+
```

Review comment:
Why do we need this? Why does `v_load()` not work?
**File:** modules/gapi/src/backends/fluid/gfluidcore.cpp
**Change Type:** modified
**Context:** PR #18466: GAPI: SIMD optimization for AddWeighted kernel. - SIMD optimization for AddWeighted kernel via universal intrinsics. <cut/> ``` force_build...

**Code Changes:**
```diff
@@ -97,6 +97,130 @@ static inline DST divr(SRC1 x, SRC2 y, float scale=1)
 // Fluid kernels: addWeighted
 //
 //---------------------------
+#if CV_SSE2
+CV_ALWAYS_INLINE v_float32 v_load_f32(const ushort* in)
+{
+    return v_cvt_f32(v_reinterpret_as_s32(vx_load_expand(in)));
+}
+
```

Review comment:
OK, converted to "draft" (just UI marker, no changes in automation are expected). Press "Ready for review" then PR is ready for non-internal discussions.