Merge remote-tracking branch 'upstream/3.4' into merge-3.4
This commit is contained in:
@@ -371,7 +371,7 @@ It is possible to alternate error processing by using redirectError().
|
||||
@param _func - function name. Available only when the compiler supports getting it
|
||||
@param _file - source file name where the error has occurred
|
||||
@param _line - line number in the source file where the error has occurred
|
||||
@see CV_Error, CV_Error_, CV_ErrorNoReturn, CV_ErrorNoReturn_, CV_Assert, CV_DbgAssert
|
||||
@see CV_Error, CV_Error_, CV_Assert, CV_DbgAssert
|
||||
*/
|
||||
CV_EXPORTS void error(int _code, const String& _err, const char* _func, const char* _file, int _line);
|
||||
|
||||
@@ -414,8 +414,6 @@ CV_INLINE CV_NORETURN void errorNoReturn(int _code, const String& _err, const ch
|
||||
// We need to use simplified definition for them.
|
||||
#define CV_Error(...) do { abort(); } while (0)
|
||||
#define CV_Error_( code, args ) do { cv::format args; abort(); } while (0)
|
||||
#define CV_ErrorNoReturn(...) do { abort(); } while (0)
|
||||
#define CV_ErrorNoReturn_(...) do { abort(); } while (0)
|
||||
#define CV_Assert_1( expr ) do { if (!(expr)) abort(); } while (0)
|
||||
|
||||
#else // CV_STATIC_ANALYSIS
|
||||
@@ -446,22 +444,22 @@ for example:
|
||||
*/
|
||||
#define CV_Error_( code, args ) cv::error( code, cv::format args, CV_Func, __FILE__, __LINE__ )
|
||||
|
||||
/** same as CV_Error(code,msg), but does not return */
|
||||
#define CV_ErrorNoReturn( code, msg ) cv::errorNoReturn( code, msg, CV_Func, __FILE__, __LINE__ )
|
||||
|
||||
/** same as CV_Error_(code,args), but does not return */
|
||||
#define CV_ErrorNoReturn_( code, args ) cv::errorNoReturn( code, cv::format args, CV_Func, __FILE__, __LINE__ )
|
||||
|
||||
#define CV_Assert_1( expr ) if(!!(expr)) ; else cv::error( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ )
|
||||
|
||||
//! @cond IGNORED
|
||||
#define CV__ErrorNoReturn( code, msg ) cv::errorNoReturn( code, msg, CV_Func, __FILE__, __LINE__ )
|
||||
#define CV__ErrorNoReturn_( code, args ) cv::errorNoReturn( code, cv::format args, CV_Func, __FILE__, __LINE__ )
|
||||
#ifdef __OPENCV_BUILD
|
||||
#undef CV_Error
|
||||
#define CV_Error CV_ErrorNoReturn
|
||||
#define CV_Error CV__ErrorNoReturn
|
||||
#undef CV_Error_
|
||||
#define CV_Error_ CV_ErrorNoReturn_
|
||||
#define CV_Error_ CV__ErrorNoReturn_
|
||||
#undef CV_Assert_1
|
||||
#define CV_Assert_1( expr ) if(!!(expr)) ; else cv::errorNoReturn( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ )
|
||||
#else
|
||||
// backward compatibility
|
||||
#define CV_ErrorNoReturn CV__ErrorNoReturn
|
||||
#define CV_ErrorNoReturn_ CV__ErrorNoReturn_
|
||||
#endif
|
||||
//! @endcond
|
||||
|
||||
|
||||
@@ -1042,13 +1042,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_
|
||||
else
|
||||
select i-th bit from _b_ */
|
||||
Return value will be built by combining values _a_ and _b_ using the following scheme:
|
||||
result[i] = mask[i] ? a[i] : b[i];
|
||||
|
||||
@note: _mask_ element values are restricted to these values:
|
||||
- 0: select element from _b_
|
||||
- 0xff/0xffff/etc: select element from _a_
|
||||
(fully compatible with bitwise-based operator)
|
||||
*/
|
||||
template<typename _Tp, int n> inline v_reg<_Tp, n> v_select(const v_reg<_Tp, n>& mask,
|
||||
const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b)
|
||||
{
|
||||
@@ -1058,8 +1061,8 @@ template<typename _Tp, int n> inline v_reg<_Tp, n> v_select(const v_reg<_Tp, n>&
|
||||
for( int i = 0; i < n; i++ )
|
||||
{
|
||||
int_type m = Traits::reinterpret_int(mask.s[i]);
|
||||
c.s[i] = Traits::reinterpret_from_int((Traits::reinterpret_int(a.s[i]) & m)
|
||||
| (Traits::reinterpret_int(b.s[i]) & ~m));
|
||||
CV_DbgAssert(m == 0 || m == (~(int_type)0)); // restrict mask values: 0 or 0xff/0xffff/etc
|
||||
c.s[i] = m ? a.s[i] : b.s[i];
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
@@ -438,10 +438,14 @@ void v_rshr_pack_store(schar* ptr, const v_int16x8& a)
|
||||
}
|
||||
|
||||
|
||||
// bit-wise "mask ? a : b"
|
||||
// byte-wise "mask ? a : b"
|
||||
inline __m128i v_select_si128(__m128i mask, __m128i a, __m128i b)
|
||||
{
|
||||
#if CV_SSE4_1
|
||||
return _mm_blendv_epi8(b, a, mask);
|
||||
#else
|
||||
return _mm_xor_si128(b, _mm_and_si128(_mm_xor_si128(a, b), mask));
|
||||
#endif
|
||||
}
|
||||
|
||||
inline v_uint16x8 v_pack(const v_uint32x4& a, const v_uint32x4& b)
|
||||
@@ -1403,6 +1407,26 @@ OPENCV_HAL_IMPL_SSE_CHECK_SIGNS(v_int32x4, epi8, v_packq_epi32, OPENCV_HAL_AND,
|
||||
OPENCV_HAL_IMPL_SSE_CHECK_SIGNS(v_float32x4, ps, OPENCV_HAL_NOP, OPENCV_HAL_1ST, 15, 15)
|
||||
OPENCV_HAL_IMPL_SSE_CHECK_SIGNS(v_float64x2, pd, OPENCV_HAL_NOP, OPENCV_HAL_1ST, 3, 3)
|
||||
|
||||
#if CV_SSE4_1
|
||||
#define OPENCV_HAL_IMPL_SSE_SELECT(_Tpvec, cast_ret, cast, suffix) \
|
||||
inline _Tpvec v_select(const _Tpvec& mask, const _Tpvec& a, const _Tpvec& b) \
|
||||
{ \
|
||||
return _Tpvec(cast_ret(_mm_blendv_##suffix(cast(b.val), cast(a.val), cast(mask.val)))); \
|
||||
}
|
||||
|
||||
OPENCV_HAL_IMPL_SSE_SELECT(v_uint8x16, OPENCV_HAL_NOP, OPENCV_HAL_NOP, epi8)
|
||||
OPENCV_HAL_IMPL_SSE_SELECT(v_int8x16, OPENCV_HAL_NOP, OPENCV_HAL_NOP, epi8)
|
||||
OPENCV_HAL_IMPL_SSE_SELECT(v_uint16x8, OPENCV_HAL_NOP, OPENCV_HAL_NOP, epi8)
|
||||
OPENCV_HAL_IMPL_SSE_SELECT(v_int16x8, OPENCV_HAL_NOP, OPENCV_HAL_NOP, epi8)
|
||||
OPENCV_HAL_IMPL_SSE_SELECT(v_uint32x4, _mm_castps_si128, _mm_castsi128_ps, ps)
|
||||
OPENCV_HAL_IMPL_SSE_SELECT(v_int32x4, _mm_castps_si128, _mm_castsi128_ps, ps)
|
||||
// OPENCV_HAL_IMPL_SSE_SELECT(v_uint64x2, TBD, TBD, pd)
|
||||
// OPENCV_HAL_IMPL_SSE_SELECT(v_int64x2, TBD, TBD, ps)
|
||||
OPENCV_HAL_IMPL_SSE_SELECT(v_float32x4, OPENCV_HAL_NOP, OPENCV_HAL_NOP, ps)
|
||||
OPENCV_HAL_IMPL_SSE_SELECT(v_float64x2, OPENCV_HAL_NOP, OPENCV_HAL_NOP, pd)
|
||||
|
||||
#else // CV_SSE4_1
|
||||
|
||||
#define OPENCV_HAL_IMPL_SSE_SELECT(_Tpvec, suffix) \
|
||||
inline _Tpvec v_select(const _Tpvec& mask, const _Tpvec& a, const _Tpvec& b) \
|
||||
{ \
|
||||
@@ -1419,6 +1443,7 @@ OPENCV_HAL_IMPL_SSE_SELECT(v_int32x4, si128)
|
||||
// OPENCV_HAL_IMPL_SSE_SELECT(v_int64x2, si128)
|
||||
OPENCV_HAL_IMPL_SSE_SELECT(v_float32x4, ps)
|
||||
OPENCV_HAL_IMPL_SSE_SELECT(v_float64x2, pd)
|
||||
#endif
|
||||
|
||||
#define OPENCV_HAL_IMPL_SSE_EXPAND(_Tpuvec, _Tpwuvec, _Tpu, _Tpsvec, _Tpwsvec, _Tps, suffix, wsuffix, shift) \
|
||||
inline void v_expand(const _Tpuvec& a, _Tpwuvec& b0, _Tpwuvec& b1) \
|
||||
@@ -1607,6 +1632,28 @@ inline void v_load_deinterleave(const uchar* ptr, v_uint8x16& a, v_uint8x16& b)
|
||||
|
||||
inline void v_load_deinterleave(const uchar* ptr, v_uint8x16& a, v_uint8x16& b, v_uint8x16& c)
|
||||
{
|
||||
#if CV_SSSE3
|
||||
static const __m128i m0 = _mm_setr_epi8(0, 3, 6, 9, 12, 15, 1, 4, 7, 10, 13, 2, 5, 8, 11, 14);
|
||||
static const __m128i m1 = _mm_alignr_epi8(m0, m0, 11);
|
||||
static const __m128i m2 = _mm_alignr_epi8(m0, m0, 6);
|
||||
|
||||
__m128i t0 = _mm_loadu_si128((const __m128i*)ptr);
|
||||
__m128i t1 = _mm_loadu_si128((const __m128i*)(ptr + 16));
|
||||
__m128i t2 = _mm_loadu_si128((const __m128i*)(ptr + 32));
|
||||
|
||||
__m128i s0 = _mm_shuffle_epi8(t0, m0);
|
||||
__m128i s1 = _mm_shuffle_epi8(t1, m1);
|
||||
__m128i s2 = _mm_shuffle_epi8(t2, m2);
|
||||
|
||||
t0 = _mm_alignr_epi8(s1, _mm_slli_si128(s0, 10), 5);
|
||||
a.val = _mm_alignr_epi8(s2, t0, 5);
|
||||
|
||||
t1 = _mm_alignr_epi8(_mm_srli_si128(s1, 5), _mm_slli_si128(s0, 5), 6);
|
||||
b.val = _mm_alignr_epi8(_mm_srli_si128(s2, 5), t1, 5);
|
||||
|
||||
t2 = _mm_alignr_epi8(_mm_srli_si128(s2, 10), s1, 11);
|
||||
c.val = _mm_alignr_epi8(t2, s0, 11);
|
||||
#else
|
||||
__m128i t00 = _mm_loadu_si128((const __m128i*)ptr);
|
||||
__m128i t01 = _mm_loadu_si128((const __m128i*)(ptr + 16));
|
||||
__m128i t02 = _mm_loadu_si128((const __m128i*)(ptr + 32));
|
||||
@@ -1626,6 +1673,7 @@ inline void v_load_deinterleave(const uchar* ptr, v_uint8x16& a, v_uint8x16& b,
|
||||
a.val = _mm_unpacklo_epi8(t30, _mm_unpackhi_epi64(t31, t31));
|
||||
b.val = _mm_unpacklo_epi8(_mm_unpackhi_epi64(t30, t30), t32);
|
||||
c.val = _mm_unpacklo_epi8(t31, _mm_unpackhi_epi64(t32, t32));
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void v_load_deinterleave(const uchar* ptr, v_uint8x16& a, v_uint8x16& b, v_uint8x16& c, v_uint8x16& d)
|
||||
@@ -1840,6 +1888,27 @@ inline void v_store_interleave( uchar* ptr, const v_uint8x16& a, const v_uint8x1
|
||||
inline void v_store_interleave( uchar* ptr, const v_uint8x16& a, const v_uint8x16& b,
|
||||
const v_uint8x16& c )
|
||||
{
|
||||
#if CV_SSSE3
|
||||
static const __m128i m0 = _mm_setr_epi8(0, 6, 11, 1, 7, 12, 2, 8, 13, 3, 9, 14, 4, 10, 15, 5);
|
||||
static const __m128i m1 = _mm_setr_epi8(5, 11, 0, 6, 12, 1, 7, 13, 2, 8, 14, 3, 9, 15, 4, 10);
|
||||
static const __m128i m2 = _mm_setr_epi8(10, 0, 5, 11, 1, 6, 12, 2, 7, 13, 3, 8, 14, 4, 9, 15);
|
||||
|
||||
__m128i t0 = _mm_alignr_epi8(b.val, _mm_slli_si128(a.val, 10), 5);
|
||||
t0 = _mm_alignr_epi8(c.val, t0, 5);
|
||||
__m128i s0 = _mm_shuffle_epi8(t0, m0);
|
||||
|
||||
__m128i t1 = _mm_alignr_epi8(_mm_srli_si128(b.val, 5), _mm_slli_si128(a.val, 5), 6);
|
||||
t1 = _mm_alignr_epi8(_mm_srli_si128(c.val, 5), t1, 5);
|
||||
__m128i s1 = _mm_shuffle_epi8(t1, m1);
|
||||
|
||||
__m128i t2 = _mm_alignr_epi8(_mm_srli_si128(c.val, 10), b.val, 11);
|
||||
t2 = _mm_alignr_epi8(t2, a.val, 11);
|
||||
__m128i s2 = _mm_shuffle_epi8(t2, m2);
|
||||
|
||||
_mm_storeu_si128((__m128i*)ptr, s0);
|
||||
_mm_storeu_si128((__m128i*)(ptr + 16), s1);
|
||||
_mm_storeu_si128((__m128i*)(ptr + 32), s2);
|
||||
#else
|
||||
__m128i z = _mm_setzero_si128();
|
||||
__m128i ab0 = _mm_unpacklo_epi8(a.val, b.val);
|
||||
__m128i ab1 = _mm_unpackhi_epi8(a.val, b.val);
|
||||
@@ -1881,6 +1950,7 @@ inline void v_store_interleave( uchar* ptr, const v_uint8x16& a, const v_uint8x1
|
||||
_mm_storeu_si128((__m128i*)(ptr), v0);
|
||||
_mm_storeu_si128((__m128i*)(ptr + 16), v1);
|
||||
_mm_storeu_si128((__m128i*)(ptr + 32), v2);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void v_store_interleave( uchar* ptr, const v_uint8x16& a, const v_uint8x16& b,
|
||||
|
||||
@@ -93,7 +93,7 @@ static void dumpOpenCLInformation()
|
||||
|
||||
const Device& device = Device::getDefault();
|
||||
if (!device.available())
|
||||
CV_ErrorNoReturn(Error::OpenCLInitError, "OpenCL device is not available");
|
||||
CV_Error(Error::OpenCLInitError, "OpenCL device is not available");
|
||||
|
||||
DUMP_MESSAGE_STDOUT("Current OpenCL device: ");
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef CL_VERSION_1_2
|
||||
#define CV_REQUIRE_OPENCL_1_2_ERROR CV_ErrorNoReturn(cv::Error::OpenCLApiCallError, "OpenCV compiled without OpenCL v1.2 support, so we can't use functionality from OpenCL v1.2")
|
||||
#define CV_REQUIRE_OPENCL_1_2_ERROR CV_Error(cv::Error::OpenCLApiCallError, "OpenCV compiled without OpenCL v1.2 support, so we can't use functionality from OpenCL v1.2")
|
||||
#endif
|
||||
|
||||
#endif // HAVE_OPENCL
|
||||
|
||||
Reference in New Issue
Block a user