8 #ifndef META_OCEAN_CV_SSE_H
9 #define META_OCEAN_CV_SSE_H
17 #if defined(OCEAN_HARDWARE_SSE_VERSION) && OCEAN_HARDWARE_SSE_VERSION >= 41
20 #include <emmintrin.h>
21 #include <immintrin.h>
25 #include <pmmintrin.h>
29 #include <smmintrin.h>
45 #if !defined(OCEAN_COMPILER_MSC)
65 static_assert(
sizeof(
M128i) == 16,
"Invalid data type!");
76 static_assert(
sizeof(
M128) == 16,
"Invalid data type!");
87 static_assert(
sizeof(
M128d) == 16,
"Invalid data type!");
97 static inline void prefetchT0(
const void*
const data);
103 static inline void prefetchT1(
const void*
const data);
109 static inline void prefetchT2(
const void*
const data);
115 static inline void prefetchNTA(
const void*
const data);
123 template <
unsigned int tIndex>
124 static inline uint8_t
value_u8(
const __m128i& value);
132 static inline uint8_t
value_u8(
const __m128i& value,
const unsigned int index);
140 template <
unsigned int tIndex>
141 static inline uint16_t
value_u16(
const __m128i& value);
149 template <
unsigned int tIndex>
150 static inline unsigned int value_u32(
const __m128i& value);
157 static OCEAN_FORCE_INLINE
unsigned int sum_u32_4(
const __m128i& value);
178 static OCEAN_FORCE_INLINE
float sum_f32_4(
const __m128& value);
185 static OCEAN_FORCE_INLINE
double sum_f64_2(
const __m128d& value);
223 template <
bool tBufferHas16Bytes>
244 template <
bool tBufferHas16Bytes>
426 static inline void average30Elements1Channel8Bit3x3(
const uint8_t*
const image0,
const uint8_t*
const image1,
const uint8_t*
const image2, uint8_t*
const result);
514 template <
bool tBufferHas16Bytes>
525 template <
bool tBufferHas16Bytes>
543 static inline __m128i
interpolation1Channel8Bit8Elements(
const __m128i& values0,
const __m128i& values1,
const __m128i& fx_fy_,
const __m128i& fxfy_,
const __m128i& fx_fy,
const __m128i& fxfy);
560 static inline __m128i
interpolation2Channel16Bit8Elements(
const __m128i& values0,
const __m128i& values1,
const __m128i& fx_fy_,
const __m128i& fxfy_,
const __m128i& fx_fy,
const __m128i& fxfy);
577 static inline __m128i
interpolation3Channel24Bit8Elements(
const __m128i& values0,
const __m128i& values1,
const __m128i& fx_fy_,
const __m128i& fxfy_,
const __m128i& fx_fy,
const __m128i& fxfy);
616 static inline __m128i
interpolation4Channel32Bit8Elements(
const __m128i& values0,
const __m128i& values1,
const __m128i& fx_fy_,
const __m128i& fxfy_,
const __m128i& fx_fy,
const __m128i& fxfy);
633 static inline __m128i
interpolation4Channel32Bit2x4Elements(
const __m128i& values0,
const __m128i& values1,
const __m128i& fx_fy_,
const __m128i& fxfy_,
const __m128i& fx_fy,
const __m128i& fxfy);
647 static inline unsigned int ssd2Channel16Bit1x1(
const uint8_t*
const pixel0,
const uint8_t*
const pixel1,
const unsigned int size0,
const unsigned int size1,
const unsigned int f1x_y_,
const unsigned int f1xy_,
const unsigned int f1x_y,
const unsigned int f1xy);
665 static inline unsigned int ssd2Channel16Bit1x1(
const uint8_t*
const pixel0,
const uint8_t*
const pixel1,
const unsigned int size0,
const unsigned int size1,
const unsigned int f0x_y_,
const unsigned int f0xy_,
const unsigned int f0x_y,
const unsigned int f0xy,
const unsigned int f1x_y_,
const unsigned int f1xy_,
const unsigned int f1x_y,
const unsigned int f1xy);
704 static OCEAN_FORCE_INLINE
void deInterleave3Channel8Bit48Elements(
const __m128i& interleavedA,
const __m128i& interleavedB,
const __m128i& interleavedC, __m128i& channel0, __m128i& channel1, __m128i& channel2);
743 OCEAN_FORCE_INLINE
static void interleave3Channel8Bit48Elements(
const __m128i& channel0,
const __m128i& channel1,
const __m128i& channel2, __m128i& interleavedA, __m128i& interleavedB, __m128i& interleavedC);
752 static OCEAN_FORCE_INLINE
void interleave3Channel8Bit48Elements(
const uint8_t*
const channel0,
const uint8_t*
const channel1,
const uint8_t*
const channel2, uint8_t*
const interleaved);
770 static OCEAN_FORCE_INLINE
void reverseChannelOrder3Channel8Bit48Elements(
const __m128i& interleaved0,
const __m128i& interleaved1,
const __m128i& interleaved2, __m128i& reversedInterleaved0, __m128i& reversedInterleaved1, __m128i& reversedInterleaved2);
808 static inline void reverseElements8Bit48Elements(
const __m128i& elements0,
const __m128i& elements1,
const __m128i& elements2, __m128i& reversedElements0, __m128i& reversedElements1, __m128i& reversedElements2);
885 template <
bool tBufferHas16Bytes>
937 static inline __m128i
load128i(
const void*
const buffer);
947 template <
bool tBufferHas16Bytes>
958 template <
bool tBufferHas16Bytes>
969 template <
bool tBufferHas16Bytes>
980 template <
bool tBufferHas16Bytes>
991 template <
bool tBufferHas16Bytes>
1005 template <
unsigned int tShiftBytes>
1013 static inline void store128i(
const __m128i& value, uint8_t*
const buffer);
1021 static inline __m128i
set128i(
const unsigned long long high64,
const unsigned long long low64);
1219 static OCEAN_FORCE_INLINE
void multiplyInt8x16ToInt32x8(
const __m128i& values0,
const __m128i& values1, __m128i& products0, __m128i& products1);
1252 static inline unsigned int interpolation2Channel16Bit1x1(
const uint8_t*
const pixel,
const unsigned int size,
const unsigned int fx_y_,
const unsigned int fxy_,
const unsigned int fx_y,
const unsigned int fxy);
1257 _mm_prefetch((
char*)data, _MM_HINT_T0);
1262 _mm_prefetch((
char*)data, _MM_HINT_T1);
1267 _mm_prefetch((
char*)data, _MM_HINT_T2);
1272 _mm_prefetch((
char*)data, _MM_HINT_NTA);
1275 template <
unsigned int tIndex>
1278 static_assert(tIndex <= 15u,
"Invalid index!");
1280 #ifdef OCEAN_COMPILER_MSC
1281 return value.m128i_u8[tIndex];
1283 return ((
const M128i*)(&value))->m128i_u8[tIndex];
1289 ocean_assert(index <= 15u);
1291 #ifdef OCEAN_COMPILER_MSC
1292 return value.m128i_u8[index];
1294 return ((
const M128i*)(&value))->m128i_u8[index];
1298 template <
unsigned int tIndex>
1301 static_assert(tIndex <= 7u,
"Invalid index!");
1303 #ifdef OCEAN_COMPILER_MSC
1304 return value.m128i_u16[tIndex];
1306 return ((
const M128i*)(&value))->m128i_u16[tIndex];
1310 template <
unsigned int tIndex>
1313 static_assert(tIndex <= 3u,
"Invalid index!");
1315 #ifdef OCEAN_COMPILER_MSC
1316 return value.m128i_u32[tIndex];
1318 return ((
const M128i*)(&value))->m128i_u32[tIndex];
1324 #ifdef OCEAN_COMPILER_MSC
1325 return value.m128i_u32[0] + value.m128i_u32[1] + value.m128i_u32[2] + value.m128i_u32[3];
1327 return ((
const M128i*)(&value))->m128i_u32[0] + ((
const M128i*)(&value))->m128i_u32[1] + ((
const M128i*)(&value))->m128i_u32[2] + ((
const M128i*)(&value))->m128i_u32[3];
1333 #ifdef OCEAN_COMPILER_MSC
1334 return value.m128i_u32[0] + value.m128i_u32[1];
1336 return ((
const M128i*)(&value))->m128i_u32[0] + ((
const M128i*)(&value))->m128i_u32[1];
1342 #ifdef OCEAN_COMPILER_MSC
1343 return value.m128i_u32[0] + value.m128i_u32[2];
1345 return ((
const M128i*)(&value))->m128i_u32[0] + ((
const M128i*)(&value))->m128i_u32[2];
1351 #ifdef OCEAN_COMPILER_MSC
1352 return value.m128_f32[0] + value.m128_f32[1] + value.m128_f32[2] + value.m128_f32[3];
1354 return ((
const M128*)(&value))->m128_f32[0] + ((
const M128*)(&value))->m128_f32[1] + ((
const M128*)(&value))->m128_f32[2] + ((
const M128*)(&value))->m128_f32[3];
1360 #ifdef OCEAN_COMPILER_MSC
1361 return value.m128d_f64[0] + value.m128d_f64[1];
1363 return ((
const M128d*)(&value))->m128d_f64[0] + ((
const M128d*)(&value))->m128d_f64[1];
1369 ocean_assert(image0 && image1);
1376 ocean_assert(image0 && image1);
1383 ocean_assert(image0 && image1);
1385 const __m128i row0 = _mm_lddqu_si128((__m128i*)image0);
1386 const __m128i row1 = _mm_lddqu_si128((__m128i*)image1);
1389 const __m128i subtract = _mm_or_si128(_mm_subs_epu8(row0, row1), _mm_subs_epu8(row1, row0));
1393 const __m128i subtractLow = _mm_shuffle_epi8(subtract,
set128i(0xA0A0A0A0A00AA008ull, 0xA006A004A002A000ull));
1394 const __m128i subtractHigh = _mm_shuffle_epi8(subtract,
set128i(0xA0A0A0A0A00BA009ull, 0xA007A005A003A001ull));
1397 const __m128i squareLow = _mm_mullo_epi16(subtractLow, subtractLow);
1398 const __m128i squareHigh = _mm_mullo_epi16(subtractHigh, subtractHigh);
1405 return _mm_add_epi32(sumSquareLow, sumSquareHigh);
1410 ocean_assert(image0 && image1);
1412 const __m128i row0 = _mm_lddqu_si128((__m128i*)image0);
1413 const __m128i row1 = _mm_lddqu_si128((__m128i*)image1);
1416 const __m128i subtract = _mm_or_si128(_mm_subs_epu8(row0, row1), _mm_subs_epu8(row1, row0));
1420 const __m128i subtractLow = _mm_shuffle_epi8(subtract,
set128i(0xA0A0A0A0A00EA00Cull, 0xA00AA008A006A004ull));
1421 const __m128i subtractHigh = _mm_shuffle_epi8(subtract,
set128i(0xA0A0A0A0A00FA00Dull, 0xA00BA009A007A005ull));
1424 const __m128i squareLow = _mm_mullo_epi16(subtractLow, subtractLow);
1425 const __m128i squareHigh = _mm_mullo_epi16(subtractHigh, subtractHigh);
1432 return _mm_add_epi32(sumSquareLow, sumSquareHigh);
1435 template <
bool tBufferHas16Bytes>
1438 ocean_assert(image0 && image1);
1440 const __m128i row0 = load_u8_13_lower_random<tBufferHas16Bytes>(image0);
1441 const __m128i row1 = load_u8_13_lower_random<tBufferHas16Bytes>(image1);
1444 const __m128i subtract = _mm_or_si128(_mm_subs_epu8(row0, row1), _mm_subs_epu8(row1, row0));
1448 const __m128i subtractLow = _mm_shuffle_epi8(subtract,
set128i(0xA0A0A00CA00AA008ull, 0xA006A004A002A000ull));
1449 const __m128i subtractHigh = _mm_shuffle_epi8(subtract,
set128i(0xA0A0A0A0A00BA009ull, 0xA007A005A003A001ull));
1452 const __m128i squareLow = _mm_mullo_epi16(subtractLow, subtractLow);
1453 const __m128i squareHigh = _mm_mullo_epi16(subtractHigh, subtractHigh);
1460 return _mm_add_epi32(sumSquareLow, sumSquareHigh);
1465 ocean_assert(image0 && image1);
1467 const __m128i row0 = _mm_lddqu_si128((__m128i*)image0);
1468 const __m128i row1 = _mm_lddqu_si128((__m128i*)image1);
1471 const __m128i subtract = _mm_or_si128(_mm_subs_epu8(row0, row1), _mm_subs_epu8(row1, row0));
1475 const __m128i subtractLow = _mm_shuffle_epi8(subtract,
set128i(0xA0A0A00FA00DA00Bull, 0xA009A007A005A003ull));
1476 const __m128i subtractHigh = _mm_shuffle_epi8(subtract,
set128i(0xA0A0A0A0A00EA00Cull, 0xA00AA008A006A004ull));
1479 const __m128i squareLow = _mm_mullo_epi16(subtractLow, subtractLow);
1480 const __m128i squareHigh = _mm_mullo_epi16(subtractHigh, subtractHigh);
1487 return _mm_add_epi32(sumSquareLow, sumSquareHigh);
1490 template <
bool tBufferHas16Bytes>
1493 ocean_assert(image0 && image1);
1495 const __m128i row0 = load_u8_15_lower_random<tBufferHas16Bytes>(image0);
1496 const __m128i row1 = load_u8_15_lower_random<tBufferHas16Bytes>(image1);
1499 const __m128i subtract = _mm_or_si128(_mm_subs_epu8(row0, row1), _mm_subs_epu8(row1, row0));
1506 const __m128i squareLow = _mm_mullo_epi16(subtractLow, subtractLow);
1507 const __m128i squareHigh = _mm_mullo_epi16(subtractHigh, subtractHigh);
1514 return _mm_add_epi32(sumSquareLow, sumSquareHigh);
1517 template <
bool tBufferHas16Bytes>
1520 ocean_assert(image0 && image1);
1522 return _mm_sad_epu8(load_u8_10_upper_zero<tBufferHas16Bytes>(image0), load_u8_10_upper_zero<tBufferHas16Bytes>(image1));
1525 template <
bool tBufferHas16Bytes>
1528 ocean_assert(image0 && image1);
1530 return _mm_sad_epu8(load_u8_15_upper_zero<tBufferHas16Bytes>(image0), load_u8_15_upper_zero<tBufferHas16Bytes>(image1));
1535 ocean_assert(image0 && image1);
1537 const __m128i row0 = _mm_lddqu_si128((__m128i*)image0);
1538 const __m128i row1 = _mm_lddqu_si128((__m128i*)image1);
1545 ocean_assert(image0 && image1);
1552 ocean_assert(image0 && image1);
1553 ocean_assert((
unsigned long long)image0 % 16ll == 0ll);
1554 ocean_assert((
unsigned long long)image1 % 16ll == 0ll);
1556 const __m128i row0 = _mm_load_si128((__m128i*)image0);
1557 const __m128i row1 = _mm_load_si128((__m128i*)image1);
1565 const __m128i subtract = _mm_or_si128(_mm_subs_epu8(row0, row1), _mm_subs_epu8(row1, row0));
1572 const __m128i squareLow = _mm_mullo_epi16(subtractLow, subtractLow);
1573 const __m128i squareHigh = _mm_mullo_epi16(subtractHigh, subtractHigh);
1580 return _mm_add_epi32(sumSquareLow, sumSquareHigh);
1595 #ifdef OCEAN_COMPILER_MSC
1597 ocean_assert(fx_fy_.m128i_u16[0] == fx_fy_.m128i_u16[1]);
1598 ocean_assert(fx_fy_.m128i_u16[1] == fx_fy_.m128i_u16[2]);
1599 ocean_assert(fx_fy_.m128i_u16[2] == fx_fy_.m128i_u16[3]);
1600 ocean_assert(fx_fy_.m128i_u16[3] == fx_fy_.m128i_u16[4]);
1601 ocean_assert(fx_fy_.m128i_u16[4] == fx_fy_.m128i_u16[5]);
1602 ocean_assert(fx_fy_.m128i_u16[5] == fx_fy_.m128i_u16[6]);
1603 ocean_assert(fx_fy_.m128i_u16[6] == fx_fy_.m128i_u16[7]);
1605 ocean_assert(fxfy_.m128i_u16[0] == fxfy_.m128i_u16[1]);
1606 ocean_assert(fxfy_.m128i_u16[1] == fxfy_.m128i_u16[2]);
1607 ocean_assert(fxfy_.m128i_u16[2] == fxfy_.m128i_u16[3]);
1608 ocean_assert(fxfy_.m128i_u16[3] == fxfy_.m128i_u16[4]);
1609 ocean_assert(fxfy_.m128i_u16[4] == fxfy_.m128i_u16[5]);
1610 ocean_assert(fxfy_.m128i_u16[5] == fxfy_.m128i_u16[6]);
1611 ocean_assert(fxfy_.m128i_u16[6] == fxfy_.m128i_u16[7]);
1613 ocean_assert(fx_fy.m128i_u16[0] == fx_fy.m128i_u16[1]);
1614 ocean_assert(fx_fy.m128i_u16[1] == fx_fy.m128i_u16[2]);
1615 ocean_assert(fx_fy.m128i_u16[2] == fx_fy.m128i_u16[3]);
1616 ocean_assert(fx_fy.m128i_u16[3] == fx_fy.m128i_u16[4]);
1617 ocean_assert(fx_fy.m128i_u16[4] == fx_fy.m128i_u16[5]);
1618 ocean_assert(fx_fy.m128i_u16[5] == fx_fy.m128i_u16[6]);
1619 ocean_assert(fx_fy.m128i_u16[6] == fx_fy.m128i_u16[7]);
1621 ocean_assert(fxfy.m128i_u16[0] == fxfy.m128i_u16[1]);
1622 ocean_assert(fxfy.m128i_u16[1] == fxfy.m128i_u16[2]);
1623 ocean_assert(fxfy.m128i_u16[2] == fxfy.m128i_u16[3]);
1624 ocean_assert(fxfy.m128i_u16[3] == fxfy.m128i_u16[4]);
1625 ocean_assert(fxfy.m128i_u16[4] == fxfy.m128i_u16[5]);
1626 ocean_assert(fxfy.m128i_u16[5] == fxfy.m128i_u16[6]);
1627 ocean_assert(fxfy.m128i_u16[6] == fxfy.m128i_u16[7]);
1629 ocean_assert(fx_fy_.m128i_u16[0] + fxfy_.m128i_u16[0] + fx_fy.m128i_u16[0] + fxfy.m128i_u16[0] == 128u * 128u);
1635 const M128i& debug_fx_fy_ = *(
const M128i*)(&fx_fy_);
1636 const M128i& debug_fx_fy = *(
const M128i*)(&fx_fy);
1637 const M128i& debug_fxfy_ = *(
const M128i*)(&fxfy_);
1638 const M128i& debug_fxfy = *(
const M128i*)(&fxfy);
1678 __m128i shuffle =
set128i(0xA007A006A005A004ull, 0xA003A002A001A000ull);
1681 __m128i row = _mm_shuffle_epi8(values0, shuffle);
1683 __m128i multiLow = _mm_mullo_epi16(row, fx_fy_);
1684 __m128i multiHigh = _mm_mulhi_epu16(row, fx_fy_);
1686 __m128i resultEven = _mm_blend_epi16(multiLow, _mm_slli_si128(multiHigh, 2), 0xAA);
1687 __m128i resultOdd = _mm_blend_epi16(_mm_srli_si128(multiLow, 2), multiHigh, 0xAA);
1690 row = _mm_shuffle_epi8(values1, shuffle);
1692 multiLow = _mm_mullo_epi16(row, fx_fy);
1693 multiHigh = _mm_mulhi_epu16(row, fx_fy);
1695 resultEven = _mm_add_epi32(resultEven, _mm_blend_epi16(multiLow, _mm_slli_si128(multiHigh, 2), 0xAA));
1696 resultOdd = _mm_add_epi32(resultOdd, _mm_blend_epi16(_mm_srli_si128(multiLow, 2), multiHigh, 0xAA));
1700 shuffle =
set128i(0xA008A007A006A005ull, 0xA004A003A002A001ull);
1703 row = _mm_shuffle_epi8(values0, shuffle);
1705 multiLow = _mm_mullo_epi16(row, fxfy_);
1706 multiHigh = _mm_mulhi_epu16(row, fxfy_);
1708 resultEven = _mm_add_epi32(resultEven, _mm_blend_epi16(multiLow, _mm_slli_si128(multiHigh, 2), 0xAA));
1709 resultOdd = _mm_add_epi32(resultOdd, _mm_blend_epi16(_mm_srli_si128(multiLow, 2), multiHigh, 0xAA));
1713 row = _mm_shuffle_epi8(values1, shuffle);
1715 multiLow = _mm_mullo_epi16(row, fxfy);
1716 multiHigh = _mm_mulhi_epu16(row, fxfy);
1718 resultEven = _mm_add_epi32(resultEven, _mm_blend_epi16(multiLow, _mm_slli_si128(multiHigh, 2), 0xAA));
1719 resultOdd = _mm_add_epi32(resultOdd, _mm_blend_epi16(_mm_srli_si128(multiLow, 2), multiHigh, 0xAA));
1723 resultEven = _mm_add_epi32(resultEven, _mm_set1_epi32(8192));
1724 resultEven = _mm_srli_epi32(resultEven, 14);
1726 resultOdd = _mm_add_epi32(resultOdd, _mm_set1_epi32(8192));
1727 resultOdd = _mm_srli_epi32(resultOdd, 14);
1745 #ifdef OCEAN_COMPILER_MSC
1747 ocean_assert(fx_fy_.m128i_u16[0] == fx_fy_.m128i_u16[1]);
1748 ocean_assert(fx_fy_.m128i_u16[1] == fx_fy_.m128i_u16[2]);
1749 ocean_assert(fx_fy_.m128i_u16[2] == fx_fy_.m128i_u16[3]);
1750 ocean_assert(fx_fy_.m128i_u16[3] == fx_fy_.m128i_u16[4]);
1751 ocean_assert(fx_fy_.m128i_u16[4] == fx_fy_.m128i_u16[5]);
1752 ocean_assert(fx_fy_.m128i_u16[5] == fx_fy_.m128i_u16[6]);
1753 ocean_assert(fx_fy_.m128i_u16[6] == fx_fy_.m128i_u16[7]);
1755 ocean_assert(fxfy_.m128i_u16[0] == fxfy_.m128i_u16[1]);
1756 ocean_assert(fxfy_.m128i_u16[1] == fxfy_.m128i_u16[2]);
1757 ocean_assert(fxfy_.m128i_u16[2] == fxfy_.m128i_u16[3]);
1758 ocean_assert(fxfy_.m128i_u16[3] == fxfy_.m128i_u16[4]);
1759 ocean_assert(fxfy_.m128i_u16[4] == fxfy_.m128i_u16[5]);
1760 ocean_assert(fxfy_.m128i_u16[5] == fxfy_.m128i_u16[6]);
1761 ocean_assert(fxfy_.m128i_u16[6] == fxfy_.m128i_u16[7]);
1763 ocean_assert(fx_fy.m128i_u16[0] == fx_fy.m128i_u16[1]);
1764 ocean_assert(fx_fy.m128i_u16[1] == fx_fy.m128i_u16[2]);
1765 ocean_assert(fx_fy.m128i_u16[2] == fx_fy.m128i_u16[3]);
1766 ocean_assert(fx_fy.m128i_u16[3] == fx_fy.m128i_u16[4]);
1767 ocean_assert(fx_fy.m128i_u16[4] == fx_fy.m128i_u16[5]);
1768 ocean_assert(fx_fy.m128i_u16[5] == fx_fy.m128i_u16[6]);
1769 ocean_assert(fx_fy.m128i_u16[6] == fx_fy.m128i_u16[7]);
1771 ocean_assert(fxfy.m128i_u16[0] == fxfy.m128i_u16[1]);
1772 ocean_assert(fxfy.m128i_u16[1] == fxfy.m128i_u16[2]);
1773 ocean_assert(fxfy.m128i_u16[2] == fxfy.m128i_u16[3]);
1774 ocean_assert(fxfy.m128i_u16[3] == fxfy.m128i_u16[4]);
1775 ocean_assert(fxfy.m128i_u16[4] == fxfy.m128i_u16[5]);
1776 ocean_assert(fxfy.m128i_u16[5] == fxfy.m128i_u16[6]);
1777 ocean_assert(fxfy.m128i_u16[6] == fxfy.m128i_u16[7]);
1783 const M128i& debug_fx_fy_ = *(
const M128i*)(&fx_fy_);
1784 const M128i& debug_fx_fy = *(
const M128i*)(&fx_fy);
1785 const M128i& debug_fxfy_ = *(
const M128i*)(&fxfy_);
1786 const M128i& debug_fxfy = *(
const M128i*)(&fxfy);
1824 __m128i shuffle =
set128i(0xA007A006A005A004ull, 0xA003A002A001A000ull);
1827 __m128i row = _mm_shuffle_epi8(values0, shuffle);
1829 __m128i multiLow = _mm_mullo_epi16(row, fx_fy_);
1830 __m128i multiHigh = _mm_mulhi_epu16(row, fx_fy_);
1832 __m128i resultEven = _mm_blend_epi16(multiLow, _mm_slli_si128(multiHigh, 2), 0xAA);
1833 __m128i resultOdd = _mm_blend_epi16(_mm_srli_si128(multiLow, 2), multiHigh, 0xAA);
1836 row = _mm_shuffle_epi8(values1, shuffle);
1838 multiLow = _mm_mullo_epi16(row, fx_fy);
1839 multiHigh = _mm_mulhi_epu16(row, fx_fy);
1841 resultEven = _mm_add_epi32(resultEven, _mm_blend_epi16(multiLow, _mm_slli_si128(multiHigh, 2), 0xAA));
1842 resultOdd = _mm_add_epi32(resultOdd, _mm_blend_epi16(_mm_srli_si128(multiLow, 2), multiHigh, 0xAA));
1846 shuffle =
set128i(0xA009A008A007A006ull, 0xA005A004A003A002ull);
1849 row = _mm_shuffle_epi8(values0, shuffle);
1851 multiLow = _mm_mullo_epi16(row, fxfy_);
1852 multiHigh = _mm_mulhi_epu16(row, fxfy_);
1854 resultEven = _mm_add_epi32(resultEven, _mm_blend_epi16(multiLow, _mm_slli_si128(multiHigh, 2), 0xAA));
1855 resultOdd = _mm_add_epi32(resultOdd, _mm_blend_epi16(_mm_srli_si128(multiLow, 2), multiHigh, 0xAA));
1859 row = _mm_shuffle_epi8(values1, shuffle);
1861 multiLow = _mm_mullo_epi16(row, fxfy);
1862 multiHigh = _mm_mulhi_epu16(row, fxfy);
1864 resultEven = _mm_add_epi32(resultEven, _mm_blend_epi16(multiLow, _mm_slli_si128(multiHigh, 2), 0xAA));
1865 resultOdd = _mm_add_epi32(resultOdd, _mm_blend_epi16(_mm_srli_si128(multiLow, 2), multiHigh, 0xAA));
1869 resultEven = _mm_add_epi32(resultEven, _mm_set1_epi32(8192));
1870 resultEven = _mm_srli_epi32(resultEven, 14);
1872 resultOdd = _mm_add_epi32(resultOdd, _mm_set1_epi32(8192));
1873 resultOdd = _mm_srli_epi32(resultOdd, 14);
1891 #ifdef OCEAN_COMPILER_MSC
1893 ocean_assert(fx_fy_.m128i_u16[0] == fx_fy_.m128i_u16[1]);
1894 ocean_assert(fx_fy_.m128i_u16[1] == fx_fy_.m128i_u16[2]);
1895 ocean_assert(fx_fy_.m128i_u16[2] == fx_fy_.m128i_u16[3]);
1896 ocean_assert(fx_fy_.m128i_u16[3] == fx_fy_.m128i_u16[4]);
1897 ocean_assert(fx_fy_.m128i_u16[4] == fx_fy_.m128i_u16[5]);
1898 ocean_assert(fx_fy_.m128i_u16[5] == fx_fy_.m128i_u16[6]);
1899 ocean_assert(fx_fy_.m128i_u16[6] == fx_fy_.m128i_u16[7]);
1901 ocean_assert(fxfy_.m128i_u16[0] == fxfy_.m128i_u16[1]);
1902 ocean_assert(fxfy_.m128i_u16[1] == fxfy_.m128i_u16[2]);
1903 ocean_assert(fxfy_.m128i_u16[2] == fxfy_.m128i_u16[3]);
1904 ocean_assert(fxfy_.m128i_u16[3] == fxfy_.m128i_u16[4]);
1905 ocean_assert(fxfy_.m128i_u16[4] == fxfy_.m128i_u16[5]);
1906 ocean_assert(fxfy_.m128i_u16[5] == fxfy_.m128i_u16[6]);
1907 ocean_assert(fxfy_.m128i_u16[6] == fxfy_.m128i_u16[7]);
1909 ocean_assert(fx_fy.m128i_u16[0] == fx_fy.m128i_u16[1]);
1910 ocean_assert(fx_fy.m128i_u16[1] == fx_fy.m128i_u16[2]);
1911 ocean_assert(fx_fy.m128i_u16[2] == fx_fy.m128i_u16[3]);
1912 ocean_assert(fx_fy.m128i_u16[3] == fx_fy.m128i_u16[4]);
1913 ocean_assert(fx_fy.m128i_u16[4] == fx_fy.m128i_u16[5]);
1914 ocean_assert(fx_fy.m128i_u16[5] == fx_fy.m128i_u16[6]);
1915 ocean_assert(fx_fy.m128i_u16[6] == fx_fy.m128i_u16[7]);
1917 ocean_assert(fxfy.m128i_u16[0] == fxfy.m128i_u16[1]);
1918 ocean_assert(fxfy.m128i_u16[1] == fxfy.m128i_u16[2]);
1919 ocean_assert(fxfy.m128i_u16[2] == fxfy.m128i_u16[3]);
1920 ocean_assert(fxfy.m128i_u16[3] == fxfy.m128i_u16[4]);
1921 ocean_assert(fxfy.m128i_u16[4] == fxfy.m128i_u16[5]);
1922 ocean_assert(fxfy.m128i_u16[5] == fxfy.m128i_u16[6]);
1923 ocean_assert(fxfy.m128i_u16[6] == fxfy.m128i_u16[7]);
1929 const M128i& debug_fx_fy_ = *(
const M128i*)(&fx_fy_);
1930 const M128i& debug_fx_fy = *(
const M128i*)(&fx_fy);
1931 const M128i& debug_fxfy_ = *(
const M128i*)(&fxfy_);
1932 const M128i& debug_fxfy = *(
const M128i*)(&fxfy);
1970 __m128i shuffle =
set128i(0xA007A006A005A004ull, 0xA003A002A001A000ull);
1973 __m128i row = _mm_shuffle_epi8(values0, shuffle);
1975 __m128i multiLow = _mm_mullo_epi16(row, fx_fy_);
1976 __m128i multiHigh = _mm_mulhi_epu16(row, fx_fy_);
1978 __m128i resultEven = _mm_blend_epi16(multiLow, _mm_slli_si128(multiHigh, 2), 0xAA);
1979 __m128i resultOdd = _mm_blend_epi16(_mm_srli_si128(multiLow, 2), multiHigh, 0xAA);
1982 row = _mm_shuffle_epi8(values1, shuffle);
1984 multiLow = _mm_mullo_epi16(row, fx_fy);
1985 multiHigh = _mm_mulhi_epu16(row, fx_fy);
1987 resultEven = _mm_add_epi32(resultEven, _mm_blend_epi16(multiLow, _mm_slli_si128(multiHigh, 2), 0xAA));
1988 resultOdd = _mm_add_epi32(resultOdd, _mm_blend_epi16(_mm_srli_si128(multiLow, 2), multiHigh, 0xAA));
1992 shuffle =
set128i(0xA00AA009A008A007ull, 0xA006A005A004A003ull);
1995 row = _mm_shuffle_epi8(values0, shuffle);
1997 multiLow = _mm_mullo_epi16(row, fxfy_);
1998 multiHigh = _mm_mulhi_epu16(row, fxfy_);
2000 resultEven = _mm_add_epi32(resultEven, _mm_blend_epi16(multiLow, _mm_slli_si128(multiHigh, 2), 0xAA));
2001 resultOdd = _mm_add_epi32(resultOdd, _mm_blend_epi16(_mm_srli_si128(multiLow, 2), multiHigh, 0xAA));
2005 row = _mm_shuffle_epi8(values1, shuffle);
2007 multiLow = _mm_mullo_epi16(row, fxfy);
2008 multiHigh = _mm_mulhi_epu16(row, fxfy);
2010 resultEven = _mm_add_epi32(resultEven, _mm_blend_epi16(multiLow, _mm_slli_si128(multiHigh, 2), 0xAA));
2011 resultOdd = _mm_add_epi32(resultOdd, _mm_blend_epi16(_mm_srli_si128(multiLow, 2), multiHigh, 0xAA));
2015 resultEven = _mm_add_epi32(resultEven, _mm_set1_epi32(8192));
2016 resultEven = _mm_srli_epi32(resultEven, 14);
2018 resultOdd = _mm_add_epi32(resultOdd, _mm_set1_epi32(8192));
2019 resultOdd = _mm_srli_epi32(resultOdd, 14);
2027 __m128i row0_a = _mm_shuffle_epi8(values0,
set128i(0xFF04FF03FF03FF02ull, 0xFF02FF01FF01FF00ull));
2028 __m128i row1_a = _mm_shuffle_epi8(values1,
set128i(0xFF04FF03FF03FF02ull, 0xFF02FF01FF01FF00ull));
2030 __m128i row0_b = _mm_shuffle_epi8(values0,
set128i(0xFF08FF07FF07FF06ull, 0xFF06FF05FF05FF04ull));
2031 __m128i row1_b = _mm_shuffle_epi8(values1,
set128i(0xFF08FF07FF07FF06ull, 0xFF06FF05FF05FF04ull));
2033 __m128i row0_c = _mm_shuffle_epi8(values0,
set128i(0xFF0cFF0bFF0bFF0aull, 0xFF0aFF09FF09FF08ull));
2034 __m128i row1_c = _mm_shuffle_epi8(values1,
set128i(0xFF0cFF0bFF0bFF0aull, 0xFF0aFF09FF09FF08ull));
2036 __m128i row0_d = _mm_shuffle_epi8(values0,
set128i(0xFFFFFFFFFF0fFF0eull, 0xFF0eFF0dFF0dFF0cull));
2037 __m128i row1_d = _mm_shuffle_epi8(values1,
set128i(0xFFFFFFFFFF0fFF0eull, 0xFF0eFF0dFF0dFF0cull));
2039 row0_a = _mm_madd_epi16(row0_a, fx_fy_fxfy_);
2040 row0_b = _mm_madd_epi16(row0_b, fx_fy_fxfy_);
2041 row0_c = _mm_madd_epi16(row0_c, fx_fy_fxfy_);
2042 row0_d = _mm_madd_epi16(row0_d, fx_fy_fxfy_);
2044 row1_a = _mm_madd_epi16(row1_a, fx_fyfxfy);
2045 row1_b = _mm_madd_epi16(row1_b, fx_fyfxfy);
2046 row1_c = _mm_madd_epi16(row1_c, fx_fyfxfy);
2047 row1_d = _mm_madd_epi16(row1_d, fx_fyfxfy);
2049 const __m128i rounding = _mm_set1_epi32(8192);
2051 __m128i row_a = _mm_add_epi32(row0_a, row1_a);
2052 __m128i row_b = _mm_add_epi32(row0_b, row1_b);
2053 __m128i row_c = _mm_add_epi32(row0_c, row1_c);
2054 __m128i row_d = _mm_add_epi32(row0_d, row1_d);
2056 row_a = _mm_add_epi32(row_a, rounding);
2057 row_b = _mm_add_epi32(row_b, rounding);
2058 row_c = _mm_add_epi32(row_c, rounding);
2059 row_d = _mm_add_epi32(row_d, rounding);
2061 row_a = _mm_srli_epi32(row_a, 14);
2062 row_b = _mm_srli_epi32(row_b, 14);
2063 row_c = _mm_srli_epi32(row_c, 14);
2064 row_d = _mm_srli_epi32(row_d, 14);
2066 row_a = _mm_shuffle_epi8(row_a,
set128i(0xFFFFFFFFFFFFFFFFull, 0xFFFFFFFF0c080400ull));
2067 row_b = _mm_shuffle_epi8(row_b,
set128i(0xFFFFFFFFFFFFFFFFull, 0x0c080400FFFFFFFFull));
2068 row_c = _mm_shuffle_epi8(row_c,
set128i(0xFFFFFFFF0c080400ull, 0xFFFFFFFFFFFFFFFFull));
2069 row_d = _mm_shuffle_epi8(row_d,
set128i(0xFF080400FFFFFFFFull, 0xFFFFFFFFFFFFFFFFull));
2071 row_a = _mm_or_si128(row_a, row_b);
2072 row_c = _mm_or_si128(row_c, row_d);
2074 return _mm_or_si128(row_a, row_c);
2079 __m128i row0_a = _mm_shuffle_epi8(values0,
set128i(0xFF0cFF09FF09FF06ull, 0xFF06FF03FF03FF00ull));
2080 __m128i row1_a = _mm_shuffle_epi8(values1,
set128i(0xFF0cFF09FF09FF06ull, 0xFF06FF03FF03FF00ull));
2082 __m128i row0_b = _mm_shuffle_epi8(values0,
set128i(0xFF0dFF0aFF0aFF07ull, 0xFF07FF04FF04FF01ull));
2083 __m128i row1_b = _mm_shuffle_epi8(values1,
set128i(0xFF0dFF0aFF0aFF07ull, 0xFF07FF04FF04FF01ull));
2085 __m128i row0_c = _mm_shuffle_epi8(values0,
set128i(0xFF0eFF0bFF0bFF08ull, 0xFF08FF05FF05FF02ull));
2086 __m128i row1_c = _mm_shuffle_epi8(values1,
set128i(0xFF0eFF0bFF0bFF08ull, 0xFF08FF05FF05FF02ull));
2088 row0_a = _mm_madd_epi16(row0_a, fx_fy_fxfy_);
2089 row0_b = _mm_madd_epi16(row0_b, fx_fy_fxfy_);
2090 row0_c = _mm_madd_epi16(row0_c, fx_fy_fxfy_);
2092 row1_a = _mm_madd_epi16(row1_a, fx_fyfxfy);
2093 row1_b = _mm_madd_epi16(row1_b, fx_fyfxfy);
2094 row1_c = _mm_madd_epi16(row1_c, fx_fyfxfy);
2096 const __m128i rounding = _mm_set1_epi32(8192);
2098 __m128i row_a = _mm_add_epi32(row0_a, row1_a);
2099 __m128i row_b = _mm_add_epi32(row0_b, row1_b);
2100 __m128i row_c = _mm_add_epi32(row0_c, row1_c);
2102 row_a = _mm_add_epi32(row_a, rounding);
2103 row_b = _mm_add_epi32(row_b, rounding);
2104 row_c = _mm_add_epi32(row_c, rounding);
2106 row_a = _mm_srli_epi32(row_a, 14);
2107 row_b = _mm_srli_epi32(row_b, 14);
2108 row_c = _mm_srli_epi32(row_c, 14);
2110 row_a = _mm_shuffle_epi8(row_a,
set128i(0xFFFFFFFFFFFF0cFFull, 0xFF08FFFF04FFFF00ull));
2111 row_b = _mm_shuffle_epi8(row_b,
set128i(0xFFFFFFFFFF0cFFFFull, 0x08FFFF04FFFF00FFull));
2112 row_c = _mm_shuffle_epi8(row_c,
set128i(0xFFFFFFFF0cFFFF08ull, 0xFFFF04FFFF00FFFFull));
2114 return _mm_or_si128(row_a, _mm_or_si128(row_b, row_c));
2129 #ifdef OCEAN_COMPILER_MSC
2131 ocean_assert(fx_fy_.m128i_u16[0] == fx_fy_.m128i_u16[1]);
2132 ocean_assert(fx_fy_.m128i_u16[1] == fx_fy_.m128i_u16[2]);
2133 ocean_assert(fx_fy_.m128i_u16[2] == fx_fy_.m128i_u16[3]);
2134 ocean_assert(fx_fy_.m128i_u16[3] == fx_fy_.m128i_u16[4]);
2135 ocean_assert(fx_fy_.m128i_u16[4] == fx_fy_.m128i_u16[5]);
2136 ocean_assert(fx_fy_.m128i_u16[5] == fx_fy_.m128i_u16[6]);
2137 ocean_assert(fx_fy_.m128i_u16[6] == fx_fy_.m128i_u16[7]);
2139 ocean_assert(fxfy_.m128i_u16[0] == fxfy_.m128i_u16[1]);
2140 ocean_assert(fxfy_.m128i_u16[1] == fxfy_.m128i_u16[2]);
2141 ocean_assert(fxfy_.m128i_u16[2] == fxfy_.m128i_u16[3]);
2142 ocean_assert(fxfy_.m128i_u16[3] == fxfy_.m128i_u16[4]);
2143 ocean_assert(fxfy_.m128i_u16[4] == fxfy_.m128i_u16[5]);
2144 ocean_assert(fxfy_.m128i_u16[5] == fxfy_.m128i_u16[6]);
2145 ocean_assert(fxfy_.m128i_u16[6] == fxfy_.m128i_u16[7]);
2147 ocean_assert(fx_fy.m128i_u16[0] == fx_fy.m128i_u16[1]);
2148 ocean_assert(fx_fy.m128i_u16[1] == fx_fy.m128i_u16[2]);
2149 ocean_assert(fx_fy.m128i_u16[2] == fx_fy.m128i_u16[3]);
2150 ocean_assert(fx_fy.m128i_u16[3] == fx_fy.m128i_u16[4]);
2151 ocean_assert(fx_fy.m128i_u16[4] == fx_fy.m128i_u16[5]);
2152 ocean_assert(fx_fy.m128i_u16[5] == fx_fy.m128i_u16[6]);
2153 ocean_assert(fx_fy.m128i_u16[6] == fx_fy.m128i_u16[7]);
2155 ocean_assert(fxfy.m128i_u16[0] == fxfy.m128i_u16[1]);
2156 ocean_assert(fxfy.m128i_u16[1] == fxfy.m128i_u16[2]);
2157 ocean_assert(fxfy.m128i_u16[2] == fxfy.m128i_u16[3]);
2158 ocean_assert(fxfy.m128i_u16[3] == fxfy.m128i_u16[4]);
2159 ocean_assert(fxfy.m128i_u16[4] == fxfy.m128i_u16[5]);
2160 ocean_assert(fxfy.m128i_u16[5] == fxfy.m128i_u16[6]);
2161 ocean_assert(fxfy.m128i_u16[6] == fxfy.m128i_u16[7]);
2167 const M128i& debug_fx_fy_ = *(
const M128i*)(&fx_fy_);
2168 const M128i& debug_fx_fy = *(
const M128i*)(&fx_fy);
2169 const M128i& debug_fxfy_ = *(
const M128i*)(&fxfy_);
2170 const M128i& debug_fxfy = *(
const M128i*)(&fxfy);
2208 __m128i shuffle =
set128i(0xA007A006A005A004ull, 0xA003A002A001A000ull);
2211 __m128i row = _mm_shuffle_epi8(values0, shuffle);
2213 __m128i multiLow = _mm_mullo_epi16(row, fx_fy_);
2214 __m128i multiHigh = _mm_mulhi_epu16(row, fx_fy_);
2216 __m128i resultEven = _mm_blend_epi16(multiLow, _mm_slli_si128(multiHigh, 2), 0xAA);
2217 __m128i resultOdd = _mm_blend_epi16(_mm_srli_si128(multiLow, 2), multiHigh, 0xAA);
2220 row = _mm_shuffle_epi8(values1, shuffle);
2222 multiLow = _mm_mullo_epi16(row, fx_fy);
2223 multiHigh = _mm_mulhi_epu16(row, fx_fy);
2225 resultEven = _mm_add_epi32(resultEven, _mm_blend_epi16(multiLow, _mm_slli_si128(multiHigh, 2), 0xAA));
2226 resultOdd = _mm_add_epi32(resultOdd, _mm_blend_epi16(_mm_srli_si128(multiLow, 2), multiHigh, 0xAA));
2230 shuffle =
set128i(0xA00BA00AA009A008ull, 0xA007A006A005A004ull);
2233 row = _mm_shuffle_epi8(values0, shuffle);
2235 multiLow = _mm_mullo_epi16(row, fxfy_);
2236 multiHigh = _mm_mulhi_epu16(row, fxfy_);
2238 resultEven = _mm_add_epi32(resultEven, _mm_blend_epi16(multiLow, _mm_slli_si128(multiHigh, 2), 0xAA));
2239 resultOdd = _mm_add_epi32(resultOdd, _mm_blend_epi16(_mm_srli_si128(multiLow, 2), multiHigh, 0xAA));
2243 row = _mm_shuffle_epi8(values1, shuffle);
2245 multiLow = _mm_mullo_epi16(row, fxfy);
2246 multiHigh = _mm_mulhi_epu16(row, fxfy);
2248 resultEven = _mm_add_epi32(resultEven, _mm_blend_epi16(multiLow, _mm_slli_si128(multiHigh, 2), 0xAA));
2249 resultOdd = _mm_add_epi32(resultOdd, _mm_blend_epi16(_mm_srli_si128(multiLow, 2), multiHigh, 0xAA));
2253 resultEven = _mm_add_epi32(resultEven, _mm_set1_epi32(8192));
2254 resultEven = _mm_srli_epi32(resultEven, 14);
2256 resultOdd = _mm_add_epi32(resultOdd, _mm_set1_epi32(8192));
2257 resultOdd = _mm_srli_epi32(resultOdd, 14);
2276 #ifdef OCEAN_COMPILER_MSC
2278 ocean_assert(fx_fy_.m128i_u16[0] == fx_fy_.m128i_u16[1]);
2279 ocean_assert(fx_fy_.m128i_u16[1] == fx_fy_.m128i_u16[2]);
2280 ocean_assert(fx_fy_.m128i_u16[2] == fx_fy_.m128i_u16[3]);
2281 ocean_assert(fx_fy_.m128i_u16[3] == fx_fy_.m128i_u16[4]);
2282 ocean_assert(fx_fy_.m128i_u16[4] == fx_fy_.m128i_u16[5]);
2283 ocean_assert(fx_fy_.m128i_u16[5] == fx_fy_.m128i_u16[6]);
2284 ocean_assert(fx_fy_.m128i_u16[6] == fx_fy_.m128i_u16[7]);
2286 ocean_assert(fxfy_.m128i_u16[0] == fxfy_.m128i_u16[1]);
2287 ocean_assert(fxfy_.m128i_u16[1] == fxfy_.m128i_u16[2]);
2288 ocean_assert(fxfy_.m128i_u16[2] == fxfy_.m128i_u16[3]);
2289 ocean_assert(fxfy_.m128i_u16[3] == fxfy_.m128i_u16[4]);
2290 ocean_assert(fxfy_.m128i_u16[4] == fxfy_.m128i_u16[5]);
2291 ocean_assert(fxfy_.m128i_u16[5] == fxfy_.m128i_u16[6]);
2292 ocean_assert(fxfy_.m128i_u16[6] == fxfy_.m128i_u16[7]);
2294 ocean_assert(fx_fy.m128i_u16[0] == fx_fy.m128i_u16[1]);
2295 ocean_assert(fx_fy.m128i_u16[1] == fx_fy.m128i_u16[2]);
2296 ocean_assert(fx_fy.m128i_u16[2] == fx_fy.m128i_u16[3]);
2297 ocean_assert(fx_fy.m128i_u16[3] == fx_fy.m128i_u16[4]);
2298 ocean_assert(fx_fy.m128i_u16[4] == fx_fy.m128i_u16[5]);
2299 ocean_assert(fx_fy.m128i_u16[5] == fx_fy.m128i_u16[6]);
2300 ocean_assert(fx_fy.m128i_u16[6] == fx_fy.m128i_u16[7]);
2302 ocean_assert(fxfy.m128i_u16[0] == fxfy.m128i_u16[1]);
2303 ocean_assert(fxfy.m128i_u16[1] == fxfy.m128i_u16[2]);
2304 ocean_assert(fxfy.m128i_u16[2] == fxfy.m128i_u16[3]);
2305 ocean_assert(fxfy.m128i_u16[3] == fxfy.m128i_u16[4]);
2306 ocean_assert(fxfy.m128i_u16[4] == fxfy.m128i_u16[5]);
2307 ocean_assert(fxfy.m128i_u16[5] == fxfy.m128i_u16[6]);
2308 ocean_assert(fxfy.m128i_u16[6] == fxfy.m128i_u16[7]);
2314 const M128i& debug_fx_fy_ = *(
const M128i*)(&fx_fy_);
2315 const M128i& debug_fx_fy = *(
const M128i*)(&fx_fy);
2316 const M128i& debug_fxfy_ = *(
const M128i*)(&fxfy_);
2317 const M128i& debug_fxfy = *(
const M128i*)(&fxfy);
2355 __m128i shuffle =
set128i(0xA00BA00AA009A008ull, 0xA003A002A001A000ull);
2358 __m128i row = _mm_shuffle_epi8(values0, shuffle);
2360 __m128i multiLow = _mm_mullo_epi16(row, fx_fy_);
2361 __m128i multiHigh = _mm_mulhi_epu16(row, fx_fy_);
2363 __m128i resultEven = _mm_blend_epi16(multiLow, _mm_slli_si128(multiHigh, 2), 0xAA);
2364 __m128i resultOdd = _mm_blend_epi16(_mm_srli_si128(multiLow, 2), multiHigh, 0xAA);
2367 row = _mm_shuffle_epi8(values1, shuffle);
2369 multiLow = _mm_mullo_epi16(row, fx_fy);
2370 multiHigh = _mm_mulhi_epu16(row, fx_fy);
2372 resultEven = _mm_add_epi32(resultEven, _mm_blend_epi16(multiLow, _mm_slli_si128(multiHigh, 2), 0xAA));
2373 resultOdd = _mm_add_epi32(resultOdd, _mm_blend_epi16(_mm_srli_si128(multiLow, 2), multiHigh, 0xAA));
2377 shuffle =
set128i(0xA00FA00EA00DA00Cull, 0xA007A006A005A004ull);
2380 row = _mm_shuffle_epi8(values0, shuffle);
2382 multiLow = _mm_mullo_epi16(row, fxfy_);
2383 multiHigh = _mm_mulhi_epu16(row, fxfy_);
2385 resultEven = _mm_add_epi32(resultEven, _mm_blend_epi16(multiLow, _mm_slli_si128(multiHigh, 2), 0xAA));
2386 resultOdd = _mm_add_epi32(resultOdd, _mm_blend_epi16(_mm_srli_si128(multiLow, 2), multiHigh, 0xAA));
2390 row = _mm_shuffle_epi8(values1, shuffle);
2392 multiLow = _mm_mullo_epi16(row, fxfy);
2393 multiHigh = _mm_mulhi_epu16(row, fxfy);
2395 resultEven = _mm_add_epi32(resultEven, _mm_blend_epi16(multiLow, _mm_slli_si128(multiHigh, 2), 0xAA));
2396 resultOdd = _mm_add_epi32(resultOdd, _mm_blend_epi16(_mm_srli_si128(multiLow, 2), multiHigh, 0xAA));
2400 resultEven = _mm_add_epi32(resultEven, _mm_set1_epi32(8192));
2401 resultEven = _mm_srli_epi32(resultEven, 14);
2403 resultOdd = _mm_add_epi32(resultOdd, _mm_set1_epi32(8192));
2404 resultOdd = _mm_srli_epi32(resultOdd, 14);
2412 ocean_assert(image0 && image1);
2415 const __m128 row0 = _mm_loadu_ps(image0);
2416 const __m128 row1 = _mm_loadu_ps(image1);
2419 const __m128 sumFirst = _mm_add_ps(row0, row1);
2422 const __m128 rowSecond0 = _mm_loadu_ps(image0 + 4);
2423 const __m128 rowSecond1 = _mm_loadu_ps(image1 + 4);
2426 const __m128 sumSecond = _mm_add_ps(rowSecond0, rowSecond1);
2429 const __m128 sumAdjacent = _mm_hadd_ps(sumFirst, sumSecond);
2438 const __m128 division = _mm_mul_ps(sumAdjacent, _mm_set_ps1(0.25f));
2441 _mm_storeu_ps(result, division);
2446 ocean_assert(image0 && image1);
2449 const __m128i row0 = _mm_loadl_epi64((__m128i*)image0);
2450 const __m128i row1 = _mm_loadl_epi64((__m128i*)image1);
2457 const __m128i sum = _mm_add_epi16(sumLow, _mm_add_epi16(sumHigh, _mm_set1_epi32(
int(0x00020002))));
2460 const __m128i division16 = _mm_srli_epi16(sum, 2);
2465 memcpy(result, &division8,
sizeof(uint8_t) * 4);
2470 ocean_assert(image0 !=
nullptr && image1 !=
nullptr);
2471 ocean_assert(threshold >= 1u);
2474 const __m128i row0_u_8x8 = _mm_loadl_epi64((__m128i*)image0);
2475 const __m128i row1_u_8x8 = _mm_loadl_epi64((__m128i*)image1);
2477 const __m128i row0_u_16x8 = _mm_cvtepu8_epi16(row0_u_8x8);
2478 const __m128i row1_u_16x8 = _mm_cvtepu8_epi16(row1_u_8x8);
2480 const __m128i verticalSum_u_16x8 = _mm_adds_epu16(row0_u_16x8, row1_u_16x8);
2481 const __m128i sum_u_16x8 = _mm_hadd_epi16(verticalSum_u_16x8, verticalSum_u_16x8);
2483 const __m128i mask_u_16x8 = _mm_cmpgt_epi16(sum_u_16x8, _mm_set1_epi16(
short(threshold - 1u)));
2487 memcpy(result, &mask_u_8x8,
sizeof(uint8_t) * 4);
2492 ocean_assert(image0 && image1);
2495 const __m128i row0 = _mm_lddqu_si128((__m128i*)image0);
2496 const __m128i row1 = _mm_lddqu_si128((__m128i*)image1);
2503 const __m128i sum = _mm_add_epi16(sumLow, _mm_add_epi16(sumHigh, _mm_set1_epi32(
int(0x00020002))));
2506 const __m128i division16 = _mm_srli_epi16(sum, 2);
2512 _mm_storel_epi64((__m128i*)result, division8);
2527 ocean_assert(image0 !=
nullptr && image1 !=
nullptr);
2528 ocean_assert(threshold >= 1u);
2531 const __m128i row0_u_8x16 = _mm_lddqu_si128((__m128i*)image0);
2532 const __m128i row1_u_8x16 = _mm_lddqu_si128((__m128i*)image1);
2534 const __m128i horizontalSum0_u_16x8 = _mm_maddubs_epi16(row0_u_8x16, _mm_set1_epi8(1));
2535 const __m128i horizontalSum1_u_16x8 = _mm_maddubs_epi16(row1_u_8x16, _mm_set1_epi8(1));
2537 const __m128i sum_u_16x8 = _mm_add_epi16(horizontalSum0_u_16x8, horizontalSum1_u_16x8);
2539 const __m128i mask_u_16x8 = _mm_cmpgt_epi16(sum_u_16x8, _mm_set1_epi16(
short(threshold - 1u)));
2544 _mm_storel_epi64((__m128i*)result, mask_u_8x8);
2549 ocean_assert(image0 && image1);
2552 const __m128i firstRow0 = _mm_lddqu_si128((__m128i*)image0);
2553 const __m128i firstRow1 = _mm_lddqu_si128((__m128i*)image1);
2560 const __m128i firstSum = _mm_add_epi16(firstSumLow, _mm_add_epi16(firstSumHigh, _mm_set1_epi32(
int(0x00020002))));
2563 const __m128i firstDivision16 = _mm_srli_epi16(firstSum, 2);
2569 const __m128i secondRow0 = _mm_lddqu_si128((__m128i*)(image0 + 16));
2570 const __m128i secondRow1 = _mm_lddqu_si128((__m128i*)(image1 + 16));
2577 const __m128i secondSum = _mm_add_epi16(secondSumLow, _mm_add_epi16(secondSumHigh, _mm_set1_epi32(
int(0x00020002))));
2580 const __m128i secondDivision16 = _mm_srli_epi16(secondSum, 2);
2587 const __m128i division8 = _mm_or_si128(firstDivision8, secondDivision8);
2590 _mm_storeu_si128((__m128i*)result, division8);
2615 ocean_assert(image0 !=
nullptr && image1 !=
nullptr);
2616 ocean_assert(threshold >= 1u);
2619 const __m128i row0A_u_8x16 = _mm_lddqu_si128((__m128i*)image0);
2620 const __m128i row1A_u_8x16 = _mm_lddqu_si128((__m128i*)image1);
2622 const __m128i horizontalSum0A_u_16x8 = _mm_maddubs_epi16(row0A_u_8x16, _mm_set1_epi8(1));
2623 const __m128i horizontalSum1A_u_16x8 = _mm_maddubs_epi16(row1A_u_8x16, _mm_set1_epi8(1));
2625 const __m128i sumA_u_16x8 = _mm_add_epi16(horizontalSum0A_u_16x8, horizontalSum1A_u_16x8);
2627 const __m128i maskA_u_16x8 = _mm_cmpgt_epi16(sumA_u_16x8, _mm_set1_epi16(
short(threshold - 1)));
2629 const __m128i row0B_u_8x16 = _mm_lddqu_si128((__m128i*)(image0 + 16));
2630 const __m128i row1B_u_8x16 = _mm_lddqu_si128((__m128i*)(image1 + 16));
2632 const __m128i horizontalSum0B_u_16x8 = _mm_maddubs_epi16(row0B_u_8x16, _mm_set1_epi8(1));
2633 const __m128i horizontalSum1B_u_16x8 = _mm_maddubs_epi16(row1B_u_8x16, _mm_set1_epi8(1));
2635 const __m128i sumB_u_16x8 = _mm_add_epi16(horizontalSum0B_u_16x8, horizontalSum1B_u_16x8);
2637 const __m128i maskB_u_16x8 = _mm_cmpgt_epi16(sumB_u_16x8, _mm_set1_epi16(
short(threshold - 1u)));
2642 _mm_storeu_si128((__m128i*)result, mask_u_8x16);
2647 ocean_assert(image0 && image1);
2650 const __m128i row0 = _mm_loadl_epi64((__m128i*)image0);
2651 const __m128i row1 = _mm_loadl_epi64((__m128i*)image1);
2658 const __m128i sumLow = _mm_add_epi16(shuffledRow0, shuffledRow1);
2659 const __m128i sum = _mm_add_epi16(_mm_hadd_epi16(sumLow, sumLow), _mm_set1_epi32(
int(0x00020002)));
2662 const __m128i division16 = _mm_srli_epi16(sum, 2);
2667 memcpy(result, &division8,
sizeof(uint8_t) * 4);
2672 ocean_assert(image0 && image1);
2675 const __m128 row0 = _mm_loadu_ps(image0);
2676 const __m128 row1 = _mm_loadu_ps(image1);
2679 const __m128 sumFirst = _mm_add_ps(row0, row1);
2682 const __m128 rowSecond0 = _mm_loadu_ps(image0 + 4);
2683 const __m128 rowSecond1 = _mm_loadu_ps(image1 + 4);
2686 const __m128 sumSecond = _mm_add_ps(rowSecond0, rowSecond1);
2691 const __m128 sumComponents = _mm_add_ps(_mm_shuffle_ps(sumFirst, sumSecond, 68u), _mm_shuffle_ps(sumFirst, sumSecond, 238u));
2694 const __m128 division = _mm_mul_ps(sumComponents, _mm_set_ps1(0.25f));
2697 _mm_storeu_ps(result, division);
2702 ocean_assert(image0 && image1);
2705 const __m128i row0 = _mm_lddqu_si128((__m128i*)image0);
2706 const __m128i row1 = _mm_lddqu_si128((__m128i*)image1);
2713 const __m128i sum = _mm_add_epi16(_mm_hadd_epi16(sumLow, sumHigh), _mm_set1_epi32(
int(0x00020002)));
2716 const __m128i division16 = _mm_srli_epi16(sum, 2);
2722 _mm_storel_epi64((__m128i*)result, division8);
2727 ocean_assert(image0 && image1);
2730 const __m128i row0 = _mm_lddqu_si128((__m128i*)image0);
2731 const __m128i row1 = _mm_lddqu_si128((__m128i*)image1);
2738 const __m128i sum = _mm_add_epi16(_mm_hadd_epi16(sumLow, sumHigh), _mm_set1_epi32(
int(0x00020002)));
2741 const __m128i division16 = _mm_srli_epi16(sum, 2);
2747 const __m128i secondRow0 = _mm_lddqu_si128((__m128i*)(image0 + 16));
2748 const __m128i secondRow1 = _mm_lddqu_si128((__m128i*)(image1 + 16));
2755 const __m128i secondSum = _mm_add_epi16(_mm_hadd_epi16(secondSumLow, secondSumHigh), _mm_set1_epi32(
int(0x00020002)));
2758 const __m128i secondDivision16 = _mm_srli_epi16(secondSum, 2);
2765 const __m128i division8 = _mm_or_si128(firstDivision8, secondDivision8);
2768 _mm_storeu_si128((__m128i*)result, division8);
2773 ocean_assert(image0 && image1 && result);
2778 const __m128 row0 = _mm_loadu_ps(image0);
2779 const __m128 row1 = _mm_loadu_ps(image1);
2782 const __m128 sumFirst = _mm_add_ps(row0, row1);
2785 const __m128 rowSecond0 = _mm_loadu_ps(image0 + 2);
2786 const __m128 rowSecond1 = _mm_loadu_ps(image1 + 2);
2789 const __m128 sumSecond = _mm_add_ps(rowSecond0, rowSecond1);
2794 const __m128 sumComponents = _mm_add_ps(sumFirst, _mm_shuffle_ps(sumSecond, sumSecond, 57u));
2797 const __m128 division = _mm_mul_ps(sumComponents, _mm_set_ps1(0.25f));
2801 #ifdef OCEAN_COMPILER_MSC
2802 memcpy(result, &division.m128_f32[0],
sizeof(
float) * 3);
2804 memcpy(result, &division,
sizeof(
float) * 3);
2810 ocean_assert(image0 && image1 && result);
2812 __m128i row0 = _mm_lddqu_si128((__m128i*)image0);
2813 __m128i row1 = _mm_lddqu_si128((__m128i*)image1);
2821 __m128i shuffleMaskLow =
set128i(0xA0A0A0A0A008A007ull, 0xA006A002A001A000ull);
2822 __m128i shuffleMaskHigh =
set128i(0xA0A0A0A0A00BA00Aull, 0xA009A005A004A003ull);
2824 __m128i sumLow = _mm_add_epi16(_mm_shuffle_epi8(row0, shuffleMaskLow), _mm_shuffle_epi8(row1, shuffleMaskLow));
2825 __m128i sumHigh = _mm_add_epi16(_mm_shuffle_epi8(row0, shuffleMaskHigh), _mm_shuffle_epi8(row1, shuffleMaskHigh));
2828 __m128i sum = _mm_add_epi16(_mm_add_epi16(sumLow, sumHigh), _mm_set1_epi32(
int(0x00020002)));
2831 __m128i division16 = _mm_srli_epi16(sum, 2);
2834 __m128i division8 = _mm_shuffle_epi8(division16,
set128i(0xA0A0A0A0A0A0A0A0ull, 0xA0A00A0806040200ull));
2843 row0 = _mm_lddqu_si128((__m128i*)(image0 + 8));
2844 row1 = _mm_lddqu_si128((__m128i*)(image1 + 8));
2846 shuffleMaskLow =
set128i(0xA0A0A0A0A00CA00Bull, 0xA00AA006A005A004ull);
2847 shuffleMaskHigh =
set128i(0xA0A0A0A0A00FA00Eull, 0xA00DA009A008A007ull);
2849 sumLow = _mm_add_epi16(_mm_shuffle_epi8(row0, shuffleMaskLow), _mm_shuffle_epi8(row1, shuffleMaskLow));
2850 sumHigh = _mm_add_epi16(_mm_shuffle_epi8(row0, shuffleMaskHigh), _mm_shuffle_epi8(row1, shuffleMaskHigh));
2853 sum = _mm_add_epi16(_mm_add_epi16(sumLow, sumHigh), _mm_set1_epi32(
int(0x00020002)));
2856 division16 = _mm_srli_epi16(sum, 2);
2859 division8 = _mm_or_si128(division8, _mm_shuffle_epi8(division16,
set128i(0xA0A0A0A00A080604ull, 0x0200A0A0A0A0A0A0ull)));
2861 #ifdef OCEAN_COMPILER_MSC
2862 memcpy(result, &division8.m128i_u8[0], 12);
2864 memcpy(result, &division8, 12);
2870 ocean_assert(image0 && image1);
2873 const __m128 row0 = _mm_loadu_ps(image0);
2874 const __m128 row1 = _mm_loadu_ps(image1);
2877 const __m128 sumFirstPixel = _mm_add_ps(row0, row1);
2880 const __m128 rowSecond0 = _mm_loadu_ps(image0 + 4);
2881 const __m128 rowSecond1 = _mm_loadu_ps(image1 + 4);
2884 const __m128 sumSecondPixel = _mm_add_ps(rowSecond0, rowSecond1);
2887 const __m128 sumComponents = _mm_add_ps(sumFirstPixel, sumSecondPixel);
2890 const __m128 division = _mm_mul_ps(sumComponents, _mm_set_ps1(0.25f));
2893 _mm_storeu_ps(result, division);
2898 ocean_assert(image0 && image1);
2900 const __m128i row0 = _mm_lddqu_si128((__m128i*)image0);
2901 const __m128i row1 = _mm_lddqu_si128((__m128i*)image1);
2908 const __m128i sum = _mm_add_epi16(_mm_hadd_epi16(sumLow, sumHigh), _mm_set1_epi32(
int(0x00020002)));
2911 const __m128i division16 = _mm_srli_epi16(sum, 2);
2917 _mm_storel_epi64((__m128i*)result, division8);
2922 ocean_assert(image0 && image1);
2925 const __m128i firstRow0 = _mm_lddqu_si128((__m128i*)image0);
2926 const __m128i firstRow1 = _mm_lddqu_si128((__m128i*)image1);
2933 const __m128i firstSum = _mm_add_epi16(_mm_hadd_epi16(firstSumLow, firstSumHigh), _mm_set1_epi32(
int(0x00020002)));
2936 const __m128i firstDivision16 = _mm_srli_epi16(firstSum, 2);
2943 const __m128i secondRow0 = _mm_lddqu_si128((__m128i*)(image0 + 16));
2944 const __m128i secondRow1 = _mm_lddqu_si128((__m128i*)(image1 + 16));
2951 const __m128i secondSum = _mm_add_epi16(_mm_hadd_epi16(secondSumLow, secondSumHigh), _mm_set1_epi32(
int(0x00020002)));
2954 const __m128i secondDivision16 = _mm_srli_epi16(secondSum, 2);
2961 const __m128i division8 = _mm_or_si128(firstDivision8, secondDivision8);
2964 _mm_storeu_si128((__m128i*)result, division8);
2969 ocean_assert(image0 && image1 && image2);
2978 const __m128i firstRow0 = _mm_lddqu_si128((__m128i*)image0);
2979 const __m128i firstRow1 = _mm_lddqu_si128((__m128i*)image1);
2980 const __m128i firstRow2 = _mm_lddqu_si128((__m128i*)image2);
2987 const __m128i secondRow0 = _mm_lddqu_si128((__m128i*)(image0 + 14));
2988 const __m128i secondRow1 = _mm_lddqu_si128((__m128i*)(image1 + 14));
2989 const __m128i secondRow2 = _mm_lddqu_si128((__m128i*)(image2 + 14));
2997 const __m128i firstSum = _mm_add_epi16(firstSumEven, _mm_add_epi16(firstSumOdd, _mm_set1_epi32(
int(0x00080008))));
2999 const __m128i firstSumWithEven = _mm_add_epi16(firstSum, _mm_shuffle_epi8(firstSumEven,
set128i(0xFFFF0F0E0B0AFFFFull, 0x09080504FFFF0302ull)));
3001 const __m128i firstSumWithBoth = _mm_add_epi16(firstSumWithEven, _mm_shuffle_epi8(firstSumOdd,
set128i(0xFFFF0D0C0908FFFFull, 0x07060302FFFF0100ull)));
3005 const __m128i secondSum = _mm_add_epi16(secondSumEven, _mm_add_epi16(secondSumOdd, _mm_set1_epi32(
int(0x00080008))));
3006 const __m128i secondSumWithEven = _mm_add_epi16(secondSum, _mm_shuffle_epi8(secondSumEven,
set128i(0x0F0EFFFF0D0C0908ull, 0xFFFF07060302FFFFull)));
3007 const __m128i secondSumWithBoth = _mm_add_epi16(secondSumWithEven, _mm_shuffle_epi8(secondSumOdd,
set128i(0x0D0CFFFF0B0A0706ull, 0xFFFF05040100FFFFull)));
3010 const __m128i firstDivision16 = _mm_srli_epi16(firstSumWithBoth, 4);
3011 const __m128i secondDivision16 = _mm_srli_epi16(secondSumWithBoth, 4);
3014 const __m128i firstDivision8 = _mm_shuffle_epi8(firstDivision16,
set128i(0xFFFFFFFFFFFFFFFFull, 0xFFFFFF0C0A060400ull));
3015 const __m128i secondDivision8 = _mm_shuffle_epi8(secondDivision16,
set128i(0xFFFFFFFFFFFF0E0Aull, 0x080402FFFFFFFFFFull));
3018 const __m128i division8 = _mm_or_si128(firstDivision8, secondDivision8);
3021 #ifdef OCEAN_COMPILER_MSC
3022 memcpy(result, &division8.m128i_u8[0], 10);
3024 memcpy(result, &division8, 10);
3037 const __m128i maskOdds = _mm_and_si128(value,
CV::SSE::set128i(0x0001000100010001ull, 0x0001000100010001ull));
3040 const __m128i maskNegatives = _mm_srli_epi16(_mm_and_si128(value,
CV::SSE::set128i(0x8000800080008000ull, 0x8000800080008000ull)), 15);
3044 return _mm_add_epi16(value, _mm_and_si128(maskNegatives, maskOdds));
3049 ocean_assert(rightShifts < 16u);
3052 const __m128i offsetForNegatives_s_16x8 = _mm_set1_epi16(
short((1u << rightShifts) - 1u));
3055 const __m128i maskHigh_s_16x8 =
CV::SSE::set128i(0x8000800080008000ull, 0x8000800080008000ull);
3058 const __m128i maskNegativeValues_s_16x8 = _mm_cmpeq_epi16(_mm_and_si128(value, maskHigh_s_16x8), maskHigh_s_16x8);
3061 const __m128i offset_s_16x8 = _mm_and_si128(offsetForNegatives_s_16x8, maskNegativeValues_s_16x8);
3063 return _mm_add_epi16(value, offset_s_16x8);
3080 const __m128i maskOdds = _mm_and_si128(value,
CV::SSE::set128i(0x0000000100000001ull, 0x0000000100000001ull));
3083 const __m128i maskNegatives = _mm_srli_epi32(_mm_and_si128(value,
CV::SSE::set128i(0x8000000080000000ull, 0x8000000080000000ull)), 31);
3086 return _mm_add_epi32(value, _mm_and_si128(maskNegatives, maskOdds));
3091 ocean_assert(rightShifts < 32u);
3094 const __m128i offsetForNegatives_s_32x4 = _mm_set1_epi32(
int((1u << rightShifts) - 1u));
3097 const __m128i maskHigh_s_32x4 =
CV::SSE::set128i(0x8000000080000000ull, 0x8000000080000000ull);
3100 const __m128i maskNegativeValues_s_32x4 = _mm_cmpeq_epi32(_mm_and_si128(value, maskHigh_s_32x4), maskHigh_s_32x4);
3103 const __m128i offset_s_32x4 = _mm_and_si128(offsetForNegatives_s_32x4, maskNegativeValues_s_32x4);
3105 return _mm_add_epi32(value, offset_s_32x4);
3115 ocean_assert(source && response && width >= 10u);
3118 const __m128i horizontalMinus = _mm_lddqu_si128((__m128i*)(source - 1));
3119 const __m128i horizontalPlus = _mm_lddqu_si128((__m128i*)(source + 1));
3121 const __m128i verticalMinus = _mm_lddqu_si128((__m128i*)(source - width));
3122 const __m128i verticalPlus = _mm_lddqu_si128((__m128i*)(source + width));
3125 const __m128i horizontalMinusLo = _mm_cvtepu8_epi16(horizontalMinus);
3127 const __m128i horizontalMinusHi = _mm_shuffle_epi8(horizontalMinus,
set128i(0x800F800E800D800Cull, 0x800B800A80098008ull));
3129 const __m128i horizontalPlusLo = _mm_cvtepu8_epi16(horizontalPlus);
3131 const __m128i horizontalPlusHi = _mm_shuffle_epi8(horizontalPlus,
set128i(0x800F800E800D800Cull, 0x800B800A80098008ull));
3138 const __m128i horizontalGradient = _mm_or_si128(
3139 _mm_shuffle_epi8(horizontalGradientLo,
set128i(0x8080808080808080ull, 0x0E0C0A0806040200ull)),
3140 _mm_shuffle_epi8(horizontalGradientHi,
set128i(0x0E0C0A0806040200ull, 0x8080808080808080ull)));
3143 const __m128i verticalMinusLo = _mm_cvtepu8_epi16(verticalMinus);
3145 const __m128i verticalMinusHi = _mm_shuffle_epi8(verticalMinus,
set128i(0x800F800E800D800Cull, 0x800B800A80098008ull));
3147 const __m128i verticalPlusLo = _mm_cvtepu8_epi16(verticalPlus);
3149 const __m128i verticalPlusHi = _mm_shuffle_epi8(verticalPlus,
set128i(0x800F800E800D800Cull, 0x800B800A80098008ull));
3156 const __m128i verticalGradient = _mm_or_si128(
3157 _mm_shuffle_epi8(verticalGradientLo,
set128i(0x8080808080808080ull, 0x0E0C0A0806040200ull)),
3158 _mm_shuffle_epi8(verticalGradientHi,
set128i(0x0E0C0A0806040200ull, 0x8080808080808080ull)));
3161 const __m128i interleavedResponseLo = _mm_unpacklo_epi8(horizontalGradient, verticalGradient);
3162 const __m128i interleavedResponseHi = _mm_unpackhi_epi8(horizontalGradient, verticalGradient);
3164 ocean_assert(
sizeof(
char) == 1ull);
3165 _mm_storeu_si128((__m128i*)response, interleavedResponseLo);
3166 _mm_storeu_si128((__m128i*)(response + 16ull), interleavedResponseHi);
3171 ocean_assert(source && response && width >= 10u);
3174 const __m128i horizontalMinus = _mm_lddqu_si128((__m128i*)(source - 1));
3175 const __m128i horizontalPlus = _mm_lddqu_si128((__m128i*)(source + 1));
3177 const __m128i verticalMinus = _mm_lddqu_si128((__m128i*)(source - width));
3178 const __m128i verticalPlus = _mm_lddqu_si128((__m128i*)(source + width));
3181 const __m128i horizontalMinusLo = _mm_cvtepu8_epi16(horizontalMinus);
3182 const __m128i horizontalMinusHi = _mm_shuffle_epi8(horizontalMinus,
set128i(0x800F800E800D800Cull, 0x800B800A80098008ull));
3184 const __m128i horizontalPlusLo = _mm_cvtepu8_epi16(horizontalPlus);
3185 const __m128i horizontalPlusHi = _mm_shuffle_epi8(horizontalPlus,
set128i(0x800F800E800D800Cull, 0x800B800A80098008ull));
3192 const __m128i verticalMinusLo = _mm_cvtepu8_epi16(verticalMinus);
3193 const __m128i verticalMinusHi = _mm_shuffle_epi8(verticalMinus,
set128i(0x800F800E800D800Cull, 0x800B800A80098008ull));
3195 const __m128i verticalPlusLo = _mm_cvtepu8_epi16(verticalPlus);
3196 const __m128i verticalPlusHi = _mm_shuffle_epi8(verticalPlus,
set128i(0x800F800E800D800Cull, 0x800B800A80098008ull));
3203 const __m128i horizontalHorizontalLo = _mm_mullo_epi16(horizontalGradientLo, horizontalGradientLo);
3204 const __m128i horizontalHorizontalHi = _mm_mullo_epi16(horizontalGradientHi, horizontalGradientHi);
3206 const __m128i verticalVerticalLo = _mm_mullo_epi16(verticalGradientLo, verticalGradientLo);
3207 const __m128i verticalVerticalHi = _mm_mullo_epi16(verticalGradientHi, verticalGradientHi);
3209 const __m128i horzontalVerticalLo = _mm_mullo_epi16(horizontalGradientLo, verticalGradientLo);
3210 const __m128i horzontalVerticalHi = _mm_mullo_epi16(horizontalGradientHi, verticalGradientHi);
3233 const __m128i block0Lo = _mm_or_si128(
3235 _mm_shuffle_epi8(horizontalHorizontalLo,
set128i(0xFFFF0504FFFFFFFFull, 0x0302FFFFFFFF0100ull)),
3236 _mm_shuffle_epi8(verticalVerticalLo,
set128i(0x0504FFFFFFFF0302ull, 0xFFFFFFFF0100FFFFull))),
3237 _mm_shuffle_epi8(horzontalVerticalLo,
set128i(0xFFFFFFFF0302FFFFull, 0xFFFF0100FFFFFFFFull)));
3239 const __m128i block1Lo = _mm_or_si128(
3241 _mm_shuffle_epi8(horizontalHorizontalLo,
set128i(0x0B0AFFFFFFFF0908ull, 0xFFFFFFFF0706FFFFull)),
3242 _mm_shuffle_epi8(verticalVerticalLo,
set128i(0xFFFFFFFF0908FFFFull, 0xFFFF0706FFFFFFFFull))),
3243 _mm_shuffle_epi8(horzontalVerticalLo,
set128i(0xFFFF0908FFFFFFFFull, 0x0706FFFFFFFF0504ull)));
3245 const __m128i block2Lo = _mm_or_si128(
3247 _mm_shuffle_epi8(horizontalHorizontalLo,
set128i(0xFFFFFFFF0F0EFFFFull, 0xFFFF0D0CFFFFFFFFull)),
3248 _mm_shuffle_epi8(verticalVerticalLo,
set128i(0xFFFF0F0EFFFFFFFFull, 0x0D0CFFFFFFFF0B0Aull))),
3249 _mm_shuffle_epi8(horzontalVerticalLo,
set128i(0x0F0EFFFFFFFF0D0Cull, 0xFFFFFFFF0B0AFFFFull)));
3251 const __m128i block0Hi = _mm_or_si128(
3253 _mm_shuffle_epi8(horizontalHorizontalHi,
set128i(0xFFFF0504FFFFFFFFull, 0x0302FFFFFFFF0100ull)),
3254 _mm_shuffle_epi8(verticalVerticalHi,
set128i(0x0504FFFFFFFF0302ull, 0xFFFFFFFF0100FFFFull))),
3255 _mm_shuffle_epi8(horzontalVerticalHi,
set128i(0xFFFFFFFF0302FFFFull, 0xFFFF0100FFFFFFFFull)));
3257 const __m128i block1Hi = _mm_or_si128(
3259 _mm_shuffle_epi8(horizontalHorizontalHi,
set128i(0x0B0AFFFFFFFF0908ull, 0xFFFFFFFF0706FFFFull)),
3260 _mm_shuffle_epi8(verticalVerticalHi,
set128i(0xFFFFFFFF0908FFFFull, 0xFFFF0706FFFFFFFFull))),
3261 _mm_shuffle_epi8(horzontalVerticalHi,
set128i(0xFFFF0908FFFFFFFFull, 0x0706FFFFFFFF0504ull)));
3263 const __m128i block2Hi = _mm_or_si128(
3265 _mm_shuffle_epi8(horizontalHorizontalHi,
set128i(0xFFFFFFFF0F0EFFFFull, 0xFFFF0D0CFFFFFFFFull)),
3266 _mm_shuffle_epi8(verticalVerticalHi,
set128i(0xFFFF0F0EFFFFFFFFull, 0x0D0CFFFFFFFF0B0Aull))),
3267 _mm_shuffle_epi8(horzontalVerticalHi,
set128i(0x0F0EFFFFFFFF0D0Cull, 0xFFFFFFFF0B0AFFFFull)));
3269 _mm_storeu_si128((__m128i*)response, block0Lo);
3270 _mm_storeu_si128((__m128i*)(response + 8ull), block1Lo);
3271 _mm_storeu_si128((__m128i*)(response + 16ull), block2Lo);
3272 _mm_storeu_si128((__m128i*)(response + 24ull), block0Hi);
3273 _mm_storeu_si128((__m128i*)(response + 32ull), block1Hi);
3274 _mm_storeu_si128((__m128i*)(response + 40ull), block2Hi);
3284 channel01 = _mm_shuffle_epi8(interleaved,
set128i(0xFFFFFF0d0a070401ull, 0xFFFFFF0c09060300ull));
3286 channel2 = _mm_shuffle_epi8(interleaved,
set128i(0xFFFFFFFFFFFFFFFFull, 0xFFFFFF0e0b080502ull));
3297 channel01 = _mm_or_si128(_mm_shuffle_epi8(interleavedA,
set128i(0xFFFFFF0d0a070401ull, 0xFFFF0f0c09060300ull)),
3298 _mm_shuffle_epi8(interleavedB,
set128i(0x060300FFFFFFFFFFull, 0x0502FFFFFFFFFFFFull)));
3300 channel2 = _mm_or_si128(_mm_shuffle_epi8(interleavedA,
set128i(0xFFFFFFFFFFFFFFFFull, 0xFFFFFF0e0b080502ull)),
3301 _mm_shuffle_epi8(interleavedB,
set128i(0xFFFFFFFFFFFFFFFFull, 0x070401FFFFFFFFFFull)));
3306 channel0 = _mm_or_si128(_mm_shuffle_epi8(interleavedA,
set128i(0xFFFFFFFFFFFFFFFFull, 0xFFFF0f0c09060300ull)),
3307 _mm_or_si128(_mm_shuffle_epi8(interleavedB,
set128i(0xFFFFFFFFFF0e0b08ull, 0x0502FFFFFFFFFFFFull)),
3308 _mm_shuffle_epi8(interleavedC,
set128i(0x0d0a070401FFFFFFull, 0xFFFFFFFFFFFFFFFFull))));
3310 channel1 = _mm_or_si128(_mm_shuffle_epi8(interleavedA,
set128i(0xFFFFFFFFFFFFFFFFull, 0xFFFFFF0d0a070401ull)),
3311 _mm_or_si128(_mm_shuffle_epi8(interleavedB,
set128i(0xFFFFFFFFFF0f0c09ull, 0x060300FFFFFFFFFFull)),
3312 _mm_shuffle_epi8(interleavedC,
set128i(0x0e0b080502FFFFFFull, 0xFFFFFFFFFFFFFFFFull))));
3314 channel2 = _mm_or_si128(_mm_shuffle_epi8(interleavedA,
set128i(0xFFFFFFFFFFFFFFFFull, 0xFFFFFF0e0b080502ull)),
3315 _mm_or_si128(_mm_shuffle_epi8(interleavedB,
set128i(0xFFFFFFFFFFFF0d0aull, 0x070401FFFFFFFFFFull)),
3316 _mm_shuffle_epi8(interleavedC,
set128i(0x0f0c09060300FFFFull, 0xFFFFFFFFFFFFFFFFull))));
3321 ocean_assert(interleaved !=
nullptr);
3328 ocean_assert(interleaved && channel0 && channel1 && channel2);
3330 __m128i channel0_128, channel1_128, channel2_128;
3340 ocean_assert(interleaved !=
nullptr);
3345 OCEAN_FORCE_INLINE
void SSE::interleave3Channel8Bit48Elements(
const __m128i& channel0,
const __m128i& channel1,
const __m128i& channel2, __m128i& interleavedA, __m128i& interleavedB, __m128i& interleavedC)
3347 interleavedA = _mm_or_si128(_mm_shuffle_epi8(channel0,
set128i(0x05FFFF04FFFF03FFull, 0xFF02FFFF01FFFF00ull)),
3348 _mm_or_si128(_mm_shuffle_epi8(channel1,
set128i(0xFFFF04FFFF03FFFFull, 0x02FFFF01FFFF00FFull)),
3349 _mm_shuffle_epi8(channel2,
set128i(0xFF04FFFF03FFFF02ull, 0xFFFF01FFFF00FFFFull))));
3351 interleavedB = _mm_or_si128(_mm_shuffle_epi8(channel0,
set128i(0xFF0AFFFF09FFFF08ull, 0xFFFF07FFFF06FFFFull)),
3352 _mm_or_si128(_mm_shuffle_epi8(channel1,
set128i(0x0AFFFF09FFFF08FFull, 0xFF07FFFF06FFFF05ull)),
3353 _mm_shuffle_epi8(channel2,
set128i(0xFFFF09FFFF08FFFFull, 0x07FFFF06FFFF05FFull))));
3355 interleavedC = _mm_or_si128(_mm_shuffle_epi8(channel0,
set128i(0xFFFF0FFFFF0EFFFFull, 0x0DFFFF0CFFFF0BFFull)),
3356 _mm_or_si128(_mm_shuffle_epi8(channel1,
set128i(0xFF0FFFFF0EFFFF0Dull, 0xFFFF0CFFFF0BFFFFull)),
3357 _mm_shuffle_epi8(channel2,
set128i(0x0FFFFF0EFFFF0DFFull, 0xFF0CFFFF0BFFFF0Aull))));
3362 ocean_assert(channel0 && channel1 && channel2 && interleaved);
3364 __m128i interleavedA_128, interleavedB_128, interleavedC_128;
3367 store128i(interleavedA_128, interleaved + 0);
3368 store128i(interleavedB_128, interleaved + 16);
3369 store128i(interleavedC_128, interleaved + 32);
3374 ocean_assert(interleaved !=
nullptr && reversedInterleaved !=
nullptr);
3381 const __m128i shuffleMask_u_16x8 =
set128i(0x0E0F0C0D0A0B0809ull, 0x0607040502030001ull);
3383 store128i(_mm_shuffle_epi8(
load128i(interleaved + 0), shuffleMask_u_16x8), reversedInterleaved + 0);
3384 store128i(_mm_shuffle_epi8(
load128i(interleaved + 16), shuffleMask_u_16x8), reversedInterleaved + 16);
3387 OCEAN_FORCE_INLINE
void SSE::reverseChannelOrder3Channel8Bit48Elements(
const __m128i& interleaved0,
const __m128i& interleaved1,
const __m128i& interleaved2, __m128i& reversedInterleaved0, __m128i& reversedInterleaved1, __m128i& reversedInterleaved2)
3389 reversedInterleaved0 = _mm_or_si128(_mm_shuffle_epi8(interleaved0,
set128i(0xFF0c0d0e090a0b06ull, 0x0708030405000102ull)),
3390 _mm_shuffle_epi8(interleaved1,
set128i(0x01FFFFFFFFFFFFFFull, 0xFFFFFFFFFFFFFFFFull)));
3392 reversedInterleaved1 = _mm_or_si128(_mm_shuffle_epi8(interleaved0,
set128i(0xFFFFFFFFFFFFFFFFull, 0xFFFFFFFFFFFF0fFFull)),
3393 _mm_or_si128(_mm_shuffle_epi8(interleaved1,
set128i(0x0fFF0b0c0d08090aull, 0x050607020304FF00ull)),
3394 _mm_shuffle_epi8(interleaved2,
set128i(0xFF00FFFFFFFFFFFFull, 0xFFFFFFFFFFFFFFFFull))));
3396 reversedInterleaved2 = _mm_or_si128(_mm_shuffle_epi8(interleaved1,
set128i(0xFFFFFFFFFFFFFFFFull, 0xFFFFFFFFFFFFFF0eull)),
3397 _mm_shuffle_epi8(interleaved2,
set128i(0x0d0e0f0a0b0c0708ull, 0x09040506010203FFull)));
3402 ocean_assert(interleaved !=
nullptr && reversedInterleaved !=
nullptr);
3404 __m128i reversedInterleaved0, reversedInterleaved1, reversedInterleaved2;
3407 store128i(reversedInterleaved0, reversedInterleaved);
3408 store128i(reversedInterleaved1, reversedInterleaved + 16);
3409 store128i(reversedInterleaved2, reversedInterleaved + 32);
3414 ocean_assert(interleaved !=
nullptr && reversedInterleaved !=
nullptr);
3421 const __m128i shuffleMask_u_16x8 =
set128i(0x0C0D0E0F08090A0Bull, 0x0405060700010203ull);
3423 store128i(_mm_shuffle_epi8(
load128i(interleaved + 0), shuffleMask_u_16x8), reversedInterleaved + 0);
3424 store128i(_mm_shuffle_epi8(
load128i(interleaved + 16), shuffleMask_u_16x8), reversedInterleaved + 16);
3425 store128i(_mm_shuffle_epi8(
load128i(interleaved + 32), shuffleMask_u_16x8), reversedInterleaved + 32);
3426 store128i(_mm_shuffle_epi8(
load128i(interleaved + 48), shuffleMask_u_16x8), reversedInterleaved + 48);
3431 ocean_assert(interleaved);
3433 __m128i reversedInterleaved0, reversedInterleaved1, reversedInterleaved2;
3436 store128i(reversedInterleaved0, interleaved);
3437 store128i(reversedInterleaved1, interleaved + 16);
3438 store128i(reversedInterleaved2, interleaved + 32);
3443 ocean_assert(first && second && first != second);
3445 __m128i first0, first1, first2;
3448 __m128i second0, second1, second2;
3460 inline void SSE::reverseElements8Bit48Elements(
const __m128i& elements0,
const __m128i& elements1,
const __m128i& elements2, __m128i& reversedElements0, __m128i& reversedElements1, __m128i& reversedElements2)
3462 const __m128i mask =
set128i(0x0001020304050607ull, 0x08090a0b0c0d0e0full);
3464 reversedElements0 = _mm_shuffle_epi8(elements2, mask);
3465 reversedElements1 = _mm_shuffle_epi8(elements1, mask);
3466 reversedElements2 = _mm_shuffle_epi8(elements0, mask);
3471 ocean_assert(elements && reversedElements);
3473 __m128i reversedElements0, reversedElements1, reversedElements2;
3476 store128i(reversedElements0, reversedElements);
3477 store128i(reversedElements1, reversedElements + 16);
3478 store128i(reversedElements2, reversedElements + 32);
3483 ocean_assert(elements);
3485 __m128i reversedElements0, reversedElements1, reversedElements2;
3489 store128i(reversedElements1, elements + 16);
3490 store128i(reversedElements2, elements + 32);
3495 ocean_assert(first && second && first != second);
3497 __m128i first0, first1, first2;
3500 __m128i second0, second1, second2;
3514 ocean_assert(elements && shiftedElements);
3516 store128i(_mm_shuffle_epi8(
load128i(elements),
set128i(0x0c0f0e0d080b0a09ull, 0x0407060500030201ull)), shiftedElements);
3521 ocean_assert(elements && shiftedElements);
3523 store128i(_mm_shuffle_epi8(
load128i(elements),
set128i(0x0003020104070605ull, 0x080b0a090c0f0e0dull)), shiftedElements);
3528 ocean_assert(elements && shiftedElements);
3530 store128i(_mm_shuffle_epi8(
load128i(elements),
set128i(0x0e0d0c0f0a09080bull, 0x0605040702010003ull)), shiftedElements);
3535 ocean_assert(elements && shiftedElements);
3537 store128i(_mm_shuffle_epi8(
load128i(elements),
set128i(0x0201000306050407ull, 0x0a09080b0e0d0c0full)), shiftedElements);
3542 const __m128i zero = _mm_setzero_si128();
3543 const __m128i sum = _mm_sad_epu8(elements, zero);
3545 return _mm_add_epi32(_mm_srli_si128(sum, 8), sum);
3550 ocean_assert(elements !=
nullptr);
3555 template <
bool tBufferHas16Bytes>
3558 ocean_assert(elements !=
nullptr);
3564 ocean_assert(elements !=
nullptr);
3575 const __m128i channel0_2First = _mm_or_si128(_mm_shuffle_epi8(interleaved0,
set128i(0xFFFFFF0e0b080502ull, 0xFFFF0f0c09060300ull)),
3576 _mm_shuffle_epi8(interleaved1,
set128i(0x070401FFFFFFFFFFull, 0x0502FFFFFFFFFFFFull)));
3579 const __m128i channel0_2Second = _mm_or_si128(_mm_shuffle_epi8(interleaved1,
set128i(0xFFFFFFFFFFFF0d0aull, 0xFFFFFFFFFF0e0b08ull)),
3580 _mm_shuffle_epi8(interleaved2,
set128i(0x0f0c09060300FFFFull, 0x0d0a070401FFFFFFull)));
3583 const __m128i channel1 = _mm_or_si128(_mm_shuffle_epi8(interleaved0,
set128i(0xFFFFFFFFFFFFFFFFull, 0xFFFFFF0d0a070401ull)),
3584 _mm_or_si128(_mm_shuffle_epi8(interleaved1,
set128i(0xFFFFFFFFFF0f0c09ull, 0x060300FFFFFFFFFFull)),
3585 _mm_shuffle_epi8(interleaved2,
set128i(0x0e0b080502FFFFFFull, 0xFFFFFFFFFFFFFFFFull))));
3587 const __m128i zero = _mm_setzero_si128();
3590 const __m128i sum0_2 = _mm_add_epi32(_mm_sad_epu8(channel0_2First, zero), _mm_sad_epu8(channel0_2Second, zero));
3593 const __m128i sum1 = _mm_sad_epu8(channel1, zero);
3596 return _mm_blend_epi16(sum0_2, _mm_add_epi32(_mm_slli_si128(sum1, 4), _mm_srli_si128(sum1, 4)),
int(0xC));
3601 ocean_assert(interleaved !=
nullptr);
3608 ocean_assert(interleaved !=
nullptr);
3615 ocean_assert(buffer !=
nullptr);
3616 return _mm_loadl_epi64((
const __m128i*)(buffer));
3621 ocean_assert(buffer !=
nullptr);
3622 return _mm_lddqu_si128((
const __m128i*)(buffer));
3625 template <
bool tBufferHas16Bytes>
3628 ocean_assert(buffer !=
nullptr);
3632 #ifdef OCEAN_COMPILER_MSC
3634 result.m128i_u64[0] = uint64_t(0);
3635 memcpy(result.m128i_u16 + 3, buffer + 0,
sizeof(uint16_t));
3636 memcpy(result.m128i_u64 + 1, buffer + 2,
sizeof(uint64_t));
3643 memcpy(ourResult.
m128i_u16 + 3, buffer + 0,
sizeof(uint16_t));
3644 memcpy(ourResult.
m128i_u64 + 1, buffer + 2,
sizeof(uint64_t));
3652 inline __m128i SSE::load_u8_10_upper_zero<true>(
const uint8_t*
const buffer)
3654 ocean_assert(buffer !=
nullptr);
3660 template <
bool tBufferHas16Bytes>
3663 ocean_assert(buffer !=
nullptr);
3665 __m128i intermediate;
3666 memcpy(&intermediate, buffer, 15);
3669 return _mm_slli_si128(intermediate, 1);
3673 inline __m128i SSE::load_u8_15_upper_zero<true>(
const uint8_t*
const buffer)
3675 ocean_assert(buffer !=
nullptr);
3678 return _mm_slli_si128(_mm_lddqu_si128((__m128i*)(buffer)), 1);
3681 template <
bool tBufferHas16Bytes>
3684 ocean_assert(buffer !=
nullptr);
3687 memcpy(&result, buffer, 13);
3693 inline __m128i SSE::load_u8_13_lower_random<true>(
const uint8_t*
const buffer)
3695 ocean_assert(buffer !=
nullptr);
3698 return _mm_lddqu_si128((__m128i*)(buffer));
3701 template <
bool tBufferHas16Bytes>
3704 ocean_assert(buffer !=
nullptr);
3707 memcpy(&result, buffer, 15);
3709 #ifdef OCEAN_COMPILER_MSC
3710 result.m128i_u8[15] = 0u;
3712 ((
M128i&)result).m128i_u8[15] = 0u;
3719 inline __m128i SSE::load_u8_15_lower_zero<true>(
const uint8_t*
const buffer)
3721 ocean_assert(buffer !=
nullptr);
3724 __m128i result = _mm_lddqu_si128((__m128i*)(buffer));
3726 #ifdef OCEAN_COMPILER_MSC
3727 result.m128i_u8[15] = 0u;
3729 ((
M128i&)result).m128i_u8[15] = 0u;
3735 template <
bool tBufferHas16Bytes>
3738 ocean_assert(buffer !=
nullptr);
3741 memcpy(&result, buffer, 15);
3747 inline __m128i SSE::load_u8_15_lower_random<true>(
const uint8_t*
const buffer)
3749 ocean_assert(buffer !=
nullptr);
3752 return _mm_lddqu_si128((__m128i*)(buffer));
3755 template <
unsigned int tShiftBytes>
3758 static_assert(tShiftBytes <= 16u,
"Invalid shift!");
3760 ocean_assert(buffer !=
nullptr);
3761 return _mm_srli_si128(_mm_lddqu_si128((__m128i*)(buffer)), tShiftBytes);
3766 ocean_assert(buffer !=
nullptr);
3767 _mm_storeu_si128((__m128i*)(buffer), value);
3770 inline __m128i
SSE::set128i(
const unsigned long long high64,
const unsigned long long low64)
3776 return _mm_set_epi64x(high64, low64);
3778 return _mm_set_epi32(*(((
int*)&high64) + 1), *((
int*)&high64), *(((
int*)&low64) + 1), *((
int*)&low64));
3783 return _mm_set_epi64x(high64, low64);
3791 return _mm_and_si128(value, _mm_set1_epi32(
int(0x0000FFFFu)));
3796 return _mm_and_si128(value, _mm_set1_epi32(
int(0xFFFF0000u)));
3801 return _mm_and_si128(value, _mm_set1_epi32(
int(0x00FF00FFu)));
3806 return _mm_and_si128(value,
set128i(0x000000FF00FF00FFull, 0x00FF00FF00FF00FFull));
3811 return _mm_and_si128(value,
set128i(0x00FF00FF00FF00FFull, 0x00FF00FF00FF0000ull));
3816 return _mm_shuffle_epi8(value,
set128i(0xA0A0A0A0A0A0A0A0ull, 0x0E0C0A0806040200ull));
3821 return _mm_shuffle_epi8(value,
set128i(0xA0A0A0A0A0A0A0A0ull, 0xA0A0A0A00C080400ull));
3826 return _mm_shuffle_epi8(value,
set128i(0xA0A0A0A0A0A0A0A0ull, 0x0D0C090805040100ull));
3831 return _mm_shuffle_epi8(value,
set128i(0x0E0C0A0806040200ull, 0xA0A0A0A0A0A0A0A0ull));
3837 return _mm_srli_epi32(value, 16);
3842 return _mm_shuffle_epi8(value,
set128i(0xA00FA00DA00BA009ull, 0xA007A005A003A001ull));
3847 return _mm_shuffle_epi8(value,
set128i(0xA0A0A0A0A0A0A009ull, 0xA007A005A003A001ull));
3852 return _mm_shuffle_epi8(value,
set128i(0xFFFFFFFFFF0bFF09ull, 0xFF07FF05FF03FF01ull));
3857 return _mm_shuffle_epi8(value,
set128i(0xA0A0A00DA00BA009ull, 0xA007A005A003A001ull));
3862 return _mm_shuffle_epi8(value,
set128i(0xA0A0A003A0A0A002ull, 0xA0A0A001A0A0A000ull));
3872 return _mm_shuffle_epi8(value,
set128i(0xA007A003A006A002ull, 0xA005A001A004A000ull));
3877 return _mm_shuffle_epi8(value,
set128i(0xA00FA00BA00EA00Aull, 0xA00DA009A00CA008ull));
3882 return _mm_shuffle_epi8(value,
set128i(0xFF07FF05FF06FF04ull, 0xFF03FF01FF02FF00ull));
3887 return _mm_shuffle_epi8(value,
set128i(0xFF0FFF0DFF0EFF0Cull, 0xFF0BFF09FF0AFF08ull));
3892 return _mm_set1_epi32(
int(0x00FF00FFu));
3897 return _mm_set1_epi32(
int(0x0000FFFFu));
3902 const __m128i lowProducts = _mm_mullo_epi16(values0, values1);
3903 const __m128i highProducts = _mm_mulhi_epi16(values0, values1);
3905 products0 = _mm_unpacklo_epi16(lowProducts, highProducts);
3906 products1 = _mm_unpackhi_epi16(lowProducts, highProducts);
3915 results0 = _mm_add_epi32(results0, products0);
3916 results1 = _mm_add_epi32(results1, products1);
3919 inline unsigned int SSE::interpolation2Channel16Bit1x1(
const uint8_t*
const pixel,
const unsigned int size,
const unsigned int fx_y_,
const unsigned int fxy_,
const unsigned int fx_y,
const unsigned int fxy)
3921 ocean_assert(pixel);
3922 ocean_assert(fx_y_ + fxy_ + fx_y + fxy == 128u * 128u);
3924 return (pixel[0] * fx_y_ + pixel[2] * fxy_ + pixel[size] * fx_y + pixel[size + 2u] * fxy + 8192u) / 16384u;
3927 inline unsigned int SSE::ssd2Channel16Bit1x1(
const uint8_t*
const pixel0,
const uint8_t*
const pixel1,
const unsigned int ,
const unsigned int size1,
const unsigned int f1x_y_,
const unsigned int f1xy_,
const unsigned int f1x_y,
const unsigned int f1xy)
3929 ocean_assert(pixel0 && pixel1);
3931 ocean_assert(f1x_y_ + f1xy_ + f1x_y + f1xy == 128u * 128u);
3936 inline unsigned int SSE::ssd2Channel16Bit1x1(
const uint8_t*
const pixel0,
const uint8_t*
const pixel1,
const unsigned int size0,
const unsigned int size1,
const unsigned int f0x_y_,
const unsigned int f0xy_,
const unsigned int f0x_y,
const unsigned int f0xy,
const unsigned int f1x_y_,
const unsigned int f1xy_,
const unsigned int f1x_y,
const unsigned int f1xy)
3938 ocean_assert(pixel0 && pixel1);
3940 ocean_assert(f0x_y_ + f0xy_ + f0x_y + f0xy == 128u * 128u);
3941 ocean_assert(f1x_y_ + f1xy_ + f1x_y + f1xy == 128u * 128u);
3943 return sqrDistance(
interpolation2Channel16Bit1x1(pixel0, size0, f0x_y_, f0xy_, f0x_y, f0xy),
interpolation2Channel16Bit1x1(pixel1, size1, f1x_y_, f1xy_, f1x_y, f1xy));
This class implements computer vision functions using SSE extensions.
Definition: SSE.h:42
static __m128i divideByRightShiftSigned32Bit(const __m128i &value, const unsigned int rightShifts)
Divides eight signed 32 bit values by applying a right shift.
Definition: SSE.h:3108
static void average32Elements2Channel16Bit2x2(const uint8_t *const image0, const uint8_t *const image1, uint8_t *const result)
Averages 32 elements of 2x2 blocks for 2 channel 16 bit frames.
Definition: SSE.h:2725
static void gradientHorizontalVertical8Elements1Channel8Bit(const uint8_t *source, int8_t *response, const unsigned int width)
Determines the horizontal and the vertical gradients for 16 following pixels for a given 1 channel 8 ...
Definition: SSE.h:3113
static unsigned int sum_u32_first_2(const __m128i &value)
Adds the first two individual 32 bit unsigned integer values of a m128i value and returns the result.
Definition: SSE.h:1331
static void average24Elements3Channel24Bit2x2(const uint8_t *const image0, const uint8_t *const image1, uint8_t *const result)
Averages 24 elements of 2x2 blocks for 3 channel 24 bit frames.
Definition: SSE.h:2808
static void prefetchT2(const void *const data)
Prefetches a block of temporal memory in all cache levels, except 0th and 1st cache levels.
Definition: SSE.h:1265
static void reverseElements8Bit48Elements(const __m128i &elements0, const __m128i &elements1, const __m128i &elements2, __m128i &reversedElements0, __m128i &reversedElements1, __m128i &reversedElements2)
Reverses the order of 48 elements with 8 bit per element.
Definition: SSE.h:3460
static __m128i load128i(const void *const buffer)
Loads a 128i value from the memory.
Definition: SSE.h:3619
static void average16Elements2Channel16Bit2x2(const uint8_t *const image0, const uint8_t *const image1, uint8_t *const result)
Averages 16 elements of 2x2 blocks for 2 channel 16 bit frames.
Definition: SSE.h:2700
static __m128i load_u8_16_and_shift_right(const uint8_t *const buffer)
Loads 16 bytes from memory which is at least 16 bytes large and shifts the 128i value by a specified ...
Definition: SSE.h:3756
static __m128i moveLowBits32_16ToLow64(const __m128i &value)
Moves the lower 16 bits of four 32 bit elements to the lower 64 bits and fills the high 64 bits with ...
Definition: SSE.h:3824
static __m128i moveLowBits32_8ToLow32(const __m128i &value)
Moves the lower 8 bits of four 32 bit elements to the lower 32 bits and fills the high 96 bits with 0...
Definition: SSE.h:3819
static __m128i moveHighBits16_8_6(const __m128i &value)
Moves the higher 8 bits of six 16 bit elements to the lower 8 bits and fills the high bits with 0.
Definition: SSE.h:3850
static __m128i addOffsetBeforeRightShiftDivisionByTwoSigned32Bit(const __m128i &value)
Adds 1 to each signed 32 bit value which is both, negative and odd, so that each value can be right s...
Definition: SSE.h:3071
static OCEAN_FORCE_INLINE double sum_f64_2(const __m128d &value)
Adds the two (all two) individual 64 bit float of a m128 value and returns the result.
Definition: SSE.h:1358
static OCEAN_FORCE_INLINE void deInterleave3Channel8Bit15Elements(const __m128i &interleaved, __m128i &channel01, __m128i &channel2)
Deinterleaves 15 elements of e.g., and image with 3 channels and 8 bit per element.
Definition: SSE.h:3277
static void store128i(const __m128i &value, uint8_t *const buffer)
Stores a 128i value to the memory.
Definition: SSE.h:3764
static __m128i sumSquareDifference8BitFront13Elements(const uint8_t *const image0, const uint8_t *const image1)
Sum square difference determination for the first 13 elements of a buffer with 8 bit precision.
Definition: SSE.h:1436
static __m128i sumInterleave3Channel8Bit45Elements(const uint8_t *interleaved)
Sums 15 elements individually for an interleaved pixel format with 3 channels and 8 bit per channel a...
Definition: SSE.h:3606
static __m128i moveLowBits16_8ToHigh64(const __m128i &value)
Moves the lower 8 bits of eight 16 bit elements to the higher 64 bits and fills the low 64 bits with ...
Definition: SSE.h:3829
static __m128i divideByRightShiftSigned16Bit(const __m128i &value, const unsigned int rightShifts)
Divides eight signed 16 bit values by applying a right shift.
Definition: SSE.h:3066
static __m128i shuffleNeighbor4High64BitsToLow16_8(const __m128i &value)
Shuffles pairs of four neighbors of the high 64 bits to the low 8 bits of eight 16 bit elements.
Definition: SSE.h:3875
static void swapReversedElements8Bit48Elements(uint8_t *first, uint8_t *second)
Reverses the order of two sets of 48 elements with 8 bit per element and further swaps both sets.
Definition: SSE.h:3493
static __m128i sumAbsoluteDifferences8BitBack11Elements(const uint8_t *const image0, const uint8_t *const image1)
Sum absolute differences determination for the last 11 elements of a 16 elements buffer with 8 bit pr...
Definition: SSE.h:1374
static void average8ElementsBinary1Channel8Bit2x2(const uint8_t *const image0, const uint8_t *const image1, uint8_t *const result, const uint16_t threshold=776u)
Averages 8 elements of 2x2 blocks for 1 binary (x00 or 0xFF) frames.
Definition: SSE.h:2468
static __m128i interpolation1Channel8Bit8Elements(const __m128i &values0, const __m128i &values1, const __m128i &fx_fy_, const __m128i &fxfy_, const __m128i &fx_fy, const __m128i &fxfy)
Interpolates 8 elements of 2x2 blocks for 1 channel 8 bit frames.
Definition: SSE.h:1583
static OCEAN_FORCE_INLINE void multiplyInt8x16ToInt32x8AndAccumulate(const __m128i &values0, const __m128i &values1, __m128i &results0, __m128i &results1)
Multiplies 8 int16_t values with 8 int16_t values and adds the products to 8 int32_t values.
Definition: SSE.h:3909
static __m128i sumSquareDifference8BitBack13Elements(const uint8_t *const image0, const uint8_t *const image1)
Sum square difference determination for the last 13 elements of an 16 elements buffer with 8 bit prec...
Definition: SSE.h:1463
static unsigned int sum_u32_first_third(const __m128i &value)
Adds the first and the second 32 bit unsigned integer values of a m128i value and returns the result.
Definition: SSE.h:1340
static __m128i sumSquareDifference8BitFront12Elements(const uint8_t *const image0, const uint8_t *const image1)
Sum square difference determination for the first 12 elements of an 16 elements buffer with 8 bit pre...
Definition: SSE.h:1381
static void average16ElementsBinary1Channel8Bit2x2(const uint8_t *const image0, const uint8_t *const image1, uint8_t *const result, const uint16_t threshold=776u)
Averages 16 elements of 2x2 blocks for 1 binary (x00 or 0xFF) frames.
Definition: SSE.h:2525
static __m128i moveHighBits16_8_5(const __m128i &value)
Moves the higher 8 bits of five 16 bit elements to the lower 8 bits and fills the high bits with 0.
Definition: SSE.h:3845
static __m128i shuffleLow32ToLow32_8(const __m128i &value)
Shuffles the lower four 8 bits to the low 8 bits of four 32 bit elements.
Definition: SSE.h:3860
static void shiftChannelToFront4Channel32Bit(const uint8_t *elements, uint8_t *shiftedElements)
Shifts the channels of a 4 channel 32 bit pixels to the front and moves the front channel to the back...
Definition: SSE.h:3512
static __m128i moveHighBits16_8(const __m128i &value)
Moves the higher 8 bits of eight 16 bit elements to the lower 8 bits and fills the high bits with 0.
Definition: SSE.h:3840
static __m128i removeHighBits16_8_7_upper(const __m128i &value)
Removes the higher 8 bits of eight 16 bit elements and sets the lower two bytes to zero.
Definition: SSE.h:3809
static void deInterleave3Channel8Bit45Elements(const uint8_t *interleaved, __m128i &channel0, __m128i &channel1, __m128i &channel2)
Deinterleaves 45 elements of e.g., an image with 3 channels and 8 bit per element.
Definition: SSE.h:3338
static unsigned int value_u32(const __m128i &value)
Returns one specific 32 bit unsigned integer value of a m128i value object.
Definition: SSE.h:1311
static OCEAN_FORCE_INLINE void interleave3Channel8Bit48Elements(const __m128i &channel0, const __m128i &channel1, const __m128i &channel2, __m128i &interleavedA, __m128i &interleavedB, __m128i &interleavedC)
Interleaves 48 elements of e.g., an image with 3 channels and 8 bit per element.
Definition: SSE.h:3345
static __m128i load_u8_15_upper_zero(const uint8_t *const buffer)
Loads 15 bytes from memory, which holds either at least 16 bytes or exactly 15 bytes,...
Definition: SSE.h:3661
static __m128i shuffleNeighbor2Low64BitsToLow16_8(const __m128i &value)
Shuffles pairs of two neighbors of the low 64 bits to the low 8 bits of eight 16 bit elements.
Definition: SSE.h:3880
static void prefetchT1(const void *const data)
Prefetches a block of temporal memory in all cache levels except 0th cache level.
Definition: SSE.h:1260
static __m128i sum1Channel8Bit16Elements(const __m128i &elements)
Sums 16 elements with 8 bit per element.
Definition: SSE.h:3540
static __m128i shuffleNeighbor4Low64BitsToLow16_8(const __m128i &value)
Shuffles pairs of four neighbors of the low 64 bits to the low 8 bits of eight 16 bit elements.
Definition: SSE.h:3865
static void average8Elements2Channel64Bit2x2(const float *const image0, const float *const image1, float *const result)
Averages 8 elements of 2x2 blocks for 2 channel 64 bit frames.
Definition: SSE.h:2670
static __m128i addOffsetBeforeRightShiftDivisionSigned16Bit(const __m128i &value, const unsigned int rightShifts)
Adds 2^shifts - 1 to each negative signed 16 bit value, so they each value can be right shifted to al...
Definition: SSE.h:3047
static __m128i load_u8_15_lower_random(const uint8_t *const buffer)
Loads 15 bytes from memory, which holds either at least 16 bytes or exactly 15 bytes,...
Definition: SSE.h:3736
static __m128i removeHighBits16_8_7_lower(const __m128i &value)
Removes the higher 8 bits of eight 16 bit elements and sets the upper two bytes to zero.
Definition: SSE.h:3804
static void average8Elements4Channel128Bit2x2(const float *const image0, const float *const image1, float *const result)
Averages 8 elements of 2x2 blocks for 4 channel 128 bit frames.
Definition: SSE.h:2868
static __m128i load_u8_10_upper_zero(const uint8_t *const buffer)
Loads 10 bytes from memory, which holds either at least 16 bytes or exactly 10 bytes,...
Definition: SSE.h:3626
static __m128i sumAbsoluteDifferences8Bit16Elements(const uint8_t *const image0, const uint8_t *const image1)
Sum absolute differences determination for 16 elements of an 16 elements buffer with 8 bit precision.
Definition: SSE.h:1543
static __m128i moveHighBits32_16(const __m128i &value)
Moves the higher 16 bits of four 32 bit elements to the lower 16 bits and fills the high bits with 0.
Definition: SSE.h:3834
static void average16Elements4Channel32Bit2x2(const uint8_t *const image0, const uint8_t *const image1, uint8_t *const result)
Averages 16 elements of 2x2 blocks for 4 channel 32 bit frames.
Definition: SSE.h:2896
static __m128i moveHighBits16_8_7(const __m128i &value)
Moves the higher 8 bits of seven 16 bit elements to the lower 8 bits and fills the high bits with 0.
Definition: SSE.h:3855
static __m128i bitMaskRemoveHigh32_16()
Returns the following 128 bit mask: 0x0000FFFF-0000FFFF-0000FFFF-0000FFFF.
Definition: SSE.h:3895
static __m128i sumSquareDifference8Bit16ElementsAligned16(const uint8_t *const image0, const uint8_t *const image1)
Sum square difference determination for 16 elements with 8 bit precision.
Definition: SSE.h:1550
static __m128i removeHighBits32_16(const __m128i &value)
Removes the higher 16 bits of four 32 bit elements.
Definition: SSE.h:3789
static __m128i shuffleNeighbor2High64BitsToLow16_8(const __m128i &value)
Shuffles pairs of two neighbors of the high 64 bits to the low 8 bits of eight 16 bit elements.
Definition: SSE.h:3885
static void average6Elements3Channel96Bit2x2(const float *const image0, const float *const image1, float *const result)
Averages 6 elements of 2x2 blocks for 3 channel 96 bit frames.
Definition: SSE.h:2771
static __m128i interpolation4Channel32Bit2x4Elements(const __m128i &values0, const __m128i &values1, const __m128i &fx_fy_, const __m128i &fxfy_, const __m128i &fx_fy, const __m128i &fxfy)
Interpolates 2x4 elements (two seperated blocks of 4 elements) of 2x2 blocks for 4 channel 32 bit fra...
Definition: SSE.h:2264
static __m128i interpolation3Channel24Bit12Elements(const __m128i &values0, const __m128i &values1, const __m128i &fx_fy_fxfy_, const __m128i &fx_fyfxfy)
Interpolates 12 elements of 2x2 blocks for 3 channel 24 bit frames.
Definition: SSE.h:2077
static __m128i addOffsetBeforeRightShiftDivisionSigned32Bit(const __m128i &value, const unsigned int rightShifts)
Adds 2^shifts - 1 to each negative signed 32 bit value, so they each value can be right shifted to al...
Definition: SSE.h:3089
static __m128i interpolation4Channel32Bit8Elements(const __m128i &values0, const __m128i &values1, const __m128i &fx_fy_, const __m128i &fxfy_, const __m128i &fx_fy, const __m128i &fxfy)
Interpolates 8 elements of 2x2 blocks for 4 channel 32 bit frames.
Definition: SSE.h:2117
static void average8Elements1Channel32Bit2x2(const float *const image0, const float *const image1, float *const result)
Averages 8 elements of 2x2 blocks for 1 channel 32 bit frames.
Definition: SSE.h:2410
static void shiftChannelToBack4Channel32Bit(const uint8_t *elements, uint8_t *shiftedElements)
Shifts the channels of a 4 channel 32 bit pixels to the back and moves the back channel to the front ...
Definition: SSE.h:3526
static void average8Elements1Channel8Bit2x2(const uint8_t *const image0, const uint8_t *const image1, uint8_t *const result)
Averages 8 elements of 2x2 blocks for 1 channel 8 bit frames.
Definition: SSE.h:2444
static OCEAN_FORCE_INLINE void deInterleave3Channel8Bit24Elements(const __m128i &interleavedA, const __m128i &interleavedB, __m128i &channel01, __m128i &channel2)
Deinterleaves 24 elements of e.g., and image with 3 channels and 8 bit per element.
Definition: SSE.h:3289
static void prefetchT0(const void *const data)
Prefetches a block of temporal memory into all cache levels.
Definition: SSE.h:1255
static __m128i interpolation1Channel8Bit15Elements(const __m128i &values0, const __m128i &values1, const __m128i &fx_fy_fxfy_, const __m128i &fx_fyfxfy)
Interpolates 15 elements of 2x2 blocks for 1 channel 8 bit frames.
Definition: SSE.h:2025
static uint16_t value_u16(const __m128i &value)
Returns one specific 16 bit unsigned integer value of a m128i value object.
Definition: SSE.h:1299
static OCEAN_FORCE_INLINE void reverseChannelOrder3Channel8Bit48Elements(const __m128i &interleaved0, const __m128i &interleaved1, const __m128i &interleaved2, __m128i &reversedInterleaved0, __m128i &reversedInterleaved1, __m128i &reversedInterleaved2)
Reverses the order of the first and last channel of 48 elements of an image with 3 interleaved channe...
Definition: SSE.h:3387
static __m128i sumSquareDifferences8BitBack11Elements(const uint8_t *const image0, const uint8_t *const image1)
Sum square differences determination for the last 11 elements of an 16 elements buffer with 8 bit pre...
Definition: SSE.h:1367
static __m128i removeLowBits32_16(const __m128i &value)
Removes the lower 16 bits of four 32 bit elements.
Definition: SSE.h:3794
static __m128i interpolation2Channel16Bit8Elements(const __m128i &values0, const __m128i &values1, const __m128i &fx_fy_, const __m128i &fxfy_, const __m128i &fx_fy, const __m128i &fxfy)
Interpolates 8 elements of 2x2 blocks for 2 channel 16 bit frames.
Definition: SSE.h:1733
static uint8_t value_u8(const __m128i &value)
Returns one specific 8 bit unsigned integer value of a m128i value object.
Definition: SSE.h:1276
static void gradientHorizontalVertical8Elements3Products1Channel8Bit(const uint8_t *source, int16_t *response, const unsigned int width)
Determines the squared horizontal and vertical gradients and the product of both gradients for 16 fol...
Definition: SSE.h:3169
static __m128i bitMaskRemoveHigh16_8()
Returns the following 128 bit mask: 0x00FF00FF-00FF00FF-00FF00FF-00FF00FF.
Definition: SSE.h:3890
static __m128i removeHighBits16_8(const __m128i &value)
Removes the higher 8 bits of eight 16 bit elements.
Definition: SSE.h:3799
static __m128i sum1Channel8BitBack15Elements(const uint8_t *elements)
Sums the last 15 elements of a 16 elements buffer with 8 bit per element, the beginning 1 element is ...
Definition: SSE.h:3562
static __m128i load_u8_15_lower_zero(const uint8_t *const buffer)
Loads 15 bytes from memory, which holds either at least 16 bytes or exactly 15 bytes,...
Definition: SSE.h:3702
static OCEAN_FORCE_INLINE void deInterleave3Channel8Bit48Elements(const __m128i &interleavedA, const __m128i &interleavedB, const __m128i &interleavedC, __m128i &channel0, __m128i &channel1, __m128i &channel2)
Deinterleaves 48 elements of e.g., and image with 3 channels and 8 bit per element.
Definition: SSE.h:3304
static __m128i sumSquareDifference8Bit16Elements(const uint8_t *const image0, const uint8_t *const image1)
Sum square difference determination for 16 elements with 8 bit precision.
Definition: SSE.h:1533
static __m128i sumInterleave3Channel8Bit48Elements(const __m128i &interleaved0, const __m128i &interleaved1, const __m128i &interleaved2)
Sums 16 elements individually for an interleaved pixel format with 3 channels and 8 bit per channel a...
Definition: SSE.h:3568
static void average32Elements4Channel32Bit2x2(const uint8_t *const image0, const uint8_t *const image1, uint8_t *const result)
Averages 32 elements of 2x2 blocks for 4 channel 32 bit frames.
Definition: SSE.h:2920
static void average30Elements1Channel8Bit3x3(const uint8_t *const image0, const uint8_t *const image1, const uint8_t *const image2, uint8_t *const result)
Averages 30 elements of 3x3 blocks for 1 channel 8 bit frames.
Definition: SSE.h:2967
static __m128i sumSquareDifference8BitFront15Elements(const uint8_t *const image0, const uint8_t *const image1)
Sum square difference determination for the first 15 elements of a buffer with 8 bit precision.
Definition: SSE.h:1491
static __m128i sum1Channel8BitFront15Elements(const uint8_t *elements)
Sums the first 15 elements of a buffer with 8 bit per element.
Definition: SSE.h:3556
static void average32ElementsBinary1Channel8Bit2x2(const uint8_t *const image0, const uint8_t *const image1, uint8_t *const result, const uint16_t threshold=776u)
Averages 32 elements of 2x2 blocks for 1 binary (0x00 or 0xFF) frames.
Definition: SSE.h:2613
static void average32Elements1Channel8Bit2x2(const uint8_t *const image0, const uint8_t *const image1, uint8_t *const result)
Averages 32 elements of 2x2 blocks for 1 channel 8 bit frames.
Definition: SSE.h:2547
static __m128i sumSquareDifference8BitBack12Elements(const uint8_t *const image0, const uint8_t *const image1)
Sum square difference determination for the last 12 elements of an 16 elements buffer with 8 bit prec...
Definition: SSE.h:1408
static OCEAN_FORCE_INLINE float sum_f32_4(const __m128 &value)
Adds the four (all four) individual 32 bit float of a m128 value and returns the result.
Definition: SSE.h:1349
static __m128i load_u8_13_lower_random(const uint8_t *const buffer)
Loads 13 bytes from memory, which holds either at least 16 bytes or exactly 13 bytes,...
Definition: SSE.h:3682
static void swapReversedChannelOrder3Channel8Bit48Elements(uint8_t *first, uint8_t *second)
Reverses the order of the first and last channel of two sets of 48 elements of an image with 3 interl...
Definition: SSE.h:3441
static OCEAN_FORCE_INLINE unsigned int sum_u32_4(const __m128i &value)
Adds the four (all four) individual 32 bit unsigned integer values of a m128i value and returns the r...
Definition: SSE.h:1322
static void prefetchNTA(const void *const data)
Prefetches a block of non-temporal memory into non-temporal cache structure.
Definition: SSE.h:1270
static __m128i moveLowBits16_8ToLow64(const __m128i &value)
Moves the lower 8 bits of eight 16 bit elements to the lower 64 bits and fills the high 64 bits with ...
Definition: SSE.h:3814
static __m128i sumAbsoluteDifferences8BitFront10Elements(const uint8_t *const image0, const uint8_t *const image1)
Sum absolute differences determination for the first 10 elements of a buffer with 8 bit precision.
Definition: SSE.h:1518
static unsigned int interpolation2Channel16Bit1x1(const uint8_t *const pixel, const unsigned int size, const unsigned int fx_y_, const unsigned int fxy_, const unsigned int fx_y, const unsigned int fxy)
Returns the interpolated pixel values for one 2 channel 16 bit pixel.
Definition: SSE.h:3919
static void shiftAndMirrorChannelToBack4Channel32Bit(const uint8_t *elements, uint8_t *shiftedElements)
Shifts the channels of a 4 channel 32 bit pixels to the back and moves the back channel to the front ...
Definition: SSE.h:3533
static __m128i load128iLower64(const void *const buffer)
Loads the lower 64 bit of a 128i value from the memory.
Definition: SSE.h:3613
static unsigned int ssd2Channel16Bit1x1(const uint8_t *const pixel0, const uint8_t *const pixel1, const unsigned int size0, const unsigned int size1, const unsigned int f1x_y_, const unsigned int f1xy_, const unsigned int f1x_y, const unsigned int f1xy)
Returns the interpolated sum of square difference for one 2 channel 16 bit pixel.
Definition: SSE.h:3927
static __m128i set128i(const unsigned long long high64, const unsigned long long low64)
Sets a 128i value by two 64 bit values.
Definition: SSE.h:3770
static OCEAN_FORCE_INLINE void reverseChannelOrder4Channel8Bit64Elements(const uint8_t *interleaved, uint8_t *reversedInterleaved)
Reverses the order of the channels of 16 pixels (64 elements) of an image with 4 interleaved channels...
Definition: SSE.h:3412
static __m128i addOffsetBeforeRightShiftDivisionByTwoSigned16Bit(const __m128i &value)
Adds 1 to each signed 16 bit value which is both, negative and odd, so that each value can be right s...
Definition: SSE.h:3028
static void average8Elements2Channel16Bit2x2(const uint8_t *const image0, const uint8_t *const image1, uint8_t *const result)
Averages 8 elements of 2x2 blocks for 2 channel 16 bit frames.
Definition: SSE.h:2645
static void shiftAndMirrorChannelToFront4Channel32Bit(const uint8_t *elements, uint8_t *shiftedElements)
Shifts the channels of a 4 channel 32 bit pixels to the front and moves the front channel to the back...
Definition: SSE.h:3519
static __m128i sumAbsoluteDifferences8BitFront15Elements(const uint8_t *const image0, const uint8_t *const image1)
Sum absolute differences determination for the first 15 elements of a buffer with 8 bit precision.
Definition: SSE.h:1526
static void average16Elements1Channel8Bit2x2(const uint8_t *const image0, const uint8_t *const image1, uint8_t *const result)
Averages 16 elements of 2x2 blocks for 1 channel 8 bit frames.
Definition: SSE.h:2490
static OCEAN_FORCE_INLINE void multiplyInt8x16ToInt32x8(const __m128i &values0, const __m128i &values1, __m128i &products0, __m128i &products1)
Multiplies 8 int16_t values with 8 int16_t values and returns the products as 8 int32_t results.
Definition: SSE.h:3900
static OCEAN_FORCE_INLINE void reverseChannelOrder2Channel8Bit32Elements(const uint8_t *interleaved, uint8_t *reversedInterleaved)
Reverses the order of the channels of 16 pixels (32 elements) of an image with 2 interleaved channels...
Definition: SSE.h:3372
static __m128i interpolation3Channel24Bit8Elements(const __m128i &values0, const __m128i &values1, const __m128i &fx_fy_, const __m128i &fxfy_, const __m128i &fx_fy, const __m128i &fxfy)
Interpolates 8 elements of 2x2 blocks for 3 channel 24 bit frames.
Definition: SSE.h:1879
unsigned int sqrDistance(const char first, const char second)
Returns the square distance between two values.
Definition: base/Utilities.h:1089
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15
This union defines a wrapper for the __m128 SSE intrinsic data type.
Definition: SSE.h:71
float m128_f32[4]
The four 32 bit elements.
Definition: SSE.h:73
This union defines a wrapper for the __m128 SSE intrinsic data type.
Definition: SSE.h:82
double m128d_f64[2]
The two 64 bit elements.
Definition: SSE.h:84
This union defines a wrapper for the __m128i SSE intrinsic data type.
Definition: SSE.h:51
uint64_t m128i_u64[2]
The two 64 bit elements.
Definition: SSE.h:53
uint16_t m128i_u16[8]
The eight 16 bit elements.
Definition: SSE.h:59
uint32_t m128i_u32[4]
The four 32 bit elements.
Definition: SSE.h:56
uint8_t m128i_u8[16]
The sixteen 8 bit elements.
Definition: SSE.h:62