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

Maximiliano Curia maxy at moszumanska.debian.org
Thu Jul 13 17:37:43 UTC 2017


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

The following commit has been merged in the master branch:
commit 707b8e8dc0ec172540b856d26ede624ec763d785
Author: Andreas Huggel <ahuggel at gmx.net>
Date:   Sun Jun 4 15:21:19 2006 +0000

    New TIFF parser: Extract TIFF thumbnail from IFD1 if there is one.
---
 src/ifd.cpp           | 18 +++++++++++---
 src/tiffcomposite.cpp | 20 ---------------
 src/tiffcomposite.hpp | 20 ++++++++++++---
 src/tiffparser.cpp    |  6 +++--
 src/tiffvisitor.cpp   | 68 ++++++++++++++++++++++++++++++---------------------
 src/tiffvisitor.hpp   |  7 ++++++
 6 files changed, 81 insertions(+), 58 deletions(-)

diff --git a/src/ifd.cpp b/src/ifd.cpp
index 11066ee..1f4001f 100644
--- a/src/ifd.cpp
+++ b/src/ifd.cpp
@@ -193,17 +193,25 @@ namespace Exiv2 {
 
     void Entry::setDataAreaOffsets(uint32_t offset, ByteOrder byteOrder)
     {
+        // Hack: Do not require offsets to start from 0, except for rationals
+        uint16_t  fusOffset = 0;
+        uint32_t  fulOffset = 0;
+        int16_t   fsOffset  = 0;
+        int32_t   flOffset  = 0;
+
         for (uint32_t i = 0; i < count(); ++i) {
             byte* buf = pData_ + i * typeSize();
             switch(TypeId(type())) {
             case unsignedShort: {
-                uint16_t d = getUShort(buf, byteOrder);
+                if (i == 0) fusOffset = getUShort(buf, byteOrder);
+                uint16_t d = getUShort(buf, byteOrder) - fusOffset;
                 if (d + offset > 0xffff) throw Error(26);
                 us2Data(buf, d + static_cast<uint16_t>(offset), byteOrder);
                 break;
             }
             case unsignedLong: {
-                ul2Data(buf, getULong(buf, byteOrder) + offset, byteOrder);
+                if (i == 0) fulOffset = getULong(buf, byteOrder);
+                ul2Data(buf, getULong(buf, byteOrder) - fulOffset + offset, byteOrder);
                 break;
             }
             case unsignedRational: {
@@ -213,13 +221,15 @@ namespace Exiv2 {
                 break;
             }
             case signedShort: {
-                int16_t d = getShort(buf, byteOrder);
+                if (i == 0) fsOffset = getShort(buf, byteOrder);
+                int16_t d = getShort(buf, byteOrder) - fsOffset;
                 if (d + static_cast<int32_t>(offset) > 0xffff) throw Error(26);
                 s2Data(buf, d + static_cast<int16_t>(offset), byteOrder);
                 break;
             }
             case signedLong: {
-                int32_t d = getLong(buf, byteOrder);
+                if (i == 0) flOffset = getLong(buf, byteOrder);
+                int32_t d = getLong(buf, byteOrder) - flOffset;
                 l2Data(buf, d + static_cast<int32_t>(offset), byteOrder);
                 break;
             }
diff --git a/src/tiffcomposite.cpp b/src/tiffcomposite.cpp
index d78d7ad..5d78e6f 100644
--- a/src/tiffcomposite.cpp
+++ b/src/tiffcomposite.cpp
@@ -294,24 +294,4 @@ namespace Exiv2 {
                                                       ts->newGroup_));
     }
 
-    TiffComponent::AutoPtr newTiffThumbData(uint16_t tag,
-                                            const TiffStructure* ts)
-    {
-        assert(ts);
-        return TiffComponent::AutoPtr(new TiffDataEntry(tag,
-                                                        ts->group_,
-                                                        0x0202,
-                                                        Group::ifd1));
-    }
-
-    TiffComponent::AutoPtr newTiffThumbSize(uint16_t tag,
-                                            const TiffStructure* ts)
-    {
-        assert(ts);
-        return TiffComponent::AutoPtr(new TiffSizeEntry(tag,
-                                                        ts->group_,
-                                                        0x0201,
-                                                        Group::ifd1));
-    }
-
 }                                       // namespace Exiv2
diff --git a/src/tiffcomposite.hpp b/src/tiffcomposite.hpp
index 0565d11..0dd6788 100644
--- a/src/tiffcomposite.hpp
+++ b/src/tiffcomposite.hpp
@@ -606,13 +606,25 @@ namespace Exiv2 {
         return newTiffArrayElement<typeId, invalidByteOrder>(tag, ts);
     }
 
-    //! Function to create and initialize a new TIFF entry for a Jpeg thumbnail (data)
+    //! Function to create and initialize a new TIFF entry for a thumbnail (data)
+    template<uint16_t szTag, uint16_t szGroup>
     TiffComponent::AutoPtr newTiffThumbData(uint16_t tag,
-                                            const TiffStructure* ts);
+                                            const TiffStructure* ts)
+    {
+        assert(ts);
+        return TiffComponent::AutoPtr(
+            new TiffDataEntry(tag, ts->group_, szTag, szGroup));
+    }
 
-    //! Function to create and initialize a new TIFF entry for a Jpeg thumbnail (size)
+    //! Function to create and initialize a new TIFF entry for a thumbnail (size)
+    template<uint16_t dtTag, uint16_t dtGroup>
     TiffComponent::AutoPtr newTiffThumbSize(uint16_t tag,
-                                            const TiffStructure* ts);
+                                            const TiffStructure* ts)
+    {
+        assert(ts);
+        return TiffComponent::AutoPtr(
+            new TiffSizeEntry(tag, ts->group_, dtTag, dtGroup));
+    }
 
 }                                       // namespace Exiv2
 
