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

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: 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
« no previous file with comments | « third_party/qcms/README.chromium ('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 /* 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 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 return NO_MEM_PROFILE; 1196 return NO_MEM_PROFILE;
1197 } 1197 }
1198 1198
1199 profile->class = DISPLAY_DEVICE_PROFILE; 1199 profile->class = DISPLAY_DEVICE_PROFILE;
1200 profile->rendering_intent = QCMS_INTENT_PERCEPTUAL; 1200 profile->rendering_intent = QCMS_INTENT_PERCEPTUAL;
1201 profile->color_space = RGB_SIGNATURE; 1201 profile->color_space = RGB_SIGNATURE;
1202 profile->pcs = XYZ_SIGNATURE; 1202 profile->pcs = XYZ_SIGNATURE;
1203 return profile; 1203 return profile;
1204 } 1204 }
1205 1205
1206 qcms_profile* qcms_profile_create_rgb_with_table( 1206 /*unused*/ qcms_profile* qcms_profile_create_rgb_with_table(
radu.velea 2016/03/10 15:08:32 I think there are a lot of unused functions that c
Noel Gordon 2016/03/11 13:53:48 This is can probably go, but in a future CL.
radu.velea 2016/03/11 14:59:58 Done.
1207 qcms_CIE_xyY white_point, 1207 qcms_CIE_xyY white_point,
1208 qcms_CIE_xyYTRIPLE primaries, 1208 qcms_CIE_xyYTRIPLE primaries,
1209 uint16_t *table, int num_entries) 1209 uint16_t *table, int num_entries)
1210 { 1210 {
1211 qcms_profile* profile = qcms_profile_create(); 1211 qcms_profile* profile = qcms_profile_create();
1212 if (!profile) 1212 if (!profile)
1213 return NO_MEM_PROFILE; 1213 return NO_MEM_PROFILE;
1214 1214
1215 if (!set_rgb_colorants(profile, white_point, primaries)) { 1215 if (!set_rgb_colorants(profile, white_point, primaries)) {
1216 qcms_profile_release(profile); 1216 qcms_profile_release(profile);
(...skipping 14 matching lines...) Expand all
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 /*unused*/ qcms_CIE_xyY white_point_from_temp(int temp_K)
radu.velea 2016/03/10 15:08:32 This is an example.
Noel Gordon 2016/03/11 13:53:48 I would retain this code, not remove it, it is use
radu.velea 2016/03/11 14:59:58 OK, but removing the static keyword so it does not
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;
1294 struct XYZNumber D50 = {0xF351, 0x10000, 0x116CC}; // TODO - find actual values.
Noel Gordon 2016/03/11 13:53:48 The values are correct, decoding them gives: 0x0f
radu.velea 2016/03/11 14:59:58 Done.
1295 // D50 white point and colorant matrix for the official sRGB IEC61966-2. 1 color profile.
Noel Gordon 2016/03/11 13:53:48 // sRGB IEC61966-2.1 / Rec.709 color profile prima
radu.velea 2016/03/11 14:59:58 Done.
1296 s15Fixed16Number colorants[3][3] = {
1297 {0x06fa2, 0x06299, 0x024a0},
1298 {0x038f5, 0x0b785, 0x00f84},
1299 {0x00390, 0x018da, 0x0b6cf}};
1293 1300
1294 » qcms_CIE_xyYTRIPLE Rec709Primaries = { 1301 » table = build_sRGB_gamma_table(num_entries);
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 1302
1305 if (!table) 1303 if (!table)
1306 return NO_MEM_PROFILE; 1304 return NO_MEM_PROFILE;
1307 1305
1308 » profile = qcms_profile_create_rgb_with_table(D65, Rec709Primaries, table , 1024); 1306 » profile = qcms_profile_create();
1309 » if (profile) 1307
1310 » » strcpy(profile->description, "sRGB IEC61966-2.1"); 1308 » if (!profile) {
1309 » » free(table);
1310 » » return NO_MEM_PROFILE;
1311 » }
1312
1313 » profile->redTRC = curve_from_table(table, num_entries);
1314 » profile->blueTRC = curve_from_table(table, num_entries);
1315 » profile->greenTRC = curve_from_table(table, num_entries);
1316
1317 » if (!profile->redTRC || !profile->blueTRC || !profile->greenTRC) {
1318 » » free(table);
1319 » » qcms_profile_release(profile);
1320 » » return NO_MEM_PROFILE;
1321 » }
1322
1323 » profile->redColorant.X = colorants[0][0];
Noel Gordon 2016/03/11 13:53:48 colorants -> primaries
radu.velea 2016/03/11 14:59:58 Done.
1324 » profile->redColorant.Y = colorants[1][0];
1325 » profile->redColorant.Z = colorants[2][0];
1326
1327 » profile->greenColorant.X = colorants[0][1];
1328 » profile->greenColorant.Y = colorants[1][1];
1329 » profile->greenColorant.Z = colorants[2][1];
1330
1331 » profile->blueColorant.X = colorants[0][2];
1332 » profile->blueColorant.Y = colorants[1][2];
1333 » profile->blueColorant.Z = colorants[2][2];
1334
1335 » profile->mediaWhitePoint.X = D50.X;
1336 » profile->mediaWhitePoint.Y = D50.Y;
1337 » profile->mediaWhitePoint.Z = D50.Z;
1338
1339 » profile->class = DISPLAY_DEVICE_PROFILE;
1340 » profile->rendering_intent = QCMS_INTENT_PERCEPTUAL;
1341 » profile->color_space = RGB_SIGNATURE;
1342 » profile->pcs = XYZ_SIGNATURE;
1343
1344 » strcpy(profile->description, "sRGB IEC61966-2.1");
1311 1345
1312 free(table); 1346 free(table);
1347
1313 return profile; 1348 return profile;
1314 } 1349 }
1315 1350
1316 /* qcms_profile_from_memory does not hold a reference to the memory passed in */ 1351 /* 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) 1352 qcms_profile* qcms_profile_from_memory(const void *mem, size_t size)
1318 { 1353 {
1319 uint32_t length; 1354 uint32_t length;
1320 struct mem_source source; 1355 struct mem_source source;
1321 struct mem_source *src = &source; 1356 struct mem_source *src = &source;
1322 struct tag_index index; 1357 struct tag_index index;
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
1583 { 1618 {
1584 qcms_profile *profile = NULL; 1619 qcms_profile *profile = NULL;
1585 FILE *file = _wfopen(path, L"rb"); 1620 FILE *file = _wfopen(path, L"rb");
1586 if (file) { 1621 if (file) {
1587 profile = qcms_profile_from_file(file); 1622 profile = qcms_profile_from_file(file);
1588 fclose(file); 1623 fclose(file);
1589 } 1624 }
1590 return profile; 1625 return profile;
1591 } 1626 }
1592 #endif 1627 #endif
OLDNEW
« no previous file with comments | « third_party/qcms/README.chromium ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698