[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:50 UTC 2017


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

The following commit has been merged in the master branch:
commit b7c90140c7b4c021672e0f0756a8b01ca49009c5
Author: Robin Mills <robin at clanmills.com>
Date:   Thu Sep 1 16:44:29 2016 +0000

    #1074 ICC support in jpgimage.cpp.  Add test/icc-test.sh
---
 Makefile               |  13 ++++---
 config/Makefile.in     |  13 ++++---
 src/jpgimage.cpp       | 102 ++++++++++++++++++++++++++++++-------------------
 test/Makefile          |   1 +
 test/data/big.icc      | Bin 0 -> 1613600 bytes
 test/data/icc-test.out |  72 ++++++++++++++++++++++++++++++++++
 test/data/small.icc    | Bin 0 -> 3144 bytes
 test/icc-test.sh       |  49 ++++++++++++++++++++++++
 8 files changed, 200 insertions(+), 50 deletions(-)

diff --git a/Makefile b/Makefile
index dafad45..662b41b 100644
--- a/Makefile
+++ b/Makefile
@@ -87,13 +87,13 @@ teste testx testv:
 	cd test && $(MAKE) $@
 
 # convenience for running individual tests
-bugfixes-test.sh   crw-test.sh     curliotest.sh    eps-preview-test.sh    eps-test.sh       exifdata-test.sh \
-exiv2-test.sh      httpiotest.sh   imagetest.sh     iotest.sh              iptctest.sh       modify-test.sh \
-path-test.sh       preview-test.sh sshiotest.sh     stringto-test.sh       tiff-test.sh      video-test.sh \
-write-test.sh      write-video-test.sh              write2-test.sh         xmpparser-test.sh webp-test.sh:
+bugfixes-test.sh   crw-test.sh     curliotest.sh       eps-preview-test.sh    eps-test.sh       exifdata-test.sh \
+exiv2-test.sh      httpiotest.sh   icc-test.sh         imagetest.sh           iotest.sh         iptctest.sh      \
+modify-test.sh     path-test.sh    preview-test.sh     sshiotest.sh           stringto-test.sh  tiff-test.sh     \
+video-test.sh      write-test.sh   write-video-test.sh write2-test.sh         xmpparser-test.sh webp-test.sh:
 	cd test && ./$@
 
-# convenience targets for running bugfixes-test.sh webp-test.sh and preview-test.sh
+# convenience targets for running selected test scripts
 bugtest bugstest testbugs bugfixes:
 	cd test && ./bugfixes-test.sh
 
@@ -103,6 +103,9 @@ webp-test webptest:
 preview-test preview:
 	cd test && ./preview-test.sh
 
+icc-test icc:
+	cd test && ./icc-test.sh
+
 # convenience target for building individual sample programs
 addmoddel		exifcomment		exifvalue	httptest	iptctest		mmap-test	stringto-test \
 exifdata		iotest			key-test	path-test	taglist			write2-test write-test	\
diff --git a/config/Makefile.in b/config/Makefile.in
index dafad45..662b41b 100644
--- a/config/Makefile.in
+++ b/config/Makefile.in
@@ -87,13 +87,13 @@ teste testx testv:
 	cd test && $(MAKE) $@
 
 # convenience for running individual tests
-bugfixes-test.sh   crw-test.sh     curliotest.sh    eps-preview-test.sh    eps-test.sh       exifdata-test.sh \
-exiv2-test.sh      httpiotest.sh   imagetest.sh     iotest.sh              iptctest.sh       modify-test.sh \
-path-test.sh       preview-test.sh sshiotest.sh     stringto-test.sh       tiff-test.sh      video-test.sh \
-write-test.sh      write-video-test.sh              write2-test.sh         xmpparser-test.sh webp-test.sh:
+bugfixes-test.sh   crw-test.sh     curliotest.sh       eps-preview-test.sh    eps-test.sh       exifdata-test.sh \
+exiv2-test.sh      httpiotest.sh   icc-test.sh         imagetest.sh           iotest.sh         iptctest.sh      \
+modify-test.sh     path-test.sh    preview-test.sh     sshiotest.sh           stringto-test.sh  tiff-test.sh     \
+video-test.sh      write-test.sh   write-video-test.sh write2-test.sh         xmpparser-test.sh webp-test.sh:
 	cd test && ./$@
 
-# convenience targets for running bugfixes-test.sh webp-test.sh and preview-test.sh
+# convenience targets for running selected test scripts
 bugtest bugstest testbugs bugfixes:
 	cd test && ./bugfixes-test.sh
 
@@ -103,6 +103,9 @@ webp-test webptest:
 preview-test preview:
 	cd test && ./preview-test.sh
 
+icc-test icc:
+	cd test && ./icc-test.sh
+
 # convenience target for building individual sample programs
 addmoddel		exifcomment		exifvalue	httptest	iptctest		mmap-test	stringto-test \
 exifdata		iotest			key-test	path-test	taglist			write2-test write-test	\
diff --git a/src/jpgimage.cpp b/src/jpgimage.cpp
index 8b50ac8..e1c4c3b 100644
--- a/src/jpgimage.cpp
+++ b/src/jpgimage.cpp
@@ -103,6 +103,16 @@ namespace Exiv2 {
     const uint16_t Photoshop::iptc_    = 0x0404;
     const uint16_t Photoshop::preview_ = 0x040c;
 
+    static inline bool inRange(int lo,int value, int hi)
+    {
+    	return lo<=value && value <= hi;
+    }
+
+    static inline bool inRange2(int value,int lo1,int hi1, int lo2,int hi2)
+    {
+    	return inRange(lo1,value,hi1) || inRange(lo2,value,hi2);
+    }
+
     bool Photoshop::isIrb(const byte* pPsData,
                           long        sizePsData)
     {
@@ -345,7 +355,7 @@ namespace Exiv2 {
             throw Error(15);
         }
         clearMetadata();
-        int search = 6;
+        int search = 6 ; // Exif, ICC, XMP, Comment, IPTC, SOF
         const long bufMinSize = 36;
         long bufRead = 0;
         DataBuf buf(bufMinSize);
@@ -453,19 +463,19 @@ namespace Exiv2 {
                 --search;
             }
             else if ( marker == app2_ && memcmp(buf.pData_ + 2, iccId_,11)==0) {
-                // Seek to beginning and read the iccProfile
-                io_->seek(31 - bufRead, BasicIo::cur);
-                DataBuf iccProfile(size);
-                io_->read(iccProfile.pData_, iccProfile.size_);
-                if (io_->error() || io_->eof()) throw Error(14);
-                foundIccData = true; // set a flag, we'll collect the profile later
+            	// skip the profile, we'll recover it later.
+            	if ( ! foundIccData  ) {
+            		foundIccData = true ;
+            		--search ;
+            	}
+                if (io_->seek(size - bufRead, BasicIo::cur)) throw Error(14);
+#ifdef DEBUG
+				int chunk  = (int) buf.pData_[2+12];
+				int chunks = (int) buf.pData_[2+13];
+                std::cerr << "Found ICC Profile chunk " << chunk <<" of "<<  chunks << "
";
+#endif
             }
-            else if (   pixelHeight_ == 0
-                     && (   marker == sof0_  || marker == sof1_  || marker == sof2_
-                         || marker == sof3_  || marker == sof5_  || marker == sof6_
-                         || marker == sof7_  || marker == sof9_  || marker == sof10_
-                         || marker == sof11_ || marker == sof13_ || marker == sof14_
-                         || marker == sof15_)) {
+            else if (  pixelHeight_ == 0 && inRange2(marker,sof0_,sof3_,sof5_,sof15_) ) {
                 // We hit a SOFn (start-of-frame) marker
                 if (size < 8) {
                     rc = 7;
@@ -526,6 +536,7 @@ namespace Exiv2 {
         if ( rc==0 && foundIccData ) {
         	long restore = io_->tell();
         	std::stringstream binary( std::ios_base::out | std::ios_base::in | std::ios_base::binary );
+            io_->seek(0,Exiv2::BasicIo::beg);
         	printStructure(binary,kpsIccProfile,0);
         	long length = (long) binary.rdbuf()->pubseekoff(0, binary.end, binary.out);
         	DataBuf iccProfile(length);
@@ -881,9 +892,10 @@ namespace Exiv2 {
         int comPos = 0;
         int skipApp1Exif = -1;
         int skipApp1Xmp = -1;
-        int skipApp2IccProfile = -1;
         bool foundCompletePsData = false;
+        bool foundIccData        = false;
         std::vector<int> skipApp13Ps3;
+        std::vector<int> skipApp2Icc;
         int skipCom = -1;
         Blob psBlob;
         DataBuf rawExif;
@@ -898,7 +910,7 @@ namespace Exiv2 {
         // First find segments of interest. Normally app0 is first and we want
         // to insert after it. But if app0 comes after com, app1 and app13 then
         // don't bother.
-        while (marker != sos_ && marker != eoi_ && search < 5) {
+        while (marker != sos_ && marker != eoi_ && search < 6) {
             // Read size and signature (ok if this hits EOF)
             bufRead = io_->read(buf.pData_, bufMinSize);
             if (io_->error()) throw Error(20);
@@ -927,10 +939,13 @@ namespace Exiv2 {
                 ++search;
                 if (io_->seek(size-bufRead, BasicIo::cur)) throw Error(22);
             }
-            else if (   skipApp2IccProfile == -1 && marker == app2_) {
+            else if ( marker == app2_ && memcmp(buf.pData_ + 2, iccId_, 11)== 0 ) {
                 if (size < 31) throw Error(22);
-                skipApp2IccProfile = count;
-                ++search;
+                skipApp2Icc.push_back(count);
+                if ( !foundIccData ) {
+                	++search;
+                	foundIccData = true ;
+                }
                 if (io_->seek(size-bufRead, BasicIo::cur)) throw Error(22);
             }
             else if (   !foundCompletePsData
@@ -969,20 +984,7 @@ namespace Exiv2 {
             // This (a) causes the new comment to appear after, rather than before,
             // existing comments; and (b) ensures that comments come after any JFIF
             // or JFXX markers, as required by the JFIF specification.
-            if (   comPos == 0
-                && (   marker == sof0_
-                    || marker == sof1_
-                    || marker == sof2_
-                    || marker == sof3_
-                    || marker == sof5_
-                    || marker == sof6_
-                    || marker == sof7_
-                    || marker == sof9_
-                    || marker == sof10_
-                    || marker == sof11_
-                    || marker == sof13_
-                    || marker == sof14_
-                    || marker == sof15_)) {
+            if (   comPos == 0 && inRange2(marker,sof0_,sof3_,sof5_,sof15_) ) {
                 comPos = count;
                 ++search;
             }
@@ -992,7 +994,7 @@ namespace Exiv2 {
         }
 
         if (!foundCompletePsData && psBlob.size() > 0) throw Error(22);
-        search += (int) skipApp13Ps3.size();
+        search += (int) skipApp13Ps3.size() + (int) skipApp2Icc.size();
 
         if (comPos == 0) {
             if (marker == eoi_) comPos = count;
@@ -1084,20 +1086,39 @@ namespace Exiv2 {
                     if (outIo.error()) throw Error(21);
                     --search;
                 }
+
                 if (iccProfile_.size_ > 0) {
                     // Write APP2 marker, size of APP2 field, and IccProfile
                     tmpBuf[0] = 0xff;
                     tmpBuf[1] = app2_;
 
-                    if (iccProfile_.size_ > 0xffff) throw Error(37, "IccProfile");
-                    us2Data(tmpBuf + 2, static_cast<uint16_t>(iccProfile_.size_), bigEndian);
-                    if (outIo.write(tmpBuf, 4) != 4) throw Error(21);
-
-                    // Write new iccProfile
-                    if ( outIo.write(iccProfile_.pData_,iccProfile_.size_) != static_cast<long>(iccProfile_.size_) ) throw Error(21);
-                    if ( outIo.error() ) throw Error(21);
+                    int       chunk_size = 256*256-18 ; // leave bytes for marker and header
+                    int       size       = (int) iccProfile_.size_   ;
+                    int       chunks     = 1 + (size-1) / chunk_size ;
+                    if (iccProfile_.size_ > 256*chunk_size) throw Error(37, "IccProfile");
+                    for ( int chunk = 0 ; chunk < chunks ; chunk ++ ) {
+                        int bytes   = size > chunk_size ? chunk_size : size  ; // bytes to write
+                        size       -= bytes ;
+
+                        // write JPEG marker (2 bytes)
+                        us2Data(tmpBuf + 2, 16 + bytes, bigEndian);
+                        if (outIo.write(tmpBuf, 4) != 4) throw Error(21); // JPEG Marker
+
+                        // write the ICC_PROFILE header (16 bytes)
+                        char pad[4];
+                        pad[0] = chunk+1;
+                        pad[1] = chunks;
+                        pad[2] = 0;
+                        pad[3] = 0;
+                        outIo.write((const byte *) iccId_, ::strlen(iccId_) + 1);
+                        outIo.write((const byte *) pad, sizeof(pad));
+                        if (outIo.write(iccProfile_.pData_+ (chunk*chunk_size), bytes) != bytes)
+                            throw Error(21);
+                        if (outIo.error()) throw Error(21);
+                    }
                     --search;
                 }
+
                 if (foundCompletePsData || iptcData_.count() > 0) {
                     // Set the new IPTC IRB, keeps existing IRBs but removes the
                     // IPTC block if there is no new IPTC data to write
@@ -1163,6 +1184,7 @@ namespace Exiv2 {
             else if (   skipApp1Exif == count
                      || skipApp1Xmp  == count
                      || std::find(skipApp13Ps3.begin(), skipApp13Ps3.end(), count) != skipApp13Ps3.end()
+                     || std::find(skipApp2Icc.begin() , skipApp2Icc.end(),  count) != skipApp2Icc.end()
                      || skipCom      == count) {
                 --search;
                 io_->seek(size-bufRead, BasicIo::cur);
diff --git a/test/Makefile b/test/Makefile
index aeb4725..1434a77 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -68,6 +68,7 @@ TESTS  = addmoddel.sh         \
          exifdata-test.sh     \
          exiv2-test.sh        \
          imagetest.sh         \
+         icc-test.sh          \
          iotest.sh            \
          iptctest.sh          \
          iso65k-test.sh       \
diff --git a/test/data/big.icc b/test/data/big.icc
new file mode 100644
index 0000000..ed4a6b3
Binary files /dev/null and b/test/data/big.icc differ
diff --git a/test/data/icc-test.out b/test/data/icc-test.out
new file mode 100644
index 0000000..9093c09
--- /dev/null
+++ b/test/data/icc-test.out
@@ -0,0 +1,72 @@
+STRUCTURE OF JPEG FILE: Reagan.jpg
+ address | marker     | length  | data
+       2 | 0xd8 SOI   |       0 
+       4 | 0xe0 APP0  |      16 | JFIF.....,.,....
+      22 | 0xe1 APP1  |    5671 | Exif..MM.*......................
+    5695 | 0xed APP13 |    9594 | Photoshop 3.0.8BIM..........Z...
+   15291 | 0xe1 APP1  |    7062 | http://ns.adobe.com/xap/1.0/.<?x
+   22355 | 0xe2 APP2  |    3160 | ICC_PROFILE......HLino....mntrRG chunk 1/1
+   25517 | 0xee APP14 |      14 | Adobe.d at ......
+   25533 | 0xdb DQT   |     132 
+   25667 | 0xc0 SOF0  |      17 
+   25686 | 0xdd DRI   |       4 
+   25692 | 0xc4 DHT   |     418 
+   26112 | 0xda SOS   |      12 
+STRUCTURE OF JPEG FILE: Reagan.jpg
+ address | marker     | length  | data
+       2 | 0xd8 SOI   |       0 
+       4 | 0xe0 APP0  |      16 | JFIF.....,.,....
+      22 | 0xe1 APP1  |    5658 | Exif..MM.*......................
+    5682 | 0xe1 APP1  |    7024 | http://ns.adobe.com/xap/1.0/.<?x
+   12708 | 0xe2 APP2  |   65534 | ICC_PROFILE........ APPL....prtr chunk 1/25
+   78246 | 0xe2 APP2  |   65534 | ICC_PROFILE.....o.S...r.R...t.RT chunk 2/25
+  143784 | 0xe2 APP2  |   65534 | ICC_PROFILE.........o..b.tn..Q.K chunk 3/25
+  209322 | 0xe2 APP2  |   65534 | ICC_PROFILE.......n.....l>...... chunk 4/25
+  274860 | 0xe2 APP2  |   65534 | ICC_PROFILE.....W8w;.QY2w$.gZ.wY chunk 5/25
+  340398 | 0xe2 APP2  |   65534 | ICC_PROFILE.....Y1...]W.j....QlT chunk 6/25
+  405936 | 0xe2 APP2  |   65534 | ICC_PROFILE......ik.....j;....h. chunk 7/25
+  471474 | 0xe2 APP2  |   65534 | ICC_PROFILE.....a.r2GRW.M...Y.MX chunk 8/25
+  537012 | 0xe2 APP2  |   65534 | ICC_PROFILE.....`...bs]...dDZ7.b chunk 9/25
+  602550 | 0xe2 APP2  |   65534 | ICC_PROFILE.....d.}...f.z...hRv. chunk 10/25
+  668088 | 0xe2 APP2  |   65534 | ICC_PROFILE.......y+...^yy....y. chunk 11/25
+  733626 | 0xe2 APP2  |   65534 | ICC_PROFILE......v.-i.....kN...< chunk 12/25
+  799164 | 0xe2 APP2  |   65534 | ICC_PROFILE......'Z.....M.....>. chunk 13/25
+  864702 | 0xe2 APP2  |   65534 | ICC_PROFILE..................... chunk 14/25
+  930240 | 0xe2 APP2  |   65534 | ICC_PROFILE........D..........". chunk 15/25
+  995778 | 0xe2 APP2  |   65534 | ICC_PROFILE.......V[*+..7.,G..'. chunk 16/25
+ 1061316 | 0xe2 APP2  |   65534 | ICC_PROFILE......Z...G.....C.... chunk 17/25
+ 1126854 | 0xe2 APP2  |   65534 | ICC_PROFILE......2yg.Te....VG... chunk 18/25
+ 1192392 | 0xe2 APP2  |   65534 | ICC_PROFILE..................... chunk 19/25
+ 1257930 | 0xe2 APP2  |   65534 | ICC_PROFILE.....1.0.285.0.373.0. chunk 20/25
+ 1323468 | 0xe2 APP2  |   65534 | ICC_PROFILE.....0.260.0.271.0.27 chunk 21/25
+ 1389006 | 0xe2 APP2  |   65534 | ICC_PROFILE.....39.0.145.0.150.0 chunk 22/25
+ 1454544 | 0xe2 APP2  |   65534 | ICC_PROFILE......0.051.0.060.0.0 chunk 23/25
+ 1520082 | 0xe2 APP2  |   65534 | ICC_PROFILE......0.743.0.788.0.8 chunk 24/25
+ 1585620 | 0xe2 APP2  |   41184 | ICC_PROFILE......452.0.452.0.464 chunk 25/25
+ 1626808 | 0xed APP13 |    9594 | Photoshop 3.0.8BIM..........Z...
+ 1636404 | 0xee APP14 |      14 | Adobe.d at ......
+ 1636420 | 0xdb DQT   |     132 
+ 1636554 | 0xc0 SOF0  |      17 
+ 1636573 | 0xdd DRI   |       4 
+ 1636579 | 0xc4 DHT   |     418 
+ 1636999 | 0xda SOS   |      12 
+STRUCTURE OF JPEG FILE: Reagan.jpg
+ address | marker     | length  | data
+       2 | 0xd8 SOI   |       0 
+       4 | 0xe0 APP0  |      16 | JFIF.....,.,....
+      22 | 0xe1 APP1  |    5658 | Exif..MM.*......................
+    5682 | 0xe1 APP1  |    7024 | http://ns.adobe.com/xap/1.0/.<?x
+   12708 | 0xe2 APP2  |    3160 | ICC_PROFILE........HLino....mntr chunk 1/1
+   15872 | 0xed APP13 |    9594 | Photoshop 3.0.8BIM..........Z...
+   25468 | 0xee APP14 |      14 | Adobe.d at ......
+   25484 | 0xdb DQT   |     132 
+   25618 | 0xc0 SOF0  |      17 
+   25637 | 0xdd DRI   |       4 
+   25643 | 0xc4 DHT   |     418 
+   26063 | 0xda SOS   |      12 
+md5: reagan1_.icc: No such file or directory
+md5: reagan2_.icc: No such file or directory
+md5: small1_.icc: No such file or directory
+md5: small2_.icc: No such file or directory
+md5: big1_.icc: No such file or directory
+md5: big2_.icc: No such file or directory
diff --git a/test/data/small.icc b/test/data/small.icc
new file mode 100644
index 0000000..7f9d18d
Binary files /dev/null and b/test/data/small.icc differ
diff --git a/test/icc-test.sh b/test/icc-test.sh
new file mode 100755
index 0000000..7475de2
--- /dev/null
+++ b/test/icc-test.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+# Test driver for webp
+
+source ./functions.source
+
+(   cd "$testdir"
+
+    num=1074                    # ICC Profile Support
+    printf "ICC " >&3
+    printf "jpg " >&3
+    filename=Reagan.jpg
+    iccname_=Reagan.icc
+
+    copyTestFiles big.icc small.icc     $filename
+    runTest exiv2 -pS                   $filename
+    runTest exiv2 -pC                   $filename > reagan_1.icc
+    runTest exiv2 -eC --force           $filename
+            mv                          $iccname_   reagan_2.icc
+
+    copyTestFile          big.icc       $iccname_
+    runTest exiv2 -iC                   $filename
+    runTest exiv2 -pC                   $filename > big_1.icc
+    runTest exiv2 -pS                   $filename
+    runTest exiv2 -eC --force           $filename
+            mv                          $iccname_   big_2.icc
+
+
+    copyTestFile          small.icc     $iccname_
+    runTest exiv2 -iC                   $filename
+    runTest exiv2 -pC                   $filename > small_.icc
+    runTest exiv2 -pS                   $filename
+    runTest exiv2 -eC --force           $filename
+            mv                          $iccname_   small_2.icc
+
+	for f in reagan small big; do for i in 1 2; do
+      md5 ${f}${i}_.icc
+    done ; done
+
+) 3>&1 > $results 2>&1
+
+printf "
"
+
+# ----------------------------------------------------------------------
+# Evaluate results
+cat $results | sed 's/\x0d$//' > $results-stripped
+reportTest $results-stripped $good
+
+# That's all Folks!
+##

-- 
exiv2 packaging



More information about the pkg-kde-commits mailing list