Merge pull request #9856 from GregoryMorse:patch-1
authorGregory Morse <gregory.morse@live.com>
Mon, 16 Oct 2017 09:12:35 +0000 (11:12 +0200)
committerAlexander Alekhin <alexander.a.alekhin@gmail.com>
Mon, 16 Oct 2017 09:12:35 +0000 (12:12 +0300)
* Update OpenCVCompilerOptimizations.cmake

Neon not supported on MSVC ARM breaking build fix

* Update OpenCVCompilerOptimizations.cmake

Whitespace

* Update intrin.hpp

Many problems in MSVC ARM builds (at least on VS2017) being fixed in this PR now.

C:\Users\Gregory\DOCUME~1\MYLIBR~1\OPENCV~3\opencv\sources\modules\core\include\opencv2/core/hal/intrin.hpp(444): error C3861: '_tzcnt_u32': identifier not found

* Update hal_replacement.hpp

Passing variadic expansion in a macro to another macro does not work properly in MSVC and a famous known workaround is hereby applied.  Discussion of it: https://stackoverflow.com/questions/5134523/msvc-doesnt-expand-va-args-correctly
Only needed the fix for ARM builds: TEGRA_ macros are used for cv_hal_ functions in the carotene library.

C:\Users\Gregory\Documents\My Libraries\opencv330\opencv\sources\modules\core\src\arithm.cpp(2378): warning C4003: not enough actual parameters for macro 'TEGRA_ADD'
C:\Users\Gregory\Documents\My Libraries\opencv330\opencv\sources\modules\core\src\arithm.cpp(2378): error C2143: syntax error: missing ')' before ','
C:\Users\Gregory\Documents\My Libraries\opencv330\opencv\sources\modules\core\src\arithm.cpp(2378): error C2059: syntax error: ')'

* Update hal_replacement.hpp

All hal_replacement's using carotene\hal\tegra_hal.hpp TEGRA_ functions as macros preprocessed by variadic macros should be changed, identical as was done in core.
C:\Users\Gregory\Documents\My Libraries\opencv330\opencv\sources\modules\imgproc\src\color.cpp(9604): warning C4003: not enough actual parameters for macro 'TEGRA_CVTBGRTOBGR'
C:\Users\Gregory\Documents\My Libraries\opencv330\opencv\sources\modules\imgproc\src\color.cpp(9604): error C2059: syntax error: '=='

* Update OpenCVCompilerOptimizations.cmake

* Update hal_replacement.hpp

* Update hal_replacement.hpp

cmake/OpenCVCompilerOptimizations.cmake
modules/core/include/opencv2/core/hal/intrin.hpp
modules/core/src/hal_replacement.hpp
modules/imgproc/src/hal_replacement.hpp

index fea13ce..2696ac2 100644 (file)
@@ -256,12 +256,14 @@ elseif(ARM OR AARCH64)
   ocv_update(CPU_FP16_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_fp16.cpp")
   if(NOT AARCH64)
     ocv_update(CPU_KNOWN_OPTIMIZATIONS "VFPV3;NEON;FP16")
-    ocv_update(CPU_VFPV3_FLAGS_ON "-mfpu=vfpv3")
-    ocv_update(CPU_NEON_FLAGS_ON "-mfpu=neon")
-    ocv_update(CPU_NEON_FLAGS_CONFLICT "-mfpu=[^ ]*")
-    ocv_update(CPU_FP16_FLAGS_ON "-mfpu=neon-fp16")
+    if(NOT MSVC)
+      ocv_update(CPU_VFPV3_FLAGS_ON "-mfpu=vfpv3")
+      ocv_update(CPU_NEON_FLAGS_ON "-mfpu=neon")
+      ocv_update(CPU_NEON_FLAGS_CONFLICT "-mfpu=[^ ]*")
+      ocv_update(CPU_FP16_FLAGS_ON "-mfpu=neon-fp16")
+      ocv_update(CPU_FP16_FLAGS_CONFLICT "-mfpu=[^ ]*")
+    endif()
     ocv_update(CPU_FP16_IMPLIES "NEON")
-    ocv_update(CPU_FP16_FLAGS_CONFLICT "-mfpu=[^ ]*")
   else()
     ocv_update(CPU_KNOWN_OPTIMIZATIONS "NEON;FP16")
     ocv_update(CPU_NEON_FLAGS_ON "")
index 26fd918..9dcfc56 100644 (file)
@@ -440,7 +440,7 @@ template <> struct V_RegTrait128<double> {
 
 inline unsigned int trailingZeros32(unsigned int value) {
 #if defined(_MSC_VER)
-#if (_MSC_VER < 1700)
+#if (_MSC_VER < 1700) || defined(_M_ARM)
     unsigned long index = 0;
     _BitScanForward(&index, value);
     return (unsigned int)index;
index 9a1177e..c0477e6 100644 (file)
@@ -727,7 +727,7 @@ inline int hal_ni_gemm64fc(const double* src1, size_t src1_step, const double* s
 //! @cond IGNORED
 #define CALL_HAL_RET(name, fun, retval, ...) \
 { \
-    int res = fun(__VA_ARGS__, &retval); \
+    int res = __CV_EXPAND(fun(__VA_ARGS__, &retval)); \
     if (res == CV_HAL_ERROR_OK) \
         return retval; \
     else if (res != CV_HAL_ERROR_NOT_IMPLEMENTED) \
@@ -738,7 +738,7 @@ inline int hal_ni_gemm64fc(const double* src1, size_t src1_step, const double* s
 
 #define CALL_HAL(name, fun, ...) \
 { \
-    int res = fun(__VA_ARGS__); \
+    int res = __CV_EXPAND(fun(__VA_ARGS__)); \
     if (res == CV_HAL_ERROR_OK) \
         return; \
     else if (res != CV_HAL_ERROR_NOT_IMPLEMENTED) \
index 1bbc2f3..5c7e772 100644 (file)
@@ -627,7 +627,7 @@ inline int hal_ni_integral(int depth, int sdepth, int sqdepth, const uchar * src
 
 //! @cond IGNORED
 #define CALL_HAL_RET(name, fun, retval, ...) \
-    int res = fun(__VA_ARGS__, &retval); \
+    int res = __CV_EXPAND(fun(__VA_ARGS__, &retval)); \
     if (res == CV_HAL_ERROR_OK) \
         return retval; \
     else if (res != CV_HAL_ERROR_NOT_IMPLEMENTED) \
@@ -636,7 +636,7 @@ inline int hal_ni_integral(int depth, int sdepth, int sqdepth, const uchar * src
 
 
 #define CALL_HAL(name, fun, ...) \
-    int res = fun(__VA_ARGS__); \
+    int res = __CV_EXPAND(fun(__VA_ARGS__)); \
     if (res == CV_HAL_ERROR_OK) \
         return; \
     else if (res != CV_HAL_ERROR_NOT_IMPLEMENTED) \