1 /* mnote-olympus-entry.c
2 *
3 * Copyright (c) 2002-2009 Lutz Mueller <lutz@users.sourceforge.net> et. al.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301 USA.
19 */
20
21 #include <config.h>
22 #include "mnote-olympus-entry.h"
23
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
27
28 #include <libexif/exif-format.h>
29 #include <libexif/exif-utils.h>
30 #include <libexif/exif-entry.h>
31 #include <libexif/i18n.h>
32
33 #define CF(format,target,v,maxlen) \
34 { \
35 if (format != target) { \
36 snprintf (v, maxlen, \
37 _("Invalid format '%s', " \
38 "expected '%s'."), \
39 exif_format_get_name (format), \
40 exif_format_get_name (target)); \
41 break; \
42 } \
43 }
44
45 #define CF2(format,target1,target2,v,maxlen) \
46 { \
47 if ((format != target1) && (format != target2)) { \
48 snprintf (v, maxlen, \
49 _("Invalid format '%s', " \
50 "expected '%s' or '%s'."), \
51 exif_format_get_name (format), \
52 exif_format_get_name (target1), \
53 exif_format_get_name (target2)); \
54 break; \
55 } \
56 }
57
58 #define CC(number,target,v,maxlen) \
59 { \
60 if (number != target) { \
61 snprintf (v, maxlen, \
62 _("Invalid number of components (%i, " \
63 "expected %i)."), (int) number, (int) target); \
64 break; \
65 } \
66 }
67
68 #define CC2(number,t1,t2,v,maxlen) \
69 { \
70 if ((number < t1) || (number > t2)) { \
71 snprintf (v, maxlen, \
72 _("Invalid number of components (%i, " \
73 "expected %i or %i)."), (int) number, \
74 (int) t1, (int) t2); \
75 break; \
76 } \
77 }
78
79 #define R2L(n) ((n).denominator ? (long)(n).numerator/(n).denominator : 0L)
80 #define R2D(n) ((n).denominator ? (double)(n).numerator/(n).denominator : 0.0)
81
82 static const struct {
83 MnoteOlympusTag tag;
84 ExifFormat fmt;
85 struct {
86 int index;
87 const char *string;
88 } elem[24];
89 } items[] = {
90 #ifndef NO_VERBOSE_TAG_DATA
91 { MNOTE_NIKON_TAG_LENSTYPE, EXIF_FORMAT_BYTE,
92 { {0, N_("AF non D lens")},
93 {1, N_("Manual")},
94 {2, N_("AF-D or AF-S lens")},
95 {6, N_("AF-D G lens")},
96 {10, N_("AF-D VR lens")},
97 {14, N_("AF-D G VR lens")},
98 {0, NULL}}},
99 { MNOTE_NIKON_TAG_FLASHUSED, EXIF_FORMAT_BYTE,
100 { {0, N_("Flash did not fire")},
101 {4, N_("Flash unit unknown")},
102 {7, N_("Flash is external")},
103 {9, N_("Flash is on camera")},
104 {0, NULL}}},
105 { MNOTE_NIKON1_TAG_QUALITY, EXIF_FORMAT_SHORT,
106 { {1, N_("VGA basic")},
107 {2, N_("VGA normal")},
108 {3, N_("VGA fine")},
109 {4, N_("SXGA basic")},
110 {5, N_("SXGA normal")},
111 {6, N_("SXGA fine")},
112 {10, N_("2 Mpixel basic")},
113 {11, N_("2 Mpixel normal")},
114 {12, N_("2 Mpixel fine")},
115 {0, NULL}}},
116 { MNOTE_NIKON1_TAG_COLORMODE, EXIF_FORMAT_SHORT,
117 { {1, N_("Color")},
118 {2, N_("Monochrome")},
119 {0, NULL}}},
120 { MNOTE_NIKON1_TAG_IMAGEADJUSTMENT, EXIF_FORMAT_SHORT,
121 { {0, N_("Normal")},
122 {1, N_("Bright+")},
123 {2, N_("Bright-")},
124 {3, N_("Contrast+")},
125 {4, N_("Contrast-")},
126 {0, NULL}}},
127 { MNOTE_NIKON1_TAG_CCDSENSITIVITY, EXIF_FORMAT_SHORT,
128 { {0, N_("ISO 80")},
129 {2, N_("ISO 160")},
130 {4, N_("ISO 320")},
131 {5, N_("ISO 100")},
132 {0, NULL}}},
133 { MNOTE_NIKON1_TAG_WHITEBALANCE, EXIF_FORMAT_SHORT,
134 { {0, N_("Auto")},
135 {1, N_("Preset")},
136 {2, N_("Daylight")},
137 {3, N_("Incandescence")},
138 {4, N_("Fluorescence")},
139 {5, N_("Cloudy")},
140 {6, N_("SpeedLight")},
141 {0, NULL}}},
142 { MNOTE_NIKON1_TAG_CONVERTER, EXIF_FORMAT_SHORT,
143 { {0, N_("No fisheye")},
144 {1, N_("Fisheye on")},
145 {0, NULL}}},
146 { MNOTE_OLYMPUS_TAG_QUALITY, EXIF_FORMAT_SHORT,
147 { {1, N_("Normal, SQ")},
148 {2, N_("Normal, HQ")},
149 {3, N_("Normal, SHQ")},
150 {4, N_("Normal, RAW")},
151 {5, N_("Normal, SQ1")},
152 {6, N_("Normal, SQ2")},
153 {7, N_("Normal, super high")},
154 {17, N_("Normal, standard")},
155 {0x101, N_("Fine, SQ")},
156 {0x102, N_("Fine, HQ")},
157 {0x103, N_("Fine, SHQ")},
158 {0x104, N_("Fine, RAW")},
159 {0x105, N_("Fine, SQ1")},
160 {0x106, N_("Fine, SQ2")},
161 {0x107, N_("Fine, super high")},
162 {0x201, N_("Super fine, SQ")},
163 {0x202, N_("Super fine, HQ")},
164 {0x203, N_("Super fine, SHQ")},
165 {0x204, N_("Super fine, RAW")},
166 {0x205, N_("Super fine, SQ1")},
167 {0x206, N_("Super fine, SQ2")},
168 {0x207, N_("Super fine, super high")},
169 {0x211, N_("Super fine, high")},
170 {0, NULL}}},
171 { MNOTE_OLYMPUS_TAG_MACRO, EXIF_FORMAT_SHORT,
172 { {0, N_("No")},
173 {1, N_("Yes")},
174 {2, N_("Super macro")},
175 {0, NULL}}},
176 { MNOTE_OLYMPUS_TAG_BWMODE, EXIF_FORMAT_SHORT,
177 { {0, N_("No")},
178 {1, N_("Yes")},
179 {0, NULL}}},
180 { MNOTE_OLYMPUS_TAG_ONETOUCHWB, EXIF_FORMAT_SHORT,
181 { {0, N_("Off")},
182 {1, N_("On")},
183 {2, N_("On (Preset)")},
184 {0, NULL}}},
185 { MNOTE_OLYMPUS_TAG_FLASHMODE, EXIF_FORMAT_SHORT,
186 { {0, N_("Auto")},
187 {1, N_("Red-eye reduction")},
188 {2, N_("Fill")},
189 {3, N_("Off")},
190 {0, NULL}}},
191 { MNOTE_OLYMPUS_TAG_FLASHDEVICE, EXIF_FORMAT_SHORT,
192 { {0, N_("None")},
193 {1, N_("Internal")},
194 {4, N_("External")},
195 {5, N_("Internal + external")},
196 {0, NULL}}},
197 { MNOTE_OLYMPUS_TAG_FOCUSRANGE, EXIF_FORMAT_SHORT,
198 { {0, N_("Normal")},
199 {1, N_("Macro")},
200 {0, NULL}}},
201 { MNOTE_OLYMPUS_TAG_MANFOCUS, EXIF_FORMAT_SHORT,
202 { {0, N_("Auto")},
203 {1, N_("Manual")},
204 {0, NULL}}},
205 { MNOTE_OLYMPUS_TAG_SHARPNESS, EXIF_FORMAT_SHORT,
206 { {0, N_("Normal")},
207 {1, N_("Hard")},
208 {2, N_("Soft")},
209 {0, NULL}}},
210 { MNOTE_OLYMPUS_TAG_EXTERNALFLASHBOUNCE, EXIF_FORMAT_SHORT,
211 { {0, N_("No")},
212 {1, N_("Yes")},
213 {0, NULL}}},
214 { MNOTE_OLYMPUS_TAG_CONTRAST, EXIF_FORMAT_SHORT,
215 { {0, N_("Hard")},
216 {1, N_("Normal")},
217 {2, N_("Soft")},
218 {0, NULL}}},
219 { MNOTE_OLYMPUS_TAG_PREVIEWIMAGEVALID, EXIF_FORMAT_LONG,
220 { {0, N_("No")},
221 {1, N_("Yes")},
222 {0, NULL}}},
223 { MNOTE_OLYMPUS_TAG_CCDSCANMODE, EXIF_FORMAT_SHORT,
224 { {0, N_("Interlaced")},
225 {1, N_("Progressive")},
226 {0, NULL}}},
227
228 { MNOTE_SANYO_TAG_SEQUENTIALSHOT, EXIF_FORMAT_SHORT,
229 { {0, N_("None")},
230 {1, N_("Standard")},
231 {2, N_("Best")},
232 {3, N_("Adjust exposure")},
233 {0, NULL}}},
234 { MNOTE_SANYO_TAG_FOCUSMODE, EXIF_FORMAT_SHORT,
235 { {1, N_("Spot focus")},
236 {2, N_("Normal focus")},
237 {0, NULL}}},
238 { MNOTE_SANYO_TAG_RECORDSHUTTERRELEASE, EXIF_FORMAT_SHORT,
239 { {0, N_("Record while down")},
240 {1, N_("Press start, press stop")},
241 {0, NULL}}},
242 { MNOTE_SANYO_TAG_RESAVED, EXIF_FORMAT_SHORT,
243 { {0, N_("No")},
244 {1, N_("Yes")},
245 {0, NULL}}},
246 { MNOTE_SANYO_TAG_CCDSENSITIVITY, EXIF_FORMAT_SHORT,
247 { {0, N_("Auto")},
248 {1, N_("ISO 50")},
249 {3, N_("ISO 100")},
250 {4, N_("ISO 200")},
251 {5, N_("ISO 400")},
252 {0, NULL}}},
253 { MNOTE_SANYO_TAG_SCENESELECT, EXIF_FORMAT_SHORT,
254 { {0, N_("Off")},
255 {1, N_("Sport")},
256 {2, N_("TV")},
257 {3, N_("Night")},
258 {4, N_("User 1")},
259 {5, N_("User 2")},
260 {6, N_("Lamp")},
261 {0, NULL}}},
262 { MNOTE_SANYO_TAG_SEQUENCESHOTINTERVAL, EXIF_FORMAT_SHORT,
263 { {0, N_("5 frames/sec")},
264 {1, N_("10 frames/sec")},
265 {2, N_("15 frames/sec")},
266 {3, N_("20 frames/sec")},
267 {0, NULL}}},
268 #endif
269 { 0, 0, { { 0, NULL } } }
270 };
271
272 char *
mnote_olympus_entry_get_value(MnoteOlympusEntry * entry,char * v,unsigned int maxlen)273 mnote_olympus_entry_get_value (MnoteOlympusEntry *entry, char *v, unsigned int maxlen)
274 {
275 char buf[30];
276 ExifLong vl;
277 ExifSLong vsl;
278 ExifShort vs = 0;
279 ExifSShort vss = 0;
280 ExifRational vr, vr2;
281 ExifSRational vsr;
282 int i, j;
283 double r, b;
284
285 if (!entry)
286 return (NULL);
287
288 memset (v, 0, maxlen);
289 maxlen--;
290
291 if ((!entry->data) && (entry->components > 0))
292 return (v);
293
294 if ((!entry->data) && (entry->size > 0))
295 return NULL; /* internal inconsistency error */
296
297 switch (entry->tag) {
298
299 /* Nikon */
300 case MNOTE_NIKON_TAG_FIRMWARE:
301 CF (entry->format, EXIF_FORMAT_UNDEFINED, v, maxlen);
302 CC (entry->components, 4, v, maxlen);
303 vl = exif_get_long (entry->data, EXIF_BYTE_ORDER_INTEL);
304 if ((vl & 0xF0F0F0F0) == 0x30303030) {
305 memcpy (v, entry->data, MIN (maxlen, 4));
306 } else {
307 snprintf (v, maxlen, "%04lx", (long unsigned int) vl);
308 }
309 break;
310 case MNOTE_NIKON_TAG_ISO:
311 CF (entry->format, EXIF_FORMAT_SHORT, v, maxlen);
312 CC (entry->components, 2, v, maxlen);
313 /*vs = exif_get_short (entry->data, entry->order);*/
314 vs = exif_get_short (entry->data + 2, entry->order);
315 snprintf (v, maxlen, "ISO %hd", vs);
316 break;
317 case MNOTE_NIKON_TAG_ISO2:
318 CF (entry->format, EXIF_FORMAT_SHORT, v, maxlen);
319 CC (entry->components, 2, v, maxlen);
320 /*vs = exif_get_short (entry->data, entry->order);*/
321 vs = exif_get_short (entry->data + 2, entry->order);
322 snprintf (v, maxlen, "ISO2 %hd", vs);
323 break;
324 case MNOTE_NIKON_TAG_QUALITY:
325 case MNOTE_NIKON_TAG_COLORMODE:
326 case MNOTE_NIKON_TAG_COLORMODE1:
327 case MNOTE_NIKON_TAG_WHITEBALANCE:
328 case MNOTE_NIKON_TAG_SHARPENING:
329 case MNOTE_NIKON_TAG_FOCUSMODE:
330 case MNOTE_NIKON_TAG_FLASHSETTING:
331 case MNOTE_NIKON_TAG_ISOSELECTION:
332 case MNOTE_NIKON_TAG_FLASHMODE:
333 case MNOTE_NIKON_TAG_IMAGEADJUSTMENT:
334 case MNOTE_NIKON_TAG_ADAPTER:
335 case MNOTE_NIKON_TAG_SATURATION2:
336 case MNOTE_EPSON_TAG_SOFTWARE:
337 CF (entry->format, EXIF_FORMAT_ASCII, v, maxlen);
338 memcpy(v, entry->data, MIN (maxlen, entry->size));
339 break;
340 case MNOTE_NIKON_TAG_TOTALPICTURES:
341 case MNOTE_EPSON_TAG_IMAGE_WIDTH:
342 case MNOTE_EPSON_TAG_IMAGE_HEIGHT:
343 CF (entry->format, EXIF_FORMAT_LONG, v, maxlen);
344 CC (entry->components, 1, v, maxlen);
345 vl = exif_get_long (entry->data, entry->order);
346 snprintf (v, maxlen, "%lu", (long unsigned int) vl );
347 break;
348 case MNOTE_NIKON_TAG_LENS_FSTOPS:
349 case MNOTE_NIKON_TAG_EXPOSUREDIFF: {
350 unsigned char a,b,c;
351 CF (entry->format, EXIF_FORMAT_UNDEFINED, v, maxlen);
352 CC (entry->components, 4, v, maxlen);
353 vl = exif_get_long (entry->data, entry->order);
354 a = (vl>>24)&0xff; b = (vl>>16)&0xff; c = (vl>>8)&0xff;
355 snprintf (v, maxlen, "%.1f", c?(double)a*((double)b/(double)c):0 );
356 break;
357 }
358 case MNOTE_NIKON_TAG_FLASHEXPCOMPENSATION:
359 case MNOTE_NIKON_TAG_FLASHEXPOSUREBRACKETVAL:
360 CF (entry->format, EXIF_FORMAT_UNDEFINED, v, maxlen);
361 CC (entry->components, 4, v, maxlen);
362 vl = exif_get_long (entry->data, entry->order);
363 snprintf (v, maxlen, "%.1f", ((long unsigned int) vl>>24)/6.0 );
364 break;
365 case MNOTE_NIKON_TAG_SATURATION:
366 case MNOTE_NIKON_TAG_WHITEBALANCEFINE:
367 case MNOTE_NIKON_TAG_HUE:
368 case MNOTE_OLYMPUS_TAG_SENSORTEMPERATURE:
369 case MNOTE_OLYMPUS_TAG_LENSTEMPERATURE:
370 CF (entry->format, EXIF_FORMAT_SSHORT, v, maxlen);
371 CC (entry->components, 1, v, maxlen);
372 vs = exif_get_short (entry->data, entry->order);
373 snprintf (v, maxlen, "%hd", vs);
374 break;
375 case MNOTE_NIKON_TAG_WHITEBALANCERB:
376 CF (entry->format, EXIF_FORMAT_RATIONAL, v, maxlen);
377 CC (entry->components, 4, v, maxlen);
378 vr = exif_get_rational (entry->data, entry->order);
379 r = R2D(vr);
380 vr = exif_get_rational (entry->data+8, entry->order);
381 b = R2D(vr);
382 snprintf (v, maxlen, _("Red Correction %f, blue Correction %f"), r,b);
383 break;
384 case MNOTE_NIKON_TAG_MANUALFOCUSDISTANCE:
385 CF (entry->format, EXIF_FORMAT_RATIONAL, v, maxlen);
386 CC (entry->components, 1, v, maxlen);
387 vr = exif_get_rational (entry->data, entry->order);
388 if (!vr.numerator || !vr.denominator) {
389 strncpy (v, _("No manual focus selection"), maxlen);
390 } else {
391 r = R2D(vr);
392 snprintf (v, maxlen, _("%2.2f meters"), r);
393 }
394 break;
395 case MNOTE_NIKON_TAG_SENSORPIXELSIZE:
396 CF (entry->format, EXIF_FORMAT_RATIONAL, v, maxlen);
397 CC (entry->components, 2, v, maxlen);
398 vr = exif_get_rational (entry->data, entry->order);
399 vr2 = exif_get_rational (entry->data+8, entry->order);
400 r = R2D(vr);
401 b = R2D(vr2);
402 snprintf (v, maxlen, "%2.2f x %2.2f um", r, b);
403 break;
404 case MNOTE_NIKON_TAG_BRACKETING:
405 CF2 (entry->format, EXIF_FORMAT_BYTE, EXIF_FORMAT_SHORT, v, maxlen);
406 CC (entry->components, 1, v, maxlen);
407 if (EXIF_FORMAT_SHORT == entry->format) {
408 vs = exif_get_short (entry->data, entry->order);
409 } else {
410 vs = entry->data[0];
411 }
412 snprintf (v, maxlen, "%hd", vs);
413 break;
414 case MNOTE_NIKON_TAG_AFFOCUSPOSITION:
415 CF (entry->format, EXIF_FORMAT_UNDEFINED, v, maxlen);
416 CC (entry->components, 4, v, maxlen);
417 switch ( *( entry->data+1) ) {
418 case 0: strncpy (v, _("AF position: center"), maxlen); break;
419 case 1: strncpy (v, _("AF position: top"), maxlen); break;
420 case 2: strncpy (v, _("AF position: bottom"), maxlen); break;
421 case 3: strncpy (v, _("AF position: left"), maxlen); break;
422 case 4: strncpy (v, _("AF position: right"), maxlen); break;
423 case 5: strncpy (v, _("AF position: upper-left"), maxlen); break;
424 case 6: strncpy (v, _("AF position: upper-right"), maxlen); break;
425 case 7: strncpy (v, _("AF position: lower-left"), maxlen); break;
426 case 8: strncpy (v, _("AF position: lower-right"), maxlen); break;
427 case 9: strncpy (v, _("AF position: far left"), maxlen); break;
428 case 10: strncpy (v, _("AF position: far right"), maxlen); break;
429 default: strncpy (v, _("Unknown AF position"), maxlen);
430 }
431 break;
432 case MNOTE_OLYMPUS_TAG_FLASHDEVICE:
433 CF (entry->format, EXIF_FORMAT_SHORT, v, maxlen);
434 CC (entry->components, 2, v, maxlen);
435 vs = exif_get_short(entry->data, entry->order);
436 /* search for the tag */
437 for (i = 0; (items[i].tag && items[i].tag != entry->tag); i++)
438 ;
439 if (!items[i].tag) {
440 snprintf (v, maxlen, _("Internal error (unknown value %hi)"), vs);
441 break;
442 }
443 CF (entry->format, items[i].fmt, v, maxlen);
444 /* find the value */
445 for (j = 0; items[i].elem[j].string &&
446 (items[i].elem[j].index < vs); j++);
447 if (items[i].elem[j].index != vs) {
448 snprintf (v, maxlen, _("Unknown value %hi"), vs);
449 break;
450 }
451 strncpy (v, _(items[i].elem[j].string), maxlen);
452 break;
453 case MNOTE_OLYMPUS_TAG_DIGIZOOM:
454 if (entry->format == EXIF_FORMAT_RATIONAL) {
455 CC (entry->components, 1, v, maxlen);
456 vr = exif_get_rational (entry->data, entry->order);
457 if (!vr.numerator || !vr.denominator) {
458 strncpy (v, _("None"), maxlen);
459 } else {
460 r = R2D(vr);
461 snprintf (v, maxlen, "%2.2f", r);
462 }
463 break;
464 }
465 /* to handle SHORT version of this tag, */
466 /* fall through */
467 case MNOTE_NIKON_TAG_LENSTYPE:
468 case MNOTE_NIKON_TAG_FLASHUSED:
469 case MNOTE_NIKON1_TAG_QUALITY:
470 case MNOTE_NIKON1_TAG_COLORMODE:
471 case MNOTE_NIKON1_TAG_IMAGEADJUSTMENT:
472 case MNOTE_NIKON1_TAG_CCDSENSITIVITY:
473 case MNOTE_NIKON1_TAG_WHITEBALANCE:
474 case MNOTE_NIKON1_TAG_CONVERTER:
475 case MNOTE_OLYMPUS_TAG_QUALITY:
476 case MNOTE_OLYMPUS_TAG_MACRO:
477 case MNOTE_OLYMPUS_TAG_BWMODE:
478 case MNOTE_OLYMPUS_TAG_ONETOUCHWB:
479 case MNOTE_OLYMPUS_TAG_FLASHMODE:
480 case MNOTE_OLYMPUS_TAG_FOCUSRANGE:
481 case MNOTE_OLYMPUS_TAG_MANFOCUS:
482 case MNOTE_OLYMPUS_TAG_SHARPNESS:
483 case MNOTE_OLYMPUS_TAG_EXTERNALFLASHBOUNCE:
484 case MNOTE_OLYMPUS_TAG_CONTRAST:
485 case MNOTE_OLYMPUS_TAG_PREVIEWIMAGEVALID:
486 case MNOTE_OLYMPUS_TAG_CCDSCANMODE:
487 case MNOTE_SANYO_TAG_SEQUENTIALSHOT:
488 case MNOTE_SANYO_TAG_FOCUSMODE:
489 case MNOTE_SANYO_TAG_RECORDSHUTTERRELEASE:
490 case MNOTE_SANYO_TAG_RESAVED:
491 case MNOTE_SANYO_TAG_CCDSENSITIVITY:
492 case MNOTE_SANYO_TAG_SCENESELECT:
493 case MNOTE_SANYO_TAG_SEQUENCESHOTINTERVAL:
494 CC (entry->components, 1, v, maxlen);
495 switch (entry->format) {
496 case EXIF_FORMAT_BYTE:
497 case EXIF_FORMAT_UNDEFINED:
498 vs = entry->data[0];
499 break;
500 case EXIF_FORMAT_SHORT:
501 vs = exif_get_short(entry->data, entry->order);
502 break;
503 default:
504 vs = 0;
505 break;
506 }
507 /* search for the tag */
508 for (i = 0; (items[i].tag && items[i].tag != entry->tag); i++)
509 ;
510 if (!items[i].tag) {
511 snprintf (v, maxlen, _("Internal error (unknown value %hi)"), vs);
512 break;
513 }
514 CF (entry->format, items[i].fmt, v, maxlen);
515 /* find the value */
516 for (j = 0; items[i].elem[j].string &&
517 (items[i].elem[j].index < vs); j++);
518 if (items[i].elem[j].index != vs) {
519 snprintf (v, maxlen, _("Unknown value %hi"), vs);
520 break;
521 }
522 strncpy (v, _(items[i].elem[j].string), maxlen);
523 break;
524 case MNOTE_OLYMPUS_TAG_NOISEREDUCTION:
525 case MNOTE_SANYO_TAG_WIDERANGE:
526 case MNOTE_SANYO_TAG_COLORADJUSTMENTMODE:
527 case MNOTE_SANYO_TAG_QUICKSHOT:
528 case MNOTE_SANYO_TAG_VOICEMEMO:
529 case MNOTE_SANYO_TAG_FLICKERREDUCE:
530 case MNOTE_SANYO_TAG_OPTICALZOOM:
531 case MNOTE_SANYO_TAG_DIGITALZOOM:
532 case MNOTE_SANYO_TAG_LIGHTSOURCESPECIAL:
533 CF (entry->format, EXIF_FORMAT_SHORT, v, maxlen);
534 CC (entry->components, 1, v, maxlen);
535 vs = exif_get_short (entry->data, entry->order);
536 switch (vs) {
537 case 0:
538 strncpy (v, _("Off"), maxlen);
539 break;
540 case 1:
541 strncpy (v, _("On"), maxlen);
542 break;
543 default:
544 sprintf (buf, _("Unknown %hu"), vs);
545 strncat (v, buf, maxlen - strlen (v));
546 break;
547 }
548 break;
549 case MNOTE_SANYO_TAG_SELFTIMER:
550 CF (entry->format, EXIF_FORMAT_SHORT, v, maxlen);
551 CC (entry->components, 1, v, maxlen);
552 vs = exif_get_short (entry->data, entry->order);
553 switch (vs) {
554 case 0:
555 strncpy (v, _("Off"), maxlen);
556 break;
557 case 1:
558 strncpy (v, _("On"), maxlen);
559 break;
560 case 2:
561 strncpy (v, _("2 sec."), maxlen);
562 break;
563 default:
564 sprintf (buf, _("Unknown %hu"), vs);
565 strncat (v, buf, maxlen - strlen (v));
566 break;
567 }
568 break;
569 case MNOTE_NIKON_TAG_LENS:
570 CF (entry->format, EXIF_FORMAT_RATIONAL, v, maxlen);
571 CC (entry->components, 4, v, maxlen);
572 {
573 double c,d;
574 unsigned long a,b;
575 vr = exif_get_rational (entry->data, entry->order);
576 a = R2L(vr);
577 vr = exif_get_rational (entry->data+8, entry->order);
578 b = R2L(vr);
579 vr = exif_get_rational (entry->data+16, entry->order);
580 c = R2D(vr);
581 vr = exif_get_rational (entry->data+24, entry->order);
582 d = R2D(vr);
583 snprintf (v, maxlen, "%ld-%ldmm 1:%3.1f - %3.1f",a,b,c,d);
584 }
585 break;
586
587 /* Olympus */
588 case MNOTE_OLYMPUS_TAG_MODE:
589 CF (entry->format, EXIF_FORMAT_LONG, v, maxlen);
590 CC (entry->components, 3, v, maxlen);
591 vl = exif_get_long (entry->data, entry->order);
592 switch (vl) {
593 case 0:
594 strncpy (v, _("Normal"), maxlen);
595 break;
596 case 1:
597 strncpy (v, _("Unknown"), maxlen);
598 break;
599 case 2:
600 strncpy (v, _("Fast"), maxlen);
601 break;
602 case 3:
603 strncpy (v, _("Panorama"), maxlen);
604 break;
605 default:
606 snprintf (v, maxlen, "%li", (long int) vl);
607 }
608 vl = exif_get_long (entry->data + 4, entry->order);
609 snprintf (buf, sizeof (buf), "/%li/", (long int) vl);
610 strncat (v, buf, maxlen - strlen (v));
611 vl = exif_get_long (entry->data + 8, entry->order);
612 switch (vl) {
613 case 1:
614 strncat (v, _("Left to right"), maxlen - strlen (v));
615 break;
616 case 2:
617 strncat (v, _("Right to left"), maxlen - strlen (v));
618 break;
619 case 3:
620 strncat (v, _("Bottom to top"), maxlen - strlen (v));
621 break;
622 case 4:
623 strncat (v, _("Top to bottom"), maxlen - strlen (v));
624 break;
625 default:
626 snprintf (buf, sizeof (buf), "%li",
627 (long int) vl);
628 strncat (v, buf, maxlen - strlen (v));
629 }
630 break;
631 case MNOTE_OLYMPUS_TAG_LENSDISTORTION:
632 if (entry->format == EXIF_FORMAT_SHORT) {
633 /* Epson uses a single SHORT here */
634 CC (entry->components, 1, v, maxlen);
635 vs = exif_get_short (entry->data, entry->order);
636 sprintf (buf, "%hu", vs);
637 strncat (v, buf, maxlen - strlen (v));
638 } else {
639 /* Others use an array of SSHORT here */
640 CC (entry->components, 6, v, maxlen);
641 CF (entry->format, EXIF_FORMAT_SSHORT, v, maxlen);
642 for (i=0; i < (int)entry->components; ++i) {
643 vss = exif_get_sshort (entry->data+2*i, entry->order);
644 sprintf (buf, "%hd ", vss);
645 strncat (v, buf, maxlen - strlen (v));
646 }
647 }
648 break;
649 case MNOTE_OLYMPUS_TAG_COLORCONTROL:
650 CF (entry->format, EXIF_FORMAT_SHORT, v, maxlen);
651 CC (entry->components, 6, v, maxlen);
652 for (i=0; i < (int)entry->components; ++i) {
653 vs = exif_get_short (entry->data+2*i, entry->order);
654 sprintf (buf, "%hu ", vs);
655 strncat (v, buf, maxlen - strlen (v));
656 }
657 break;
658 case MNOTE_OLYMPUS_TAG_VERSION:
659 CF (entry->format, EXIF_FORMAT_ASCII, v, maxlen);
660 CC2 (entry->components, 5, 8, v, maxlen);
661 strncpy (v, (char *)entry->data, MIN (maxlen, entry->size));
662 break;
663 case MNOTE_OLYMPUS_TAG_SERIALNUMBER2:
664 CF (entry->format, EXIF_FORMAT_ASCII, v, maxlen);
665 strncpy (v, (char *)entry->data, MIN (maxlen, entry->size));
666 break;
667 case MNOTE_OLYMPUS_TAG_INFO:
668 CF (entry->format, EXIF_FORMAT_ASCII, v, maxlen);
669 CC2 (entry->components, 52, 60, v, maxlen);
670 strncpy (v, (char *)entry->data, MIN (maxlen, entry->size));
671 break;
672 case MNOTE_OLYMPUS_TAG_ID:
673 CF (entry->format, EXIF_FORMAT_UNDEFINED, v, maxlen);
674 CC (entry->components, 32, v, maxlen);
675 strncpy (v, (char *)entry->data, MIN (maxlen, entry->size));
676 break;
677 case MNOTE_OLYMPUS_TAG_UNKNOWN_4:
678 CF (entry->format, EXIF_FORMAT_LONG, v, maxlen);
679 CC (entry->components, 30, v, maxlen);
680 for (i=0; i < (int)entry->components; ++i) {
681 vl = exif_get_long (entry->data+4*i, entry->order);
682 sprintf (buf, "%lu ", (unsigned long)vl);
683 strncat (v, buf, maxlen - strlen (v));
684 }
685 break;
686 case MNOTE_OLYMPUS_TAG_FOCUSDIST:
687 CF (entry->format, EXIF_FORMAT_RATIONAL, v, maxlen);
688 CC (entry->components, 1, v, maxlen);
689 vr = exif_get_rational (entry->data, entry->order);
690 if (!vr.numerator || !vr.denominator) {
691 strncpy (v, _("Unknown"), maxlen);
692 }
693 else {
694 unsigned long tmp = vr.numerator / vr.denominator;
695 snprintf (v, maxlen, "%li mm", tmp);
696 }
697 break;
698 case MNOTE_OLYMPUS_TAG_WBALANCE:
699 CF (entry->format, EXIF_FORMAT_SHORT, v, maxlen);
700 CC (entry->components, 2, v, maxlen);
701 vs = exif_get_short (entry->data, entry->order);
702 switch (vs) {
703 case 1:
704 strncpy (v, _("Automatic"), maxlen);
705 break;
706 case 2:
707 {
708 ExifShort v2 = exif_get_short (entry->data + 2, entry->order);
709 unsigned long colorTemp = 0;
710 switch (v2) {
711 case 2:
712 colorTemp = 3000;
713 break;
714 case 3:
715 colorTemp = 3700;
716 break;
717 case 4:
718 colorTemp = 4000;
719 break;
720 case 5:
721 colorTemp = 4500;
722 break;
723 case 6:
724 colorTemp = 5500;
725 break;
726 case 7:
727 colorTemp = 6500;
728 break;
729 case 9:
730 colorTemp = 7500;
731 break;
732 }
733 if (colorTemp) {
734 snprintf (v, maxlen, _("Manual: %liK"), colorTemp);
735 }
736 else {
737 strncpy (v, _("Manual: unknown"), maxlen);
738 }
739
740 }
741 break;
742 case 3:
743 strncpy (v, _("One-touch"), maxlen);
744 break;
745 default:
746 strncpy (v, _("Unknown"), maxlen);
747 break;
748 }
749 break;
750 case MNOTE_OLYMPUS_TAG_REDBALANCE:
751 case MNOTE_OLYMPUS_TAG_BLUEBALANCE:
752 CF (entry->format, EXIF_FORMAT_SHORT, v, maxlen);
753 CC (entry->components, 2, v, maxlen);
754 vs = exif_get_short (entry->data, entry->order);
755 snprintf (v, maxlen, "%hu ", vs);
756 vs = exif_get_short (entry->data + 2, entry->order);
757 sprintf (buf, "%hu", vs);
758 strncat (v, buf, maxlen - strlen (v));
759 break;
760 case MNOTE_OLYMPUS_TAG_BLACKLEVEL:
761 case MNOTE_NIKON_TAG_IMAGEBOUNDARY:
762 CC (entry->components, 4, v, maxlen);
763 /* Fall through to COLORMATRIX */
764 /* fall through */
765 case MNOTE_OLYMPUS_TAG_COLORMATRIX:
766 CF (entry->format, EXIF_FORMAT_SHORT, v, maxlen);
767 if (entry->tag == MNOTE_OLYMPUS_TAG_COLORMATRIX)
768 CC (entry->components, 9, v, maxlen);
769 for (i=0; i < (int)entry->components; ++i) {
770 vs = exif_get_short (entry->data+2*i, entry->order);
771 sprintf (buf, "%hu ", vs);
772 strncat (v, buf, maxlen - strlen (v));
773 }
774 break;
775 case MNOTE_NIKON1_TAG_FOCUS:
776 case MNOTE_NIKON_TAG_DIGITALZOOM:
777 case MNOTE_NIKON1_TAG_DIGITALZOOM:
778 case MNOTE_OLYMPUS_TAG_FOCALPLANEDIAGONAL:
779 CF (entry->format, EXIF_FORMAT_RATIONAL, v, maxlen);
780 /* Fall through to default handler for display */
781 /* fall through */
782 default:
783 switch (entry->format) {
784 case EXIF_FORMAT_ASCII:
785 strncpy (v, (char *)entry->data, MIN (maxlen, entry->size));
786 break;
787 case EXIF_FORMAT_SHORT:
788 CC (entry->components, 1, v, maxlen);
789 vs = exif_get_short (entry->data, entry->order);
790 snprintf (v, maxlen, "%hu", vs);
791 break;
792 case EXIF_FORMAT_SSHORT:
793 CC (entry->components, 1, v, maxlen);
794 vss = exif_get_sshort (entry->data, entry->order);
795 snprintf (v, maxlen, "%hi", vss);
796 break;
797 case EXIF_FORMAT_LONG:
798 CC (entry->components, 1, v, maxlen);
799 vl = exif_get_long (entry->data, entry->order);
800 snprintf (v, maxlen, "%lu", (long unsigned) vl);
801 break;
802 case EXIF_FORMAT_SLONG:
803 CC (entry->components, 1, v, maxlen);
804 vsl = exif_get_slong (entry->data, entry->order);
805 snprintf (v, maxlen, "%li", (long int) vsl);
806 break;
807 case EXIF_FORMAT_RATIONAL:
808 CC (entry->components, 1, v, maxlen);
809 vr = exif_get_rational (entry->data, entry->order);
810 if (!vr.denominator) {
811 strncpy (v, _("Infinite"), maxlen);
812 } else {
813 r = R2D(vr);
814 snprintf (v, maxlen, "%2.3f", r);
815 }
816 break;
817 case EXIF_FORMAT_SRATIONAL:
818 CC (entry->components, 1, v, maxlen);
819 vsr = exif_get_srational (entry->data, entry->order);
820 if (!vsr.denominator) {
821 strncpy (v, _("Infinite"), maxlen);
822 } else {
823 r = R2D(vsr);
824 snprintf (v, maxlen, "%2.3f", r);
825 }
826 break;
827 case EXIF_FORMAT_UNDEFINED:
828 default:
829 snprintf (v, maxlen, _("%i bytes unknown data: "),
830 entry->size);
831 for (i = 0; i < (int)entry->size; i++) {
832 sprintf (buf, "%02x", entry->data[i]);
833 strncat (v, buf, maxlen - strlen (v));
834 }
835 break;
836 }
837 break;
838 }
839
840 return (v);
841 }
842