1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

Merge remote-tracking branch 'upstream/3.4' into merge-3.4

This commit is contained in:
Alexander Alekhin
2022-01-31 12:53:45 +00:00
27 changed files with 575 additions and 113 deletions
+8 -5
View File
@@ -48,16 +48,19 @@
#include "opencv2/core/types_c.h"
#ifdef __cplusplus
# ifdef _MSC_VER
/* disable warning C4190: 'function' has C-linkage specified, but returns UDT 'typename'
which is incompatible with C
/* disable MSVC warning C4190 / clang-cl -Wreturn-type-c-linkage:
'function' has C-linkage specified, but returns UDT 'typename'
which is incompatible with C
It is OK to disable it because we only extend few plain structures with
C++ constructors for simpler interoperability with C++ API of the library
*/
# pragma warning(disable:4190)
# elif defined __clang__ && __clang_major__ >= 3
# if defined(__clang__)
// handle clang on Linux and clang-cl (i. e. clang on Windows) first
# pragma GCC diagnostic ignored "-Wreturn-type-c-linkage"
# elif defined(_MSC_VER)
// then handle MSVC
# pragma warning(disable:4190)
# endif
#endif
@@ -0,0 +1,29 @@
// 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.
#ifndef OPENCV_CORE_FP_CONTROL_UTILS_PRIVATE_HPP
#define OPENCV_CORE_FP_CONTROL_UTILS_PRIVATE_HPP
#include "fp_control_utils.hpp"
#if OPENCV_SUPPORTS_FP_DENORMALS_HINT == 0
// disabled
#elif defined(OPENCV_IMPL_FP_HINTS)
// custom
#elif defined(OPENCV_IMPL_FP_HINTS_X86)
// custom
#elif defined(__SSE__) || defined(__SSE2__) || defined(_M_X64) || (defined(_M_IX86_FP) && _M_IX86_FP >= 1)
#include <xmmintrin.h>
#define OPENCV_IMPL_FP_HINTS_X86 1
#define OPENCV_IMPL_FP_HINTS 1
#endif
#ifndef OPENCV_IMPL_FP_HINTS
#define OPENCV_IMPL_FP_HINTS 0
#endif
#ifndef OPENCV_IMPL_FP_HINTS_X86
#define OPENCV_IMPL_FP_HINTS_X86 0
#endif
#endif // OPENCV_CORE_FP_CONTROL_UTILS_PRIVATE_HPP
@@ -0,0 +1,69 @@
// 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.
#ifndef OPENCV_CORE_FP_CONTROL_UTILS_HPP
#define OPENCV_CORE_FP_CONTROL_UTILS_HPP
namespace cv {
namespace details {
struct FPDenormalsModeState
{
uint32_t reserved[16]; // 64-bytes
}; // FPDenormalsModeState
CV_EXPORTS void setFPDenormalsIgnoreHint(bool ignore, CV_OUT FPDenormalsModeState& state);
CV_EXPORTS int saveFPDenormalsState(CV_OUT FPDenormalsModeState& state);
CV_EXPORTS bool restoreFPDenormalsState(const FPDenormalsModeState& state);
class FPDenormalsIgnoreHintScope
{
public:
inline explicit FPDenormalsIgnoreHintScope(bool ignore = true)
{
details::setFPDenormalsIgnoreHint(ignore, saved_state);
}
inline explicit FPDenormalsIgnoreHintScope(const FPDenormalsModeState& state)
{
details::saveFPDenormalsState(saved_state);
details::restoreFPDenormalsState(state);
}
inline ~FPDenormalsIgnoreHintScope()
{
details::restoreFPDenormalsState(saved_state);
}
protected:
FPDenormalsModeState saved_state;
}; // FPDenormalsIgnoreHintScope
class FPDenormalsIgnoreHintScopeNOOP
{
public:
inline FPDenormalsIgnoreHintScopeNOOP(bool ignore = true) { CV_UNUSED(ignore); }
inline FPDenormalsIgnoreHintScopeNOOP(const FPDenormalsModeState& state) { CV_UNUSED(state); }
inline ~FPDenormalsIgnoreHintScopeNOOP() { }
}; // FPDenormalsIgnoreHintScopeNOOP
} // namespace details
// Should depend on target compilation architecture only
// Note: previously added archs should NOT be removed to preserve ABI compatibility
#if defined(OPENCV_SUPPORTS_FP_DENORMALS_HINT)
// preserve configuration overloading through ports
#elif defined(__i386__) || defined(__x86_64__) || defined(_M_X64) || defined(_X86_)
typedef details::FPDenormalsIgnoreHintScope FPDenormalsIgnoreHintScope;
#define OPENCV_SUPPORTS_FP_DENORMALS_HINT 1
#else
#define OPENCV_SUPPORTS_FP_DENORMALS_HINT 0
typedef details::FPDenormalsIgnoreHintScopeNOOP FPDenormalsIgnoreHintScope;
#endif
} // namespace cv
#endif // OPENCV_CORE_FP_CONTROL_UTILS_HPP