mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
[primitives,copy] remove alignment check
This commit is contained in:
@@ -61,7 +61,6 @@ static INLINE pstatus_t avx2_image_copy_bgr24_bgrx32(BYTE* WINPR_RESTRICT pDstDa
|
||||
const SSIZE_T width = nWidth - rem;
|
||||
|
||||
const size_t align = nSrcStep % 32;
|
||||
const BOOL fast = (align == 0) ? TRUE : (align >= 8 - MIN(8, (size_t)rem) ? TRUE : FALSE);
|
||||
for (SSIZE_T y = 0; y < nHeight; y++)
|
||||
{
|
||||
const BYTE* WINPR_RESTRICT srcLine =
|
||||
@@ -72,29 +71,26 @@ static INLINE pstatus_t avx2_image_copy_bgr24_bgrx32(BYTE* WINPR_RESTRICT pDstDa
|
||||
SSIZE_T x = 0;
|
||||
|
||||
/* Ensure alignment requirements can be met */
|
||||
if (fast)
|
||||
for (; x < width; x += 8)
|
||||
{
|
||||
for (; x < width; x += 8)
|
||||
{
|
||||
const __m256i* src = (const __m256i*)&srcLine[(x + nXSrc) * srcByte];
|
||||
__m256i* dst = (__m256i*)&dstLine[(x + nXDst) * dstByte];
|
||||
const __m256i s0 = _mm256_loadu_si256(src);
|
||||
__m256i s1 = _mm256_shuffle_epi8(s0, smask);
|
||||
const __m256i* src = (const __m256i*)&srcLine[(x + nXSrc) * srcByte];
|
||||
__m256i* dst = (__m256i*)&dstLine[(x + nXDst) * dstByte];
|
||||
const __m256i s0 = _mm256_loadu_si256(src);
|
||||
__m256i s1 = _mm256_shuffle_epi8(s0, smask);
|
||||
|
||||
/* _mm256_shuffle_epi8 can not cross 128bit lanes.
|
||||
* manually copy these bytes with extract/insert */
|
||||
const __m256i sx = _mm256_broadcastsi128_si256(_mm256_extractf128_si256(s0, 0));
|
||||
const __m256i sxx = _mm256_shuffle_epi8(sx, shelpmask);
|
||||
const __m256i bmask =
|
||||
_mm256_set_epi32(0x00000000, 0x00000000, 0x000000FF, 0x00FFFFFF, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000);
|
||||
const __m256i merged = _mm256_blendv_epi8(s1, sxx, bmask);
|
||||
/* _mm256_shuffle_epi8 can not cross 128bit lanes.
|
||||
* manually copy these bytes with extract/insert */
|
||||
const __m256i sx = _mm256_broadcastsi128_si256(_mm256_extractf128_si256(s0, 0));
|
||||
const __m256i sxx = _mm256_shuffle_epi8(sx, shelpmask);
|
||||
const __m256i bmask = _mm256_set_epi32(0x00000000, 0x00000000, 0x000000FF, 0x00FFFFFF,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000);
|
||||
const __m256i merged = _mm256_blendv_epi8(s1, sxx, bmask);
|
||||
|
||||
const __m256i s2 = _mm256_loadu_si256(dst);
|
||||
__m256i d0 = _mm256_blendv_epi8(merged, s2, mask);
|
||||
_mm256_storeu_si256(dst, d0);
|
||||
}
|
||||
const __m256i s2 = _mm256_loadu_si256(dst);
|
||||
__m256i d0 = _mm256_blendv_epi8(merged, s2, mask);
|
||||
_mm256_storeu_si256(dst, d0);
|
||||
}
|
||||
|
||||
for (; x < nWidth; x++)
|
||||
{
|
||||
const BYTE* src = &srcLine[(x + nXSrc) * srcByte];
|
||||
|
||||
@@ -50,7 +50,6 @@ static INLINE pstatus_t sse_image_copy_bgr24_bgrx32(BYTE* WINPR_RESTRICT pDstDat
|
||||
const UINT32 rem = nWidth % 4;
|
||||
|
||||
const size_t align = nSrcStep % 64;
|
||||
const BOOL fast = (align == 0) ? TRUE : (align >= 16 - MIN(16, (size_t)rem) ? TRUE : FALSE);
|
||||
const SSIZE_T width = nWidth - rem;
|
||||
for (SSIZE_T y = 0; y < nHeight; y++)
|
||||
{
|
||||
@@ -61,20 +60,18 @@ static INLINE pstatus_t sse_image_copy_bgr24_bgrx32(BYTE* WINPR_RESTRICT pDstDat
|
||||
|
||||
SSIZE_T x = 0;
|
||||
/* Ensure alignment requirements can be met */
|
||||
if (fast)
|
||||
for (; x < width; x += 4)
|
||||
{
|
||||
for (; x < width; x += 4)
|
||||
{
|
||||
const __m128i* src = (const __m128i*)&srcLine[(x + nXSrc) * srcByte];
|
||||
__m128i* dst = (__m128i*)&dstLine[(x + nXDst) * dstByte];
|
||||
const __m128i s0 = LOAD_SI128(src);
|
||||
const __m128i s1 = _mm_shuffle_epi8(s0, smask);
|
||||
const __m128i s2 = LOAD_SI128(dst);
|
||||
const __m128i* src = (const __m128i*)&srcLine[(x + nXSrc) * srcByte];
|
||||
__m128i* dst = (__m128i*)&dstLine[(x + nXDst) * dstByte];
|
||||
const __m128i s0 = LOAD_SI128(src);
|
||||
const __m128i s1 = _mm_shuffle_epi8(s0, smask);
|
||||
const __m128i s2 = LOAD_SI128(dst);
|
||||
|
||||
__m128i d0 = _mm_blendv_epi8(s1, s2, mask);
|
||||
STORE_SI128(dst, d0);
|
||||
}
|
||||
__m128i d0 = _mm_blendv_epi8(s1, s2, mask);
|
||||
STORE_SI128(dst, d0);
|
||||
}
|
||||
|
||||
for (; x < nWidth; x++)
|
||||
{
|
||||
const BYTE* src = &srcLine[(x + nXSrc) * srcByte];
|
||||
|
||||
Reference in New Issue
Block a user