mnote-canon-entry.c

Go to the documentation of this file.
00001 /* mnote-canon-entry.c
00002  *
00003  * Copyright © 2002 Lutz Müller <lutz@users.sourceforge.net>
00004  * Copyright © 2003 Matthieu Castet <mat-c@users.sourceforge.net>
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the
00018  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019  * Boston, MA 02111-1307, USA.
00020  */
00021 
00022 #include "config.h"
00023 #include "mnote-canon-entry.h"
00024 
00025 #include <stdio.h>
00026 #include <stdlib.h>
00027 #include <string.h>
00028 #include <math.h>
00029 
00030 #include <libexif/exif-format.h>
00031 #include <libexif/exif-utils.h>
00032 #include <libexif/i18n.h>
00033 
00034 /* #define DEBUG */
00035 
00036 #define CF(format,target,v,maxlen)                              \
00037 {                                                               \
00038         if (format != target) {                                 \
00039                 snprintf (v, maxlen,                            \
00040                         _("Invalid format '%s', "               \
00041                         "expected '%s'."),                      \
00042                         exif_format_get_name (format),          \
00043                         exif_format_get_name (target));         \
00044                 break;                                          \
00045         }                                                       \
00046 }
00047 
00048 #define CC(number,target,v,maxlen)                                      \
00049 {                                                                       \
00050         if (number != target) {                                         \
00051                 snprintf (v, maxlen,                                    \
00052                         _("Invalid number of components (%i, "          \
00053                         "expected %i)."), (int) number, (int) target);  \
00054                 break;                                                  \
00055         }                                                               \
00056 }
00057 #define CC2(number,t1,t2,v,maxlen)                                      \
00058 {                                                                       \
00059         if ((number != t1) && (number != t2)) {                         \
00060                 snprintf (v, maxlen,                                    \
00061                         _("Invalid number of components (%i, "          \
00062                         "expected %i or %i)."), (int) number,           \
00063                         (int) t1, (int) t2);                            \
00064                 break;                                                  \
00065         }                                                               \
00066 }
00067 
00068 #define UNDEFINED 0xFF
00069     
00070 static struct canon_entry_table_t {
00071   unsigned int subtag;
00072   ExifShort value;
00073   char *name;
00074 } entries_settings_1 [] = {
00075   { 0,  1, N_("Macro")},
00076   { 0,  2, N_("Normal")},
00077   { 2,  1, N_("Economy")},
00078   { 2,  2, N_("Normal")},  
00079   { 2,  3, N_("Fine")},
00080   { 2,  4, N_("RAW")},
00081   { 2,  5, N_("Superfine")},
00082   { 3,  0, N_("Off")},
00083   { 3,  1, N_("Auto")},
00084   { 3,  2, N_("On")},
00085   { 3,  3, N_("Red-eye reduction")},
00086   { 3,  4, N_("Slow synchro")},
00087   { 3,  5, N_("Auto + Red-eye reduction")},
00088   { 3,  6, N_("On + Red-eye reduction")},
00089   { 3, 16, N_("External flash")},
00090   { 4,  0, N_("Single")},
00091   { 4,  1, N_("Continuous")},
00092   { 4,  2, N_("Movie")},
00093   { 4,  3, N_("Continuous, speed priority")},
00094   { 4,  4, N_("Continuous, low")},
00095   { 4,  5, N_("Continuous, high")},
00096   { 6,  0, N_("One-shot AF")},
00097   { 6,  1, N_("AI servo AF")},
00098   { 6,  2, N_("AI focus AF")},
00099   { 6,  3, N_("Manual focus")}, 
00100   { 6,  4, N_("Single")},
00101   { 6,  5, N_("Continuous")},
00102   { 6,  6, N_("Manual focus")},
00103   { 6,  16, N_("Pan focus")},  
00104   { 9,  0, N_("Large")},
00105   { 9,  1, N_("Medium")},
00106   { 9,  2, N_("Small")},
00107   { 9,  5, N_("Medium 1")},
00108   { 9,  6, N_("Medium 2")},
00109   { 9,  7, N_("Medium 3")},  
00110   {10,  0, N_("Full auto")},
00111         {10,  1, N_("Manual")},
00112         {10,  2, N_("Landscape")},
00113         {10,  3, N_("Fast shutter")},
00114         {10,  4, N_("Slow shutter")},
00115         {10,  5, N_("Night")},
00116         {10,  6, N_("Grayscale")},
00117         {10,  7, N_("Sepia")},
00118         {10,  8, N_("Portrait")},
00119         {10,  9, N_("Sports")},
00120         {10, 10, N_("Macro")},
00121         {10, 11, N_("Black & white")},
00122         {10, 12, N_("Pan focus")},
00123         {10, 13, N_("Vivid")},
00124         {10, 14, N_("Neutral")},
00125         {10, 15, N_("Flash off")},
00126         {10, 16, N_("Long shutter")},
00127         {10, 17, N_("Super macro")},
00128         {10, 18, N_("Foliage")},
00129         {10, 19, N_("Indoor")},
00130         {10, 20, N_("Fireworks")},
00131         {10, 21, N_("Beach")},
00132         {10, 22, N_("Underwater")},
00133         {10, 23, N_("Snow")},
00134         {10, 24, N_("Kids & pets")},
00135         {10, 25, N_("Night snapshot")},
00136         {10, 26, N_("Digital macro")},
00137         {10, 27, N_("My colors")},
00138         {10, 28, N_("Still image")},
00139         {11, 0, N_("None")},
00140         {11, 1, N_("2x")},
00141         {11, 2, N_("4x")},
00142         {11, 3, N_("Other")},
00143         {12, 0x0000, N_("Normal")},
00144         {12, 0x0001, N_("High")},
00145         {12, 0xffff, N_("Low")},
00146         {13, 0x0000, N_("Normal")},
00147         {13, 0x0001, N_("High")},
00148         {13, 0xffff, N_("Low")},
00149         {14, 0x0000, N_("Normal")},
00150         {14, 0x0001, N_("High")},
00151         {14, 0xffff, N_("Low")},
00152         {15, 14, N_("Auto high")},
00153         {15, 15, N_("Auto")},
00154         {15, 16, N_("50")},
00155         {15, 17, N_("100")},
00156         {15, 18, N_("200")},
00157         {15, 19, N_("400")},
00158         {15, 20, N_("800")},
00159         {16,  0, N_("Default")},
00160         {16,  1, N_("Spot")},
00161         {16,  2, N_("Average")},        
00162         {16,  3, N_("Evaluative")},
00163         {16,  4, N_("Partial")},
00164         {16,  5, N_("Center-weighted average")},
00165         {17,  0, N_("Manual")},
00166         {17,  1, N_("Auto")},
00167         {17,  2, N_("Not known")},
00168         {17,  3, N_("Macro")},
00169         {17,  4, N_("Very close")},
00170         {17,  5, N_("Close")},
00171         {17,  6, N_("Middle range")},
00172         {17,  7, N_("Far range")},
00173         {17,  8, N_("Pan focus")},
00174         {17,  9, N_("Super macro")},
00175         {17,  10, N_("Infinity")},
00176         {18, 0x2005, N_("Manual AF point selection")},
00177         {18, 0x3000, N_("None (MF)")},
00178         {18, 0x3001, N_("Auto-selected")},
00179         {18, 0x3002, N_("Right")},
00180         {18, 0x3003, N_("Center")},
00181         {18, 0x3004, N_("Left")},
00182         {18, 0x4001, N_("Auto AF point selection")},
00183         {19,  0, N_("Easy shooting")},
00184         {19,  1, N_("Program")},
00185         {19,  2, N_("Tv-priority")},
00186         {19,  3, N_("Av-priority")},
00187         {19,  4, N_("Manual")},
00188         {19,  5, N_("A-DEP")},
00189         {19,  6, N_("M-DEP")},
00190         {21, 0x001, N_("Canon EF 50mm f/1.8")},
00191         {21, 0x002, N_("Canon EF 28mm f/2.8")},
00192         {21, 0x004, N_("Sigma UC Zoom 35-135mm f/4-5.6")},
00193         {21, 0x006, N_("Tokina AF193-2 19-35mm f/3.5-4.5")},
00194         {21, 0x010, N_("Sigma 50mm f/2.8 EX or 28mm f/1.8")},
00195         {21, 0x011, N_("Canon EF 35mm f/2")},
00196         {21, 0x013, N_("Canon EF 15mm f/2.8")},
00197         {21, 0x021, N_("Canon EF 80-200mm f/2.8L")},
00198         {21, 0x026, N_("Cosina 100mm f/3.5 Macro AF")},
00199         {21, 0x028, N_("Tamron AF Aspherical 28-200mm f/3.8-5.6")},
00200         {21, 0x029, N_("Canon EF 50mm f/1.8 MkII")},
00201         {21, 0x039, N_("Canon EF 75-300mm f/4-5.6")},
00202         {21, 0x040, N_("Canon EF 28-80mm f/3.5-5.6")},
00203         {21, 0x124, N_("Canon MP-E 65mm f/2.8 1-5x Macro Photo")},
00204         {21, 0x125, N_("Canon TS-E 24mm f/3.5L")},
00205         {21, 0x131, N_("Sigma 17-35mm f2.8-4 EX Aspherical HSM")},
00206         {21, 0x135, N_("Canon EF 200mm f/1.8L")},
00207         {21, 0x136, N_("Canon EF 300mm f/2.8L")},
00208         {21, 0x139, N_("Canon EF 400mm f/2.8L")},
00209         {21, 0x141, N_("Canon EF 500mm f/4.5L")},
00210         {21, 0x149, N_("Canon EF 100mm f/2")},
00211         {21, 0x150, N_("Sigma 20mm EX f/1.8")},
00212         {21, 0x151, N_("Canon EF 200mm f/2.8L")},
00213         {21, 0x153, N_("Canon EF 35-350mm f/3.5-5.6L")},
00214         {21, 0x155, N_("Canon EF 85mm f/1.8 USM")},
00215         {21, 0x156, N_("Canon EF 28-105mm f/3.5-4.5 USM")},
00216         {21, 0x160, N_("Canon EF 20-35mm f/3.5-4.5 USM")},
00217         {21, 0x161, N_("Canon EF 28-70mm f/2.8L or Sigma 24-70mm EX f/2.8")},
00218         {21, 0x165, N_("Canon EF 70-200mm f/2.8 L")},
00219         {21, 0x166, N_("Canon EF 70-200mm f/2.8 L + x1.4")},
00220         {21, 0x167, N_("Canon EF 70-200mm f/2.8 L + x2")},
00221         {21, 0x169, N_("Sigma 15-30mm f/3.5-4.5 EX DG Aspherical")},
00222         {21, 0x170, N_("Canon EF 200mm f/2.8L II")},
00223         {21, 0x173, N_("Canon EF 180mm Macro f/3.5L or Sigma 180mm EX HSM Macro f/3.5")},
00224         {21, 0x174, N_("Canon EF 135mm f/2L")},
00225         {21, 0x176, N_("Canon EF 24-85mm f/3.5-4.5 USM")},
00226         {21, 0x177, N_("Canon EF 300mm f/4L IS")},
00227         {21, 0x178, N_("Canon EF 28-135mm f/3.5-5.6 IS")},
00228         {21, 0x180, N_("Canon EF 35mm f/1.4L")},
00229         {21, 0x182, N_("Canon EF 100-400mm f/4.5-5.6L IS + x2")},
00230         {21, 0x183, N_("Canon EF 100-400mm f/4.5-5.6L IS")},
00231         {21, 0x186, N_("Canon EF 70-200mm f/4L")},
00232         {21, 0x190, N_("Canon EF 100mm f/2.8 Macro")},
00233         {21, 0x191, N_("Canon EF 400mm f/4 DO IS")},
00234         {21, 0x197, N_("Canon EF 75-300mm f/4-5.6 IS")},
00235         {21, 0x198, N_("Canon EF 50mm f/1.4")},
00236         {21, 0x202, N_("Canon EF 28-80 f/3.5-5.6 USM IV")},
00237         {21, 0x213, N_("Canon EF 90-300mm f/4.5-5.6")},
00238         {21, 0x229, N_("Canon EF 16-35mm f/2.8L")},
00239         {21, 0x230, N_("Canon EF 24-70mm f/2.8L")},
00240         {21, 0x231, N_("Canon EF 17-40mm f/4L")},
00241         {28, 0, N_("Manual")},
00242         {28, 1, N_("TTL")},
00243         {28, 2, N_("A-TTL")},
00244         {28, 3, N_("E-TTL")},
00245         {28, 4, N_("FP sync enabled")},
00246         {28, 7, N_("2nd-curtain sync used")},
00247         {28, 11, N_("FP sync used")},
00248         {28, 13, N_("Internal")},
00249         {28, 14, N_("External")},
00250   {31,  0, N_("Single")},
00251   {31,  1, N_("Continuous")},
00252         {32, 0, N_("Normal AE")},
00253         {32, 1, N_("Exposure compensation")},
00254         {32, 2, N_("AE lock")},
00255         {32, 3, N_("AE lock + Exposure compensation")},
00256         {32, 4, N_("No AE")},
00257         {33, 0, N_("Off")},
00258         {33, 1, N_("On")},
00259         {33, 2, N_("On, shot only")},
00260         {39, 0, N_("Off")},
00261         {39, 1, N_("Vivid")},
00262         {39, 2, N_("Neutral")},
00263         {39, 3, N_("Smooth")},
00264         {39, 4, N_("Sepia")},
00265         {39, 5, N_("Black & white")},
00266         {39, 6, N_("Custom")},
00267         {39, 100, N_("My color data")},
00268         {40, 0, N_("Off")},
00269         {40, 0x0500, N_("Full")},
00270         {40, 0x0502, N_("2/3")},
00271         {40, 0x0504, N_("1/3")},
00272   { 0,  0, NULL}
00273 },
00274 entries_focal_length [] = {
00275         {0, 1, N_("Fixed")},
00276         {0, 2, N_("Zoom")},
00277         {0, 0, NULL}
00278 },
00279 entries_settings_2 [] = {
00280   { 6,  0, N_("Auto")},
00281   { 6,  1, N_("Sunny")},
00282   { 6,  2, N_("Cloudy")},
00283   { 6,  3, N_("Tungsten")},
00284   { 6,  4, N_("Fluorescent")},
00285   { 6,  5, N_("Flash")},
00286   { 6,  6, N_("Custom")},
00287   { 6,  7, N_("Black & white")},
00288   { 6,  8, N_("Shade")},
00289   { 6,  9, N_("Manual temperature (Kelvin)")},
00290   { 6,  10, N_("PC set 1")},
00291   { 6,  11, N_("PC set 2")},
00292   { 6,  12, N_("PC set 3")},
00293   { 6,  14, N_("Daylight fluorescent")},
00294   { 6,  15, N_("Custom 1")},
00295   { 6,  16, N_("Custom 2")},
00296   { 6,  17, N_("Underwater")},
00297   { 7,  0, N_("Off")},
00298   { 7,  1, N_("Night scene")},
00299   { 7,  2, N_("On")},
00300   { 7,  3, N_("None")},
00301   { 13,  0x3000, N_("None (MF)")},
00302   { 13,  0x3001, N_("Right")},
00303   { 13,  0x3002, N_("Center")},
00304   { 13,  0x3003, N_("Center + Right")},
00305   { 13,  0x3004, N_("Left")},
00306   { 13,  0x3005, N_("Left + Right")},
00307   { 13,  0x3006, N_("Left + Center")},
00308   { 13,  0x3007, N_("All")},
00309   { 15,  0, N_("Off")},
00310   { 15,  1, N_("On (shot 1)")},
00311   { 15,  2, N_("On (shot 2)")},
00312   { 15,  3, N_("On (shot 3)")},
00313   { 15,  0xffff, N_("On")},
00314   { 25,  248, N_("EOS high-end")},
00315   { 25,  250, N_("Compact")},
00316   { 25,  252, N_("EOS mid-range")},
00317   { 26,  0, N_("None")},
00318   { 26,  1, N_("Rotate 90 CW")},
00319   { 26,  2, N_("Rotate 180")},
00320   { 26,  3, N_("Rotate 270 CW")},
00321   { 26,  0xffff, N_("Rotated by software")},
00322   { 27,  0, N_("Off")},
00323   { 27,  1, N_("On")},  
00324         {32, 0, N_("Off")},
00325         {32, 0x0014, N_("1/3")},
00326         {32, 0x008c, N_("2/3")},
00327         {32, 0x07d0, N_("Full")},
00328         {0, 0, NULL}
00329 },
00330 entries_panorama [] = {
00331         {0, 0, N_("Left to right")},
00332         {0, 1, N_("Right to left")},
00333         {0, 2, N_("Bottom to top")},
00334         {0, 3, N_("Top to bottom")},
00335         {0, 4, N_("2x2 matrix (clockwise)")},
00336         {0, 0, NULL}
00337 };
00338 
00339 static void
00340 canon_search_table_value (struct canon_entry_table_t table[],
00341     unsigned int t, ExifShort vs, char *val, unsigned int maxlen)
00342 {
00343         unsigned int j;
00344 
00345         /* Search the table for the first matching subtag and value. */
00346         for (j = 0; table[j].name && ((table[j].subtag < t) ||
00347                         ((table[j].subtag == t) && table[j].value <= vs)); j++) {
00348                 if ((table[j].subtag == t) && (table[j].value == vs)) {
00349                         break;
00350                 }
00351         }
00352         if ((table[j].subtag == t) && (table[j].value == vs) && table[j].name) {
00353     /* Matching subtag and value found. */
00354                 strncpy (val, table[j].name, maxlen);
00355         } else {
00356                 /* No matching subtag and/or value found. */
00357                 snprintf (val, maxlen, "0x%04x", vs);
00358         }
00359 }
00360 
00361 static void
00362 canon_search_table_bitfield (struct canon_entry_table_t table[],
00363     unsigned int t, ExifShort vs, char *val, unsigned int maxlen)
00364 {
00365         unsigned int j;
00366 
00367         /* Search the table for the first matching subtag. */
00368         for (j = 0; table[j].name && (table[j].subtag <= t); j++) {
00369                 if (table[j].subtag == t) {
00370                         break;
00371                 }
00372         }
00373         if ((table[j].subtag == t) && table[j].name) {
00374                 unsigned int i, bit, lastbit = 0;
00375 
00376                 /*
00377      * Search the table for the last matching bit, because
00378      * that one needs no additional comma appended.
00379      */
00380                 for (i = j; table[i].name && (table[i].subtag == t); i++) {
00381                         bit = table[i].value;
00382                         if ((vs >> bit) & 1) {
00383                                 lastbit = bit;
00384                         }
00385                 }
00386                 /* Search the table for all matching bits. */
00387                 for (i = j; table[i].name && (table[i].subtag == t); i++) {
00388                         bit = table[i].value;
00389                         if ((vs >> bit) & 1) {
00390                                 strncat(val, table[i].name, maxlen - strlen (val));
00391                                 if (bit != lastbit) 
00392                                         strncat (val, N_(", "), maxlen - strlen (val));
00393                         }
00394                 }
00395         } else {
00396                 /* No matching subtag found. */
00397                 snprintf (val, maxlen, "0x%04x", vs);
00398         }
00399 }
00400 
00401 unsigned int
00402 mnote_canon_entry_count_values (const MnoteCanonEntry *entry)
00403 {
00404         unsigned int  val;
00405 
00406         if (!entry) return 0;
00407 
00408         switch (entry->tag) {
00409         case MNOTE_CANON_TAG_FOCAL_LENGTH:
00410         case MNOTE_CANON_TAG_PANORAMA:
00411                 return entry->components;
00412         case MNOTE_CANON_TAG_SETTINGS_1:
00413         case MNOTE_CANON_TAG_SETTINGS_2:
00414         case MNOTE_CANON_TAG_CUSTOM_FUNCS:
00415                 if (entry->format != EXIF_FORMAT_SHORT) return 0;
00416 
00417                 val = exif_get_short (entry->data, entry->order);
00418                 /* val is buffer size, i.e. # of values plus 1 */
00419                 return MIN (entry->size - 2, val) / 2;
00420         default:
00421                 return 1;
00422         }
00423 }
00424 
00425 /*
00426  * For reference, see Exif 2.1 specification (Appendix C), 
00427  * or http://en.wikipedia.org/wiki/APEX_system
00428  */
00429 static double
00430 apex_value_to_aperture (double x)
00431 {
00432         return pow (2, x / 2.);
00433 }
00434 
00435 static double
00436 apex_value_to_shutter_speed(double x)
00437 {
00438         return 1.0 / pow (2, x);
00439 }
00440 
00441 static double
00442 apex_value_to_iso_speed (double x)
00443 {
00444         return 3.125 * pow (2, x);
00445 }
00446 
00447 char *
00448 mnote_canon_entry_get_value (const MnoteCanonEntry *entry, unsigned int t, char *val, unsigned int maxlen)
00449 {
00450         char buf[128];
00451         ExifLong vl;
00452         ExifShort vs, n;
00453         unsigned char *data = entry->data;
00454         double d;
00455 
00456         if (!entry) return NULL;
00457 
00458         memset (val, 0, maxlen);
00459         maxlen--;
00460 
00461         switch (entry->tag) {
00462         case MNOTE_CANON_TAG_SETTINGS_1:
00463                 CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen);
00464                 n = exif_get_short (data, entry->order) / 2;
00465                 if (t >= n) return NULL;
00466                 CC (entry->components, n, val, maxlen);
00467                 vs = exif_get_short (entry->data + 2 + t * 2, entry->order);
00468                 switch (t) {
00469                 case 1:
00470                         if (!vs) break;
00471                         snprintf (val, maxlen, _("%i (ms)"), vs * 100);
00472                         break;
00473                 case 22:
00474                 case 23:
00475                 case 24:
00476                         snprintf (val, maxlen, "%u", vs);
00477                         break;
00478                 case 25:
00479                 case 26:
00480                         snprintf (val, maxlen, "%.2f", apex_value_to_aperture (vs / 32.0));
00481                         break;
00482                 case 28:
00483                         canon_search_table_bitfield(entries_settings_1, t, vs, val, maxlen);
00484                         break;
00485                 case 34:
00486                         snprintf (val, maxlen, "%.2f", vs / 10.0);
00487                         break;
00488                 case 35:
00489                 case 36:
00490                         snprintf (val, maxlen, "%u", vs);
00491                         break;
00492                 default:
00493                         canon_search_table_value (entries_settings_1, t, vs, val, maxlen);
00494                 }
00495                 break;
00496 
00497         case MNOTE_CANON_TAG_FOCAL_LENGTH:
00498                 CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen);
00499                 vs = exif_get_short (entry->data + t * 2, entry->order);
00500                 switch (t) {
00501                 case 1:
00502                         snprintf (val, maxlen, "%u", vs);
00503                         break;
00504                 case 2:
00505                 case 3:
00506                         snprintf (val, maxlen, _("%.2f mm"), vs * 25.4 / 1000);
00507                         break;
00508                 default:
00509                         canon_search_table_value (entries_focal_length, t, vs, val, maxlen);
00510                 }
00511                 break;
00512 
00513         case MNOTE_CANON_TAG_SETTINGS_2:
00514                 CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen);
00515                 n = exif_get_short (data, entry->order) / 2;
00516                 if (t >= n) return NULL;
00517                 CC (entry->components, n, val, maxlen);
00518                 vs = exif_get_short (entry->data + 2 + t * 2, entry->order);
00519                 switch (t) {
00520                 case 0:
00521                 case 1:
00522                         snprintf (val, maxlen, "%.0f", apex_value_to_iso_speed(vs / 32.0));
00523                         break;
00524                 case 2:
00525                 case 5:
00526                 case 14:
00527                 case 16:
00528                         snprintf (val, maxlen, _("%.2f EV"), vs / 32.0);
00529                         break;
00530                 case 3:
00531                 case 20:
00532                         snprintf (val, maxlen, "%.2f", apex_value_to_aperture (vs / 32.0));
00533                         break;
00534                 case 4:
00535                 case 21:
00536                         d = apex_value_to_shutter_speed(vs / 32.0);
00537                         if (d < 1)
00538                                 snprintf (val, maxlen, _("1/%d"),(int)(1.0 / d));
00539                         else
00540                                 snprintf (val, maxlen, _("%d"), (int) d);
00541                         break;
00542                 case 8:
00543                         snprintf (val, maxlen, "%u", vs);
00544                         break;
00545                 case 12:
00546                         snprintf (val, maxlen, "%.2f", vs / 32.0);
00547                         break;
00548                 case 18:
00549                 case 19:
00550                         snprintf (val, maxlen, _("%u mm"), vs);
00551                         break;
00552                 case 28:
00553                         if (!vs) break;
00554                         snprintf (val, maxlen, _("%i (ms)"), vs * 100);
00555                         break;
00556                 default:
00557                         canon_search_table_value (entries_settings_2, t, vs, val, maxlen);
00558                 }
00559                 break;
00560 
00561         case MNOTE_CANON_TAG_PANORAMA:
00562                 CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen);
00563                 vs = exif_get_short (entry->data + t * 2, entry->order);
00564                 canon_search_table_value (entries_panorama, t, vs, val, maxlen);
00565                 break;
00566 
00567         case MNOTE_CANON_TAG_OWNER:
00568                 CC (entry->components, 32, val, maxlen);
00569                 /* Fall through; ImageType can have many sizes */
00570         case MNOTE_CANON_TAG_IMAGE_TYPE:
00571                 CF (entry->format, EXIF_FORMAT_ASCII, val, maxlen);
00572                 strncpy (val, (char *)data, MIN (entry->size, maxlen));
00573                 break;
00574 
00575         case MNOTE_CANON_TAG_FIRMWARE:
00576                 CF (entry->format, EXIF_FORMAT_ASCII, val, maxlen);
00577 /*              CC2 (entry->components, 24, 32, val, maxlen); Can also be 22 */
00578                 strncpy (val, (char *)data, MIN (entry->size, maxlen));
00579                 break;
00580 
00581         case MNOTE_CANON_TAG_IMAGE_NUMBER:
00582                 CF (entry->format, EXIF_FORMAT_LONG, val, maxlen);
00583                 CC (entry->components, 1, val, maxlen);
00584                 vl = exif_get_long (data, entry->order);
00585                 snprintf (val, maxlen, "%03lu-%04lu",
00586                                 (unsigned long) vl/10000,
00587                                 (unsigned long) vl%10000);
00588                 break;
00589 
00590         case MNOTE_CANON_TAG_SERIAL_NUMBER:
00591                 CF (entry->format, EXIF_FORMAT_LONG, val, maxlen);
00592                 CC (entry->components, 1, val, maxlen);
00593                 vl = exif_get_long (data, entry->order);
00594                 snprintf (val, maxlen, "%04X-%05d", (int)vl>>16,(int)vl&0xffff);
00595                 break;
00596 
00597         case MNOTE_CANON_TAG_CUSTOM_FUNCS:
00598                 CF (entry->format, EXIF_FORMAT_SHORT, val, maxlen);
00599                 n = exif_get_short (data, entry->order) / 2;
00600                 if (t >= n) return NULL;
00601                 CC (entry->components, n, val, maxlen);
00602                 vs = exif_get_short (data + 2 + 2 * t, entry->order);
00603                 snprintf (buf, sizeof (buf), "%u", vs);
00604                 strncat (val, buf, maxlen - strlen (val));
00605                 break;
00606 
00607         default:
00608 #ifdef DEBUG
00609                 if (entry->format == EXIF_FORMAT_SHORT)
00610                 for(i=0;i<entry->components;i++) {
00611                         vs = exif_get_short (data, entry->order);
00612                         data+=2;
00613                         printf ("Value%d=%d\n", i, vs);
00614                 }
00615                 else if (entry->format == EXIF_FORMAT_LONG)
00616                 for(i=0;i<entry->components;i++) {
00617                         vl = exif_get_long (data, entry->order);
00618                         data+=4;
00619                         printf ("Value%d=%d\n", i, vs);
00620                 }
00621                 else if (entry->format == EXIF_FORMAT_ASCII)
00622                     strncpy (val, data, MIN (entry->size, maxlen));
00623 #endif
00624                 break;
00625         }
00626         return val;
00627 }

Generated on Fri Jun 15 20:58:43 2007 for EXIF library (libexif) Internals by  doxygen 1.5.0