[Pkg-phototools-commits] [SCM] openimageio branch, upstream, updated. upstream/1.1.3+dfsg0-2-g46e86ea

Matteo F. Vescovi mfv.debian at gmail.com
Thu Jan 31 16:39:48 UTC 2013


The following commit has been merged in the upstream branch:
commit 46e86ea57bcd7bdd74c103d89728b577cb931e12
Author: Matteo F. Vescovi <mfv.debian at gmail.com>
Date:   Thu Jan 31 17:26:44 2013 +0100

    Imported Upstream version 1.1.5+dfsg0

diff --git a/CHANGES b/CHANGES
index 0a0ee2b..ebb2394 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,16 @@
 Changes:
 
 
+Release 1.1.5 (29 Jan 2013)
+---------------------------
+* Bug fix in ImageBufAlgo::parallel_image utility template -- care when
+  not enough work chunks to dole out to all the threads (was previously
+  sending work to threads with nonsensical ROI's, now we just stop when
+  all the regions have been doled out).
+* Additional optional argument to IBA::zover that, when nonzero, will
+  treat z=0 pixels as infinitely far away, not super close.  You can turn
+  this on from oiiotool with:  oiiotool --zover:zeroisinf=1 ...
+
 Release 1.1.4 (27 Jan 2013)
 ---------------------------
 * ImageBufAlgo::make_texture() allows you to do the same thing that
@@ -12,6 +22,7 @@ Release 1.1.4 (27 Jan 2013)
 * oiiotool --zover does z (depth) composites (it's like a regular "over",
   but uses the z depth at each pixel to determine which of the two images
   is the foreground and which is the background).
+* ImageBufAlgo::zover() performs z compositing (same as oiiotool --zover).
 * ImageBufAlgo::fixNonFinite didn't work properly with 'half' image buffers.
 * Performance improvements when reading and writing images.
 * Fix error when writing tiled 'float' TIFF images, corrupted output.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d0b2849..42523b4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -3,7 +3,7 @@ project (OpenImageIO)
 # Release version of the library
 set (OIIO_VERSION_MAJOR 1)
 set (OIIO_VERSION_MINOR 1)
-set (OIIO_VERSION_PATCH 4)
+set (OIIO_VERSION_PATCH 5)
 
 cmake_minimum_required (VERSION 2.6)
 if (NOT CMAKE_VERSION VERSION_LESS 2.8.4)
diff --git a/src/doc/oiiotool.tex b/src/doc/oiiotool.tex
index 47c0826..fe7c510 100644
--- a/src/doc/oiiotool.tex
+++ b/src/doc/oiiotool.tex
@@ -738,7 +738,15 @@ Porter/Duff ``over'' composite, but each pixel individually will choose
 which of the two images is the foreground and which background, depending on
 the ``Z'' channel values for that pixel (larger Z means farther away).
 Both input images must have the same number and order of channels
-and must contain both depth/Z and alpha channels.
+and must contain both depth/Z and alpha channels. Optional appended arguments
+include:
+
+\begin{tabular}{p{10pt} p{1in} p{3.5in}}
+  & {\cf zeroisinf=}\emph{num} & If nonzero, indicates that $z=0$ pixels
+  should be treated as if they were infinitely far away. (The default is
+  0, meaning that ``zero means zero.'').
+\end{tabular}
+
 \apiend
 
 \apiitem{--flip}
diff --git a/src/doc/openimageio.tex b/src/doc/openimageio.tex
index dd0fae4..2f2a299 100644
--- a/src/doc/openimageio.tex
+++ b/src/doc/openimageio.tex
@@ -85,7 +85,7 @@
 \date{{\large 
 %Editor: Larry Gritz \\[2ex]
 Date: 18 Nov, 2012
-\\ (with corrections, 25 Jan 2013)
+\\ (with corrections, 29 Jan 2013)
 }}
 
 
