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

Maximiliano Curia maxy at moszumanska.debian.org
Thu Jul 13 17:46:36 UTC 2017


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

The following commit has been merged in the master branch:
commit bcd455be7a9b7258903e46f2c62d413e648971b5
Author: Robin Mills <robin at clanmills.com>
Date:   Thu Aug 11 10:12:25 2016 +0000

    #1199  Patch from Ben.  http://dev.exiv2.org/issues/1199#note-37
---
 include/exiv2/webpimage.hpp |   3 +-
 src/webpimage.cpp           | 150 +++++++++++++++++++++++++++++++++++++-------
 2 files changed, 128 insertions(+), 25 deletions(-)

diff --git a/include/exiv2/webpimage.hpp b/include/exiv2/webpimage.hpp
index a2f59cd..f1306b3 100644
--- a/include/exiv2/webpimage.hpp
+++ b/include/exiv2/webpimage.hpp
@@ -94,7 +94,8 @@ namespace Exiv2 {
         bool equalsWebPTag(Exiv2::DataBuf& buf ,const char* str);
         void decodeChunks(uint64_t filesize);
         void inject_VP8X(BasicIo& iIo, bool has_xmp, bool has_exif,
-                         bool has_alpha, bool has_icc);
+                         bool has_alpha, bool has_icc, int width,
+                         int height);
 
         //! Copy constructor
         WebPImage(const WebPImage& rhs);
