00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <config.h>
00022 #include "mnote-olympus-entry.h"
00023
00024 #include <stdio.h>
00025 #include <stdlib.h>
00026 #include <string.h>
00027
00028 #include <libexif/exif-format.h>
00029 #include <libexif/exif-utils.h>
00030 #include <libexif/exif-entry.h>
00031 #include <libexif/i18n.h>
00032
00033 #define CF(format,target,v,maxlen) \
00034 { \
00035 if (format != target) { \
00036 snprintf (v, maxlen, \
00037 _("Invalid format '%s', " \
00038 "expected '%s'."), \
00039 exif_format_get_name (format), \
00040 exif_format_get_name (target)); \
00041 break; \
00042 } \
00043 }
00044
00045 #define CF2(format,target1,target2,v,maxlen) \
00046 { \
00047 if ((format != target1) && (format != target2)) { \
00048 snprintf (v, maxlen, \
00049 _("Invalid format '%s', " \
00050 "expected '%s' or '%s'."), \
00051 exif_format_get_name (format), \
00052 exif_format_get_name (target1), \
00053 exif_format_get_name (target2)); \
00054 break; \
00055 } \
00056 }
00057
00058 #define CC(number,target,v,maxlen) \
00059 { \
00060 if (number != target) { \
00061 snprintf (v, maxlen, \
00062 _("Invalid number of components (%i, " \
00063 "expected %i)."), (int) number, (int) target); \
00064 break; \
00065 } \
00066 }
00067
00068 #define CC2(number,t1,t2,v,maxlen) \
00069 { \
00070 if ((number < t1) || (number > t2)) { \
00071 snprintf (v, maxlen, \
00072 _("Invalid number of components (%i, " \
00073 "expected %i or %i)."), (int) number, \
00074 (int) t1, (int) t2); \
00075 break; \
00076 } \
00077 }
00078
00079 #define R2L(n) ((n).denominator ? (long)(n).numerator/(n).denominator : 0L)
00080 #define R2D(n) ((n).denominator ? (double)(n).numerator/(n).denominator : 0.0)
00081
00082 static const struct {
00083 ExifTag tag;
00084 ExifFormat fmt;
00085 struct {
00086 int index;
00087 const char *string;
00088 } elem[24];
00089 } items[] = {
00090 #ifndef NO_VERBOSE_TAG_DATA
00091 { MNOTE_NIKON_TAG_LENSTYPE, EXIF_FORMAT_BYTE,
00092 { {0, N_("AF non D lens")},
00093 {1, N_("Manual")},
00094 {2, N_("AF-D or AF-S lens")},
00095 {6, N_("AF-D G lens")},
00096 {10, N_("AF-D VR lens")},
00097 {14, N_("AF-D G VR lens")},
00098 {0, NULL}}},
00099 { MNOTE_NIKON_TAG_FLASHUSED, EXIF_FORMAT_BYTE,
00100 { {0, N_("Flash did not fire")},
00101 {4, N_("Flash unit unknown")},
00102 {7, N_("Flash is external")},
00103 {9, N_("Flash is on camera")},
00104 {0, NULL}}},
00105 { MNOTE_NIKON1_TAG_QUALITY, EXIF_FORMAT_SHORT,
00106 { {1, N_("VGA basic")},
00107 {2, N_("VGA normal")},
00108 {3, N_("VGA fine")},
00109 {4, N_("SXGA basic")},
00110 {5, N_("SXGA normal")},
00111 {6, N_("SXGA fine")},
00112 {10, N_("2 Mpixel basic")},
00113 {11, N_("2 Mpixel normal")},
00114 {12, N_("2 Mpixel fine")},
00115 {0, NULL}}},
00116 { MNOTE_NIKON1_TAG_COLORMODE, EXIF_FORMAT_SHORT,
00117 { {1, N_("Color")},
00118 {2, N_("Monochrome")},
00119 {0, NULL}}},
00120 { MNOTE_NIKON1_TAG_IMAGEADJUSTMENT, EXIF_FORMAT_SHORT,
00121 { {0, N_("Normal")},
00122 {1, N_("Bright+")},
00123 {2, N_("Bright-")},
00124 {3, N_("Contrast+")},
00125 {4, N_("Contrast-")},
00126 {0, NULL}}},
00127 { MNOTE_NIKON1_TAG_CCDSENSITIVITY, EXIF_FORMAT_SHORT,
00128 { {0, N_("ISO 80")},
00129 {2, N_("ISO 160")},
00130 {4, N_("ISO 320")},
00131 {5, N_("ISO 100")},
00132 {0, NULL}}},
00133 { MNOTE_NIKON1_TAG_WHITEBALANCE, EXIF_FORMAT_SHORT,
00134 { {0, N_("Auto")},
00135 {1, N_("Preset")},
00136 {2, N_("Daylight")},
00137 {3, N_("Incandescence")},
00138 {4, N_("Fluorescence")},
00139 {5, N_("Cloudy")},
00140 {6, N_("SpeedLight")},
00141 {0, NULL}}},
00142 { MNOTE_NIKON1_TAG_CONVERTER, EXIF_FORMAT_SHORT,
00143 { {0, N_("No fisheye")},
00144 {1, N_("Fisheye on")},
00145 {0, NULL}}},
00146 { MNOTE_OLYMPUS_TAG_QUALITY, EXIF_FORMAT_SHORT,
00147 { {1, N_("Normal, SQ")},
00148 {2, N_("Normal, HQ")},
00149 {3, N_("Normal, SHQ")},
00150 {4, N_("Normal, RAW")},
00151 {5, N_("Normal, SQ1")},
00152 {6, N_("Normal, SQ2")},
00153 {7, N_("Normal, super high")},
00154 {17, N_("Normal, standard")},
00155 {0x101, N_("Fine, SQ")},
00156 {0x102, N_("Fine, HQ")},
00157 {0x103, N_("Fine, SHQ")},
00158 {0x104, N_("Fine, RAW")},
00159 {0x105, N_("Fine, SQ1")},
00160 {0x106, N_("Fine, SQ2")},
00161 {0x107, N_("Fine, super high")},
00162 {0x201, N_("Super fine, SQ")},
00163 {0x202, N_("Super fine, HQ")},
00164 {0x203, N_("Super fine, SHQ")},
00165 {0x204, N_("Super fine, RAW")},
00166 {0x205, N_("Super fine, SQ1")},
00167 {0x206, N_("Super fine, SQ2")},
00168 {0x207, N_("Super fine, super high")},
00169 {0x211, N_("Super fine, high")},
00170 {0, NULL}}},
00171 { MNOTE_OLYMPUS_TAG_MACRO, EXIF_FORMAT_SHORT,
00172 { {0, N_("No")},
00173 {1, N_("Yes")},
00174 {2, N_("Super macro")},
00175 {0, NULL}}},
00176 { MNOTE_OLYMPUS_TAG_BWMODE, EXIF_FORMAT_SHORT,
00177 { {0, N_("No")},
00178 {1, N_("Yes")},
00179 {0, NULL}}},
00180 { MNOTE_OLYMPUS_TAG_ONETOUCHWB, EXIF_FORMAT_SHORT,
00181 { {0, N_("Off")},
00182 {1, N_("On")},
00183 {2, N_("On (Preset)")},
00184 {0, NULL}}},
00185 { MNOTE_OLYMPUS_TAG_FLASHMODE, EXIF_FORMAT_SHORT,
00186 { {0, N_("Auto")},
00187 {1, N_("Red-eye reduction")},
00188 {2, N_("Fill")},
00189 {3, N_("Off")},
00190 {0, NULL}}},
00191 { MNOTE_OLYMPUS_TAG_FLASHDEVICE, EXIF_FORMAT_SHORT,
00192 { {0, N_("None")},
00193 {1, N_("Internal")},
00194 {4, N_("External")},
00195 {5, N_("Internal + external")},
00196 {0, NULL}}},
00197 { MNOTE_OLYMPUS_TAG_FOCUSRANGE, EXIF_FORMAT_SHORT,
00198 { {0, N_("Normal")},
00199 {1, N_("Macro")},
00200 {0, NULL}}},
00201 { MNOTE_OLYMPUS_TAG_MANFOCUS, EXIF_FORMAT_SHORT,
00202 { {0, N_("Auto")},
00203 {1, N_("Manual")},
00204 {0, NULL}}},
00205 { MNOTE_OLYMPUS_TAG_SHARPNESS, EXIF_FORMAT_SHORT,
00206 { {0, N_("Normal")},
00207 {1, N_("Hard")},
00208 {2, N_("Soft")},
00209 {0, NULL}}},
00210 { MNOTE_OLYMPUS_TAG_EXTERNALFLASHBOUNCE, EXIF_FORMAT_SHORT,
00211 { {0, N_("No")},
00212 {1, N_("Yes")},
00213 {0, NULL}}},
00214 { MNOTE_OLYMPUS_TAG_CONTRAST, EXIF_FORMAT_SHORT,
00215 { {0, N_("Hard")},
00216 {1, N_("Normal")},
00217 {2, N_("Soft")},
00218 {0, NULL}}},
00219 { MNOTE_OLYMPUS_TAG_PREVIEWIMAGEVALID, EXIF_FORMAT_LONG,
00220 { {0, N_("No")},
00221 {1, N_("Yes")},
00222 {0, NULL}}},
00223 { MNOTE_OLYMPUS_TAG_CCDSCANMODE, EXIF_FORMAT_SHORT,
00224 { {0, N_("Interlaced")},
00225 {1, N_("Progressive")},
00226 {0, NULL}}},
00227
00228 { MNOTE_SANYO_TAG_SEQUENTIALSHOT, EXIF_FORMAT_SHORT,
00229 { {0, N_("None")},
00230 {1, N_("Standard")},
00231 {2, N_("Best")},
00232 {3, N_("Adjust exposure")},
00233 {0, NULL}}},
00234 { MNOTE_SANYO_TAG_FOCUSMODE, EXIF_FORMAT_SHORT,
00235 { {1, N_("Spot focus")},
00236 {2, N_("Normal focus")},
00237 {0, NULL}}},
00238 { MNOTE_SANYO_TAG_RECORDSHUTTERRELEASE, EXIF_FORMAT_SHORT,
00239 { {0, N_("Record while down")},
00240 {1, N_("Press start, press stop")},
00241 {0, NULL}}},
00242 { MNOTE_SANYO_TAG_RESAVED, EXIF_FORMAT_SHORT,
00243 { {0, N_("No")},
00244 {1, N_("Yes")},
00245 {0, NULL}}},
00246 { MNOTE_SANYO_TAG_CCDSENSITIVITY, EXIF_FORMAT_SHORT,
00247 { {0, N_("Auto")},
00248 {1, N_("ISO 50")},
00249 {3, N_("ISO 100")},
00250 {4, N_("ISO 200")},
00251 {5, N_("ISO 400")},
00252 {0, NULL}}},
00253 { MNOTE_SANYO_TAG_SCENESELECT, EXIF_FORMAT_SHORT,
00254 { {0, N_("Off")},
00255 {1, N_("Sport")},
00256 {2, N_("TV")},
00257 {3, N_("Night")},
00258 {4, N_("User 1")},
00259 {5, N_("User 2")},
00260 {6, N_("Lamp")},
00261 {0, NULL}}},
00262 { MNOTE_SANYO_TAG_SEQUENCESHOTINTERVAL, EXIF_FORMAT_SHORT,
00263 { {0, N_("5 frames/sec")},
00264 {1, N_("10 frames/sec")},
00265 {2, N_("15 frames/sec")},
00266 {3, N_("20 frames/sec")},
00267 {0, NULL}}},
00268 #endif
00269 { 0, 0, { { 0, NULL } } }
00270 };
00271
00272 char *
00273 mnote_olympus_entry_get_value (MnoteOlympusEntry *entry, char *v, unsigned int maxlen)
00274 {
00275 char buf[30];
00276 ExifLong vl;
00277 ExifShort vs = 0;
00278 ExifSShort vss = 0;
00279 ExifRational vr, vr2;
00280 ExifSRational vsr;
00281 int i, j;
00282 double r, b;
00283
00284 if (!entry)
00285 return (NULL);
00286
00287 memset (v, 0, maxlen);
00288 maxlen--;
00289
00290 if ((!entry->data) && (entry->components > 0))
00291 return (v);
00292
00293 if ((!entry->data) && (entry->size > 0))
00294 return NULL;
00295
00296 switch (entry->tag) {
00297
00298
00299 case MNOTE_NIKON_TAG_FIRMWARE:
00300 CF (entry->format, EXIF_FORMAT_UNDEFINED, v, maxlen);
00301 CC (entry->components, 4, v, maxlen);
00302 vl = exif_get_long (entry->data, entry->order);
00303 if ((vl & 0xF0F0F0F0) == 0x30303030) {
00304 memcpy (v, entry->data, MIN (maxlen, 4));
00305 } else {
00306 snprintf (v, maxlen, "%04lx", (long unsigned int) vl);
00307 }
00308 break;
00309 case MNOTE_NIKON_TAG_ISO:
00310 CF (entry->format, EXIF_FORMAT_SHORT, v, maxlen);
00311 CC (entry->components, 2, v, maxlen);
00312
00313 vs = exif_get_short (entry->data + 2, entry->order);
00314 snprintf (v, maxlen, "ISO %hd", vs);
00315 break;
00316 case MNOTE_NIKON_TAG_ISO2:
00317 CF (entry->format, EXIF_FORMAT_SHORT, v, maxlen);
00318 CC (entry->components, 2, v, maxlen);
00319
00320 vs = exif_get_short (entry->data + 2, entry->order);
00321 snprintf (v, maxlen, "ISO2 %hd", vs);
00322 break;
00323 case MNOTE_NIKON_TAG_QUALITY:
00324 case MNOTE_NIKON_TAG_COLORMODE:
00325 case MNOTE_NIKON_TAG_COLORMODE1:
00326 case MNOTE_NIKON_TAG_WHITEBALANCE:
00327 case MNOTE_NIKON_TAG_SHARPENING:
00328 case MNOTE_NIKON_TAG_FOCUSMODE:
00329 case MNOTE_NIKON_TAG_FLASHSETTING:
00330 case MNOTE_NIKON_TAG_ISOSELECTION:
00331 case MNOTE_NIKON_TAG_FLASHMODE:
00332 case MNOTE_NIKON_TAG_IMAGEADJUSTMENT:
00333 case MNOTE_NIKON_TAG_ADAPTER:
00334 case MNOTE_NIKON_TAG_SATURATION2:
00335 case MNOTE_EPSON_TAG_SOFTWARE:
00336 CF (entry->format, EXIF_FORMAT_ASCII, v, maxlen);
00337 memcpy(v, entry->data, MIN (maxlen, entry->size));
00338 break;
00339 case MNOTE_NIKON_TAG_TOTALPICTURES:
00340 case MNOTE_EPSON_TAG_IMAGE_WIDTH:
00341 case MNOTE_EPSON_TAG_IMAGE_HEIGHT:
00342 CF (entry->format, EXIF_FORMAT_LONG, v, maxlen);
00343 CC (entry->components, 1, v, maxlen);
00344 vl = exif_get_long (entry->data, entry->order);
00345 snprintf (v, maxlen, "%lu", (long unsigned int) vl );
00346 break;
00347 case MNOTE_NIKON_TAG_LENS_FSTOPS:
00348 case MNOTE_NIKON_TAG_EXPOSUREDIFF: {
00349 unsigned char a,b,c,d;
00350 CF (entry->format, EXIF_FORMAT_UNDEFINED, v, maxlen);
00351 CC (entry->components, 4, v, maxlen);
00352 vl = exif_get_long (entry->data, entry->order);
00353 a = (vl>>24)&0xff; b = (vl>>16)&0xff; c = (vl>>8)&0xff; d = (vl)&0xff;
00354 snprintf (v, maxlen, "%.1f", c?(float)a*((float)b/(float)c):0 );
00355 break;
00356 }
00357 case MNOTE_NIKON_TAG_FLASHEXPCOMPENSATION:
00358 case MNOTE_NIKON_TAG_FLASHEXPOSUREBRACKETVAL:
00359 CF (entry->format, EXIF_FORMAT_UNDEFINED, v, maxlen);
00360 CC (entry->components, 4, v, maxlen);
00361 vl = exif_get_long (entry->data, entry->order);
00362 snprintf (v, maxlen, "%.1f", ((long unsigned int) vl>>24)/6.0 );
00363 break;
00364 case MNOTE_NIKON_TAG_SATURATION:
00365 case MNOTE_NIKON_TAG_WHITEBALANCEFINE:
00366 case MNOTE_NIKON_TAG_HUE:
00367 case MNOTE_OLYMPUS_TAG_SENSORTEMPERATURE:
00368 case MNOTE_OLYMPUS_TAG_LENSTEMPERATURE:
00369 CF (entry->format, EXIF_FORMAT_SSHORT, v, maxlen);
00370 CC (entry->components, 1, v, maxlen);
00371 vs = exif_get_short (entry->data, entry->order);
00372 snprintf (v, maxlen, "%hd", vs);
00373 break;
00374 case MNOTE_NIKON_TAG_WHITEBALANCERB:
00375 CF (entry->format, EXIF_FORMAT_RATIONAL, v, maxlen);
00376 CC (entry->components, 4, v, maxlen);
00377 vr = exif_get_rational (entry->data, entry->order);
00378 r = R2D(vr);
00379 vr = exif_get_rational (entry->data+8, entry->order);
00380 b = R2D(vr);
00381 snprintf (v, maxlen, _("Red Correction %f, blue Correction %f"), r,b);
00382 break;
00383 case MNOTE_NIKON_TAG_MANUALFOCUSDISTANCE:
00384 CF (entry->format, EXIF_FORMAT_RATIONAL, v, maxlen);
00385 CC (entry->components, 1, v, maxlen);
00386 vr = exif_get_rational (entry->data, entry->order);
00387 if (!vr.numerator || !vr.denominator) {
00388 strncpy (v, _("No manual focus selection"), maxlen);
00389 } else {
00390 r = R2D(vr);
00391 snprintf (v, maxlen, _("%2.2f meters"), r);
00392 }
00393 break;
00394 case MNOTE_NIKON_TAG_SENSORPIXELSIZE:
00395 CF (entry->format, EXIF_FORMAT_RATIONAL, v, maxlen);
00396 CC (entry->components, 2, v, maxlen);
00397 vr = exif_get_rational (entry->data, entry->order);
00398 vr2 = exif_get_rational (entry->data+8, entry->order);
00399 r = R2D(vr);
00400 b = R2D(vr2);
00401 snprintf (v, maxlen, "%2.2f x %2.2f um", r, b);
00402 break;
00403 case MNOTE_NIKON_TAG_BRACKETING:
00404 CF2 (entry->format, EXIF_FORMAT_BYTE, EXIF_FORMAT_SHORT, v, maxlen);
00405 CC (entry->components, 1, v, maxlen);
00406 if (EXIF_FORMAT_SHORT == entry->format) {
00407 vs = exif_get_short (entry->data, entry->order);
00408 } else {
00409 vs = entry->data[0];
00410 }
00411 snprintf (v, maxlen, "%hd", vs);
00412 break;
00413 case MNOTE_NIKON_TAG_AFFOCUSPOSITION:
00414 CF (entry->format, EXIF_FORMAT_UNDEFINED, v, maxlen);
00415 CC (entry->components, 4, v, maxlen);
00416 switch ( *( entry->data+1) ) {
00417 case 0: strncpy (v, _("AF position: center"), maxlen); break;
00418 case 1: strncpy (v, _("AF position: top"), maxlen); break;
00419 case 2: strncpy (v, _("AF position: bottom"), maxlen); break;
00420 case 3: strncpy (v, _("AF position: left"), maxlen); break;
00421 case 4: strncpy (v, _("AF position: right"), maxlen); break;
00422 case 5: strncpy (v, _("AF position: upper-left"), maxlen); break;
00423 case 6: strncpy (v, _("AF position: upper-right"), maxlen); break;
00424 case 7: strncpy (v, _("AF position: lower-left"), maxlen); break;
00425 case 8: strncpy (v, _("AF position: lower-right"), maxlen); break;
00426 case 9: strncpy (v, _("AF position: far left"), maxlen); break;
00427 case 10: strncpy (v, _("AF position: far right"), maxlen); break;
00428 default: strncpy (v, _("Unknown AF position"), maxlen);
00429 }
00430 break;
00431 case MNOTE_OLYMPUS_TAG_FLASHDEVICE:
00432 CF (entry->format, EXIF_FORMAT_SHORT, v, maxlen);
00433 CC (entry->components, 2, v, maxlen);
00434 vs = exif_get_short(entry->data, entry->order);
00435
00436 for (i = 0; (items[i].tag && items[i].tag != entry->tag); i++)
00437 ;
00438 if (!items[i].tag) {
00439 snprintf (v, maxlen, _("Internal error (unknown value %hi)"), vs);
00440 break;
00441 }
00442 CF (entry->format, items[i].fmt, v, maxlen);
00443
00444 for (j = 0; items[i].elem[j].string &&
00445 (items[i].elem[j].index < vs); j++);
00446 if (items[i].elem[j].index != vs) {
00447 snprintf (v, maxlen, _("Unknown value %hi"), vs);
00448 break;
00449 }
00450 strncpy (v, _(items[i].elem[j].string), maxlen);
00451 break;
00452 case MNOTE_OLYMPUS_TAG_DIGIZOOM:
00453 if (entry->format == EXIF_FORMAT_RATIONAL) {
00454 CC (entry->components, 1, v, maxlen);
00455 vr = exif_get_rational (entry->data, entry->order);
00456 if (!vr.numerator || !vr.denominator) {
00457 strncpy (v, _("None"), maxlen);
00458 } else {
00459 r = R2D(vr);
00460 snprintf (v, maxlen, "%2.2f", r);
00461 }
00462 break;
00463 }
00464
00465 case MNOTE_NIKON_TAG_LENSTYPE:
00466 case MNOTE_NIKON_TAG_FLASHUSED:
00467 case MNOTE_NIKON1_TAG_QUALITY:
00468 case MNOTE_NIKON1_TAG_COLORMODE:
00469 case MNOTE_NIKON1_TAG_IMAGEADJUSTMENT:
00470 case MNOTE_NIKON1_TAG_CCDSENSITIVITY:
00471 case MNOTE_NIKON1_TAG_WHITEBALANCE:
00472 case MNOTE_NIKON1_TAG_CONVERTER:
00473 case MNOTE_OLYMPUS_TAG_QUALITY:
00474 case MNOTE_OLYMPUS_TAG_MACRO:
00475 case MNOTE_OLYMPUS_TAG_BWMODE:
00476 case MNOTE_OLYMPUS_TAG_ONETOUCHWB:
00477 case MNOTE_OLYMPUS_TAG_FLASHMODE:
00478 case MNOTE_OLYMPUS_TAG_FOCUSRANGE:
00479 case MNOTE_OLYMPUS_TAG_MANFOCUS:
00480 case MNOTE_OLYMPUS_TAG_SHARPNESS:
00481 case MNOTE_OLYMPUS_TAG_EXTERNALFLASHBOUNCE:
00482 case MNOTE_OLYMPUS_TAG_CONTRAST:
00483 case MNOTE_OLYMPUS_TAG_PREVIEWIMAGEVALID:
00484 case MNOTE_OLYMPUS_TAG_CCDSCANMODE:
00485 case MNOTE_SANYO_TAG_SEQUENTIALSHOT:
00486 case MNOTE_SANYO_TAG_FOCUSMODE:
00487 case MNOTE_SANYO_TAG_RECORDSHUTTERRELEASE:
00488 case MNOTE_SANYO_TAG_RESAVED:
00489 case MNOTE_SANYO_TAG_CCDSENSITIVITY:
00490 case MNOTE_SANYO_TAG_SCENESELECT:
00491 case MNOTE_SANYO_TAG_SEQUENCESHOTINTERVAL:
00492 CC (entry->components, 1, v, maxlen);
00493 switch (entry->format) {
00494 case EXIF_FORMAT_BYTE:
00495 case EXIF_FORMAT_UNDEFINED:
00496 vs = entry->data[0];
00497 break;
00498 case EXIF_FORMAT_SHORT:
00499 vs = exif_get_short(entry->data, entry->order);
00500 break;
00501 default:
00502 vs = 0;
00503 break;
00504 }
00505
00506 for (i = 0; (items[i].tag && items[i].tag != entry->tag); i++)
00507 ;
00508 if (!items[i].tag) {
00509 snprintf (v, maxlen, _("Internal error (unknown value %hi)"), vs);
00510 break;
00511 }
00512 CF (entry->format, items[i].fmt, v, maxlen);
00513
00514 for (j = 0; items[i].elem[j].string &&
00515 (items[i].elem[j].index < vs); j++);
00516 if (items[i].elem[j].index != vs) {
00517 snprintf (v, maxlen, _("Unknown value %hi"), vs);
00518 break;
00519 }
00520 strncpy (v, _(items[i].elem[j].string), maxlen);
00521 break;
00522 case MNOTE_OLYMPUS_TAG_NOISEREDUCTION:
00523 case MNOTE_SANYO_TAG_WIDERANGE:
00524 case MNOTE_SANYO_TAG_COLORADJUSTMENTMODE:
00525 case MNOTE_SANYO_TAG_QUICKSHOT:
00526 case MNOTE_SANYO_TAG_VOICEMEMO:
00527 case MNOTE_SANYO_TAG_FLICKERREDUCE:
00528 case MNOTE_SANYO_TAG_OPTICALZOOM:
00529 case MNOTE_SANYO_TAG_DIGITALZOOM:
00530 case MNOTE_SANYO_TAG_LIGHTSOURCESPECIAL:
00531 CF (entry->format, EXIF_FORMAT_SHORT, v, maxlen);
00532 CC (entry->components, 1, v, maxlen);
00533 vs = exif_get_short (entry->data, entry->order);
00534 switch (vs) {
00535 case 0:
00536 strncpy (v, _("Off"), maxlen);
00537 break;
00538 case 1:
00539 strncpy (v, _("On"), maxlen);
00540 break;
00541 default:
00542 sprintf (buf, _("Unknown %hu"), vs);
00543 strncat (v, buf, maxlen - strlen (v));
00544 break;
00545 }
00546 break;
00547 case MNOTE_SANYO_TAG_SELFTIMER:
00548 CF (entry->format, EXIF_FORMAT_SHORT, v, maxlen);
00549 CC (entry->components, 1, v, maxlen);
00550 vs = exif_get_short (entry->data, entry->order);
00551 switch (vs) {
00552 case 0:
00553 strncpy (v, _("Off"), maxlen);
00554 break;
00555 case 1:
00556 strncpy (v, _("On"), maxlen);
00557 break;
00558 case 2:
00559 strncpy (v, _("2 sec."), maxlen);
00560 break;
00561 default:
00562 sprintf (buf, _("Unknown %hu"), vs);
00563 strncat (v, buf, maxlen - strlen (v));
00564 break;
00565 }
00566 break;
00567 case MNOTE_NIKON_TAG_LENS:
00568 CF (entry->format, EXIF_FORMAT_RATIONAL, v, maxlen);
00569 CC (entry->components, 4, v, maxlen);
00570 {
00571 double c,d;
00572 unsigned long a,b;
00573 vr = exif_get_rational (entry->data, entry->order);
00574 a = R2L(vr);
00575 vr = exif_get_rational (entry->data+8, entry->order);
00576 b = R2L(vr);
00577 vr = exif_get_rational (entry->data+16, entry->order);
00578 c = R2D(vr);
00579 vr = exif_get_rational (entry->data+24, entry->order);
00580 d = R2D(vr);
00581 snprintf (v, maxlen, "%ld-%ldmm 1:%3.1f - %3.1f",a,b,c,d);
00582 }
00583 break;
00584
00585
00586 case MNOTE_OLYMPUS_TAG_MODE:
00587 CF (entry->format, EXIF_FORMAT_LONG, v, maxlen);
00588 CC (entry->components, 3, v, maxlen);
00589 vl = exif_get_long (entry->data, entry->order);
00590 switch (vl) {
00591 case 0:
00592 strncpy (v, _("Normal"), maxlen);
00593 break;
00594 case 1:
00595 strncpy (v, _("Unknown"), maxlen);
00596 break;
00597 case 2:
00598 strncpy (v, _("Fast"), maxlen);
00599 break;
00600 case 3:
00601 strncpy (v, _("Panorama"), maxlen);
00602 break;
00603 default:
00604 snprintf (v, maxlen, "%li", (long int) vl);
00605 }
00606 vl = exif_get_long (entry->data + 4, entry->order);
00607 snprintf (buf, sizeof (buf), "/%li/", (long int) vl);
00608 strncat (v, buf, maxlen - strlen (v));
00609 vl = exif_get_long (entry->data + 8, entry->order);
00610 switch (vl) {
00611 case 1:
00612 strncat (v, _("Left to right"), maxlen - strlen (v));
00613 break;
00614 case 2:
00615 strncat (v, _("Right to left"), maxlen - strlen (v));
00616 break;
00617 case 3:
00618 strncat (v, _("Bottom to top"), maxlen - strlen (v));
00619 break;
00620 case 4:
00621 strncat (v, _("Top to bottom"), maxlen - strlen (v));
00622 break;
00623 default:
00624 snprintf (buf, sizeof (buf), "%li",
00625 (long int) vl);
00626 strncat (v, buf, maxlen - strlen (v));
00627 }
00628 break;
00629 case MNOTE_OLYMPUS_TAG_LENSDISTORTION:
00630 if (entry->format == EXIF_FORMAT_SHORT) {
00631
00632 CC (entry->components, 1, v, maxlen);
00633 vs = exif_get_short (entry->data, entry->order);
00634 sprintf (buf, "%hu", vs);
00635 strncat (v, buf, maxlen - strlen (v));
00636 } else {
00637
00638 CC (entry->components, 6, v, maxlen);
00639 CF (entry->format, EXIF_FORMAT_SSHORT, v, maxlen);
00640 for (i=0; i < (int)entry->components; ++i) {
00641 vss = exif_get_sshort (entry->data+2*i, entry->order);
00642 sprintf (buf, "%hd ", vss);
00643 strncat (v, buf, maxlen - strlen (v));
00644 }
00645 }
00646 break;
00647 case MNOTE_OLYMPUS_TAG_COLORCONTROL:
00648 CF (entry->format, EXIF_FORMAT_SHORT, v, maxlen);
00649 CC (entry->components, 6, v, maxlen);
00650 for (i=0; i < (int)entry->components; ++i) {
00651 vs = exif_get_short (entry->data+2*i, entry->order);
00652 sprintf (buf, "%hu ", vs);
00653 strncat (v, buf, maxlen - strlen (v));
00654 }
00655 break;
00656 case MNOTE_OLYMPUS_TAG_VERSION:
00657 CF (entry->format, EXIF_FORMAT_ASCII, v, maxlen);
00658 CC2 (entry->components, 5, 8, v, maxlen);
00659 strncpy (v, (char *)entry->data, MIN (maxlen, entry->size));
00660 break;
00661 case MNOTE_OLYMPUS_TAG_SERIALNUMBER2:
00662 CF (entry->format, EXIF_FORMAT_ASCII, v, maxlen);
00663 strncpy (v, (char *)entry->data, MIN (maxlen, entry->size));
00664 break;
00665 case MNOTE_OLYMPUS_TAG_INFO:
00666 CF (entry->format, EXIF_FORMAT_ASCII, v, maxlen);
00667 CC2 (entry->components, 52, 60, v, maxlen);
00668 strncpy (v, (char *)entry->data, MIN (maxlen, entry->size));
00669 break;
00670 case MNOTE_OLYMPUS_TAG_ID:
00671 CF (entry->format, EXIF_FORMAT_UNDEFINED, v, maxlen);
00672 CC (entry->components, 32, v, maxlen);
00673 strncpy (v, (char *)entry->data, MIN (maxlen, entry->size));
00674 break;
00675 case MNOTE_OLYMPUS_TAG_UNKNOWN_4:
00676 CF (entry->format, EXIF_FORMAT_LONG, v, maxlen);
00677 CC (entry->components, 30, v, maxlen);
00678 for (i=0; i < (int)entry->components; ++i) {
00679 vl = exif_get_long (entry->data+4*i, entry->order);
00680 sprintf (buf, "%lu ", (unsigned long)vl);
00681 strncat (v, buf, maxlen - strlen (v));
00682 }
00683 break;
00684 case MNOTE_OLYMPUS_TAG_FOCUSDIST:
00685 CF (entry->format, EXIF_FORMAT_RATIONAL, v, maxlen);
00686 CC (entry->components, 1, v, maxlen);
00687 vr = exif_get_rational (entry->data, entry->order);
00688 if (!vr.numerator || !vr.denominator) {
00689 strncpy (v, _("Unknown"), maxlen);
00690 }
00691 else {
00692 unsigned long tmp = vr.numerator / vr.denominator;
00693 snprintf (v, maxlen, "%li mm", tmp);
00694 }
00695 break;
00696 case MNOTE_OLYMPUS_TAG_WBALANCE:
00697 CF (entry->format, EXIF_FORMAT_SHORT, v, maxlen);
00698 CC (entry->components, 2, v, maxlen);
00699 vs = exif_get_short (entry->data, entry->order);
00700 switch (vs) {
00701 case 1:
00702 strncpy (v, _("Automatic"), maxlen);
00703 break;
00704 case 2:
00705 {
00706 ExifShort v2 = exif_get_short (entry->data + 2, entry->order);
00707 unsigned long colorTemp = 0;
00708 switch (v2) {
00709 case 2:
00710 colorTemp = 3000;
00711 break;
00712 case 3:
00713 colorTemp = 3700;
00714 break;
00715 case 4:
00716 colorTemp = 4000;
00717 break;
00718 case 5:
00719 colorTemp = 4500;
00720 break;
00721 case 6:
00722 colorTemp = 5500;
00723 break;
00724 case 7:
00725 colorTemp = 6500;
00726 break;
00727 case 9:
00728 colorTemp = 7500;
00729 break;
00730 }
00731 if (colorTemp) {
00732 snprintf (v, maxlen, _("Manual: %liK"), colorTemp);
00733 }
00734 else {
00735 strncpy (v, _("Manual: unknown"), maxlen);
00736 }
00737
00738 }
00739 break;
00740 case 3:
00741 strncpy (v, _("One-touch"), maxlen);
00742 break;
00743 default:
00744 strncpy (v, _("Unknown"), maxlen);
00745 break;
00746 }
00747 break;
00748 case MNOTE_OLYMPUS_TAG_REDBALANCE:
00749 case MNOTE_OLYMPUS_TAG_BLUEBALANCE:
00750 CF (entry->format, EXIF_FORMAT_SHORT, v, maxlen);
00751 CC (entry->components, 2, v, maxlen);
00752 vs = exif_get_short (entry->data, entry->order);
00753 snprintf (v, maxlen, "%hu ", vs);
00754 vs = exif_get_short (entry->data + 2, entry->order);
00755 sprintf (buf, "%hu", vs);
00756 strncat (v, buf, maxlen - strlen (v));
00757 break;
00758 case MNOTE_OLYMPUS_TAG_BLACKLEVEL:
00759 case MNOTE_NIKON_TAG_IMAGEBOUNDARY:
00760 CC (entry->components, 4, v, maxlen);
00761
00762 case MNOTE_OLYMPUS_TAG_COLORMATRIX:
00763 CF (entry->format, EXIF_FORMAT_SHORT, v, maxlen);
00764 if (entry->tag == MNOTE_OLYMPUS_TAG_COLORMATRIX)
00765 CC (entry->components, 9, v, maxlen);
00766 for (i=0; i < (int)entry->components; ++i) {
00767 vs = exif_get_short (entry->data+2*i, entry->order);
00768 sprintf (buf, "%hu ", vs);
00769 strncat (v, buf, maxlen - strlen (v));
00770 }
00771 break;
00772 case MNOTE_NIKON1_TAG_FOCUS:
00773 case MNOTE_NIKON_TAG_DIGITALZOOM:
00774 case MNOTE_NIKON1_TAG_DIGITALZOOM:
00775 case MNOTE_OLYMPUS_TAG_FOCALPLANEDIAGONAL:
00776 CF (entry->format, EXIF_FORMAT_RATIONAL, v, maxlen);
00777
00778 default:
00779 switch (entry->format) {
00780 case EXIF_FORMAT_ASCII:
00781 strncpy (v, (char *)entry->data, MIN (maxlen, entry->size));
00782 break;
00783 case EXIF_FORMAT_SHORT:
00784 CC (entry->components, 1, v, maxlen);
00785 vs = exif_get_short (entry->data, entry->order);
00786 snprintf (v, maxlen, "%hu", vs);
00787 break;
00788 case EXIF_FORMAT_LONG:
00789 CC (entry->components, 1, v, maxlen);
00790 vl = exif_get_long (entry->data, entry->order);
00791 snprintf (v, maxlen, "%li", (long int) vl);
00792 break;
00793 case EXIF_FORMAT_RATIONAL:
00794 CC (entry->components, 1, v, maxlen);
00795 vr = exif_get_rational (entry->data, entry->order);
00796 if (!vr.denominator) {
00797 strncpy (v, _("Infinite"), maxlen);
00798 } else {
00799 r = R2D(vr);
00800 snprintf (v, maxlen, "%2.3f", r);
00801 }
00802 break;
00803 case EXIF_FORMAT_SRATIONAL:
00804 CC (entry->components, 1, v, maxlen);
00805 vsr = exif_get_srational (entry->data, entry->order);
00806 if (!vsr.denominator) {
00807 strncpy (v, _("Infinite"), maxlen);
00808 } else {
00809 r = R2D(vsr);
00810 snprintf (v, maxlen, "%2.3f", r);
00811 }
00812 break;
00813 case EXIF_FORMAT_UNDEFINED:
00814 default:
00815 snprintf (v, maxlen, _("%i bytes unknown data: "),
00816 entry->size);
00817 for (i = 0; i < (int)entry->size; i++) {
00818 sprintf (buf, "%02x", entry->data[i]);
00819 strncat (v, buf, maxlen - strlen (v));
00820 }
00821 break;
00822 }
00823 break;
00824 }
00825
00826 return (v);
00827 }