Index: third_party/qcms/src/iccread.c |
diff --git a/third_party/qcms/src/iccread.c b/third_party/qcms/src/iccread.c |
index 2e86aa814b8bfcbaea6fe7b9417af4b98612b9d8..6cec34a31c0e5edd1adeffd05a6f563018e96d1f 100644 |
--- a/third_party/qcms/src/iccread.c |
+++ b/third_party/qcms/src/iccread.c |
@@ -356,6 +356,7 @@ static struct tag *find_tag(struct tag_index index, uint32_t tag_id) |
#define DESC_TYPE 0x64657363 // 'desc' |
#define MLUC_TYPE 0x6d6c7563 // 'mluc' |
+#define MMOD_TYPE 0x6D6D6F64 // 'mmod' |
static bool read_tag_descType(qcms_profile *profile, struct mem_source *src, struct tag_index index, uint32_t tag_id) |
{ |
@@ -365,25 +366,25 @@ static bool read_tag_descType(qcms_profile *profile, struct mem_source *src, str |
uint32_t offset = tag->offset; |
uint32_t type = read_u32(src, offset); |
uint32_t length = read_u32(src, offset+8); |
- uint32_t i, description; |
+ uint32_t i, description_offset; |
bool mluc = false; |
if (length && type == MLUC_TYPE) { |
length = read_u32(src, offset+20); |
if (!length || (length & 1) || (read_u32(src, offset+12) != 12)) |
goto invalid_desc_tag; |
- description = offset + read_u32(src, offset+24); |
+ description_offset = offset + read_u32(src, offset+24); |
if (!src->valid) |
goto invalid_desc_tag; |
mluc = true; |
} else if (length && type == DESC_TYPE) { |
- description = offset + 12; |
+ description_offset = offset + 12; |
} else { |
goto invalid_desc_tag; |
} |
if (length >= limit) |
length = limit - 1; |
for (i = 0; i < length; ++i) { |
- uint8_t value = read_u8(src, description+i); |
+ uint8_t value = read_u8(src, description_offset + i); |
if (!src->valid) |
goto invalid_desc_tag; |
if (mluc && !value) |
@@ -405,9 +406,10 @@ invalid_desc_tag: |
#if defined(__APPLE__) |
+// Use the dscm tag to change profile description "Display" to its more specific en-localized monitor name, if any. |
+ |
#define TAG_dscm 0x6473636D // 'dscm' |
-// Use dscm tag to change profile description "Display" to its more specific en-localized monitor name, if any. |
static bool read_tag_dscmType(qcms_profile *profile, struct mem_source *src, struct tag_index index, uint32_t tag_id) |
{ |
if (strcmp(profile->description, "Display") != 0) |
@@ -462,6 +464,40 @@ invalid_dscm_tag: |
return false; |
} |
+// Use the mmod tag to change profile description "Display" to its specific mmod maker model data, if any. |
+ |
+#define TAG_mmod 0x6D6D6F64 // 'mmod' |
+ |
+static bool read_tag_mmodType(qcms_profile *profile, struct mem_source *src, struct tag_index index, uint32_t tag_id) |
+{ |
+ if (strcmp(profile->description, "Display") != 0) |
+ return true; |
+ |
+ struct tag *tag = find_tag(index, tag_id); |
+ if (tag) { |
+ const uint8_t length = 4 * 4; // Four 4-byte fields: 'mmod', 0, maker, model. |
+ |
+ uint32_t offset = tag->offset; |
+ if (tag->size < 40 || read_u32(src, offset) != MMOD_TYPE) |
+ goto invalid_mmod_tag; |
+ |
+ for (uint8_t i = 0; i < length; ++i) { |
+ uint8_t value = read_u8(src, offset + i); |
+ if (!src->valid) |
+ goto invalid_mmod_tag; |
+ profile->description[i] = value ? value : '.'; |
+ } |
+ profile->description[length] = 0; |
+ } |
+ |
+ if (src->valid) |
+ return true; |
+ |
+invalid_mmod_tag: |
+ invalid_source(src, "invalid mmod tag"); |
+ return false; |
+} |
+ |
#endif // __APPLE__ |
#define XYZ_TYPE 0x58595a20 // 'XYZ ' |
@@ -1163,6 +1199,8 @@ qcms_profile* qcms_profile_from_memory(const void *mem, size_t size) |
#if defined(__APPLE__) |
if (!read_tag_dscmType(profile, src, index, TAG_dscm)) |
goto invalid_tag_table; |
+ if (!read_tag_mmodType(profile, src, index, TAG_mmod)) |
+ goto invalid_tag_table; |
#endif // __APPLE__ |
if (find_tag(index, TAG_CHAD)) { |