[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a

Maximiliano Curia maxy at moszumanska.debian.org
Thu Jul 13 17:40:09 UTC 2017


Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=800b1c1

The following commit has been merged in the master branch:
commit 800b1c1c29c087612e11f69d202b470ec7a95c62
Author: Andreas Huggel <ahuggel at gmx.net>
Date:   Sat Nov 22 06:43:35 2008 +0000

    Improved non-intrusive writing.
---
 src/metadatum.hpp         |  4 ++--
 src/tags.cpp              |  5 +++++
 src/tags.hpp              |  6 ++++--
 src/tiffcomposite.cpp     |  2 +-
 src/tiffcomposite_int.hpp |  7 ++++++
 src/tiffimage.cpp         |  2 --
 src/tiffvisitor.cpp       | 54 ++++++++++++++++++++++++++++++++++++++++-------
 src/tiffvisitor_int.hpp   |  3 +++
 8 files changed, 68 insertions(+), 15 deletions(-)

diff --git a/src/metadatum.hpp b/src/metadatum.hpp
index 6260ece..939da17 100644
--- a/src/metadatum.hpp
+++ b/src/metadatum.hpp
@@ -301,7 +301,7 @@ namespace Exiv2 {
     //! Unary predicate that matches a Exifdatum with a given key
     class EXIV2API FindMetadatumByKey {
     public:
-        //! Constructor, initializes the object with the tag to look for
+        //! Constructor, initializes the object with the key to look for
         FindMetadatumByKey(const std::string& key) : key_(key) {}
         /*!
           @brief Returns true if the key of the argument metadatum is equal
@@ -313,7 +313,7 @@ namespace Exiv2 {
     private:
         std::string key_;
 
-    }; // class FindMetadatumByTag
+    }; // class FindMetadatumByKey
 
     /*!
       @brief Output operator for Metadatum types, writing the interpreted
diff --git a/src/tags.cpp b/src/tags.cpp
index 95932ea..ee92c7e 100644
--- a/src/tags.cpp
+++ b/src/tags.cpp
@@ -1867,6 +1867,11 @@ namespace Exiv2 {
         return *this;
     }
 
+    void ExifKey::setIdx(int idx)
+    {
+        idx_ = idx;
+    }
+
     std::string ExifKey::tagName() const
     {
         return ExifTags::tagName(tag_, ifdId_);
diff --git a/src/tags.hpp b/src/tags.hpp
index 01d2b4d..1f0dc41 100644
--- a/src/tags.hpp
+++ b/src/tags.hpp
@@ -362,6 +362,8 @@ namespace Exiv2 {
           @brief Assignment operator.
          */
         ExifKey& operator=(const ExifKey& rhs);
+        //! Set the index.
+        void setIdx(int idx);
         //@}
 
         //! @name Accessors
@@ -386,7 +388,7 @@ namespace Exiv2 {
         std::string ifdItem() const { return ifdItem_; }
         //! Return the name of the Exif section (deprecated)
         std::string sectionName() const;
-        //! Return the index (unique id of this key within the original IFD)
+        //! Return the index (unique id of this key within the original Exif data, 0 if not set)
         int idx() const { return idx_; }
         //@}
 
@@ -418,7 +420,7 @@ namespace Exiv2 {
         uint16_t tag_;                  //!< Tag value
         IfdId ifdId_;                   //!< The IFD associated with this tag
         std::string ifdItem_;           //!< The IFD item
-        int idx_;                       //!< Unique id of an entry within one IFD
+        int idx_;                       //!< Unique id of the Exif key in the image
         std::string key_;               //!< Key
     }; // class ExifKey
 
diff --git a/src/tiffcomposite.cpp b/src/tiffcomposite.cpp
index 9b64dd6..e6bb765 100644
--- a/src/tiffcomposite.cpp
+++ b/src/tiffcomposite.cpp
@@ -160,7 +160,7 @@ namespace Exiv2 {
     TiffEntryBase::TiffEntryBase(uint16_t tag, uint16_t group, TiffType tiffType)
         : TiffComponent(tag, group),
           tiffType_(tiffType), count_(0), offset_(0),
-          size_(0), pData_(0), isMalloced_(false),
+          size_(0), pData_(0), isMalloced_(false), idx_(0),
           pValue_(0)
     {
     }
diff --git a/src/tiffcomposite_int.hpp b/src/tiffcomposite_int.hpp
index f5d478e..6b98829 100644
--- a/src/tiffcomposite_int.hpp
+++ b/src/tiffcomposite_int.hpp
@@ -424,6 +424,10 @@ namespace Exiv2 {
          */
         int32_t offset()         const { return offset_; }
         /*!
+          @brief Return the unique id of the entry in the image
+         */
+        int idx()                const { return idx_; }
+        /*!
           @brief Return a pointer to the binary representation of the
                  value of this component.
          */
@@ -439,6 +443,8 @@ namespace Exiv2 {
         virtual void doEncode(TiffEncoder& encoder, const Exifdatum* datum) =0;
         //! Set the number of components in this entry
         void setCount(uint32_t count) { count_ = count; }
+        //! Set the unique id of the entry in the image
+        void setIdx(int idx) { idx_ = idx; }
         //@}
 
         //! @name Accessors
@@ -509,6 +515,7 @@ namespace Exiv2 {
         uint32_t size_;
         byte*    pData_;      //!< Pointer to the data area
         bool     isMalloced_; //!< True if this entry owns the value data
+        int      idx_;        //!< Unique id of the entry in the image
         Value*   pValue_;     //!< Converted data value
 
     }; // class TiffEntryBase
diff --git a/src/tiffimage.cpp b/src/tiffimage.cpp
index 49ab9bd..f4a73b6 100644
--- a/src/tiffimage.cpp
+++ b/src/tiffimage.cpp
@@ -66,8 +66,6 @@ EXIV2_RCSID("@(#) $Id$")
      do. What a mess. (That'll become an issue when it comes to writing to CR2)
    + Sony makernotes in RAW files do not seem to have header like those in Jpegs.
      And maybe no next pointer either.
-   + Filtering of large unknown tags: Should be moved to writing/encoding code
-     and done only if really needed (i.e., if writing to a Jpeg segment)
 
    in crwimage.* :
 
diff --git a/src/tiffvisitor.cpp b/src/tiffvisitor.cpp
index 44c2dfe..bdd0426 100644
--- a/src/tiffvisitor.cpp
+++ b/src/tiffvisitor.cpp
@@ -54,6 +54,22 @@ EXIV2_RCSID("@(#) $Id$")
 #include <cassert>
 
 // *****************************************************************************
+namespace {
+    //! Unary predicate that matches an Exifdatum with a given index.
+    class FindExifdatumByIdx {
+    public:
+        //! Constructor, initializes the object with the index to look for.
+        FindExifdatumByIdx(int idx) : idx_(idx) {}
+        //! Returns true if the index matches.
+        bool operator()(const Exiv2::Exifdatum& md) const { return idx_ == md.idx(); }
+
+    private:
+        int idx_;
+
+    }; // class FindExifdatumByIdx
+}
+
+// *****************************************************************************
 // class member definitions
 namespace Exiv2 {
     namespace Internal {
@@ -347,6 +363,7 @@ namespace Exiv2 {
         // Todo: ExifKey should have an appropriate c'tor, it should not be
         //       necessary to use groupName here
         ExifKey key(object->tag(), tiffGroupName(object->group()));
+        key.setIdx(object->idx());
         exifData_.add(key, object->pValue());
 
     } // TiffDecoder::decodeTiffEntry
@@ -409,15 +426,19 @@ namespace Exiv2 {
         // If there is new IPTC data and Exif.Image.ImageResources does
         // not exist, create a new IPTCNAA Exif tag.
         bool del = false;
-        const ExifKey iptcNaaKey("Exif.Image.IPTCNAA");
+        ExifKey iptcNaaKey("Exif.Image.IPTCNAA");
         ExifData::iterator pos = exifData_.findKey(iptcNaaKey);
         if (pos != exifData_.end()) {
+            iptcNaaKey.setIdx(pos->idx());
             exifData_.erase(pos);
             del = true;
         }
         DataBuf rawIptc = IptcParser::encode(iptcData_);
-        const ExifKey irbKey("Exif.Image.ImageResources");
+        ExifKey irbKey("Exif.Image.ImageResources");
         pos = exifData_.findKey(irbKey);
+        if (pos != exifData_.end()) {
+            irbKey.setIdx(pos->idx());
+        }
         if (rawIptc.size_ != 0 && (del || pos == exifData_.end())) {
             Value::AutoPtr value = Value::create(unsignedLong);
             value->read(rawIptc.pData_, rawIptc.size_, byteOrder_);
@@ -443,10 +464,11 @@ namespace Exiv2 {
 
     void TiffEncoder::encodeXmp()
     {
-        const ExifKey xmpKey("Exif.Image.XMLPacket");
+        ExifKey xmpKey("Exif.Image.XMLPacket");
         // Remove any existing XMP Exif tag
         ExifData::iterator pos = exifData_.findKey(xmpKey);
         if (pos != exifData_.end()) {
+            xmpKey.setIdx(pos->idx());
             exifData_.erase(pos);
         }
         std::string xmpPacket;
@@ -604,11 +626,19 @@ namespace Exiv2 {
         ExifData::iterator pos = exifData_.end();
         const Exifdatum* ed = datum;
         if (ed == 0) {
+            // Attempting non-intrusive writing. Look for the corresponding Exif
+            // datum by index rather than the key to be able to handle duplicate tags.
+            pos = std::find_if(exifData_.begin(), exifData_.end(),
+                               FindExifdatumByIdx(object->idx()));
             ExifKey key(object->tag(), tiffGroupName(object->group()));
-            pos = exifData_.findKey(key);
-            if (pos == exifData_.end()) { // metadatum not found (deleted)
+            if (pos == exifData_.end() || key.key() != pos->key()) {
 #ifdef DEBUG
-                std::cerr << "DELETING          " << key << "
";
+                if (pos == exifData_.end()) { // metadatum not found
+                    std::cerr << "DELETING          " << key << ", idx = " << object->idx() << "
";
+                }
+                else {
+                    std::cerr << "KEY/IDX MISMATCH  " << key << ", idx = " << object->idx() << "
";
+                }
 #endif
                 setDirty();
             }
@@ -792,7 +822,7 @@ namespace Exiv2 {
         ExifKey key(object->tag(), tiffGroupName(object->group()));
         std::cerr << "UPDATING DATA     " << key;
         if (tooLarge) {
-            std::cerr << "			 ALLOCATED " << object->size_ << " BYTES";
+            std::cerr << "			 ALLOCATED " << std::dec << object->size_ << " BYTES";
         }
 #endif
     } // TiffEncoder::encodeTiffEntryBase
@@ -1003,7 +1033,8 @@ namespace Exiv2 {
           pLast_(pData + size),
           pRoot_(pRoot),
           pState_(state.release()),
-          pOrigState_(pState_)
+          pOrigState_(pState_),
+          idxSeq_(0)
     {
         assert(pData_);
         assert(size_ > 0);
@@ -1109,6 +1140,11 @@ namespace Exiv2 {
         return false;
     }
 
+    int TiffReader::nextIdx()
+    {
+        return ++idxSeq_;
+    }
+
     void TiffReader::visitDirectory(TiffDirectory* object)
     {
         assert(object != 0);
@@ -1387,6 +1423,7 @@ namespace Exiv2 {
         object->setValue(v);
         object->setData(pData, size);
         object->setOffset(offset);
+        object->setIdx(nextIdx());
 
     } // TiffReader::readTiffEntry
 
@@ -1443,6 +1480,7 @@ namespace Exiv2 {
         object->setValue(v);
         object->setData(pData, size);
         object->setOffset(0);
+        object->setIdx(nextIdx());
         object->setCount(1);
 
     } // TiffReader::visitArrayElement
diff --git a/src/tiffvisitor_int.hpp b/src/tiffvisitor_int.hpp
index cea2860..7141621 100644
--- a/src/tiffvisitor_int.hpp
+++ b/src/tiffvisitor_int.hpp
@@ -615,6 +615,8 @@ namespace Exiv2 {
         void resetState();
         //! Check IFD directory pointer \em start for circular reference
         bool circularReference(const byte* start, uint16_t group);
+        //! Return the next idx sequence number
+        int nextIdx();
         //@}
 
         //! @name Accessors
@@ -639,6 +641,7 @@ namespace Exiv2 {
         TiffRwState*         pState_;     //!< State class
         TiffRwState*         pOrigState_; //!< State class as set in the c'tor
         DirList              dirList_;    //!< List of IFD pointers and their groups
+        int                  idxSeq_;     //!< Sequence used for the entry's idx
 
     }; // class TiffReader
 

-- 
exiv2 packaging



More information about the pkg-kde-commits mailing list