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

Side by Side Diff: third_party/qcms/src/iccread.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: Added internal profile bogus test. Fix D50 -> D65 Created 4 years, 9 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
OLDNEW
1 /* vim: set ts=8 sw=8 noexpandtab: */ 1 /* vim: set ts=8 sw=8 noexpandtab: */
2 // qcms 2 // qcms
3 // Copyright (C) 2009 Mozilla Foundation 3 // Copyright (C) 2009 Mozilla Foundation
4 // Copyright (C) 1998-2007 Marti Maria 4 // Copyright (C) 1998-2007 Marti Maria
5 // 5 //
6 // Permission is hereby granted, free of charge, to any person obtaining 6 // Permission is hereby granted, free of charge, to any person obtaining
7 // a copy of this software and associated documentation files (the "Software"), 7 // a copy of this software and associated documentation files (the "Software"),
8 // to deal in the Software without restriction, including without limitation 8 // to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 // and/or sell copies of the Software, and to permit persons to whom the Softwar e 10 // and/or sell copies of the Software, and to permit persons to whom the Softwar e
(...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 profile->color_space = RGB_SIGNATURE; 1231 profile->color_space = RGB_SIGNATURE;
1232 profile->pcs = XYZ_SIGNATURE; 1232 profile->pcs = XYZ_SIGNATURE;
1233 return profile; 1233 return profile;
1234 } 1234 }
1235 1235
1236 /* from lcms: cmsWhitePointFromTemp */ 1236 /* from lcms: cmsWhitePointFromTemp */
1237 /* tempK must be >= 4000. and <= 25000. 1237 /* tempK must be >= 4000. and <= 25000.
1238 * Invalid values of tempK will return 1238 * Invalid values of tempK will return
1239 * (x,y,Y) = (-1.0, -1.0, -1.0) 1239 * (x,y,Y) = (-1.0, -1.0, -1.0)
1240 * similar to argyll: icx_DTEMP2XYZ() */ 1240 * similar to argyll: icx_DTEMP2XYZ() */
1241 static qcms_CIE_xyY white_point_from_temp(int temp_K) 1241 qcms_CIE_xyY white_point_from_temp(int temp_K)
1242 { 1242 {
1243 qcms_CIE_xyY white_point; 1243 qcms_CIE_xyY white_point;
1244 double x, y; 1244 double x, y;
1245 double T, T2, T3; 1245 double T, T2, T3;
1246 // double M1, M2; 1246 // double M1, M2;
1247 1247
1248 // No optimization provided. 1248 // No optimization provided.
1249 T = temp_K; 1249 T = temp_K;
1250 T2 = T*T; // Square 1250 T2 = T*T; // Square
1251 T3 = T2*T; // Cube 1251 T3 = T2*T; // Cube
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 white_point.y = y; 1283 white_point.y = y;
1284 white_point.Y = 1.0; 1284 white_point.Y = 1.0;
1285 1285
1286 return white_point; 1286 return white_point;
1287 } 1287 }
1288 1288
1289 qcms_profile* qcms_profile_sRGB(void) 1289 qcms_profile* qcms_profile_sRGB(void)
1290 { 1290 {
1291 qcms_profile *profile; 1291 qcms_profile *profile;
1292 uint16_t *table; 1292 uint16_t *table;
1293 int num_entries = 1024;
Noel Gordon 2016/03/11 15:20:44 remove this.
radu.velea 2016/03/11 15:32:02 Done.
1294 // Standard Illuminant D65 in XYZ coordinates, which is the standard
Noel Gordon 2016/03/11 15:19:20 space before this line.
radu.velea 2016/03/11 15:32:02 Done.
1295 // sRGB IEC61966-2.1 / Rec.709 profile reference media white point.
1296 struct XYZNumber D65 = {
1297 0xf351, 0x10000, 0x116cc // ( 0.950455, 1.000000, 1.0890 50 )
1298 };
1299 // sRGB IEC61966-2.1 / Rec.709 color profile primaries, chromatically
Noel Gordon 2016/03/11 15:19:21 space before this line.
radu.velea 2016/03/11 15:32:02 Done.
1300 // adapted (via Bradford procedures) to the ICC PCS white point, D50.
1301 s15Fixed16Number primaries[3][3] = {
1302 { 0x06fa2, 0x06299, 0x024a0 }, // ( 0.436066, 0.385147, 0.143066 )
1303 { 0x038f5, 0x0b785, 0x00f84 }, // ( 0.222488, 0.716873, 0.060608 )
1304 { 0x00390, 0x018da, 0x0b6cf }, // ( 0.013916, 0.097076, 0.714096 )
1305 };
1293 1306
1294 » qcms_CIE_xyYTRIPLE Rec709Primaries = { 1307 » table = build_sRGB_gamma_table(num_entries);
Noel Gordon 2016/03/11 15:20:44 No need to change this line.
radu.velea 2016/03/11 15:32:01 Done.
1295 » » {0.6400, 0.3300, 1.0},
1296 » » {0.3000, 0.6000, 1.0},
1297 » » {0.1500, 0.0600, 1.0}
1298 » };
1299 » qcms_CIE_xyY D65;
1300
1301 » D65 = white_point_from_temp(6504);
1302
1303 » table = build_sRGB_gamma_table(1024);
1304 1308
1305 if (!table) 1309 if (!table)
1306 return NO_MEM_PROFILE; 1310 return NO_MEM_PROFILE;
1307 1311
1308 » profile = qcms_profile_create_rgb_with_table(D65, Rec709Primaries, table , 1024); 1312 » profile = qcms_profile_create();
1309 » if (profile) 1313
1310 » » strcpy(profile->description, "sRGB IEC61966-2.1"); 1314 » if (!profile) {
1315 » » free(table);
1316 » » return NO_MEM_PROFILE;
1317 » }
1318
1319 » profile->redTRC = curve_from_table(table, num_entries);
1320 » profile->blueTRC = curve_from_table(table, num_entries);
1321 » profile->greenTRC = curve_from_table(table, num_entries);
1322
1323 » if (!profile->redTRC || !profile->blueTRC || !profile->greenTRC) {
1324 » » free(table);
1325 » » qcms_profile_release(profile);
1326 » » return NO_MEM_PROFILE;
1327 » }
1328
1329 » profile->redColorant.X = primaries[0][0];
1330 » profile->redColorant.Y = primaries[1][0];
1331 » profile->redColorant.Z = primaries[2][0];
1332
1333 » profile->greenColorant.X = primaries[0][1];
1334 » profile->greenColorant.Y = primaries[1][1];
1335 » profile->greenColorant.Z = primaries[2][1];
1336
1337 » profile->blueColorant.X = primaries[0][2];
1338 » profile->blueColorant.Y = primaries[1][2];
1339 » profile->blueColorant.Z = primaries[2][2];
1340
1341 » profile->mediaWhitePoint.X = D65.X;
1342 » profile->mediaWhitePoint.Y = D65.Y;
1343 » profile->mediaWhitePoint.Z = D65.Z;
1344
1345 » profile->class = DISPLAY_DEVICE_PROFILE;
1346 » profile->rendering_intent = QCMS_INTENT_PERCEPTUAL;
1347 » profile->color_space = RGB_SIGNATURE;
1348 » profile->pcs = XYZ_SIGNATURE;
1349
1350 » strcpy(profile->description, "sRGB IEC61966-2.1");
1311 1351
1312 free(table); 1352 free(table);
1353
1313 return profile; 1354 return profile;
1314 } 1355 }
1315 1356
1316 /* qcms_profile_from_memory does not hold a reference to the memory passed in */ 1357 /* qcms_profile_from_memory does not hold a reference to the memory passed in */
1317 qcms_profile* qcms_profile_from_memory(const void *mem, size_t size) 1358 qcms_profile* qcms_profile_from_memory(const void *mem, size_t size)
1318 { 1359 {
1319 uint32_t length; 1360 uint32_t length;
1320 struct mem_source source; 1361 struct mem_source source;
1321 struct mem_source *src = &source; 1362 struct mem_source *src = &source;
1322 struct tag_index index; 1363 struct tag_index index;
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
1583 { 1624 {
1584 qcms_profile *profile = NULL; 1625 qcms_profile *profile = NULL;
1585 FILE *file = _wfopen(path, L"rb"); 1626 FILE *file = _wfopen(path, L"rb");
1586 if (file) { 1627 if (file) {
1587 profile = qcms_profile_from_file(file); 1628 profile = qcms_profile_from_file(file);
1588 fclose(file); 1629 fclose(file);
1589 } 1630 }
1590 return profile; 1631 return profile;
1591 } 1632 }
1592 #endif 1633 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698