Skip to content

Commit

Permalink
add missing +128 from formula on Wikipedia
Browse files Browse the repository at this point in the history
* add possiblitity to have a better color profile in exchange for some additional computing (currently not enabled from CMake)
* rewrite RGB2YUV in SSSE3 to use 3 base functions for Y U and V
* fix log message for similarRGB
* set fixed values for TestPrimitiveRgbToLumaChroma
* testing issues still persist in some cases
  • Loading branch information
alexandru-bagu committed Oct 23, 2021
1 parent 9e497cf commit 387996e
Show file tree
Hide file tree
Showing 3 changed files with 244 additions and 139 deletions.
25 changes: 19 additions & 6 deletions libfreerdp/primitives/prim_YUV.c
Original file line number Diff line number Diff line change
Expand Up @@ -588,24 +588,37 @@ static pstatus_t general_YUV420ToRGB_8u_P3AC4R(const BYTE* const pSrc[3], const
return PRIMITIVES_SUCCESS;
}

#ifdef WITH_H264_COLOR_CORRECTION
/**
* | Y | ( | 66 129 25 | | R | ) | 16 |
* | U | = ( | -38 -74 112 | | G | ) >> 8 + | 128 |
* | V | ( | 112 -94 -18 | | B | ) | 128 |
* | Y | ( ( | 66 129 25 | | R | ) | 128 | ) | 16 |
* | U | = ( ( | -38 -74 112 | | G | ) + | 128 | ) >> 8 + | 128 |
* | V | ( ( | 112 -94 -18 | | B | ) | 128 | ) | 128 |
*/
#else
/**
* | Y | ( ( | 66 127 25 | | R | ) | 128 | ) | 16 |
* | U | = ( ( | -38 -74 112 | | G | ) + | 128 | ) >> 8 + | 128 |
* | V | ( ( | 112 -94 -18 | | B | ) | 128 | ) | 128 |
*/
#endif

static INLINE BYTE RGB2Y(BYTE R, BYTE G, BYTE B)
{
return ((66 * R + 129 * G + 25 * B) >> 8) + 16u;
#ifdef WITH_H264_COLOR_CORRECTION
return ((66lu * R + 129lu * G + 25lu * B + 128lu) >> 8lu) + 16lu;
#else
return ((66lu * R + 127lu * G + 25lu * B + 128lu) >> 8lu) + 16lu;
#endif
}

static INLINE BYTE RGB2U(BYTE R, BYTE G, BYTE B)
{
return ((-38u * R - 74u * G + 112u * B) >> 8u) + 128u;
return ((-38lu * R - 74lu * G + 112lu * B + 128lu) >> 8lu) + 128lu;
}

static INLINE BYTE RGB2V(INT32 R, INT32 G, INT32 B)
{
return ((112lu * R - 94lu * G - 18lu * B) >> 8lu) + 128lu;
return ((112lu * R - 94lu * G - 18lu * B + 128lu) >> 8lu) + 128lu;
}

static pstatus_t general_RGBToYUV444_8u_P3AC4R(const BYTE* pSrc, UINT32 SrcFormat,
Expand Down

0 comments on commit 387996e

Please sign in to comment.