Fixed primitiveYUV unit test.

This commit is contained in:
akallabeth 2021-01-12 13:41:29 +01:00 committed by akallabeth
parent 6c6e31217d
commit 3b7af0293e

View File

@ -14,6 +14,8 @@
#define TAG __FILE__
#define PADDING_FILL_VALUE 0x37
/* YUV to RGB conversion is lossy, so consider every value only
* differing by less than 2 abs equal. */
static BOOL similar(const BYTE* src, const BYTE* dst, size_t size)
@ -35,10 +37,13 @@ static BOOL similar(const BYTE* src, const BYTE* dst, size_t size)
return TRUE;
}
static BOOL similarRGB(const BYTE* src, const BYTE* dst, size_t size, UINT32 format)
static BOOL similarRGB(const BYTE* src, const BYTE* dst, size_t size, UINT32 format, BOOL use444)
{
size_t x;
const UINT32 bpp = GetBytesPerPixel(format);
BYTE fill = PADDING_FILL_VALUE;
if (!ColorHasAlpha(format))
fill = 0xFF;
for (x = 0; x < size; x++)
{
@ -57,14 +62,15 @@ static BOOL similarRGB(const BYTE* src, const BYTE* dst, size_t size, UINT32 for
{
fprintf(
stderr,
"Color value mismatch R[%02X %02X], G[%02X %02X], B[%02X %02X] at position %lu",
"Color value mismatch R[%02X %02X], G[%02X %02X], B[%02X %02X] at position %lu\n",
sR, dR, sG, dG, sA, dA, x);
return FALSE;
}
if (dA != 0xFF)
if (dA != fill)
{
fprintf(stderr, "Invalid destination alpha value %02X at position %lu", dA, x);
fprintf(stderr, "[%s] Invalid destination alpha value %02X at position %lu\n",
use444 ? "AVC444" : "AVC420", dA, x);
return FALSE;
}
}
@ -141,7 +147,7 @@ static void* set_padding(size_t size, size_t padding)
return NULL;
memset(&src[0], 'A', halfPad);
memset(&src[halfPad], 0, size);
memset(&src[halfPad], PADDING_FILL_VALUE, size);
memset(&src[halfPad + size], 'A', halfPad);
psrc = &src[halfPad];
@ -448,6 +454,8 @@ static BOOL TestPrimitiveYUV(primitives_t* prims, prim_size_t roi, BOOL use444)
pstatus_t rc;
const UINT32 DstFormat = formats[x];
printf("Testing destination color format %s\n", FreeRDPGetColorFormatName(DstFormat));
memset(rgb_dst, PADDING_FILL_VALUE, size * sizeof(UINT32));
PROFILER_CREATE(rgbToYUV420, "RGBToYUV420")
PROFILER_CREATE(rgbToYUV444, "RGBToYUV444")
PROFILER_CREATE(yuv420ToRGB, "YUV420ToRGB")
@ -543,7 +551,7 @@ static BOOL TestPrimitiveYUV(primitives_t* prims, prim_size_t roi, BOOL use444)
BYTE* srgb = &rgb[y * stride];
BYTE* drgb = &rgb_dst[y * stride];
if (!similarRGB(srgb, drgb, roi.width, DstFormat))
if (!similarRGB(srgb, drgb, roi.width, DstFormat, use444))
goto fail;
}