diff options
Diffstat (limited to 'src/libexif/canon')
-rw-r--r-- | src/libexif/canon/exif-mnote-data-canon.c | 168 | ||||
-rw-r--r-- | src/libexif/canon/exif-mnote-data-canon.h | 7 | ||||
-rw-r--r-- | src/libexif/canon/mnote-canon-entry.c | 1061 | ||||
-rw-r--r-- | src/libexif/canon/mnote-canon-entry.h | 5 | ||||
-rw-r--r-- | src/libexif/canon/mnote-canon-tag.c | 134 | ||||
-rw-r--r-- | src/libexif/canon/mnote-canon-tag.h | 17 |
6 files changed, 873 insertions, 519 deletions
diff --git a/src/libexif/canon/exif-mnote-data-canon.c b/src/libexif/canon/exif-mnote-data-canon.c index b1c5dab..2783d15 100644 --- a/src/libexif/canon/exif-mnote-data-canon.c +++ b/src/libexif/canon/exif-mnote-data-canon.c @@ -1,7 +1,7 @@ /* exif-mnote-data-canon.c * - * Copyright © 2002, 2003 Lutz Müller <lutz@users.sourceforge.net> - * Copyright © 2003 Matthieu Castet <mat-c@users.sourceforge.net> + * Copyright (c) 2002, 2003 Lutz Mueller <lutz@users.sourceforge.net> + * Copyright (c) 2003 Matthieu Castet <mat-c@users.sourceforge.net> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -60,14 +60,33 @@ exif_mnote_data_canon_free (ExifMnoteData *n) exif_mnote_data_canon_clear ((ExifMnoteDataCanon *) n); } +static void +exif_mnote_data_canon_get_tags (ExifMnoteDataCanon *dc, unsigned int n, + unsigned int *m, unsigned int *s) +{ + unsigned int from = 0, to; + + if (!dc || !m) return; + for (*m = 0; *m < dc->count; (*m)++) { + to = from + mnote_canon_entry_count_values (&dc->entries[*m]); + if (to > n) { + if (s) *s = n - from; + break; + } + from = to; + } +} + static char * exif_mnote_data_canon_get_value (ExifMnoteData *note, unsigned int n, char *val, unsigned int maxlen) { - ExifMnoteDataCanon *cnote = (ExifMnoteDataCanon *) note; + ExifMnoteDataCanon *dc = (ExifMnoteDataCanon *) note; + unsigned int m, s; - if (!note) return NULL; - if (cnote->count <= n) return NULL; - return mnote_canon_entry_get_value (&cnote->entries[n], val, maxlen); + if (!dc) return NULL; + exif_mnote_data_canon_get_tags (dc, n, &m, &s); + if (m >= dc->count) return NULL; + return mnote_canon_entry_get_value (&dc->entries[m], s, val, maxlen); } static void @@ -99,7 +118,9 @@ exif_mnote_data_canon_save (ExifMnoteData *ne, unsigned char **buf, unsigned int *buf_size) { ExifMnoteDataCanon *n = (ExifMnoteDataCanon *) ne; - unsigned int i, o, s, doff; + size_t i, o, s, doff; + unsigned char *t; + size_t ts; if (!n || !buf || !buf_size) return; @@ -124,14 +145,22 @@ exif_mnote_data_canon_save (ExifMnoteData *ne, o += 8; s = exif_format_get_size (n->entries[i].format) * n->entries[i].components; + if (s > 65536) { + /* Corrupt data: EXIF data size is limited to the + * maximum size of a JPEG segment (64 kb). + */ + continue; + } if (s > 4) { - *buf_size += s; + ts = *buf_size + s; /* Ensure even offsets. Set padding bytes to 0. */ - if (s & 1) *buf_size += 1; - *buf = exif_mem_realloc (ne->mem, *buf, - sizeof (char) * *buf_size); - if (!*buf) return; + if (s & 1) ts += 1; + t = exif_mem_realloc (ne->mem, *buf, + sizeof (char) * ts); + if (!t) return; + *buf = t; + *buf_size = ts; doff = *buf_size - s; if (s & 1) { doff--; *(*buf + *buf_size - 1) = '\0'; } exif_set_long (*buf + o, n->order, n->offset + doff); @@ -166,7 +195,8 @@ exif_mnote_data_canon_load (ExifMnoteData *ne, { ExifMnoteDataCanon *n = (ExifMnoteDataCanon *) ne; ExifShort c; - unsigned int i, o, s; + size_t i, o, s; + MnoteCanonEntry *t; if (!n || !buf || !buf_size || (buf_size < 6 + n->offset + 2)) return; @@ -176,86 +206,102 @@ exif_mnote_data_canon_load (ExifMnoteData *ne, /* Parse the entries */ for (i = 0; i < c; i++) { - o = 6 + 2 + n->offset + 12 * i; - if (o + 8 > buf_size) return; - - n->count = i + 1; - n->entries = exif_mem_realloc (ne->mem, n->entries, - sizeof (MnoteCanonEntry) * (i+1)); - memset (&n->entries[i], 0, sizeof (MnoteCanonEntry)); - n->entries[i].tag = exif_get_short (buf + o, n->order); - n->entries[i].format = exif_get_short (buf + o + 2, n->order); - n->entries[i].components = exif_get_long (buf + o + 4, n->order); - n->entries[i].order = n->order; - - /* - * Size? If bigger than 4 bytes, the actual data is not - * in the entry but somewhere else (offset). - */ - s = exif_format_get_size (n->entries[i].format) * - n->entries[i].components; - if (!s) return; - o += 8; - if (s > 4) o = exif_get_long (buf + o, n->order) + 6; - if (o + s > buf_size) return; - - /* Sanity check */ - n->entries[i].data = exif_mem_alloc (ne->mem, sizeof (char) * s); - if (!n->entries[i].data) return; - n->entries[i].size = s; - memcpy (n->entries[i].data, buf + o, s); + o = 6 + 2 + n->offset + 12 * i; + if (o + 8 > buf_size) return; + + t = exif_mem_realloc (ne->mem, n->entries, + sizeof (MnoteCanonEntry) * (i + 1)); + if (!t) return; + n->count = i + 1; + n->entries = t; + memset (&n->entries[i], 0, sizeof (MnoteCanonEntry)); + n->entries[i].tag = exif_get_short (buf + o, n->order); + n->entries[i].format = exif_get_short (buf + o + 2, n->order); + n->entries[i].components = exif_get_long (buf + o + 4, n->order); + n->entries[i].order = n->order; + + /* + * Size? If bigger than 4 bytes, the actual data is not + * in the entry but somewhere else (offset). + */ + s = exif_format_get_size (n->entries[i].format) * n->entries[i].components; + if (!s) return; + o += 8; + if (s > 4) o = exif_get_long (buf + o, n->order) + 6; + if (o + s > buf_size) return; + + /* Sanity check */ + n->entries[i].data = exif_mem_alloc (ne->mem, sizeof (char) * s); + if (!n->entries[i].data) return; + n->entries[i].size = s; + memcpy (n->entries[i].data, buf + o, s); } } static unsigned int exif_mnote_data_canon_count (ExifMnoteData *n) { - return n ? ((ExifMnoteDataCanon *) n)->count : 0; + ExifMnoteDataCanon *dc = (ExifMnoteDataCanon *) n; + unsigned int i, c; + + for (i = c = 0; dc && (i < dc->count); i++) + c += mnote_canon_entry_count_values (&dc->entries[i]); + return c; } static unsigned int -exif_mnote_data_canon_get_id (ExifMnoteData *d, unsigned int n) +exif_mnote_data_canon_get_id (ExifMnoteData *d, unsigned int i) { - ExifMnoteDataCanon *note = (ExifMnoteDataCanon *) d; + ExifMnoteDataCanon *dc = (ExifMnoteDataCanon *) d; + unsigned int m; - if (!note) return 0; - if (note->count <= n) return 0; - return note->entries[n].tag; + if (!dc) return 0; + exif_mnote_data_canon_get_tags (dc, i, &m, NULL); + if (m >= dc->count) return 0; + return dc->entries[m].tag; } static const char * exif_mnote_data_canon_get_name (ExifMnoteData *note, unsigned int i) { - ExifMnoteDataCanon *cnote = (ExifMnoteDataCanon *) note; + ExifMnoteDataCanon *dc = (ExifMnoteDataCanon *) note; + unsigned int m, s; - if (!note) return NULL; - if (i >= cnote->count) return NULL; - return mnote_canon_tag_get_name (cnote->entries[i].tag); + if (!dc) return NULL; + exif_mnote_data_canon_get_tags (dc, i, &m, &s); + if (m >= dc->count) return NULL; + return mnote_canon_tag_get_name_sub (dc->entries[m].tag, s, dc->options); } static const char * exif_mnote_data_canon_get_title (ExifMnoteData *note, unsigned int i) { - ExifMnoteDataCanon *cnote = (ExifMnoteDataCanon *) note; + ExifMnoteDataCanon *dc = (ExifMnoteDataCanon *) note; + unsigned int m, s; - if (!note) return NULL; - if (i >= cnote->count) return NULL; - return mnote_canon_tag_get_title (cnote->entries[i].tag); + if (!dc) return NULL; + exif_mnote_data_canon_get_tags (dc, i, &m, &s); + if (m >= dc->count) return NULL; + return mnote_canon_tag_get_title_sub (dc->entries[m].tag, s, dc->options); } static const char * exif_mnote_data_canon_get_description (ExifMnoteData *note, unsigned int i) { - ExifMnoteDataCanon *cnote = (ExifMnoteDataCanon *) note; - if (!note) return NULL; - if (i >= cnote->count) return NULL; - return mnote_canon_tag_get_description (cnote->entries[i].tag); + ExifMnoteDataCanon *dc = (ExifMnoteDataCanon *) note; + unsigned int m; + + if (!dc) return NULL; + exif_mnote_data_canon_get_tags (dc, i, &m, NULL); + if (m >= dc->count) return NULL; + return mnote_canon_tag_get_description (dc->entries[m].tag); } ExifMnoteData * -exif_mnote_data_canon_new (ExifMem *mem) +exif_mnote_data_canon_new (ExifMem *mem, ExifDataOption o) { ExifMnoteData *d; + ExifMnoteDataCanon *dc; if (!mem) return NULL; @@ -277,5 +323,7 @@ exif_mnote_data_canon_new (ExifMem *mem) d->methods.get_description = exif_mnote_data_canon_get_description; d->methods.get_value = exif_mnote_data_canon_get_value; + dc = (ExifMnoteDataCanon*)d; + dc->options = o; return d; } diff --git a/src/libexif/canon/exif-mnote-data-canon.h b/src/libexif/canon/exif-mnote-data-canon.h index a476ca0..6d46432 100644 --- a/src/libexif/canon/exif-mnote-data-canon.h +++ b/src/libexif/canon/exif-mnote-data-canon.h @@ -1,6 +1,6 @@ /* exif-mnote-data-canon.h * - * Copyright © 2002, 2003 Lutz Müller <lutz@users.sourceforge.net> + * Copyright (c) 2002, 2003 Lutz Mueller <lutz@users.sourceforge.net> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -25,6 +25,7 @@ #include <libexif/exif-mnote-data.h> #include <libexif/exif-mnote-data-priv.h> #include <libexif/exif-mem.h> +#include <libexif/exif-data.h> typedef struct _ExifMnoteDataCanon ExifMnoteDataCanon; @@ -38,8 +39,10 @@ struct _ExifMnoteDataCanon { ExifByteOrder order; unsigned int offset; + + ExifDataOption options; }; -ExifMnoteData *exif_mnote_data_canon_new (ExifMem *mem); +ExifMnoteData *exif_mnote_data_canon_new (ExifMem *mem, ExifDataOption o); #endif /* __EXIF_MNOTE_DATA_CANON_H__ */ diff --git a/src/libexif/canon/mnote-canon-entry.c b/src/libexif/canon/mnote-canon-entry.c index 5fa4991..2a206de 100644 --- a/src/libexif/canon/mnote-canon-entry.c +++ b/src/libexif/canon/mnote-canon-entry.c @@ -1,7 +1,7 @@ /* mnote-canon-entry.c * - * Copyright © 2002 Lutz Müller <lutz@users.sourceforge.net> - * Copyright © 2003 Matthieu Castet <mat-c@users.sourceforge.net> + * Copyright (c) 2002 Lutz Mueller <lutz@users.sourceforge.net> + * Copyright (c) 2003 Matthieu Castet <mat-c@users.sourceforge.net> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -25,6 +25,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <math.h> #include <libexif/exif-format.h> #include <libexif/exif-utils.h> @@ -32,9 +33,6 @@ /* #define DEBUG */ -#undef MIN -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) - #define CF(format,target,v,maxlen) \ { \ if (format != target) { \ @@ -67,470 +65,637 @@ } \ } +#define UNDEFINED 0xFF + +static const struct canon_entry_table_t { + unsigned int subtag; + ExifShort value; + const char *name; +} entries_settings_1 [] = { +#ifndef NO_VERBOSE_TAG_DATA + { 0, 1, N_("Macro")}, + { 0, 2, N_("Normal")}, + { 2, 1, N_("Economy")}, + { 2, 2, N_("Normal")}, + { 2, 3, N_("Fine")}, + { 2, 4, N_("RAW")}, + { 2, 5, N_("Superfine")}, + { 3, 0, N_("Off")}, + { 3, 1, N_("Auto")}, + { 3, 2, N_("On")}, + { 3, 3, N_("Red-eye reduction")}, + { 3, 4, N_("Slow synchro")}, + { 3, 5, N_("Auto + Red-eye reduction")}, + { 3, 6, N_("On + Red-eye reduction")}, + { 3, 16, N_("External flash")}, + { 4, 0, N_("Single")}, + { 4, 1, N_("Continuous")}, + { 4, 2, N_("Movie")}, + { 4, 3, N_("Continuous, speed priority")}, + { 4, 4, N_("Continuous, low")}, + { 4, 5, N_("Continuous, high")}, + { 6, 0, N_("One-shot AF")}, + { 6, 1, N_("AI servo AF")}, + { 6, 2, N_("AI focus AF")}, + { 6, 3, N_("Manual focus")}, + { 6, 4, N_("Single")}, + { 6, 5, N_("Continuous")}, + { 6, 6, N_("Manual focus")}, + { 6, 16, N_("Pan focus")}, + { 8, 1, N_("JPEG")}, + { 8, 2, N_("CRW+THM")}, + { 8, 3, N_("AVI+THM")}, + { 8, 4, N_("TIF")}, + { 8, 5, N_("TIF+JPEG")}, + { 8, 6, N_("CR2")}, + { 8, 7, N_("CR2+JPEG")}, + { 9, 0, N_("Large")}, + { 9, 1, N_("Medium")}, + { 9, 2, N_("Small")}, + { 9, 5, N_("Medium 1")}, + { 9, 6, N_("Medium 2")}, + { 9, 7, N_("Medium 3")}, + { 9, 8, N_("Postcard")}, + { 9, 9, N_("Widescreen")}, + {10, 0, N_("Full auto")}, + {10, 1, N_("Manual")}, + {10, 2, N_("Landscape")}, + {10, 3, N_("Fast shutter")}, + {10, 4, N_("Slow shutter")}, + {10, 5, N_("Night")}, + {10, 6, N_("Grayscale")}, + {10, 7, N_("Sepia")}, + {10, 8, N_("Portrait")}, + {10, 9, N_("Sports")}, + {10, 10, N_("Macro")}, + {10, 11, N_("Black & white")}, + {10, 12, N_("Pan focus")}, + {10, 13, N_("Vivid")}, + {10, 14, N_("Neutral")}, + {10, 15, N_("Flash off")}, + {10, 16, N_("Long shutter")}, + {10, 17, N_("Super macro")}, + {10, 18, N_("Foliage")}, + {10, 19, N_("Indoor")}, + {10, 20, N_("Fireworks")}, + {10, 21, N_("Beach")}, + {10, 22, N_("Underwater")}, + {10, 23, N_("Snow")}, + {10, 24, N_("Kids & pets")}, + {10, 25, N_("Night snapshot")}, + {10, 26, N_("Digital macro")}, + {10, 27, N_("My colors")}, + {10, 28, N_("Still image")}, + {10, 30, N_("Color accent")}, + {10, 31, N_("Color swap")}, + {10, 32, N_("Aquarium")}, + {10, 33, N_("ISO 3200")}, + {11, 0, N_("None")}, + {11, 1, N_("2x")}, + {11, 2, N_("4x")}, + {11, 3, N_("Other")}, + {12, 0x0000, N_("Normal")}, + {12, 0x0001, N_("High")}, + {12, 0xffff, N_("Low")}, + {13, 0x0000, N_("Normal")}, + {13, 0x0001, N_("High")}, + {13, 0xffff, N_("Low")}, + {14, 0x0000, N_("Normal")}, + {14, 0x0001, N_("High")}, + {14, 0xffff, N_("Low")}, + {15, 14, N_("Auto high")}, + {15, 15, N_("Auto")}, + {15, 16, N_("50")}, + {15, 17, N_("100")}, + {15, 18, N_("200")}, + {15, 19, N_("400")}, + {15, 20, N_("800")}, + {16, 0, N_("Default")}, + {16, 1, N_("Spot")}, + {16, 2, N_("Average")}, + {16, 3, N_("Evaluative")}, + {16, 4, N_("Partial")}, + {16, 5, N_("Center-weighted average")}, + {17, 0, N_("Manual")}, + {17, 1, N_("Auto")}, + {17, 2, N_("Not known")}, + {17, 3, N_("Macro")}, + {17, 4, N_("Very close")}, + {17, 5, N_("Close")}, + {17, 6, N_("Middle range")}, + {17, 7, N_("Far range")}, + {17, 8, N_("Pan focus")}, + {17, 9, N_("Super macro")}, + {17, 10, N_("Infinity")}, + {18, 0x2005, N_("Manual AF point selection")}, + {18, 0x3000, N_("None (MF)")}, + {18, 0x3001, N_("Auto-selected")}, + {18, 0x3002, N_("Right")}, + {18, 0x3003, N_("Center")}, + {18, 0x3004, N_("Left")}, + {18, 0x4001, N_("Auto AF point selection")}, + {19, 0, N_("Easy shooting")}, + {19, 1, N_("Program")}, + {19, 2, N_("Tv-priority")}, + {19, 3, N_("Av-priority")}, + {19, 4, N_("Manual")}, + {19, 5, N_("A-DEP")}, + {19, 6, N_("M-DEP")}, + {21, 1, N_("Canon EF 50mm f/1.8")}, + {21, 2, N_("Canon EF 28mm f/2.8")}, + {21, 4, N_("Sigma UC Zoom 35-135mm f/4-5.6")}, + {21, 6, N_("Tokina AF193-2 19-35mm f/3.5-4.5")}, + {21, 7, N_("Canon EF 100-300mm F5.6L")}, + {21, 10, N_("Sigma 50mm f/2.8 EX or 28mm f/1.8")}, + {21, 11, N_("Canon EF 35mm f/2")}, + {21, 13, N_("Canon EF 15mm f/2.8")}, + {21, 21, N_("Canon EF 80-200mm f/2.8L")}, + {21, 22, N_("Tokina AT-X280AF PRO 28-80mm F2.8 ASPHERICAL")}, + {21, 26, N_("Cosina 100mm f/3.5 Macro AF")}, + {21, 28, N_("Tamron AF Aspherical 28-200mm f/3.8-5.6")}, + {21, 29, N_("Canon EF 50mm f/1.8 MkII")}, + {21, 31, N_("Tamron SP AF 300mm f/2.8 LD IF")}, + {21, 32, N_("Canon EF 24mm f/2.8 or Sigma 15mm f/2.8 EX Fisheye")}, + {21, 39, N_("Canon EF 75-300mm f/4-5.6")}, + {21, 40, N_("Canon EF 28-80mm f/3.5-5.6")}, + {21, 43, N_("Canon EF 28-105mm f/4-5.6")}, + {21, 45, N_("Canon EF-S 18-55mm f/3.5-5.6")}, + {21, 124, N_("Canon MP-E 65mm f/2.8 1-5x Macro Photo")}, + {21, 125, N_("Canon TS-E 24mm f/3.5L")}, + {21, 126, N_("Canon TS-E 45mm f/2.8")}, + {21, 127, N_("Canon TS-E 90mm f/2.8")}, + {21, 130, N_("Canon EF 50mm f/1.0L")}, + {21, 131, N_("Sigma 17-35mm f2.8-4 EX Aspherical HSM")}, + {21, 134, N_("Canon EF 600mm f/4L IS")}, + {21, 135, N_("Canon EF 200mm f/1.8L")}, + {21, 136, N_("Canon EF 300mm f/2.8L")}, + {21, 137, N_("Canon EF 85mm f/1.2L")}, + {21, 139, N_("Canon EF 400mm f/2.8L")}, + {21, 141, N_("Canon EF 500mm f/4.5L")}, + {21, 142, N_("Canon EF 300mm f/2.8L IS")}, + {21, 143, N_("Canon EF 500mm f/4L IS")}, + {21, 149, N_("Canon EF 100mm f/2")}, + {21, 150, N_("Sigma 20mm EX f/1.8")}, + {21, 151, N_("Canon EF 200mm f/2.8L")}, + {21, 152, N_("Sigma 10-20mm F4-5.6 or 12-24mm f/4.5-5.6 or 14mm f/2.8")}, + {21, 153, N_("Canon EF 35-350mm f/3.5-5.6L")}, + {21, 155, N_("Canon EF 85mm f/1.8 USM")}, + {21, 156, N_("Canon EF 28-105mm f/3.5-4.5 USM")}, + {21, 160, N_("Canon EF 20-35mm f/3.5-4.5 USM")}, + {21, 161, N_("Canon EF 28-70mm f/2.8L or Sigma 24-70mm EX f/2.8")}, + {21, 165, N_("Canon EF 70-200mm f/2.8 L")}, + {21, 166, N_("Canon EF 70-200mm f/2.8 L + x1.4")}, + {21, 167, N_("Canon EF 70-200mm f/2.8 L + x2")}, + {21, 168, N_("Canon EF 28mm f/1.8 USM")}, + {21, 169, N_("Sigma 15-30mm f/3.5-4.5 EX DG Aspherical")}, + {21, 170, N_("Canon EF 200mm f/2.8L II")}, + {21, 173, N_("Canon EF 180mm Macro f/3.5L or Sigma 180mm EX HSM Macro f/3.5")}, + {21, 174, N_("Canon EF 135mm f/2L")}, + {21, 176, N_("Canon EF 24-85mm f/3.5-4.5 USM")}, + {21, 177, N_("Canon EF 300mm f/4L IS")}, + {21, 178, N_("Canon EF 28-135mm f/3.5-5.6 IS")}, + {21, 180, N_("Canon EF 35mm f/1.4L")}, + {21, 181, N_("Canon EF 100-400mm f/4.5-5.6L IS + x1.4")}, + {21, 182, N_("Canon EF 100-400mm f/4.5-5.6L IS + x2")}, + {21, 183, N_("Canon EF 100-400mm f/4.5-5.6L IS")}, + {21, 184, N_("Canon EF 400mm f/2.8L + x2")}, + {21, 186, N_("Canon EF 70-200mm f/4L")}, + {21, 190, N_("Canon EF 100mm f/2.8 Macro")}, + {21, 191, N_("Canon EF 400mm f/4 DO IS")}, + {21, 197, N_("Canon EF 75-300mm f/4-5.6 IS")}, + {21, 198, N_("Canon EF 50mm f/1.4")}, + {21, 202, N_("Canon EF 28-80 f/3.5-5.6 USM IV")}, + {21, 211, N_("Canon EF 28-200mm f/3.5-5.6")}, + {21, 213, N_("Canon EF 90-300mm f/4.5-5.6")}, + {21, 214, N_("Canon EF-S 18-55mm f/3.5-4.5 USM")}, + {21, 224, N_("Canon EF 70-200mm f/2.8L IS USM")}, + {21, 225, N_("Canon EF 70-200mm f/2.8L IS USM + x1.4")}, + {21, 226, N_("Canon EF 70-200mm f/2.8L IS USM + x2")}, + {21, 229, N_("Canon EF 16-35mm f/2.8L")}, + {21, 230, N_("Canon EF 24-70mm f/2.8L")}, + {21, 231, N_("Canon EF 17-40mm f/4L")}, + {21, 232, N_("Canon EF 70-300mm f/4.5-5.6 DO IS USM")}, + {21, 234, N_("Canon EF-S 17-85mm f4-5.6 IS USM")}, + {21, 235, N_("Canon EF-S10-22mm F3.5-4.5 USM")}, + {21, 236, N_("Canon EF-S60mm F2.8 Macro USM")}, + {21, 237, N_("Canon EF 24-105mm f/4L IS")}, + {21, 238, N_("Canon EF 70-300mm F4-5.6 IS USM")}, + {21, 241, N_("Canon EF 50mm F1.2L USM")}, + {21, 242, N_("Canon EF 70-200mm f/4L IS USM")}, + {28, 0, N_("Manual")}, + {28, 1, N_("TTL")}, + {28, 2, N_("A-TTL")}, + {28, 3, N_("E-TTL")}, + {28, 4, N_("FP sync enabled")}, + {28, 7, N_("2nd-curtain sync used")}, + {28, 11, N_("FP sync used")}, + {28, 13, N_("Internal")}, + {28, 14, N_("External")}, + {31, 0, N_("Single")}, + {31, 1, N_("Continuous")}, + {32, 0, N_("Normal AE")}, + {32, 1, N_("Exposure compensation")}, + {32, 2, N_("AE lock")}, + {32, 3, N_("AE lock + Exposure compensation")}, + {32, 4, N_("No AE")}, + {33, 0, N_("Off")}, + {33, 1, N_("On")}, + {33, 2, N_("On, shot only")}, + {39, 0, N_("Off")}, + {39, 1, N_("Vivid")}, + {39, 2, N_("Neutral")}, + {39, 3, N_("Smooth")}, + {39, 4, N_("Sepia")}, + {39, 5, N_("Black & white")}, + {39, 6, N_("Custom")}, + {39, 100, N_("My color data")}, + {40, 0, N_("Off")}, + {40, 0x0500, N_("Full")}, + {40, 0x0502, N_("2/3")}, + {40, 0x0504, N_("1/3")}, +#endif + { 0, 0, NULL} +}, +entries_focal_length [] = { +#ifndef NO_VERBOSE_TAG_DATA + {0, 1, N_("Fixed")}, + {0, 2, N_("Zoom")}, +#endif + {0, 0, NULL} +}, +entries_settings_2 [] = { +#ifndef NO_VERBOSE_TAG_DATA + { 6, 0, N_("Auto")}, + { 6, 1, N_("Sunny")}, + { 6, 2, N_("Cloudy")}, + { 6, 3, N_("Tungsten")}, + { 6, 4, N_("Fluorescent")}, + { 6, 5, N_("Flash")}, + { 6, 6, N_("Custom")}, + { 6, 7, N_("Black & white")}, + { 6, 8, N_("Shade")}, + { 6, 9, N_("Manual temperature (Kelvin)")}, + { 6, 10, N_("PC set 1")}, + { 6, 11, N_("PC set 2")}, + { 6, 12, N_("PC set 3")}, + { 6, 14, N_("Daylight fluorescent")}, + { 6, 15, N_("Custom 1")}, + { 6, 16, N_("Custom 2")}, + { 6, 17, N_("Underwater")}, + { 7, 0, N_("Off")}, + { 7, 1, N_("Night scene")}, + { 7, 2, N_("On")}, + { 7, 3, N_("None")}, + { 13, 0x3000, N_("None (MF)")}, + { 13, 0x3001, N_("Right")}, + { 13, 0x3002, N_("Center")}, + { 13, 0x3003, N_("Center + Right")}, + { 13, 0x3004, N_("Left")}, + { 13, 0x3005, N_("Left + Right")}, + { 13, 0x3006, N_("Left + Center")}, + { 13, 0x3007, N_("All")}, + { 15, 0, N_("Off")}, + { 15, 1, N_("On (shot 1)")}, + { 15, 2, N_("On (shot 2)")}, + { 15, 3, N_("On (shot 3)")}, + { 15, 0xffff, N_("On")}, + { 25, 248, N_("EOS high-end")}, + { 25, 250, N_("Compact")}, + { 25, 252, N_("EOS mid-range")}, + { 26, 0, N_("None")}, + { 26, 1, N_("Rotate 90 CW")}, + { 26, 2, N_("Rotate 180")}, + { 26, 3, N_("Rotate 270 CW")}, + { 26, 0xffff, N_("Rotated by software")}, + { 27, 0, N_("Off")}, + { 27, 1, N_("On")}, + { 32, 0, N_("Off")}, + { 32, 0x0014, N_("1/3")}, + { 32, 0x008c, N_("2/3")}, + { 32, 0x07d0, N_("Full")}, +#endif + {0, 0, NULL} +}, +entries_panorama [] = { +#ifndef NO_VERBOSE_TAG_DATA + {0, 0, N_("Left to right")}, + {0, 1, N_("Right to left")}, + {0, 2, N_("Bottom to top")}, + {0, 3, N_("Top to bottom")}, + {0, 4, N_("2x2 matrix (clockwise)")}, +#endif + {0, 0, NULL} +}, +color_information [] = { +#ifndef NO_VERBOSE_TAG_DATA + {0, 0, N_("Standard")}, + {0, 1, N_("Manual")}, + {0, 2, N_("Custom")}, + {2, 0, N_("N/A")}, + {2, 1, N_("Lowest")}, + {2, 2, N_("Low")}, + {2, 3, N_("Standard")}, + {2, 4, N_("High")}, + {2, 5, N_("Highest")}, + {7, 0, N_("Auto")}, + {7, 1, N_("Daylight")}, + {7, 2, N_("Cloudy")}, + {7, 3, N_("Tungsten")}, + {7, 4, N_("Fluorescent")}, + {7, 5, N_("Flash")}, + {7, 6, N_("Custom")}, + {7, 7, N_("Black & White")}, + {7, 8, N_("Shade")}, + {7, 9, N_("Manual Temperature (Kelvin)")}, + {7, 10, N_("PC Set1")}, + {7, 11, N_("PC Set2")}, + {7, 12, N_("PC Set3")}, + {7, 14, N_("Daylight Fluorescent")}, + {7, 15, N_("Custom 1")}, + {7, 16, N_("Custom 2")}, + {7, 17, N_("Underwater")}, + {9, 0x00, N_("None")}, + {9, 0x01, N_("Standard")}, + {9, 0x02, N_("Set 1")}, + {9, 0x03, N_("Set 2")}, + {9, 0x04, N_("Set 3")}, + {9, 0x21, N_("User Def. 1")}, + {9, 0x22, N_("User Def. 2")}, + {9, 0x23, N_("User Def. 3")}, + {9, 0x41, N_("External 1")}, + {9, 0x42, N_("External 2")}, + {9, 0x43, N_("External 3")}, + {9, 0x81, N_("Standard")}, + {9, 0x82, N_("Portrait")}, + {9, 0x83, N_("Landscape")}, + {9, 0x84, N_("Neutral")}, + {9, 0x85, N_("Faithful")}, + {9, 0x86, N_("Monochrome")}, +#endif + {0, 0, NULL} +}; + +static void +canon_search_table_value (const struct canon_entry_table_t table[], + unsigned int t, ExifShort vs, char *val, unsigned int maxlen) +{ + unsigned int j; + + /* Search the table for the first matching subtag and value. */ + for (j = 0; table[j].name && ((table[j].subtag < t) || + ((table[j].subtag == t) && table[j].value <= vs)); j++) { + if ((table[j].subtag == t) && (table[j].value == vs)) { + break; + } + } + if ((table[j].subtag == t) && (table[j].value == vs) && table[j].name) { + /* Matching subtag and value found. */ + strncpy (val, _(table[j].name), maxlen); + } else { + /* No matching subtag and/or value found. */ + snprintf (val, maxlen, "0x%04x", vs); + } +} + +static void +canon_search_table_bitfield (const struct canon_entry_table_t table[], + unsigned int t, ExifShort vs, char *val, unsigned int maxlen) +{ + unsigned int j; + + /* Search the table for the first matching subtag. */ + for (j = 0; table[j].name && (table[j].subtag <= t); j++) { + if (table[j].subtag == t) { + break; + } + } + if ((table[j].subtag == t) && table[j].name) { + unsigned int i, bit, lastbit = 0; + + /* + * Search the table for the last matching bit, because + * that one needs no additional comma appended. + */ + for (i = j; table[i].name && (table[i].subtag == t); i++) { + bit = table[i].value; + if ((vs >> bit) & 1) { + lastbit = bit; + } + } + /* Search the table for all matching bits. */ + for (i = j; table[i].name && (table[i].subtag == t); i++) { + bit = table[i].value; + if ((vs >> bit) & 1) { + strncat(val, table[i].name, maxlen - strlen (val)); + if (bit != lastbit) + strncat (val, N_(", "), maxlen - strlen (val)); + } + } + } else { + /* No matching subtag found. */ + snprintf (val, maxlen, "0x%04x", vs); + } +} + +unsigned int +mnote_canon_entry_count_values (const MnoteCanonEntry *entry) +{ + unsigned int val; + + if (!entry) return 0; + + switch (entry->tag) { + case MNOTE_CANON_TAG_FOCAL_LENGTH: + case MNOTE_CANON_TAG_PANORAMA: + return entry->components; + case MNOTE_CANON_TAG_SETTINGS_1: + case MNOTE_CANON_TAG_SETTINGS_2: + case MNOTE_CANON_TAG_CUSTOM_FUNCS: + case MNOTE_CANON_TAG_COLOR_INFORMATION: + if (entry->format != EXIF_FORMAT_SHORT) return 0; + + val = exif_get_short (entry->data, entry->order); + /* val is buffer size, i.e. # of values plus 1 */ + return MIN (entry->size - 2, val) / 2; + default: + return 1; + } +} + +/* + * For reference, see Exif 2.1 specification (Appendix C), + * or http://en.wikipedia.org/wiki/APEX_system + */ +static double +apex_value_to_aperture (double x) +{ + return pow (2, x / 2.); +} + +static double +apex_value_to_shutter_speed(double x) +{ + return 1.0 / pow (2, x); +} + +static double +apex_value_to_iso_speed (double x) +{ + return 3.125 * pow (2, x); +} + char * -mnote_canon_entry_get_value (const MnoteCanonEntry *entry, char *val, unsigned int maxlen) +mnote_canon_entry_get_value (const MnoteCanonEntry *entry, unsigned int t, char *val, unsigned int maxlen) { - char buf[128]; - ExifLong vl; - ExifShort vs, n; - int i; - unsigned char *data = entry->data; + char buf[128]; + ExifLong vl; + ExifShort vs, n; + unsigned char *data; + double d; - if (!entry) return NULL; + if (!entry) + return NULL; - memset (val, 0, maxlen); - maxlen--; + data = entry->data; + + memset (val, 0, maxlen); + maxlen--; switch (entry->tag) { case MNOTE_CANON_TAG_SETTINGS_1: CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen); n = exif_get_short (data, entry->order) / 2; - data += 2; + if (t >= n) return NULL; CC (entry->components, n, val, maxlen); - for (i = 1; i < n; i++) { - vs = exif_get_short (data, entry->order); - data += 2; - switch (i) { - case 1: - strncpy (val, _("Macro mode : "), maxlen); - switch (vs) { - case 1: - strncat (val, _("Macro"), maxlen - strlen(val)); - break; - case 2: - strncat (val, _("Normal"), maxlen - strlen(val)); - break; - default: - snprintf (buf, sizeof (buf), _("%i???"), vs); - strncat (val, buf, maxlen - strlen(val)); - } - break; - case 2: - if (vs) { - snprintf (buf, sizeof (buf), - _(" / Self Timer : %i (ms)"), vs*100); - strncat (val, buf, maxlen - strlen(val)); + vs = exif_get_short (data + 2 + t * 2, entry->order); + switch (t) { + case 1: + if (!vs) { + strncpy(val, _("Off"), maxlen); + break; } + snprintf (val, maxlen, _("%i (ms)"), vs * 100); break; - case 4: - strncat (val, _(" / Flash mode : "), maxlen - strlen(val)); - switch (vs) { - case 0: - strncat (val, _("Flash not fired"), maxlen - strlen(val)); - break; - case 1: - strncat (val, _("auto"), maxlen - strlen(val)); - break; - case 2: - strncat (val, _("on"), maxlen - strlen(val)); - break; - case 3: - strncat (val, _("red eyes reduction"), maxlen - strlen(val)); - break; - case 4: - strncat (val, _("slow synchro"), maxlen - strlen(val)); - break; - case 5: - strncat (val, _("auto + red eyes reduction"), maxlen - strlen(val)); - break; - case 6: - strncat (val, _("on + red eyes reduction"), maxlen - strlen(val)); - break; - case 16: - strncat (val, _("external"), maxlen - strlen(val)); - break; - default: - snprintf (buf, sizeof (buf), _("%i???"), vs); - strncat (val, buf, maxlen - strlen(val)); + case 15: + if (((vs & 0xC000) == 0x4000) && (vs != 0x7FFF)) { + /* Canon S3 IS - directly specified value */ + snprintf (val, maxlen, _("%i"), vs & ~0x4000); + } else { + /* Standard Canon - index into lookup table */ + canon_search_table_value (entries_settings_1, t, vs, val, maxlen); } break; - case 5: - strncat (val, _(" / Continuous drive mode : "), maxlen - strlen(val)); - switch (vs) { - case 0: - strncat (val, _("single or timer"), maxlen - strlen(val)); - break; - case 1: - strncat (val, _("continuous"), maxlen - strlen(val)); - break; - default: - snprintf (buf, sizeof (buf), _("%i???"), vs); - strncat (val, buf, maxlen - strlen(val)); - } + case 22: + case 23: + case 24: + snprintf (val, maxlen, "%u", vs); break; - case 7: - strncat (val, _(" / Focus mode : "), maxlen - strlen(val)); - switch (vs) { - case 0: - strncat (val, _("One-Shot"), maxlen - strlen(val)); - break; - case 1: - strncat (val, _("AI Servo"), maxlen - strlen(val)); - break; - case 2: - strncat (val, _("AI Focus"), maxlen - strlen(val)); - break; - case 3: - strncat (val, _("MF"), maxlen - strlen(val)); - break; - case 4: - strncat (val, _("Single"), maxlen - strlen(val)); - break; - case 5: - strncat (val, _("Continuous"), maxlen - strlen(val)); - break; - case 6: - strncat (val, _("MF"), maxlen - strlen(val)); - break; - default: - snprintf (buf, sizeof (buf), _("%i???"), vs); - strncat (val, buf, maxlen - strlen(val)); - } + case 25: + case 26: + snprintf (val, maxlen, "%.2f", apex_value_to_aperture (vs / 32.0)); break; - case 10: - strncat (val, _(" / Image size : "), maxlen - strlen(val)); - switch (vs) { - case 0: - strncat (val, _("Large"), maxlen - strlen(val)); - break; - case 1: - strncat (val, _("Medium"), maxlen - strlen(val)); - break; - case 2: - strncat (val, _("Small"), maxlen - strlen(val)); - break; - default: - snprintf (buf, sizeof (buf), _("%i???"), vs); - strncat (val, buf, maxlen - strlen(val)); - } + case 28: + canon_search_table_bitfield(entries_settings_1, t, vs, val, maxlen); break; - case 11: - strncat (val, _(" / Easy shooting mode : "), maxlen - strlen(val)); - switch (vs) { - case 0: - strncat (val, _("Full Auto"), maxlen - strlen(val)); - break; - case 1: - strncat (val, _("Manual"), maxlen - strlen(val)); - break; - case 2: - strncat (val, _("Landscape"), maxlen - strlen(val)); - break; - case 3: - strncat (val, _("Fast Shutter"), maxlen - strlen(val)); - break; - case 4: - strncat (val, _("Slow Shutter"), maxlen - strlen(val)); - break; - case 5: - strncat (val, _("Night"), maxlen - strlen(val)); - break; - case 6: - strncat (val, _("Black & White"), maxlen - strlen(val)); - break; - case 7: - strncat (val, _("Sepia"), maxlen - strlen(val)); - break; - case 8: - strncat (val, _("Portrait"), maxlen - strlen(val)); - break; - case 9: - strncat (val, _("Sports"), maxlen - strlen(val)); - break; - case 10: - strncat (val, _("Macro / Close-Up"), maxlen - strlen(val)); - break; - case 11: - strncat (val, _("Pan Focus"), maxlen - strlen(val)); - break; - default: - snprintf (buf, sizeof (buf), _("%i???"), vs); - strncat (val, buf, maxlen - strlen(val)); - } + case 34: + snprintf (val, maxlen, "%.2f", vs / 10.0); break; - case 13: - strncat (val, _(" / Contrast : "), maxlen - strlen(val)); - switch (vs) { - case 0xffff: - strncat (val, _("Low"), maxlen - strlen(val)); - break; - case 0x0000: - strncat (val, _("Normal"), maxlen - strlen(val)); - break; - case 0x0001: - strncat (val, _("High"), maxlen - strlen(val)); - break; - default: - snprintf (buf, sizeof (buf), _("%i???"), vs); - strncat (val, buf, maxlen - strlen(val)); - } + case 35: + case 36: + snprintf (val, maxlen, "%u", vs); break; - case 14: - strncat (val, _(" / Saturation : "), maxlen - strlen(val)); - switch (vs) { - case 0xffff: - strncat (val, _("Low"), maxlen - strlen(val)); - break; - case 0x0000: - strncat (val, _("Normal"), maxlen - strlen(val)); - break; - case 0x0001: - strncat (val, _("High"), maxlen - strlen(val)); - break; - default: - snprintf (buf, sizeof (buf), _("%i???"), vs); - strncat (val, buf, maxlen - strlen(val)); - } - break; - case 15: - strncat (val, _(" / Sharpness : "), maxlen - strlen(val)); - switch (vs) { - case 0xffff: - strncat (val, _("Low"), maxlen - strlen(val)); - break; - case 0x0000: - strncat (val, _("Normal"), maxlen - strlen(val)); - break; - case 0x0001: - strncat (val, _("High"), maxlen - strlen(val)); - break; - default: - snprintf (buf, sizeof (buf), _("%i???"), vs); - strncat (val, buf, maxlen - strlen(val)); - } - break; - case 16: - if (vs) { - strncat (val, _(" / ISO : "), maxlen - strlen(val)); - switch (vs) { - case 15: - strncat (val, _("auto"), maxlen - strlen(val)); - break; - case 16: - strncat (val, _("50"), maxlen - strlen(val)); - break; - case 17: - strncat (val, _("100"), maxlen - strlen(val)); - break; - case 18: - strncat (val, _("200"), maxlen - strlen(val)); - break; - case 19: - strncat (val, _("400"), maxlen - strlen(val)); - break; - default: - snprintf (buf, sizeof (buf), _("%i???"), vs); - strncat (val, buf, maxlen - strlen(val)); - } - break; - } - case 17: - strncat (val, _(" / Metering mode : "), maxlen - strlen(val)); - switch (vs) { - case 3: - strncat (val, _("Evaluative"), maxlen - strlen(val)); - break; - case 4: - strncat (val, _("Partial"), maxlen - strlen(val)); - break; - case 5: - strncat (val, _("Center-weighted"), maxlen - strlen(val)); - break; - default: - snprintf (buf, sizeof (buf), _("%i???"), vs); - strncat (val, buf, maxlen - strlen(val)); - } + default: + canon_search_table_value (entries_settings_1, t, vs, val, maxlen); + } + break; + + case MNOTE_CANON_TAG_FOCAL_LENGTH: + CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen); + vs = exif_get_short (data + t * 2, entry->order); + switch (t) { + case 1: + snprintf (val, maxlen, "%u", vs); break; - case 19: - strncat (val, _(" / AF point selected : "), maxlen - strlen(val)); - switch (vs) { - case 0x3000: - strncat (val, _("none (MF)"), maxlen - strlen(val)); - break; - case 0x3001: - strncat (val, _("auto-selected"), maxlen - strlen(val)); - break; - case 0x3002: - strncat (val, _("right"), maxlen - strlen(val)); - break; - case 0x3003: - strncat (val, _("center"), maxlen - strlen(val)); - break; - case 0x3004: - strncat (val, _("left"), maxlen - strlen(val)); - break; - default: - snprintf (buf, sizeof (buf), _("0x%x???"), vs); - strncat (val, buf, maxlen - strlen(val)); - } + case 2: + case 3: + snprintf (val, maxlen, _("%.2f mm"), vs * 25.4 / 1000); break; - case 20: - strncat (val, _(" / Exposure mode : "), maxlen - strlen(val)); - switch (vs) { - case 0: - strncat (val, _("Easy shooting"), maxlen - strlen(val)); - break; - case 1: - strncat (val, _("Program"), maxlen - strlen(val)); - break; - case 2: - strncat (val, _("Tv-priority"), maxlen - strlen(val)); - break; - case 3: - strncat (val, _("Av-priority"), maxlen - strlen(val)); - break; - case 4: - strncat (val, _("Manual"), maxlen - strlen(val)); - break; - case 5: - strncat (val, _("A-DEP"), maxlen - strlen(val)); - break; - default: - snprintf (buf, sizeof (buf), _("%i???"), vs); - strncat (val, buf, maxlen - strlen(val)); - } - break; - case 23: - snprintf (buf, sizeof (buf), _(" / long focal length of lens (in focal units) : %u"), vs); - strncat (val, buf, maxlen - strlen(val)); - break; - case 24: - snprintf (buf, sizeof (buf), _(" / short focal length of lens (in focal units) : %u"), vs); - strncat (val, buf, maxlen - strlen(val)); - break; - case 25: - snprintf (buf, sizeof (buf), _(" / focal units per mm : %u"), vs); - strncat (val, buf, maxlen - strlen(val)); - break; - case 29: - strncat (val, _(" / Flash details : "), maxlen - strlen(val)); - if ((vs>>14)&1) - strncat (val, _("External E-TTL"), maxlen - strlen(val)); - if ((vs>>13)&1) - strncat (val, _("Internal flash"), maxlen - strlen(val)); - if ((vs>>11)&1) - strncat (val, _("FP sync used"), maxlen - strlen(val)); - if ((vs>>4)&1) - strncat (val, _("FP sync enabled"), maxlen - strlen(val)); -#ifdef DEBUG - printf ("Value29=0x%08x\n", vs); -#endif - break; - case 32: - strncat (val, _(" / Focus mode2 : "), maxlen - strlen(val)); - switch (vs) { - case 0: - strncat (val, _("Single"), maxlen - strlen(val)); - break; - case 1: - strncat (val, _("Continuous"), maxlen - strlen(val)); - break; - default: - snprintf (buf, sizeof (buf), _("%i???"), vs); - strncat (val, buf, maxlen - strlen(val)); - } - break; -#ifdef DEBUG - default: - printf ("Value%d=%d\n", i, vs); -#endif - } + default: + canon_search_table_value (entries_focal_length, t, vs, val, maxlen); } - - break; + break; case MNOTE_CANON_TAG_SETTINGS_2: CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen); - n = exif_get_short (data, entry->order)/2; - data += 2; + n = exif_get_short (data, entry->order) / 2; + if (t >= n) return NULL; CC (entry->components, n, val, maxlen); -#ifdef DEBUG - printf ("Setting2 size %d %d\n",n,entry->size); -#endif - for (i=1;i<n;i++) - { - vs = exif_get_short (data, entry->order); - data+=2; - switch(i) { - case 7: - strncpy (val, _("White balance : "), maxlen - strlen(val)); - switch (vs) { - case 0: - strncat (val, _("Auto"), maxlen - strlen(val)); - break; - case 1: - strncat (val, _("Sunny"), maxlen - strlen(val)); - break; - case 2: - strncat (val, _("Cloudy"), maxlen - strlen(val)); - break; - case 3: - strncat (val, _("Tungsten"), maxlen - strlen(val)); - break; - case 4: - strncat (val, _("Flourescent"), maxlen - strlen(val)); - break; - case 5: - strncat (val, _("Flash"), maxlen - strlen(val)); - break; - case 6: - strncat (val, _("Custom"), maxlen - strlen(val)); - break; - default: - snprintf (buf, sizeof (buf), _("%i???"), vs); - strncat (val, buf, maxlen - strlen(val)); - } - break; - case 9: - snprintf (buf, sizeof (buf), _(" / Sequence number : %u"), vs); - strncat (val, buf, maxlen - strlen(val)); - break; - case 14: - if (vs>>12) - { - strncat (val, _(" / AF point used : "), maxlen - strlen(val)); - if (vs&1) - strncat (val, _("Right"), maxlen - strlen(val)); - if ((vs>>1)&1) - strncat (val, _("Center"), maxlen - strlen(val)); - if ((vs>>2)&1) - strncat (val, _("Left"), maxlen - strlen(val)); - snprintf (buf, sizeof (buf), _(" (%u available focus point)"), vs>>12); - strncat (val, buf, maxlen - strlen(val)); - } -#ifdef DEBUG - printf ("0x%08x\n", vs); -#endif - break; - case 15: - snprintf (buf, sizeof (buf), _(" / Flash bias : %.2f EV"), vs/32.0); - strncat (val, buf, maxlen - strlen(val)); - - break; - case 19: - snprintf (buf, sizeof (buf), _(" / Subject Distance (mm) : %u"), vs); - strncat (val, buf, maxlen - strlen(val)); + vs = exif_get_short (data + 2 + t * 2, entry->order); + switch (t) { + case 0: + snprintf (val, maxlen, "%.3f", pow (2, (ExifSShort)vs / 32.0)); + break; + case 1: + snprintf (val, maxlen, "%.0f", apex_value_to_iso_speed ((ExifSShort)vs / 32.0)); + break; + case 2: + case 5: + case 14: + case 16: + snprintf (val, maxlen, _("%.2f EV"), vs / 32.0); + break; + case 3: + case 20: + snprintf (val, maxlen, "%.2f", apex_value_to_aperture (vs / 32.0)); + break; + case 4: + case 21: + d = apex_value_to_shutter_speed ((ExifSShort)vs / 32.0); + if (d < 1) + snprintf (val, maxlen, _("1/%d"),(int)(1.0 / d)); + else + snprintf (val, maxlen, _("%d"), (int) d); + break; + case 8: + snprintf (val, maxlen, "%u", vs); + break; + case 12: + snprintf (val, maxlen, "%.2f", vs / 32.0); + break; + case 18: + case 19: + snprintf (val, maxlen, _("%u mm"), vs); + break; + case 28: + if ((ExifSShort)vs <= 0) { + strncpy(val, _("Off"), maxlen); break; -#ifdef DEBUG - default: - printf ("Value%d=%d\n", i, vs); -#endif } + snprintf (val, maxlen, _("%i (ms)"), vs * 100); + break; + default: + canon_search_table_value (entries_settings_2, t, vs, val, maxlen); } + break; + case MNOTE_CANON_TAG_PANORAMA: + CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen); + vs = exif_get_short (data + t * 2, entry->order); + canon_search_table_value (entries_panorama, t, vs, val, maxlen); break; - case MNOTE_CANON_TAG_IMAGE_TYPE: case MNOTE_CANON_TAG_OWNER: - CF (entry->format, EXIF_FORMAT_ASCII, val, maxlen); CC (entry->components, 32, val, maxlen); - strncpy (val, data, MIN (entry->size, maxlen)); + /* Fall through; ImageType can have many sizes */ + case MNOTE_CANON_TAG_IMAGE_TYPE: + CF (entry->format, EXIF_FORMAT_ASCII, val, maxlen); + strncpy (val, (char *)data, MIN (entry->size, maxlen)); break; case MNOTE_CANON_TAG_FIRMWARE: CF (entry->format, EXIF_FORMAT_ASCII, val, maxlen); - CC2 (entry->components, 24, 32, val, maxlen); - strncpy (val, data, MIN (entry->size, maxlen)); +/* CC2 (entry->components, 24, 32, val, maxlen); Can also be 22 */ + strncpy (val, (char *)data, MIN (entry->size, maxlen)); break; case MNOTE_CANON_TAG_IMAGE_NUMBER: @@ -551,23 +716,27 @@ mnote_canon_entry_get_value (const MnoteCanonEntry *entry, char *val, unsigned i case MNOTE_CANON_TAG_CUSTOM_FUNCS: CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen); - n = exif_get_short (data, entry->order)/2; - data+=2; + n = exif_get_short (data, entry->order) / 2; + if (t >= n) return NULL; CC (entry->components, n, val, maxlen); -#ifdef DEBUG - printf ("Custom Function size %d %d\n",n,entry->size); -#endif - for (i=1;i<n;i++) - { - vs = exif_get_short (data, entry->order); - data += 2; - snprintf (buf, sizeof(buf), _("C.F%d : %u"), i, vs); - strncat (val, buf, maxlen - strlen(val)); - } + vs = exif_get_short (data + 2 + t * 2, entry->order); + snprintf (buf, sizeof (buf), "%u", vs); + strncat (val, buf, maxlen - strlen (val)); + break; + + case MNOTE_CANON_TAG_COLOR_INFORMATION: + CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen); + n = exif_get_short (data, entry->order) / 2; + if (t >= n) return NULL; + CC (entry->components, n, val, maxlen); + vs = exif_get_short (data + 2 + t * 2, entry->order); + canon_search_table_value (color_information, t, vs, val, maxlen); break; default: #ifdef DEBUG + { + int i; if (entry->format == EXIF_FORMAT_SHORT) for(i=0;i<entry->components;i++) { vs = exif_get_short (data, entry->order); @@ -582,9 +751,9 @@ mnote_canon_entry_get_value (const MnoteCanonEntry *entry, char *val, unsigned i } else if (entry->format == EXIF_FORMAT_ASCII) strncpy (val, data, MIN (entry->size, maxlen)); + } #endif break; - } - - return val; + } + return val; } diff --git a/src/libexif/canon/mnote-canon-entry.h b/src/libexif/canon/mnote-canon-entry.h index 62345d8..e78c639 100644 --- a/src/libexif/canon/mnote-canon-entry.h +++ b/src/libexif/canon/mnote-canon-entry.h @@ -1,6 +1,6 @@ /* mnote-canon-entry.h * - * Copyright © 2002 Lutz Müller <lutz@users.sourceforge.net> + * Copyright (c) 2002 Lutz Mueller <lutz@users.sourceforge.net> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -38,6 +38,7 @@ struct _MnoteCanonEntry { ExifByteOrder order; }; -char *mnote_canon_entry_get_value (const MnoteCanonEntry *entry, char *val, unsigned int maxlen); +unsigned int mnote_canon_entry_count_values (const MnoteCanonEntry *); +char *mnote_canon_entry_get_value (const MnoteCanonEntry *, unsigned int t, char *val, unsigned int maxlen); #endif /* __MNOTE_CANON_ENTRY_H__ */ diff --git a/src/libexif/canon/mnote-canon-tag.c b/src/libexif/canon/mnote-canon-tag.c index 890a5fc..447caab 100644 --- a/src/libexif/canon/mnote-canon-tag.c +++ b/src/libexif/canon/mnote-canon-tag.c @@ -1,6 +1,6 @@ /* mnote-canon-tag.c * - * Copyright © 2002 Lutz Müller <lutz@users.sourceforge.net> + * Copyright (c) 2002 Lutz Mueller <lutz@users.sourceforge.net> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -25,34 +25,137 @@ #include <libexif/i18n.h> -static struct { +static const struct { MnoteCanonTag tag; const char *name; const char *title; const char *description; } table[] = { +#ifndef NO_VERBOSE_TAG_STRINGS {MNOTE_CANON_TAG_SETTINGS_1, "Settings1", N_("Settings (first part)"), ""}, + {MNOTE_CANON_TAG_FOCAL_LENGTH, "FocalLength", N_("Focal length"), ""}, {MNOTE_CANON_TAG_SETTINGS_2, "Settings2", N_("Settings (second part)"), ""}, + {MNOTE_CANON_TAG_PANORAMA, "Panorama", N_("Panorama"), ""}, {MNOTE_CANON_TAG_IMAGE_TYPE, "ImageType", N_("Image type"), ""}, {MNOTE_CANON_TAG_FIRMWARE, "FirmwareVersion", N_("Firmware version"), ""}, {MNOTE_CANON_TAG_IMAGE_NUMBER, "ImageNumber", N_("Image number"), ""}, {MNOTE_CANON_TAG_OWNER, "OwnerName", N_("Owner name"), ""}, + {MNOTE_CANON_TAG_COLOR_INFORMATION, "ColorInformation", N_("Color information"), ""}, {MNOTE_CANON_TAG_SERIAL_NUMBER, "SerialNumber", N_("Serial number"), ""}, {MNOTE_CANON_TAG_CUSTOM_FUNCS, "CustomFunctions", N_("Custom functions"), ""}, +#endif {0, NULL, NULL, NULL} }; +static const struct { + MnoteCanonTag tag; + unsigned int subtag; + const char *name; +} table_sub[] = { +#ifndef NO_VERBOSE_TAG_STRINGS + {MNOTE_CANON_TAG_SETTINGS_1, 0, N_("Macro mode")}, + {MNOTE_CANON_TAG_SETTINGS_1, 1, N_("Self-timer")}, + {MNOTE_CANON_TAG_SETTINGS_1, 2, N_("Quality")}, + {MNOTE_CANON_TAG_SETTINGS_1, 3, N_("Flash mode")}, + {MNOTE_CANON_TAG_SETTINGS_1, 4, N_("Drive mode")}, + {MNOTE_CANON_TAG_SETTINGS_1, 6, N_("Focus mode")}, + {MNOTE_CANON_TAG_SETTINGS_1, 8, N_("Record mode")}, + {MNOTE_CANON_TAG_SETTINGS_1, 9, N_("Image size")}, + {MNOTE_CANON_TAG_SETTINGS_1, 10, N_("Easy shooting mode")}, + {MNOTE_CANON_TAG_SETTINGS_1, 11, N_("Digital zoom")}, + {MNOTE_CANON_TAG_SETTINGS_1, 12, N_("Contrast")}, + {MNOTE_CANON_TAG_SETTINGS_1, 13, N_("Saturation")}, + {MNOTE_CANON_TAG_SETTINGS_1, 14, N_("Sharpness")}, + {MNOTE_CANON_TAG_SETTINGS_1, 15, N_("ISO")}, + {MNOTE_CANON_TAG_SETTINGS_1, 16, N_("Metering mode")}, + {MNOTE_CANON_TAG_SETTINGS_1, 17, N_("Focus range")}, + {MNOTE_CANON_TAG_SETTINGS_1, 18, N_("AF point")}, + {MNOTE_CANON_TAG_SETTINGS_1, 19, N_("Exposure mode")}, + {MNOTE_CANON_TAG_SETTINGS_1, 21, N_("Lens type")}, + {MNOTE_CANON_TAG_SETTINGS_1, 22, N_("Long focal length of lens")}, + {MNOTE_CANON_TAG_SETTINGS_1, 23, N_("Short focal length of lens")}, + {MNOTE_CANON_TAG_SETTINGS_1, 24, N_("Focal units per mm")}, + {MNOTE_CANON_TAG_SETTINGS_1, 25, N_("Maximal aperture")}, + {MNOTE_CANON_TAG_SETTINGS_1, 26, N_("Minimal aperture")}, + {MNOTE_CANON_TAG_SETTINGS_1, 27, N_("Flash activity")}, + {MNOTE_CANON_TAG_SETTINGS_1, 28, N_("Flash details")}, + {MNOTE_CANON_TAG_SETTINGS_1, 31, N_("Focus mode")}, + {MNOTE_CANON_TAG_SETTINGS_1, 32, N_("AE setting")}, + {MNOTE_CANON_TAG_SETTINGS_1, 33, N_("Image stabilization")}, + {MNOTE_CANON_TAG_SETTINGS_1, 34, N_("Display aperture")}, + {MNOTE_CANON_TAG_SETTINGS_1, 35, N_("Zoom source width")}, + {MNOTE_CANON_TAG_SETTINGS_1, 36, N_("Zoom target width")}, + {MNOTE_CANON_TAG_SETTINGS_1, 39, N_("Photo effect")}, + {MNOTE_CANON_TAG_SETTINGS_1, 40, N_("Manual flash output")}, + {MNOTE_CANON_TAG_SETTINGS_1, 41, N_("Color tone")}, + {MNOTE_CANON_TAG_FOCAL_LENGTH, 0, N_("Focal type")}, + {MNOTE_CANON_TAG_FOCAL_LENGTH, 1, N_("Focal length")}, + {MNOTE_CANON_TAG_FOCAL_LENGTH, 2, N_("Focal plane x size")}, + {MNOTE_CANON_TAG_FOCAL_LENGTH, 3, N_("Focal plane y size")}, + {MNOTE_CANON_TAG_SETTINGS_2, 0, N_("Auto ISO")}, + {MNOTE_CANON_TAG_SETTINGS_2, 1, N_("Shot ISO")}, + {MNOTE_CANON_TAG_SETTINGS_2, 2, N_("Measured EV")}, + {MNOTE_CANON_TAG_SETTINGS_2, 3, N_("Target aperture")}, + {MNOTE_CANON_TAG_SETTINGS_2, 4, N_("Target exposure time")}, + {MNOTE_CANON_TAG_SETTINGS_2, 5, N_("Exposure compensation")}, + {MNOTE_CANON_TAG_SETTINGS_2, 6, N_("White balance")}, + {MNOTE_CANON_TAG_SETTINGS_2, 7, N_("Slow shutter")}, + {MNOTE_CANON_TAG_SETTINGS_2, 8, N_("Sequence number")}, + {MNOTE_CANON_TAG_SETTINGS_2, 12, N_("Flash guide number")}, + {MNOTE_CANON_TAG_SETTINGS_2, 13, N_("AF point")}, + {MNOTE_CANON_TAG_SETTINGS_2, 14, N_("Flash exposure compensation")}, + {MNOTE_CANON_TAG_SETTINGS_2, 15, N_("AE bracketing")}, + {MNOTE_CANON_TAG_SETTINGS_2, 16, N_("AE bracket value")}, + {MNOTE_CANON_TAG_SETTINGS_2, 18, N_("Focus distance upper")}, + {MNOTE_CANON_TAG_SETTINGS_2, 19, N_("Focus distance lower")}, + {MNOTE_CANON_TAG_SETTINGS_2, 20, N_("FNumber")}, + {MNOTE_CANON_TAG_SETTINGS_2, 21, N_("Exposure time")}, + {MNOTE_CANON_TAG_SETTINGS_2, 23, N_("Bulb duration")}, + {MNOTE_CANON_TAG_SETTINGS_2, 25, N_("Camera type")}, + {MNOTE_CANON_TAG_SETTINGS_2, 26, N_("Auto rotate")}, + {MNOTE_CANON_TAG_SETTINGS_2, 27, N_("ND filter")}, + {MNOTE_CANON_TAG_SETTINGS_2, 28, N_("Self-timer")}, + {MNOTE_CANON_TAG_SETTINGS_2, 32, N_("Manual flash output")}, + {MNOTE_CANON_TAG_PANORAMA, 2, N_("Panorama frame")}, + {MNOTE_CANON_TAG_PANORAMA, 5, N_("Panorama direction")}, + {MNOTE_CANON_TAG_COLOR_INFORMATION, 0, N_("Tone curve")}, + {MNOTE_CANON_TAG_COLOR_INFORMATION, 2, N_("Sharpness frequency")}, + {MNOTE_CANON_TAG_COLOR_INFORMATION, 7, N_("White balance")}, + {MNOTE_CANON_TAG_COLOR_INFORMATION, 9, N_("Picture style")}, +#endif + {0, 0, NULL} +}; + const char * mnote_canon_tag_get_name (MnoteCanonTag t) { unsigned int i; for (i = 0; i < sizeof (table) / sizeof (table[0]); i++) - if (table[i].tag == t) return (_(table[i].name)); + if (table[i].tag == t) return table[i].name; /* do not translate */ return NULL; } const char * +mnote_canon_tag_get_name_sub (MnoteCanonTag t, unsigned int s, ExifDataOption o) +{ + unsigned int i; + int tag_found = 0; + + for (i = 0; i < sizeof (table_sub) / sizeof (table_sub[0]); i++) { + if (table_sub[i].tag == t) { + if (table_sub[i].subtag == s) + return table_sub[i].name; + tag_found = 1; + } + } + if (!tag_found || !(o & EXIF_DATA_OPTION_IGNORE_UNKNOWN_TAGS)) + return mnote_canon_tag_get_name (t); + else + return NULL; +} + +const char * mnote_canon_tag_get_title (MnoteCanonTag t) { unsigned int i; @@ -64,12 +167,35 @@ mnote_canon_tag_get_title (MnoteCanonTag t) } const char * +mnote_canon_tag_get_title_sub (MnoteCanonTag t, unsigned int s, ExifDataOption o) +{ + unsigned int i; + int tag_found = 0; + + for (i = 0; i < sizeof (table_sub) / sizeof (table_sub[0]); i++) { + if (table_sub[i].tag == t) { + if (table_sub[i].subtag == s) + return _(table_sub[i].name); + tag_found = 1; + } + } + if (!tag_found || !(o & EXIF_DATA_OPTION_IGNORE_UNKNOWN_TAGS)) + return mnote_canon_tag_get_title (t); + else + return NULL; +} + +const char * mnote_canon_tag_get_description (MnoteCanonTag t) { unsigned int i; bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); for (i = 0; i < sizeof (table) / sizeof (table[0]); i++) - if (table[i].tag == t) return (_(table[i].description)); + if (table[i].tag == t) { + if (!*table[i].description) + return ""; + return (_(table[i].description)); + } return NULL; } diff --git a/src/libexif/canon/mnote-canon-tag.h b/src/libexif/canon/mnote-canon-tag.h index ce1a72e..aead76e 100644 --- a/src/libexif/canon/mnote-canon-tag.h +++ b/src/libexif/canon/mnote-canon-tag.h @@ -1,6 +1,6 @@ /* mnote-canon-tag.h * - * Copyright © 2002 Lutz Müller <lutz@users.sourceforge.net> + * Copyright (c) 2002 Lutz Mueller <lutz@users.sourceforge.net> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -21,6 +21,8 @@ #ifndef __MNOTE_CANON_TAG_H__ #define __MNOTE_CANON_TAG_H__ +#include <libexif/exif-data.h> + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ @@ -28,8 +30,10 @@ extern "C" { enum _MnoteCanonTag { MNOTE_CANON_TAG_UNKNOWN_0 = 0x0, MNOTE_CANON_TAG_SETTINGS_1 = 0x1, + MNOTE_CANON_TAG_FOCAL_LENGTH = 0x2, MNOTE_CANON_TAG_UNKNOWN_3 = 0x3, MNOTE_CANON_TAG_SETTINGS_2 = 0x4, + MNOTE_CANON_TAG_PANORAMA = 0x5, MNOTE_CANON_TAG_IMAGE_TYPE = 0x6, MNOTE_CANON_TAG_FIRMWARE = 0x7, MNOTE_CANON_TAG_IMAGE_NUMBER = 0x8, @@ -37,13 +41,16 @@ enum _MnoteCanonTag { MNOTE_CANON_TAG_UNKNOWN_10 = 0xa, MNOTE_CANON_TAG_SERIAL_NUMBER = 0xc, MNOTE_CANON_TAG_UNKNOWN_13 = 0xd, - MNOTE_CANON_TAG_CUSTOM_FUNCS = 0xf + MNOTE_CANON_TAG_CUSTOM_FUNCS = 0xf, + MNOTE_CANON_TAG_COLOR_INFORMATION = 0xa0 }; typedef enum _MnoteCanonTag MnoteCanonTag; -const char *mnote_canon_tag_get_name (MnoteCanonTag tag); -const char *mnote_canon_tag_get_title (MnoteCanonTag tag); -const char *mnote_canon_tag_get_description (MnoteCanonTag tag); +const char *mnote_canon_tag_get_name (MnoteCanonTag); +const char *mnote_canon_tag_get_name_sub (MnoteCanonTag, unsigned int, ExifDataOption); +const char *mnote_canon_tag_get_title (MnoteCanonTag); +const char *mnote_canon_tag_get_title_sub (MnoteCanonTag, unsigned int, ExifDataOption); +const char *mnote_canon_tag_get_description (MnoteCanonTag); #ifdef __cplusplus } |