From: Lutz M?l. <lu...@us...> - 2003-10-26 10:10:30
|
Update of /cvsroot/libexif/libexif/libexif In directory sc8-pr-cvs1:/tmp/cvs-serv26651/libexif Modified Files: Makefile.am exif-data.c exif-data.h Added Files: exif-mnote-data-priv.h exif-mnote-data.c exif-mnote-data.h Log Message: 2003-10-26 Lutz Mueller <lu...@us...> * libexif/olympus * libexif/canon * libexif/pentax: Merge libmnote with libexif. The code compiles but is completely untested. Index: exif-data.h =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/exif-data.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- exif-data.h 15 Dec 2002 11:41:11 -0000 1.6 +++ exif-data.h 26 Oct 2003 10:06:17 -0000 1.7 @@ -33,6 +33,7 @@ typedef struct _ExifDataPrivate ExifDataPrivate; #include <libexif/exif-content.h> +#include <libexif/exif-mnote-data.h> struct _ExifData { @@ -61,12 +62,27 @@ ExifByteOrder exif_data_get_byte_order (ExifData *data); void exif_data_set_byte_order (ExifData *data, ExifByteOrder order); +ExifMnoteData *exif_data_get_mnote_data (ExifData *); + typedef void (* ExifDataForeachContentFunc) (ExifContent *, void *user_data); void exif_data_foreach_content (ExifData *data, ExifDataForeachContentFunc func, void *user_data); void exif_data_dump (ExifData *data); + +/* For your convenience */ +#define exif_data_get_entry(d,t) \ + (exif_content_get_entry(d->ifd[EXIF_IFD_0],t) ? \ + exif_content_get_entry(d->ifd[EXIF_IFD_0],t) : \ + exif_content_get_entry(d->ifd[EXIF_IFD_1],t) ? \ + exif_content_get_entry(d->ifd[EXIF_IFD_1],t) : \ + exif_content_get_entry(d->ifd[EXIF_IFD_EXIF],t) ? \ + exif_content_get_entry(d->ifd[EXIF_IFD_EXIF],t) : \ + exif_content_get_entry(d->ifd[EXIF_IFD_GPS],t) ? \ + exif_content_get_entry(d->ifd[EXIF_IFD_GPS],t) : \ + exif_content_get_entry(d->ifd[EXIF_IFD_INTEROPERABILITY],t) ? \ + exif_content_get_entry(d->ifd[EXIF_IFD_INTEROPERABILITY],t) : NULL) #ifdef __cplusplus } --- NEW FILE: exif-mnote-data.h --- (This appears to be a binary file; contents omitted.) Index: Makefile.am =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/Makefile.am,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- Makefile.am 17 Mar 2003 20:38:46 -0000 1.20 +++ Makefile.am 26 Oct 2003 10:06:17 -0000 1.21 @@ -1,3 +1,4 @@ +SUBDIRS = canon olympus pentax INCLUDES = \ -DLIBEXIF_LOCALEDIR=\""$(datadir)/locale"\" \ -I$(top_srcdir)/libexif \ @@ -16,10 +17,15 @@ exif-format.c \ exif-ifd.c \ exif-loader.c \ + exif-mnote-data.c \ + exif-mnote-data-priv.h \ exif-tag.c \ exif-utils.c \ i18n.h -libexif_la_LIBADD = -lm +libexif_la_LIBADD = -lm \ + canon/libmnote-canon.a \ + olympus/libmnote-olympus.a \ + olympus/libmnote-pentax.a libexifincludedir = $(includedir)/libexif libexifinclude_HEADERS = \ @@ -30,6 +36,7 @@ exif-format.h \ exif-ifd.h \ exif-loader.h \ + exif-mnote-data.h \ exif-result.h \ exif-tag.h \ exif-utils.h Index: exif-data.c =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/exif-data.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- exif-data.c 8 Oct 2003 18:08:01 -0000 1.28 +++ exif-data.c 26 Oct 2003 10:06:17 -0000 1.29 @@ -18,13 +18,20 @@ * Boston, MA 02111-1307, USA. */ -#include "config.h" +#include <config.h> +#include "exif-mnote-data.h" + #include "exif-data.h" #include "exif-ifd.h" +#include "exif-mnote-data-priv.h" #include "exif-utils.h" #include "exif-loader.h" #include "jpeg-marker.h" +#include <libexif/olympus/exif-mnote-data-olympus.h> +#include <libexif/canon/exif-mnote-data-canon.h> +#include <libexif/pentax/exif-mnote-data-pentax.h> + #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -40,6 +47,8 @@ { ExifByteOrder order; + ExifMnoteData *md; + unsigned int ref_count; }; @@ -451,12 +460,31 @@ exif_set_long (*d + 6 + offset, data->priv->order, 0); } +static void +exif_data_remove_entry (ExifData *d, ExifTag t) +{ + exif_content_remove_entry (d->ifd[EXIF_IFD_0], + exif_content_get_entry (d->ifd[EXIF_IFD_0], t)); + exif_content_remove_entry (d->ifd[EXIF_IFD_1], + exif_content_get_entry (d->ifd[EXIF_IFD_1], t)); + exif_content_remove_entry (d->ifd[EXIF_IFD_EXIF], + exif_content_get_entry (d->ifd[EXIF_IFD_EXIF], t)); + exif_content_remove_entry (d->ifd[EXIF_IFD_GPS], + exif_content_get_entry (d->ifd[EXIF_IFD_GPS], t)); + exif_content_remove_entry (d->ifd[EXIF_IFD_INTEROPERABILITY], + exif_content_get_entry (d->ifd[EXIF_IFD_INTEROPERABILITY], t)); +} + void -exif_data_load_data (ExifData *data, const unsigned char *d, unsigned int size) +exif_data_load_data (ExifData *data, const unsigned char *d_orig, + unsigned int ds_orig) { - unsigned int l, len = size; + unsigned int l; ExifLong offset; ExifShort n; + ExifEntry *e, *em; + const unsigned char *d = d_orig; + unsigned int size = ds_orig, len; if (!data) return; @@ -601,6 +629,48 @@ exif_data_load_data_content (data, data->ifd[EXIF_IFD_1], d + 6, size - 6, offset); } + + /* + * If we got an EXIF_TAG_MAKER_NOTE, try to interpret it. Some + * cameras use pointers in the maker note tag that point to the + * space between IFDs. Here is the only place where we have access + * to that data. + */ + e = exif_data_get_entry (data, EXIF_TAG_MAKER_NOTE); + if (e) { + + /* Olympus */ + if ((e->size >= 5) && (!memcmp (e->data, "OLYMP", 5))) + data->priv->md = exif_mnote_data_olympus_new ( + data->priv->order); + + /* Pentax */ + else if ((e->size >= 2) && (e->data[0] == 0x00) + && (e->data[1] == 0x1b)) + data->priv->md = exif_mnote_data_pentax_new ( + data->priv->order); + + else { + em = exif_data_get_entry (data, EXIF_TAG_MAKE); + if (em) { + + /* Canon */ + if (!strcmp (exif_entry_get_value (em), "Canon")) + data->priv->md = exif_mnote_data_canon_new ( + data->priv->order); + } + } + + /* + * If we are able to interpret the maker note, interpret it and + * remove the corresponding entry as it may contain invalid + * pointers after this function here returns. + */ + if (data->priv->md) { + exif_mnote_data_load (data->priv->md, d_orig, ds_orig); + exif_data_remove_entry (data, EXIF_TAG_MAKER_NOTE); + } + } } void @@ -718,6 +788,10 @@ data->data = NULL; } if (data->priv) { + if (data->priv->md) { + exif_mnote_data_unref (data->priv->md); + data->priv->md = NULL; + } free (data->priv); data->priv = NULL; } --- NEW FILE: exif-mnote-data-priv.h --- (This appears to be a binary file; contents omitted.) --- NEW FILE: exif-mnote-data.c --- (This appears to be a binary file; contents omitted.) |