Update of /cvsroot/libexif/libmnote/libmnote/olympus
In directory sc8-pr-cvs1:/tmp/cvs-serv3220/libmnote/olympus
Modified Files:
mnote-olympus-data.c mnote-olympus-tag.h
Log Message:
2003-08-25 Lutz Mueller <lutz@...>
* libmnote/mnote-data.c (mnote_data_new_from_path): New
(mnote_data_new_from_data): Now handles EXIF data, too (instead
of only MakerNote data).
Index: mnote-olympus-data.c
===================================================================
RCS file: /cvsroot/libexif/libmnote/libmnote/olympus/mnote-olympus-data.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- mnote-olympus-data.c 24 Jul 2003 20:18:11 -0000 1.4
+++ mnote-olympus-data.c 25 Aug 2003 21:00:24 -0000 1.5
@@ -27,6 +27,7 @@
#include <libexif/exif-byte-order.h>
#include <libexif/exif-utils.h>
+#include <libexif/exif-data.h>
#define DEBUG
@@ -138,8 +139,8 @@
doff = exif_get_long (d + offset + 8, order);
d_orig = d + doff;
#ifdef DEBUG
- printf("**** data offset is %i\n", doff);
- dump_memory_around(d_orig);
+ printf ("**** data offset is %i\n", doff);
+ dump_memory_around (d_orig);
#endif
}
else {
@@ -160,7 +161,6 @@
memcpy (entry->data, d_orig, s);
}
-
static void
mnote_olympus_data_load_data (MNoteData *en, const unsigned char *data,
unsigned int size)
@@ -168,38 +168,49 @@
MNoteOlympusData *note = (MNoteOlympusData *) en;
MNoteOlympusTag tag;
MNoteOlympusEntry *entry;
+ const unsigned char *p = data;
+ ExifData *ed = NULL;
+ ExifEntry *e = NULL;
+ ExifByteOrder o = EXIF_BYTE_ORDER_INTEL;
+ short nEntries;
+ const unsigned char *tagEntries;
+ unsigned int i;
- // Check for reality and usefulness
- // -- needs to start with OLYMP
- // -- if < 22 bytes, hasn't got space for any entries
- if ((size < 22) || memcmp(data, "OLYMP", 5)) {
-#ifdef DEBUG
- printf("Olympus maker note malformed or too small\n");
-#endif
- return;
+ /* If we got EXIF data, go to the MakerNote tag. */
+ ed = exif_data_new_from_data (data, size);
+ if (ed) {
+ e = exif_content_get_entry (ed->ifd[EXIF_IFD_EXIF],
+ EXIF_TAG_MAKER_NOTE);
+ o = exif_data_get_byte_order (ed);
+ if (e) p = e->data;
}
- else {
- ExifByteOrder order = mnote_data_get_byte_order (en);
- short nEntries = exif_get_short (data + 8, order);
- const unsigned char *tagEntries = data + 10;
- unsigned int i;
- for (i = 0; i < nEntries; i++) {
- tag = exif_get_short (tagEntries + 12 * i, order);
+ /*
+ * Olympus headers start with "OLYMP" and need to have at least
+ * a size of 22 bytes.
+ */
+ if ((size < 22) || memcmp (p, "OLYMP", 5)) {
+ exif_data_unref (ed);
+ return;
+ }
+
+ nEntries = exif_get_short (p + 8, o);
+ tagEntries = p + 10;
+
+ for (i = 0; i < nEntries; i++) {
+ tag = exif_get_short (tagEntries + 12 * i, o);
#ifdef DEBUG
- printf ("Loading entry '%s' (%x) (%i)...\n",
- mnote_olympus_tag_get_name (tag), tag, i + 1);
+ printf ("Loading entry '%s' (%x) (%i)...\n",
+ mnote_olympus_tag_get_name (tag), tag, i + 1);
#endif
entry = mnote_olympus_entry_new ();
mnote_olympus_data_add_entry (note, entry);
- mnote_olympus_data_load_data_entry (note, entry, tagEntries, size,
- 12 * i);
+ mnote_olympus_data_load_data_entry (note, entry,
+ tagEntries, size, 12 * i);
mnote_olympus_entry_unref (entry);
}
- }
-
-
}
+
static unsigned int
mnote_olympus_get_count (MNoteData *n)
{
@@ -233,12 +244,12 @@
if (!note || !func) {
#ifdef DEBUG
- if (!note) printf("No note in foreach_entry\n");
- if (!func) printf("No func in foreach_entry\n");
+ if (!note) printf ("No note in foreach_entry\n");
+ if (!func) printf ("No func in foreach_entry\n");
#endif
return;
}
- printf("In mnote_olympus_foreach_entry for %d entries\n", note->count);
+ printf ("In mnote_olympus_foreach_entry for %d entries\n", note->count);
for (i = 0; i < note->count; i++) {
printf ("Calling func for i = %i\n", i);
func (n, (MNoteTag)note->entries[i]->tag, data);
Index: mnote-olympus-tag.h
===================================================================
RCS file: /cvsroot/libexif/libmnote/libmnote/olympus/mnote-olympus-tag.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- mnote-olympus-tag.h 24 Jul 2003 20:18:11 -0000 1.3
+++ mnote-olympus-tag.h 25 Aug 2003 21:00:24 -0000 1.4
@@ -32,7 +32,7 @@
MNOTE_OLYMPUS_TAG_QUALITY = 0x0201,
MNOTE_OLYMPUS_TAG_MACRO = 0x0202,
MNOTE_OLYMPUS_TAG_UNKNOWN_1 = 0x0203,
- MNOTE_OLYMPUS_TAG_DIGIZOOM = 0x0204,
+ MNOTE_OLYMPUS_TAG_DIGIZOOM = 0x0204,
MNOTE_OLYMPUS_TAG_UNKNOWN_2 = 0x0205,
MNOTE_OLYMPUS_TAG_UNKNOWN_3 = 0x0206,
MNOTE_OLYMPUS_TAG_VERSION = 0x0207,
|