diff --git a/src/include/imagebufalgo.h b/src/include/imagebufalgo.h
index 829c0aa..afbc3a7 100644
--- a/src/include/imagebufalgo.h
+++ b/src/include/imagebufalgo.h
@@ -368,10 +368,16 @@ bool OIIO_API over (ImageBuf &R, const ImageBuf &A, const ImageBuf &B,
 /// Just like ImageBufAlgo::over(), but inputs A and B must have
 /// designated 'z' channels, and on a pixel-by-pixel basis, the z values
 /// will determine which of A or B will be considered the foreground or
-/// background (lower z is foreground).
+/// background (lower z is foreground).  If z_zeroisinf is true, then
+/// z=0 values will be treated as if they are infinitely far away.
 bool OIIO_API zover (ImageBuf &R, const ImageBuf &A, const ImageBuf &B,
+                     bool z_zeroisinf = false,
                      ROI roi = ROI(), int threads = 0);
 
+/// DEPRECATED -- preserved for link compatibility, but will be removed.
+bool OIIO_API zover (ImageBuf &R, const ImageBuf &A, const ImageBuf &B,
+                     ROI roi, int threads = 0);
+
 
 /// Render a text string into image R, essentially doing an "over" of
 /// the character into the existing pixel data.  The baseline of the
@@ -580,6 +586,8 @@ parallel_image (Func f, ROI roi, int nthreads=0)
         for (int i = 0;  i < nthreads;  i++) {
             roi.ybegin = roi_ybegin + i * blocksize;
             roi.yend = std::min (roi.ybegin + blocksize, roi_yend);
+            if (roi.ybegin >= roi.yend)
+                break;   // no more work to dole out
             threads.add_thread (new boost::thread (f, roi));
         }
         threads.join_all ();
diff --git a/src/libOpenImageIO/imagebufalgo.cpp b/src/libOpenImageIO/imagebufalgo.cpp
index f4d598a..961c787 100644
--- a/src/libOpenImageIO/imagebufalgo.cpp
+++ b/src/libOpenImageIO/imagebufalgo.cpp
@@ -1279,7 +1279,7 @@ decode_over_channels (const ImageBuf &R, int &nchannels,
 template<class Rtype, class Atype, class Btype>
 static bool
 over_impl (ImageBuf &R, const ImageBuf &A, const ImageBuf &B, ROI roi,
-           bool zcomp=false)
+           bool zcomp=false, bool z_zeroisinf=false)
 {
     if (R.spec().format != BaseTypeFromC<Rtype>::value ||
         A.spec().format != BaseTypeFromC<Atype>::value ||
@@ -1303,29 +1303,39 @@ over_impl (ImageBuf &R, const ImageBuf &A, const ImageBuf &B, ROI roi,
         a.pos (r.x(), r.y(), r.z());
         b.pos (r.x(), r.y(), r.z());
 
-        if (! a.valid()) {
-            if (! b.valid()) {
-                // a and b are both invalid -- make it an "empty" pixel
+        if (! a.exists()) {
+            if (! b.exists()) {
+                // a and b outside their data window -- "empty" pixels
                 for (int c = 0; c < nchannels; c++)
                     r[c] = 0.0f;
             } else {
-                // a invalid, b valid -- copy B
+                // a doesn't exist, but b does -- copy B
                 for (int c = 0; c < nchannels; ++c)
                     r[c] = b[c];
             }
             continue;
         }
 
-        if (! b.valid()) {
-            // a valid, b invalid -- copy A
+        if (! b.exists()) {
+            // a exists, b does not -- copy A
             for (int c = 0; c < nchannels; ++c)
                 r[c] = a[c];
             continue;
         }
 
-        // At this point, a and b are valid.
-
-        if (!zcomp || a[z_channel] <= b[z_channel]) {
+        // At this point, a and b exist.
+        float az = 0.0f, bz = 0.0f;
+        bool a_is_closer = true;  // will remain true if !zcomp
+        if (zcomp && has_z) {
+            az = a[z_channel];
+            bz = b[z_channel];
+            if (z_zeroisinf) {
+                if (az == 0.0f) az = std::numeric_limits<float>::max();
+                if (bz == 0.0f) bz = std::numeric_limits<float>::max();
+            }
+            a_is_closer = (az <= bz);
+        }
+        if (a_is_closer) {
             // A over B
             float alpha = clamp (a[alpha_channel], 0.0f, 1.0f);
             float one_minus_alpha = 1.0f - alpha;
@@ -1414,7 +1424,7 @@ ImageBufAlgo::over (ImageBuf &R, const ImageBuf &A, const ImageBuf &B, ROI roi,
         roi = get_roi (R.spec());
 
     parallel_image (boost::bind (over_impl<float,float,float>, boost::ref(R),
-                                 boost::cref(A), boost::cref(B), _1, false),
+                                 boost::cref(A), boost::cref(B), _1, false, false),
                     roi, nthreads);
     return ! R.has_error();
 }
@@ -1423,7 +1433,7 @@ ImageBufAlgo::over (ImageBuf &R, const ImageBuf &A, const ImageBuf &B, ROI roi,
 
 bool
 ImageBufAlgo::zover (ImageBuf &R, const ImageBuf &A, const ImageBuf &B,
-                     ROI roi, int nthreads)
+                     bool z_zeroisinf, ROI roi, int nthreads)
 {
     const ImageSpec &specR = R.spec();
     const ImageSpec &specA = A.spec();
@@ -1491,13 +1501,26 @@ ImageBufAlgo::zover (ImageBuf &R, const ImageBuf &A, const ImageBuf &B,
         roi = get_roi (R.spec());
 
     parallel_image (boost::bind (over_impl<float,float,float>, boost::ref(R),
-                                 boost::cref(A), boost::cref(B), _1, true),
+                                 boost::cref(A), boost::cref(B), _1,
+                                 true, z_zeroisinf),
                     roi, nthreads);
     return ! R.has_error();
 }
 
 
 
+bool
+ImageBufAlgo::zover (ImageBuf &R, const ImageBuf &A, const ImageBuf &B,
+                     ROI roi, int nthreads)
+{
+    // DEPRECATED version -- just call the new version.  This exists to 
+    // avoid breaking link compatibility.  Eventually remove it at the
+    // next major release.
+    return zover (R, A, B, false, roi, nthreads);
+}
+
+
+
 #ifdef USE_FREETYPE
 namespace { // anon
 static mutex ft_mutex;
diff --git a/src/oiiotool/oiiotool.cpp b/src/oiiotool/oiiotool.cpp
index 0f8438c..424d52b 100644
--- a/src/oiiotool/oiiotool.cpp
+++ b/src/oiiotool/oiiotool.cpp
@@ -1637,6 +1637,16 @@ action_zover (int argc, const char *argv[])
     if (ot.postpone_callback (2, action_over, argc, argv))
         return 0;
 
+    // Get optional flags
+    bool z_zeroisinf = false;
+    std::string cmd = argv[0];
+    size_t pos;
+    while ((pos = cmd.find_first_of(":")) != std::string::npos) {
+        cmd = cmd.substr (pos+1, std::string::npos);
+        if (Strutil::istarts_with(cmd,"zeroisinf="))
+            z_zeroisinf = (atoi(cmd.c_str()+10) != 0);
+    }
+
     ImageRecRef B (ot.pop());
     ImageRecRef A (ot.pop());
     ot.read (A);
@@ -1653,7 +1663,7 @@ action_zover (int argc, const char *argv[])
     ot.push (new ImageRec ("zover", specR, ot.imagecache));
     ImageBuf &Rib ((*ot.curimg)());
 
-    bool ok = ImageBufAlgo::zover (Rib, Aib, Bib);
+    bool ok = ImageBufAlgo::zover (Rib, Aib, Bib, z_zeroisinf);
     if (! ok)
         ot.error (argv[0], Rib.geterror());
     return 0;
@@ -1933,18 +1943,18 @@ getargs (int argc, char *argv[])
                 "--hardwarn %g", &ot.diff_hardwarn, "Warn if any one pixel difference exceeds this error (infinity)",
                 "<SEPARATOR>", "Actions:",
                 "--create %@ %s %d", action_create, NULL, NULL,
-                        "Create a blank image (args: geom, channels)",
+                        "Create a blank image (optional args: geom, channels)",
                 "--pattern %@ %s %s %d", action_pattern, NULL, NULL, NULL,
-                        "Create a patterned image (args: pattern, geom, channels)",
+                        "Create a patterned image (optional args: pattern, geom, channels)",
                 "--capture %@", action_capture, NULL,
-                        "Capture an image (args: camera=%%d)",
+                        "Capture an image (optional args: camera=%d)",
                 "--diff %@", action_diff, NULL, "Print report on the difference of two images (modified by --fail, --failpercent, --hardfail, --warn, --warnpercent --hardwarn)",
                 "--add %@", action_add, NULL, "Add two images",
                 "--sub %@", action_sub, NULL, "Subtract two images",
                 "--abs %@", action_abs, NULL, "Take the absolute value of the image pixels",
                 "--over %@", action_over, NULL, "'Over' composite of two images",
-                "--zover %@", action_zover, NULL, "Depth composite two images with Z channels",
-                "--histogram %@ %s %d", action_histogram, NULL, NULL, "Histogram one channel (args: cumulative=0)",
+                "--zover %@", action_zover, NULL, "Depth composite two images with Z channels (optional args: zeroisinf=%d)",
+                "--histogram %@ %s %d", action_histogram, NULL, NULL, "Histogram one channel (optional args: cumulative=0)",
                 "--flip %@", action_flip, NULL, "Flip the image vertically (top<->bottom)",
                 "--flop %@", action_flop, NULL, "Flop the image horizontally (left<->right)",
                 "--flipflop %@", action_flipflop, NULL, "Flip and flop the image (180 degree rotation)",

-- 
OpenImageIO packaging



More information about the Pkg-phototools-commits mailing list