From: Dan F. <dfa...@us...> - 2009-01-22 07:38:29
|
Update of /cvsroot/libexif/libexif/libexif In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv30749/libexif Modified Files: exif-tag.c exif-tag.h Log Message: When the data type is not known in exif_tag_get_support_level_in_ifd check the support level for all data types and if it's all the same, return that. This means that fixing a new EXIF tag block will actually create some tags in it now. Index: exif-tag.h =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/exif-tag.h,v retrieving revision 1.22 retrieving revision 1.23 diff -u -p -d -r1.22 -r1.23 --- exif-tag.h 14 Jan 2009 06:27:35 -0000 1.22 +++ exif-tag.h 22 Jan 2009 07:38:19 -0000 1.23 @@ -188,7 +188,7 @@ typedef enum { /*! The meaning of this tag is unknown */ EXIF_SUPPORT_LEVEL_UNKNOWN = 0, - /*! This tag is not found in the given IFD */ + /*! This tag is not allowed in the given IFD */ EXIF_SUPPORT_LEVEL_NOT_RECORDED, /*! This tag is mandatory in the given IFD */ @@ -239,6 +239,7 @@ const char *exif_tag_get_descriptio * \param[in] tag EXIF tag * \param[in] ifd IFD * \param[in] t data type + * \return the level of support for this tag */ ExifSupportLevel exif_tag_get_support_level_in_ifd (ExifTag tag, ExifIfd ifd, ExifDataType t); Index: exif-tag.c =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/exif-tag.c,v retrieving revision 1.51 retrieving revision 1.52 diff -u -p -d -r1.51 -r1.52 --- exif-tag.c 21 Jan 2009 00:09:44 -0000 1.51 +++ exif-tag.c 22 Jan 2009 07:38:19 -0000 1.52 @@ -39,6 +39,8 @@ #define ESL_GPS { ESL_NNNN, ESL_NNNN, ESL_NNNN, ESL_OOOO, ESL_NNNN } static const struct { + /*! Tag ID. There may be duplicate tags when the same number is used for + * different meanings in different IFDs. */ ExifTag tag; const char *name; const char *title; @@ -991,17 +993,70 @@ exif_tag_from_name (const char *name) return result; } +/*! Return the support level of a tag in the given IFD with the given data + * type. If the tag is not specified in the EXIF standard, this function + * returns EXIF_SUPPORT_LEVEL_NOT_RECORDED. + * + * \param[in] tag EXIF tag + * \param[in] ifd a valid IFD (not EXIF_IFD_COUNT) + * \param[in] t a valid data type (not EXIF_DATA_TYPE_COUNT) + * \return the level of support for this tag + */ +static inline ExifSupportLevel +get_support_level_in_ifd (ExifTag tag, ExifIfd ifd, ExifDataType t) +{ + unsigned int i; + for (i = 0; ExifTagTable[i].description; i++) { + if (ExifTagTable[i].tag == tag) + return ExifTagTable[i].esl[ifd][t]; + } + return EXIF_SUPPORT_LEVEL_NOT_RECORDED; +} + +/*! Return the support level of a tag in the given IFD, regardless of the + * data type. If the support level varies depending on the data type, this + * function returns EXIF_SUPPORT_LEVEL_UNKNOWN. If the tag is not specified + * in the EXIF standard, this function returns EXIF_SUPPORT_LEVEL_UNKNOWN. + * + * \param[in] tag EXIF tag + * \param[in] ifd a valid IFD (not EXIF_IFD_COUNT) + * \return the level of support for this tag + */ +static inline ExifSupportLevel +get_support_level_any_type (ExifTag tag, ExifIfd ifd) +{ + unsigned int i; + for (i = 0; ExifTagTable[i].description; i++) { + if (ExifTagTable[i].tag == tag) { + /* + * Check whether the support level is the same for all possible + * data types and isn't marked not recorded. + */ + const ExifSupportLevel supp = ExifTagTable[i].esl[ifd][0]; + if (supp != EXIF_SUPPORT_LEVEL_NOT_RECORDED) { + unsigned int dt; + for (dt = 0; dt < EXIF_DATA_TYPE_COUNT; ++dt) { + if (ExifTagTable[i].esl[ifd][dt] != supp) + break; + } + if (dt == EXIF_DATA_TYPE_COUNT) + /* Support level is always the same, so return it */ + return supp; + } + /* Keep searching the table for another tag for our IFD */ + } + } + return EXIF_SUPPORT_LEVEL_UNKNOWN; +} + ExifSupportLevel exif_tag_get_support_level_in_ifd (ExifTag tag, ExifIfd ifd, ExifDataType t) { - unsigned int i; + if (ifd >= EXIF_IFD_COUNT) + return EXIF_SUPPORT_LEVEL_UNKNOWN; - if (ifd >= EXIF_IFD_COUNT) return EXIF_SUPPORT_LEVEL_UNKNOWN; - if (t >= EXIF_DATA_TYPE_COUNT) return EXIF_SUPPORT_LEVEL_UNKNOWN; + if (t >= EXIF_DATA_TYPE_COUNT) + return get_support_level_any_type (tag, ifd); - for (i = 0; ExifTagTable[i].description; i++) - if ((ExifTagTable[i].tag == tag) && - (ExifTagTable[i].esl[ifd][t] != EXIF_SUPPORT_LEVEL_NOT_RECORDED)) - return ExifTagTable[i].esl[ifd][t]; - return EXIF_SUPPORT_LEVEL_NOT_RECORDED; + return get_support_level_in_ifd (tag, ifd, t); } |