Skip to content

Commit

Permalink
use 516 instead of 517 constant
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandru-bagu committed Oct 22, 2021
1 parent 7592283 commit 9e497cf
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
18 changes: 9 additions & 9 deletions libfreerdp/primitives/prim_YUV_neon.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static primitives_t* generic = NULL;
/**
* | R | ( | 298 0 409 | | Y - 16 | )
* | G | = ( | 298 -100 -208 | | U - 128 | ) >> 8
* | B | ( | 298 517 0 | | V - 128 | )
* | B | ( | 298 516 0 | | V - 128 | )
*/

static INLINE uint8x8_t neon_YUV2R(int32x4_t Ch, int32x4_t Cl, int16x4_t Dh, int16x4_t Dl,
Expand Down Expand Up @@ -77,10 +77,10 @@ static INLINE uint8x8_t neon_YUV2G(int32x4_t Ch, int32x4_t Cl, int16x4_t Dh, int
static INLINE uint8x8_t neon_YUV2B(int32x4_t Ch, int32x4_t Cl, int16x4_t Dh, int16x4_t Dl,
int16x4_t Eh, int16x4_t El)
{
/* B = (298 * (Y - 16) + 517 * (U - 128)) >> 8*/
const int16x4_t c517 = { 517, 517, 517, 517 };
const int32x4_t CDh = vmlal_s16(Ch, Dh, c517);
const int32x4_t CDl = vmlal_s16(Ch, Dl, c517);
/* B = (298 * (Y - 16) + 516 * (U - 128)) >> 8*/
const int16x4_t c516 = { 516, 516, 516, 516 };
const int32x4_t CDh = vmlal_s16(Ch, Dh, c516);
const int32x4_t CDl = vmlal_s16(Ch, Dl, c516);
const int32x4_t Bh = vrshrq_n_s32(CDh, 8);
const int32x4_t Bl = vrshrq_n_s32(CDl, 8);
const int16x8_t B = vcombine_s16(vqmovn_s32(Bl), vqmovn_s32(Bh));
Expand All @@ -102,10 +102,10 @@ static INLINE BYTE* neon_YuvToRgbPixel(BYTE* pRGB, int16x8_t Y, int16x8_t D, int
const int16x4_t Eh = vget_high_s16(E);
const int16x4_t El = vget_low_s16(E);
{
/* B = (298 * (Y - 16) + 517 * (U - 128)) >> 8*/
const int16x4_t c517 = { 517, 517, 517, 517 };
const int32x4_t CDh = vmlal_s16(Ch, Dh, c517);
const int32x4_t CDl = vmlal_s16(Cl, Dl, c517);
/* B = (298 * (Y - 16) + 516 * (U - 128)) >> 8*/
const int16x4_t c516 = { 516, 516, 516, 516 };
const int32x4_t CDh = vmlal_s16(Ch, Dh, c516);
const int32x4_t CDl = vmlal_s16(Cl, Dl, c516);
const int32x4_t Bh = vrshrq_n_s32(CDh, 8);
const int32x4_t Bl = vrshrq_n_s32(CDl, 8);
const int16x8_t B = vcombine_s16(vqmovn_s32(Bl), vqmovn_s32(Bh));
Expand Down
8 changes: 4 additions & 4 deletions libfreerdp/primitives/prim_YUV_ssse3.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ static __m128i* ssse3_YUV444Pixel(__m128i* dst, __m128i Yraw, __m128i Uraw, __m1
}
/* Get the B value */
{
const __m128i c517 = _mm_set1_epi16(517);
const __m128i d517 =
_mm_unpackhi_epi16(_mm_mullo_epi16(D, c517), _mm_mulhi_epi16(D, c517));
const __m128i Bs = _mm_add_epi32(y298, d517);
const __m128i c516 = _mm_set1_epi16(516);
const __m128i d516 =
_mm_unpackhi_epi16(_mm_mullo_epi16(D, c516), _mm_mulhi_epi16(D, c516));
const __m128i Bs = _mm_add_epi32(y298, d516);
const __m128i B32 = _mm_srai_epi32(Bs, 8);
const __m128i B16 = _mm_packs_epi32(B32, _mm_setzero_si128());
const __m128i B = _mm_packus_epi16(B16, _mm_setzero_si128());
Expand Down
4 changes: 2 additions & 2 deletions libfreerdp/primitives/prim_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ static INLINE BYTE CLIP(INT64 X)
*
* | R | ( | 298 0 409 | | Y - 16 | )
* | G | = ( | 298 -100 -208 | | U - 128 | ) >> 8
* | B | ( | 298 517 0 | | V - 128 | )
* | B | ( | 298 516 0 | | V - 128 | )
*/

static INLINE INT32 C(INT32 Y)
Expand Down Expand Up @@ -259,7 +259,7 @@ static INLINE BYTE YUV2G(INT32 Y, INT32 U, INT32 V)

static INLINE BYTE YUV2B(INT32 Y, INT32 U, INT32 V)
{
const INT32 b = (298L * C(Y) + 517L * D(U) + 0L * E(V));
const INT32 b = (298L * C(Y) + 516L * D(U) + 0L * E(V));
const INT32 b8 = b >> 8L;
return CLIP(b8);
}
Expand Down
16 changes: 8 additions & 8 deletions libfreerdp/primitives/primitives.cl
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ __kernel void yuv420_to_argb_1b(
/**
* | R | ( | 298 0 409 | | Y - 16 | )
* | G | = ( | 298 -100 -208 | | U - 128 | ) >> 8
* | B | ( | 298 517 0 | | V - 128 | )
* | B | ( | 298 516 0 | | V - 128 | )
*/
int y298 = 298 * Ydim;
destPtr[0] = 0xff; /* A */
destPtr[1] = clamp_uc((y298 + (409 * Vdim)) >> 8, 0, 255); /* R */
destPtr[2] = clamp_uc((y298 - (100 * Udim) - (208 * Vdim)) >> 8 , 0, 255); /* G */
destPtr[3] = clamp_uc((y298 + (517 * Udim)) >> 8, 0, 255); /* B */
destPtr[3] = clamp_uc((y298 + (516 * Udim)) >> 8, 0, 255); /* B */
}

__kernel void yuv420_to_bgra_1b(
Expand All @@ -73,10 +73,10 @@ __kernel void yuv420_to_bgra_1b(
/**
* | R | ( | 298 0 409 | | Y - 16 | )
* | G | = ( | 298 -100 -208 | | U - 128 | ) >> 8
* | B | ( | 298 517 0 | | V - 128 | )
* | B | ( | 298 516 0 | | V - 128 | )
*/
int y298 = 298 * Y;
destPtr[0] = clamp_uc((y298 + (517 * U)) >> 8, 0, 255); /* B */
destPtr[0] = clamp_uc((y298 + (516 * U)) >> 8, 0, 255); /* B */
destPtr[1] = clamp_uc((y298 - (100 * U) - (208 * V)) >> 8 , 0, 255); /* G */
destPtr[2] = clamp_uc((y298 + (409 * V)) >> 8, 0, 255); /* R */
destPtr[3] = 0xff; /* A */
Expand All @@ -100,10 +100,10 @@ __kernel void yuv444_to_bgra_1b(
/**
* | R | ( | 298 0 409 | | Y - 16 | )
* | G | = ( | 298 -100 -208 | | U - 128 | ) >> 8
* | B | ( | 298 517 0 | | V - 128 | )
* | B | ( | 298 516 0 | | V - 128 | )
*/
int y298 = 298 * Y;
destPtr[0] = clamp_uc((y298 + (517 * U)) >> 8, 0, 255); /* B */
destPtr[0] = clamp_uc((y298 + (516 * U)) >> 8, 0, 255); /* B */
destPtr[1] = clamp_uc((y298 - (100 * U) - (208 * V)) >> 8 , 0, 255); /* G */
destPtr[2] = clamp_uc((y298 + (409 * V)) >> 8, 0, 255); /* R */
destPtr[3] = 0xff; /* A */
Expand All @@ -127,10 +127,10 @@ __kernel void yuv444_to_argb_1b(
/**
* | R | ( | 298 0 409 | | Y - 16 | )
* | G | = ( | 298 -100 -208 | | U - 128 | ) >> 8
* | B | ( | 298 517 0 | | V - 128 | )
* | B | ( | 298 516 0 | | V - 128 | )
*/
int y298 = 298 * Y;
destPtr[3] = clamp_uc((y298 + (517 * U)) >> 8, 0, 255); /* B */
destPtr[3] = clamp_uc((y298 + (516 * U)) >> 8, 0, 255); /* B */
destPtr[2] = clamp_uc((y298 - (100 * U) - (208 * V)) >> 8 , 0, 255); /* G */
destPtr[1] = clamp_uc((y298 + (409 * V)) >> 8, 0, 255); /* R */
destPtr[0] = 0xff; /* A */
Expand Down

0 comments on commit 9e497cf

Please sign in to comment.