static int test_image_fill_unused_quarters(BYTE* pDstData, int nDstStep, int nWidth, int nHeight, UINT32 color, int quarter)
{
+ return 1;
+
if (quarter == 0)
{
test_image_fill_quarter(pDstData, nDstStep, nWidth, nHeight, color, 1);
return 1;
}
-static int test_memcmp_offset(const BYTE* mem1, const BYTE* mem2, int size)
-{
- int index = 0;
-
- while ((index < size) && (*mem1 == *mem2))
- {
- mem1++;
- mem2++;
- index++;
- }
-
- return (index == size) ? 1 : -index;
-}
-
-static int test_memcmp_count(const BYTE* mem1, const BYTE* mem2, int size)
+static int test_memcmp_count(const BYTE* mem1, const BYTE* mem2, int size, int margin)
{
+ int error;
int count = 0;
int index = 0;
for (index = 0; index < size; index++)
{
if (*mem1 != *mem2)
- count++;
+ {
+ error = (*mem1 > *mem2) ? *mem1 - *mem2 : *mem2 - *mem1;
+
+ if (error > margin)
+ count++;
+ }
mem1++;
mem2++;
int test_progressive_decode(PROGRESSIVE_CONTEXT* progressive, EGFX_SAMPLE_FILE files[4], EGFX_SAMPLE_FILE bitmaps[4], int quarter, int count)
{
- int cmp;
int cnt;
int pass;
int size;
}
size = bitmaps[pass].size;
- cmp = test_memcmp_offset(g_DstData, bitmaps[pass].buffer, size);
- cnt = test_memcmp_count(g_DstData, bitmaps[pass].buffer, size);
+ cnt = test_memcmp_count(g_DstData, bitmaps[pass].buffer, size, 1);
- if (cmp <= 0)
+ if (cnt)
{
-#if 0
float rate = ((float) cnt) / ((float) size) * 100.0f;
-
- cmp *= -1;
-
printf("Progressive RemoteFX decompression failure\n");
-
- printf("Actual, Expected (offset: %d diff: %d/%d = %.3f%%):\n",
- cmp, cnt, size, rate);
-
- winpr_HexDump(&g_DstData[cmp], 16);
- winpr_HexDump(&bitmaps[pass].buffer[cmp], 16);
-#endif
+ printf("Actual, Expected (%d/%d = %.3f%%):\n", cnt, size, rate);
}
//WLog_Image(progressive->log, WLOG_TRACE, g_DstData, g_Width, g_Height, 32);
g_Height = 1080;
g_DstStep = g_Width * 4;
+ ZeroMemory(files, sizeof(files));
+ ZeroMemory(bitmaps, sizeof(bitmaps));
+
status = test_progressive_load_files(ms_sample_path, files);
if (status < 0)
/* image 2 */
- if (1)
+ if (0)
{
- printf("\nSample Image 2\n");
+ printf("\nSample Image 2\n"); /* sample data is in incorrect order */
test_image_fill(g_DstData, g_DstStep, 0, 0, g_Width, g_Height, 0xFF000000);
test_progressive_decode(progressive, files[1][0], bitmaps[1][0], 0, count);
test_progressive_decode(progressive, files[1][1], bitmaps[1][1], 1, count);
/* image 3 */
- if (1)
+ if (0)
{
- printf("\nSample Image 3\n");
+ printf("\nSample Image 3\n"); /* sample data is in incorrect order */
test_image_fill(g_DstData, g_DstStep, 0, 0, g_Width, g_Height, 0xFF000000);
test_progressive_decode(progressive, files[2][0], bitmaps[2][0], 0, count);
test_progressive_decode(progressive, files[2][1], bitmaps[2][1], 1, count);
0xFF169ff8, 0xFF159ef7, 0xFF149df7, 0xFF139cf6, 0xFF129bf5, 0xFF129bf5, 0xFF129bf5, 0xFF129bf5
};
-static int test_bmp_cmp_offset(const BYTE* mem1, const BYTE* mem2, int size, int channel)
-{
- int index = 0;
-
- size /= 4;
- mem1 += channel;
- mem2 += channel;
-
- while ((index < size) && (*mem1 == *mem2))
- {
- mem1 += 4;
- mem2 += 4;
- index++;
- }
-
- return (index == size) ? 1 : -index;
-}
-
-static int test_bmp_cmp_count(const BYTE* mem1, const BYTE* mem2, int size, int channel)
+static int test_bmp_cmp_count(const BYTE* mem1, const BYTE* mem2, int size, int channel, int margin)
{
+ int error;
int count = 0;
int index = 0;
for (index = 0; index < size; index++)
{
if (*mem1 != *mem2)
- count++;
+ {
+ error = (*mem1 > *mem2) ? *mem1 - *mem2 : *mem2 - *mem1;
+
+ if (error > margin)
+ count++;
+ }
mem1 += 4;
mem2 += 4;
return count;
}
-static int test_bmp_cmp_dump(const BYTE* actual, const BYTE* expected, int size, int channel)
+static int test_bmp_cmp_dump(const BYTE* actual, const BYTE* expected, int size, int channel, int margin)
{
+ int x, y;
+ int error[3];
UINT32 pixel;
int count = 0;
int index = 0;
Cb = TEST_CB_COMPONENT[index];
Cr = TEST_CR_COMPONENT[index];
- printf("Idx: %d Y: %+5d Cb: %+5d Cr: %+5d Actual: R: %3d G: %3d B: %3d Expected: R: %3d G: %3d B: %3d\n",
- index, Y, Cb, Cr, R, G, B, eR, eG, eB);
+ x = index % 64;
+ y = (index - x) / 64;
- count++;
+ error[0] = (R > eR) ? R - eR : eR - R;
+ error[1] = (G > eG) ? G - eG : eG - G;
+ error[2] = (B > eB) ? B - eB : eB - B;
+
+ if ((error[0] > margin) || (error[1] > margin) || (error[2] > margin))
+ {
+ printf("(%2d,%2d) Y: %+5d Cb: %+5d Cr: %+5d R: %03d/%03d G: %03d/%03d B: %03d/%03d %d %d %d\n",
+ x, y, Y, Cb, Cr, R, eR, G, eG, B, eB, R - eR, G - eG, B - eB);
+ count++;
+ }
}
actual += 4;
static TEST_FP_TYPE TEST_YCbCrToRGB_02[4] = { 1.402525f, 0.343730f, 0.714401f, 1.769905f };
static TEST_FP_TYPE TEST_YCbCrToRGB_03[4] = { 1.402524948120117L, 0.3437300026416779L, 0.7144010066986084L, 1.769904971122742L };
-static INT16 TEST_YCbCr_01[3] = { +115, +1720, -2145 };
-static BYTE TEST_RGB_01[3] = { 37, 161, 227 }; /* incorrect red */
+static INT16 TEST_YCbCr_01[3] = { +3443, -1863, +272 };
+static BYTE TEST_RGB_01[3] = { 247, 249, 132 };
-static INT16 TEST_YCbCr_02[3] = { -450, +1938, -2126 };
-static BYTE TEST_RGB_02[3] = { 21, 140, 221 }; /* incorrect green */
+static INT16 TEST_YCbCr_02[3] = { +1086, +1584, -2268 };
+static BYTE TEST_RGB_02[3] = { 62, 195, 249 };
-static INT16 TEST_YCbCr_03[3] = { -504, +1896, -2168 };
-static BYTE TEST_RGB_03[3] = { 17, 140, 217 }; /* incorrect blue */
+static INT16 TEST_YCbCr_03[3] = { -576, +2002, -2179 };
+static BYTE TEST_RGB_03[3] = { 15, 137, 221 };
int test_YCbCr_fp(TEST_FP_TYPE coeffs[4], INT16 YCbCr[3], BYTE RGB[3])
{
INT16 R, G, B;
TEST_FP_TYPE Y, Cb, Cr;
TEST_FP_TYPE fR, fG, fB;
+ TEST_FP_TYPE fR1, fR2;
Y = (TEST_FP_TYPE) (YCbCr[0] + 4096);
Cb = (TEST_FP_TYPE) (YCbCr[1]);
Cr = (TEST_FP_TYPE) (YCbCr[2]);
#if 1
+ fR1 = Cr * coeffs[0];
+ fR2 = fR1 + Y + 16.0f;
+
fR = ((Cr * coeffs[0]) + Y + 16.0f);
fG = (Y - (Cb * coeffs[1]) - (Cr * coeffs[2]) + 16.0f);
fB = ((Cb * coeffs[3]) + Y + 16.0f);
- printf("fR: %f fG: %f fB: %f\n", fR, fG, fB);
+ printf("fR: %f fG: %f fB: %f fY: %f\n", fR, fG, fB, Y);
R = (INT16) fR;
G = (INT16) fG;
B = (INT16) fB;
+ printf("mR: %d mG: %d mB: %d\n",
+ (R - 16) % 32, (G - 16) % 32, (B - 16) % 32);
+
printf("iR: %d iG: %d iB: %d\n", R, G, B);
R >>= 5;
int TestPrimitivesYCbCr(int argc, char* argv[])
{
int size;
- int cmp[3];
int cnt[3];
float err[3];
BYTE* actual;
BYTE* expected;
+ int margin = 1;
INT16* pYCbCr[3];
const primitives_t* prims = primitives_get();
static const prim_size_t roi_64x64 = { 64, 64 };
test_fill_bitmap_channel(expected, 64, 64, 0, 0); /* blue */
}
- cmp[2] = test_bmp_cmp_offset(actual, expected, size, 2); /* red */
- cnt[2] = test_bmp_cmp_count(actual, expected, size, 2); /* red */
+ cnt[2] = test_bmp_cmp_count(actual, expected, size, 2, margin); /* red */
err[2] = ((float) cnt[2]) / ((float) size / 4) * 100.0f;
- cmp[1] = test_bmp_cmp_offset(actual, expected, size, 1); /* green */
- cnt[1] = test_bmp_cmp_count(actual, expected, size, 1); /* green */
+ cnt[1] = test_bmp_cmp_count(actual, expected, size, 1, margin); /* green */
err[1] = ((float) cnt[1]) / ((float) size / 4) * 100.0f;
- cmp[0] = test_bmp_cmp_offset(actual, expected, size, 0); /* blue */
- cnt[0] = test_bmp_cmp_count(actual, expected, size, 0); /* blue */
+ cnt[0] = test_bmp_cmp_count(actual, expected, size, 0, margin); /* blue */
err[0] = ((float) cnt[0]) / ((float) size / 4) * 100.0f;
- if (0)
+ if (cnt[0] || cnt[1] || cnt[2])
{
printf("Red Error Dump:\n");
- test_bmp_cmp_dump(actual, expected, size, 2); /* red */
+ test_bmp_cmp_dump(actual, expected, size, 2, margin); /* red */
printf("Green Error Dump:\n");
- test_bmp_cmp_dump(actual, expected, size, 1); /* green */
+ test_bmp_cmp_dump(actual, expected, size, 1, margin); /* green */
printf("Blue Error Dump:\n");
- test_bmp_cmp_dump(actual, expected, size, 0); /* blue */
- }
+ test_bmp_cmp_dump(actual, expected, size, 0, margin); /* blue */
- printf("R: diff: %d (%f%%)\n", cnt[2], err[2]);
- printf("G: diff: %d (%f%%)\n", cnt[1], err[1]);
- printf("B: diff: %d (%f%%)\n", cnt[0], err[0]);
+ printf("R: diff: %d (%f%%)\n", cnt[2], err[2]);
+ printf("G: diff: %d (%f%%)\n", cnt[1], err[1]);
+ printf("B: diff: %d (%f%%)\n", cnt[0], err[0]);
+ }
_aligned_free(actual);