diff --git a/src/tiffparser.cpp b/src/tiffparser.cpp
index 4f63c74..e2c3255 100644
--- a/src/tiffparser.cpp
+++ b/src/tiffparser.cpp
@@ -100,8 +100,10 @@ namespace Exiv2 {
         {    0x8825, Group::ifd0,      newTiffSubIfd,        Group::gps     },
         {    0xa005, Group::exif,      newTiffSubIfd,        Group::iop     },
         {    0x927c, Group::exif,      newTiffMnEntry,       Group::mn      },
-        {    0x0201, Group::ifd1,      newTiffThumbData,     Group::ifd1    },
-        {    0x0202, Group::ifd1,      newTiffThumbSize,     Group::ifd1    },
+        {    0x0111, Group::ifd1,      newTiffThumbData<0x0117, Group::ifd1>, Group::ifd1 },
+        {    0x0117, Group::ifd1,      newTiffThumbSize<0x0111, Group::ifd1>, Group::ifd1 },
+        {    0x0201, Group::ifd1,      newTiffThumbData<0x0202, Group::ifd1>, Group::ifd1 },
+        {    0x0202, Group::ifd1,      newTiffThumbSize<0x0201, Group::ifd1>, Group::ifd1 },
         { Tag::next, Group::ifd0,      newTiffDirectory,     Group::ifd1    },
         { Tag::next, Group::ifd1,      newTiffDirectory,     Group::ignr    },
         { Tag::next, Group::ignr,      newTiffDirectory,     Group::ignr    },
diff --git a/src/tiffvisitor.cpp b/src/tiffvisitor.cpp
index 81ac80d..b61bca4 100644
--- a/src/tiffvisitor.cpp
+++ b/src/tiffvisitor.cpp
@@ -493,22 +493,8 @@ namespace Exiv2 {
         pRoot_->accept(finder);
         TiffEntryBase* te = dynamic_cast<TiffEntryBase*>(finder.result());
         if (te && te->pValue()) {
-            long size = te->pValue()->toLong();
-            long offset = object->pValue()->toLong();
-            if (baseOffset() + offset + size <= size_) {
-                object->pValue_->setDataArea(pData_ + baseOffset() + offset, size);
-            }
-#ifndef SUPPRESS_WARNINGS
-            else {
-                std::cerr << "Warning: "
-                          << "Directory " << object->groupName()
-                          << ", entry 0x" << std::setw(4)
-                          << std::setfill('0') << std::hex << object->tag()
-                          << " Data area exceeds data buffer, ignoring it.
";
-            }
-#endif
+            setDataArea(object, te->pValue());
         }
-
     }
 
     void TiffReader::visitSizeEntry(TiffSizeEntry* object)
@@ -520,22 +506,48 @@ namespace Exiv2 {
         pRoot_->accept(finder);
         TiffEntryBase* te = dynamic_cast<TiffEntryBase*>(finder.result());
         if (te && te->pValue()) {
-            long offset = te->pValue()->toLong();
-            long size = object->pValue()->toLong();
-            if (baseOffset() + offset + size <= size_) {
-                te->pValue_->setDataArea(pData_ + baseOffset() + offset, size);
-            }
+            setDataArea(te, object->pValue());
+        }
+    }
+
+    void TiffReader::setDataArea(TiffEntryBase* pOffsetEntry, const Value* pSize)
+    {
+        assert(pOffsetEntry);
+        assert(pSize);
+
+        Value* pOffset = pOffsetEntry->pValue_;
+        assert(pOffset);
+
+        long size = 0;
+        for (long i = 0; i < pSize->count(); ++i) {
+            size += pSize->toLong(i);
+        }
+        long offset = pOffset->toLong(0);
+        // Todo: Remove limitation of Jpeg writer: strips must be contiguous
+        // Until then we check: last offset + last size - first offset == size?
+        if (  pOffset->toLong(pOffset->count()-1) 
+            + pSize->toLong(pSize->count()-1)
+            - offset != size) {
 #ifndef SUPPRESS_WARNINGS
-            else {
-                std::cerr << "Warning: "
-                          << "Directory " << object->groupName()
-                          << ", entry 0x" << std::setw(4)
-                          << std::setfill('0') << std::hex << object->tag()
-                          << " Data area exceeds data buffer, ignoring it.
";
-            }
+            std::cerr << "Warning: "
+                      << "Directory " << pOffsetEntry->groupName()
+                      << ", entry 0x" << std::setw(4)
+                      << std::setfill('0') << std::hex << pOffsetEntry->tag()
+                      << " Data area is not contiguous, ignoring it.
";
+#endif
+            return;
+        }
+        if (baseOffset() + offset + size > size_) {
+#ifndef SUPPRESS_WARNINGS
+            std::cerr << "Warning: "
+                      << "Directory " << pOffsetEntry->groupName()
+                      << ", entry 0x" << std::setw(4)
+                      << std::setfill('0') << std::hex << pOffsetEntry->tag()
+                      << " Data area exceeds data buffer, ignoring it.
";
 #endif
+            return;
         }
-
+        pOffset->setDataArea(pData_ + baseOffset() + offset, size);
     }
 
     void TiffReader::visitDirectory(TiffDirectory* object)
diff --git a/src/tiffvisitor.hpp b/src/tiffvisitor.hpp
index 7bb5822..422cb81 100644
--- a/src/tiffvisitor.hpp
+++ b/src/tiffvisitor.hpp
@@ -432,6 +432,13 @@ namespace Exiv2 {
         //@}
 
     private:
+        //! @name Manipulators
+        //@{
+        //! Helper function to set the thumbnail data area
+        void setDataArea(TiffEntryBase* pOffsetEntry, const Value* pSize);
+        //@}
+
+    private:
         // DATA
         const byte*          pData_;      //!< Pointer to the memory buffer
         const uint32_t       size_;       //!< Size of the buffer

-- 
exiv2 packaging



More information about the pkg-kde-commits mailing list