From: Lutz M. <lu...@us...> - 2004-06-06 03:04:39
|
Update of /cvsroot/libexif/libexif/libexif/olympus In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29923/libexif/olympus Modified Files: Makefile.am exif-mnote-data-olympus.c mnote-olympus-entry.c mnote-olympus-tag.c Log Message: 2004-06-06 Lutz Mueller <lu...@us...> * libexif/olympus/exif-mnote-data-olympus.c: More documentation, additional case (Nikon, 02 0a 00). * Makefile.am: s/LIBMNOTE/LIBEXIF Index: mnote-olympus-entry.c =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/olympus/mnote-olympus-entry.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- mnote-olympus-entry.c 25 May 2004 22:30:53 -0000 1.11 +++ mnote-olympus-entry.c 6 Jun 2004 03:04:21 -0000 1.12 @@ -179,7 +179,7 @@ CC (entry->components, 4, v, maxlen); vl = exif_get_long (entry->data, entry->order); if ((vl & 0xF0F0F0F0) == 0x30303030) { - memcpy (v, entry->data, MIN(maxlen, 4)); + memcpy (v, entry->data, MIN (maxlen, 4)); } else { snprintf (v, maxlen, "%04lx", vl); } Index: mnote-olympus-tag.c =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/olympus/mnote-olympus-tag.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- mnote-olympus-tag.c 10 May 2004 12:28:48 -0000 1.3 +++ mnote-olympus-tag.c 6 Jun 2004 03:04:21 -0000 1.4 @@ -22,6 +22,7 @@ #include "mnote-olympus-tag.h" #include <libexif/i18n.h> +#include <libexif/exif-utils.h> #include <stdlib.h> @@ -133,7 +134,7 @@ { unsigned int i; - bindtextdomain (GETTEXT_PACKAGE, LIBMNOTE_LOCALEDIR); + bindtextdomain (GETTEXT_PACKAGE, LIBEXIF_LOCALEDIR); for (i = 0; table[i].title; i++) if (table[i].tag == t) break; return (_(table[i].title)); } @@ -143,7 +144,8 @@ { unsigned int i; - bindtextdomain (GETTEXT_PACKAGE, LIBMNOTE_LOCALEDIR); + bindtextdomain (GETTEXT_PACKAGE, LIBEXIF_LOCALEDIR); for (i = 0; table[i].description; i++) if (table[i].tag == t) break; + if (!table[i].description) return NULL; return (_(table[i].description)); } Index: exif-mnote-data-olympus.c =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/olympus/exif-mnote-data-olympus.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- exif-mnote-data-olympus.c 25 May 2004 22:30:49 -0000 1.14 +++ exif-mnote-data-olympus.c 6 Jun 2004 03:04:21 -0000 1.15 @@ -62,9 +62,9 @@ { ExifMnoteDataOlympus *n = (ExifMnoteDataOlympus *) d; - if (!d) return NULL; - if (n->count <= i) return NULL; - exif_log (d->log, EXIF_LOG_CODE_DEBUG, "MnoteDataOlympus", + if (!d || !val) return NULL; + if (i > n->count -1) return NULL; + exif_log (d->log, EXIF_LOG_CODE_DEBUG, "ExifMnoteDataOlympus", "Querying value for tag '%s'...", mnote_olympus_tag_get_name (n->entries[i].tag)); return mnote_olympus_entry_get_value (&n->entries[i], val, maxlen); @@ -159,58 +159,108 @@ { ExifMnoteDataOlympus *n = (ExifMnoteDataOlympus *) en; ExifShort c; - unsigned int i, s, o, o2, datao = 6, base = 0; + unsigned int i, s, o, o2 = 0, datao = 6, base = 0; if (!n || !buf) return; - exif_log (en->log, EXIF_LOG_CODE_DEBUG, "ExifMnoteOlympus", - "Trying to parse Olympus/Nikon maker note..."); + /* Start of interesting data */ + o2 = 6 + n->offset; /* * Olympus headers start with "OLYMP" and need to have at least * a size of 22 bytes (6 for 'OLYMP', 2 other bytes, 2 for the * number of entries, and 12 for one entry. * - * Nikon v1 headers start with "Nikon", 0, 1, 0, number_of_tags, + * Nikon headers start with "Nikon" (6 bytes including '\0'), + * version number (1 or 2). + * + * Version 1 continues with 0, 1, 0, number_of_tags, * or just with number_of_tags (models D1H, D1X...). - * Nikon v2 headers start with "Nikon", 0, 2, 0, 0, 0, "MM", 0, 0x2A - * or "Nikon", 0, 2, 0, 0, 0, "II", 0x2A, 0. + * + * Version 2 continues with an unknown byte (0 or 10), + * two unknown bytes (0), "MM" or "II", another byte 0 and + * lastly 0x2A. */ if (buf_size - n->offset < 22) return; - if (!memcmp (buf + 6 + n->offset, "OLYMP", 5)) { - o2 = 6 + n->offset + 8 + 2; - c = exif_get_short (buf + 6 + n->offset + 8, n->order); + if (!memcmp (buf + o2, "OLYMP", 5)) { + exif_log (en->log, EXIF_LOG_CODE_DEBUG, "ExifMnoteDataOlympus", + "Parsing Olympus maker note..."); + + /* The number of entries is at position 8. */ n->version = 0; - } else if (!memcmp (buf + 6 + n->offset, "Nikon", 5)) { - o2 = 6 + n->offset + 8 + 2; - datao = o2; - if (!memcmp(buf + o2 - 4, "\2\0\0\0II\x2A\0", 8)) { - n->order = EXIF_BYTE_ORDER_INTEL; - o2 += exif_get_long(buf + o2 + 4, n->order); - n->version = 2; - } else if (!memcmp(buf + o2 - 4, "\2\0\0\0MM\0\x2A", 8)) { - n->order = EXIF_BYTE_ORDER_MOTOROLA; - o2 += exif_get_long(buf + o2 + 4, n->order); - n->version = 2; - } else if (!memcmp(buf + o2 - 4, "\1\0", 2)) { - o2 -= 2; + o2 += 8; + + } else if (!memcmp (buf + o2, "Nikon", 6)) { + o2 += 6; + exif_log (en->log, EXIF_LOG_CODE_DEBUG, "ExifMnoteDataOlympus", + "Parsing Nikon maker note (0x%02x, %02x, %02x, " + "%02x, %02x, %02x, %02x, %02x, %02x)...", + buf[o2 + 0], buf[o2 + 1], buf[o2 + 2], buf[o2 + 3], + buf[o2 + 4], buf[o2 + 5], buf[o2 + 6], buf[o2 + 7]); + + /* The first byte is the version. */ + if (o2 >= buf_size) return; + n->version = buf[o2]; + o2 += 1; + + /* Skip an unknown byte (00 or 0A). */ + o2 += 1; + + switch (n->version) { + case 1: + base = MNOTE_NIKON1_TAG_BASE; - n->version = 1; - } else { + break; + + case 2: + + /* Skip 2 unknown bytes (00 00). */ + o2 += 2; + + /* + * Byte order. From here the data offset + * gets calculated. + */ + datao = o2; + if (o2 >= buf_size) return; + if (!strncmp (&buf[o2], "II", 2)) + n->order = EXIF_BYTE_ORDER_INTEL; + else if (!strncmp (&buf[o2], "MM", 2)) + n->order = EXIF_BYTE_ORDER_MOTOROLA; + else { + exif_log (en->log, EXIF_LOG_CODE_DEBUG, + "ExifMnoteDatalympus", "Unknown " + "byte order '%c%c'", buf[o2], + buf[o2 + 1]); + return; + } + o2 += 2; + + /* Skip 2 unknown bytes (00 2A). */ + o2 += 2; + + /* Go to where the number of entries is. */ + if (o2 >= buf_size) return; + o2 = datao + exif_get_long (buf + o2, n->order); + break; + + default: + exif_log (en->log, EXIF_LOG_CODE_DEBUG, + "ExifMnoteDataOlympus", "Unknown version " + "number %i.", n->version); return; } - if (o2 + 2 > buf_size) return; - c = exif_get_short (buf + o2, n->order); - o2 += 2; - } else if (!memcmp (buf + 6 + n->offset, "\0\x1b", 2)) { - o2 = 6 + n->offset; - c = exif_get_short (buf + o2, n->order); - o2 += 2; + } else if (!memcmp (buf + o2, "\0\x1b", 2)) { n->version = 2; } else { return; } + /* Number of entries */ + if (o2 >= buf_size) return; + c = exif_get_short (buf + o2, n->order); + o2 += 2; + /* Read the number of entries and remove old ones. */ exif_mnote_data_olympus_clear (n); Index: Makefile.am =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/olympus/Makefile.am,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Makefile.am 26 Oct 2003 10:11:31 -0000 1.6 +++ Makefile.am 6 Jun 2004 03:04:21 -0000 1.7 @@ -1,5 +1,5 @@ INCLUDES = \ - -DLIBMNOTE_LOCALEDIR=\""$(datadir)/locale"\" \ + -DLIBEXIF_LOCALEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir) \ -I$(top_srcdir)/intl |