OLD | NEW |
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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 } | 396 } |
397 | 397 |
398 if (src->valid) | 398 if (src->valid) |
399 return true; | 399 return true; |
400 | 400 |
401 invalid_desc_tag: | 401 invalid_desc_tag: |
402 invalid_source(src, "invalid description"); | 402 invalid_source(src, "invalid description"); |
403 return false; | 403 return false; |
404 } | 404 } |
405 | 405 |
| 406 #if defined(__APPLE__) |
| 407 |
| 408 #define TAG_dscm 0x6473636D // 'dscm' |
| 409 |
| 410 // Use dscm tag to change profile description "Display" to its more specific en-
localized monitor name, if any. |
| 411 static bool read_tag_dscmType(qcms_profile *profile, struct mem_source *src, str
uct tag_index index, uint32_t tag_id) |
| 412 { |
| 413 if (strcmp(profile->description, "Display") != 0) |
| 414 return true; |
| 415 |
| 416 struct tag *tag = find_tag(index, tag_id); |
| 417 if (tag) { |
| 418 uint32_t offset = tag->offset; |
| 419 uint32_t type = read_u32(src, offset); |
| 420 uint32_t records = read_u32(src, offset+8); |
| 421 |
| 422 if (!src->valid || !records || type != MLUC_TYPE) |
| 423 goto invalid_dscm_tag; |
| 424 if (read_u32(src, offset+12) != 12) // MLUC record size: bytes |
| 425 goto invalid_dscm_tag; |
| 426 |
| 427 for (uint32_t i = 0; i < records; ++i) { |
| 428 const uint32_t limit = sizeof profile->description; |
| 429 const uint16_t isoen = 0x656E; // ISO-3166-1 language 'e
n' |
| 430 |
| 431 uint16_t language = read_u16(src, offset + 16 + (i * 12)
+ 0); |
| 432 uint32_t length = read_u32(src, offset + 16 + (i * 12) +
4); |
| 433 uint32_t description_offset = read_u32(src, offset + 16
+ (i * 12) + 8); |
| 434 |
| 435 if (!src->valid || !length || (length & 1)) |
| 436 goto invalid_dscm_tag; |
| 437 if (language != isoen) |
| 438 continue; |
| 439 |
| 440 // Use a prefix to identify the display description sour
ce |
| 441 strcpy(profile->description, "dscm:"); |
| 442 length += 5; |
| 443 |
| 444 if (length >= limit) |
| 445 length = limit - 1; |
| 446 for (uint32_t j = 5; j < length; ++j) { |
| 447 uint8_t value = read_u8(src, offset + descriptio
n_offset + j - 5); |
| 448 if (!src->valid) |
| 449 goto invalid_dscm_tag; |
| 450 profile->description[j] = value ? value : '.'; |
| 451 } |
| 452 profile->description[length] = 0; |
| 453 break; |
| 454 } |
| 455 } |
| 456 |
| 457 if (src->valid) |
| 458 return true; |
| 459 |
| 460 invalid_dscm_tag: |
| 461 invalid_source(src, "invalid dscm tag"); |
| 462 return false; |
| 463 } |
| 464 |
| 465 #endif // __APPLE__ |
| 466 |
406 #define XYZ_TYPE 0x58595a20 // 'XYZ ' | 467 #define XYZ_TYPE 0x58595a20 // 'XYZ ' |
407 #define CURVE_TYPE 0x63757276 // 'curv' | 468 #define CURVE_TYPE 0x63757276 // 'curv' |
408 #define PARAMETRIC_CURVE_TYPE 0x70617261 // 'para' | 469 #define PARAMETRIC_CURVE_TYPE 0x70617261 // 'para' |
409 #define LUT16_TYPE 0x6d667432 // 'mft2' | 470 #define LUT16_TYPE 0x6d667432 // 'mft2' |
410 #define LUT8_TYPE 0x6d667431 // 'mft1' | 471 #define LUT8_TYPE 0x6d667431 // 'mft1' |
411 #define LUT_MAB_TYPE 0x6d414220 // 'mAB ' | 472 #define LUT_MAB_TYPE 0x6d414220 // 'mAB ' |
412 #define LUT_MBA_TYPE 0x6d424120 // 'mBA ' | 473 #define LUT_MBA_TYPE 0x6d424120 // 'mBA ' |
413 #define CHROMATIC_TYPE 0x73663332 // 'sf32' | 474 #define CHROMATIC_TYPE 0x73663332 // 'sf32' |
414 | 475 |
415 static struct matrix read_tag_s15Fixed16ArrayType(struct mem_source *src, struct
tag_index index, uint32_t tag_id) | 476 static struct matrix read_tag_s15Fixed16ArrayType(struct mem_source *src, struct
tag_index index, uint32_t tag_id) |
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1092 | 1153 |
1093 if (!src->valid) | 1154 if (!src->valid) |
1094 goto invalid_profile; | 1155 goto invalid_profile; |
1095 | 1156 |
1096 index = read_tag_table(profile, src); | 1157 index = read_tag_table(profile, src); |
1097 if (!src->valid || !index.tags) | 1158 if (!src->valid || !index.tags) |
1098 goto invalid_tag_table; | 1159 goto invalid_tag_table; |
1099 | 1160 |
1100 if (!read_tag_descType(profile, src, index, TAG_desc)) | 1161 if (!read_tag_descType(profile, src, index, TAG_desc)) |
1101 goto invalid_tag_table; | 1162 goto invalid_tag_table; |
| 1163 #if defined(__APPLE__) |
| 1164 if (!read_tag_dscmType(profile, src, index, TAG_dscm)) |
| 1165 goto invalid_tag_table; |
| 1166 #endif // __APPLE__ |
1102 | 1167 |
1103 if (find_tag(index, TAG_CHAD)) { | 1168 if (find_tag(index, TAG_CHAD)) { |
1104 profile->chromaticAdaption = read_tag_s15Fixed16ArrayType(src, i
ndex, TAG_CHAD); | 1169 profile->chromaticAdaption = read_tag_s15Fixed16ArrayType(src, i
ndex, TAG_CHAD); |
1105 } else { | 1170 } else { |
1106 profile->chromaticAdaption.invalid = true; //Signal the data is
not present | 1171 profile->chromaticAdaption.invalid = true; //Signal the data is
not present |
1107 } | 1172 } |
1108 | 1173 |
1109 if (profile->class == DISPLAY_DEVICE_PROFILE || profile->class == INPUT_
DEVICE_PROFILE || | 1174 if (profile->class == DISPLAY_DEVICE_PROFILE || profile->class == INPUT_
DEVICE_PROFILE || |
1110 profile->class == OUTPUT_DEVICE_PROFILE || profile->class == COLOR_
SPACE_PROFILE) { | 1175 profile->class == OUTPUT_DEVICE_PROFILE || profile->class == COLOR_
SPACE_PROFILE) { |
1111 if (profile->color_space == RGB_SIGNATURE) { | 1176 if (profile->color_space == RGB_SIGNATURE) { |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1277 { | 1342 { |
1278 qcms_profile *profile = NULL; | 1343 qcms_profile *profile = NULL; |
1279 FILE *file = _wfopen(path, L"rb"); | 1344 FILE *file = _wfopen(path, L"rb"); |
1280 if (file) { | 1345 if (file) { |
1281 profile = qcms_profile_from_file(file); | 1346 profile = qcms_profile_from_file(file); |
1282 fclose(file); | 1347 fclose(file); |
1283 } | 1348 } |
1284 return profile; | 1349 return profile; |
1285 } | 1350 } |
1286 #endif | 1351 #endif |
OLD | NEW |