diff --git a/libfreerdp/primitives/neon/prim_YUV_neon.c b/libfreerdp/primitives/neon/prim_YUV_neon.c index d7388c458..66db2ee9d 100644 --- a/libfreerdp/primitives/neon/prim_YUV_neon.c +++ b/libfreerdp/primitives/neon/prim_YUV_neon.c @@ -444,87 +444,6 @@ static pstatus_t neon_LumaToYUV444(const BYTE* WINPR_RESTRICT pSrcRaw[3], const return PRIMITIVES_SUCCESS; } -static pstatus_t neon_ChromaFilter(BYTE* WINPR_RESTRICT pDst[3], const UINT32 dstStep[3], - const RECTANGLE_16* WINPR_RESTRICT roi) -{ - const UINT32 oddY = 1; - const UINT32 evenY = 0; - const UINT32 nWidth = roi->right - roi->left; - const UINT32 nHeight = roi->bottom - roi->top; - const UINT32 halfHeight = (nHeight + 1) / 2; - const UINT32 halfWidth = (nWidth + 1) / 2; - const UINT32 halfPad = halfWidth % 16; - - /* Filter */ - for (UINT32 y = roi->top / 2; y < halfHeight + roi->top / 2; y++) - { - const UINT32 val2y = (y * 2 + evenY); - const UINT32 val2y1 = val2y + oddY; - BYTE* pU1 = pDst[1] + dstStep[1] * val2y1; - BYTE* pV1 = pDst[2] + dstStep[2] * val2y1; - BYTE* pU = pDst[1] + dstStep[1] * val2y; - BYTE* pV = pDst[2] + dstStep[2] * val2y; - - if (val2y1 > nHeight + roi->top) - continue; - - UINT32 x = roi->left / 2; - for (; x < halfWidth + roi->left / 2 - halfPad; x += 8) - { - { - /* U = (U2x,2y << 2) - U2x1,2y - U2x,2y1 - U2x1,2y1 */ - uint8x8x2_t u = vld2_u8(&pU[2 * x]); - const int16x8_t up = - vreinterpretq_s16_u16(vshll_n_u8(u.val[0], 2)); /* Ux2,2y << 2 */ - const uint8x8x2_t u1 = vld2_u8(&pU1[2 * x]); - const uint16x8_t usub = vaddl_u8(u1.val[1], u1.val[0]); /* U2x,2y1 + U2x1,2y1 */ - const int16x8_t us = vreinterpretq_s16_u16( - vaddw_u8(usub, u.val[1])); /* U2x1,2y + U2x,2y1 + U2x1,2y1 */ - const int16x8_t un = vsubq_s16(up, us); - const uint8x8_t u8 = vqmovun_s16(un); /* CLIP(un) */ - u.val[0] = u8; - vst2_u8(&pU[2 * x], u); - } - { - /* V = (V2x,2y << 2) - V2x1,2y - V2x,2y1 - V2x1,2y1 */ - uint8x8x2_t v = vld2_u8(&pV[2 * x]); - const int16x8_t vp = - vreinterpretq_s16_u16(vshll_n_u8(v.val[0], 2)); /* Vx2,2y << 2 */ - const uint8x8x2_t v1 = vld2_u8(&pV1[2 * x]); - const uint16x8_t vsub = vaddl_u8(v1.val[1], v1.val[0]); /* V2x,2y1 + V2x1,2y1 */ - const int16x8_t vs = vreinterpretq_s16_u16( - vaddw_u8(vsub, v.val[1])); /* V2x1,2y + V2x,2y1 + V2x1,2y1 */ - const int16x8_t vn = vsubq_s16(vp, vs); - const uint8x8_t v8 = vqmovun_s16(vn); /* CLIP(vn) */ - v.val[0] = v8; - vst2_u8(&pV[2 * x], v); - } - } - - for (; x < halfWidth + roi->left / 2; x++) - { - const UINT32 val2x = (x * 2); - const UINT32 val2x1 = val2x + 1; - const BYTE inU = pU[val2x]; - const BYTE inV = pV[val2x]; - const INT32 up = inU * 4; - const INT32 vp = inV * 4; - INT32 u2020; - INT32 v2020; - - if (val2x1 > nWidth + roi->left) - continue; - - u2020 = up - pU[val2x1] - pU1[val2x] - pU1[val2x1]; - v2020 = vp - pV[val2x1] - pV1[val2x] - pV1[val2x1]; - pU[val2x] = CONDITIONAL_CLIP(u2020, inU); - pV[val2x] = CONDITIONAL_CLIP(v2020, inV); - } - } - - return PRIMITIVES_SUCCESS; -} - static pstatus_t neon_ChromaV1ToYUV444(const BYTE* WINPR_RESTRICT pSrcRaw[3], const UINT32 srcStep[3], BYTE* WINPR_RESTRICT pDstRaw[3], const UINT32 dstStep[3], @@ -612,8 +531,7 @@ static pstatus_t neon_ChromaV1ToYUV444(const BYTE* WINPR_RESTRICT pSrcRaw[3], } } - /* Filter */ - return neon_ChromaFilter(pDst, dstStep, roi); + return PRIMITIVES_SUCCESS; } static pstatus_t neon_ChromaV2ToYUV444(const BYTE* WINPR_RESTRICT pSrc[3], const UINT32 srcStep[3], @@ -697,7 +615,7 @@ static pstatus_t neon_ChromaV2ToYUV444(const BYTE* WINPR_RESTRICT pSrc[3], const } } - return neon_ChromaFilter(pDst, dstStep, roi); + return PRIMITIVES_SUCCESS; } static pstatus_t neon_YUV420CombineToYUV444(avc444_frame_type type, diff --git a/libfreerdp/primitives/prim_YUV.c b/libfreerdp/primitives/prim_YUV.c index e5f0e517b..25c8e1cb3 100644 --- a/libfreerdp/primitives/prim_YUV.c +++ b/libfreerdp/primitives/prim_YUV.c @@ -93,54 +93,6 @@ static pstatus_t general_LumaToYUV444(const BYTE* WINPR_RESTRICT pSrcRaw[3], return PRIMITIVES_SUCCESS; } -static pstatus_t general_ChromaFilter(BYTE* WINPR_RESTRICT pDst[3], const UINT32 dstStep[3], - const RECTANGLE_16* WINPR_RESTRICT roi) -{ - const UINT32 oddY = 1; - const UINT32 evenY = 0; - const UINT32 nWidth = roi->right - roi->left; - const UINT32 nHeight = roi->bottom - roi->top; - const UINT32 halfHeight = (nHeight + 1) / 2; - const UINT32 halfWidth = (nWidth + 1) / 2; - - /* Filter */ - for (UINT32 y = roi->top; y < halfHeight + roi->top; y++) - { - const UINT32 val2y = (y * 2 + evenY); - const UINT32 val2y1 = val2y + oddY; - BYTE* pU1 = pDst[1] + 1ULL * dstStep[1] * val2y1; - BYTE* pV1 = pDst[2] + 1ULL * dstStep[2] * val2y1; - BYTE* pU = pDst[1] + 1ULL * dstStep[1] * val2y; - BYTE* pV = pDst[2] + 1ULL * dstStep[2] * val2y; - - if (val2y1 > nHeight) - continue; - - for (UINT32 x = roi->left; x < halfWidth + roi->left; x++) - { - const UINT32 val2x = (x * 2); - const UINT32 val2x1 = val2x + 1; - const BYTE inU = pU[val2x]; - const BYTE inV = pV[val2x]; - const INT32 up = inU * 4; - const INT32 vp = inV * 4; - INT32 u2020 = 0; - INT32 v2020 = 0; - - if (val2x1 > nWidth) - continue; - - u2020 = up - pU[val2x1] - pU1[val2x] - pU1[val2x1]; - v2020 = vp - pV[val2x1] - pV1[val2x] - pV1[val2x1]; - - pU[val2x] = CONDITIONAL_CLIP(u2020, inU); - pV[val2x] = CONDITIONAL_CLIP(v2020, inV); - } - } - - return PRIMITIVES_SUCCESS; -} - static pstatus_t general_ChromaV1ToYUV444(const BYTE* WINPR_RESTRICT pSrcRaw[3], const UINT32 srcStep[3], BYTE* WINPR_RESTRICT pDstRaw[3], const UINT32 dstStep[3], @@ -212,8 +164,7 @@ static pstatus_t general_ChromaV1ToYUV444(const BYTE* WINPR_RESTRICT pSrcRaw[3], } } - /* Filter */ - return general_ChromaFilter(pDst, dstStep, roi); + return PRIMITIVES_SUCCESS; } static pstatus_t general_ChromaV2ToYUV444(const BYTE* WINPR_RESTRICT pSrc[3], @@ -264,7 +215,7 @@ static pstatus_t general_ChromaV2ToYUV444(const BYTE* WINPR_RESTRICT pSrc[3], } } - return general_ChromaFilter(pDst, dstStep, roi); + return PRIMITIVES_SUCCESS; } static pstatus_t general_YUV420CombineToYUV444(avc444_frame_type type, @@ -307,13 +258,12 @@ general_YUV444SplitToYUV420(const BYTE* WINPR_RESTRICT pSrc[3], const UINT32 src { UINT32 uY = 0; UINT32 vY = 0; - UINT32 halfWidth = 0; - UINT32 halfHeight = 0; + /* The auxiliary frame is aligned to multiples of 16x16. * We need the padded height for B4 and B5 conversion. */ const UINT32 padHeigth = roi->height + 16 - roi->height % 16; - halfWidth = (roi->width + 1) / 2; - halfHeight = (roi->height + 1) / 2; + const UINT32 halfWidth = (roi->width + 1) / 2; + const UINT32 halfHeight = (roi->height + 1) / 2; /* B1 */ for (size_t y = 0; y < roi->height; y++) @@ -328,18 +278,13 @@ general_YUV444SplitToYUV420(const BYTE* WINPR_RESTRICT pSrc[3], const UINT32 src { const BYTE* pSrcU = pSrc[1] + 2ULL * y * srcStep[1]; const BYTE* pSrcV = pSrc[2] + 2ULL * y * srcStep[2]; - const BYTE* pSrcU1 = pSrc[1] + (2ULL * y + 1ULL) * srcStep[1]; - const BYTE* pSrcV1 = pSrc[2] + (2ULL * y + 1ULL) * srcStep[2]; BYTE* pU = pMainDst[1] + y * dstMainStep[1]; BYTE* pV = pMainDst[2] + y * dstMainStep[2]; for (size_t x = 0; x < halfWidth; x++) { - /* Filter */ - const INT32 u = pSrcU[2 * x] + pSrcU[2 * x + 1] + pSrcU1[2 * x] + pSrcU1[2 * x + 1]; - const INT32 v = pSrcV[2 * x] + pSrcV[2 * x + 1] + pSrcV1[2 * x] + pSrcV1[2 * x + 1]; - pU[x] = CLIP(u / 4L); - pV[x] = CLIP(v / 4L); + pU[x] = pSrcV[2 * x]; + pV[x] = pSrcU[2 * x]; } } diff --git a/libfreerdp/primitives/sse/prim_YUV_ssse3.c b/libfreerdp/primitives/sse/prim_YUV_ssse3.c index e3107dcfd..994c7cb94 100644 --- a/libfreerdp/primitives/sse/prim_YUV_ssse3.c +++ b/libfreerdp/primitives/sse/prim_YUV_ssse3.c @@ -1142,83 +1142,6 @@ static pstatus_t ssse3_LumaToYUV444(const BYTE* WINPR_RESTRICT pSrcRaw[], const return PRIMITIVES_SUCCESS; } -static INLINE void ssse3_filter(BYTE* WINPR_RESTRICT pSrcDst, const BYTE* WINPR_RESTRICT pSrc2) -{ - const __m128i even = _mm_set_epi8((char)0x80, 14, (char)0x80, 12, (char)0x80, 10, (char)0x80, 8, - (char)0x80, 6, (char)0x80, 4, (char)0x80, 2, (char)0x80, 0); - const __m128i odd = _mm_set_epi8((char)0x80, 15, (char)0x80, 13, (char)0x80, 11, (char)0x80, 9, - (char)0x80, 7, (char)0x80, 5, (char)0x80, 3, (char)0x80, 1); - const __m128i interleave = _mm_set_epi8(15, 7, 14, 6, 13, 5, 12, 4, 11, 3, 10, 2, 9, 1, 8, 0); - const __m128i u = _mm_loadu_si128((const __m128i*)pSrcDst); - const __m128i u1 = _mm_loadu_si128((const __m128i*)pSrc2); - const __m128i uEven = _mm_shuffle_epi8(u, even); - const __m128i uEven4 = _mm_slli_epi16(uEven, 2); - const __m128i uOdd = _mm_shuffle_epi8(u, odd); - const __m128i u1Even = _mm_shuffle_epi8(u1, even); - const __m128i u1Odd = _mm_shuffle_epi8(u1, odd); - const __m128i tmp1 = _mm_add_epi16(uOdd, u1Even); - const __m128i tmp2 = _mm_add_epi16(tmp1, u1Odd); - const __m128i result = _mm_sub_epi16(uEven4, tmp2); - const __m128i packed = _mm_packus_epi16(result, uOdd); - const __m128i interleaved = _mm_shuffle_epi8(packed, interleave); - _mm_storeu_si128((__m128i*)pSrcDst, interleaved); -} - -static pstatus_t ssse3_ChromaFilter(BYTE* WINPR_RESTRICT pDst[], const UINT32 dstStep[], - const RECTANGLE_16* WINPR_RESTRICT roi) -{ - const UINT32 oddY = 1; - const UINT32 evenY = 0; - const UINT32 nWidth = roi->right - roi->left; - const UINT32 nHeight = roi->bottom - roi->top; - const UINT32 halfHeight = (nHeight + 1) / 2; - const UINT32 halfWidth = (nWidth + 1) / 2; - const UINT32 halfPad = halfWidth % 16; - - /* Filter */ - for (size_t y = roi->top; y < halfHeight + roi->top; y++) - { - size_t x = roi->left; - const size_t val2y = (y * 2ULL + evenY); - const size_t val2y1 = val2y + oddY; - BYTE* pU1 = pDst[1] + 1ULL * dstStep[1] * val2y1; - BYTE* pV1 = pDst[2] + 1ULL * dstStep[2] * val2y1; - BYTE* pU = pDst[1] + 1ULL * dstStep[1] * val2y; - BYTE* pV = pDst[2] + 1ULL * dstStep[2] * val2y; - - if (val2y1 > nHeight) - continue; - - for (; x < halfWidth + roi->left - halfPad; x += 16) - { - ssse3_filter(&pU[2 * x], &pU1[2 * x]); - ssse3_filter(&pV[2 * x], &pV1[2 * x]); - } - - for (; x < halfWidth + roi->left; x++) - { - const size_t val2x = (x * 2ULL); - const size_t val2x1 = val2x + 1ULL; - const BYTE inU = pU[val2x]; - const BYTE inV = pV[val2x]; - const INT32 up = inU * 4; - const INT32 vp = inV * 4; - INT32 u2020 = 0; - INT32 v2020 = 0; - - if (val2x1 > nWidth) - continue; - - u2020 = up - pU[val2x1] - pU1[val2x] - pU1[val2x1]; - v2020 = vp - pV[val2x1] - pV1[val2x] - pV1[val2x1]; - pU[val2x] = CONDITIONAL_CLIP(u2020, inU); - pV[val2x] = CONDITIONAL_CLIP(v2020, inV); - } - } - - return PRIMITIVES_SUCCESS; -} - static pstatus_t ssse3_ChromaV1ToYUV444(const BYTE* WINPR_RESTRICT pSrcRaw[3], const UINT32 srcStep[3], BYTE* WINPR_RESTRICT pDstRaw[3], const UINT32 dstStep[3], @@ -1313,8 +1236,7 @@ static pstatus_t ssse3_ChromaV1ToYUV444(const BYTE* WINPR_RESTRICT pSrcRaw[3], } } - /* Filter */ - return ssse3_ChromaFilter(pDst, dstStep, roi); + return PRIMITIVES_SUCCESS; } static pstatus_t ssse3_ChromaV2ToYUV444(const BYTE* WINPR_RESTRICT pSrc[3], const UINT32 srcStep[3], @@ -1429,7 +1351,7 @@ static pstatus_t ssse3_ChromaV2ToYUV444(const BYTE* WINPR_RESTRICT pSrc[3], cons } } - return ssse3_ChromaFilter(pDst, dstStep, roi); + return PRIMITIVES_SUCCESS; } static pstatus_t ssse3_YUV420CombineToYUV444(avc444_frame_type type,