EXIF library (libexif) Internals  0.6.24
mnote-olympus-entry.c
Go to the documentation of this file.
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 {
85  struct {
86  int index;
87  const char *string;
88  } elem[24];
89 } items[] = {
90 #ifndef NO_VERBOSE_TAG_DATA
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}}},
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}}},
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}}},
117  { {1, N_("Color")},
118  {2, N_("Monochrome")},
119  {0, NULL}}},
121  { {0, N_("Normal")},
122  {1, N_("Bright+")},
123  {2, N_("Bright-")},
124  {3, N_("Contrast+")},
125  {4, N_("Contrast-")},
126  {0, NULL}}},
128  { {0, N_("ISO 80")},
129  {2, N_("ISO 160")},
130  {4, N_("ISO 320")},
131  {5, N_("ISO 100")},
132  {0, NULL}}},
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}}},
143  { {0, N_("No fisheye")},
144  {1, N_("Fisheye on")},
145  {0, NULL}}},
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}}},
172  { {0, N_("No")},
173  {1, N_("Yes")},
174  {2, N_("Super macro")},
175  {0, NULL}}},
177  { {0, N_("No")},
178  {1, N_("Yes")},
179  {0, NULL}}},
181  { {0, N_("Off")},
182  {1, N_("On")},
183  {2, N_("On (Preset)")},
184  {0, NULL}}},
186  { {0, N_("Auto")},
187  {1, N_("Red-eye reduction")},
188  {2, N_("Fill")},
189  {3, N_("Off")},
190  {0, NULL}}},
192  { {0, N_("None")},
193  {1, N_("Internal")},
194  {4, N_("External")},
195  {5, N_("Internal + external")},
196  {0, NULL}}},
198  { {0, N_("Normal")},
199  {1, N_("Macro")},
200  {0, NULL}}},
202  { {0, N_("Auto")},
203  {1, N_("Manual")},
204  {0, NULL}}},
206  { {0, N_("Normal")},
207  {1, N_("Hard")},
208  {2, N_("Soft")},
209  {0, NULL}}},
211  { {0, N_("No")},
212  {1, N_("Yes")},
213  {0, NULL}}},
215  { {0, N_("Hard")},
216  {1, N_("Normal")},
217  {2, N_("Soft")},
218  {0, NULL}}},
220  { {0, N_("No")},
221  {1, N_("Yes")},
222  {0, NULL}}},
224  { {0, N_("Interlaced")},
225  {1, N_("Progressive")},
226  {0, NULL}}},
227 
229  { {0, N_("None")},
230  {1, N_("Standard")},
231  {2, N_("Best")},
232  {3, N_("Adjust exposure")},
233  {0, NULL}}},
235  { {1, N_("Spot focus")},
236  {2, N_("Normal focus")},
237  {0, NULL}}},
239  { {0, N_("Record while down")},
240  {1, N_("Press start, press stop")},
241  {0, NULL}}},
243  { {0, N_("No")},
244  {1, N_("Yes")},
245  {0, NULL}}},
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}}},
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}}},
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 *
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 */
301  CF (entry->format, EXIF_FORMAT_UNDEFINED, v, maxlen);
302  CC (entry->components, 4, v, maxlen);
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;
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;
337  CF (entry->format, EXIF_FORMAT_ASCII, v, maxlen);
338  memcpy(v, entry->data, MIN (maxlen, entry->size));
339  break;
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;
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  }
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;
367  case MNOTE_NIKON_TAG_HUE:
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;
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;
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;
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;
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;
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;
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;
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 */
494  CC (entry->components, 1, v, maxlen);
495  switch (entry->format) {
496  case EXIF_FORMAT_BYTE:
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;
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;
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;
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 */
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;
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;
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;
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;
664  CF (entry->format, EXIF_FORMAT_ASCII, v, maxlen);
665  strncpy (v, (char *)entry->data, MIN (maxlen, entry->size));
666  break;
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;
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;
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;
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;
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;
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;
762  CC (entry->components, 4, v, maxlen);
763  /* Fall through to COLORMATRIX */
764  /* fall through */
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;
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;
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;
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;
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 }
@ EXIF_BYTE_ORDER_INTEL
Little-endian byte order.
Handling EXIF entries.
Handling native EXIF data types.
ExifFormat
EXIF tag data formats.
Definition: exif-format.h:32
@ EXIF_FORMAT_SLONG
Definition: exif-format.h:41
@ EXIF_FORMAT_RATIONAL
Definition: exif-format.h:37
@ EXIF_FORMAT_SRATIONAL
Definition: exif-format.h:42
@ EXIF_FORMAT_LONG
Definition: exif-format.h:36
@ EXIF_FORMAT_UNDEFINED
Definition: exif-format.h:39
@ EXIF_FORMAT_SHORT
Definition: exif-format.h:35
@ EXIF_FORMAT_SSHORT
Definition: exif-format.h:40
@ EXIF_FORMAT_ASCII
Definition: exif-format.h:34
@ EXIF_FORMAT_BYTE
Definition: exif-format.h:33
ExifRational exif_get_rational(const unsigned char *buf, ExifByteOrder order)
Retrieve an ExifRational value from memory.
Definition: exif-utils.c:188
ExifLong exif_get_long(const unsigned char *buf, ExifByteOrder order)
Retrieve an ExifLong value from memory.
Definition: exif-utils.c:165
ExifShort exif_get_short(const unsigned char *buf, ExifByteOrder order)
Retrieve an ExifShort value from memory.
Definition: exif-utils.c:102
ExifSLong exif_get_slong(const unsigned char *b, ExifByteOrder order)
Retrieve an ExifSLong value from memory.
Definition: exif-utils.c:130
ExifSShort exif_get_sshort(const unsigned char *buf, ExifByteOrder order)
Retrieve an ExifSShort value from memory.
Definition: exif-utils.c:87
ExifSRational exif_get_srational(const unsigned char *buf, ExifByteOrder order)
Retrieve an ExifSRational value from memory.
Definition: exif-utils.c:177
EXIF data manipulation functions and types.
uint32_t ExifLong
EXIF Unsigned Long data type.
Definition: exif-utils.h:54
int32_t ExifSLong
EXIF Signed Long data type.
Definition: exif-utils.h:57
uint16_t ExifShort
EXIF Unsigned Short data type.
Definition: exif-utils.h:48
#define MIN(a, b)
Definition: exif-utils.h:180
int16_t ExifSShort
EXIF Signed Short data type.
Definition: exif-utils.h:51
#define _(String)
Definition: i18n.h:48
#define N_(String)
Definition: i18n.h:49
MnoteOlympusTag tag
#define CC(number, target, v, maxlen)
ExifFormat fmt
int index
struct @13::@14 elem[24]
#define R2L(n)
static const struct @13 items[]
#define R2D(n)
#define CF(format, target, v, maxlen)
char * mnote_olympus_entry_get_value(MnoteOlympusEntry *entry, char *v, unsigned int maxlen)
#define CC2(number, t1, t2, v, maxlen)
#define CF2(format, target1, target2, v, maxlen)
const char * string
@ MNOTE_NIKON1_TAG_WHITEBALANCE
@ MNOTE_OLYMPUS_TAG_ID
@ MNOTE_SANYO_TAG_FLICKERREDUCE
@ MNOTE_NIKON_TAG_IMAGEADJUSTMENT
@ MNOTE_OLYMPUS_TAG_REDBALANCE
@ MNOTE_OLYMPUS_TAG_FOCALPLANEDIAGONAL
@ MNOTE_EPSON_TAG_SOFTWARE
@ MNOTE_OLYMPUS_TAG_FOCUSRANGE
@ MNOTE_OLYMPUS_TAG_EXTERNALFLASHBOUNCE
@ MNOTE_SANYO_TAG_FOCUSMODE
@ MNOTE_SANYO_TAG_QUICKSHOT
@ MNOTE_NIKON_TAG_TOTALPICTURES
@ MNOTE_SANYO_TAG_CCDSENSITIVITY
@ MNOTE_NIKON_TAG_SATURATION2
@ MNOTE_OLYMPUS_TAG_MODE
@ MNOTE_OLYMPUS_TAG_ONETOUCHWB
@ MNOTE_OLYMPUS_TAG_FLASHDEVICE
@ MNOTE_OLYMPUS_TAG_CONTRAST
@ MNOTE_OLYMPUS_TAG_FLASHMODE
@ MNOTE_SANYO_TAG_COLORADJUSTMENTMODE
@ MNOTE_NIKON_TAG_ISO2
@ MNOTE_NIKON1_TAG_CCDSENSITIVITY
@ MNOTE_NIKON_TAG_WHITEBALANCERB
@ MNOTE_NIKON1_TAG_IMAGEADJUSTMENT
@ MNOTE_OLYMPUS_TAG_LENSTEMPERATURE
@ MNOTE_NIKON_TAG_ISOSELECTION
@ MNOTE_OLYMPUS_TAG_VERSION
@ MNOTE_NIKON_TAG_SATURATION
@ MNOTE_OLYMPUS_TAG_SHARPNESS
@ MNOTE_NIKON_TAG_COLORMODE
@ MNOTE_SANYO_TAG_SELFTIMER
@ MNOTE_OLYMPUS_TAG_SENSORTEMPERATURE
@ MNOTE_OLYMPUS_TAG_NOISEREDUCTION
@ MNOTE_NIKON_TAG_SENSORPIXELSIZE
@ MNOTE_OLYMPUS_TAG_BWMODE
@ MNOTE_NIKON_TAG_EXPOSUREDIFF
@ MNOTE_OLYMPUS_TAG_QUALITY
@ MNOTE_SANYO_TAG_WIDERANGE
@ MNOTE_OLYMPUS_TAG_MACRO
@ MNOTE_OLYMPUS_TAG_CCDSCANMODE
@ MNOTE_OLYMPUS_TAG_UNKNOWN_4
@ MNOTE_NIKON_TAG_MANUALFOCUSDISTANCE
@ MNOTE_OLYMPUS_TAG_PREVIEWIMAGEVALID
@ MNOTE_OLYMPUS_TAG_COLORMATRIX
@ MNOTE_OLYMPUS_TAG_SERIALNUMBER2
@ MNOTE_NIKON1_TAG_COLORMODE
@ MNOTE_EPSON_TAG_IMAGE_WIDTH
@ MNOTE_NIKON_TAG_FLASHMODE
@ MNOTE_NIKON1_TAG_DIGITALZOOM
@ MNOTE_OLYMPUS_TAG_BLACKLEVEL
@ MNOTE_OLYMPUS_TAG_FOCUSDIST
@ MNOTE_NIKON_TAG_FLASHEXPCOMPENSATION
@ MNOTE_NIKON_TAG_FIRMWARE
@ MNOTE_OLYMPUS_TAG_INFO
@ MNOTE_NIKON1_TAG_CONVERTER
@ MNOTE_SANYO_TAG_VOICEMEMO
@ MNOTE_SANYO_TAG_DIGITALZOOM
@ MNOTE_NIKON_TAG_ADAPTER
@ MNOTE_OLYMPUS_TAG_WBALANCE
@ MNOTE_NIKON_TAG_WHITEBALANCE
@ MNOTE_NIKON_TAG_FLASHEXPOSUREBRACKETVAL
@ MNOTE_OLYMPUS_TAG_MANFOCUS
@ MNOTE_NIKON_TAG_LENSTYPE
@ MNOTE_NIKON_TAG_FLASHUSED
@ MNOTE_NIKON1_TAG_FOCUS
@ MNOTE_OLYMPUS_TAG_BLUEBALANCE
@ MNOTE_NIKON_TAG_QUALITY
@ MNOTE_NIKON_TAG_AFFOCUSPOSITION
@ MNOTE_NIKON_TAG_LENS_FSTOPS
@ MNOTE_SANYO_TAG_RESAVED
@ MNOTE_SANYO_TAG_SEQUENTIALSHOT
@ MNOTE_NIKON_TAG_SHARPENING
@ MNOTE_NIKON_TAG_HUE
@ MNOTE_EPSON_TAG_IMAGE_HEIGHT
@ MNOTE_NIKON_TAG_LENS
@ MNOTE_OLYMPUS_TAG_DIGIZOOM
@ MNOTE_SANYO_TAG_RECORDSHUTTERRELEASE
@ MNOTE_SANYO_TAG_SCENESELECT
@ MNOTE_NIKON_TAG_ISO
@ MNOTE_NIKON_TAG_DIGITALZOOM
@ MNOTE_SANYO_TAG_SEQUENCESHOTINTERVAL
@ MNOTE_NIKON_TAG_BRACKETING
@ MNOTE_OLYMPUS_TAG_LENSDISTORTION
@ MNOTE_NIKON_TAG_FOCUSMODE
@ MNOTE_NIKON1_TAG_QUALITY
@ MNOTE_NIKON_TAG_FLASHSETTING
@ MNOTE_NIKON_TAG_IMAGEBOUNDARY
@ MNOTE_SANYO_TAG_OPTICALZOOM
@ MNOTE_NIKON_TAG_COLORMODE1
@ MNOTE_OLYMPUS_TAG_COLORCONTROL
@ MNOTE_SANYO_TAG_LIGHTSOURCESPECIAL
@ MNOTE_NIKON_TAG_WHITEBALANCEFINE
enum _MnoteOlympusTag MnoteOlympusTag
EXIF Unsigned Rational data type.
Definition: exif-utils.h:60
ExifLong denominator
Definition: exif-utils.h:60
ExifLong numerator
Definition: exif-utils.h:60
EXIF Signed Rational data type.
Definition: exif-utils.h:65
ExifSLong denominator
Definition: exif-utils.h:65
unsigned long components
unsigned char * data

libexif Generated by doxygen