Chromium Code Reviews| Index: third_party/qcms/src/tests/qcms_test_internal_srgb.c |
| diff --git a/third_party/qcms/src/tests/qcms_test_internal_srgb.c b/third_party/qcms/src/tests/qcms_test_internal_srgb.c |
| index 58855a1b6c924edcc0c4a50a1f42afdbf5f5d731..005d2788589f8bdb88a62348371a86f8a7833407 100644 |
| --- a/third_party/qcms/src/tests/qcms_test_internal_srgb.c |
| +++ b/third_party/qcms/src/tests/qcms_test_internal_srgb.c |
| @@ -5,58 +5,99 @@ |
| #include "qcms.h" |
| #include "qcms_test_util.h" |
| +#include <math.h> // sqrt |
| #include <stdio.h> |
| #include <stdint.h> |
| #include <stdlib.h> |
| -// Colorant matrix for the official sRGB IEC61966-2.1 color (D50) primaries. |
| +// D50 adapted color primaries of the sRGB IEC61966-2.1 color profile. |
|
Noel Gordon
2016/03/25 09:43:11
D50 adapted color primaries of the internal sRGB c
radu.velea
2016/03/25 10:02:50
Done.
|
| static s15Fixed16Number sRGB_reference[3][3] = { |
| - {0x06fa2 /*0.436066*/, /*0.385147*/ 0x06299, /*0.143066*/ 0x024a0}, |
| - {0x038f5 /*0.222488*/, /*0.716873*/ 0x0b785, /*0.060608*/ 0x00f84}, |
| - {0x00390 /*0.013916*/, /*0.097076*/ 0x018da, /*0.714096*/ 0x0b6cf}}; |
| + { 0x06fa0, 0x06296, 0x024a0 }, // ( 0.436035, 0.385101, 0.143066 ) |
| + { 0x038f2, 0x0b789, 0x00f85 }, // ( 0.222443, 0.716934, 0.060623 ) |
| + { 0x0038f, 0x018da, 0x0b6c4 }, // ( 0.013901, 0.097076, 0.713928 ) |
| +}; |
| + |
| +// Reference media white point of the sRGB IEC61966-2.1 color profile. |
| +static struct XYZNumber D65 = { |
| + 0xf351, 0x10000, 0x116cc // ( 0.950455, 1.000000, 1.089050 ) |
| +}; |
| static int qcms_test_internal_srgb(size_t width, |
| - size_t height, |
| - int iterations, |
| - const char *in_path, |
| - const char *out_path, |
| - const int force_software) |
| + size_t height, |
| + int iterations, |
| + const char *in_path, |
| + const char *out_path, |
| + const int force_software) |
| { |
| - qcms_profile *profile = qcms_profile_sRGB(); |
| - s15Fixed16Number sRGB_internal[3][3]; |
| - s15Fixed16Number diff = 0; |
| - int i, j; |
| - |
| - printf("Test qcms internal sRGB colorant matrix against official sRGB IEC61966-2.1 color (D50) primaries\n"); |
| - |
| - sRGB_internal[0][0] = profile->redColorant.X; |
| - sRGB_internal[1][0] = profile->redColorant.Y; |
| - sRGB_internal[2][0] = profile->redColorant.Z; |
| - sRGB_internal[0][1] = profile->greenColorant.X; |
| - sRGB_internal[1][1] = profile->greenColorant.Y; |
| - sRGB_internal[2][1] = profile->greenColorant.Z; |
| - sRGB_internal[0][2] = profile->blueColorant.X; |
| - sRGB_internal[1][2] = profile->blueColorant.Y; |
| - sRGB_internal[2][2] = profile->blueColorant.Z; |
| - |
| - for (i = 0; i < 3; i++) { |
| - for (j = 0; j < 3; j++) { |
| - s15Fixed16Number tmp = sRGB_internal[i][j] - sRGB_reference[i][j]; |
| - printf("\t%d", tmp); |
| - diff += abs(tmp); |
| - } |
| - printf("\n"); |
| - } |
| - |
| - qcms_profile_release(profile); |
| - |
| - printf("Total error = 0x%x [%.6f]\n", diff, diff / 65536.0); |
| - |
| - return diff; |
| + qcms_profile *profile = qcms_profile_sRGB(); |
| + s15Fixed16Number sRGB_internal[3][3]; |
| + s15Fixed16Number diff = 0; |
| + float X, Y, Z; |
| + float x, y; |
| + float xerr, yerr, Yerr; |
| + float error; |
| + int i, j; |
| + |
| + if (qcms_profile_is_bogus(profile)) { |
| + fprintf(stderr, "Failure: the internal sRGB profile failed the bogus profile check\n"); |
| + qcms_profile_release(profile); |
| + return -1; |
| + } |
| + |
| + printf("Test qcms internal sRGB color primaries against sRGB IEC61966-2.1 color primaries\n"); |
| + |
| + sRGB_internal[0][0] = profile->redColorant.X; |
| + sRGB_internal[1][0] = profile->redColorant.Y; |
| + sRGB_internal[2][0] = profile->redColorant.Z; |
| + sRGB_internal[0][1] = profile->greenColorant.X; |
| + sRGB_internal[1][1] = profile->greenColorant.Y; |
| + sRGB_internal[2][1] = profile->greenColorant.Z; |
| + sRGB_internal[0][2] = profile->blueColorant.X; |
| + sRGB_internal[1][2] = profile->blueColorant.Y; |
| + sRGB_internal[2][2] = profile->blueColorant.Z; |
| + |
| + for (i = 0; i < 3; i++) { |
| + for (j = 0; j < 3; j++) { |
| + s15Fixed16Number tmp = sRGB_internal[i][j] - sRGB_reference[i][j]; |
| + printf("\t%d", tmp); |
| + diff += abs(tmp); |
| + } |
| + printf("\n"); |
| + } |
| + |
| + printf("Total error = 0x%x [%.6f]\n\n", diff, diff / 65536.0); |
| + |
| + printf("Test media white point against expected sRGB IEC61966-2.1 D65 XYZ values\n"); |
| + printf("Internal values = [0x%X, 0x%X, 0x%X]\n", |
| + profile->mediaWhitePoint.X, profile->mediaWhitePoint.Y, profile->mediaWhitePoint.Z); |
| + |
| + printf("White point error = [%d, %d, %d]\n\n", |
| + profile->mediaWhitePoint.X - D65.X, profile->mediaWhitePoint.Y - D65.Y, profile->mediaWhitePoint.Z - D65.Z); |
| + |
| + // Compute distance from ICC D50 xyY. |
| + X = s15Fixed16Number_to_float(profile->redColorant.X + profile->greenColorant.X + profile->blueColorant.X); |
|
Noel Gordon
2016/03/25 09:43:11
You should make Compute distance from ICC D50 xyY
radu.velea
2016/03/25 10:02:50
Done.
|
| + Y = s15Fixed16Number_to_float(profile->redColorant.Y + profile->greenColorant.Y + profile->blueColorant.Y); |
| + Z = s15Fixed16Number_to_float(profile->redColorant.Z + profile->greenColorant.Z + profile->blueColorant.Z); |
| + |
| + x = X / (X + Y + Z); |
| + y = Y / (X + Y + Z); |
| + |
| + xerr = x - 0.345702915; |
| + yerr = y - 0.358538597; |
| + Yerr = Y - 1.000000000; |
| + error = sqrt((xerr * xerr) + (yerr * yerr) + (Yerr * Yerr)); |
| + |
| + printf("Test PCS white point error\n"); |
| + printf("Profile White point test: xyY [ %.6f %f.6 %.6f ]\n", x, y, Y); |
| + printf("White point error: %.6f\n", error); |
| + |
| + qcms_profile_release(profile); |
| + |
| + return diff; |
| } |
| struct qcms_test_case qcms_test_internal_srgb_info = { |
| - "qcms_test_internal_srgb", |
| - qcms_test_internal_srgb, |
| - QCMS_TEST_DISABLED |
| + "qcms_test_internal_srgb", |
| + qcms_test_internal_srgb, |
| + QCMS_TEST_DISABLED |
| }; |