mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
Merge pull request #21083 from OrestChura:oc/fix_coverity_vino_issues
[G-API] Fixed Coverity issues * Fixed Coverity issues - VectorRef&OpaqueRef m_kind = CV_UNKNOWN - added same-type overload for saturate() - sanitized resize value in ByteMemoryInStream::operator>> (std::string& str) - handled throws from ~GStreamingExecutor() * Catching exception by const ref * Addressing Sergey's comments * Applied enable_if semanitcs to saturate(x, round) too * Removed uncaught_exception, made destructor noexcept back * Split Fluid ConvertTo to multiple functions to avoid ifs; added CV_ALWAYS_INLINE * Added FIXME to address throwings from stop() * Fix standalone * Addressing comments * Guarded SIMD optimizations properly * Removed excess parameter from simd_impl functions
This commit is contained in:
@@ -236,7 +236,7 @@ namespace detail
|
||||
class VectorRef
|
||||
{
|
||||
std::shared_ptr<BasicVectorRef> m_ref;
|
||||
cv::detail::OpaqueKind m_kind;
|
||||
cv::detail::OpaqueKind m_kind = cv::detail::OpaqueKind::CV_UNKNOWN;
|
||||
|
||||
template<typename T> inline void check() const
|
||||
{
|
||||
|
||||
@@ -232,7 +232,7 @@ namespace detail
|
||||
class OpaqueRef
|
||||
{
|
||||
std::shared_ptr<BasicOpaqueRef> m_ref;
|
||||
cv::detail::OpaqueKind m_kind;
|
||||
cv::detail::OpaqueKind m_kind = cv::detail::OpaqueKind::CV_UNKNOWN;
|
||||
|
||||
template<typename T> inline void check() const
|
||||
{
|
||||
|
||||
@@ -84,6 +84,16 @@ typedef unsigned short ushort;
|
||||
|
||||
// cvdef.h:
|
||||
|
||||
#ifndef CV_ALWAYS_INLINE
|
||||
# if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
|
||||
# define CV_ALWAYS_INLINE inline __attribute__((always_inline))
|
||||
# elif defined(_MSC_VER)
|
||||
# define CV_ALWAYS_INLINE __forceinline
|
||||
# else
|
||||
# define CV_ALWAYS_INLINE inline
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define CV_MAT_CN_MASK ((CV_CN_MAX - 1) << CV_CN_SHIFT)
|
||||
#define CV_MAT_CN(flags) ((((flags) & CV_MAT_CN_MASK) >> CV_CN_SHIFT) + 1)
|
||||
#define CV_MAT_TYPE_MASK (CV_DEPTH_MAX*CV_CN_MAX - 1)
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
#include <math.h>
|
||||
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
|
||||
#include <opencv2/gapi/own/assert.hpp>
|
||||
#include <opencv2/gapi/util/type_traits.hpp>
|
||||
|
||||
namespace cv { namespace gapi { namespace own {
|
||||
//-----------------------------
|
||||
@@ -22,16 +22,12 @@ namespace cv { namespace gapi { namespace own {
|
||||
//
|
||||
//-----------------------------
|
||||
|
||||
template<typename DST, typename SRC>
|
||||
static inline DST saturate(SRC x)
|
||||
template<typename DST, typename SRC,
|
||||
typename = cv::util::enable_if_t<!std::is_same<DST, SRC>::value &&
|
||||
std::is_integral<DST>::value &&
|
||||
std::is_integral<SRC>::value> >
|
||||
static CV_ALWAYS_INLINE DST saturate(SRC x)
|
||||
{
|
||||
// only integral types please!
|
||||
GAPI_DbgAssert(std::is_integral<DST>::value &&
|
||||
std::is_integral<SRC>::value);
|
||||
|
||||
if (std::is_same<DST, SRC>::value)
|
||||
return static_cast<DST>(x);
|
||||
|
||||
if (sizeof(DST) > sizeof(SRC))
|
||||
return static_cast<DST>(x);
|
||||
|
||||
@@ -44,38 +40,35 @@ static inline DST saturate(SRC x)
|
||||
std::numeric_limits<DST>::max():
|
||||
static_cast<DST>(x);
|
||||
}
|
||||
template<typename T>
|
||||
static CV_ALWAYS_INLINE T saturate(T x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
template<typename DST, typename SRC, typename R,
|
||||
cv::util::enable_if_t<std::is_floating_point<DST>::value, bool> = true >
|
||||
static CV_ALWAYS_INLINE DST saturate(SRC x, R)
|
||||
{
|
||||
return static_cast<DST>(x);
|
||||
}
|
||||
template<typename DST, typename SRC, typename R,
|
||||
cv::util::enable_if_t<std::is_integral<DST>::value &&
|
||||
std::is_integral<SRC>::value , bool> = true >
|
||||
static CV_ALWAYS_INLINE DST saturate(SRC x, R)
|
||||
{
|
||||
return saturate<DST>(x);
|
||||
}
|
||||
// Note, that OpenCV rounds differently:
|
||||
// - like std::round() for add, subtract
|
||||
// - like std::rint() for multiply, divide
|
||||
template<typename DST, typename SRC, typename R>
|
||||
static inline DST saturate(SRC x, R round)
|
||||
template<typename DST, typename SRC, typename R,
|
||||
cv::util::enable_if_t<std::is_integral<DST>::value &&
|
||||
std::is_floating_point<SRC>::value, bool> = true >
|
||||
static CV_ALWAYS_INLINE DST saturate(SRC x, R round)
|
||||
{
|
||||
if (std::is_floating_point<DST>::value)
|
||||
{
|
||||
return static_cast<DST>(x);
|
||||
}
|
||||
else if (std::is_integral<SRC>::value)
|
||||
{
|
||||
GAPI_DbgAssert(std::is_integral<DST>::value &&
|
||||
std::is_integral<SRC>::value);
|
||||
return saturate<DST>(x);
|
||||
}
|
||||
else
|
||||
{
|
||||
GAPI_DbgAssert(std::is_integral<DST>::value &&
|
||||
std::is_floating_point<SRC>::value);
|
||||
#ifdef _WIN32
|
||||
// Suppress warning about converting x to floating-point
|
||||
// Note that x is already floating-point at this point
|
||||
#pragma warning(disable: 4244)
|
||||
#endif
|
||||
int ix = static_cast<int>(round(x));
|
||||
#ifdef _WIN32
|
||||
#pragma warning(default: 4244)
|
||||
#endif
|
||||
return saturate<DST>(ix);
|
||||
}
|
||||
int ix = static_cast<int>(round(x));
|
||||
return saturate<DST>(ix);
|
||||
}
|
||||
|
||||
// explicit suffix 'd' for double type
|
||||
|
||||
Reference in New Issue
Block a user