libfreerdp-primitives: update YCbCr color converter
This commit is contained in:
parent
ad9092baf9
commit
cc16ddea2d
@ -51,13 +51,13 @@ pstatus_t general_yCbCrToRGB_16s8u_P3AC4R(const INT16* pSrc[3], int srcStep,
|
||||
{
|
||||
for (x = 0; x < roi->width; x++)
|
||||
{
|
||||
Y = (double) ((*pY++ >> 1) + 2048);
|
||||
Cb = (double) (*pCb++ >> 1);
|
||||
Cr = (double) (*pCr++ >> 1);
|
||||
Y = (double) (pY[0] + 4096);
|
||||
Cb = (double) (pCb[0]);
|
||||
Cr = (double) (pCr[0]);
|
||||
|
||||
R = (INT16) (((int) (Y + (1.402524948120117L * Cr) + 8.0L)) >> 4);
|
||||
G = (INT16) (((int) (Y - (0.3437300026416779L * Cb) - (0.7144010066986084L * Cr) + 8.0L)) >> 4);
|
||||
B = (INT16) (((int) (Y + (1.769904971122742L * Cb) + 8.0L)) >> 4);
|
||||
R = ((INT16) (((Cr * 1.402524948120117L) + Y + 16.0L)) >> 5);
|
||||
G = ((INT16) ((Y - (Cb * 0.3437300026416779L) - (Cr * 0.7144010066986084L) + 16.0L)) >> 5);
|
||||
B = ((INT16) (((Cb * 1.769904971122742L) + Y + 16.0L)) >> 5);
|
||||
|
||||
if (R < 0)
|
||||
R = 0;
|
||||
@ -78,6 +78,10 @@ pstatus_t general_yCbCrToRGB_16s8u_P3AC4R(const INT16* pSrc[3], int srcStep,
|
||||
*pRGB++ = (BYTE) G;
|
||||
*pRGB++ = (BYTE) R;
|
||||
*pRGB++ = 0xFF;
|
||||
|
||||
pY++;
|
||||
pCb++;
|
||||
pCr++;
|
||||
}
|
||||
|
||||
pY += srcPad;
|
||||
|
@ -2106,6 +2106,51 @@ static int test_memcmp_count(const BYTE* mem1, const BYTE* mem2, int size)
|
||||
return count;
|
||||
}
|
||||
|
||||
static void test_fill_bitmap_red_channel(BYTE* data, int width, int height, BYTE value)
|
||||
{
|
||||
int i, j;
|
||||
UINT32* pixel;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
pixel = (UINT32*) &data[((i * width) + j) * 4];
|
||||
*pixel = ((*pixel & 0xFF00FFFF) | (value << 16));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void test_fill_bitmap_green_channel(BYTE* data, int width, int height, BYTE value)
|
||||
{
|
||||
int i, j;
|
||||
UINT32* pixel;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
pixel = (UINT32*) &data[((i * width) + j) * 4];
|
||||
*pixel = ((*pixel & 0xFFFF00FF) | (value << 8));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void test_fill_bitmap_blue_channel(BYTE* data, int width, int height, BYTE value)
|
||||
{
|
||||
int i, j;
|
||||
UINT32* pixel;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
pixel = (UINT32*) &data[((i * width) + j) * 4];
|
||||
*pixel = ((*pixel & 0xFFFFFF00) | (value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int TestPrimitivesYCbCr(int argc, char* argv[])
|
||||
{
|
||||
int cmp;
|
||||
@ -2159,6 +2204,24 @@ int TestPrimitivesYCbCr(int argc, char* argv[])
|
||||
_aligned_free(pSrcDst[2]);
|
||||
}
|
||||
|
||||
if (0)
|
||||
{
|
||||
test_fill_bitmap_red_channel(actual, 64, 64, 0);
|
||||
test_fill_bitmap_red_channel(expected, 64, 64, 0);
|
||||
}
|
||||
|
||||
if (0)
|
||||
{
|
||||
test_fill_bitmap_green_channel(actual, 64, 64, 0);
|
||||
test_fill_bitmap_green_channel(expected, 64, 64, 0);
|
||||
}
|
||||
|
||||
if (0)
|
||||
{
|
||||
test_fill_bitmap_blue_channel(actual, 64, 64, 0);
|
||||
test_fill_bitmap_blue_channel(expected, 64, 64, 0);
|
||||
}
|
||||
|
||||
cmp = test_memcmp_offset(actual, expected, size);
|
||||
cnt = test_memcmp_count(actual, expected, size);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user