diff --git a/src/webpimage.cpp b/src/webpimage.cpp
index e66ef77..1795cd6 100644
--- a/src/webpimage.cpp
+++ b/src/webpimage.cpp
@@ -120,19 +120,22 @@ namespace Exiv2 {
 
         io_->read(data, TAG_SIZE * 3);
         uint64_t filesize = Exiv2::getULong(data + 4, littleEndian);
-        // uint64_t endoffile = 12;
 
         /* Set up header */
         if (outIo.write(data, TAG_SIZE * 3) != TAG_SIZE * 3)
             throw Error(21);
 
         /* Parse Chunks */
+        bool has_size = false;
         bool has_xmp = false;
         bool has_exif = false;
         bool has_vp8x = false;
         bool has_alpha = false;
         bool has_icc = false;
 
+        int height;
+        int width;
+
         byte size_buff[4];
         std::string xmpData;
         Blob blob;
@@ -176,37 +179,117 @@ namespace Exiv2 {
                 uint64_t size = Exiv2::getULong(size_buff, littleEndian);
                 DataBuf payload(size);
                 io_->read(payload.pData_, payload.size_);
+
+                /* Chunk with color profile. */
                 if (equalsWebPTag(chunkId, "ICCP") && !has_alpha) {
                     has_icc = true;
                 }
-                if (equalsWebPTag(chunkId, "VP8X")) {
+
+                /* Chunk with information about features
+                   used in the file. */
+                if (equalsWebPTag(chunkId, "VP8X") && !has_vp8x) {
                     has_vp8x = true;
                 }
-#if 0 // May need to verify for alpha for these chunks in the future
-                if (equalsWebPTag(chunkId, "VP8 ") && !has_alpha) {
-                    has_alpha = true;
+                if (equalsWebPTag(chunkId, "VP8X") && !has_size) {
+                    has_size = true;
+                    byte size_buf[4];
+
+                    // Fetch width
+                    memcpy(&size_buf, &payload.pData_[4], 3);
+                    size_buf[3] = 0;
+                    width = Exiv2::getULong(size_buf, littleEndian) + 1;
+
+                    // Fetch height
+                    memcpy(&size_buf, &payload.pData_[7], 3);
+                    size_buf[3] = 0;
+                    height = Exiv2::getULong(size_buf, littleEndian) + 1;
                 }
+
+                /* Chunk with with animation control data. */
+#ifdef __CHECK_FOR_ALPHA__  // Maybe in the future
                 if (equalsWebPTag(chunkId, "ANIM") && !has_alpha) {
                     has_alpha = true;
                 }
 #endif
+
+                /* Chunk with with lossy image data. */
+#ifdef __CHECK_FOR_ALPHA__ // Maybe in the future
+                if (equalsWebPTag(chunkId, "VP8 ") && !has_alpha) {
+                    has_alpha = true;
+                }
+#endif
+                if (equalsWebPTag(chunkId, "VP8 ") && !has_size) {
+                    has_size = true;
+                    byte size_buf[4];
+
+                    // Fetch width
+                    memcpy(&size_buf, &payload.pData_[6], 2);
+                    size_buf[2] = 0;
+                    size_buf[3] = 0;
+                    width = Exiv2::getULong(size_buf, littleEndian) & 0x3fff;
+
+                    // Fetch height
+                    memcpy(&size_buf, &payload.pData_[8], 2);
+                    size_buf[2] = 0;
+                    size_buf[3] = 0;
+                    height = Exiv2::getULong(size_buf, littleEndian) & 0x3fff;
+                }
+
+                /* Chunk with with lossless image data. */
                 if (equalsWebPTag(chunkId, "VP8L") && !has_alpha) {
                     if ((payload.pData_[5] & 0x10) == 0x10) {
                       has_alpha = true;
                     }
                 }
+                if (equalsWebPTag(chunkId, "VP8L") && !has_size) {
+                    has_size = true;
+                    byte size_buf_w[2];
+                    byte size_buf_h[3];
+
+                    // Fetch width
+                    memcpy(&size_buf_w, &payload.pData_[1], 2);
+                    size_buf_w[1] &= 0x3F;
+                    width = Exiv2::getUShort(size_buf_w, littleEndian) + 1;
+
+                    // Fetch height
+                    memcpy(&size_buf_h, &payload.pData_[2], 3);
+                    size_buf_h[0] = ((size_buf_h[0] >> 6) & 0x3) | ((size_buf_h[1] & 0x3F) << 0x2);
+                    size_buf_h[1] = ((size_buf_h[1] >> 6) & 0x3) | ((size_buf_h[2] & 0xF) << 0x2);
+                    height = Exiv2::getUShort(size_buf_h, littleEndian) + 1;
+                }
+
+                /* Chunk with animation frame. */
                 if (equalsWebPTag(chunkId, "ANMF") && !has_alpha) {
                     if ((payload.pData_[5] & 0x2) == 0x2) {
                       has_alpha = true;
                     }
                 }
+                if (equalsWebPTag(chunkId, "ANMF") && !has_size) {
+                    has_size = true;
+                    byte size_buf[4];
+
+                    // Fetch width
+                    memcpy(&size_buf, &payload.pData_[6], 3);
+                    size_buf[3] = 0;
+                    width = Exiv2::getULong(size_buf, littleEndian) + 1;
+
+                    // Fetch height
+                    memcpy(&size_buf, &payload.pData_[9], 3);
+                    size_buf[3] = 0;
+                    height = Exiv2::getULong(size_buf, littleEndian) + 1;
+                }
+
+                /* Chunk with alpha data. */
                 if (equalsWebPTag(chunkId, "ALPH") && !has_alpha) {
                     has_alpha = true;
                 }
             }
 
+            std::cout << "VP8X res. size [" << width << "x" << height << "]
";
+            /* Inject a VP8X chunk if one isn't available. */
             if (!has_vp8x) {
-                inject_VP8X(outIo, has_xmp, has_exif, has_alpha, has_icc);
+                inject_VP8X(outIo, has_xmp, has_exif, has_alpha,
+                            has_icc, width, height);
             }
         }
 
@@ -272,24 +355,24 @@ namespace Exiv2 {
             offset = io_->tell();
 
             // Check for extra 

-- 
exiv2 packaging



More information about the pkg-kde-commits mailing list