diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2023-05-28 10:11:29 +0200 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2023-05-28 10:13:04 +0200 |
commit | a71069272599888742c70f832898094744ddb6dc (patch) | |
tree | c41b8fded11b71338960644a29105fa5a3dd69d1 | |
parent | 859736e5be7746ef90535754e37a3a8ec87dfd5e (diff) | |
download | fiv-a71069272599888742c70f832898094744ddb6dc.tar.gz fiv-a71069272599888742c70f832898094744ddb6dc.tar.xz fiv-a71069272599888742c70f832898094744ddb6dc.zip |
Clean up namespace pollution
-rw-r--r-- | fiv-io.c | 8 | ||||
-rw-r--r-- | tiffer.h | 63 | ||||
-rw-r--r-- | tools/info.h | 8 |
3 files changed, 42 insertions, 37 deletions
@@ -1197,7 +1197,7 @@ parse_mpf_index_ifd(struct tiffer *T) struct tiffer_entry entry = {}; while (tiffer_next_entry(T, &entry)) { // 5.2.3.3. MP Entry - if (entry.tag == MPF_MPEntry && entry.type == UNDEFINED && + if (entry.tag == MPF_MPEntry && entry.type == TIFFER_UNDEFINED && !(entry.remaining_count % 16)) { return parse_mpf_index_entries(T, &entry); } @@ -2013,13 +2013,13 @@ load_tiff_ep( // In any case, chained TIFFs are relatively rare. struct tiffer_entry entry = {}; bool is_tiffep = tiffer_find(T, TIFF_TIFF_EPStandardID, &entry) && - entry.type == BYTE && entry.remaining_count == 4 && + entry.type == TIFFER_BYTE && entry.remaining_count == 4 && entry.p[0] == 1 && !entry.p[1] && !entry.p[2] && !entry.p[3]; // Apple ProRAW, e.g., does not claim TIFF/EP compatibility, // but we should still be able to make sense of it. bool is_supported_dng = tiffer_find(T, TIFF_DNGBackwardVersion, &entry) && - entry.type == BYTE && entry.remaining_count == 4 && + entry.type == TIFFER_BYTE && entry.remaining_count == 4 && entry.p[0] == 1 && entry.p[1] <= 6 && !entry.p[2] && !entry.p[3]; if (!is_tiffep && !is_supported_dng) { set_error(error, "not a supported TIFF/EP or DNG image"); @@ -3714,7 +3714,7 @@ fiv_io_exif_orientation(const guint8 *tiff, gsize len) while (tiffer_next_entry(&T, &entry)) { int64_t orientation = 0; if (G_UNLIKELY(entry.tag == TIFF_Orientation) && - entry.type == SHORT && entry.remaining_count == 1 && + entry.type == TIFFER_SHORT && entry.remaining_count == 1 && tiffer_integer(&T, &entry, &orientation) && orientation >= 1 && orientation <= 8) return orientation; @@ -170,31 +170,36 @@ tiffer_subifd( } enum tiffer_type { - BYTE = 1, ASCII, SHORT, LONG, RATIONAL, - SBYTE, UNDEFINED, SSHORT, SLONG, SRATIONAL, FLOAT, DOUBLE, - IFD // This last type from TIFF Technical Note 1 isn't really used much. + TIFFER_BYTE = 1, TIFFER_ASCII, TIFFER_SHORT, TIFFER_LONG, + TIFFER_RATIONAL, + TIFFER_SBYTE, TIFFER_UNDEFINED, TIFFER_SSHORT, TIFFER_SLONG, + TIFFER_SRATIONAL, + TIFFER_FLOAT, + TIFFER_DOUBLE, + // This last type from TIFF Technical Note 1 isn't really used much. + TIFFER_IFD, }; static size_t tiffer_value_size(enum tiffer_type type) { switch (type) { - case BYTE: - case SBYTE: - case ASCII: - case UNDEFINED: + case TIFFER_BYTE: + case TIFFER_SBYTE: + case TIFFER_ASCII: + case TIFFER_UNDEFINED: return 1; - case SHORT: - case SSHORT: + case TIFFER_SHORT: + case TIFFER_SSHORT: return 2; - case LONG: - case SLONG: - case FLOAT: - case IFD: + case TIFFER_LONG: + case TIFFER_SLONG: + case TIFFER_FLOAT: + case TIFFER_IFD: return 4; - case RATIONAL: - case SRATIONAL: - case DOUBLE: + case TIFFER_RATIONAL: + case TIFFER_SRATIONAL: + case TIFFER_DOUBLE: return 8; default: return 0; @@ -232,25 +237,25 @@ tiffer_integer( // TIFF 6.0 only directly suggests that a reader is should accept // any of BYTE/SHORT/LONG for unsigned integers. switch (entry->type) { - case BYTE: - case ASCII: - case UNDEFINED: + case TIFFER_BYTE: + case TIFFER_ASCII: + case TIFFER_UNDEFINED: *out = *entry->p; return true; - case SBYTE: + case TIFFER_SBYTE: *out = (int8_t) *entry->p; return true; - case SHORT: + case TIFFER_SHORT: *out = self->un->u16(entry->p); return true; - case SSHORT: + case TIFFER_SSHORT: *out = (int16_t) self->un->u16(entry->p); return true; - case LONG: - case IFD: + case TIFFER_LONG: + case TIFFER_IFD: *out = self->un->u32(entry->p); return true; - case SLONG: + case TIFFER_SLONG: *out = (int32_t) self->un->u32(entry->p); return true; default: @@ -267,11 +272,11 @@ tiffer_rational(const struct tiffer *self, const struct tiffer_entry *entry, // Somewhat excessively lenient, intended for display. switch (entry->type) { - case RATIONAL: + case TIFFER_RATIONAL: *numerator = self->un->u32(entry->p); *denominator = self->un->u32(entry->p + 4); return true; - case SRATIONAL: + case TIFFER_SRATIONAL: *numerator = (int32_t) self->un->u32(entry->p); *denominator = (int32_t) self->un->u32(entry->p + 4); return true; @@ -295,10 +300,10 @@ tiffer_real( // Assuming the host architecture uses IEEE 754. switch (entry->type) { int64_t numerator, denominator; - case FLOAT: + case TIFFER_FLOAT: *out = *(float *) entry->p; return true; - case DOUBLE: + case TIFFER_DOUBLE: *out = *(double *) entry->p; return true; default: diff --git a/tools/info.h b/tools/info.h index 3106ecf..699e434 100644 --- a/tools/info.h +++ b/tools/info.h @@ -193,11 +193,11 @@ parse_exif_entry(jv o, const struct tiffer *T, struct tiffer_entry *entry, double real = 0; if (!entry->remaining_count) { v = jv_null(); - } else if (entry->type == IFD || subentries) { + } else if (entry->type == TIFFER_IFD || subentries) { v = parse_exif_subifds(T, entry, subentries); - } else if (entry->type == ASCII) { + } else if (entry->type == TIFFER_ASCII) { v = parse_exif_extract_sole_array_element(parse_exif_ascii(entry)); - } else if (entry->type == UNDEFINED && !info->values) { + } else if (entry->type == TIFFER_UNDEFINED && !info->values) { // Several Exif entries of UNDEFINED type contain single-byte numbers. v = parse_exif_undefined(entry); } else if (tiffer_real(T, entry, &real)) { @@ -682,7 +682,7 @@ parse_mpf_index_entry(jv o, uint32_t **offsets, const struct tiffer *T, struct tiffer_entry *entry) { // 5.2.3.3. MP Entry - if (entry->tag != MPF_MPEntry || entry->type != UNDEFINED || + if (entry->tag != MPF_MPEntry || entry->type != TIFFER_UNDEFINED || entry->remaining_count % 16) { return parse_exif_entry(o, T, entry, mpf_entries); } |