Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: third_party/qcms/src/tests/qcms_test_internal_srgb.c

Issue 1779163002: [qcms] Update primaries used to build internal sRGB profile (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add helper functions Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/qcms/src/iccread.c ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the Chromium LICENSE file. 3 // found in the Chromium LICENSE file.
4 4
5 #include "qcms.h" 5 #include "qcms.h"
6 #include "qcms_test_util.h" 6 #include "qcms_test_util.h"
7 7
8 #include <math.h> // sqrt
8 #include <stdio.h> 9 #include <stdio.h>
9 #include <stdint.h> 10 #include <stdint.h>
10 #include <stdlib.h> 11 #include <stdlib.h>
11 12
12 // Colorant matrix for the official sRGB IEC61966-2.1 color (D50) primaries. 13 // D50 adapted color primaries of the internal sRGB color profile.
13 static s15Fixed16Number sRGB_reference[3][3] = { 14 static s15Fixed16Number sRGB_reference[3][3] = {
14 » » {0x06fa2 /*0.436066*/, /*0.385147*/ 0x06299, /*0.143066*/ 0x024 a0}, 15 { 0x06fa0, 0x06296, 0x024a0 }, // ( 0.436035, 0.385101, 0.143066 )
15 » » {0x038f5 /*0.222488*/, /*0.716873*/ 0x0b785, /*0.060608*/ 0x00f 84}, 16 { 0x038f2, 0x0b789, 0x00f85 }, // ( 0.222443, 0.716934, 0.060623 )
16 » » {0x00390 /*0.013916*/, /*0.097076*/ 0x018da, /*0.714096*/ 0x0b6 cf}}; 17 { 0x0038f, 0x018da, 0x0b6c4 }, // ( 0.013901, 0.097076, 0.713928 )
18 };
19
20 // Reference media white point of the sRGB IEC61966-2.1 color profile.
21 static struct XYZNumber D65 = {
22 0xf351, 0x10000, 0x116cc // ( 0.950455, 1.000000, 1.089050 )
23 };
24
25 static float check_profile_pcs_white_point(const qcms_profile *profile)
26 {
27 float rX = s15Fixed16Number_to_float(profile->redColorant.X);
28 float gX = s15Fixed16Number_to_float(profile->greenColorant.X);
29 float bX = s15Fixed16Number_to_float(profile->blueColorant.X);
30 float rY = s15Fixed16Number_to_float(profile->redColorant.Y);
31 float gY = s15Fixed16Number_to_float(profile->greenColorant.Y);
32 float bY = s15Fixed16Number_to_float(profile->blueColorant.Y);
33 float rZ = s15Fixed16Number_to_float(profile->redColorant.Z);
34 float gZ = s15Fixed16Number_to_float(profile->greenColorant.Z);
35 float bZ = s15Fixed16Number_to_float(profile->blueColorant.Z);
36
37 float X = rX + gX + bX;
38 float Y = rY + gY + bY;
39 float Z = rZ + gZ + bZ;
40
41 float x = X / (X + Y + Z);
42 float y = Y / (X + Y + Z);
43
44 printf("Profile White point test: xyY [ %.6f %.6f %.6f ]\n", x, y, Y);
45
46 float xerr = x - 0.345702915;
47 float yerr = y - 0.358538597;
48 float Yerr = Y - 1.000000000;
49
50 return sqrt((xerr * xerr) + (yerr * yerr) + (Yerr * Yerr));
51 }
52
53 static void check_profile_media_white_point(const qcms_profile *profile)
54 {
55 int errX = profile->mediaWhitePoint.X - D65.X;
56 int errY = profile->mediaWhitePoint.Y - D65.Y;
57 int errZ = profile->mediaWhitePoint.Z - D65.Z;
58
59 printf("Internal values = [0x%X, 0x%X, 0x%X]\n",
60 profile->mediaWhitePoint.X, profile->mediaWhitePoint.Y, profile->med iaWhitePoint.Z);
61
62 printf("White point error = [%d, %d, %d]\n\n", errX, errY, errZ);
63 }
64
65 static s15Fixed16Number check_profile_primaries(const qcms_profile *profile)
66 {
67 s15Fixed16Number ret = 0;
68 s15Fixed16Number sRGB_internal[3][3];
69 int i, j;
70
71 sRGB_internal[0][0] = profile->redColorant.X;
72 sRGB_internal[1][0] = profile->redColorant.Y;
73 sRGB_internal[2][0] = profile->redColorant.Z;
74 sRGB_internal[0][1] = profile->greenColorant.X;
75 sRGB_internal[1][1] = profile->greenColorant.Y;
76 sRGB_internal[2][1] = profile->greenColorant.Z;
77 sRGB_internal[0][2] = profile->blueColorant.X;
78 sRGB_internal[1][2] = profile->blueColorant.Y;
79 sRGB_internal[2][2] = profile->blueColorant.Z;
80
81 for (i = 0; i < 3; i++) {
82 for (j = 0; j < 3; j++) {
83 s15Fixed16Number tmp = sRGB_internal[i][j] - sRGB_reference[i][j];
84 printf("\t%d", tmp);
85 ret += abs(tmp);
86 }
87 printf("\n");
88 }
89
90 return ret;
91 }
17 92
18 static int qcms_test_internal_srgb(size_t width, 93 static int qcms_test_internal_srgb(size_t width,
19 » » size_t height, 94 size_t height,
20 » » int iterations, 95 int iterations,
21 » » const char *in_path, 96 const char *in_path,
22 » » const char *out_path, 97 const char *out_path,
23 » » const int force_software) 98 const int force_software)
24 { 99 {
25 » qcms_profile *profile = qcms_profile_sRGB(); 100 qcms_profile *profile = qcms_profile_sRGB();
26 » s15Fixed16Number sRGB_internal[3][3]; 101 s15Fixed16Number primary_error;
27 » s15Fixed16Number diff = 0; 102 float pcs_error;
28 » int i, j;
29 103
30 » printf("Test qcms internal sRGB colorant matrix against official sRGB IE C61966-2.1 color (D50) primaries\n"); 104 if (qcms_profile_is_bogus(profile)) {
105 fprintf(stderr, "Failure: the internal sRGB profile failed the bogus pro file check\n");
106 qcms_profile_release(profile);
107 return -1;
108 }
31 109
32 » sRGB_internal[0][0] = profile->redColorant.X; 110 printf("Test qcms internal sRGB color primaries against sRGB IEC61966-2.1 co lor primaries\n");
33 » sRGB_internal[1][0] = profile->redColorant.Y;
34 » sRGB_internal[2][0] = profile->redColorant.Z;
35 » sRGB_internal[0][1] = profile->greenColorant.X;
36 » sRGB_internal[1][1] = profile->greenColorant.Y;
37 » sRGB_internal[2][1] = profile->greenColorant.Z;
38 » sRGB_internal[0][2] = profile->blueColorant.X;
39 » sRGB_internal[1][2] = profile->blueColorant.Y;
40 » sRGB_internal[2][2] = profile->blueColorant.Z;
41 111
Noel Gordon 2016/03/28 20:55:56 nit: delete this empty line.
radu.velea 2016/03/29 08:44:26 Done.
42 » for (i = 0; i < 3; i++) { 112 primary_error = check_profile_primaries(profile);
43 » » for (j = 0; j < 3; j++) {
44 » » » s15Fixed16Number tmp = sRGB_internal[i][j] - sRGB_refere nce[i][j];
45 » » » printf("\t%d", tmp);
46 » » » diff += abs(tmp);
47 » » }
48 » » printf("\n");
49 » }
50 113
Noel Gordon 2016/03/28 20:55:56 Ditto.
radu.velea 2016/03/29 08:44:26 Done.
51 » qcms_profile_release(profile); 114 printf("Total error = 0x%x [%.6f]\n\n", primary_error, primary_error / 65536 .0);
52 115
53 » printf("Total error = 0x%x [%.6f]\n", diff, diff / 65536.0); 116 printf("Test media white point against expected sRGB IEC61966-2.1 D65 XYZ va lues\n");
117 check_profile_media_white_point(profile);
54 118
Noel Gordon 2016/03/28 20:55:56 Ditto.
radu.velea 2016/03/29 08:44:26 Done.
55 » return diff; 119 printf("Test PCS white point error\n");
120
Noel Gordon 2016/03/28 20:55:56 Ditto.
radu.velea 2016/03/29 08:44:26 Done.
121 // Compute distance from ICC D50 xyY.
122 pcs_error = check_profile_pcs_white_point(profile);
123
Noel Gordon 2016/03/28 20:55:56 Ditto.
radu.velea 2016/03/29 08:44:26 Done.
124 printf("White point error: %.6f\n", pcs_error);
125
126 qcms_profile_release(profile);
127
128 return primary_error;
56 } 129 }
57 130
58 struct qcms_test_case qcms_test_internal_srgb_info = { 131 struct qcms_test_case qcms_test_internal_srgb_info = {
59 » » "qcms_test_internal_srgb", 132 "qcms_test_internal_srgb",
60 » » qcms_test_internal_srgb, 133 qcms_test_internal_srgb,
61 » » QCMS_TEST_DISABLED 134 QCMS_TEST_DISABLED
62 }; 135 };
OLDNEW
« no previous file with comments | « third_party/qcms/src/iccread.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698