MCPcopy Create free account
hub / github.com/creatale/node-dv / cmp8u

Function cmp8u

deps/opencv/modules/core/src/arithm.cpp:2208–2283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2206#endif
2207
2208static void cmp8u(const uchar* src1, size_t step1, const uchar* src2, size_t step2,
2209 uchar* dst, size_t step, Size size, void* _cmpop)
2210{
2211#if ARITHM_USE_IPP
2212 IppCmpOp op = convert_cmp(*(int *)_cmpop);
2213 if( op >= 0 )
2214 {
2215 fixSteps(size, sizeof(dst[0]), step1, step2, step);
2216 if( ippiCompare_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(size), op) >= 0 )
2217 return;
2218 }
2219#endif
2220 //vz optimized cmp_(src1, step1, src2, step2, dst, step, size, *(int*)_cmpop);
2221 int code = *(int*)_cmpop;
2222 step1 /= sizeof(src1[0]);
2223 step2 /= sizeof(src2[0]);
2224 if( code == CMP_GE || code == CMP_LT )
2225 {
2226 std::swap(src1, src2);
2227 std::swap(step1, step2);
2228 code = code == CMP_GE ? CMP_LE : CMP_GT;
2229 }
2230
2231 if( code == CMP_GT || code == CMP_LE )
2232 {
2233 int m = code == CMP_GT ? 0 : 255;
2234 for( ; size.height--; src1 += step1, src2 += step2, dst += step )
2235 {
2236 int x =0;
2237 #if CV_SSE2
2238 if( USE_SSE2 ){
2239 __m128i m128 = code == CMP_GT ? _mm_setzero_si128() : _mm_set1_epi8 (-1);
2240 __m128i c128 = _mm_set1_epi8 (-128);
2241 for( ; x <= size.width - 16; x += 16 )
2242 {
2243 __m128i r00 = _mm_loadu_si128((const __m128i*)(src1 + x));
2244 __m128i r10 = _mm_loadu_si128((const __m128i*)(src2 + x));
2245 // no simd for 8u comparison, that's why we need the trick
2246 r00 = _mm_sub_epi8(r00,c128);
2247 r10 = _mm_sub_epi8(r10,c128);
2248
2249 r00 =_mm_xor_si128(_mm_cmpgt_epi8(r00, r10), m128);
2250 _mm_storeu_si128((__m128i*)(dst + x),r00);
2251
2252 }
2253 }
2254 #endif
2255
2256 for( ; x < size.width; x++ ){
2257 dst[x] = (uchar)(-(src1[x] > src2[x]) ^ m);
2258 }
2259 }
2260 }
2261 else if( code == CMP_EQ || code == CMP_NE )
2262 {
2263 int m = code == CMP_EQ ? 0 : 255;
2264 for( ; size.height--; src1 += step1, src2 += step2, dst += step )
2265 {

Callers

nothing calls this directly

Calls 4

convert_cmpFunction · 0.85
fixStepsFunction · 0.85
ippiSizeFunction · 0.70
swapFunction · 0.70

Tested by

no test coverage detected