Added support for Sanyo makernotes, which are identical to Olympus
authorDan Fandrich <dan@coneharvesters.com>
Sat, 10 Nov 2007 08:02:33 +0000 (00:02 -0800)
committerDan Fandrich <dan@coneharvesters.com>
Sat, 10 Nov 2007 08:02:33 +0000 (00:02 -0800)
NEWS
libexif/exif-data.c
libexif/olympus/exif-mnote-data-olympus.c
libexif/olympus/exif-mnote-data-olympus.h

diff --git a/NEWS b/NEWS
index 7ecce94..cc99ca9 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ libexif-0.6.16.2:
   * New translations: nl, se, en_CA
   * Bug fixes: #1773810, #1774626
   * Enhanced support of Canon makernotes 
+  * Added support for Sanyo makernotes
   * Added support for the NO_VERBOSE_TAG_STRINGS macro for embedded
     applications
 
index 88758ce..499239c 100644 (file)
@@ -689,9 +689,11 @@ exif_data_get_type_maker_note (ExifData *d)
        if (!e) 
                return EXIF_DATA_TYPE_MAKER_NOTE_NONE;
 
-       /* Olympus & Nikon */
-       if ((e->size >= 8) && (!memcmp (e->data, "OLYMP", 6) ||
-                       !memcmp (e->data, "OLYMPUS", 8) || !memcmp (e->data, "Nikon", 6)))
+       /* Olympus & Nikon & Sanyo */
+       if ((e->size >= 8) && ( !memcmp (e->data, "OLYMP", 6) ||
+                               !memcmp (e->data, "OLYMPUS", 8) ||
+                               !memcmp (e->data, "SANYO", 6) ||
+                               !memcmp (e->data, "Nikon", 6)))
                return EXIF_DATA_TYPE_MAKER_NOTE_OLYMPUS;
 
        em = exif_data_get_entry (d, EXIF_TAG_MAKE);
index c3e19ee..e445401 100644 (file)
@@ -97,11 +97,12 @@ exif_mnote_data_olympus_save (ExifMnoteData *ne,
        *buf_size = 6 + 2 + 2 + n->count * 12;
        switch (n->version) {
        case olympusV1:
+       case sanyoV1:
                *buf = exif_mem_alloc (ne->mem, *buf_size);
                if (!*buf) return;
 
                /* Write the header and the number of entries. */
-               strcpy ((char *)*buf, "OLYMP");
+               strcpy ((char *)*buf, n->version==sanyoV1?"SANYO":"OLYMP");
                exif_set_short (*buf + 6, n->order, (ExifShort) 1);
                datao = n->offset;
                break;
@@ -208,6 +209,9 @@ exif_mnote_data_olympus_load (ExifMnoteData *en,
         * a size of 22 bytes (6 for 'OLYMP', 2 other bytes, 2 for the
         * number of entries, and 12 for one entry.
         *
+        * Sanyo format is identical and uses identical tags except that
+        * header starts with "SANYO".
+        *
         * Nikon headers start with "Nikon" (6 bytes including '\0'), 
         * version number (1 or 2).
         * 
@@ -219,12 +223,15 @@ exif_mnote_data_olympus_load (ExifMnoteData *en,
         * lastly 0x2A.
         */
        if (buf_size - n->offset < 22) return;
-       if (!memcmp (buf + o2, "OLYMP", 6)) {
+       if (!memcmp (buf + o2, "OLYMP", 6) || !memcmp (buf + o2, "SANYO", 6)) {
                exif_log (en->log, EXIF_LOG_CODE_DEBUG, "ExifMnoteDataOlympus",
-                       "Parsing Olympus maker note v1...");
+                       "Parsing Olympus/Sanyo maker note v1...");
 
                /* The number of entries is at position 8. */
-               n->version = olympusV1;
+               if (!memcmp (buf + o2, "SANYO", 6))
+                       n->version = sanyoV1;
+               else
+                       n->version = olympusV1;
                if (buf[o2 + 6] == 1)
                        n->order = EXIF_BYTE_ORDER_INTEL;
                else if (buf[o2 + 6 + 1] == 1)
index d39cb6f..2368a95 100644 (file)
@@ -26,7 +26,7 @@
 #include <libexif/exif-byte-order.h>
 #include <libexif/exif-mem.h>
 
-enum OlympusVersion {nikonV1 = 1, nikonV2 = 2, olympusV1 = 3, olympusV2 = 4 };
+enum OlympusVersion {nikonV1 = 1, nikonV2 = 2, olympusV1 = 3, olympusV2 = 4, sanyoV1 = 5 };
 
 
 typedef struct _ExifMnoteDataOlympus ExifMnoteDataOlympus;